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

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/layout/LayoutInline.h" 7 #include "core/layout/LayoutInline.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "core/layout/svg/LayoutSVGModelObject.h" 9 #include "core/layout/svg/LayoutSVGModelObject.h"
10 #include "core/layout/svg/LayoutSVGRoot.h" 10 #include "core/layout/svg/LayoutSVGRoot.h"
11 #include "core/layout/svg/SVGLayoutSupport.h"
11 #include "core/paint/PaintLayer.h" 12 #include "core/paint/PaintLayer.h"
12 13
13 namespace blink { 14 namespace blink {
14 15
15 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec tor<LayoutObject*>& pendingDelayedPaintInvalidations, const PaintInvalidationSta te* ownerPaintInvalidationState) 16 static LayoutSize computeViewPaintOffset(const LayoutView& layoutView, const Lay outBoxModelObject& paintInvalidationContainer)
17 {
18 LayoutView::setViewClippingAndScrollOffsetDisabled(true);
19 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &paintInval idationContainer, TraverseDocumentBoundaries);
20 LayoutView::setViewClippingAndScrollOffsetDisabled(false);
21 return LayoutSize(point.x(), point.y());
22 }
23
24 static bool supportsCachedOffsets(const LayoutObject& object)
25 {
26 // TODO(wangxianzhu): Move some conditions to fast path if possible.
27 return !object.hasTransformRelatedProperty()
28 && !object.hasReflection()
29 && !object.hasFilter()
30 && object.styleRef().position() != FixedPosition;
31 }
32
33 static bool supportsCachedOffsetsForChildren(const LayoutObject& object)
34 {
35 // TODO(wangxianzhu): Move some conditions to fast path if possible.
36 return !object.styleRef().isFlippedBlocksWritingMode()
37 && !object.isLayoutFlowThread();
38 }
39
40 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec tor<LayoutObject*>& pendingDelayedPaintInvalidations)
16 : m_currentObject(layoutView) 41 : m_currentObject(layoutView)
17 , m_clipped(false) 42 , m_clipped(false)
18 , m_cachedOffsetsEnabled(true) 43 , m_cachedOffsetsEnabled(true)
19 , m_forcedSubtreeInvalidationWithinContainer(false) 44 , m_forcedSubtreeInvalidationWithinContainer(false)
20 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false) 45 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false)
21 , m_viewClippingAndScrollOffsetDisabled(false)
22 , m_paintInvalidationContainer(layoutView.containerForPaintInvalidation()) 46 , m_paintInvalidationContainer(layoutView.containerForPaintInvalidation())
23 , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations) 47 , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations)
24 , m_enclosingSelfPaintingLayer(*layoutView.layer()) 48 , m_enclosingSelfPaintingLayer(*layoutView.layer())
25 #if ENABLE(ASSERT) 49 #if ENABLE(ASSERT)
26 , m_didUpdatePaintOffsetAndClipForChildren(true) 50 , m_didUpdateForChildren(false)
27 #endif 51 #endif
28 { 52 {
29 ASSERT(!ownerPaintInvalidationState || ownerPaintInvalidationState->m_didUpd atePaintOffsetAndClipForChildren); 53 if (!supportsCachedOffsets(layoutView)) {
54 m_cachedOffsetsEnabled = false;
55 return;
56 }
30 57
31 bool establishesPaintInvalidationContainer = layoutView == m_paintInvalidati onContainer; 58 m_paintOffset = computeViewPaintOffset(layoutView, m_paintInvalidationContai ner);
32 if (!establishesPaintInvalidationContainer) {
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 } 59 }
47 60
48 // TODO(wangxianzhu): This is temporary for positioned object whose paintInvalid ationContainer is different from 61 // 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. 62 // 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) 63 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par entState, const LayoutBoxModelObject& currentObject, const LayoutBoxModelObject& paintInvalidationContainer)
51 : m_currentObject(currentObject) 64 : m_currentObject(currentObject)
52 , m_clipped(parentState.m_clipped) 65 , m_clipped(parentState.m_clipped)
53 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled) 66 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled)
54 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva lidationWithinContainer) 67 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva lidationWithinContainer)
55 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS ubtreeInvalidationRectUpdateWithinContainer) 68 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS ubtreeInvalidationRectUpdateWithinContainer)
56 , m_viewClippingAndScrollOffsetDisabled(false)
57 , m_clipRect(parentState.m_clipRect) 69 , m_clipRect(parentState.m_clipRect)
58 , m_paintOffset(parentState.m_paintOffset) 70 , m_paintOffset(parentState.m_paintOffset)
59 , m_paintInvalidationContainer(paintInvalidationContainer) 71 , m_paintInvalidationContainer(paintInvalidationContainer)
60 , m_svgTransform(parentState.m_svgTransform) 72 , m_svgTransform(parentState.m_svgTransform)
61 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida tionTargets()) 73 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida tionTargets())
62 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren tObject)) 74 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren tObject))
63 #if ENABLE(ASSERT) 75 #if ENABLE(ASSERT)
64 , m_didUpdatePaintOffsetAndClipForChildren(true) 76 , m_didUpdateForChildren(true)
65 #endif 77 #endif
66 { 78 {
67 ASSERT(parentState.m_didUpdatePaintOffsetAndClipForChildren); 79 ASSERT(parentState.m_didUpdateForChildren);
68 ASSERT(!m_cachedOffsetsEnabled); 80 ASSERT(!m_cachedOffsetsEnabled);
69 } 81 }
70 82
71 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par entState, const LayoutObject& currentObject) 83 PaintInvalidationState::PaintInvalidationState(const PaintInvalidationState& par entState, const LayoutObject& currentObject)
72 : m_currentObject(currentObject) 84 : m_currentObject(currentObject)
73 , m_clipped(parentState.m_clipped) 85 , m_clipped(parentState.m_clipped)
74 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled) 86 , m_cachedOffsetsEnabled(parentState.m_cachedOffsetsEnabled)
75 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva lidationWithinContainer) 87 , m_forcedSubtreeInvalidationWithinContainer(parentState.m_forcedSubtreeInva lidationWithinContainer)
76 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS ubtreeInvalidationRectUpdateWithinContainer) 88 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(parentState.m_forcedS ubtreeInvalidationRectUpdateWithinContainer)
77 , m_viewClippingAndScrollOffsetDisabled(false)
78 , m_clipRect(parentState.m_clipRect) 89 , m_clipRect(parentState.m_clipRect)
79 , m_paintOffset(parentState.m_paintOffset) 90 , m_paintOffset(parentState.m_paintOffset)
80 , m_paintInvalidationContainer(currentObject.isPaintInvalidationContainer() ? toLayoutBoxModelObject(currentObject) : parentState.m_paintInvalidationContain er) 91 , m_paintInvalidationContainer(currentObject.isPaintInvalidationContainer() ? toLayoutBoxModelObject(currentObject) : parentState.m_paintInvalidationContain er)
81 , m_svgTransform(parentState.m_svgTransform) 92 , m_svgTransform(parentState.m_svgTransform)
82 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida tionTargets()) 93 , m_pendingDelayedPaintInvalidations(parentState.pendingDelayedPaintInvalida tionTargets())
83 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren tObject)) 94 , m_enclosingSelfPaintingLayer(parentState.enclosingSelfPaintingLayer(curren tObject))
84 #if ENABLE(ASSERT) 95 #if ENABLE(ASSERT)
85 , m_didUpdatePaintOffsetAndClipForChildren(false) 96 , m_didUpdateForChildren(false)
86 #endif 97 #endif
87 { 98 {
88 ASSERT(parentState.m_didUpdatePaintOffsetAndClipForChildren); 99 if (currentObject == parentState.m_currentObject) {
89 } 100 // Sometimes we create a new PaintInvalidationState from parentState on the same object.
90 101 // TODO(wangxianzhu): Avoid this for RuntimeEnabledFeatures::slimmingPai ntInvalidationEnabled().
91 void PaintInvalidationState::updatePaintOffsetAndClipForChildren()
92 {
93 #if ENABLE(ASSERT) 102 #if ENABLE(ASSERT)
94 ASSERT(!m_didUpdatePaintOffsetAndClipForChildren); 103 m_didUpdateForChildren = parentState.m_didUpdateForChildren;
95 m_didUpdatePaintOffsetAndClipForChildren = true;
96 #endif 104 #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; 105 return;
107 } 106 }
108 107
109 bool fixed = m_currentObject.style()->position() == FixedPosition; 108 ASSERT(parentState.m_didUpdateForChildren);
110 109
111 if (!m_currentObject.supportsPaintInvalidationStateCachedOffsets()) 110 if (!currentObject.isBoxModelObject() && !currentObject.isSVG())
111 return;
112
113 bool establishesPaintInvalidationContainer = currentObject == m_paintInvalid ationContainer;
114
115 if (currentObject.isSVG() && !currentObject.isSVGRoot()) {
116 // TODO(wangxianzhu): SVG could probably benefit from a stack-based opti mization like html does. crbug.com/391054.
117 ASSERT(!establishesPaintInvalidationContainer);
118 if (m_cachedOffsetsEnabled)
119 m_svgTransform = AffineTransform(m_svgTransform * currentObject.loca lToSVGParentTransform());
120 return;
121 }
122
123 if (!supportsCachedOffsets(currentObject))
112 m_cachedOffsetsEnabled = false; 124 m_cachedOffsetsEnabled = false;
125
113 if (establishesPaintInvalidationContainer) { 126 if (establishesPaintInvalidationContainer) {
114 // When we hit a new paint invalidation container, we don't need to 127 // When we hit a new paint invalidation container, we don't need to
115 // continue forcing a check for paint invalidation, since we're 128 // continue forcing a check for paint invalidation, since we're
116 // descending into a different invalidation container. (For instance if 129 // descending into a different invalidation container. (For instance if
117 // our parents were moved, the entire container will just move.) 130 // our parents were moved, the entire container will just move.)
118 m_forcedSubtreeInvalidationWithinContainer = false; 131 m_forcedSubtreeInvalidationWithinContainer = false;
119 m_forcedSubtreeInvalidationRectUpdateWithinContainer = false; 132 m_forcedSubtreeInvalidationRectUpdateWithinContainer = false;
120 133
121 m_clipped = false; // Will be updated in applyClipIfNeeded(). 134 m_clipped = false; // Will be updated in applyClipIfNeeded().
122 m_paintOffset = LayoutSize(); 135 m_paintOffset = LayoutSize();
123 } else { 136 } else if (m_cachedOffsetsEnabled) {
124 if (m_cachedOffsetsEnabled) { 137 if (currentObject.isLayoutView()) {
125 if (fixed) { 138 m_paintOffset = computeViewPaintOffset(toLayoutView(currentObject), m_paintInvalidationContainer);
126 FloatPoint fixedOffset = m_currentObject.localToAncestorPoint(Fl oatPoint(), &m_paintInvalidationContainer, TraverseDocumentBoundaries); 139 return;
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 } 140 }
143 141
144 m_clipped = !fixed && m_clipped; 142 if (currentObject.styleRef().position() == FixedPosition) {
143 // TODO(wangxianzhu): Replace localToAncestorPoint with fast path.
144 FloatPoint fixedOffset = currentObject.localToAncestorPoint(FloatPoi nt(), &m_paintInvalidationContainer, TraverseDocumentBoundaries);
145 m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y());
146 m_clipped = false;
147 } else if (currentObject.isBox()) {
148 m_paintOffset += toLayoutBox(currentObject).locationOffset();
149 if (currentObject.isTableCell()) {
150 // A table cell's locationOffset() includes its row's locationOf fset().
151 m_paintOffset -= toLayoutBox(currentObject.parent())->locationOf fset();
152 }
153 }
154
155 if (currentObject.styleRef().position() == AbsolutePosition) {
156 if (LayoutObject* container = currentObject.container()) {
157 if (container->isInFlowPositioned() && container->isLayoutInline ())
158 m_paintOffset += toLayoutInline(container)->offsetForInFlowP ositionedInline(toLayoutBox(currentObject));
159 }
160 }
161
162 if (currentObject.isInFlowPositioned() && currentObject.hasLayer())
163 m_paintOffset += toLayoutBoxModelObject(currentObject).layer()->offs etForInFlowPosition();
145 } 164 }
146 165
147 if (m_cachedOffsetsEnabled && m_currentObject.isSVGRoot()) { 166 if (m_cachedOffsetsEnabled && currentObject.isSVGRoot())
167 m_svgTransform = AffineTransform(toLayoutSVGRoot(currentObject).localToB orderBoxTransform());
168 }
169
170 void PaintInvalidationState::updateForChildren()
171 {
172 #if ENABLE(ASSERT)
173 ASSERT(!m_didUpdateForChildren);
174 m_didUpdateForChildren = true;
175 #endif
176
177 if (!m_cachedOffsetsEnabled)
178 return;
179
180 if (!supportsCachedOffsetsForChildren(m_currentObject)) {
181 m_cachedOffsetsEnabled = false;
182 return;
183 }
184
185 if (!m_currentObject.isBoxModelObject() && !m_currentObject.isSVG())
186 return;
187
188 if (m_currentObject.isLayoutView()) {
189 if (m_currentObject != m_paintInvalidationContainer) {
190 // TODO(wangxianzhu): Replace localToAncestorPoint with fast path.
191 FloatPoint viewOffset = m_currentObject.localToAncestorPoint(FloatPo int(), &m_paintInvalidationContainer, TraverseDocumentBoundaries);
192 m_paintOffset = LayoutSize(viewOffset.x(), viewOffset.y());
193 m_clipRect = toLayoutView(m_currentObject).viewRect();
194 m_clipRect.move(m_paintOffset);
195 m_clipped = true;
196 return;
197 }
198 } else if (m_currentObject.isSVGRoot()) {
148 const LayoutSVGRoot& svgRoot = toLayoutSVGRoot(m_currentObject); 199 const LayoutSVGRoot& svgRoot = toLayoutSVGRoot(m_currentObject);
149 m_svgTransform = AffineTransform(svgRoot.localToBorderBoxTransform());
150 if (svgRoot.shouldApplyViewportClip()) 200 if (svgRoot.shouldApplyViewportClip())
151 addClipRectRelativeToPaintOffset(LayoutSize(svgRoot.pixelSnappedSize ())); 201 addClipRectRelativeToPaintOffset(LayoutSize(svgRoot.pixelSnappedSize ()));
152 } 202 }
153 203
154 applyClipIfNeeded(); 204 if (!m_currentObject.hasOverflowClip())
205 return;
206
207 const LayoutBox& box = toLayoutBox(m_currentObject);
208
209 // Do not clip scroll layer contents because the compositor expects the whol e layer
210 // to be always invalidated in-time.
211 if (box.usesCompositedScrolling())
212 ASSERT(!m_clipped); // The box should establish paint invalidation conta iner, so no m_clipped inherited.
213 else
214 addClipRectRelativeToPaintOffset(LayoutSize(box.layer()->size()));
215
216 m_paintOffset -= box.scrolledContentOffset();
155 217
156 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present. 218 // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present.
157 } 219 }
158 220
159 void PaintInvalidationState::mapObjectRectToAncestor(const LayoutObject& object, const LayoutBoxModelObject* ancestor, LayoutRect& rect) const 221 LayoutPoint PaintInvalidationState::computePositionFromPaintInvalidationBacking( ) const
160 { 222 {
161 ASSERT(canMapToAncestor(ancestor)); 223 FloatPoint point;
162 224 if (m_paintInvalidationContainer != m_currentObject) {
163 if (ancestor == &object) { 225 if (m_cachedOffsetsEnabled) {
164 if (object.isBox() && object.styleRef().isFlippedBlocksWritingMode()) 226 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot())
165 toLayoutBox(object).flipForWritingMode(rect); 227 point = m_svgTransform.mapPoint(point);
166 return; 228 point += FloatPoint(m_paintOffset);
229 } else {
230 // Fallback to slow path.
231 point = m_currentObject.localToAncestorPoint(FloatPoint(), &m_paintI nvalidationContainer);
232 }
167 } 233 }
168 234
169 if (object.hasLayer()) { 235 if (m_paintInvalidationContainer.layer()->groupedMapping())
170 if (const TransformationMatrix* transform = toLayoutBoxModelObject(objec t).layer()->transform()) 236 PaintLayer::mapPointInPaintInvalidationContainerToBacking(m_paintInvalid ationContainer, point);
171 rect = LayoutRect(transform->mapRect(pixelSnappedIntRect(rect)));
172 237
173 if (object.isInFlowPositioned()) 238 return LayoutPoint(point);
174 rect.move(toLayoutBoxModelObject(object).layer()->offsetForInFlowPos ition()); 239 }
240
241 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBacking() const
242 {
243 if (m_currentObject.isSVG() && !m_currentObject.isSVGRoot())
244 return computePaintInvalidationRectInBackingForSVG();
245
246 LayoutRect rect = m_currentObject.localOverflowRectForPaintInvalidation();
247 mapLocalRectToPaintInvalidationBacking(rect);
248 return rect;
249 }
250
251 LayoutRect PaintInvalidationState::computePaintInvalidationRectInBackingForSVG() const
252 {
253 LayoutRect rect;
254 if (m_cachedOffsetsEnabled) {
255 FloatRect svgRect = SVGLayoutSupport::localOverflowRectForPaintInvalidat ion(m_currentObject);
256 rect = SVGLayoutSupport::transformPaintInvalidationRect(m_currentObject, m_svgTransform, svgRect);
257 rect.move(m_paintOffset);
258 if (m_clipped)
259 rect.intersect(m_clipRect);
260 } else {
261 rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(m_curre ntObject, m_paintInvalidationContainer);
175 } 262 }
176 263
177 if (object.isBox()) 264 if (m_paintInvalidationContainer.layer()->groupedMapping())
178 rect.moveBy(toLayoutBox(object).location()); 265 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida tionContainer, rect);
266 return rect;
267 }
179 268
180 rect.move(m_paintOffset); 269 void PaintInvalidationState::mapLocalRectToPaintInvalidationBacking(LayoutRect& rect) const
270 {
271 if (m_cachedOffsetsEnabled) {
272 rect.move(m_paintOffset);
273 if (m_clipped)
274 rect.intersect(m_clipRect);
275 } else {
276 // Fallback to slow path.
277 m_currentObject.mapToVisibleRectInAncestorSpace(&m_paintInvalidationCont ainer, rect);
278 }
181 279
182 if (m_clipped) 280 if (m_paintInvalidationContainer.layer()->groupedMapping())
183 rect.intersect(m_clipRect); 281 PaintLayer::mapRectInPaintInvalidationContainerToBacking(m_paintInvalida tionContainer, rect);
184 } 282 }
185 283
186 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize& clipSize) 284 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize& clipSize)
187 { 285 {
188 LayoutRect clipRect(toPoint(m_paintOffset), clipSize); 286 LayoutRect clipRect(toPoint(m_paintOffset), clipSize);
189 if (m_clipped) { 287 if (m_clipped) {
190 m_clipRect.intersect(clipRect); 288 m_clipRect.intersect(clipRect);
191 } else { 289 } else {
192 m_clipRect = clipRect; 290 m_clipRect = clipRect;
193 m_clipped = true; 291 m_clipped = true;
194 } 292 }
195 } 293 }
196 294
197 void PaintInvalidationState::applyClipIfNeeded()
198 {
199 if (!m_currentObject.hasOverflowClip())
200 return;
201
202 const LayoutBox& box = toLayoutBox(m_currentObject);
203
204 // Do not clip scroll layer contents because the compositor expects the whol e layer
205 // to be always invalidated in-time.
206 if (box.usesCompositedScrolling())
207 ASSERT(!m_clipped); // The box should establish paint invalidation conta iner, so no m_clipped inherited.
208 else
209 addClipRectRelativeToPaintOffset(LayoutSize(box.layer()->size()));
210
211 m_paintOffset -= box.scrolledContentOffset();
212 }
213
214 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec t& layoutObject) const 295 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec t& layoutObject) const
215 { 296 {
216 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP aintingLayer()) 297 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP aintingLayer())
217 return *toLayoutBoxModelObject(layoutObject).layer(); 298 return *toLayoutBoxModelObject(layoutObject).layer();
218 299
219 return m_enclosingSelfPaintingLayer; 300 return m_enclosingSelfPaintingLayer;
220 } 301 }
221 302
222 } // namespace blink 303 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698