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

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, 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 // 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 | InputIsInFrameCoordinates);
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 { 130 return;
124 if (m_cachedOffsetsEnabled) { 131 }
125 if (fixed) { 132
126 FloatPoint fixedOffset = m_currentObject.localToAncestorPoint(Fl oatPoint(), &m_paintInvalidationContainer, TraverseDocumentBoundaries); 133 if (!m_cachedOffsetsEnabled)
127 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()); 134 return;
128 } else if (m_currentObject.isBox() && !m_currentObject.isTableRow()) { 135
129 // We don't add locationOffset of table row because the child ce lls' location offsets include the row's location offset. 136 if (currentObject.isLayoutView()) {
130 m_paintOffset += toLayoutBox(m_currentObject).locationOffset(); 137 ASSERT(&parentState.m_currentObject == toLayoutView(currentObject).frame ()->ownerLayoutObject());
138 m_paintOffset += toLayoutBox(parentState.m_currentObject).contentBoxOffs et();
139 return;
140 }
141
142 if (currentObject.isBox())
143 m_paintOffset += toLayoutBox(currentObject).locationOffset();
144
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 }
152
153 if (currentObject.isInFlowPositioned() && currentObject.hasLayer())
154 m_paintOffset += toLayoutBoxModelObject(currentObject).layer()->offsetFo rInFlowPosition();
155 }
156
157 void PaintInvalidationState::updateForChildren()
158 {
159 #if ENABLE(ASSERT)
160 ASSERT(!m_didUpdateForChildren);
161 m_didUpdateForChildren = true;
162 #endif
163
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 if (m_currentObject != m_paintInvalidationContainer) {
173 m_paintOffset -= toLayoutView(m_currentObject).frameView()->scro llOffset();
174 addClipRectRelativeToPaintOffset(toLayoutView(m_currentObject).v iewRect());
131 } 175 }
132 176 return;
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 } 177 }
143 178 } else if (m_currentObject.isSVGRoot()) {
144 m_clipped = !fixed && m_clipped;
145 }
146
147 if (m_cachedOffsetsEnabled && m_currentObject.isSVGRoot()) {
148 const LayoutSVGRoot& svgRoot = toLayoutSVGRoot(m_currentObject); 179 const LayoutSVGRoot& svgRoot = toLayoutSVGRoot(m_currentObject);
149 m_svgTransform = AffineTransform(svgRoot.localToBorderBoxTransform());
150 if (svgRoot.shouldApplyViewportClip()) 180 if (svgRoot.shouldApplyViewportClip())
151 addClipRectRelativeToPaintOffset(LayoutSize(svgRoot.pixelSnappedSize ())); 181 addClipRectRelativeToPaintOffset(LayoutRect(LayoutPoint(), LayoutSiz e(svgRoot.pixelSnappedSize())));
152 } 182 } else if (m_currentObject.isTableRow()) {
153 183 // Child table cell's locationOffset() includes its row's locationOffset ().
154 applyClipIfNeeded(); 184 m_paintOffset -= toLayoutBox(m_currentObject).locationOffset();
155 185 }
156 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present. 186
157 }
158
159 bool PaintInvalidationState::mapObjectRectToAncestor(const LayoutObject& object, const LayoutBoxModelObject* ancestor, LayoutRect& rect, VisibleRectFlags visibl eRectFlags) 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 true;
167 }
168
169 if (object.hasLayer()) {
170 if (const TransformationMatrix* transform = toLayoutBoxModelObject(objec t).layer()->transform())
171 rect = LayoutRect(transform->mapRect(pixelSnappedIntRect(rect)));
172
173 if (object.isInFlowPositioned())
174 rect.move(toLayoutBoxModelObject(object).layer()->offsetForInFlowPos ition());
175 }
176
177 if (object.isBox())
178 rect.moveBy(toLayoutBox(object).location());
179
180 rect.move(m_paintOffset);
181
182 if (m_clipped) {
183 if (visibleRectFlags & EdgeInclusive)
184 return rect.inclusiveIntersect(m_clipRect);
185 rect.intersect(m_clipRect);
186 }
187
188 return !rect.isEmpty();
189 }
190
191 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize& clipSize)
192 {
193 LayoutRect clipRect(toPoint(m_paintOffset), clipSize);
194 if (m_clipped) {
195 m_clipRect.intersect(clipRect);
196 } else {
197 m_clipRect = clipRect;
198 m_clipped = true;
199 }
200 }
201
202 void PaintInvalidationState::applyClipIfNeeded()
203 {
204 if (!m_currentObject.hasOverflowClip()) 187 if (!m_currentObject.hasOverflowClip())
205 return; 188 return;
206 189
207 const LayoutBox& box = toLayoutBox(m_currentObject); 190 const LayoutBox& box = toLayoutBox(m_currentObject);
208 191
209 // Do not clip scroll layer contents because the compositor expects the whol e layer 192 // Do not clip scroll layer contents because the compositor expects the whol e layer
210 // to be always invalidated in-time. 193 // to be always invalidated in-time.
211 if (box.usesCompositedScrolling()) 194 if (box.usesCompositedScrolling())
212 ASSERT(!m_clipped); // The box should establish paint invalidation conta iner, so no m_clipped inherited. 195 ASSERT(!m_clipped); // The box should establish paint invalidation conta iner, so no m_clipped inherited.
213 else 196 else
214 addClipRectRelativeToPaintOffset(LayoutSize(box.layer()->size())); 197 addClipRectRelativeToPaintOffset(LayoutRect(LayoutPoint(), LayoutSize(bo x.layer()->size())));
215 198
216 m_paintOffset -= box.scrolledContentOffset(); 199 m_paintOffset -= box.scrolledContentOffset();
200
201 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present.
202 }
203
204 static FloatPoint slowLocalToAncestorPoint(const LayoutObject& object, const Lay outBoxModelObject& ancestor, const FloatPoint& point)
205 {
206 if (object.isLayoutView())
207 return toLayoutView(object).localToAncestorPoint(point, &ancestor, Trave rseDocumentBoundaries | InputIsInFrameCoordinates);
208 return object.localToAncestorPoint(point, &ancestor, TraverseDocumentBoundar ies);
209 }
210
211 LayoutPoint PaintInvalidationState::computePositionFromPaintInvalidationBacking( ) const
212 {
213 ASSERT(!m_didUpdateForChildren);
214
215 FloatPoint point;
216 if (m_paintInvalidationContainer != m_currentObject) {
217 if (m_cachedOffsetsEnabled) {
218 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot())
219 point = m_svgTransform.mapPoint(point);
220 point += FloatPoint(m_paintOffset);
221 #ifndef NDEBUG
222 // Make sure that the fast path and the slow path generate the same point.
223 // TODO(wangxianzhu): We can't enable this ASSERT for now because of crbug.com/597745.
224 // ASSERT(point == slowLocalOriginToAncestorPoint(m_currentObject, m _paintInvalidationContainer, FloatPoint());
225 #endif
226 } else {
227 point = slowLocalToAncestorPoint(m_currentObject, m_paintInvalidatio nContainer, FloatPoint());
228 }
229 }
230
231 if (m_paintInvalidationContainer.layer()->groupedMapping())
232 PaintLayer::mapPointInPaintInvalidationContainerToBacking(m_paintInvalid ationContainer, point);
233
234 return LayoutPoint(point);
235 }
236
237 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBacking() const
238 {
239 ASSERT(!m_didUpdateForChildren);
240
241 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot())
242 return computePaintInvalidationRectInBackingForSVG();
243
244 LayoutRect rect = m_currentObject.localOverflowRectForPaintInvalidation();
245 mapLocalRectToPaintInvalidationBacking(rect);
246 return rect;
247 }
248
249 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBackingForSVG() const
250 {
251 LayoutRect rect;
252 if (m_cachedOffsetsEnabled) {
253 FloatRect svgRect = SVGLayoutSupport::localOverflowRectForPaintInvalidat ion(m_currentObject);
254 rect = SVGLayoutSupport::transformPaintInvalidationRect(m_currentObject, m_svgTransform, svgRect);
255 rect.move(m_paintOffset);
256 if (m_clipped)
257 rect.intersect(m_clipRect);
258 #if !defined(NDEBUG) && ENABLE(ASSERT)
259 // Make sure that the fast path and the slow path generate the same rect .
260 LayoutRect slowPathRect = SVGLayoutSupport::clippedOverflowRectForPaintI nvalidation(m_currentObject, m_paintInvalidationContainer);
261 // TODO(crbug.com/597902): Slow path misses clipping of paintInvalidatio nContainer.
262 if (m_clipped)
263 slowPathRect.intersect(m_clipRect);
264 // TODO(crbug.com/597903): Fast path and slow path should generate equal empty rects.
265 ASSERT((rect.isEmpty() && slowPathRect.isEmpty()) || rect == slowPathRec t);
266 #endif
267 } else {
268 // TODO(wangxianzhu): Sometimes m_cachedOffsetsEnabled==false doesn't me an we can't use cached
269 // m_svgTransform. We can use hybrid fast-path (for SVG) and slow-path ( for things above the SVGRoot).
270 rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(m_curre ntObject, m_paintInvalidationContainer);
271 }
272
273 if (m_paintInvalidationContainer.layer()->groupedMapping())
274 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida tionContainer, rect);
275 return rect;
276 }
277
278 static void slowMapToVisibleRectInAncestorSpace(const LayoutObject& object, cons t LayoutBoxModelObject& ancestor, LayoutRect& rect)
279 {
280 // TODO(crbug.com/597965): LayoutBox::mapToVisibleRectInAncestorSpace() inco rrectly flips a rect
281 // in its own space for writing mode. Here flip to workaround the flip.
282 if (object.isBox() && (toLayoutBox(object).isWritingModeRoot() || (ancestor == object && object.styleRef().isFlippedBlocksWritingMode())))
283 toLayoutBox(object).flipForWritingMode(rect);
284
285 if (object.isLayoutView()) {
286 toLayoutView(object).mapToVisibleRectInAncestorSpace(&ancestor, rect, In putIsInFrameCoordinates, DefaultVisibleRectFlags);
287 } else if (object.isSVGRoot()) {
288 // TODO(crbug.com/597813): This is to avoid the extra clip applied in La youtSVGRoot::mapVisibleRectInAncestorSpace().
289 toLayoutSVGRoot(object).LayoutReplaced::mapToVisibleRectInAncestorSpace( &ancestor, rect);
290 } else {
291 object.mapToVisibleRectInAncestorSpace(&ancestor, rect);
292 }
293 }
294
295 void PaintInvalidationState::mapLocalRectToPaintInvalidationBacking(LayoutRect& rect) const
296 {
297 ASSERT(!m_didUpdateForChildren);
298
299 if (m_cachedOffsetsEnabled) {
300 #if !defined(NDEBUG) && ENABLE(ASSERT)
301 LayoutRect slowPathRect(rect);
302 slowMapToVisibleRectInAncestorSpace(m_currentObject, m_paintInvalidation Container, slowPathRect);
303 #endif
304 rect.move(m_paintOffset);
305 if (m_clipped)
306 rect.intersect(m_clipRect);
307 #if !defined(NDEBUG) && ENABLE(ASSERT)
308 // Make sure that the fast path and the slow path generate the same rect .
309 // TODO(crbug.com/597902): Slow path misses clipping of paintInvalidatio nContainer.
310 if (m_clipped)
311 slowPathRect.intersect(m_clipRect);
312 // TODO(wangxianzhu): The isLayoutView() condition is for cases that a s ub-frame creates a
313 // root PaintInvalidationState which doesn't inherit clip from ancestor frames.
314 // Remove the condition when we eliminate the latter case of PaintInvali dationState(const LayoutView&, ...).
315 // TODO(crbug.com/597903): Fast path and slow path should generate equal empty rects.
316 ASSERT(m_currentObject.isLayoutView() || (rect.isEmpty() && slowPathRect .isEmpty()) || rect == slowPathRect);
317 #endif
318 } else {
319 slowMapToVisibleRectInAncestorSpace(m_currentObject, m_paintInvalidation Container, rect);
320 }
321
322 if (m_paintInvalidationContainer.layer()->groupedMapping())
323 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida tionContainer, rect);
324 }
325
326 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutRect& localClipRect)
327 {
328 LayoutRect clipRect = localClipRect;
329 clipRect.move(m_paintOffset);
330 if (m_clipped) {
331 m_clipRect.intersect(clipRect);
332 } else {
333 m_clipRect = clipRect;
334 m_clipped = true;
335 }
217 } 336 }
218 337
219 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec t& layoutObject) const 338 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec t& layoutObject) const
220 { 339 {
221 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP aintingLayer()) 340 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP aintingLayer())
222 return *toLayoutBoxModelObject(layoutObject).layer(); 341 return *toLayoutBoxModelObject(layoutObject).layer();
223 342
224 return m_enclosingSelfPaintingLayer; 343 return m_enclosingSelfPaintingLayer;
225 } 344 }
226 345
227 } // namespace blink 346 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698