OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 |
| 7 #include "core/layout/LayoutBlock.h" |
| 8 #include "core/layout/LayoutInline.h" |
| 9 #include "core/layout/LayoutTestHelper.h" |
| 10 #include "core/paint/PaintLayer.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 class PaintContainmentTest : public RenderingTest { |
| 16 }; |
| 17 |
| 18 static void checkIsClippingStackingContextAndContainer(LayoutBoxModelObject& obj
) |
| 19 { |
| 20 EXPECT_TRUE(obj.canContainFixedPositionObjects()); |
| 21 EXPECT_TRUE(obj.hasClipRelatedProperty()); |
| 22 EXPECT_TRUE(obj.style()->containsPaint()); |
| 23 |
| 24 // TODO(leviw): Ideally, we wouldn't require a paint layer to handle the cli
pping |
| 25 // and stacking performed by paint containment. |
| 26 ASSERT(obj.layer()); |
| 27 PaintLayer* layer = obj.layer(); |
| 28 EXPECT_TRUE(layer->stackingNode() && layer->stackingNode()->isStackingContex
t()); |
| 29 } |
| 30 |
| 31 TEST_F(PaintContainmentTest, BlockPaintContainment) |
| 32 { |
| 33 setBodyInnerHTML("<div id='div' style='contain: paint'></div>"); |
| 34 Element* div = document().getElementById(AtomicString("div")); |
| 35 ASSERT(div); |
| 36 LayoutObject* obj = div->layoutObject(); |
| 37 ASSERT(obj && obj->isLayoutBlock()); |
| 38 LayoutBlock& block = toLayoutBlock(*obj); |
| 39 EXPECT_TRUE(block.createsNewFormattingContext()); |
| 40 EXPECT_FALSE(block.canBeScrolledAndHasScrollableArea()); |
| 41 checkIsClippingStackingContextAndContainer(block); |
| 42 } |
| 43 |
| 44 TEST_F(PaintContainmentTest, InlinePaintContainment) |
| 45 { |
| 46 setBodyInnerHTML("<div><span id='test' style='contain: paint'>Foo</span></di
v>"); |
| 47 Element* span = document().getElementById(AtomicString("test")); |
| 48 ASSERT(span); |
| 49 LayoutObject* obj = span->layoutObject(); |
| 50 ASSERT(obj && obj->isInline()); |
| 51 LayoutInline& layoutInline = toLayoutInline(*obj); |
| 52 checkIsClippingStackingContextAndContainer(layoutInline); |
| 53 } |
| 54 |
| 55 } |
OLD | NEW |