OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 "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 container->setAttribute(HTMLNames::styleAttr, |
| 48 "transform: translateY(1000px);"); |
| 49 document().updateStyleAndLayoutTree(); |
| 50 |
| 51 EXPECT_EQ(scrollableArea->maximumScrollOffset().height(), 1000); |
| 52 EXPECT_TRUE(document().layoutView()->mayNeedPaintInvalidation()); |
| 53 } |
| 54 |
| 55 } // namespace |
| 56 |
| 57 } // namespace blink |
OLD | NEW |