Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp b/third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8395b89a100a62d732281974d8dcb6ecbdc4348b |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp |
| @@ -0,0 +1,67 @@ |
| +// 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.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "core/frame/FrameView.h" |
| +#include "core/layout/LayoutTestHelper.h" |
| +#include "core/layout/LayoutView.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace blink { |
| + |
| +namespace { |
| + |
| +class PaintInvalidationTest : public RenderingTest { |
| + public: |
| + PaintInvalidationTest() |
| + : RenderingTest(SingleChildLocalFrameClient::create()) {} |
| +}; |
| + |
| +// Changing style in a way that changes overflow without layout should cause |
| +// the layout view to possibly need a paint invalidation since we may have |
| +// revealed additional background that can be scrolled into view. |
| +TEST_F(PaintInvalidationTest, RecalcOverflowInvalidatesBackground) { |
| + document().page()->settings().setViewportEnabled(true); |
| + setBodyInnerHTML( |
| + "<!DOCTYPE html>" |
| + "<style type='text/css'>" |
| + " body, html {" |
| + " width: 100%;" |
| + " height: 100%;" |
| + " margin: 0px;" |
| + " }" |
| + " #container {" |
| + " width: 100%;" |
| + " height: 100%;" |
| + " }" |
| + "</style>" |
| + "<div id='container'></div>"); |
| + |
| + document().view()->updateAllLifecyclePhases(); |
| + |
| + ScrollableArea* scrollableArea = document().view(); |
| + ASSERT_EQ(scrollableArea->maximumScrollOffset().height(), 0); |
| + EXPECT_FALSE(document().layoutView()->mayNeedPaintInvalidation()); |
| + |
| + Element* container = document().getElementById("container"); |
| + RefPtr<ComputedStyle> style = |
| + ComputedStyle::clone(*container->layoutObject()->style()); |
| + |
| + TransformOperations ops; |
| + ops.operations().push_back(TranslateTransformOperation::create( |
| + Length(0, Fixed), Length(1000, Fixed), TransformOperation::TranslateY)); |
| + style->setTransform(ops); |
| + |
| + container->layoutObject()->setStyle(std::move(style)); |
| + |
| + ASSERT_EQ(scrollableArea->maximumScrollOffset().height(), 0); |
| + |
| + document().view()->recalcOverflowAfterStyleChange(); |
| + |
| + EXPECT_EQ(scrollableArea->maximumScrollOffset().height(), 1000); |
| + EXPECT_TRUE(document().layoutView()->mayNeedPaintInvalidation()); |
| +} |
| + |
| +} // namespace |
| + |
| +} // namespace blink |