OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/frame/FrameView.h" | 5 #include "core/frame/FrameView.h" |
6 #include "core/layout/LayoutTestHelper.h" | 6 #include "core/layout/LayoutTestHelper.h" |
7 #include "core/layout/LayoutView.h" | 7 #include "core/layout/LayoutView.h" |
| 8 #include "core/paint/PaintLayer.h" |
8 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 9 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
10 | 11 |
11 namespace blink { | 12 namespace blink { |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 class PaintInvalidationTest : public ::testing::WithParamInterface<bool>, | 16 class PaintInvalidationTest : public ::testing::WithParamInterface<bool>, |
16 private ScopedRootLayerScrollingForTest, | 17 private ScopedRootLayerScrollingForTest, |
17 public RenderingTest { | 18 public RenderingTest { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 &childLayoutView->containerForPaintInvalidation()); | 77 &childLayoutView->containerForPaintInvalidation()); |
77 EXPECT_EQ(LayoutRect(10, 10, 100, 100), childLayoutView->visualRect()); | 78 EXPECT_EQ(LayoutRect(10, 10, 100, 100), childLayoutView->visualRect()); |
78 | 79 |
79 iframe->setAttribute(HTMLNames::styleAttr, "border: 20px solid blue"); | 80 iframe->setAttribute(HTMLNames::styleAttr, "border: 20px solid blue"); |
80 document().view()->updateAllLifecyclePhases(); | 81 document().view()->updateAllLifecyclePhases(); |
81 EXPECT_EQ(document().layoutView(), | 82 EXPECT_EQ(document().layoutView(), |
82 &childLayoutView->containerForPaintInvalidation()); | 83 &childLayoutView->containerForPaintInvalidation()); |
83 EXPECT_EQ(LayoutRect(30, 30, 100, 100), childLayoutView->visualRect()); | 84 EXPECT_EQ(LayoutRect(30, 30, 100, 100), childLayoutView->visualRect()); |
84 }; | 85 }; |
85 | 86 |
| 87 // This is a simplified test case for crbug.com/704182. It ensures no repaint |
| 88 // on transform change causing no visual change. |
| 89 TEST_P(PaintInvalidationTest, InvisibleTransformUnderFixedOnScroll) { |
| 90 enableCompositing(); |
| 91 setBodyInnerHTML( |
| 92 "<div style='height: 2000px'></div>" |
| 93 "<div id='fixed' style='position: fixed; top: 0; left: 0; width: 100px;" |
| 94 " height: 100px; visibility: hidden'>" |
| 95 " <div id='transform' style='will-change: transform'></div>" |
| 96 "</div>"); |
| 97 |
| 98 auto& fixed = *document().getElementById("fixed"); |
| 99 auto& transform = *document().getElementById("transform"); |
| 100 const auto& fixedObject = *fixed.layoutObject(); |
| 101 const auto& fixedLayer = *toLayoutBoxModelObject(fixedObject).layer(); |
| 102 EXPECT_TRUE(fixedLayer.subtreeIsInvisible()); |
| 103 |
| 104 document().domWindow()->scrollTo(0, 100); |
| 105 transform.setAttribute(HTMLNames::styleAttr, |
| 106 "transform: translate3d(10px, 20px, 30px)"); |
| 107 document().view()->updateLifecycleToCompositingCleanPlusScrolling(); |
| 108 |
| 109 EXPECT_TRUE(fixedLayer.subtreeIsInvisible()); |
| 110 // We skip invisible layers when setting non-composited fixed-position |
| 111 // needing paint invalidation when the frame is scrolled. |
| 112 EXPECT_FALSE(fixedObject.shouldDoFullPaintInvalidation()); |
| 113 // This was set when fixedObject is marked needsOverflowRecaldAfterStyleChange |
| 114 // when child changed transform. |
| 115 EXPECT_TRUE(fixedObject.mayNeedPaintInvalidation()); |
| 116 |
| 117 // We should not repaint anything because all contents are invisible. |
| 118 document().view()->updateAllLifecyclePhasesExceptPaint(); |
| 119 EXPECT_FALSE(fixedLayer.needsRepaint()); |
| 120 document().view()->updateAllLifecyclePhases(); |
| 121 } |
| 122 |
86 } // namespace | 123 } // namespace |
87 | 124 |
88 } // namespace blink | 125 } // namespace blink |
OLD | NEW |