Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: third_party/WebKit/Source/core/layout/PaintContainmentTest.cpp

Issue 1490063002: Implement Paint Containment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix merge Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698