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

Side by Side Diff: Source/core/paint/DeprecatedPaintLayerClipper.cpp

Issue 1316173002: Move AbsoluteClipRects to the state machine (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayerClipper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // CSS clip (different than clipping due to overflow) can clip to any box, e ven if it falls outside of the border box. 162 // CSS clip (different than clipping due to overflow) can clip to any box, e ven if it falls outside of the border box.
163 if (m_layoutObject.hasClip()) { 163 if (m_layoutObject.hasClip()) {
164 // Clip applies to *us* as well, so go ahead and update the damageRect. 164 // Clip applies to *us* as well, so go ahead and update the damageRect.
165 LayoutRect newPosClip = toLayoutBox(m_layoutObject).clipRect(offset); 165 LayoutRect newPosClip = toLayoutBox(m_layoutObject).clipRect(offset);
166 backgroundRect.intersect(newPosClip); 166 backgroundRect.intersect(newPosClip);
167 foregroundRect.intersect(newPosClip); 167 foregroundRect.intersect(newPosClip);
168 outlineRect.intersect(newPosClip); 168 outlineRect.intersect(newPosClip);
169 } 169 }
170 } 170 }
171 171
172 static void precalculate(const ClipRectsContext& context) 172 void precalculate(const ClipRectsContext& context)
173 { 173 {
174 bool isComputingPaintingRect = context.isComputingPaintingRect(); 174 bool isComputingPaintingRect = context.isComputingPaintingRect();
175 ClipRectComputationState rects; 175 ClipRectComputationState rects;
176 const DeprecatedPaintLayer* rootLayer = context.rootLayer; 176 const DeprecatedPaintLayer* rootLayer = context.rootLayer;
177 if (isComputingPaintingRect) { 177 if (isComputingPaintingRect) {
178 // Starting arbitrarily in the tree when calculating painting clipRects will 178 // Starting arbitrarily in the tree when calculating painting clipRects will
179 // not allow you to fill in all layers cache because some intermediate l ayer 179 // not allow you to fill in all layers cache because some intermediate l ayer
180 // may need clips with respect to an ancestor further up. For efficiency we 180 // may need clips with respect to an ancestor further up. For efficiency we
181 // start at the top in order to fill in the cache for all layers. 181 // start at the top in order to fill in the cache for all layers.
182 rootLayer = context.rootLayer->layoutObject()->view()->layer(); 182 rootLayer = context.rootLayer->layoutObject()->view()->layer();
183 rects.stackingContextClipRects.setRootLayer(rootLayer); 183 rects.stackingContextClipRects.setRootLayer(rootLayer);
184 } 184 }
185 rects.currentClipRects.setRootLayer(rootLayer); 185 rects.currentClipRects.setRootLayer(rootLayer);
186 186
187 rootLayer->clipper().calculateClipRects(context, rects); 187 rootLayer->clipper().calculateClipRects(context, rects);
188 } 188 }
189 189
190 void DeprecatedPaintLayerClipper::precalculateAbsoluteClipRects()
191 {
192 ASSERT(m_layoutObject.layer()->isRootLayer());
193 // The absolute rectangles rely on layout sizes and position only.
194 ASSERT(m_layoutObject.document().lifecycle().state() >= DocumentLifecycle::L ayoutClean);
195 precalculate(ClipRectsContext(m_layoutObject.layer(), AbsoluteClipRects));
196 }
190 197
191 // Calculates clipRect for each element in the section of the tree starting with context.rootLayer 198 // Calculates clipRect for each element in the section of the tree starting with context.rootLayer
192 // For painting, context.rootLayer is ignored and the entire tree is calculated. 199 // For painting, context.rootLayer is ignored and the entire tree is calculated.
193 // TODO(chadarmstrong): When using the cache context shouldn't be able to specif y the rootLayer. This affects 200 // TODO(chadarmstrong): When using the cache context shouldn't be able to specif y the rootLayer. This affects
194 // what is stored in the 5 caches, and should therefore be enforced internally. Currently 201 // what is stored in the 5 caches, and should therefore be enforced internally. Currently
195 // different callers have different ideas of what the rootLayer should be for a particular 202 // different callers have different ideas of what the rootLayer should be for a particular
196 // cacheSlot, which can fill the cache with bad data. If this can be made consis tent it should 203 // cacheSlot, which can fill the cache with bad data. If this can be made consis tent it should
197 // be possible to eliminate rootLayer. 204 // be possible to eliminate rootLayer.
198 ClipRect DeprecatedPaintLayerClipper::backgroundClipRect(const ClipRectsContext& context) const 205 ClipRect DeprecatedPaintLayerClipper::backgroundClipRect(const ClipRectsContext& context) const
199 { 206 {
200 ASSERT(m_layoutObject.layer()->parent()); 207 ASSERT(m_layoutObject.layer()->parent());
201 ASSERT(m_layoutObject.view()); 208 ASSERT(m_layoutObject.view());
202 209
203 // Ideally backgroundClipRect would not be called with itself as the rootLay er. 210 // Ideally backgroundClipRect would not be called with itself as the rootLay er.
204 // This behavior can be seen in the following test 211 // This behavior can be seen in the following test
205 // LayoutTests/compositing/squashing/abspos-under-abspos-overflow-scroll.htm l 212 // LayoutTests/compositing/squashing/abspos-under-abspos-overflow-scroll.htm l
206 if (m_layoutObject.layer() == context.rootLayer) 213 if (m_layoutObject.layer() == context.rootLayer)
207 return LayoutRect(LayoutRect::infiniteIntRect()); 214 return LayoutRect(LayoutRect::infiniteIntRect());
208 215
209 // TODO(chadarmstrong): If possible, all queries should use one of the clipR ectsCacheSlots. 216 // TODO(chadarmstrong): If possible, all queries should use one of the clipR ectsCacheSlots.
210 // Without caching this operation involves walking all the way to rootLayer. 217 // Without caching this operation involves walking all the way to rootLayer.
211 if (!context.usesCache()) 218 if (!context.usesCache())
212 return uncachedBackgroundClipRect(context); 219 return uncachedBackgroundClipRect(context);
213 220
214 // TODO(chadarmstrong): precalculation for painting should be moved to updat eLifecyclePhasesInternal 221 // TODO(chadarmstrong): precalculation for painting should be moved to updat eLifecyclePhasesInternal
215 // and precalculation could be done for all hit testing. This would let us a void clearing the cache 222 // and precalculation could be done for all hit testing. This would let us a void clearing the cache
216 if (!m_clips[context.cacheSlot()]) 223 if (!m_clips[context.cacheSlot()]) {
224 // AbsoluteClipRects should have been updated during compositing updates so we shouldn't miss here.
225 ASSERT(context.cacheSlot() != AbsoluteClipRects);
217 precalculate(context); 226 precalculate(context);
227 }
218 228
219 // TODO(chadarmstrong): eliminate this if possible. 229 // TODO(chadarmstrong): eliminate this if possible.
220 // It is necessary only because of a seemingly atypical use of rootLayer tha t 230 // It is necessary only because of a seemingly atypical use of rootLayer tha t
221 // can be seen in LayoutTests/fullscreen/full-screen-line-boxes-crash.html a nd 231 // can be seen in LayoutTests/fullscreen/full-screen-line-boxes-crash.html a nd
222 // fast/block/multicol-paint-invalidation-assert.html. 232 // fast/block/multicol-paint-invalidation-assert.html.
223 if (!m_clips[context.cacheSlot()]) 233 if (!m_clips[context.cacheSlot()])
224 return uncachedBackgroundClipRect(context); 234 return uncachedBackgroundClipRect(context);
225 // As soon as crbug.com/517173 is resolved this assert should be enabled in place of the check 235 // As soon as crbug.com/517173 is resolved this assert should be enabled in place of the check
226 // ASSERT(m_clips[context.cacheSlot()]->rootLayer() == context.rootLayer); 236 // ASSERT(m_clips[context.cacheSlot()]->rootLayer() == context.rootLayer);
227 if (m_clips[context.cacheSlot()]->rootLayer() != context.rootLayer) 237 if (m_clips[context.cacheSlot()]->rootLayer() != context.rootLayer)
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 if (context.respectOverflowClip == IgnoreOverflowClip) 456 if (context.respectOverflowClip == IgnoreOverflowClip)
447 return false; 457 return false;
448 458
449 if (layer->isRootLayer() && context.respectOverflowClipForViewport == Ignore OverflowClip) 459 if (layer->isRootLayer() && context.respectOverflowClipForViewport == Ignore OverflowClip)
450 return false; 460 return false;
451 461
452 return true; 462 return true;
453 } 463 }
454 464
455 } // namespace blink 465 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayerClipper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698