SlideShare a Scribd company logo
1 of 26
Download to read offline
about:layout

jmi@mozilla.com
Browser Basics




* Borrowed from Douglas Crockford’s Lecture on “Theory of DOM”
Browser Basics

                                                     •   The Browser has an event-
                                                         driven, single-threaded,
                                                         asynchronous programming
                                                         model.




* Borrowed from Douglas Crockford’s Lecture on “Theory of DOM”
Browser Tasks
•   Loading

•   Parsing

•   Script Execution

•   Layout

•   Style Resolution

•   Paint
                       * Picture comes from the IE blog introducing hardware acc

•   Event Handling
Layout
   Input   ?   Output
Layout
   Input   Layout   Output
Layout
   Input         Layout         Output




           where things go on
           the screen / paper
Layout
   Input         Layout         Output




           where things go on
           the screen / paper
Terms
•   DOM Tree

•   Style System



•   Layout jobs:

    •   Frames

    •   Reflow
Terms
•   DOM Tree

•   Style System



•   Layout jobs:

    •   Frames

    •   Reflow
Basic Flows
Frames
         •   An encapsulation of a region on the
             screen;
         •   A region that contains geometry,
             e.g. size, location, stacking order;
         •   1..* correspondence between
             content elements and frames;
         •   Got style contexts from Style
             System;
Frames
                                     <p>
                                      We need documentation for users, web developers, and
                                      developers working on Mozilla. Much of the existing
                                      code <b>isn’t very well documented</b>. In the process


•
                                      of figuring things out, try and document your discoveries.
    Frames are RECTANGLEs.           </p>



•   Block vs Line (inline)
    •   BLOCK is composed of 1..* LINEs.
    •   LINE is a single row of text or other presentational elements.
    •   Width of BLOCK changed, contents of LINEs must be
        reformatted.
Frame Tree              <div border=”10” padding=”20”>
                              <p>what fox has jumped ... ? </p>
•   Root Frame (<html>)     </div>

•   nsIFrame, nsFrame ...
                                         Root Frame




                                            Div Frame




                                            what fox ...
Frame Tree              <div border=”10” padding=”20”>
                              <p>what fox has jumped ... ? </p>
•   Root Frame (<html>)     </div>

•   nsIFrame, nsFrame ...
                                         Root Frame




                                            Div Frame




                                            what fox ...
Reflow
•   After Frames are created, “REFLOW” them to format!
•   REFLOW is the process by which the GEOMETRY of the layout
    engine’s formatting objects are COMPUTED.
    •   Geometry: x, y, w, h
    •   Computed hierarchically.
•   HTML uses a flow based layout model,
    •   left-right, top-bottom, 1 pass
    •   out-of-flow: floats, absolute positioned, ...
    •   Table: more than 1 pass
Reflow, How?                          <div border=”10” padding=”20”>
                                            <p>what fox has jumped ... ? </p>
                                          </div>


                Root Frame                        •   Reflow State:
                                                      • Constrained info about
Reflow State                       Reflow Metrics         parent frames;
                                                      • passed to child frames
                  Div Frame
                                                  •   Reflow Metrics:
                                                      • to send geo info back
                                                      •
  Reflow State                   Reflow Metrics
                                                        dimension of child
                 what fox ...
Reflow, When?
•   Initial page load

•   Browser window resize

•   DOM nodes added or removed

    •   div.appendChild(p) ...

•   Layout styles applied

    •   element.style.height = ‘100px’;

    •   element.style.display = ‘block’;
Reflow is simple, right?
                 Nope.
Incremental Reflow
                                                   DOM Coming

•   Goal: create parts of presentation, rather
    than waiting for entire doc

    •   Resolve Style                                 Resolve Style


    •   Create Frame

    •   Layout Frame
                                                                      Layout Frame

                                             Create Frame
•   In-flow vs. Out-of-flow
Dyn Changes to DOM
•   to manage dynamic changes to the content model after doc is loaded
    and presented

    •   content elements add, remove, modified

    •   frames add, remove, modified

    •   incremental reflow

    •   queued and processed async
After reflow: PAINT
                                                            •   Widgets

                                                            •   Views manager paints
                                                                views back-to-front

                                                            •   walk from view to the
                                                                frame, invoke
                                                                nsIFrame::Paint per layer


* Picture comes from the IE blog introducing hardware acc
Summary
•   Imagine them all as rectangles

•   Think the web pages layout as the canvas, web devs are painting on it,
    we are controlling not controlled.

•   Try to keep things neat and in-flow (Floats vs clear)

•   Thinking in layout: all box model and geometry (rectangle again)

•   Practice more, embrace the tools (Firebug) and community

•   Fire bugs to browsers makers, :)
Summary of Summary
Summary of Summary


        Rectangles
Questions & Discussion



References:
“gecko reflow layout site:developer.mozilla.org”

More Related Content

Viewers also liked

Treatment of waste from pulp industry
Treatment of waste from pulp industryTreatment of waste from pulp industry
Treatment of waste from pulp industry
prarthana mary
 

Viewers also liked (11)

How to Think on Paper - Ideas on Note-Making
How to Think on Paper - Ideas on Note-MakingHow to Think on Paper - Ideas on Note-Making
How to Think on Paper - Ideas on Note-Making
 
How to Create an Editorial Calendar
How to Create an Editorial CalendarHow to Create an Editorial Calendar
How to Create an Editorial Calendar
 
Water Pollution Control in Pulp and Paper Industry
Water Pollution Control in Pulp and Paper IndustryWater Pollution Control in Pulp and Paper Industry
Water Pollution Control in Pulp and Paper Industry
 
Treatment of waste from pulp industry
Treatment of waste from pulp industryTreatment of waste from pulp industry
Treatment of waste from pulp industry
 
Advertising
AdvertisingAdvertising
Advertising
 
Paper n pulp industries
Paper n pulp industries Paper n pulp industries
Paper n pulp industries
 
All about paper making process
All about paper making processAll about paper making process
All about paper making process
 
Pulp and Paper industry
Pulp and Paper industryPulp and Paper industry
Pulp and Paper industry
 
Paper Making Process by Nirjhar
Paper Making Process by NirjharPaper Making Process by Nirjhar
Paper Making Process by Nirjhar
 
Engineering Drawing
Engineering DrawingEngineering Drawing
Engineering Drawing
 
The Great State of Design with CSS Grid Layout and Friends
The Great State of Design with CSS Grid Layout and FriendsThe Great State of Design with CSS Grid Layout and Friends
The Great State of Design with CSS Grid Layout and Friends
 

Similar to About Layout in Firefox

Chrome Internals: Paint and Composition
Chrome Internals: Paint and CompositionChrome Internals: Paint and Composition
Chrome Internals: Paint and Composition
Dzmitry Varabei
 
Talk Paris Infovis 091207132953 Phpapp01(2)
Talk Paris Infovis 091207132953 Phpapp01(2)Talk Paris Infovis 091207132953 Phpapp01(2)
Talk Paris Infovis 091207132953 Phpapp01(2)
johnnybiz
 
Performance and scalability with drupal
Performance and scalability with drupalPerformance and scalability with drupal
Performance and scalability with drupal
Ronan Berder
 

Similar to About Layout in Firefox (20)

Designing True Cross-Platform Apps
Designing True Cross-Platform AppsDesigning True Cross-Platform Apps
Designing True Cross-Platform Apps
 
Webapp Rendering and Optimization.
Webapp Rendering and Optimization.Webapp Rendering and Optimization.
Webapp Rendering and Optimization.
 
Masterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsMasterin Large Scale Java Script Applications
Masterin Large Scale Java Script Applications
 
Psd 2 Drupal
Psd 2 DrupalPsd 2 Drupal
Psd 2 Drupal
 
Famo.us introduction
Famo.us introductionFamo.us introduction
Famo.us introduction
 
Women Who Code, Ground Floor
Women Who Code, Ground FloorWomen Who Code, Ground Floor
Women Who Code, Ground Floor
 
Browsers. Magic is inside.
Browsers. Magic is inside.Browsers. Magic is inside.
Browsers. Magic is inside.
 
Chrome Internals: Paint and Composition
Chrome Internals: Paint and CompositionChrome Internals: Paint and Composition
Chrome Internals: Paint and Composition
 
Talk Paris Infovis 091207132953 Phpapp01(2)
Talk Paris Infovis 091207132953 Phpapp01(2)Talk Paris Infovis 091207132953 Phpapp01(2)
Talk Paris Infovis 091207132953 Phpapp01(2)
 
Using Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the WebUsing Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the Web
 
Getting started with dev tools (4/10/17 DC)
Getting started with dev tools (4/10/17 DC)Getting started with dev tools (4/10/17 DC)
Getting started with dev tools (4/10/17 DC)
 
Sugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a timeSugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a time
 
Fluent 2012 v2
Fluent 2012   v2Fluent 2012   v2
Fluent 2012 v2
 
Expert guide for PHP
Expert guide for PHPExpert guide for PHP
Expert guide for PHP
 
Trendsetting: Web Design and Beyond
Trendsetting: Web Design and BeyondTrendsetting: Web Design and Beyond
Trendsetting: Web Design and Beyond
 
Web components, so close!
Web components, so close!Web components, so close!
Web components, so close!
 
Performance and scalability with drupal
Performance and scalability with drupalPerformance and scalability with drupal
Performance and scalability with drupal
 
JS Essence
JS EssenceJS Essence
JS Essence
 
Building Mobile Web Apps with jQM and Cordova on Azure
Building Mobile Web Apps with jQM and Cordova on AzureBuilding Mobile Web Apps with jQM and Cordova on Azure
Building Mobile Web Apps with jQM and Cordova on Azure
 
2011 05-jszurich
2011 05-jszurich2011 05-jszurich
2011 05-jszurich
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

About Layout in Firefox

  • 2. Browser Basics * Borrowed from Douglas Crockford’s Lecture on “Theory of DOM”
  • 3. Browser Basics • The Browser has an event- driven, single-threaded, asynchronous programming model. * Borrowed from Douglas Crockford’s Lecture on “Theory of DOM”
  • 4. Browser Tasks • Loading • Parsing • Script Execution • Layout • Style Resolution • Paint * Picture comes from the IE blog introducing hardware acc • Event Handling
  • 5. Layout Input ? Output
  • 6. Layout Input Layout Output
  • 7. Layout Input Layout Output where things go on the screen / paper
  • 8. Layout Input Layout Output where things go on the screen / paper
  • 9. Terms • DOM Tree • Style System • Layout jobs: • Frames • Reflow
  • 10. Terms • DOM Tree • Style System • Layout jobs: • Frames • Reflow
  • 12. Frames • An encapsulation of a region on the screen; • A region that contains geometry, e.g. size, location, stacking order; • 1..* correspondence between content elements and frames; • Got style contexts from Style System;
  • 13. Frames <p> We need documentation for users, web developers, and developers working on Mozilla. Much of the existing code <b>isn’t very well documented</b>. In the process • of figuring things out, try and document your discoveries. Frames are RECTANGLEs. </p> • Block vs Line (inline) • BLOCK is composed of 1..* LINEs. • LINE is a single row of text or other presentational elements. • Width of BLOCK changed, contents of LINEs must be reformatted.
  • 14. Frame Tree <div border=”10” padding=”20”> <p>what fox has jumped ... ? </p> • Root Frame (<html>) </div> • nsIFrame, nsFrame ... Root Frame Div Frame what fox ...
  • 15. Frame Tree <div border=”10” padding=”20”> <p>what fox has jumped ... ? </p> • Root Frame (<html>) </div> • nsIFrame, nsFrame ... Root Frame Div Frame what fox ...
  • 16. Reflow • After Frames are created, “REFLOW” them to format! • REFLOW is the process by which the GEOMETRY of the layout engine’s formatting objects are COMPUTED. • Geometry: x, y, w, h • Computed hierarchically. • HTML uses a flow based layout model, • left-right, top-bottom, 1 pass • out-of-flow: floats, absolute positioned, ... • Table: more than 1 pass
  • 17. Reflow, How? <div border=”10” padding=”20”> <p>what fox has jumped ... ? </p> </div> Root Frame • Reflow State: • Constrained info about Reflow State Reflow Metrics parent frames; • passed to child frames Div Frame • Reflow Metrics: • to send geo info back • Reflow State Reflow Metrics dimension of child what fox ...
  • 18. Reflow, When? • Initial page load • Browser window resize • DOM nodes added or removed • div.appendChild(p) ... • Layout styles applied • element.style.height = ‘100px’; • element.style.display = ‘block’;
  • 19. Reflow is simple, right? Nope.
  • 20. Incremental Reflow DOM Coming • Goal: create parts of presentation, rather than waiting for entire doc • Resolve Style Resolve Style • Create Frame • Layout Frame Layout Frame Create Frame • In-flow vs. Out-of-flow
  • 21. Dyn Changes to DOM • to manage dynamic changes to the content model after doc is loaded and presented • content elements add, remove, modified • frames add, remove, modified • incremental reflow • queued and processed async
  • 22. After reflow: PAINT • Widgets • Views manager paints views back-to-front • walk from view to the frame, invoke nsIFrame::Paint per layer * Picture comes from the IE blog introducing hardware acc
  • 23. Summary • Imagine them all as rectangles • Think the web pages layout as the canvas, web devs are painting on it, we are controlling not controlled. • Try to keep things neat and in-flow (Floats vs clear) • Thinking in layout: all box model and geometry (rectangle again) • Practice more, embrace the tools (Firebug) and community • Fire bugs to browsers makers, :)
  • 25. Summary of Summary Rectangles
  • 26. Questions & Discussion References: “gecko reflow layout site:developer.mozilla.org”