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

Side by Side Diff: third_party/WebKit/Source/core/paint/BoxClipper.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 // 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/paint/BoxClipper.h" 5 #include "core/paint/BoxClipper.h"
6 6
7 #include "core/layout/LayoutBox.h" 7 #include "core/layout/LayoutBox.h"
8 #include "core/layout/svg/LayoutSVGRoot.h" 8 #include "core/layout/svg/LayoutSVGRoot.h"
9 #include "core/paint/ObjectPaintProperties.h" 9 #include "core/paint/ObjectPaintProperties.h"
10 #include "core/paint/PaintInfo.h" 10 #include "core/paint/PaintInfo.h"
11 #include "core/paint/PaintLayer.h" 11 #include "core/paint/PaintLayer.h"
12 #include "platform/RuntimeEnabledFeatures.h" 12 #include "platform/RuntimeEnabledFeatures.h"
13 #include "platform/graphics/GraphicsLayer.h" 13 #include "platform/graphics/GraphicsLayer.h"
14 #include "platform/graphics/paint/ClipDisplayItem.h" 14 #include "platform/graphics/paint/ClipDisplayItem.h"
15 #include "platform/graphics/paint/PaintController.h" 15 #include "platform/graphics/paint/PaintController.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 // Clips for boxes are applied by the box's PaintLayerClipper, if the box has 19 // Clips for boxes are applied by the box's PaintLayerClipper, if the box has
20 // a self-painting PaintLayer. Otherwise the box clips itself. 20 // a self-painting PaintLayer. Otherwise the box clips itself.
21 // Note that this method is very similar to 21 // Note that this method is very similar to
22 // PaintLayerClipper::shouldClipOverflow for that reason. 22 // PaintLayerClipper::shouldClipOverflow for that reason.
23 // 23 //
24 // An exception is control clip, which is currently never applied by 24 // An exception is control clip, which is currently never applied by
25 // PaintLayerClipper. 25 // PaintLayerClipper.
26 static bool boxNeedsClip(const LayoutBox& box) { 26 static bool boxNeedsClip(const LayoutBox& box) {
27 if (box.hasLayer() && box.layer()->isSelfPaintingLayer()) 27 if (box.hasLayer() && box.layer()->isSelfPaintingLayer())
28 return false; 28 return false;
29 if (box.isSVGRoot() && toLayoutSVGRoot(box).shouldApplyViewportClip()) 29 return box.shouldClipOverflow();
30 return true;
31 return box.hasOverflowClip() || box.styleRef().containsPaint() ||
32 box.hasControlClip();
33 } 30 }
34 31
35 DISABLE_CFI_PERF 32 DISABLE_CFI_PERF
36 BoxClipper::BoxClipper(const LayoutBox& box, 33 BoxClipper::BoxClipper(const LayoutBox& box,
37 const PaintInfo& paintInfo, 34 const PaintInfo& paintInfo,
38 const LayoutPoint& accumulatedOffset, 35 const LayoutPoint& accumulatedOffset,
39 ContentsClipBehavior contentsClipBehavior) 36 ContentsClipBehavior contentsClipBehavior)
40 : m_box(box), 37 : m_box(box),
41 m_paintInfo(paintInfo), 38 m_paintInfo(paintInfo),
42 m_clipType(DisplayItem::kUninitializedType) { 39 m_clipType(DisplayItem::kUninitializedType) {
(...skipping 12 matching lines...) Expand all
55 m_scopedClipProperty.emplace(paintInfo.context.getPaintController(), box, 52 m_scopedClipProperty.emplace(paintInfo.context.getPaintController(), box,
56 paintInfo.displayItemTypeForClipping(), 53 paintInfo.displayItemTypeForClipping(),
57 properties); 54 properties);
58 } 55 }
59 return; 56 return;
60 } 57 }
61 58
62 if (!boxNeedsClip(m_box)) 59 if (!boxNeedsClip(m_box))
63 return; 60 return;
64 61
65 LayoutRect clipRect = m_box.hasControlClip() 62 LayoutRect clipRect = m_box.overflowClipRect(accumulatedOffset);
66 ? m_box.controlClipRect(accumulatedOffset)
67 : m_box.overflowClipRect(accumulatedOffset);
68 FloatRoundedRect clipRoundedRect(0, 0, 0, 0); 63 FloatRoundedRect clipRoundedRect(0, 0, 0, 0);
69 bool hasBorderRadius = m_box.style()->hasBorderRadius(); 64 bool hasBorderRadius = m_box.style()->hasBorderRadius();
70 if (hasBorderRadius) 65 if (hasBorderRadius)
71 clipRoundedRect = m_box.style()->getRoundedInnerBorderFor( 66 clipRoundedRect = m_box.style()->getRoundedInnerBorderFor(
72 LayoutRect(accumulatedOffset, m_box.size())); 67 LayoutRect(accumulatedOffset, m_box.size()));
73 68
74 // Selection may extend beyond visual overflow, so this optimization is 69 // Selection may extend beyond visual overflow, so this optimization is
75 // invalid if selection is present. 70 // invalid if selection is present.
76 if (contentsClipBehavior == SkipContentsClipIfPossible && 71 if (contentsClipBehavior == SkipContentsClipIfPossible &&
77 box.getSelectionState() == SelectionNone) { 72 box.getSelectionState() == SelectionNone) {
(...skipping 26 matching lines...) Expand all
104 BoxClipper::~BoxClipper() { 99 BoxClipper::~BoxClipper() {
105 if (m_clipType == DisplayItem::kUninitializedType) 100 if (m_clipType == DisplayItem::kUninitializedType)
106 return; 101 return;
107 102
108 DCHECK(boxNeedsClip(m_box)); 103 DCHECK(boxNeedsClip(m_box));
109 m_paintInfo.context.getPaintController().endItem<EndClipDisplayItem>( 104 m_paintInfo.context.getPaintController().endItem<EndClipDisplayItem>(
110 m_box, DisplayItem::clipTypeToEndClipType(m_clipType)); 105 m_box, DisplayItem::clipTypeToEndClipType(m_clipType));
111 } 106 }
112 107
113 } // namespace blink 108 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/BlockPainter.cpp ('k') | third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698