Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: third_party/WebKit/Source/core/paint/README.md

Issue 1833493003: Remove ForceHorriblySlowRectMapping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pi
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
chrishtr 2016/04/01 16:38:13 Nit: add period.
Xianzhu 2016/04/01 17:07:22 Done.
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 fallback to slow-path using `LayoutObject::localToAncestorPoint()` or
chrishtr 2016/04/01 16:38:13 Nit: s/fallback/fall back/
Xianzhu 2016/04/01 17:07:21 Done.
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
chrishtr 2016/04/01 16:38:13 This one is obsolete in the latest patch set, righ
Xianzhu 2016/04/01 17:07:21 The case before 'or' is still valid. Removed the l
151 `m_paintInvalidationContainerForStackedContents` becomes different from `m_p aintInvalidationContainer`,
152 or absolute-position descendants' offsets will be determined by something (e .g. their containing
153 block) above the paint invalidation container.
154
80 ### Paint invalidation of texts 155 ### Paint invalidation of texts
81 156
82 Texts are painted by `InlineTextBoxPainter` using `InlineTextBox` as display ite m client. 157 Texts are painted by `InlineTextBoxPainter` using `InlineTextBox` as display ite m client.
83 Text backgrounds and masks are painted by `InlineTextFlowPainter` using `InlineF lowBox` 158 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 159 as display item client. We should invalidate these display item clients when the ir painting
85 will change. 160 will change.
86 161
87 `LayoutInline`s and `LayoutText`s are marked for full paint invalidation if need ed when 162 `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 163 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 164 directly contained by the `LayoutInline` in `LayoutInline::invalidateDisplayItem Clients()` and
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 In a subsequence paint, if the layer would generate exactly the same display ite ms, we'll simply 211 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 212 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 213 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. 214 replace `CacheSubsequence` with cached display items created in previous paintin gs.
140 215
141 There are many conditions affecting 216 There are many conditions affecting
142 * whether we need to generate subsequence for a PaintLayer; 217 * whether we need to generate subsequence for a PaintLayer;
143 * whether we can use cached subsequence for a PaintLayer. 218 * whether we can use cached subsequence for a PaintLayer.
144 See `shouldCreateSubsequence()` and `shouldRepaintSubsequence()` in `PaintLayerP ainter.cpp` for 219 See `shouldCreateSubsequence()` and `shouldRepaintSubsequence()` in `PaintLayerP ainter.cpp` for
145 the conditions. 220 the conditions.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698