Chromium Code Reviews| 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()); | |
|
chrishtr
2015/12/11 23:39:19
EXPECT_TRUE(obj.style()->containsPaint())
| |
| 22 | |
| 23 // TODO(leviw): Ideally, we wouldn't require a paint layer to handle the cli pping | |
| 24 // and stacking performed by paint containment. | |
| 25 ASSERT(obj.layer()); | |
| 26 PaintLayer* layer = obj.layer(); | |
| 27 EXPECT_TRUE(layer->stackingNode() && layer->stackingNode()->isStackingContex t()); | |
| 28 } | |
| 29 | |
| 30 TEST_F(PaintContainmentTest, BlockPaintContainment) | |
| 31 { | |
| 32 setBodyInnerHTML("<div id='div' style='contain: paint'></div>"); | |
| 33 Element* div = document().getElementById(AtomicString("div")); | |
| 34 ASSERT(div); | |
| 35 LayoutObject* obj = div->layoutObject(); | |
| 36 ASSERT(obj && obj->isLayoutBlock()); | |
| 37 LayoutBlock& block = toLayoutBlock(*obj); | |
| 38 EXPECT_TRUE(block.createsNewFormattingContext()); | |
| 39 EXPECT_FALSE(block.canBeScrolledAndHasScrollableArea()); | |
| 40 checkIsClippingStackingContextAndContainer(block); | |
| 41 } | |
| 42 | |
| 43 TEST_F(PaintContainmentTest, InlinePaintContainment) | |
| 44 { | |
| 45 setBodyInnerHTML("<div><span id='test' style='contain: paint'>Foo</span></di v>"); | |
| 46 Element* span = document().getElementById(AtomicString("test")); | |
| 47 ASSERT(span); | |
| 48 LayoutObject* obj = span->layoutObject(); | |
| 49 ASSERT(obj && obj->isInline()); | |
| 50 LayoutInline& layoutInline = toLayoutInline(*obj); | |
| 51 checkIsClippingStackingContextAndContainer(layoutInline); | |
| 52 } | |
| 53 | |
| 54 } | |
| OLD | NEW |