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

The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 

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”