| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/layout/LayoutTestHelper.h" | 6 #include "core/layout/LayoutTestHelper.h" |
| 7 #include "core/layout/LayoutTreeAsText.h" | 7 #include "core/layout/LayoutTreeAsText.h" |
| 8 #include "core/layout/api/LayoutViewItem.h" | 8 #include "core/layout/api/LayoutViewItem.h" |
| 9 #include "core/paint/ObjectPaintProperties.h" | 9 #include "core/paint/ObjectPaintProperties.h" |
| 10 #include "core/paint/PaintPropertyTreePrinter.h" | 10 #include "core/paint/PaintPropertyTreePrinter.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 FrameView* frameView = document().view(); | 153 FrameView* frameView = document().view(); |
| 154 frameView->updateAllLifecyclePhases(); | 154 frameView->updateAllLifecyclePhases(); |
| 155 | 155 |
| 156 // target1 is a fixed-position element inside an absolute-position scrolling | 156 // target1 is a fixed-position element inside an absolute-position scrolling |
| 157 // element. It should be attached under the viewport to skip scrolling and | 157 // element. It should be attached under the viewport to skip scrolling and |
| 158 // offset of the parent. | 158 // offset of the parent. |
| 159 Element* target1 = document().getElementById("target1"); | 159 Element* target1 = document().getElementById("target1"); |
| 160 const ObjectPaintProperties* target1Properties = | 160 const ObjectPaintProperties* target1Properties = |
| 161 target1->layoutObject()->paintProperties(); | 161 target1->layoutObject()->paintProperties(); |
| 162 EXPECT_EQ(TransformationMatrix().translate(200, 150), | 162 EXPECT_EQ(FloatRoundedRect(200, 150, 100, 100), |
| 163 target1Properties->paintOffsetTranslation()->matrix()); | |
| 164 EXPECT_EQ(framePreTranslation(), | |
| 165 target1Properties->paintOffsetTranslation()->parent()); | |
| 166 EXPECT_EQ(target1Properties->paintOffsetTranslation(), | |
| 167 target1Properties->overflowClip()->localTransformSpace()); | |
| 168 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), | |
| 169 target1Properties->overflowClip()->clipRect()); | 163 target1Properties->overflowClip()->clipRect()); |
| 170 // Likewise, it inherits clip from the viewport, skipping overflow clip of the | 164 // Likewise, it inherits clip from the viewport, skipping overflow clip of the |
| 171 // scroller. | 165 // scroller. |
| 172 EXPECT_EQ(frameContentClip(), target1Properties->overflowClip()->parent()); | 166 EXPECT_EQ(frameContentClip(), target1Properties->overflowClip()->parent()); |
| 173 // target1 should not have it's own scroll node and instead should inherit | 167 // target1 should not have its own scroll node and instead should inherit |
| 174 // positionedScroll's. | 168 // positionedScroll's. |
| 175 const ObjectPaintProperties* positionedScrollProperties = | 169 const ObjectPaintProperties* positionedScrollProperties = |
| 176 positionedScroll->layoutObject()->paintProperties(); | 170 positionedScroll->layoutObject()->paintProperties(); |
| 177 EXPECT_TRUE(positionedScrollProperties->scroll()->parent()->isRoot()); | 171 EXPECT_TRUE(positionedScrollProperties->scroll()->parent()->isRoot()); |
| 178 EXPECT_EQ(TransformationMatrix().translate(0, -3), | 172 EXPECT_EQ(TransformationMatrix().translate(0, -3), |
| 179 positionedScrollProperties->scroll() | 173 positionedScrollProperties->scroll() |
| 180 ->scrollOffsetTranslation() | 174 ->scrollOffsetTranslation() |
| 181 ->matrix()); | 175 ->matrix()); |
| 182 EXPECT_EQ(nullptr, target1Properties->scroll()); | 176 EXPECT_EQ(nullptr, target1Properties->scroll()); |
| 183 | |
| 184 CHECK_EXACT_VISUAL_RECT(LayoutRect(200, 150, 100, 100), | 177 CHECK_EXACT_VISUAL_RECT(LayoutRect(200, 150, 100, 100), |
| 185 target1->layoutObject(), frameView->layoutView()); | 178 target1->layoutObject(), frameView->layoutView()); |
| 186 | 179 |
| 187 // target2 is a fixed-position element inside a transformed scrolling element. | 180 // target2 is a fixed-position element inside a transformed scrolling element. |
| 188 // It should be attached under the scrolled box of the transformed element. | 181 // It should be attached under the scrolled box of the transformed element. |
| 189 Element* target2 = document().getElementById("target2"); | 182 Element* target2 = document().getElementById("target2"); |
| 190 const ObjectPaintProperties* target2Properties = | 183 const ObjectPaintProperties* target2Properties = |
| 191 target2->layoutObject()->paintProperties(); | 184 target2->layoutObject()->paintProperties(); |
| 192 Element* scroller = document().getElementById("transformedScroll"); | 185 Element* scroller = document().getElementById("transformedScroll"); |
| 193 const ObjectPaintProperties* scrollerProperties = | 186 const ObjectPaintProperties* scrollerProperties = |
| 194 scroller->layoutObject()->paintProperties(); | 187 scroller->layoutObject()->paintProperties(); |
| 195 EXPECT_EQ(TransformationMatrix().translate(200, 150), | 188 EXPECT_EQ(FloatRoundedRect(200, 150, 100, 100), |
| 196 target2Properties->paintOffsetTranslation()->matrix()); | |
| 197 EXPECT_EQ(scrollerProperties->scrollTranslation(), | |
| 198 target2Properties->paintOffsetTranslation()->parent()); | |
| 199 EXPECT_EQ(target2Properties->paintOffsetTranslation(), | |
| 200 target2Properties->overflowClip()->localTransformSpace()); | |
| 201 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), | |
| 202 target2Properties->overflowClip()->clipRect()); | 189 target2Properties->overflowClip()->clipRect()); |
| 203 EXPECT_EQ(scrollerProperties->overflowClip(), | 190 EXPECT_EQ(scrollerProperties->overflowClip(), |
| 204 target2Properties->overflowClip()->parent()); | 191 target2Properties->overflowClip()->parent()); |
| 205 // target2 should not have it's own scroll node and instead should inherit | 192 // target2 should not have it's own scroll node and instead should inherit |
| 206 // transformedScroll's. | 193 // transformedScroll's. |
| 207 const ObjectPaintProperties* transformedScrollProperties = | 194 const ObjectPaintProperties* transformedScrollProperties = |
| 208 transformedScroll->layoutObject()->paintProperties(); | 195 transformedScroll->layoutObject()->paintProperties(); |
| 209 EXPECT_TRUE(transformedScrollProperties->scroll()->parent()->isRoot()); | 196 EXPECT_TRUE(transformedScrollProperties->scroll()->parent()->isRoot()); |
| 210 EXPECT_EQ(TransformationMatrix().translate(0, -5), | 197 EXPECT_EQ(TransformationMatrix().translate(0, -5), |
| 211 transformedScrollProperties->scroll() | 198 transformedScrollProperties->scroll() |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 const ObjectPaintProperties* containerProperties = | 925 const ObjectPaintProperties* containerProperties = |
| 939 container.paintProperties(); | 926 container.paintProperties(); |
| 940 EXPECT_EQ(TransformationMatrix().translate(20, 30), | 927 EXPECT_EQ(TransformationMatrix().translate(20, 30), |
| 941 containerProperties->transform()->matrix()); | 928 containerProperties->transform()->matrix()); |
| 942 EXPECT_EQ(svgProperties->transform(), | 929 EXPECT_EQ(svgProperties->transform(), |
| 943 containerProperties->transform()->parent()); | 930 containerProperties->transform()->parent()); |
| 944 | 931 |
| 945 Element* fixed = document().getElementById("fixed"); | 932 Element* fixed = document().getElementById("fixed"); |
| 946 const ObjectPaintProperties* fixedProperties = | 933 const ObjectPaintProperties* fixedProperties = |
| 947 fixed->layoutObject()->paintProperties(); | 934 fixed->layoutObject()->paintProperties(); |
| 948 EXPECT_EQ(TransformationMatrix().translate(200, 150), | |
| 949 fixedProperties->paintOffsetTranslation()->matrix()); | |
| 950 // Ensure the fixed position element is rooted at the nearest transform | 935 // Ensure the fixed position element is rooted at the nearest transform |
| 951 // container. | 936 // container. |
| 952 EXPECT_EQ(containerProperties->transform(), | 937 EXPECT_EQ(containerProperties->transform(), |
| 953 fixedProperties->paintOffsetTranslation()->parent()); | 938 fixedProperties->localBorderBoxProperties() |
| 939 ->propertyTreeState.transform()); |
| 954 } | 940 } |
| 955 | 941 |
| 956 TEST_P(PaintPropertyTreeBuilderTest, ControlClip) { | 942 TEST_P(PaintPropertyTreeBuilderTest, ControlClip) { |
| 957 setBodyInnerHTML( | 943 setBodyInnerHTML( |
| 958 "<style>" | 944 "<style>" |
| 959 " body {" | 945 " body {" |
| 960 " margin: 0;" | 946 " margin: 0;" |
| 961 " }" | 947 " }" |
| 962 " input {" | 948 " input {" |
| 963 " border-width: 5px;" | 949 " border-width: 5px;" |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() | 1289 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() |
| 1304 // doesn't apply css clip on the object itself. | 1290 // doesn't apply css clip on the object itself. |
| 1305 LayoutUnit::max()); | 1291 LayoutUnit::max()); |
| 1306 | 1292 |
| 1307 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 1293 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 1308 const ObjectPaintProperties* fixedProperties = fixed->paintProperties(); | 1294 const ObjectPaintProperties* fixedProperties = fixed->paintProperties(); |
| 1309 EXPECT_EQ( | 1295 EXPECT_EQ( |
| 1310 clipProperties->cssClip(), | 1296 clipProperties->cssClip(), |
| 1311 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); | 1297 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 1312 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() | 1298 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() |
| 1313 ->propertyTreeState.transform() | 1299 ->propertyTreeState.transform()); |
| 1314 ->parent()); | 1300 EXPECT_EQ(LayoutPoint(654, 321), |
| 1315 EXPECT_EQ(TransformationMatrix().translate(654, 321), | |
| 1316 fixedProperties->localBorderBoxProperties() | |
| 1317 ->propertyTreeState.transform() | |
| 1318 ->matrix()); | |
| 1319 EXPECT_EQ(LayoutPoint(), | |
| 1320 fixedProperties->localBorderBoxProperties()->paintOffset); | 1301 fixedProperties->localBorderBoxProperties()->paintOffset); |
| 1321 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(), | 1302 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(), |
| 1322 // TODO(crbug.com/599939): CSS clip of fixed-position | 1303 // TODO(crbug.com/599939): CSS clip of fixed-position |
| 1323 // descendants is broken in | 1304 // descendants is broken in |
| 1324 // mapToVisualRectInAncestorSpace(). | 1305 // mapToVisualRectInAncestorSpace(). |
| 1325 LayoutUnit::max()); | 1306 LayoutUnit::max()); |
| 1326 } | 1307 } |
| 1327 | 1308 |
| 1328 TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) { | 1309 TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) { |
| 1329 // This test verifies that clip tree hierarchy being generated correctly for | 1310 // This test verifies that clip tree hierarchy being generated correctly for |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), | 1427 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), |
| 1447 clipProperties->cssClipFixedPosition()->clipRect()); | 1428 clipProperties->cssClipFixedPosition()->clipRect()); |
| 1448 CHECK_EXACT_VISUAL_RECT(LayoutRect(), clip, document().view()->layoutView()); | 1429 CHECK_EXACT_VISUAL_RECT(LayoutRect(), clip, document().view()->layoutView()); |
| 1449 | 1430 |
| 1450 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 1431 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 1451 const ObjectPaintProperties* fixedProperties = fixed->paintProperties(); | 1432 const ObjectPaintProperties* fixedProperties = fixed->paintProperties(); |
| 1452 EXPECT_EQ( | 1433 EXPECT_EQ( |
| 1453 clipProperties->cssClipFixedPosition(), | 1434 clipProperties->cssClipFixedPosition(), |
| 1454 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); | 1435 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 1455 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() | 1436 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() |
| 1456 ->propertyTreeState.transform() | 1437 ->propertyTreeState.transform()); |
| 1457 ->parent()); | 1438 EXPECT_EQ(LayoutPoint(654, 321), |
| 1458 EXPECT_EQ(TransformationMatrix().translate(654, 321), | |
| 1459 fixedProperties->localBorderBoxProperties() | |
| 1460 ->propertyTreeState.transform() | |
| 1461 ->matrix()); | |
| 1462 EXPECT_EQ(LayoutPoint(), | |
| 1463 fixedProperties->localBorderBoxProperties()->paintOffset); | 1439 fixedProperties->localBorderBoxProperties()->paintOffset); |
| 1464 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(), | 1440 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(), |
| 1465 // TODO(crbug.com/599939): CSS clip of fixed-position | 1441 // TODO(crbug.com/599939): CSS clip of fixed-position |
| 1466 // descendants is broken in geometry mapping. | 1442 // descendants is broken in geometry mapping. |
| 1467 LayoutUnit::max()); | 1443 LayoutUnit::max()); |
| 1468 } | 1444 } |
| 1469 | 1445 |
| 1470 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) { | 1446 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) { |
| 1471 setBodyInnerHTML( | 1447 setBodyInnerHTML( |
| 1472 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" | 1448 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" |
| (...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2986 EXPECT_TRUE(filterProperties->effect()->parent()->isRoot()); | 2962 EXPECT_TRUE(filterProperties->effect()->parent()->isRoot()); |
| 2987 EXPECT_EQ(frameScrollTranslation(), | 2963 EXPECT_EQ(frameScrollTranslation(), |
| 2988 filterProperties->effect()->localTransformSpace()); | 2964 filterProperties->effect()->localTransformSpace()); |
| 2989 EXPECT_EQ(clipProperties->overflowClip(), | 2965 EXPECT_EQ(clipProperties->overflowClip(), |
| 2990 filterProperties->effect()->outputClip()); | 2966 filterProperties->effect()->outputClip()); |
| 2991 | 2967 |
| 2992 const ObjectPaintProperties* childProperties = | 2968 const ObjectPaintProperties* childProperties = |
| 2993 getLayoutObjectByElementId("child")->paintProperties(); | 2969 getLayoutObjectByElementId("child")->paintProperties(); |
| 2994 const PropertyTreeState& childPaintState = | 2970 const PropertyTreeState& childPaintState = |
| 2995 childProperties->localBorderBoxProperties()->propertyTreeState; | 2971 childProperties->localBorderBoxProperties()->propertyTreeState; |
| 2996 EXPECT_EQ(framePreTranslation(), | 2972 |
| 2997 childProperties->paintOffsetTranslation()->parent()); | |
| 2998 EXPECT_EQ(childProperties->paintOffsetTranslation(), | |
| 2999 childPaintState.transform()); | |
| 3000 // This will change once we added clip expansion node. | 2973 // This will change once we added clip expansion node. |
| 3001 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); | 2974 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); |
| 3002 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); | 2975 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); |
| 3003 } | 2976 } |
| 3004 | 2977 |
| 3005 TEST_P(PaintPropertyTreeBuilderTest, DescendantNeedsUpdateAcrossFrames) { | 2978 TEST_P(PaintPropertyTreeBuilderTest, DescendantNeedsUpdateAcrossFrames) { |
| 3006 setBodyInnerHTML( | 2979 setBodyInnerHTML( |
| 3007 "<style>body { margin: 0; }</style>" | 2980 "<style>body { margin: 0; }</style>" |
| 3008 "<div id='divWithTransform' style='transform: translate3d(1px,2px,3px);'>" | 2981 "<div id='divWithTransform' style='transform: translate3d(1px,2px,3px);'>" |
| 3009 " <iframe style='border: 7px solid black'></iframe>" | 2982 " <iframe style='border: 7px solid black'></iframe>" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3225 setBodyInnerHTML("<div id='div' style='background-color: blue'>DIV</div>"); | 3198 setBodyInnerHTML("<div id='div' style='background-color: blue'>DIV</div>"); |
| 3226 auto* div = document().getElementById("div"); | 3199 auto* div = document().getElementById("div"); |
| 3227 | 3200 |
| 3228 document().view()->updateAllLifecyclePhases(); | 3201 document().view()->updateAllLifecyclePhases(); |
| 3229 div->setAttribute(HTMLNames::styleAttr, "background-color: green"); | 3202 div->setAttribute(HTMLNames::styleAttr, "background-color: green"); |
| 3230 document().view()->updateLifecycleToLayoutClean(); | 3203 document().view()->updateLifecycleToLayoutClean(); |
| 3231 EXPECT_FALSE(div->layoutObject()->needsPaintPropertyUpdate()); | 3204 EXPECT_FALSE(div->layoutObject()->needsPaintPropertyUpdate()); |
| 3232 } | 3205 } |
| 3233 | 3206 |
| 3234 } // namespace blink | 3207 } // namespace blink |
| OLD | NEW |