| OLD | NEW |
| 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.hasControlClip()) | |
| 28 return true; | |
| 29 if (box.hasLayer() && box.layer()->isSelfPaintingLayer()) | 27 if (box.hasLayer() && box.layer()->isSelfPaintingLayer()) |
| 30 return false; | 28 return false; |
| 31 if (box.isSVGRoot() && toLayoutSVGRoot(box).shouldApplyViewportClip()) | 29 if (box.isSVGRoot() && toLayoutSVGRoot(box).shouldApplyViewportClip()) |
| 32 return true; | 30 return true; |
| 33 return box.hasOverflowClip() || box.styleRef().containsPaint(); | 31 return box.hasOverflowClip() || box.styleRef().containsPaint() || |
| 32 box.hasControlClip(); |
| 34 } | 33 } |
| 35 | 34 |
| 36 DISABLE_CFI_PERF | 35 DISABLE_CFI_PERF |
| 37 BoxClipper::BoxClipper(const LayoutBox& box, | 36 BoxClipper::BoxClipper(const LayoutBox& box, |
| 38 const PaintInfo& paintInfo, | 37 const PaintInfo& paintInfo, |
| 39 const LayoutPoint& accumulatedOffset, | 38 const LayoutPoint& accumulatedOffset, |
| 40 ContentsClipBehavior contentsClipBehavior) | 39 ContentsClipBehavior contentsClipBehavior) |
| 41 : m_box(box), | 40 : m_box(box), |
| 42 m_paintInfo(paintInfo), | 41 m_paintInfo(paintInfo), |
| 43 m_clipType(DisplayItem::kUninitializedType) { | 42 m_clipType(DisplayItem::kUninitializedType) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 BoxClipper::~BoxClipper() { | 104 BoxClipper::~BoxClipper() { |
| 106 if (m_clipType == DisplayItem::kUninitializedType) | 105 if (m_clipType == DisplayItem::kUninitializedType) |
| 107 return; | 106 return; |
| 108 | 107 |
| 109 DCHECK(boxNeedsClip(m_box)); | 108 DCHECK(boxNeedsClip(m_box)); |
| 110 m_paintInfo.context.getPaintController().endItem<EndClipDisplayItem>( | 109 m_paintInfo.context.getPaintController().endItem<EndClipDisplayItem>( |
| 111 m_box, DisplayItem::clipTypeToEndClipType(m_clipType)); | 110 m_box, DisplayItem::clipTypeToEndClipType(m_clipType)); |
| 112 } | 111 } |
| 113 | 112 |
| 114 } // namespace blink | 113 } // namespace blink |
| OLD | NEW |