OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
pdr.
2017/02/28 17:36:17
Supernit: 2017
bokan
2017/02/28 18:31:22
Heh, living in the past. Done.
| |
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/frame/FrameView.h" | |
6 #include "core/layout/LayoutTestHelper.h" | |
7 #include "core/layout/LayoutView.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | |
9 | |
10 namespace blink { | |
11 | |
12 namespace { | |
13 | |
14 class PaintInvalidationTest : public RenderingTest { | |
15 public: | |
16 PaintInvalidationTest() | |
17 : RenderingTest(SingleChildLocalFrameClient::create()) {} | |
18 }; | |
19 | |
20 // Changing style in a way that changes overflow without layout should cause | |
21 // the layout view to possibly need a paint invalidation since we may have | |
22 // revealed additional background that can be scrolled into view. | |
23 TEST_F(PaintInvalidationTest, RecalcOverflowInvalidatesBackground) { | |
24 document().page()->settings().setViewportEnabled(true); | |
25 setBodyInnerHTML( | |
26 "<!DOCTYPE html>" | |
27 "<style type='text/css'>" | |
28 " body, html {" | |
29 " width: 100%;" | |
30 " height: 100%;" | |
31 " margin: 0px;" | |
32 " }" | |
33 " #container {" | |
34 " width: 100%;" | |
35 " height: 100%;" | |
36 " }" | |
37 "</style>" | |
38 "<div id='container'></div>"); | |
39 | |
40 document().view()->updateAllLifecyclePhases(); | |
41 | |
42 ScrollableArea* scrollableArea = document().view(); | |
43 ASSERT_EQ(scrollableArea->maximumScrollOffset().height(), 0); | |
44 EXPECT_FALSE(document().layoutView()->mayNeedPaintInvalidation()); | |
45 | |
46 Element* container = document().getElementById("container"); | |
47 RefPtr<ComputedStyle> style = | |
48 ComputedStyle::clone(*container->layoutObject()->style()); | |
49 | |
50 TransformOperations ops; | |
51 ops.operations().push_back(TranslateTransformOperation::create( | |
52 Length(0, Fixed), Length(1000, Fixed), TransformOperation::TranslateY)); | |
53 style->setTransform(ops); | |
54 | |
55 container->layoutObject()->setStyle(std::move(style)); | |
56 | |
57 ASSERT_EQ(scrollableArea->maximumScrollOffset().height(), 0); | |
58 | |
59 document().view()->recalcOverflowAfterStyleChange(); | |
60 | |
61 EXPECT_EQ(scrollableArea->maximumScrollOffset().height(), 1000); | |
62 EXPECT_TRUE(document().layoutView()->mayNeedPaintInvalidation()); | |
63 } | |
64 | |
65 } // namespace | |
66 | |
67 } // namespace blink | |
OLD | NEW |