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

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

Issue 2343673003: SVG root viewport clip in paint property tree (Closed)
Patch Set: - Created 4 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
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/paint/ObjectPaintProperties.h" 9 #include "core/paint/ObjectPaintProperties.h"
9 #include "core/paint/PaintInfo.h" 10 #include "core/paint/PaintInfo.h"
10 #include "core/paint/PaintLayer.h" 11 #include "core/paint/PaintLayer.h"
11 #include "platform/RuntimeEnabledFeatures.h" 12 #include "platform/RuntimeEnabledFeatures.h"
12 #include "platform/graphics/GraphicsLayer.h" 13 #include "platform/graphics/GraphicsLayer.h"
13 #include "platform/graphics/paint/ClipDisplayItem.h" 14 #include "platform/graphics/paint/ClipDisplayItem.h"
14 #include "platform/graphics/paint/PaintController.h" 15 #include "platform/graphics/paint/PaintController.h"
15 16
16 namespace blink { 17 namespace blink {
17 18
19 static bool boxNeedsClip(const LayoutBox& box)
20 {
21 if (box.hasControlClip())
22 return true;
23 if (box.isSVGRoot() && toLayoutSVGRoot(box).shouldApplyViewportClip())
24 return true;
25 if (box.hasLayer() && box.layer()->isSelfPaintingLayer())
26 return false;
27 return box.hasOverflowClip() || box.styleRef().containsPaint();
28 }
29
18 BoxClipper::BoxClipper(const LayoutBox& box, const PaintInfo& paintInfo, const L ayoutPoint& accumulatedOffset, ContentsClipBehavior contentsClipBehavior) 30 BoxClipper::BoxClipper(const LayoutBox& box, const PaintInfo& paintInfo, const L ayoutPoint& accumulatedOffset, ContentsClipBehavior contentsClipBehavior)
19 : m_box(box) 31 : m_box(box)
20 , m_paintInfo(paintInfo) 32 , m_paintInfo(paintInfo)
21 , m_clipType(DisplayItem::kUninitializedType) 33 , m_clipType(DisplayItem::kUninitializedType)
22 { 34 {
23 ASSERT(m_paintInfo.phase != PaintPhaseSelfBlockBackgroundOnly && m_paintInfo .phase != PaintPhaseSelfOutlineOnly); 35 DCHECK(m_paintInfo.phase != PaintPhaseSelfBlockBackgroundOnly && m_paintInfo .phase != PaintPhaseSelfOutlineOnly);
24 36
25 if (m_paintInfo.phase == PaintPhaseMask) 37 if (m_paintInfo.phase == PaintPhaseMask)
26 return; 38 return;
27 39
28 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { 40 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
29 const auto* objectProperties = m_box.objectPaintProperties(); 41 const auto* objectProperties = m_box.objectPaintProperties();
30 if (objectProperties && objectProperties->overflowClip()) { 42 if (objectProperties && objectProperties->overflowClip()) {
31 PaintChunkProperties properties(paintInfo.context.getPaintController ().currentPaintChunkProperties()); 43 PaintChunkProperties properties(paintInfo.context.getPaintController ().currentPaintChunkProperties());
32 properties.clip = objectProperties->overflowClip(); 44 properties.clip = objectProperties->overflowClip();
33 m_scopedClipProperty.emplace(paintInfo.context.getPaintController(), box, paintInfo.displayItemTypeForClipping(), properties); 45 m_scopedClipProperty.emplace(paintInfo.context.getPaintController(), box, paintInfo.displayItemTypeForClipping(), properties);
34 } 46 }
35 return; 47 return;
36 } 48 }
37 49
38 bool isControlClip = m_box.hasControlClip(); 50 if (!boxNeedsClip(m_box))
39 bool isOverflowOrContainmentClip = (m_box.hasOverflowClip() || box.styleRef( ).containsPaint()) && !(m_box.hasLayer() && m_box.layer()->isSelfPaintingLayer() );
40
41 if (!isControlClip && !isOverflowOrContainmentClip)
42 return; 51 return;
43 52
44 LayoutRect clipRect = isControlClip ? m_box.controlClipRect(accumulatedOffse t) : m_box.overflowClipRect(accumulatedOffset); 53 LayoutRect clipRect = m_box.hasControlClip() ? m_box.controlClipRect(accumul atedOffset) : m_box.overflowClipRect(accumulatedOffset);
45 FloatRoundedRect clipRoundedRect(0, 0, 0, 0); 54 FloatRoundedRect clipRoundedRect(0, 0, 0, 0);
46 bool hasBorderRadius = m_box.style()->hasBorderRadius(); 55 bool hasBorderRadius = m_box.style()->hasBorderRadius();
47 if (hasBorderRadius) 56 if (hasBorderRadius)
48 clipRoundedRect = m_box.style()->getRoundedInnerBorderFor(LayoutRect(acc umulatedOffset, m_box.size())); 57 clipRoundedRect = m_box.style()->getRoundedInnerBorderFor(LayoutRect(acc umulatedOffset, m_box.size()));
49 58
50 // Selection may extend beyond visual overflow, so this optimization is inva lid if selection is present. 59 // Selection may extend beyond visual overflow, so this optimization is inva lid if selection is present.
51 if (contentsClipBehavior == SkipContentsClipIfPossible && box.getSelectionSt ate() == SelectionNone) { 60 if (contentsClipBehavior == SkipContentsClipIfPossible && box.getSelectionSt ate() == SelectionNone) {
52 LayoutRect contentsVisualOverflow = m_box.contentsVisualOverflowRect(); 61 LayoutRect contentsVisualOverflow = m_box.contentsVisualOverflowRect();
53 if (contentsVisualOverflow.isEmpty()) 62 if (contentsVisualOverflow.isEmpty())
54 return; 63 return;
(...skipping 15 matching lines...) Expand all
70 roundedRects.append(clipRoundedRect); 79 roundedRects.append(clipRoundedRect);
71 m_paintInfo.context.getPaintController().createAndAppend<ClipDisplayItem >(m_box, m_clipType, pixelSnappedIntRect(clipRect), roundedRects); 80 m_paintInfo.context.getPaintController().createAndAppend<ClipDisplayItem >(m_box, m_clipType, pixelSnappedIntRect(clipRect), roundedRects);
72 } 81 }
73 } 82 }
74 83
75 BoxClipper::~BoxClipper() 84 BoxClipper::~BoxClipper()
76 { 85 {
77 if (m_clipType == DisplayItem::kUninitializedType) 86 if (m_clipType == DisplayItem::kUninitializedType)
78 return; 87 return;
79 88
80 DCHECK(m_box.hasControlClip() || ((m_box.hasOverflowClip() || m_box.style()- >containsPaint()) && !(m_box.hasLayer() && m_box.layer()->isSelfPaintingLayer()) )); 89 DCHECK(boxNeedsClip(m_box));
81 m_paintInfo.context.getPaintController().endItem<EndClipDisplayItem>(m_box, DisplayItem::clipTypeToEndClipType(m_clipType)); 90 m_paintInfo.context.getPaintController().endItem<EndClipDisplayItem>(m_box, DisplayItem::clipTypeToEndClipType(m_clipType));
82 } 91 }
83 92
84 } // namespace blink 93 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698