Index: Source/core/paint/LayerDescendantClipRecorder.cpp |
diff --git a/Source/core/paint/LayerDescendantClipRecorder.cpp b/Source/core/paint/LayerDescendantClipRecorder.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..86b0db87e87d982a6bf93eaa94856b0b9d8b8449 |
--- /dev/null |
+++ b/Source/core/paint/LayerDescendantClipRecorder.cpp |
@@ -0,0 +1,46 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "core/paint/LayerDescendantClipRecorder.h" |
+ |
+#include "core/layout/LayoutBox.h" |
+#include "platform/RuntimeEnabledFeatures.h" |
+#include "platform/geometry/IntRect.h" |
+#include "platform/geometry/LayoutPoint.h" |
+#include "platform/graphics/GraphicsContext.h" |
+#include "platform/graphics/paint/ClipDisplayItem.h" |
+#include "platform/graphics/paint/DisplayItemList.h" |
+ |
+namespace blink { |
+ |
+LayerDescendantClipRecorder::LayerDescendantClipRecorder(GraphicsContext& context, const LayoutBox& layoutBox, const LayoutPoint& paintOffset) |
+ : m_graphicsContext(context) |
+ , m_layoutBox(layoutBox) |
+{ |
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
+ ASSERT(layoutBox.hasOverflowClip()); |
+ |
+ LayoutRect clipRect = layoutBox.overflowClipRect(paintOffset); |
+ Vector<FloatRoundedRect> roundedRects; |
+ if (layoutBox.style()->hasBorderRadius()) |
+ roundedRects.append(layoutBox.style()->getRoundedInnerBorderFor(LayoutRect(paintOffset, layoutBox.size()))); |
+ |
+ if (m_graphicsContext.displayItemList()->displayItemConstructionIsDisabled()) |
+ return; |
+ m_graphicsContext.displayItemList()->createAndAppend<ClipDisplayItem>(m_layoutBox, DisplayItem::ClipDescendantStackingContext, pixelSnappedIntRect(clipRect), roundedRects); |
+} |
+ |
+LayerDescendantClipRecorder::~LayerDescendantClipRecorder() |
+{ |
+ ASSERT(m_graphicsContext.displayItemList()); |
+ if (!m_graphicsContext.displayItemList()->displayItemConstructionIsDisabled()) { |
+ if (m_graphicsContext.displayItemList()->lastDisplayItemIsNoopBegin()) |
+ m_graphicsContext.displayItemList()->removeLastDisplayItem(); |
+ else |
+ m_graphicsContext.displayItemList()->createAndAppend<EndClipDisplayItem>(m_layoutBox, DisplayItem::clipTypeToEndClipType(DisplayItem::ClipDescendantStackingContext)); |
+ } |
+} |
+ |
+} // namespace blink |