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

Side by Side Diff: third_party/WebKit/Source/core/layout/PaintInvalidationState.cpp

Issue 1813383002: Move all fast-path paint invalidation mapping into PaintInvalidationState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/PaintInvalidationState.h" 5 #include "core/layout/PaintInvalidationState.h"
6 6
7 #include "core/frame/FrameView.h"
8 #include "core/frame/Settings.h"
7 #include "core/layout/LayoutInline.h" 9 #include "core/layout/LayoutInline.h"
10 #include "core/layout/LayoutPart.h"
8 #include "core/layout/LayoutView.h" 11 #include "core/layout/LayoutView.h"
9 #include "core/layout/svg/LayoutSVGModelObject.h" 12 #include "core/layout/svg/LayoutSVGModelObject.h"
10 #include "core/layout/svg/LayoutSVGRoot.h" 13 #include "core/layout/svg/LayoutSVGRoot.h"
14 #include "core/layout/svg/SVGLayoutSupport.h"
11 #include "core/paint/PaintLayer.h" 15 #include "core/paint/PaintLayer.h"
12 16
13 namespace blink { 17 namespace blink {
14 18
15 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec tor<LayoutObject*>& pendingDelayedPaintInvalidations, const PaintInvalidationSta te* ownerPaintInvalidationState) 19 static bool supportsCachedOffsets(const LayoutObject& object)
20 {
21 // TODO(wangxianzhu): Move some conditions to fast path if possible.
22 return !object.hasTransformRelatedProperty()
23 && !object.hasReflection()
24 && !object.hasFilter()
25 && !object.isLayoutFlowThread()
26 && object.styleRef().position() != FixedPosition
27 && !object.styleRef().isFlippedBlocksWritingMode();
28 }
29
30 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec tor<LayoutObject*>& pendingDelayedPaintInvalidations)
16 : m_currentObject(layoutView) 31 : m_currentObject(layoutView)
17 , m_clipped(false) 32 , m_clipped(false)
18 , m_cachedOffsetsEnabled(true) 33 , m_cachedOffsetsEnabled(true)
19 , m_forcedSubtreeInvalidationWithinContainer(false) 34 , m_forcedSubtreeInvalidationWithinContainer(false)
20 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false) 35 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false)
21 , m_viewClippingAndScrollOffsetDisabled(false)
22 , m_paintInvalidationContainer(layoutView.containerForPaintInvalidation()) 36 , m_paintInvalidationContainer(layoutView.containerForPaintInvalidation())
23 , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations) 37 , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations)
24 , m_enclosingSelfPaintingLayer(*layoutView.layer()) 38 , m_enclosingSelfPaintingLayer(*layoutView.layer())
25 #if ENABLE(ASSERT) 39 #if ENABLE(ASSERT)
26 , m_didUpdatePaintOffsetAndClipForChildren(true) 40 , m_didUpdateForChildren(false)
27 #endif 41 #endif
28 { 42 {
29 ASSERT(!ownerPaintInvalidationState || ownerPaintInvalidationState->m_didUpd atePaintOffsetAndClipForChildren); 43 if (!supportsCachedOffsets(layoutView)) {
44 m_cachedOffsetsEnabled = false;
45 return;
46 }
30 47
31 bool establishesPaintInvalidationContainer = layoutView == m_paintInvalidati onContainer; 48 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &m_paintInv alidationContainer, TraverseDocumentBoundaries | DontApplyFrameScrollOffsetAndCl ip);
32 if (!establishesPaintInvalidationContainer) { 49 m_paintOffset = LayoutSize(point.x(), point.y());
33 if ((ownerPaintInvalidationState && !ownerPaintInvalidationState->m_cach edOffsetsEnabled)
34 || !layoutView.supportsPaintInvalidationStateCachedOffsets()) {
35 m_cachedOffsetsEnabled = false;
36 return;
37 }
38 if (ownerPaintInvalidationState && ownerPaintInvalidationState->m_forced SubtreeInvalidationWithinContainer)
39 m_forcedSubtreeInvalidationWithinContainer = true;
40 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &m_pain tInvalidationContainer, TraverseDocumentBoundaries);
41 m_paintOffset = LayoutSize(point.x(), point.y());
42 }
43 m_clipRect = layoutView.viewRect();
44 m_clipRect.move(m_paintOffset);
45 m_clipped = true;
46 } 50 }
47 51
48 // TODO(wangxianzhu): This is temporary for positioned object whose paintInvalid ationContainer is different from 52 // TODO(wangxianzhu): This is temporary for positioned object whose paintInvalid ationContainer is different from
49 // the one we find during tree walk. Remove this after we fix the issue with tre e walk in DOM-order. 53 // the one we find during tree walk. Remove this after we fix the issue with tre e walk in DOM-order.
50 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par entState, const LayoutBoxModelObject& currentObject, const LayoutBoxModelObject& paintInvalidationContainer) 54 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par entState, const LayoutBoxModelObject& currentObject, const LayoutBoxModelObject& paintInvalidationContainer)
51 : m_currentObject(currentObject) 55 : m_currentObject(currentObject)
52 , m_clipped(parentState.m_clipped) 56 , m_clipped(parentState.m_clipped)
53 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled) 57 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled)
54 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva lidationWithinContainer) 58 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva lidationWithinContainer)
55 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS ubtreeInvalidationRectUpdateWithinContainer) 59 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS ubtreeInvalidationRectUpdateWithinContainer)
56 , m_viewClippingAndScrollOffsetDisabled(false)
57 , m_clipRect(parentState.m_clipRect) 60 , m_clipRect(parentState.m_clipRect)
58 , m_paintOffset(parentState.m_paintOffset) 61 , m_paintOffset(parentState.m_paintOffset)
59 , m_paintInvalidationContainer(paintInvalidationContainer) 62 , m_paintInvalidationContainer(paintInvalidationContainer)
60 , m_svgTransform(parentState.m_svgTransform) 63 , m_svgTransform(parentState.m_svgTransform)
61 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida tionTargets()) 64 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida tionTargets())
62 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren tObject)) 65 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren tObject))
63 #if ENABLE(ASSERT) 66 #if ENABLE(ASSERT)
64 , m_didUpdatePaintOffsetAndClipForChildren(true) 67 , m_didUpdateForChildren(true)
65 #endif 68 #endif
66 { 69 {
67 ASSERT(parentState.m_didUpdatePaintOffsetAndClipForChildren); 70 ASSERT(parentState.m_didUpdateForChildren);
68 ASSERT(!m_cachedOffsetsEnabled); 71 ASSERT(!m_cachedOffsetsEnabled);
69 } 72 }
70 73
71 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par entState, const LayoutObject& currentObject) 74 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par entState, const LayoutObject& currentObject)
72 : m_currentObject(currentObject) 75 : m_currentObject(currentObject)
73 , m_clipped(parentState.m_clipped) 76 , m_clipped(parentState.m_clipped)
74 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled) 77 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled)
75 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva lidationWithinContainer) 78 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva lidationWithinContainer)
76 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS ubtreeInvalidationRectUpdateWithinContainer) 79 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS ubtreeInvalidationRectUpdateWithinContainer)
77 , m_viewClippingAndScrollOffsetDisabled(false)
78 , m_clipRect(parentState.m_clipRect) 80 , m_clipRect(parentState.m_clipRect)
79 , m_paintOffset(parentState.m_paintOffset) 81 , m_paintOffset(parentState.m_paintOffset)
80 , m_paintInvalidationContainer(currentObject.isPaintInvalidationContainer() ? toLayoutBoxModelObject(currentObject) : parentState.m_paintInvalidationContain er) 82 , m_paintInvalidationContainer(currentObject.isPaintInvalidationContainer() ? toLayoutBoxModelObject(currentObject) : parentState.m_paintInvalidationContain er)
81 , m_svgTransform(parentState.m_svgTransform) 83 , m_svgTransform(parentState.m_svgTransform)
82 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida tionTargets()) 84 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida tionTargets())
83 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren tObject)) 85 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren tObject))
84 #if ENABLE(ASSERT) 86 #if ENABLE(ASSERT)
85 , m_didUpdatePaintOffsetAndClipForChildren(false) 87 , m_didUpdateForChildren(false)
86 #endif 88 #endif
87 { 89 {
88 ASSERT(parentState.m_didUpdatePaintOffsetAndClipForChildren); 90 if (currentObject == parentState.m_currentObject) {
89 } 91 // Sometimes we create a new PaintInvalidationState from parentState on the same object
90 92 // (e.g. LayoutView, and the HorriblySlowRectMapping cases in LayoutBloc k::invalidatePaintOfSubtreesIfNeeded()).
91 void PaintInvalidationState::updatePaintOffsetAndClipForChildren() 93 // TODO(wangxianzhu): Avoid this for RuntimeEnabledFeatures::slimmingPai ntInvalidationEnabled().
92 {
93 #if ENABLE(ASSERT) 94 #if ENABLE(ASSERT)
94 ASSERT(!m_didUpdatePaintOffsetAndClipForChildren); 95 m_didUpdateForChildren = parentState.m_didUpdateForChildren;
95 m_didUpdatePaintOffsetAndClipForChildren = true;
96 #endif 96 #endif
97
98 bool establishesPaintInvalidationContainer = m_currentObject == m_paintInval idationContainer;
99
100 if (!m_currentObject.isBoxModelObject()) {
101 // TODO(wangxianzhu): SVG could probably benefit from a stack-based opti mization like html does. crbug.com/391054.
102 ASSERT(m_currentObject.isSVG());
103 ASSERT(!establishesPaintInvalidationContainer);
104 if (m_cachedOffsetsEnabled)
105 m_svgTransform = AffineTransform(m_svgTransform * m_currentObject.lo calToSVGParentTransform());
106 return; 97 return;
107 } 98 }
108 99
109 bool fixed = m_currentObject.style()->position() == FixedPosition; 100 ASSERT(parentState.m_didUpdateForChildren);
110 101
111 if (!m_currentObject.supportsPaintInvalidationStateCachedOffsets()) 102 if (!currentObject.isBoxModelObject() && !currentObject.isSVG())
103 return;
104
105 if (m_cachedOffsetsEnabled && !supportsCachedOffsets(currentObject))
112 m_cachedOffsetsEnabled = false; 106 m_cachedOffsetsEnabled = false;
113 if (establishesPaintInvalidationContainer) { 107
108 if (currentObject.isSVG()) {
109 if (currentObject.isSVGRoot()) {
110 m_svgTransform = toLayoutSVGRoot(currentObject).localToBorderBoxTran sform();
111 // Don't early return here, because the SVGRoot object needs to exec ute the later code
112 // as a normal LayoutBox.
113 } else {
114 ASSERT(currentObject != m_paintInvalidationContainer);
115 m_svgTransform *= currentObject.localToSVGParentTransform();
116 return;
117 }
118 }
119
120 if (currentObject == m_paintInvalidationContainer) {
114 // When we hit a new paint invalidation container, we don't need to 121 // When we hit a new paint invalidation container, we don't need to
115 // continue forcing a check for paint invalidation, since we're 122 // continue forcing a check for paint invalidation, since we're
116 // descending into a different invalidation container. (For instance if 123 // descending into a different invalidation container. (For instance if
117 // our parents were moved, the entire container will just move.) 124 // our parents were moved, the entire container will just move.)
118 m_forcedSubtreeInvalidationWithinContainer = false; 125 m_forcedSubtreeInvalidationWithinContainer = false;
119 m_forcedSubtreeInvalidationRectUpdateWithinContainer = false; 126 m_forcedSubtreeInvalidationRectUpdateWithinContainer = false;
120 127
121 m_clipped = false; // Will be updated in applyClipIfNeeded(). 128 m_clipped = false; // Will be updated in updateForChildren().
122 m_paintOffset = LayoutSize(); 129 m_paintOffset = LayoutSize();
123 } else {
124 if (m_cachedOffsetsEnabled) {
125 if (fixed) {
126 FloatPoint fixedOffset = m_currentObject.localToAncestorPoint(Fl oatPoint(), &m_paintInvalidationContainer, TraverseDocumentBoundaries);
127 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y());
128 } else if (m_currentObject.isBox() && !m_currentObject.isTableRow()) {
129 // We don't add locationOffset of table row because the child ce lls' location offsets include the row's location offset.
130 m_paintOffset += toLayoutBox(m_currentObject).locationOffset();
131 }
132
133 if (m_currentObject.isOutOfFlowPositioned() && !fixed) {
134 if (LayoutObject* container = m_currentObject.container()) {
135 if (container->isInFlowPositioned() && container->isLayoutIn line())
136 m_paintOffset += toLayoutInline(container)->offsetForInF lowPositionedInline(toLayoutBox(m_currentObject));
137 }
138 }
139
140 if (m_currentObject.isInFlowPositioned() && m_currentObject.hasLayer ())
141 m_paintOffset += toLayoutBoxModelObject(m_currentObject).layer() ->offsetForInFlowPosition();
142 }
143
144 m_clipped = !fixed && m_clipped;
145 }
146
147 if (m_cachedOffsetsEnabled && m_currentObject.isSVGRoot()) {
148 const LayoutSVGRoot& svgRoot = toLayoutSVGRoot(m_currentObject);
149 m_svgTransform = AffineTransform(svgRoot.localToBorderBoxTransform());
150 if (svgRoot.shouldApplyViewportClip())
151 addClipRectRelativeToPaintOffset(LayoutSize(svgRoot.pixelSnappedSize ()));
152 }
153
154 applyClipIfNeeded();
155
156 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present.
157 }
158
159 void PaintInvalidationState::mapObjectRectToAncestor(const LayoutObject& object, const LayoutBoxModelObject* ancestor, LayoutRect& rect) const
160 {
161 ASSERT(canMapToAncestor(ancestor));
162
163 if (ancestor == &object) {
164 if (object.isBox() && object.styleRef().isFlippedBlocksWritingMode())
165 toLayoutBox(object).flipForWritingMode(rect);
166 return; 130 return;
167 } 131 }
168 132
169 if (object.hasLayer()) { 133 if (!m_cachedOffsetsEnabled)
170 if (const TransformationMatrix* transform = toLayoutBoxModelObject(objec t).layer()->transform()) 134 return;
171 rect = LayoutRect(transform->mapRect(pixelSnappedIntRect(rect)));
172 135
173 if (object.isInFlowPositioned()) 136 if (currentObject.isLayoutView()) {
174 rect.move(toLayoutBoxModelObject(object).layer()->offsetForInFlowPos ition()); 137 ASSERT(&parentState.m_currentObject == toLayoutView(currentObject).frame ()->ownerLayoutObject());
138 m_paintOffset += toLayoutBox(parentState.m_currentObject).contentBoxOffs et();
139 return;
175 } 140 }
176 141
177 if (object.isBox()) 142 if (currentObject.isBox())
178 rect.moveBy(toLayoutBox(object).location()); 143 m_paintOffset += toLayoutBox(currentObject).locationOffset();
179 144
180 rect.move(m_paintOffset); 145 if (currentObject.styleRef().position() == AbsolutePosition) {
146 if (LayoutObject* container = currentObject.container()) {
147 if (container->isInFlowPositioned() && container->isLayoutInline())
148 m_paintOffset += toLayoutInline(container)->offsetForInFlowPosit ionedInline(toLayoutBox(currentObject));
149 }
150 return;
151 }
181 152
182 if (m_clipped) 153 if (currentObject.isInFlowPositioned() && currentObject.hasLayer())
183 rect.intersect(m_clipRect); 154 m_paintOffset += toLayoutBoxModelObject(currentObject).layer()->offsetFo rInFlowPosition();
184 } 155 }
185 156
186 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize& clipSize) 157 void PaintInvalidationState::updateForChildren()
187 { 158 {
188 LayoutRect clipRect(toPoint(m_paintOffset), clipSize); 159 #if ENABLE(ASSERT)
189 if (m_clipped) { 160 ASSERT(!m_didUpdateForChildren);
190 m_clipRect.intersect(clipRect); 161 m_didUpdateForChildren = true;
191 } else { 162 #endif
192 m_clipRect = clipRect; 163
193 m_clipped = true; 164 if (!m_cachedOffsetsEnabled)
165 return;
166
167 if (!m_currentObject.isBoxModelObject() && !m_currentObject.isSVG())
168 return;
169
170 if (m_currentObject.isLayoutView()) {
171 if ((!m_currentObject.document().settings() || !m_currentObject.document ().settings()->rootLayerScrolls())
172 && m_currentObject != m_paintInvalidationContainer) {
173 m_paintOffset -= toLayoutView(m_currentObject).frameView()->scrollOf fset();
174 addClipRectRelativeToPaintOffset(toLayoutView(m_currentObject).viewR ect());
175 return;
176 }
177 } else if (m_currentObject.isSVGRoot()) {
178 const LayoutSVGRoot& svgRoot = toLayoutSVGRoot(m_currentObject);
179 if (svgRoot.shouldApplyViewportClip())
180 addClipRectRelativeToPaintOffset(LayoutRect(LayoutPoint(), LayoutSiz e(svgRoot.pixelSnappedSize())));
181 } else if (m_currentObject.isTableRow()) {
182 // Child table cell's locationOffset() includes its row's locationOffset ().
183 m_paintOffset -= toLayoutBox(m_currentObject).locationOffset();
194 } 184 }
195 }
196 185
197 void PaintInvalidationState::applyClipIfNeeded()
198 {
199 if (!m_currentObject.hasOverflowClip()) 186 if (!m_currentObject.hasOverflowClip())
200 return; 187 return;
201 188
202 const LayoutBox& box = toLayoutBox(m_currentObject); 189 const LayoutBox& box = toLayoutBox(m_currentObject);
203 190
204 // Do not clip scroll layer contents because the compositor expects the whol e layer 191 // Do not clip scroll layer contents because the compositor expects the whol e layer
205 // to be always invalidated in-time. 192 // to be always invalidated in-time.
206 if (box.usesCompositedScrolling()) 193 if (box.usesCompositedScrolling())
207 ASSERT(!m_clipped); // The box should establish paint invalidation conta iner, so no m_clipped inherited. 194 ASSERT(!m_clipped); // The box should establish paint invalidation conta iner, so no m_clipped inherited.
208 else 195 else
209 addClipRectRelativeToPaintOffset(LayoutSize(box.layer()->size())); 196 addClipRectRelativeToPaintOffset(LayoutRect(LayoutPoint(), LayoutSize(bo x.layer()->size())));
210 197
211 m_paintOffset -= box.scrolledContentOffset(); 198 m_paintOffset -= box.scrolledContentOffset();
199
200 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present.
201 }
202
203 static FloatPoint slowLocalToAncestorPoint(const LayoutObject& object, const Lay outBoxModelObject& ancestor, const FloatPoint& point)
204 {
205 if (object.isLayoutView())
206 return toLayoutView(object).localToAncestorPoint(point, &ancestor, Trave rseDocumentBoundaries | DontApplyFrameScrollOffsetAndClip);
207 return object.localToAncestorPoint(point, &ancestor, TraverseDocumentBoundar ies);
208 }
209
210 LayoutPoint PaintInvalidationState::computePositionFromPaintInvalidationBacking( ) const
211 {
212 FloatPoint point;
213 if (m_paintInvalidationContainer != m_currentObject) {
214 if (m_cachedOffsetsEnabled) {
215 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot())
216 point = m_svgTransform.mapPoint(point);
217 point += FloatPoint(m_paintOffset);
218 #ifndef NDEBUG
219 // Make sure that the fast path and the slow path generate the same point.
220 // TODO(wangxianzhu): We can't enable this ASSERT for now because of crbug.com/597745.
221 // ASSERT(point == slowLocalOriginToAncestorPoint(m_currentObject, m _paintInvalidationContainer, FloatPoint());
222 #endif
223 } else {
224 point = slowLocalToAncestorPoint(m_currentObject, m_paintInvalidatio nContainer, FloatPoint());
225 }
226 }
227
228 if (m_paintInvalidationContainer.layer()->groupedMapping())
229 PaintLayer::mapPointInPaintInvalidationContainerToBacking(m_paintInvalid ationContainer, point);
230
231 return LayoutPoint(point);
232 }
233
234 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBacking() const
235 {
236 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot())
237 return computePaintInvalidationRectInBackingForSVG();
238
239 LayoutRect rect = m_currentObject.localOverflowRectForPaintInvalidation();
240 mapLocalRectToPaintInvalidationBacking(rect);
241 return rect;
242 }
243
244 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBackingForSVG() const
245 {
246 LayoutRect rect;
247 if (m_cachedOffsetsEnabled) {
248 FloatRect svgRect = SVGLayoutSupport::localOverflowRectForPaintInvalidat ion(m_currentObject);
249 rect = SVGLayoutSupport::transformPaintInvalidationRect(m_currentObject, m_svgTransform, svgRect);
250 rect.move(m_paintOffset);
251 if (m_clipped)
252 rect.intersect(m_clipRect);
253 #if !defined(NDEBUG) && ENABLE(ASSERT)
254 // Make sure that the fast path and the slow path generate the same rect .
255 LayoutRect slowPathRect = SVGLayoutSupport::clippedOverflowRectForPaintI nvalidation(m_currentObject, m_paintInvalidationContainer);
256 if (m_clipped)
257 slowPathRect.intersect(m_clipRect);
258 ASSERT((rect.isEmpty() && slowPathRect.isEmpty()) || rect == slowPathRec t);
259 #endif
260 } else {
261 // TODO(wangxianzhu): Sometimes m_cachedOffsetsEnabled==false doesn't me an we can't use cached
262 // m_svgTransform. We can use hybrid fast-path (for SVG) and slow-path ( for things above the SVGRoot).
263 rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(m_curre ntObject, m_paintInvalidationContainer);
264 }
265
266 if (m_paintInvalidationContainer.layer()->groupedMapping())
267 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida tionContainer, rect);
268 return rect;
269 }
270
271 static void slowMapToVisibleRectInAncestorSpace(const LayoutObject& object, cons t LayoutBoxModelObject& ancestor, LayoutRect& rect)
272 {
273 if (object.isLayoutView()) {
274 toLayoutView(object).mapToVisibleRectInAncestorSpace(&ancestor, rect, Do ntApplyFrameScrollOffsetAndClip);
275 } else if (object.isSVGRoot()) {
276 // TODO(crbug.com/597813): This is to avoid the extra clip applied in La youtSVGRoot::mapVisibleRectInAncestorSpace().
277 toLayoutSVGRoot(object).LayoutReplaced::mapToVisibleRectInAncestorSpace( &ancestor, rect);
278 } else {
279 object.mapToVisibleRectInAncestorSpace(&ancestor, rect);
280 }
281 }
282
283 void PaintInvalidationState::mapLocalRectToPaintInvalidationBacking(LayoutRect& rect) const
284 {
285 if (m_cachedOffsetsEnabled) {
286 #if !defined(NDEBUG) && ENABLE(ASSERT)
287 LayoutRect slowPathRect(rect);
288 slowMapToVisibleRectInAncestorSpace(m_currentObject, m_paintInvalidation Container, slowPathRect);
289 #endif
290 rect.move(m_paintOffset);
291 if (m_clipped)
292 rect.intersect(m_clipRect);
293 #if !defined(NDEBUG) && ENABLE(ASSERT)
294 // Make sure that the fast path and the slow path generate the same rect .
295 // TODO(wangxianzhu): The isLayoutView() condition is for cases that a s ub-frame creates a
296 // root PaintInvalidationState which doesn't inherit clip from ancestor frames.
297 // Remove the condition when we eliminate the latter case of PaintInvali dationState(const LayoutView&, ...).
298 ASSERT(m_currentObject.isLayoutView() || (rect.isEmpty() && slowPathRect .isEmpty()) || rect == slowPathRect);
299 #endif
300 } else {
301 slowMapToVisibleRectInAncestorSpace(m_currentObject, m_paintInvalidation Container, rect);
302 }
303
304 if (m_paintInvalidationContainer.layer()->groupedMapping())
305 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida tionContainer, rect);
306 }
307
308 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutRect& localClipRect)
309 {
310 LayoutRect clipRect = localClipRect;
311 clipRect.move(m_paintOffset);
312 if (m_clipped) {
313 m_clipRect.intersect(clipRect);
314 } else {
315 m_clipRect = clipRect;
316 m_clipped = true;
317 }
212 } 318 }
213 319
214 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec t& layoutObject) const 320 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec t& layoutObject) const
215 { 321 {
216 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP aintingLayer()) 322 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP aintingLayer())
217 return *toLayoutBoxModelObject(layoutObject).layer(); 323 return *toLayoutBoxModelObject(layoutObject).layer();
218 324
219 return m_enclosingSelfPaintingLayer; 325 return m_enclosingSelfPaintingLayer;
220 } 326 }
221 327
222 } // namespace blink 328 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698