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/layout/LayoutBlock.h" | 5 #include "core/layout/LayoutBlock.h" |
6 #include "core/layout/LayoutInline.h" | 6 #include "core/layout/LayoutInline.h" |
7 #include "core/layout/LayoutTestHelper.h" | 7 #include "core/layout/LayoutTestHelper.h" |
8 #include "core/paint/PaintLayer.h" | 8 #include "core/paint/PaintLayer.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 class PaintContainmentTest : public RenderingTest { | 13 class PaintContainmentTest : public RenderingTest { |
14 private: | 14 private: |
15 void SetUp() override { | 15 void SetUp() override { |
16 RenderingTest::SetUp(); | 16 RenderingTest::SetUp(); |
17 enableCompositing(); | 17 enableCompositing(); |
18 } | 18 } |
19 }; | 19 }; |
20 | 20 |
21 static void checkIsClippingStackingContextAndContainer( | 21 static void checkIsClippingStackingContextAndContainer( |
22 LayoutBoxModelObject& obj) { | 22 LayoutBoxModelObject& obj) { |
23 EXPECT_TRUE(obj.canContainFixedPositionObjects()); | 23 EXPECT_TRUE(obj.canContainFixedPositionObjects()); |
24 EXPECT_TRUE(obj.hasClipRelatedProperty()); | 24 EXPECT_TRUE(obj.hasClipRelatedProperty()); |
25 EXPECT_TRUE(obj.style()->containsPaint()); | 25 EXPECT_TRUE(obj.style()->containsPaint()); |
26 | 26 |
27 // TODO(leviw): Ideally, we wouldn't require a paint layer to handle the clipp
ing | 27 // TODO(leviw): Ideally, we wouldn't require a paint layer to handle the |
28 // and stacking performed by paint containment. | 28 // clipping and stacking performed by paint containment. |
29 ASSERT(obj.layer()); | 29 ASSERT(obj.layer()); |
30 PaintLayer* layer = obj.layer(); | 30 PaintLayer* layer = obj.layer(); |
31 EXPECT_TRUE(layer->stackingNode() && | 31 EXPECT_TRUE(layer->stackingNode() && |
32 layer->stackingNode()->isStackingContext()); | 32 layer->stackingNode()->isStackingContext()); |
33 } | 33 } |
34 | 34 |
35 TEST_F(PaintContainmentTest, BlockPaintContainment) { | 35 TEST_F(PaintContainmentTest, BlockPaintContainment) { |
36 setBodyInnerHTML("<div id='div' style='contain: paint'></div>"); | 36 setBodyInnerHTML("<div id='div' style='contain: paint'></div>"); |
37 Element* div = document().getElementById(AtomicString("div")); | 37 Element* div = document().getElementById(AtomicString("div")); |
38 ASSERT(div); | 38 ASSERT(div); |
(...skipping 11 matching lines...) Expand all Loading... |
50 Element* span = document().getElementById(AtomicString("test")); | 50 Element* span = document().getElementById(AtomicString("test")); |
51 ASSERT(span); | 51 ASSERT(span); |
52 // The inline should have been coerced into a block in StyleAdjuster. | 52 // The inline should have been coerced into a block in StyleAdjuster. |
53 LayoutObject* obj = span->layoutObject(); | 53 LayoutObject* obj = span->layoutObject(); |
54 ASSERT(obj && obj->isLayoutBlock()); | 54 ASSERT(obj && obj->isLayoutBlock()); |
55 LayoutBlock& layoutBlock = toLayoutBlock(*obj); | 55 LayoutBlock& layoutBlock = toLayoutBlock(*obj); |
56 checkIsClippingStackingContextAndContainer(layoutBlock); | 56 checkIsClippingStackingContextAndContainer(layoutBlock); |
57 } | 57 } |
58 | 58 |
59 TEST_F(PaintContainmentTest, SvgWithContainmentShouldNotCrash) { | 59 TEST_F(PaintContainmentTest, SvgWithContainmentShouldNotCrash) { |
60 // SVG doesn't currently support PaintLayers and should not crash with layer-r
elated properties. | 60 // SVG doesn't currently support PaintLayers and should not crash with |
| 61 // layer-related properties. |
61 setBodyInnerHTML("<svg><text y='20' style='contain: paint'>Foo</text></svg>"); | 62 setBodyInnerHTML("<svg><text y='20' style='contain: paint'>Foo</text></svg>"); |
62 setBodyInnerHTML( | 63 setBodyInnerHTML( |
63 "<svg><foreignObject style='contain: paint'>Foo</foreignObject></svg>"); | 64 "<svg><foreignObject style='contain: paint'>Foo</foreignObject></svg>"); |
64 setBodyInnerHTML( | 65 setBodyInnerHTML( |
65 "<svg><foreignObject><span style='contain: " | 66 "<svg><foreignObject><span style='contain: " |
66 "paint'>Foo</span></foreignObject></svg>"); | 67 "paint'>Foo</span></foreignObject></svg>"); |
67 } | 68 } |
68 | 69 |
69 } // namespace blink | 70 } // namespace blink |
OLD | NEW |