Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp b/third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..73aa85232977fe044c0b0d62d6a56bcf880500ab |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp |
| @@ -0,0 +1,63 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
|
pdr.
2016/09/26 17:04:52
Nit: 2016
chrishtr
2016/09/26 17:37:54
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "core/paint/PaintLayerClipper.h" |
| + |
| +#include "core/layout/LayoutBoxModelObject.h" |
| +#include "core/layout/LayoutTestHelper.h" |
| +#include "core/layout/LayoutView.h" |
| +#include "core/paint/PaintLayer.h" |
| + |
| +namespace blink { |
| + |
| +class PaintLayerClipperTest : public RenderingTest { |
| +public: |
| + PaintLayerClipperTest() |
| + : RenderingTest(SingleChildFrameLoaderClient::create()) |
| + { } |
| +}; |
| + |
| + |
| +TEST_F(PaintLayerClipperTest, LayoutSVGRoot) |
| +{ |
| + setBodyInnerHTML("<!DOCTYPE html>" |
|
pdr.
2016/09/26 17:04:52
Nit: I recently learned setBodyInnerHTML literally
chrishtr
2016/09/26 17:37:54
Done.
|
| + "<svg id=target width=200 height=300 style='position: relative'>" |
| + " <rect width=400 height=500 fill='blue'/>" |
| + "</svg>"); |
| + |
| + Element* target = document().getElementById("target"); |
| + PaintLayer* targetPaintLayer = toLayoutBoxModelObject(target->layoutObject())->layer(); |
| + ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects); |
| + LayoutRect layerBounds; |
| + ClipRect backgroundRect, foregroundRect; |
| + targetPaintLayer->clipper().calculateRects(context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds, |
| + backgroundRect, foregroundRect); |
| + EXPECT_EQ(LayoutRect(LayoutRect::infiniteIntRect()), backgroundRect.rect()); |
| + EXPECT_EQ(LayoutRect(LayoutRect::infiniteIntRect()), foregroundRect.rect()); |
| + EXPECT_EQ(LayoutRect(8, 8, 200, 300), layerBounds); |
| +} |
| + |
| +TEST_F(PaintLayerClipperTest, LayoutSVGRootChild) |
| +{ |
| + setBodyInnerHTML("<!DOCTYPE html>" |
| + "<svg width=200 height=300 style='position: relative'>" |
| + " <foreignObject width=400 height=500>" |
| + " <div id=target xmlns='http://www.w3.org/1999/xhtml' style='position: relative'></div>" |
| + " </foreignObject>" |
| + "</svg>"); |
| + |
| + Element* target = document().getElementById("target"); |
| + PaintLayer* targetPaintLayer = toLayoutBoxModelObject(target->layoutObject())->layer(); |
| + ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects); |
| + LayoutRect layerBounds; |
| + ClipRect backgroundRect, foregroundRect; |
| + targetPaintLayer->clipper().calculateRects(context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds, |
| + backgroundRect, foregroundRect); |
| + EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect()); |
| + EXPECT_EQ(LayoutRect(8, 8, 200, 300), foregroundRect.rect()); |
| + EXPECT_EQ(LayoutRect(8, 8, 400, 0), layerBounds); |
| +} |
| + |
| + |
| +} // namespace blink |