| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/paint/PaintLayerClipper.h" |
| 6 |
| 7 #include "core/layout/LayoutBoxModelObject.h" |
| 8 #include "core/layout/LayoutTestHelper.h" |
| 9 #include "core/layout/LayoutView.h" |
| 10 #include "core/paint/PaintLayer.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 class PaintLayerClipperTest : public RenderingTest { |
| 15 public: |
| 16 PaintLayerClipperTest() |
| 17 : RenderingTest(SingleChildFrameLoaderClient::create()) |
| 18 { } |
| 19 }; |
| 20 |
| 21 |
| 22 TEST_F(PaintLayerClipperTest, LayoutSVGRoot) |
| 23 { |
| 24 setBodyInnerHTML("<!DOCTYPE html>" |
| 25 "<svg id=target width=200 height=300 style='position: relative'>" |
| 26 " <rect width=400 height=500 fill='blue'/>" |
| 27 "</svg>"); |
| 28 |
| 29 Element* target = document().getElementById("target"); |
| 30 PaintLayer* targetPaintLayer = toLayoutBoxModelObject(target->layoutObject()
)->layer(); |
| 31 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects
); |
| 32 LayoutRect layerBounds; |
| 33 ClipRect backgroundRect, foregroundRect; |
| 34 targetPaintLayer->clipper().calculateRects(context, LayoutRect(LayoutRect::i
nfiniteIntRect()), layerBounds, |
| 35 backgroundRect, foregroundRect); |
| 36 EXPECT_EQ(LayoutRect(LayoutRect::infiniteIntRect()), backgroundRect.rect()); |
| 37 EXPECT_EQ(LayoutRect(LayoutRect::infiniteIntRect()), foregroundRect.rect()); |
| 38 EXPECT_EQ(LayoutRect(8, 8, 200, 300), layerBounds); |
| 39 } |
| 40 |
| 41 TEST_F(PaintLayerClipperTest, LayoutSVGRootChild) |
| 42 { |
| 43 setBodyInnerHTML( |
| 44 "<svg width=200 height=300 style='position: relative'>" |
| 45 " <foreignObject width=400 height=500>" |
| 46 " <div id=target xmlns='http://www.w3.org/1999/xhtml' style='position
: relative'></div>" |
| 47 " </foreignObject>" |
| 48 "</svg>"); |
| 49 |
| 50 Element* target = document().getElementById("target"); |
| 51 PaintLayer* targetPaintLayer = toLayoutBoxModelObject(target->layoutObject()
)->layer(); |
| 52 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects
); |
| 53 LayoutRect layerBounds; |
| 54 ClipRect backgroundRect, foregroundRect; |
| 55 targetPaintLayer->clipper().calculateRects(context, LayoutRect(LayoutRect::i
nfiniteIntRect()), layerBounds, |
| 56 backgroundRect, foregroundRect); |
| 57 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect()); |
| 58 EXPECT_EQ(LayoutRect(8, 8, 200, 300), foregroundRect.rect()); |
| 59 EXPECT_EQ(LayoutRect(8, 8, 400, 0), layerBounds); |
| 60 } |
| 61 |
| 62 |
| 63 } // namespace blink |
| OLD | NEW |