| OLD | NEW |
| 1 # `Source/core/paint` | 1 # `Source/core/paint` |
| 2 | 2 |
| 3 This directory contains implementation of painters of layout objects. | 3 This directory contains implementation of painters of layout objects. |
| 4 | 4 |
| 5 ## Stacked contents and stacking contexts | 5 ## Glossaries |
| 6 |
| 7 ### Stacked elements and stacking contexts |
| 6 | 8 |
| 7 This chapter is basically a clarification of [CSS 2.1 appendix E. Elaborate desc
ription | 9 This chapter is basically a clarification of [CSS 2.1 appendix E. Elaborate desc
ription |
| 8 of Stacking Contexts](http://www.w3.org/TR/CSS21/zindex.html). | 10 of Stacking Contexts](http://www.w3.org/TR/CSS21/zindex.html). |
| 9 | 11 |
| 12 Note: we use 'element' instead of 'object' in this chapter to keep consistency w
ith |
| 13 the spec. We use 'object' in other places in this document. |
| 14 |
| 10 According to the documentation, we can have the following types of elements that
are | 15 According to the documentation, we can have the following types of elements that
are |
| 11 treated in different ways during painting: | 16 treated in different ways during painting: |
| 12 | 17 |
| 13 * Stacked elements: elements that are z-ordered in stacking contexts. | 18 * Stacked objects: objects that are z-ordered in stacking contexts, including: |
| 14 | 19 |
| 15 * Stacking contexts: elements with non-auto z-indices. | 20 * Stacking contexts: elements with non-auto z-indices. |
| 16 | 21 |
| 17 * Elements that are not real stacking contexts but are treated as stacking | 22 * Elements that are not real stacking contexts but are treated as stacking |
| 18 contexts but don't manage other stacked elements. Their z-ordering are | 23 contexts but don't manage other stacked elements. Their z-ordering are |
| 19 managed by real stacking contexts. They are positioned elements with | 24 managed by real stacking contexts. They are positioned elements with |
| 20 `z-index: auto` (E.2.8 in the documentation). | 25 `z-index: auto` (E.2.8 in the documentation). |
| 21 | 26 |
| 22 They must be managed by the enclosing stacking context as stacked elemen
ts | 27 They must be managed by the enclosing stacking context as stacked elemen
ts |
| 23 because `z-index:auto` and `z-index:0` are considered equal for stacking | 28 because `z-index:auto` and `z-index:0` are considered equal for stacking |
| (...skipping 24 matching lines...) Expand all Loading... |
| 48 * [grid items](http://www.w3.org/TR/css-grid-1/#z-order) | 53 * [grid items](http://www.w3.org/TR/css-grid-1/#z-order) |
| 49 * custom scrollbar parts | 54 * custom scrollbar parts |
| 50 | 55 |
| 51 They are painted by `ObjectPainter::paintAllPhasesAtomically()` which execut
es | 56 They are painted by `ObjectPainter::paintAllPhasesAtomically()` which execut
es |
| 52 all of the steps of the painting algorithm explained in the documentation, e
xcept | 57 all of the steps of the painting algorithm explained in the documentation, e
xcept |
| 53 ignores any descendants which are positioned or have non-auto z-index (which
is | 58 ignores any descendants which are positioned or have non-auto z-index (which
is |
| 54 achieved by skipping descendants with self-painting layers). | 59 achieved by skipping descendants with self-painting layers). |
| 55 | 60 |
| 56 * Other normal elements. | 61 * Other normal elements. |
| 57 | 62 |
| 58 ## Painters | 63 ### Other glossaries |
| 64 |
| 65 * Paint container: the parent of an object for painting, as defined by [CSS2.1
spec |
| 66 for painting]((http://www.w3.org/TR/CSS21/zindex.html)). For regular objects
, |
| 67 this is the parent in the DOM. For stacked objects, it's the containing stac
king |
| 68 context-inducing object. |
| 69 |
| 70 * Paint container chain: the chain of paint ancestors between an element and t
he |
| 71 root of the page. |
| 72 |
| 73 * Compositing container: an implementation detail of Blink, which uses |
| 74 `PaintLayer`s to represent some layout objects. It is the ancestor along the
paint |
| 75 ancestor chain which has a PaintLayer. Implemented in |
| 76 `PaintLayer::compositingContainer()`. Think of it as skipping intermediate n
ormal |
| 77 objects and going directly to the containing stacked object. |
| 78 |
| 79 * Compositing container chain: same as paint chain, but for compositing contai
ner. |
| 80 |
| 81 * Paint invalidation container: the nearest object on the compositing containe
r |
| 82 chain which is composited. |
| 59 | 83 |
| 60 ## Paint invalidation | 84 ## Paint invalidation |
| 61 | 85 |
| 62 Paint invalidation marks anything that need to be painted differently from the o
riginal | 86 Paint invalidation marks anything that need to be painted differently from the o
riginal |
| 63 cached painting. | 87 cached painting. |
| 64 | 88 |
| 65 ### Slimming paint v1 | 89 ### Slimming paint v1 |
| 66 | 90 |
| 67 Though described in this document, most of the actual paint invalidation code is
under | 91 Though described in this document, most of the actual paint invalidation code is
under |
| 68 `Source/core/layout`. | 92 `Source/core/layout`. |
| 69 | 93 |
| 70 Paint invalidation is a document cycle stage after compositing update and before
paint. | 94 Paint invalidation is a document cycle stage after compositing update and before
paint. |
| 71 During the previous stages, objects are marked for needing paint invalidation ch
ecking | 95 During the previous stages, objects are marked for needing paint invalidation ch
ecking |
| 72 if needed by style change, layout change, compositing change, etc. In paint inva
lidation stage, | 96 if needed by style change, layout change, compositing change, etc. In paint inva
lidation stage, |
| 73 we traverse the layout tree for marked subtrees and objects and send the followi
ng information | 97 we traverse the layout tree in pre-order, crossing frame boundaries, for marked
subtrees |
| 74 to `GraphicsLayer`s and `PaintController`s: | 98 and objects and send the following information to `GraphicsLayer`s and `PaintCon
troller`s: |
| 75 | 99 |
| 76 * paint invalidation rects: must cover all areas that will generete different
pixels. | 100 * paint invalidation rects: must cover all areas that will generete different
pixels. |
| 77 * invalidated display item clients: must invalidate all display item clients t
hat will | 101 * invalidated display item clients: must invalidate all display item clients t
hat will |
| 78 generate different display items. | 102 generate different display items. |
| 79 | 103 |
| 104 #### `PaintInvalidationState` |
| 105 |
| 106 `PaintInvalidationState` is an optimization used during the paint invalidation p
hase. Before |
| 107 the paint invalidation tree walk, a root `PaintInvalidationState` is created for
the root |
| 108 `LayoutView`. During the tree walk, one `PaintInvalidationState` is created for
each visited |
| 109 object based on the `PaintInvalidationState` passed from the parent object. |
| 110 It tracks the following information to provide O(1) complexity access to them if
possible: |
| 111 |
| 112 * Paint invalidation container: Since as indicated by the definitions in [Glos
saries](#Other glossaries), |
| 113 the paint invalidation container for stacked objects can differ from normal
objects, we |
| 114 have to track both separately. Here is an example: |
| 115 |
| 116 <div style="overflow: scroll"> |
| 117 <div id=A style="position: absolute"></div> |
| 118 <div id=B></div> |
| 119 </div> |
| 120 |
| 121 If the scroller is composited (for high-DPI screens for example), it is the
paint invalidation |
| 122 container for div B, but not A. |
| 123 |
| 124 * Paint offset and clip rect: if possible, `PaintInvalidationState` accumulate
s paint offsets |
| 125 and overflow clipping rects from the paint invalidation container to provide
O(1) complexity to |
| 126 map a point or a rect in current object's local space to paint invalidation
container's space. |
| 127 Because locations of objects are determined by their containing blocks, and
the containing block |
| 128 for absolute-position objects differs from non-absolute, we track paint offs
ets and overflow |
| 129 clipping rects for absolute-position objects separately. |
| 130 |
| 131 In cases that accurate accumulation of paint offsets and clipping rects is impos
sible, |
| 132 we will fall back to slow-path using `LayoutObject::localToAncestorPoint()` or |
| 133 `LayoutObject::mapToVisualRectInAncestorSpace()`. This includes the following ca
ses: |
| 134 |
| 135 * An object has transform related property, is multi-column or has flipped blo
cks writing-mode, |
| 136 causing we can't simply accumulate paint offset for mapping a local rect to
paint invalidation |
| 137 container; |
| 138 |
| 139 * An object has has filter or reflection, which needs to expand paint invalida
tion rect |
| 140 for descendants, because currently we don't include and reflection extents i
nto visual overflow; |
| 141 |
| 142 * For a fixed-position object we calculate its offset using `LayoutObject::loc
alToAncestorPoint()`, |
| 143 but map for its descendants in fast-path if no other things prevent us from
doing this; |
| 144 |
| 145 * Because we track paint offset from the normal paint invalidation container o
nly, if we are going |
| 146 to use `m_paintInvalidationContainerForStackedContents` and it's different f
rom the normal paint |
| 147 invalidation container, we have to force slow-path because the accumulated p
aint offset is not |
| 148 usable; |
| 149 |
| 150 * We also stop to track paint offset and clipping rect for absolute-position o
bjects when |
| 151 `m_paintInvalidationContainerForStackedContents` becomes different from `m_p
aintInvalidationContainer`. |
| 152 |
| 80 ### Paint invalidation of texts | 153 ### Paint invalidation of texts |
| 81 | 154 |
| 82 Texts are painted by `InlineTextBoxPainter` using `InlineTextBox` as display ite
m client. | 155 Texts are painted by `InlineTextBoxPainter` using `InlineTextBox` as display ite
m client. |
| 83 Text backgrounds and masks are painted by `InlineTextFlowPainter` using `InlineF
lowBox` | 156 Text backgrounds and masks are painted by `InlineTextFlowPainter` using `InlineF
lowBox` |
| 84 as display item client. We should invalidate these display item clients when the
ir painting | 157 as display item client. We should invalidate these display item clients when the
ir painting |
| 85 will change. | 158 will change. |
| 86 | 159 |
| 87 `LayoutInline`s and `LayoutText`s are marked for full paint invalidation if need
ed when | 160 `LayoutInline`s and `LayoutText`s are marked for full paint invalidation if need
ed when |
| 88 new style is set on them. During paint invalidation, we invalidate the `InlineFl
owBox`s | 161 new style is set on them. During paint invalidation, we invalidate the `InlineFl
owBox`s |
| 89 directly contained by the `LayoutInline` in `LayoutInline::invalidateDisplayItem
Clients()` and | 162 directly contained by the `LayoutInline` in `LayoutInline::invalidateDisplayItem
Clients()` and |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 In a subsequence paint, if the layer would generate exactly the same display ite
ms, we'll simply | 209 In a subsequence paint, if the layer would generate exactly the same display ite
ms, we'll simply |
| 137 output a `CachedSubsequence` display item in place of the display items, and ski
p all paintings | 210 output a `CachedSubsequence` display item in place of the display items, and ski
p all paintings |
| 138 of the layer and its descendants in painting order. After painting, `PaintContro
ller` will | 211 of the layer and its descendants in painting order. After painting, `PaintContro
ller` will |
| 139 replace `CacheSubsequence` with cached display items created in previous paintin
gs. | 212 replace `CacheSubsequence` with cached display items created in previous paintin
gs. |
| 140 | 213 |
| 141 There are many conditions affecting | 214 There are many conditions affecting |
| 142 * whether we need to generate subsequence for a PaintLayer; | 215 * whether we need to generate subsequence for a PaintLayer; |
| 143 * whether we can use cached subsequence for a PaintLayer. | 216 * whether we can use cached subsequence for a PaintLayer. |
| 144 See `shouldCreateSubsequence()` and `shouldRepaintSubsequence()` in `PaintLayerP
ainter.cpp` for | 217 See `shouldCreateSubsequence()` and `shouldRepaintSubsequence()` in `PaintLayerP
ainter.cpp` for |
| 145 the conditions. | 218 the conditions. |
| OLD | NEW |