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

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

Issue 2642193011: Unify all types of overflow-related clips for paint and hit testing. (Closed)
Patch Set: none 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 29 matching lines...) Expand all
40 * other provisions required by the MPL or the GPL, as the case may be. 40 * other provisions required by the MPL or the GPL, as the case may be.
41 * If you do not delete the provisions above, a recipient may use your 41 * If you do not delete the provisions above, a recipient may use your
42 * version of this file under any of the LGPL, the MPL or the GPL. 42 * version of this file under any of the LGPL, the MPL or the GPL.
43 */ 43 */
44 44
45 #include "core/paint/PaintLayerClipper.h" 45 #include "core/paint/PaintLayerClipper.h"
46 46
47 #include "core/frame/FrameView.h" 47 #include "core/frame/FrameView.h"
48 #include "core/frame/Settings.h" 48 #include "core/frame/Settings.h"
49 #include "core/layout/LayoutView.h" 49 #include "core/layout/LayoutView.h"
50 #include "core/layout/svg/LayoutSVGRoot.h"
51 #include "core/paint/ObjectPaintProperties.h" 50 #include "core/paint/ObjectPaintProperties.h"
52 #include "core/paint/PaintLayer.h" 51 #include "core/paint/PaintLayer.h"
53 52
54 namespace blink { 53 namespace blink {
55 54
56 static void adjustClipRectsForChildren(const LayoutBoxModelObject& layoutObject, 55 static void adjustClipRectsForChildren(const LayoutBoxModelObject& layoutObject,
57 ClipRects& clipRects) { 56 ClipRects& clipRects) {
58 EPosition position = layoutObject.styleRef().position(); 57 EPosition position = layoutObject.styleRef().position();
59 // A fixed object is essentially the root of its containing block hierarchy, 58 // A fixed object is essentially the root of its containing block hierarchy,
60 // so when we encounter such an object, we reset our clip rects to the 59 // so when we encounter such an object, we reset our clip rects to the
61 // fixedClipRect. 60 // fixedClipRect.
62 if (position == FixedPosition) { 61 if (position == FixedPosition) {
63 clipRects.setPosClipRect(clipRects.fixedClipRect()); 62 clipRects.setPosClipRect(clipRects.fixedClipRect());
64 clipRects.setOverflowClipRect(clipRects.fixedClipRect()); 63 clipRects.setOverflowClipRect(clipRects.fixedClipRect());
65 clipRects.setFixed(true); 64 clipRects.setFixed(true);
66 } else if (position == RelativePosition) { 65 } else if (position == RelativePosition) {
67 clipRects.setPosClipRect(clipRects.overflowClipRect()); 66 clipRects.setPosClipRect(clipRects.overflowClipRect());
68 } else if (position == AbsolutePosition) { 67 } else if (position == AbsolutePosition) {
69 clipRects.setOverflowClipRect(clipRects.posClipRect()); 68 clipRects.setOverflowClipRect(clipRects.posClipRect());
70 } 69 }
71 } 70 }
72 71
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
82 static void applyClipRects(const ClipRectsContext& context, 72 static void applyClipRects(const ClipRectsContext& context,
83 const LayoutBoxModelObject& layoutObject, 73 const LayoutBoxModelObject& layoutObject,
84 LayoutPoint offset, 74 LayoutPoint offset,
85 ClipRects& clipRects) { 75 ClipRects& clipRects) {
86 DCHECK(layoutObject.isBox()); 76 DCHECK(layoutObject.isBox());
87 const LayoutBox& box = *toLayoutBox(&layoutObject); 77 const LayoutBox& box = *toLayoutBox(&layoutObject);
88 78
89 DCHECK(box.hasClipRelatedProperty() || box.hasControlClip() || 79 DCHECK(box.shouldClipOverflow() || box.hasClip());
90 (box.isSVGRoot() && toLayoutSVGRoot(&box)->shouldApplyViewportClip()));
91 LayoutView* view = box.view(); 80 LayoutView* view = box.view();
92 DCHECK(view); 81 DCHECK(view);
93 if (clipRects.fixed() && context.rootLayer->layoutObject() == view) 82 if (clipRects.fixed() && context.rootLayer->layoutObject() == view)
94 offset -= LayoutSize(view->frameView()->getScrollOffset()); 83 offset -= LayoutSize(view->frameView()->getScrollOffset());
95 84
96 if (box.hasOverflowClip() || 85 if (box.shouldClipOverflow()) {
97 (box.isSVGRoot() && toLayoutSVGRoot(&box)->shouldApplyViewportClip()) || 86 ClipRect newOverflowClip =
98 box.styleRef().containsPaint() || box.hasControlClip()) { 87 box.overflowClipRect(offset, context.overlayScrollbarClipBehavior);
99 ClipRect newOverflowClip = overflowOrControlClip(
100 box, offset, context.overlayScrollbarClipBehavior);
101 newOverflowClip.setHasRadius(box.styleRef().hasBorderRadius()); 88 newOverflowClip.setHasRadius(box.styleRef().hasBorderRadius());
102 clipRects.setOverflowClipRect( 89 clipRects.setOverflowClipRect(
103 intersection(newOverflowClip, clipRects.overflowClipRect())); 90 intersection(newOverflowClip, clipRects.overflowClipRect()));
104 if (box.isPositioned()) 91 if (box.isPositioned())
105 clipRects.setPosClipRect( 92 clipRects.setPosClipRect(
106 intersection(newOverflowClip, clipRects.posClipRect())); 93 intersection(newOverflowClip, clipRects.posClipRect()));
107 if (box.isLayoutView() || box.hasTransformRelatedProperty()) 94 if (box.isLayoutView() || box.hasTransformRelatedProperty())
108 clipRects.setFixedClipRect( 95 clipRects.setFixedClipRect(
109 intersection(newOverflowClip, clipRects.fixedClipRect())); 96 intersection(newOverflowClip, clipRects.fixedClipRect()));
110 if (box.styleRef().containsPaint()) { 97 if (box.styleRef().containsPaint()) {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 341
355 LayoutPoint offset; 342 LayoutPoint offset;
356 if (offsetFromRoot) 343 if (offsetFromRoot)
357 offset = *offsetFromRoot; 344 offset = *offsetFromRoot;
358 else 345 else
359 m_layer.convertToLayerCoords(context.rootLayer, offset); 346 m_layer.convertToLayerCoords(context.rootLayer, offset);
360 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size())); 347 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size()));
361 348
362 // Update the clip rects that will be passed to child layers. 349 // Update the clip rects that will be passed to child layers.
363 if (shouldClipOverflow(context)) { 350 if (shouldClipOverflow(context)) {
364 LayoutRect overflowOrControlClipRect = 351 LayoutRect overflowAndClipRect =
365 overflowOrControlClip(toLayoutBox(layoutObject), offset, 352 toLayoutBox(layoutObject)
366 context.overlayScrollbarClipBehavior); 353 .overflowClipRect(offset, context.overlayScrollbarClipBehavior);
367 foregroundRect.intersect(overflowOrControlClipRect); 354 foregroundRect.intersect(overflowAndClipRect);
368 if (layoutObject.styleRef().hasBorderRadius()) 355 if (layoutObject.styleRef().hasBorderRadius())
369 foregroundRect.setHasRadius(true); 356 foregroundRect.setHasRadius(true);
370 357
371 // FIXME: Does not do the right thing with columns yet, since we don't yet 358 // FIXME: Does not do the right thing with columns yet, since we don't yet
372 // factor in the individual column boxes as overflow. 359 // factor in the individual column boxes as overflow.
373 360
374 // The LayoutView is special since its overflow clipping rect may be larger 361 // The LayoutView is special since its overflow clipping rect may be larger
375 // than its box rect (crbug.com/492871). 362 // than its box rect (crbug.com/492871).
376 LayoutRect layerBoundsWithVisualOverflow = 363 LayoutRect layerBoundsWithVisualOverflow =
377 layoutObject.isLayoutView() 364 layoutObject.isLayoutView()
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 541
555 bool PaintLayerClipper::shouldClipOverflow( 542 bool PaintLayerClipper::shouldClipOverflow(
556 const ClipRectsContext& context) const { 543 const ClipRectsContext& context) const {
557 if (!m_layer.layoutObject()->isBox()) 544 if (!m_layer.layoutObject()->isBox())
558 return false; 545 return false;
559 const LayoutBox& box = *toLayoutBox(m_layer.layoutObject()); 546 const LayoutBox& box = *toLayoutBox(m_layer.layoutObject());
560 547
561 if (!shouldRespectOverflowClip(context)) 548 if (!shouldRespectOverflowClip(context))
562 return false; 549 return false;
563 550
564 return box.hasOverflowClip() || box.styleRef().containsPaint() || 551 return box.shouldClipOverflow();
565 box.hasControlClip() ||
566 (box.isSVGRoot() && toLayoutSVGRoot(&box)->shouldApplyViewportClip());
567 } 552 }
568 553
569 bool PaintLayerClipper::shouldRespectOverflowClip( 554 bool PaintLayerClipper::shouldRespectOverflowClip(
570 const ClipRectsContext& context) const { 555 const ClipRectsContext& context) const {
571 if (&m_layer != context.rootLayer) 556 if (&m_layer != context.rootLayer)
572 return true; 557 return true;
573 558
574 if (context.respectOverflowClip == IgnoreOverflowClip) 559 if (context.respectOverflowClip == IgnoreOverflowClip)
575 return false; 560 return false;
576 561
(...skipping 10 matching lines...) Expand all
587 const LayoutSize& subpixelAccumulation) const { 572 const LayoutSize& subpixelAccumulation) const {
588 DCHECK(!m_geometryMapper); 573 DCHECK(!m_geometryMapper);
589 ClipRectsContext context(rootLayer, PaintingClipRects, 574 ClipRectsContext context(rootLayer, PaintingClipRects,
590 IgnoreOverlayScrollbarSize, subpixelAccumulation); 575 IgnoreOverlayScrollbarSize, subpixelAccumulation);
591 if (respectOverflowClip == IgnoreOverflowClip) 576 if (respectOverflowClip == IgnoreOverflowClip)
592 context.setIgnoreOverflowClip(); 577 context.setIgnoreOverflowClip();
593 return getClipRects(context); 578 return getClipRects(context);
594 } 579 }
595 580
596 } // namespace blink 581 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/BoxClipper.cpp ('k') | third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698