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

Side by Side Diff: Source/core/layout/LayerClipper.cpp

Issue 952273006: Make the constructor of a LayoutRect from an IntRect explicit. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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/layout/Layer.cpp ('k') | Source/core/layout/LayerScrollableArea.cpp » ('j') | 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 LayoutRect LayerClipper::childrenClipRect() const 178 LayoutRect LayerClipper::childrenClipRect() const
179 { 179 {
180 // FIXME: border-radius not accounted for. 180 // FIXME: border-radius not accounted for.
181 // FIXME: Regions not accounted for. 181 // FIXME: Regions not accounted for.
182 Layer* clippingRootLayer = clippingRootForPainting(); 182 Layer* clippingRootLayer = clippingRootForPainting();
183 LayoutRect layerBounds; 183 LayoutRect layerBounds;
184 ClipRect backgroundRect, foregroundRect, outlineRect; 184 ClipRect backgroundRect, foregroundRect, outlineRect;
185 // Need to use uncached clip rects, because the value of 'dontClipToOverflow ' may be different from the painting path (<rdar://problem/11844909>). 185 // Need to use uncached clip rects, because the value of 'dontClipToOverflow ' may be different from the painting path (<rdar://problem/11844909>).
186 ClipRectsContext context(clippingRootLayer, UncachedClipRects); 186 ClipRectsContext context(clippingRootLayer, UncachedClipRects);
187 calculateRects(context, m_renderer.view()->unscaledDocumentRect(), layerBoun ds, backgroundRect, foregroundRect, outlineRect); 187 calculateRects(context, LayoutRect(m_renderer.view()->unscaledDocumentRect() ), layerBounds, backgroundRect, foregroundRect, outlineRect);
188 return clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQuad(foregrou ndRect.rect())).enclosingBoundingBox(); 188 return LayoutRect(clippingRootLayer->renderer()->localToAbsoluteQuad(FloatQu ad(foregroundRect.rect())).enclosingBoundingBox());
189 } 189 }
190 190
191 LayoutRect LayerClipper::localClipRect() const 191 LayoutRect LayerClipper::localClipRect() const
192 { 192 {
193 // FIXME: border-radius not accounted for. 193 // FIXME: border-radius not accounted for.
194 Layer* clippingRootLayer = clippingRootForPainting(); 194 Layer* clippingRootLayer = clippingRootForPainting();
195 LayoutRect layerBounds; 195 LayoutRect layerBounds;
196 ClipRect backgroundRect, foregroundRect, outlineRect; 196 ClipRect backgroundRect, foregroundRect, outlineRect;
197 ClipRectsContext context(clippingRootLayer, PaintingClipRects); 197 ClipRectsContext context(clippingRootLayer, PaintingClipRects);
198 calculateRects(context, LayoutRect::infiniteIntRect(), layerBounds, backgrou ndRect, foregroundRect, outlineRect); 198 calculateRects(context, LayoutRect(LayoutRect::infiniteIntRect()), layerBoun ds, backgroundRect, foregroundRect, outlineRect);
199 199
200 LayoutRect clipRect = backgroundRect.rect(); 200 LayoutRect clipRect = backgroundRect.rect();
201 if (clipRect == LayoutRect::infiniteIntRect()) 201 if (clipRect == LayoutRect::infiniteIntRect())
202 return clipRect; 202 return clipRect;
203 203
204 LayoutPoint clippingRootOffset; 204 LayoutPoint clippingRootOffset;
205 m_renderer.layer()->convertToLayerCoords(clippingRootLayer, clippingRootOffs et); 205 m_renderer.layer()->convertToLayerCoords(clippingRootLayer, clippingRootOffs et);
206 clipRect.moveBy(-clippingRootOffset); 206 clipRect.moveBy(-clippingRootOffset);
207 207
208 return clipRect; 208 return clipRect;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 foregroundRect.intersect(newPosClip); 269 foregroundRect.intersect(newPosClip);
270 outlineRect.intersect(newPosClip); 270 outlineRect.intersect(newPosClip);
271 } 271 }
272 } 272 }
273 273
274 void LayerClipper::calculateClipRects(const ClipRectsContext& context, ClipRects & clipRects) const 274 void LayerClipper::calculateClipRects(const ClipRectsContext& context, ClipRects & clipRects) const
275 { 275 {
276 bool rootLayerScrolls = m_renderer.document().settings() && m_renderer.docum ent().settings()->rootLayerScrolls(); 276 bool rootLayerScrolls = m_renderer.document().settings() && m_renderer.docum ent().settings()->rootLayerScrolls();
277 if (!m_renderer.layer()->parent() && !rootLayerScrolls) { 277 if (!m_renderer.layer()->parent() && !rootLayerScrolls) {
278 // The root layer's clip rect is always infinite. 278 // The root layer's clip rect is always infinite.
279 clipRects.reset(LayoutRect::infiniteIntRect()); 279 clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect()));
280 return; 280 return;
281 } 281 }
282 282
283 bool isClippingRoot = m_renderer.layer() == context.rootLayer; 283 bool isClippingRoot = m_renderer.layer() == context.rootLayer;
284 284
285 // For transformed layers, the root layer was shifted to be us, so there is no need to 285 // For transformed layers, the root layer was shifted to be us, so there is no need to
286 // examine the parent. We want to cache clip rects with us as the root. 286 // examine the parent. We want to cache clip rects with us as the root.
287 Layer* parentLayer = !isClippingRoot ? m_renderer.layer()->parent() : 0; 287 Layer* parentLayer = !isClippingRoot ? m_renderer.layer()->parent() : 0;
288 288
289 // Ensure that our parent's clip has been calculated so that we can examine the values. 289 // Ensure that our parent's clip has been calculated so that we can examine the values.
290 if (parentLayer) { 290 if (parentLayer) {
291 // FIXME: Why don't we just call getClipRects here? 291 // FIXME: Why don't we just call getClipRects here?
292 if (context.usesCache() && parentLayer->clipper().cachedClipRects(contex t)) { 292 if (context.usesCache() && parentLayer->clipper().cachedClipRects(contex t)) {
293 clipRects = *parentLayer->clipper().cachedClipRects(context); 293 clipRects = *parentLayer->clipper().cachedClipRects(context);
294 } else { 294 } else {
295 parentLayer->clipper().calculateClipRects(context, clipRects); 295 parentLayer->clipper().calculateClipRects(context, clipRects);
296 } 296 }
297 } else { 297 } else {
298 clipRects.reset(LayoutRect::infiniteIntRect()); 298 clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect()));
299 } 299 }
300 300
301 adjustClipRectsForChildren(m_renderer, clipRects); 301 adjustClipRectsForChildren(m_renderer, clipRects);
302 302
303 if ((m_renderer.hasOverflowClip() && (context.respectOverflowClip == Respect OverflowClip || !isClippingRoot)) || m_renderer.hasClip()) { 303 if ((m_renderer.hasOverflowClip() && (context.respectOverflowClip == Respect OverflowClip || !isClippingRoot)) || m_renderer.hasClip()) {
304 // This offset cannot use convertToLayerCoords, because sometimes our ro otLayer may be across 304 // This offset cannot use convertToLayerCoords, because sometimes our ro otLayer may be across
305 // some transformed layer boundary, for example, in the LayerCompositor overlapMap, where 305 // some transformed layer boundary, for example, in the LayerCompositor overlapMap, where
306 // clipRects are needed in view space. 306 // clipRects are needed in view space.
307 applyClipRects(context, m_renderer, roundedLayoutPoint(m_renderer.localT oContainerPoint(FloatPoint(), context.rootLayer->renderer())), clipRects); 307 applyClipRects(context, m_renderer, roundedLayoutPoint(m_renderer.localT oContainerPoint(FloatPoint(), context.rootLayer->renderer())), clipRects);
308 } 308 }
(...skipping 10 matching lines...) Expand all
319 return parentRects.overflowClipRect(); 319 return parentRects.overflowClipRect();
320 } 320 }
321 321
322 ClipRect LayerClipper::backgroundClipRect(const ClipRectsContext& context) const 322 ClipRect LayerClipper::backgroundClipRect(const ClipRectsContext& context) const
323 { 323 {
324 ASSERT(m_renderer.layer()->parent()); 324 ASSERT(m_renderer.layer()->parent());
325 ASSERT(m_renderer.view()); 325 ASSERT(m_renderer.view());
326 326
327 RefPtr<ClipRects> parentClipRects = ClipRects::create(); 327 RefPtr<ClipRects> parentClipRects = ClipRects::create();
328 if (m_renderer.layer() == context.rootLayer) 328 if (m_renderer.layer() == context.rootLayer)
329 parentClipRects->reset(LayoutRect::infiniteIntRect()); 329 parentClipRects->reset(LayoutRect(LayoutRect::infiniteIntRect()));
330 else 330 else
331 m_renderer.layer()->parent()->clipper().getOrCalculateClipRects(context, *parentClipRects); 331 m_renderer.layer()->parent()->clipper().getOrCalculateClipRects(context, *parentClipRects);
332 332
333 ClipRect result = backgroundClipRectForPosition(*parentClipRects, m_renderer .style()->position()); 333 ClipRect result = backgroundClipRectForPosition(*parentClipRects, m_renderer .style()->position());
334 334
335 // Note: infinite clipRects should not be scrolled here, otherwise they will accidentally no longer be considered infinite. 335 // Note: infinite clipRects should not be scrolled here, otherwise they will accidentally no longer be considered infinite.
336 if (parentClipRects->fixed() && context.rootLayer->renderer() == m_renderer. view() && result != LayoutRect::infiniteIntRect()) 336 if (parentClipRects->fixed() && context.rootLayer->renderer() == m_renderer. view() && result != LayoutRect(LayoutRect::infiniteIntRect()))
337 result.move(m_renderer.view()->frameView()->scrollOffsetForViewportConst rainedObjects()); 337 result.move(m_renderer.view()->frameView()->scrollOffsetForViewportConst rainedObjects());
338 338
339 return result; 339 return result;
340 } 340 }
341 341
342 void LayerClipper::getOrCalculateClipRects(const ClipRectsContext& context, Clip Rects& clipRects) const 342 void LayerClipper::getOrCalculateClipRects(const ClipRectsContext& context, Clip Rects& clipRects) const
343 { 343 {
344 if (context.usesCache()) 344 if (context.usesCache())
345 clipRects = *getClipRects(context); 345 clipRects = *getClipRects(context);
346 else 346 else
(...skipping 18 matching lines...) Expand all
365 ASSERT(current); 365 ASSERT(current);
366 if (current->transform() || current->isPaintInvalidationContainer()) 366 if (current->transform() || current->isPaintInvalidationContainer())
367 return const_cast<Layer*>(current); 367 return const_cast<Layer*>(current);
368 } 368 }
369 369
370 ASSERT_NOT_REACHED(); 370 ASSERT_NOT_REACHED();
371 return 0; 371 return 0;
372 } 372 }
373 373
374 } // namespace blink 374 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/Layer.cpp ('k') | Source/core/layout/LayerScrollableArea.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698