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

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-MakingThomas Teepe
 
How to Create an Editorial Calendar
How to Create an Editorial CalendarHow to Create an Editorial Calendar
How to Create an Editorial CalendarTim Slavin
 
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 IndustryVaibhav Nautiyal
 
Treatment of waste from pulp industry
Treatment of waste from pulp industryTreatment of waste from pulp industry
Treatment of waste from pulp industryprarthana mary
 
All about paper making process
All about paper making processAll about paper making process
All about paper making processSakshi Vashist
 
Pulp and Paper industry
Pulp and Paper industryPulp and Paper industry
Pulp and Paper industryArun Sarasan
 
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 FriendsStacy Kvernmo
 

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

Designing True Cross-Platform Apps
Designing True Cross-Platform AppsDesigning True Cross-Platform Apps
Designing True Cross-Platform AppsFITC
 
Webapp Rendering and Optimization.
Webapp Rendering and Optimization.Webapp Rendering and Optimization.
Webapp Rendering and Optimization.arthurjamain
 
Masterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsMasterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsFabian Jakobs
 
Famo.us introduction
Famo.us introductionFamo.us introduction
Famo.us introductionAllen Wu
 
Women Who Code, Ground Floor
Women Who Code, Ground FloorWomen Who Code, Ground Floor
Women Who Code, Ground FloorKatie Weiss
 
Browsers. Magic is inside.
Browsers. Magic is inside.Browsers. Magic is inside.
Browsers. Magic is inside.Devexperts
 
Chrome Internals: Paint and Composition
Chrome Internals: Paint and CompositionChrome Internals: Paint and Composition
Chrome Internals: Paint and CompositionDzmitry 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
 
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 Webphilogb
 
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)Daniel Friedman
 
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 timeEinar Ingebrigtsen
 
Expert guide for PHP
Expert guide for PHPExpert guide for PHP
Expert guide for PHPSteve Fort
 
Trendsetting: Web Design and Beyond
Trendsetting: Web Design and BeyondTrendsetting: Web Design and Beyond
Trendsetting: Web Design and BeyondAndy Stratton
 
Web components, so close!
Web components, so close!Web components, so close!
Web components, so close!Aleks Zinevych
 
Performance and scalability with drupal
Performance and scalability with drupalPerformance and scalability with drupal
Performance and scalability with drupalRonan Berder
 
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 AzureBrian Lyttle
 

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

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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.pptxEarley Information Science
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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 organizationRadu Cotescu
 
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 Takeoffsammart93
 
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?Antenna Manufacturer Coco
 
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 MenDelhi Call girls
 
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 MenDelhi Call girls
 
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...Miguel Araújo
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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 MenDelhi Call girls
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
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 FresherRemote DBA Services
 
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 productivityPrincipled Technologies
 
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 AutomationSafe Software
 

Recently uploaded (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
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
 
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
 
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
 
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...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
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
 
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
 

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”