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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp

Issue 2652513002: Use control clip rather than overflow clip when present for PaintLayers. (Closed)
Patch Set: Created 3 years, 11 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 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Robert O'Callahan <roc+@cs.cmu.edu> 8 * Robert O'Callahan <roc+@cs.cmu.edu>
9 * David Baron <dbaron@fas.harvard.edu> 9 * David Baron <dbaron@fas.harvard.edu>
10 * Christian Biesinger <cbiesinger@web.de> 10 * Christian Biesinger <cbiesinger@web.de>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 clipRects.setPosClipRect(clipRects.fixedClipRect()); 63 clipRects.setPosClipRect(clipRects.fixedClipRect());
64 clipRects.setOverflowClipRect(clipRects.fixedClipRect()); 64 clipRects.setOverflowClipRect(clipRects.fixedClipRect());
65 clipRects.setFixed(true); 65 clipRects.setFixed(true);
66 } else if (position == RelativePosition) { 66 } else if (position == RelativePosition) {
67 clipRects.setPosClipRect(clipRects.overflowClipRect()); 67 clipRects.setPosClipRect(clipRects.overflowClipRect());
68 } else if (position == AbsolutePosition) { 68 } else if (position == AbsolutePosition) {
69 clipRects.setOverflowClipRect(clipRects.posClipRect()); 69 clipRects.setOverflowClipRect(clipRects.posClipRect());
70 } 70 }
71 } 71 }
72 72
73 // TODO(chrishtr): move this to LayoutBox.
74 static LayoutRect overflowOrControlClip(const LayoutBox& box,
75 const LayoutPoint& location,
76 OverlayScrollbarClipBehavior behavior) {
77 if (box.hasControlClip())
78 return box.controlClipRect(location);
79 return box.overflowClipRect(location, behavior);
80 }
81
73 static void applyClipRects(const ClipRectsContext& context, 82 static void applyClipRects(const ClipRectsContext& context,
74 const LayoutBoxModelObject& layoutObject, 83 const LayoutBoxModelObject& layoutObject,
75 LayoutPoint offset, 84 LayoutPoint offset,
76 ClipRects& clipRects) { 85 ClipRects& clipRects) {
77 DCHECK(layoutObject.isBox()); 86 DCHECK(layoutObject.isBox());
78 const LayoutBox& box = *toLayoutBox(&layoutObject); 87 const LayoutBox& box = *toLayoutBox(&layoutObject);
79 88
80 DCHECK(box.hasClipRelatedProperty() || box.hasControlClip() || 89 DCHECK(box.hasClipRelatedProperty() || box.hasControlClip() ||
81 (box.isSVGRoot() && toLayoutSVGRoot(&box)->shouldApplyViewportClip())); 90 (box.isSVGRoot() && toLayoutSVGRoot(&box)->shouldApplyViewportClip()));
82 LayoutView* view = box.view(); 91 LayoutView* view = box.view();
83 DCHECK(view); 92 DCHECK(view);
84 if (clipRects.fixed() && context.rootLayer->layoutObject() == view) 93 if (clipRects.fixed() && context.rootLayer->layoutObject() == view)
85 offset -= LayoutSize(view->frameView()->getScrollOffset()); 94 offset -= LayoutSize(view->frameView()->getScrollOffset());
86 95
87 if (box.hasOverflowClip() || 96 if (box.hasOverflowClip() ||
88 (box.isSVGRoot() && toLayoutSVGRoot(&box)->shouldApplyViewportClip()) || 97 (box.isSVGRoot() && toLayoutSVGRoot(&box)->shouldApplyViewportClip()) ||
89 box.styleRef().containsPaint() || box.hasControlClip()) { 98 box.styleRef().containsPaint() || box.hasControlClip()) {
90 ClipRect newOverflowClip = 99 ClipRect newOverflowClip = overflowOrControlClip(
91 box.overflowClipRect(offset, context.overlayScrollbarClipBehavior); 100 box, offset, context.overlayScrollbarClipBehavior);
92 newOverflowClip.setHasRadius(box.styleRef().hasBorderRadius()); 101 newOverflowClip.setHasRadius(box.styleRef().hasBorderRadius());
93 clipRects.setOverflowClipRect( 102 clipRects.setOverflowClipRect(
94 intersection(newOverflowClip, clipRects.overflowClipRect())); 103 intersection(newOverflowClip, clipRects.overflowClipRect()));
95 if (box.isPositioned()) 104 if (box.isPositioned())
96 clipRects.setPosClipRect( 105 clipRects.setPosClipRect(
97 intersection(newOverflowClip, clipRects.posClipRect())); 106 intersection(newOverflowClip, clipRects.posClipRect()));
98 if (box.isLayoutView() || box.hasTransformRelatedProperty()) 107 if (box.isLayoutView() || box.hasTransformRelatedProperty())
99 clipRects.setFixedClipRect( 108 clipRects.setFixedClipRect(
100 intersection(newOverflowClip, clipRects.fixedClipRect())); 109 intersection(newOverflowClip, clipRects.fixedClipRect()));
101 if (box.styleRef().containsPaint()) { 110 if (box.styleRef().containsPaint()) {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 354
346 LayoutPoint offset; 355 LayoutPoint offset;
347 if (offsetFromRoot) 356 if (offsetFromRoot)
348 offset = *offsetFromRoot; 357 offset = *offsetFromRoot;
349 else 358 else
350 m_layer.convertToLayerCoords(context.rootLayer, offset); 359 m_layer.convertToLayerCoords(context.rootLayer, offset);
351 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size())); 360 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size()));
352 361
353 // Update the clip rects that will be passed to child layers. 362 // Update the clip rects that will be passed to child layers.
354 if (shouldClipOverflow(context)) { 363 if (shouldClipOverflow(context)) {
355 foregroundRect.intersect( 364 LayoutRect overflowOrControlClipRect =
356 toLayoutBox(layoutObject) 365 overflowOrControlClip(toLayoutBox(layoutObject), offset,
357 .overflowClipRect(offset, context.overlayScrollbarClipBehavior)); 366 context.overlayScrollbarClipBehavior);
367 foregroundRect.intersect(overflowOrControlClipRect);
358 if (layoutObject.styleRef().hasBorderRadius()) 368 if (layoutObject.styleRef().hasBorderRadius())
359 foregroundRect.setHasRadius(true); 369 foregroundRect.setHasRadius(true);
360 370
361 // FIXME: Does not do the right thing with columns yet, since we don't yet 371 // FIXME: Does not do the right thing with columns yet, since we don't yet
362 // factor in the individual column boxes as overflow. 372 // factor in the individual column boxes as overflow.
363 373
364 // The LayoutView is special since its overflow clipping rect may be larger 374 // The LayoutView is special since its overflow clipping rect may be larger
365 // than its box rect (crbug.com/492871). 375 // than its box rect (crbug.com/492871).
366 LayoutRect layerBoundsWithVisualOverflow = 376 LayoutRect layerBoundsWithVisualOverflow =
367 layoutObject.isLayoutView() 377 layoutObject.isLayoutView()
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 const LayoutSize& subpixelAccumulation) const { 587 const LayoutSize& subpixelAccumulation) const {
578 DCHECK(!m_geometryMapper); 588 DCHECK(!m_geometryMapper);
579 ClipRectsContext context(rootLayer, PaintingClipRects, 589 ClipRectsContext context(rootLayer, PaintingClipRects,
580 IgnoreOverlayScrollbarSize, subpixelAccumulation); 590 IgnoreOverlayScrollbarSize, subpixelAccumulation);
581 if (respectOverflowClip == IgnoreOverflowClip) 591 if (respectOverflowClip == IgnoreOverflowClip)
582 context.setIgnoreOverflowClip(); 592 context.setIgnoreOverflowClip();
583 return getClipRects(context); 593 return getClipRects(context);
584 } 594 }
585 595
586 } // namespace blink 596 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698