| 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/layout/LayoutTestHelper.h" | 5 #include "core/layout/LayoutTestHelper.h" |
| 6 #include "core/layout/LayoutTreeAsText.h" | 6 #include "core/layout/LayoutTreeAsText.h" |
| 7 #include "core/layout/api/LayoutViewItem.h" | 7 #include "core/layout/api/LayoutViewItem.h" |
| 8 #include "core/paint/ObjectPaintProperties.h" | 8 #include "core/paint/ObjectPaintProperties.h" |
| 9 #include "core/paint/PaintPropertyTreePrinter.h" | 9 #include "core/paint/PaintPropertyTreePrinter.h" |
| 10 #include "platform/graphics/paint/GeometryMapper.h" | 10 #include "platform/graphics/paint/GeometryMapper.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 EXPECT_EQ(frameScrollTranslation(), | 234 EXPECT_EQ(frameScrollTranslation(), |
| 235 scrollerProperties->overflowClip()->localTransformSpace()); | 235 scrollerProperties->overflowClip()->localTransformSpace()); |
| 236 EXPECT_EQ(frameScroll(), scrollerProperties->scroll()->parent()); | 236 EXPECT_EQ(frameScroll(), scrollerProperties->scroll()->parent()); |
| 237 EXPECT_EQ(FloatSize(413, 317), scrollerProperties->scroll()->clip()); | 237 EXPECT_EQ(FloatSize(413, 317), scrollerProperties->scroll()->clip()); |
| 238 EXPECT_EQ(FloatSize(660, 10200), scrollerProperties->scroll()->bounds()); | 238 EXPECT_EQ(FloatSize(660, 10200), scrollerProperties->scroll()->bounds()); |
| 239 EXPECT_FALSE(scrollerProperties->scroll()->userScrollableHorizontal()); | 239 EXPECT_FALSE(scrollerProperties->scroll()->userScrollableHorizontal()); |
| 240 EXPECT_TRUE(scrollerProperties->scroll()->userScrollableVertical()); | 240 EXPECT_TRUE(scrollerProperties->scroll()->userScrollableVertical()); |
| 241 EXPECT_EQ(FloatRoundedRect(120, 340, 413, 317), | 241 EXPECT_EQ(FloatRoundedRect(120, 340, 413, 317), |
| 242 scrollerProperties->overflowClip()->clipRect()); | 242 scrollerProperties->overflowClip()->clipRect()); |
| 243 EXPECT_EQ(frameContentClip(), scrollerProperties->overflowClip()->parent()); | 243 EXPECT_EQ(frameContentClip(), scrollerProperties->overflowClip()->parent()); |
| 244 // http://crbug.com/638415 | 244 CHECK_EXACT_VISUAL_RECT(LayoutRect(120, 340, 413, 317), |
| 245 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 245 scroller->layoutObject(), frameView->layoutView()); |
| 246 CHECK_EXACT_VISUAL_RECT(LayoutRect(120, 340, 413, 317), | |
| 247 scroller->layoutObject(), frameView->layoutView()); | |
| 248 } | |
| 249 | 246 |
| 250 // The relative-positioned element should have accumulated box offset (exclude | 247 // The relative-positioned element should have accumulated box offset (exclude |
| 251 // scrolling), and should be affected by ancestor scroll transforms. | 248 // scrolling), and should be affected by ancestor scroll transforms. |
| 252 Element* relPos = document().getElementById("rel-pos"); | 249 Element* relPos = document().getElementById("rel-pos"); |
| 253 const ObjectPaintProperties* relPosProperties = | 250 const ObjectPaintProperties* relPosProperties = |
| 254 relPos->layoutObject()->paintProperties(); | 251 relPos->layoutObject()->paintProperties(); |
| 255 EXPECT_EQ(TransformationMatrix().translate(680, 1120), | 252 EXPECT_EQ(TransformationMatrix().translate(680, 1120), |
| 256 relPosProperties->paintOffsetTranslation()->matrix()); | 253 relPosProperties->paintOffsetTranslation()->matrix()); |
| 257 EXPECT_EQ(scrollerProperties->scrollTranslation(), | 254 EXPECT_EQ(scrollerProperties->scrollTranslation(), |
| 258 relPosProperties->paintOffsetTranslation()->parent()); | 255 relPosProperties->paintOffsetTranslation()->parent()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 272 absPos->layoutObject()->paintProperties(); | 269 absPos->layoutObject()->paintProperties(); |
| 273 EXPECT_EQ(TransformationMatrix().translate(123, 456), | 270 EXPECT_EQ(TransformationMatrix().translate(123, 456), |
| 274 absPosProperties->paintOffsetTranslation()->matrix()); | 271 absPosProperties->paintOffsetTranslation()->matrix()); |
| 275 EXPECT_EQ(frameScrollTranslation(), | 272 EXPECT_EQ(frameScrollTranslation(), |
| 276 absPosProperties->paintOffsetTranslation()->parent()); | 273 absPosProperties->paintOffsetTranslation()->parent()); |
| 277 EXPECT_EQ(absPosProperties->transform(), | 274 EXPECT_EQ(absPosProperties->transform(), |
| 278 absPosProperties->overflowClip()->localTransformSpace()); | 275 absPosProperties->overflowClip()->localTransformSpace()); |
| 279 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400), | 276 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400), |
| 280 absPosProperties->overflowClip()->clipRect()); | 277 absPosProperties->overflowClip()->clipRect()); |
| 281 EXPECT_EQ(frameContentClip(), absPosProperties->overflowClip()->parent()); | 278 EXPECT_EQ(frameContentClip(), absPosProperties->overflowClip()->parent()); |
| 282 // http://crbug.com/638415 | |
| 283 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | |
| 284 CHECK_EXACT_VISUAL_RECT(LayoutRect(123, 456, 300, 400), | 279 CHECK_EXACT_VISUAL_RECT(LayoutRect(123, 456, 300, 400), |
| 285 absPos->layoutObject(), frameView->layoutView()); | 280 absPos->layoutObject(), frameView->layoutView()); |
| 286 } | |
| 287 } | 281 } |
| 288 | 282 |
| 289 TEST_P(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) { | 283 TEST_P(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) { |
| 290 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); | 284 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); |
| 291 | 285 |
| 292 document().domWindow()->scrollTo(0, 100); | 286 document().domWindow()->scrollTo(0, 100); |
| 293 | 287 |
| 294 FrameView* frameView = document().view(); | 288 FrameView* frameView = document().view(); |
| 295 frameView->updateAllLifecyclePhases(); | 289 frameView->updateAllLifecyclePhases(); |
| 296 EXPECT_EQ(TransformationMatrix(), framePreTranslation()->matrix()); | 290 EXPECT_EQ(TransformationMatrix(), framePreTranslation()->matrix()); |
| 297 EXPECT_TRUE(framePreTranslation()->parent()->isRoot()); | 291 EXPECT_TRUE(framePreTranslation()->parent()->isRoot()); |
| 298 | 292 |
| 299 EXPECT_EQ(TransformationMatrix().translate(0, -100), | 293 EXPECT_EQ(TransformationMatrix().translate(0, -100), |
| 300 frameScrollTranslation()->matrix()); | 294 frameScrollTranslation()->matrix()); |
| 301 EXPECT_EQ(framePreTranslation(), frameScrollTranslation()->parent()); | 295 EXPECT_EQ(framePreTranslation(), frameScrollTranslation()->parent()); |
| 302 EXPECT_EQ(framePreTranslation(), frameContentClip()->localTransformSpace()); | 296 EXPECT_EQ(framePreTranslation(), frameContentClip()->localTransformSpace()); |
| 303 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameContentClip()->clipRect()); | 297 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameContentClip()->clipRect()); |
| 304 EXPECT_TRUE(frameContentClip()->parent()->isRoot()); | 298 EXPECT_TRUE(frameContentClip()->parent()->isRoot()); |
| 305 | 299 |
| 306 LayoutViewItem layoutViewItem = document().layoutViewItem(); | |
| 307 const ObjectPaintProperties* layoutViewProperties = | |
| 308 layoutViewItem.paintProperties(); | |
| 309 // http://crbug.com/638415 | |
| 310 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 300 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 311 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation()); | 301 const auto* viewProperties = frameView->layoutView()->paintProperties(); |
| 312 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 784, 10000), | 302 EXPECT_EQ(nullptr, viewProperties->scrollTranslation()); |
| 313 document().body()->layoutObject(), | |
| 314 frameView->layoutView()); | |
| 315 } | 303 } |
| 304 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 784, 10000), |
| 305 document().body()->layoutObject(), |
| 306 frameView->layoutView()); |
| 316 } | 307 } |
| 317 | 308 |
| 318 TEST_P(PaintPropertyTreeBuilderTest, Perspective) { | 309 TEST_P(PaintPropertyTreeBuilderTest, Perspective) { |
| 319 loadTestData("perspective.html"); | 310 loadTestData("perspective.html"); |
| 320 | 311 |
| 321 Element* perspective = document().getElementById("perspective"); | 312 Element* perspective = document().getElementById("perspective"); |
| 322 const ObjectPaintProperties* perspectiveProperties = | 313 const ObjectPaintProperties* perspectiveProperties = |
| 323 perspective->layoutObject()->paintProperties(); | 314 perspective->layoutObject()->paintProperties(); |
| 324 EXPECT_EQ(TransformationMatrix().applyPerspective(100), | 315 EXPECT_EQ(TransformationMatrix().applyPerspective(100), |
| 325 perspectiveProperties->perspective()->matrix()); | 316 perspectiveProperties->perspective()->matrix()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 352 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), | 343 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), |
| 353 transformProperties->transform()->matrix()); | 344 transformProperties->transform()->matrix()); |
| 354 EXPECT_EQ(FloatPoint3D(200, 150, 0), | 345 EXPECT_EQ(FloatPoint3D(200, 150, 0), |
| 355 transformProperties->transform()->origin()); | 346 transformProperties->transform()->origin()); |
| 356 EXPECT_EQ(transformProperties->paintOffsetTranslation(), | 347 EXPECT_EQ(transformProperties->paintOffsetTranslation(), |
| 357 transformProperties->transform()->parent()); | 348 transformProperties->transform()->parent()); |
| 358 EXPECT_EQ(TransformationMatrix().translate(50, 100), | 349 EXPECT_EQ(TransformationMatrix().translate(50, 100), |
| 359 transformProperties->paintOffsetTranslation()->matrix()); | 350 transformProperties->paintOffsetTranslation()->matrix()); |
| 360 EXPECT_EQ(frameScrollTranslation(), | 351 EXPECT_EQ(frameScrollTranslation(), |
| 361 transformProperties->paintOffsetTranslation()->parent()); | 352 transformProperties->paintOffsetTranslation()->parent()); |
| 362 // http://crbug.com/638415 | |
| 363 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | |
| 364 CHECK_EXACT_VISUAL_RECT(LayoutRect(173, 556, 400, 300), | 353 CHECK_EXACT_VISUAL_RECT(LayoutRect(173, 556, 400, 300), |
| 365 transform->layoutObject(), | 354 transform->layoutObject(), |
| 366 document().view()->layoutView()); | 355 document().view()->layoutView()); |
| 367 } | |
| 368 } | 356 } |
| 369 | 357 |
| 370 TEST_P(PaintPropertyTreeBuilderTest, RelativePositionInline) { | 358 TEST_P(PaintPropertyTreeBuilderTest, RelativePositionInline) { |
| 371 loadTestData("relative-position-inline.html"); | 359 loadTestData("relative-position-inline.html"); |
| 372 | 360 |
| 373 Element* inlineBlock = document().getElementById("inline-block"); | 361 Element* inlineBlock = document().getElementById("inline-block"); |
| 374 const ObjectPaintProperties* inlineBlockProperties = | 362 const ObjectPaintProperties* inlineBlockProperties = |
| 375 inlineBlock->layoutObject()->paintProperties(); | 363 inlineBlock->layoutObject()->paintProperties(); |
| 376 EXPECT_EQ(TransformationMatrix().translate(135, 490), | 364 EXPECT_EQ(TransformationMatrix().translate(135, 490), |
| 377 inlineBlockProperties->paintOffsetTranslation()->matrix()); | 365 inlineBlockProperties->paintOffsetTranslation()->matrix()); |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 "translate3d(4px, 5px, 6px); width: 100px; height: 200px'></div>"); | 972 "translate3d(4px, 5px, 6px); width: 100px; height: 200px'></div>"); |
| 985 FrameView* frameView = document().view(); | 973 FrameView* frameView = document().view(); |
| 986 frameView->updateAllLifecyclePhases(); | 974 frameView->updateAllLifecyclePhases(); |
| 987 | 975 |
| 988 LayoutObject* divWithTransform = | 976 LayoutObject* divWithTransform = |
| 989 document().getElementById("divWithTransform")->layoutObject(); | 977 document().getElementById("divWithTransform")->layoutObject(); |
| 990 const ObjectPaintProperties* divWithTransformProperties = | 978 const ObjectPaintProperties* divWithTransformProperties = |
| 991 divWithTransform->paintProperties(); | 979 divWithTransform->paintProperties(); |
| 992 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), | 980 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), |
| 993 divWithTransformProperties->transform()->matrix()); | 981 divWithTransformProperties->transform()->matrix()); |
| 994 // http://crbug.com/638415 | |
| 995 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | |
| 996 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 164), divWithTransform, | 982 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 164), divWithTransform, |
| 997 frameView->layoutView()); | 983 frameView->layoutView()); |
| 998 } | |
| 999 | 984 |
| 1000 LayoutObject* innerDivWithTransform = | 985 LayoutObject* innerDivWithTransform = |
| 1001 frameDocument.getElementById("transform")->layoutObject(); | 986 frameDocument.getElementById("transform")->layoutObject(); |
| 1002 const ObjectPaintProperties* innerDivWithTransformProperties = | 987 const ObjectPaintProperties* innerDivWithTransformProperties = |
| 1003 innerDivWithTransform->paintProperties(); | 988 innerDivWithTransform->paintProperties(); |
| 1004 auto* innerDivTransform = innerDivWithTransformProperties->transform(); | 989 auto* innerDivTransform = innerDivWithTransformProperties->transform(); |
| 1005 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), | 990 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), |
| 1006 innerDivTransform->matrix()); | 991 innerDivTransform->matrix()); |
| 1007 CHECK_EXACT_VISUAL_RECT(LayoutRect(12, 14, 100, 145), innerDivWithTransform, | 992 CHECK_EXACT_VISUAL_RECT(LayoutRect(12, 14, 100, 145), innerDivWithTransform, |
| 1008 frameView->layoutView()); | 993 frameView->layoutView()); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), | 1062 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), |
| 1078 iframePaintOffsetTranslation->matrix()); | 1063 iframePaintOffsetTranslation->matrix()); |
| 1079 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); | 1064 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); |
| 1080 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), | 1065 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), |
| 1081 divWithTransformTransform->matrix()); | 1066 divWithTransformTransform->matrix()); |
| 1082 | 1067 |
| 1083 LayoutObject* divWithTransform = | 1068 LayoutObject* divWithTransform = |
| 1084 document().getElementById("divWithTransform")->layoutObject(); | 1069 document().getElementById("divWithTransform")->layoutObject(); |
| 1085 EXPECT_EQ(divWithTransformTransform, | 1070 EXPECT_EQ(divWithTransformTransform, |
| 1086 divWithTransform->paintProperties()->transform()); | 1071 divWithTransform->paintProperties()->transform()); |
| 1087 // http://crbug.com/638415 | |
| 1088 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | |
| 1089 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 248), divWithTransform, | 1072 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 248), divWithTransform, |
| 1090 frameView->layoutView()); | 1073 frameView->layoutView()); |
| 1091 } | |
| 1092 } | 1074 } |
| 1093 | 1075 |
| 1094 TEST_P(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) { | 1076 TEST_P(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) { |
| 1095 // This test verifies the tree builder correctly computes and records the | 1077 // This test verifies the tree builder correctly computes and records the |
| 1096 // property tree context for a (pseudo) stacking context that is scrolled by a | 1078 // property tree context for a (pseudo) stacking context that is scrolled by a |
| 1097 // containing block that is not one of the painting ancestors. | 1079 // containing block that is not one of the painting ancestors. |
| 1098 setBodyInnerHTML( | 1080 setBodyInnerHTML( |
| 1099 "<style>body { margin: 0; }</style>" | 1081 "<style>body { margin: 0; }</style>" |
| 1100 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>" | 1082 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>" |
| 1101 " <div id='child' style='position:relative; width:100px; height: " | 1083 " <div id='child' style='position:relative; width:100px; height: " |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 | 1130 |
| 1149 EXPECT_EQ( | 1131 EXPECT_EQ( |
| 1150 frameContentClip(), | 1132 frameContentClip(), |
| 1151 childProperties->localBorderBoxProperties()->propertyTreeState.clip()); | 1133 childProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 1152 EXPECT_EQ(frameScrollTranslation(), | 1134 EXPECT_EQ(frameScrollTranslation(), |
| 1153 childProperties->localBorderBoxProperties() | 1135 childProperties->localBorderBoxProperties() |
| 1154 ->propertyTreeState.transform()); | 1136 ->propertyTreeState.transform()); |
| 1155 EXPECT_EQ( | 1137 EXPECT_EQ( |
| 1156 scrollerProperties->effect(), | 1138 scrollerProperties->effect(), |
| 1157 childProperties->localBorderBoxProperties()->propertyTreeState.effect()); | 1139 childProperties->localBorderBoxProperties()->propertyTreeState.effect()); |
| 1158 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | |
| 1159 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 800, 10000), &scroller, | 1140 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 800, 10000), &scroller, |
| 1160 document().view()->layoutView()); | 1141 document().view()->layoutView()); |
| 1161 } | |
| 1162 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), &child, | 1142 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), &child, |
| 1163 document().view()->layoutView()); | 1143 document().view()->layoutView()); |
| 1164 } | 1144 } |
| 1165 | 1145 |
| 1166 TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) { | 1146 TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) { |
| 1167 // This test verifies that the border box space of a table cell is being | 1147 // This test verifies that the border box space of a table cell is being |
| 1168 // correctly computed. Table cells have weird location adjustment in our | 1148 // correctly computed. Table cells have weird location adjustment in our |
| 1169 // layout/paint implementation. | 1149 // layout/paint implementation. |
| 1170 setBodyInnerHTML( | 1150 setBodyInnerHTML( |
| 1171 "<style>" | 1151 "<style>" |
| (...skipping 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2932 EXPECT_EQ(framePreTranslation(), | 2912 EXPECT_EQ(framePreTranslation(), |
| 2933 childProperties->paintOffsetTranslation()->parent()); | 2913 childProperties->paintOffsetTranslation()->parent()); |
| 2934 EXPECT_EQ(childProperties->paintOffsetTranslation(), | 2914 EXPECT_EQ(childProperties->paintOffsetTranslation(), |
| 2935 childPaintState.transform()); | 2915 childPaintState.transform()); |
| 2936 // This will change once we added clip expansion node. | 2916 // This will change once we added clip expansion node. |
| 2937 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); | 2917 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); |
| 2938 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); | 2918 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); |
| 2939 } | 2919 } |
| 2940 | 2920 |
| 2941 } // namespace blink | 2921 } // namespace blink |
| OLD | NEW |