| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/html/HTMLIFrameElement.h" | 5 #include "core/html/HTMLIFrameElement.h" |
| 6 #include "core/paint/PaintPropertyTreeBuilderTest.h" | 6 #include "core/paint/PaintPropertyTreeBuilderTest.h" |
| 7 #include "core/paint/PaintPropertyTreePrinter.h" | 7 #include "core/paint/PaintPropertyTreePrinter.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 "</div>" | 83 "</div>" |
| 84 "<div class='forceScroll'></div>"); | 84 "<div class='forceScroll'></div>"); |
| 85 Element* overflowA = document().getElementById("overflowA"); | 85 Element* overflowA = document().getElementById("overflowA"); |
| 86 Element* overflowB = document().getElementById("overflowB"); | 86 Element* overflowB = document().getElementById("overflowB"); |
| 87 | 87 |
| 88 EXPECT_TRUE(frameScroll()->hasBackgroundAttachmentFixedDescendants()); | 88 EXPECT_TRUE(frameScroll()->hasBackgroundAttachmentFixedDescendants()); |
| 89 EXPECT_TRUE(overflowA->layoutObject() | 89 EXPECT_TRUE(overflowA->layoutObject() |
| 90 ->paintProperties() | 90 ->paintProperties() |
| 91 ->scroll() | 91 ->scroll() |
| 92 ->hasBackgroundAttachmentFixedDescendants()); | 92 ->hasBackgroundAttachmentFixedDescendants()); |
| 93 EXPECT_FALSE(overflowB->layoutObject() | 93 EXPECT_TRUE(overflowB->layoutObject() |
| 94 ->paintProperties() | 94 ->paintProperties() |
| 95 ->scroll() | 95 ->scroll() |
| 96 ->hasBackgroundAttachmentFixedDescendants()); | 96 ->hasBackgroundAttachmentFixedDescendants()); |
| 97 | 97 |
| 98 // Removing a main thread scrolling reason should update the entire tree. | 98 // Removing a main thread scrolling reason should update the entire tree. |
| 99 overflowB->removeAttribute("class"); | 99 overflowB->removeAttribute("class"); |
| 100 document().view()->updateAllLifecyclePhases(); | 100 document().view()->updateAllLifecyclePhases(); |
| 101 EXPECT_FALSE(frameScroll()->hasBackgroundAttachmentFixedDescendants()); | 101 EXPECT_FALSE(frameScroll()->hasBackgroundAttachmentFixedDescendants()); |
| 102 EXPECT_FALSE(overflowA->layoutObject() | 102 EXPECT_FALSE(overflowA->layoutObject() |
| 103 ->paintProperties() | 103 ->paintProperties() |
| 104 ->scroll() | 104 ->scroll() |
| 105 ->hasBackgroundAttachmentFixedDescendants()); | 105 ->hasBackgroundAttachmentFixedDescendants()); |
| 106 EXPECT_FALSE(overflowB->layoutObject() | 106 EXPECT_FALSE(overflowB->layoutObject() |
| 107 ->paintProperties() | 107 ->paintProperties() |
| 108 ->scroll() | 108 ->scroll() |
| 109 ->hasBackgroundAttachmentFixedDescendants()); | 109 ->hasBackgroundAttachmentFixedDescendants()); |
| 110 | 110 |
| 111 // Adding a main thread scrolling reason should update the entire tree. | 111 // Adding a main thread scrolling reason should update the entire tree. |
| 112 overflowB->setAttribute(HTMLNames::classAttr, "backgroundAttachmentFixed"); | 112 overflowB->setAttribute(HTMLNames::classAttr, "backgroundAttachmentFixed"); |
| 113 document().view()->updateAllLifecyclePhases(); | 113 document().view()->updateAllLifecyclePhases(); |
| 114 EXPECT_TRUE(frameScroll()->hasBackgroundAttachmentFixedDescendants()); | 114 EXPECT_TRUE(frameScroll()->hasBackgroundAttachmentFixedDescendants()); |
| 115 EXPECT_TRUE(overflowA->layoutObject() | 115 EXPECT_TRUE(overflowA->layoutObject() |
| 116 ->paintProperties() | 116 ->paintProperties() |
| 117 ->scroll() | 117 ->scroll() |
| 118 ->hasBackgroundAttachmentFixedDescendants()); | 118 ->hasBackgroundAttachmentFixedDescendants()); |
| 119 EXPECT_FALSE(overflowB->layoutObject() | 119 EXPECT_TRUE(overflowB->layoutObject() |
| 120 ->paintProperties() | 120 ->paintProperties() |
| 121 ->scroll() | 121 ->scroll() |
| 122 ->hasBackgroundAttachmentFixedDescendants()); | 122 ->hasBackgroundAttachmentFixedDescendants()); |
| 123 } |
| 124 |
| 125 TEST_P(PaintPropertyTreeUpdateTest, ParentFrameMainThreadScrollReasons) { |
| 126 setBodyInnerHTML( |
| 127 "<style>" |
| 128 " body { margin: 0; }" |
| 129 " .fixedBackground {" |
| 130 " background-image: url('foo');" |
| 131 " background-attachment: fixed;" |
| 132 " }" |
| 133 "</style>" |
| 134 "<iframe></iframe>" |
| 135 "<div id='fixedBackground' class='fixedBackground'></div>" |
| 136 "<div id='forceScroll' style='height: 8888px;'></div>"); |
| 137 setChildFrameHTML( |
| 138 "<style>body { margin: 0; }</style>" |
| 139 "<div id='forceScroll' style='height: 8888px;'></div>"); |
| 140 document().view()->updateAllLifecyclePhases(); |
| 141 |
| 142 FrameView* parent = document().view(); |
| 143 EXPECT_TRUE(frameScroll(parent)->hasBackgroundAttachmentFixedDescendants()); |
| 144 FrameView* child = childDocument().view(); |
| 145 EXPECT_TRUE(frameScroll(child)->hasBackgroundAttachmentFixedDescendants()); |
| 146 |
| 147 // Removing a main thread scrolling reason should update the entire tree. |
| 148 auto* fixedBackground = document().getElementById("fixedBackground"); |
| 149 fixedBackground->removeAttribute(HTMLNames::classAttr); |
| 150 document().view()->updateAllLifecyclePhases(); |
| 151 EXPECT_FALSE(frameScroll(parent)->hasBackgroundAttachmentFixedDescendants()); |
| 152 EXPECT_FALSE(frameScroll(child)->hasBackgroundAttachmentFixedDescendants()); |
| 153 |
| 154 // Adding a main thread scrolling reason should update the entire tree. |
| 155 fixedBackground->setAttribute(HTMLNames::classAttr, "fixedBackground"); |
| 156 document().view()->updateAllLifecyclePhases(); |
| 157 EXPECT_TRUE(frameScroll(parent)->hasBackgroundAttachmentFixedDescendants()); |
| 158 EXPECT_TRUE(frameScroll(child)->hasBackgroundAttachmentFixedDescendants()); |
| 159 } |
| 160 |
| 161 TEST_P(PaintPropertyTreeUpdateTest, ChildFrameMainThreadScrollReasons) { |
| 162 setBodyInnerHTML( |
| 163 "<style>body { margin: 0; }</style>" |
| 164 "<iframe></iframe>" |
| 165 "<div id='forceScroll' style='height: 8888px;'></div>"); |
| 166 setChildFrameHTML( |
| 167 "<style>" |
| 168 " body { margin: 0; }" |
| 169 " .fixedBackground {" |
| 170 " background-image: url('foo');" |
| 171 " background-attachment: fixed;" |
| 172 " }" |
| 173 "</style>" |
| 174 "<div id='fixedBackground' class='fixedBackground'></div>" |
| 175 "<div id='forceScroll' style='height: 8888px;'></div>"); |
| 176 document().view()->updateAllLifecyclePhases(); |
| 177 |
| 178 FrameView* parent = document().view(); |
| 179 EXPECT_FALSE(frameScroll(parent)->hasBackgroundAttachmentFixedDescendants()); |
| 180 FrameView* child = childDocument().view(); |
| 181 EXPECT_TRUE(frameScroll(child)->hasBackgroundAttachmentFixedDescendants()); |
| 182 |
| 183 // Removing a main thread scrolling reason should update the entire tree. |
| 184 auto* fixedBackground = childDocument().getElementById("fixedBackground"); |
| 185 fixedBackground->removeAttribute(HTMLNames::classAttr); |
| 186 document().view()->updateAllLifecyclePhases(); |
| 187 EXPECT_FALSE(frameScroll(parent)->hasBackgroundAttachmentFixedDescendants()); |
| 188 EXPECT_FALSE(frameScroll(child)->hasBackgroundAttachmentFixedDescendants()); |
| 189 |
| 190 // Adding a main thread scrolling reason should update the entire tree. |
| 191 fixedBackground->setAttribute(HTMLNames::classAttr, "fixedBackground"); |
| 192 document().view()->updateAllLifecyclePhases(); |
| 193 EXPECT_FALSE(frameScroll(parent)->hasBackgroundAttachmentFixedDescendants()); |
| 194 EXPECT_TRUE(frameScroll(child)->hasBackgroundAttachmentFixedDescendants()); |
| 123 } | 195 } |
| 124 | 196 |
| 125 TEST_P(PaintPropertyTreeUpdateTest, | 197 TEST_P(PaintPropertyTreeUpdateTest, |
| 126 BackgroundAttachmentFixedMainThreadScrollReasonsWithFixedScroller) { | 198 BackgroundAttachmentFixedMainThreadScrollReasonsWithFixedScroller) { |
| 127 setBodyInnerHTML( | 199 setBodyInnerHTML( |
| 128 "<style>" | 200 "<style>" |
| 129 " #overflowA {" | 201 " #overflowA {" |
| 130 " position: absolute;" | 202 " position: absolute;" |
| 131 " overflow: scroll;" | 203 " overflow: scroll;" |
| 132 " width: 20px;" | 204 " width: 20px;" |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 EXPECT_EQ(TransformationMatrix().translate3d(50, 100, 0), | 627 EXPECT_EQ(TransformationMatrix().translate3d(50, 100, 0), |
| 556 transformObject->paintProperties()->transform()->matrix()); | 628 transformObject->paintProperties()->transform()->matrix()); |
| 557 | 629 |
| 558 transform->setAttribute(HTMLNames::styleAttr, "width: 200px; height: 300px;"); | 630 transform->setAttribute(HTMLNames::styleAttr, "width: 200px; height: 300px;"); |
| 559 document().view()->updateAllLifecyclePhases(); | 631 document().view()->updateAllLifecyclePhases(); |
| 560 EXPECT_EQ(TransformationMatrix().translate3d(100, 150, 0), | 632 EXPECT_EQ(TransformationMatrix().translate3d(100, 150, 0), |
| 561 transformObject->paintProperties()->transform()->matrix()); | 633 transformObject->paintProperties()->transform()->matrix()); |
| 562 } | 634 } |
| 563 | 635 |
| 564 } // namespace blink | 636 } // namespace blink |
| OLD | NEW |