The Pipeline from Markup to Graphics
Parsing
|
|
Content tree (DOM tree)
CSS
rule |
selector |
{ |
declarations |
} |
.panel-content h3 |
{ |
font-weight: bold; letter-spacing: -0.03em |
} |
CSS Cascade
- User-Agent (ua.css, html.css, forms.css, etc.)
- User (preferences, userContent.css, addons)
- Author (web page)
Two halves of the CSS code
- Specified style
- Computed style
Both halves of the code are in layout/style/
.
The Pipeline from Markup to Graphics
The Layout part of the pipeline
Frame tree (rendering tree)
Layout debugger
Frame tree
display:none | nothing |
display:block | nsBlockFrame |
display:inline | nsInlineFrame |
display:table | nsTableOuterFrame and nsTableFrame |
display:block; overflow:auto | nsGfxScrollFrame and nsBlockFrame |
float:left or position:absolute or ... | nsPlaceholderFrame and nsBlockFrame |
The Pipeline from Markup to Graphics
Optimization
- Unoptimized
- Redo everything for any DOM/style change
- Optimizations
- Skip entire steps
- Skip part of a step
- Coalesce changes
Unoptimized (alternative view)
Redo everything for every paint or request from script
Optimizations can and do change
Layout
- Style computation
- Frame construction
- Reflow
- Painting
Style Computation
layout/style/
- Implements CSS up to the computed value
- But CSS also defines behavior for properties, not just computed values
Frame construction
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsFrameManager.cpp
- Create style context, then create frame
- Manage dynamic changes
Reflow
- Compute positions of frames
- intrinsic width computation is separate
- Part of the frame classes (
layout/generic/
, etc.)
Painting
- layers and display lists
- Display lists:
nsIFrame::BuildDisplayList
- Also used for event targeting