| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 slopFactor) \ | 90 slopFactor) \ |
| 91 do { \ | 91 do { \ |
| 92 GeometryMapper geometryMapper; \ | 92 GeometryMapper geometryMapper; \ |
| 93 LayoutRect source( \ | 93 LayoutRect source( \ |
| 94 (sourceLayoutObject)->localOverflowRectForPaintInvalidation()); \ | 94 (sourceLayoutObject)->localOverflowRectForPaintInvalidation()); \ |
| 95 source.moveBy((sourceLayoutObject) \ | 95 source.moveBy((sourceLayoutObject) \ |
| 96 ->objectPaintProperties() \ | 96 ->objectPaintProperties() \ |
| 97 ->localBorderBoxProperties() \ | 97 ->localBorderBoxProperties() \ |
| 98 ->paintOffset); \ | 98 ->paintOffset); \ |
| 99 bool success = false; \ | 99 bool success = false; \ |
| 100 GeometryPropertyTreeState contentsTreeState; \ | 100 auto contentsProperties = \ |
| 101 LayoutPoint paintOffsetFromContentsTreeState; \ | 101 (ancestorLayoutObject)->objectPaintProperties()->contentsProperties(); \ |
| 102 (ancestorLayoutObject) \ | |
| 103 ->objectPaintProperties() \ | |
| 104 ->getContentsPropertyTreeState(contentsTreeState, \ | |
| 105 paintOffsetFromContentsTreeState); \ | |
| 106 LayoutRect actual = \ | 102 LayoutRect actual = \ |
| 107 LayoutRect(geometryMapper.mapToVisualRectInDestinationSpace( \ | 103 LayoutRect(geometryMapper.mapToVisualRectInDestinationSpace( \ |
| 108 FloatRect(source), (sourceLayoutObject) \ | 104 FloatRect(source), (sourceLayoutObject) \ |
| 109 ->objectPaintProperties() \ | 105 ->objectPaintProperties() \ |
| 110 ->localBorderBoxProperties() \ | 106 ->localBorderBoxProperties() \ |
| 111 ->geometryPropertyTreeState, \ | 107 ->propertyTreeState, \ |
| 112 contentsTreeState, success)); \ | 108 contentsProperties.propertyTreeState, success)); \ |
| 113 ASSERT_TRUE(success); \ | 109 ASSERT_TRUE(success); \ |
| 114 actual.moveBy(-paintOffsetFromContentsTreeState); \ | 110 actual.moveBy(-contentsProperties.paintOffset); \ |
| 115 EXPECT_EQ(expected, actual) \ | 111 EXPECT_EQ(expected, actual) \ |
| 116 << "GeometryMapper: expected: " << expected.toString() \ | 112 << "GeometryMapper: expected: " << expected.toString() \ |
| 117 << ", actual: " << actual.toString(); \ | 113 << ", actual: " << actual.toString(); \ |
| 118 \ | 114 \ |
| 119 if (slopFactor == LayoutUnit::max()) \ | 115 if (slopFactor == LayoutUnit::max()) \ |
| 120 break; \ | 116 break; \ |
| 121 LayoutRect slowPathRect = \ | 117 LayoutRect slowPathRect = \ |
| 122 (sourceLayoutObject)->localOverflowRectForPaintInvalidation(); \ | 118 (sourceLayoutObject)->localOverflowRectForPaintInvalidation(); \ |
| 123 (sourceLayoutObject) \ | 119 (sourceLayoutObject) \ |
| 124 ->mapToVisualRectInAncestorSpace(ancestorLayoutObject, slowPathRect); \ | 120 ->mapToVisualRectInAncestorSpace(ancestorLayoutObject, slowPathRect); \ |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 "</div>"); | 1086 "</div>"); |
| 1091 FrameView* frameView = document().view(); | 1087 FrameView* frameView = document().view(); |
| 1092 | 1088 |
| 1093 LayoutObject* scroller = | 1089 LayoutObject* scroller = |
| 1094 document().getElementById("scroller")->layoutObject(); | 1090 document().getElementById("scroller")->layoutObject(); |
| 1095 const ObjectPaintProperties* scrollerProperties = | 1091 const ObjectPaintProperties* scrollerProperties = |
| 1096 scroller->objectPaintProperties(); | 1092 scroller->objectPaintProperties(); |
| 1097 LayoutObject* child = document().getElementById("child")->layoutObject(); | 1093 LayoutObject* child = document().getElementById("child")->layoutObject(); |
| 1098 const ObjectPaintProperties* childProperties = child->objectPaintProperties(); | 1094 const ObjectPaintProperties* childProperties = child->objectPaintProperties(); |
| 1099 | 1095 |
| 1100 EXPECT_EQ(scrollerProperties->overflowClip(), | 1096 EXPECT_EQ( |
| 1101 childProperties->localBorderBoxProperties() | 1097 scrollerProperties->overflowClip(), |
| 1102 ->geometryPropertyTreeState.clip); | 1098 childProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 1103 EXPECT_EQ(scrollerProperties->scrollTranslation(), | 1099 EXPECT_EQ(scrollerProperties->scrollTranslation(), |
| 1104 childProperties->localBorderBoxProperties() | 1100 childProperties->localBorderBoxProperties() |
| 1105 ->geometryPropertyTreeState.transform); | 1101 ->propertyTreeState.transform()); |
| 1106 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties() | 1102 EXPECT_NE( |
| 1107 ->geometryPropertyTreeState.effect); | 1103 nullptr, |
| 1104 childProperties->localBorderBoxProperties()->propertyTreeState.effect()); |
| 1108 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 300), scroller, | 1105 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 300), scroller, |
| 1109 frameView->layoutView()); | 1106 frameView->layoutView()); |
| 1110 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), child, | 1107 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), child, |
| 1111 frameView->layoutView()); | 1108 frameView->layoutView()); |
| 1112 } | 1109 } |
| 1113 | 1110 |
| 1114 TEST_P(PaintPropertyTreeBuilderTest, | 1111 TEST_P(PaintPropertyTreeBuilderTest, |
| 1115 TreeContextUnclipFromParentStackingContext) { | 1112 TreeContextUnclipFromParentStackingContext) { |
| 1116 // This test verifies the tree builder correctly computes and records the prop
erty tree context | 1113 // This test verifies the tree builder correctly computes and records the prop
erty tree context |
| 1117 // for a (pseudo) stacking context that has a scrolling painting ancestor that
is not its | 1114 // for a (pseudo) stacking context that has a scrolling painting ancestor that
is not its |
| 1118 // containing block (thus should not be scrolled by it). | 1115 // containing block (thus should not be scrolled by it). |
| 1119 | 1116 |
| 1120 setBodyInnerHTML( | 1117 setBodyInnerHTML( |
| 1121 "<style>body { margin: 0; }</style>" | 1118 "<style>body { margin: 0; }</style>" |
| 1122 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" | 1119 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" |
| 1123 " <div id='child' style='position:absolute; left:0; top:0; width: " | 1120 " <div id='child' style='position:absolute; left:0; top:0; width: " |
| 1124 "100px; height: 200px'></div>" | 1121 "100px; height: 200px'></div>" |
| 1125 " <div style='height:10000px;'></div>" | 1122 " <div style='height:10000px;'></div>" |
| 1126 "</div>"); | 1123 "</div>"); |
| 1127 | 1124 |
| 1128 LayoutObject& scroller = | 1125 LayoutObject& scroller = |
| 1129 *document().getElementById("scroller")->layoutObject(); | 1126 *document().getElementById("scroller")->layoutObject(); |
| 1130 const ObjectPaintProperties* scrollerProperties = | 1127 const ObjectPaintProperties* scrollerProperties = |
| 1131 scroller.objectPaintProperties(); | 1128 scroller.objectPaintProperties(); |
| 1132 LayoutObject& child = *document().getElementById("child")->layoutObject(); | 1129 LayoutObject& child = *document().getElementById("child")->layoutObject(); |
| 1133 const ObjectPaintProperties* childProperties = child.objectPaintProperties(); | 1130 const ObjectPaintProperties* childProperties = child.objectPaintProperties(); |
| 1134 | 1131 |
| 1135 EXPECT_EQ(frameContentClip(), childProperties->localBorderBoxProperties() | 1132 EXPECT_EQ( |
| 1136 ->geometryPropertyTreeState.clip); | 1133 frameContentClip(), |
| 1134 childProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 1137 EXPECT_EQ(frameScrollTranslation(), | 1135 EXPECT_EQ(frameScrollTranslation(), |
| 1138 childProperties->localBorderBoxProperties() | 1136 childProperties->localBorderBoxProperties() |
| 1139 ->geometryPropertyTreeState.transform); | 1137 ->propertyTreeState.transform()); |
| 1140 EXPECT_EQ(scrollerProperties->effect(), | 1138 EXPECT_EQ( |
| 1141 childProperties->localBorderBoxProperties() | 1139 scrollerProperties->effect(), |
| 1142 ->geometryPropertyTreeState.effect); | 1140 childProperties->localBorderBoxProperties()->propertyTreeState.effect()); |
| 1143 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 1141 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 1144 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 800, 10000), &scroller, | 1142 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 800, 10000), &scroller, |
| 1145 document().view()->layoutView()); | 1143 document().view()->layoutView()); |
| 1146 } | 1144 } |
| 1147 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), &child, | 1145 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), &child, |
| 1148 document().view()->layoutView()); | 1146 document().view()->layoutView()); |
| 1149 } | 1147 } |
| 1150 | 1148 |
| 1151 TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) { | 1149 TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) { |
| 1152 // This test verifies that the border box space of a table cell is being corre
ctly computed. | 1150 // This test verifies that the border box space of a table cell is being corre
ctly computed. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1178 " <tr><td></td><td><div id='target'></div></td></tr>" | 1176 " <tr><td></td><td><div id='target'></div></td></tr>" |
| 1179 "</table>"); | 1177 "</table>"); |
| 1180 | 1178 |
| 1181 LayoutObject& target = *document().getElementById("target")->layoutObject(); | 1179 LayoutObject& target = *document().getElementById("target")->layoutObject(); |
| 1182 const ObjectPaintProperties* targetProperties = | 1180 const ObjectPaintProperties* targetProperties = |
| 1183 target.objectPaintProperties(); | 1181 target.objectPaintProperties(); |
| 1184 | 1182 |
| 1185 EXPECT_EQ(LayoutPoint(170, 170), | 1183 EXPECT_EQ(LayoutPoint(170, 170), |
| 1186 targetProperties->localBorderBoxProperties()->paintOffset); | 1184 targetProperties->localBorderBoxProperties()->paintOffset); |
| 1187 EXPECT_EQ(framePreTranslation(), targetProperties->localBorderBoxProperties() | 1185 EXPECT_EQ(framePreTranslation(), targetProperties->localBorderBoxProperties() |
| 1188 ->geometryPropertyTreeState.transform); | 1186 ->propertyTreeState.transform()); |
| 1189 CHECK_EXACT_VISUAL_RECT(LayoutRect(170, 170, 100, 100), &target, | 1187 CHECK_EXACT_VISUAL_RECT(LayoutRect(170, 170, 100, 100), &target, |
| 1190 document().view()->layoutView()); | 1188 document().view()->layoutView()); |
| 1191 } | 1189 } |
| 1192 | 1190 |
| 1193 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) { | 1191 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) { |
| 1194 // This test verifies that clip tree hierarchy being generated correctly for t
he hard case | 1192 // This test verifies that clip tree hierarchy being generated correctly for t
he hard case |
| 1195 // such that a fixed position element getting clipped by an absolute position
CSS clip. | 1193 // such that a fixed position element getting clipped by an absolute position
CSS clip. |
| 1196 setBodyInnerHTML( | 1194 setBodyInnerHTML( |
| 1197 "<style>" | 1195 "<style>" |
| 1198 " #clip {" | 1196 " #clip {" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1223 clipProperties->cssClip()->localTransformSpace()); | 1221 clipProperties->cssClip()->localTransformSpace()); |
| 1224 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), | 1222 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), |
| 1225 clipProperties->cssClip()->clipRect()); | 1223 clipProperties->cssClip()->clipRect()); |
| 1226 CHECK_VISUAL_RECT( | 1224 CHECK_VISUAL_RECT( |
| 1227 absoluteClipRect, &clip, document().view()->layoutView(), | 1225 absoluteClipRect, &clip, document().view()->layoutView(), |
| 1228 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() doesn't apply
css clip on the object itself. | 1226 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() doesn't apply
css clip on the object itself. |
| 1229 LayoutUnit::max()); | 1227 LayoutUnit::max()); |
| 1230 | 1228 |
| 1231 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 1229 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 1232 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(); | 1230 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(); |
| 1233 EXPECT_EQ(clipProperties->cssClip(), | 1231 EXPECT_EQ( |
| 1234 fixedProperties->localBorderBoxProperties() | 1232 clipProperties->cssClip(), |
| 1235 ->geometryPropertyTreeState.clip); | 1233 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 1236 EXPECT_EQ(framePreTranslation(), | 1234 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() |
| 1237 fixedProperties->localBorderBoxProperties() | 1235 ->propertyTreeState.transform() |
| 1238 ->geometryPropertyTreeState.transform->parent()); | 1236 ->parent()); |
| 1239 EXPECT_EQ(TransformationMatrix().translate(654, 321), | 1237 EXPECT_EQ(TransformationMatrix().translate(654, 321), |
| 1240 fixedProperties->localBorderBoxProperties() | 1238 fixedProperties->localBorderBoxProperties() |
| 1241 ->geometryPropertyTreeState.transform->matrix()); | 1239 ->propertyTreeState.transform() |
| 1240 ->matrix()); |
| 1242 EXPECT_EQ(LayoutPoint(), | 1241 EXPECT_EQ(LayoutPoint(), |
| 1243 fixedProperties->localBorderBoxProperties()->paintOffset); | 1242 fixedProperties->localBorderBoxProperties()->paintOffset); |
| 1244 CHECK_VISUAL_RECT( | 1243 CHECK_VISUAL_RECT( |
| 1245 LayoutRect(), fixed, document().view()->layoutView(), | 1244 LayoutRect(), fixed, document().view()->layoutView(), |
| 1246 // TODO(crbug.com/599939): CSS clip of fixed-position descendants is broke
n in mapToVisualRectInAncestorSpace(). | 1245 // TODO(crbug.com/599939): CSS clip of fixed-position descendants is broke
n in mapToVisualRectInAncestorSpace(). |
| 1247 LayoutUnit::max()); | 1246 LayoutUnit::max()); |
| 1248 } | 1247 } |
| 1249 | 1248 |
| 1250 TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) { | 1249 TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) { |
| 1251 // This test verifies that clip tree hierarchy being generated correctly for t
he hard case | 1250 // This test verifies that clip tree hierarchy being generated correctly for t
he hard case |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 clipProperties->cssClip()->clipRect()); | 1284 clipProperties->cssClip()->clipRect()); |
| 1286 CHECK_VISUAL_RECT( | 1285 CHECK_VISUAL_RECT( |
| 1287 absoluteClipRect, clip, document().view()->layoutView(), | 1286 absoluteClipRect, clip, document().view()->layoutView(), |
| 1288 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() doesn't apply
css clip on the object itself. | 1287 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() doesn't apply
css clip on the object itself. |
| 1289 LayoutUnit::max()); | 1288 LayoutUnit::max()); |
| 1290 | 1289 |
| 1291 LayoutObject* absolute = | 1290 LayoutObject* absolute = |
| 1292 document().getElementById("absolute")->layoutObject(); | 1291 document().getElementById("absolute")->layoutObject(); |
| 1293 const ObjectPaintProperties* absPosProperties = | 1292 const ObjectPaintProperties* absPosProperties = |
| 1294 absolute->objectPaintProperties(); | 1293 absolute->objectPaintProperties(); |
| 1295 EXPECT_EQ(clipProperties->cssClip(), | 1294 EXPECT_EQ( |
| 1296 absPosProperties->localBorderBoxProperties() | 1295 clipProperties->cssClip(), |
| 1297 ->geometryPropertyTreeState.clip); | 1296 absPosProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 1298 EXPECT_EQ(framePreTranslation(), absPosProperties->localBorderBoxProperties() | 1297 EXPECT_EQ(framePreTranslation(), absPosProperties->localBorderBoxProperties() |
| 1299 ->geometryPropertyTreeState.transform); | 1298 ->propertyTreeState.transform()); |
| 1300 EXPECT_EQ(LayoutPoint(123, 456), | 1299 EXPECT_EQ(LayoutPoint(123, 456), |
| 1301 absPosProperties->localBorderBoxProperties()->paintOffset); | 1300 absPosProperties->localBorderBoxProperties()->paintOffset); |
| 1302 CHECK_VISUAL_RECT( | 1301 CHECK_VISUAL_RECT( |
| 1303 LayoutRect(), absolute, document().view()->layoutView(), | 1302 LayoutRect(), absolute, document().view()->layoutView(), |
| 1304 // TODO(crbug.com/599939): CSS clip of fixed-position descendants is broke
n in mapToVisualRectInAncestorSpace(). | 1303 // TODO(crbug.com/599939): CSS clip of fixed-position descendants is broke
n in mapToVisualRectInAncestorSpace(). |
| 1305 LayoutUnit::max()); | 1304 LayoutUnit::max()); |
| 1306 } | 1305 } |
| 1307 | 1306 |
| 1308 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) { | 1307 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) { |
| 1309 // This test is similar to CSSClipFixedPositionDescendant above, except that | 1308 // This test is similar to CSSClipFixedPositionDescendant above, except that |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 EXPECT_EQ(frameContentClip(), | 1360 EXPECT_EQ(frameContentClip(), |
| 1362 clipProperties->cssClipFixedPosition()->parent()); | 1361 clipProperties->cssClipFixedPosition()->parent()); |
| 1363 EXPECT_EQ(overflowProperties->scrollTranslation(), | 1362 EXPECT_EQ(overflowProperties->scrollTranslation(), |
| 1364 clipProperties->cssClipFixedPosition()->localTransformSpace()); | 1363 clipProperties->cssClipFixedPosition()->localTransformSpace()); |
| 1365 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), | 1364 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), |
| 1366 clipProperties->cssClipFixedPosition()->clipRect()); | 1365 clipProperties->cssClipFixedPosition()->clipRect()); |
| 1367 CHECK_EXACT_VISUAL_RECT(LayoutRect(), clip, document().view()->layoutView()); | 1366 CHECK_EXACT_VISUAL_RECT(LayoutRect(), clip, document().view()->layoutView()); |
| 1368 | 1367 |
| 1369 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 1368 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 1370 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(); | 1369 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(); |
| 1371 EXPECT_EQ(clipProperties->cssClipFixedPosition(), | 1370 EXPECT_EQ( |
| 1372 fixedProperties->localBorderBoxProperties() | 1371 clipProperties->cssClipFixedPosition(), |
| 1373 ->geometryPropertyTreeState.clip); | 1372 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 1374 EXPECT_EQ(framePreTranslation(), | 1373 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() |
| 1375 fixedProperties->localBorderBoxProperties() | 1374 ->propertyTreeState.transform() |
| 1376 ->geometryPropertyTreeState.transform->parent()); | 1375 ->parent()); |
| 1377 EXPECT_EQ(TransformationMatrix().translate(654, 321), | 1376 EXPECT_EQ(TransformationMatrix().translate(654, 321), |
| 1378 fixedProperties->localBorderBoxProperties() | 1377 fixedProperties->localBorderBoxProperties() |
| 1379 ->geometryPropertyTreeState.transform->matrix()); | 1378 ->propertyTreeState.transform() |
| 1379 ->matrix()); |
| 1380 EXPECT_EQ(LayoutPoint(), | 1380 EXPECT_EQ(LayoutPoint(), |
| 1381 fixedProperties->localBorderBoxProperties()->paintOffset); | 1381 fixedProperties->localBorderBoxProperties()->paintOffset); |
| 1382 CHECK_VISUAL_RECT( | 1382 CHECK_VISUAL_RECT( |
| 1383 LayoutRect(), fixed, document().view()->layoutView(), | 1383 LayoutRect(), fixed, document().view()->layoutView(), |
| 1384 // TODO(crbug.com/599939): CSS clip of fixed-position descendants is broke
n in geometry mapping. | 1384 // TODO(crbug.com/599939): CSS clip of fixed-position descendants is broke
n in geometry mapping. |
| 1385 LayoutUnit::max()); | 1385 LayoutUnit::max()); |
| 1386 } | 1386 } |
| 1387 | 1387 |
| 1388 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) { | 1388 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) { |
| 1389 setBodyInnerHTML( | 1389 setBodyInnerHTML( |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2014 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( | 2014 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( |
| 2015 document().getElementById("clipper")->layoutObject()); | 2015 document().getElementById("clipper")->layoutObject()); |
| 2016 const ObjectPaintProperties* clipProperties = | 2016 const ObjectPaintProperties* clipProperties = |
| 2017 clipper->objectPaintProperties(); | 2017 clipper->objectPaintProperties(); |
| 2018 LayoutObject* child = document().getElementById("child")->layoutObject(); | 2018 LayoutObject* child = document().getElementById("child")->layoutObject(); |
| 2019 const ObjectPaintProperties* childProperties = child->objectPaintProperties(); | 2019 const ObjectPaintProperties* childProperties = child->objectPaintProperties(); |
| 2020 | 2020 |
| 2021 // No scroll translation because the document does not scroll (not enough cont
ent). | 2021 // No scroll translation because the document does not scroll (not enough cont
ent). |
| 2022 EXPECT_TRUE(!frameScrollTranslation()); | 2022 EXPECT_TRUE(!frameScrollTranslation()); |
| 2023 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() | 2023 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() |
| 2024 ->geometryPropertyTreeState.transform); | 2024 ->propertyTreeState.transform()); |
| 2025 EXPECT_EQ(frameContentClip(), clipProperties->localBorderBoxProperties() | 2025 EXPECT_EQ( |
| 2026 ->geometryPropertyTreeState.clip); | 2026 frameContentClip(), |
| 2027 clipProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 2027 | 2028 |
| 2028 GeometryPropertyTreeState contentsTreeState; | 2029 auto contentsProperties = clipProperties->contentsProperties(); |
| 2029 LayoutPoint paintOffsetFromContentsTreeState; | 2030 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset); |
| 2030 clipProperties->getContentsPropertyTreeState( | 2031 EXPECT_EQ(framePreTranslation(), |
| 2031 contentsTreeState, paintOffsetFromContentsTreeState); | 2032 contentsProperties.propertyTreeState.transform()); |
| 2032 EXPECT_EQ(LayoutPoint(30, 20), paintOffsetFromContentsTreeState); | 2033 EXPECT_EQ(clipProperties->overflowClip(), |
| 2033 EXPECT_EQ(framePreTranslation(), contentsTreeState.transform); | 2034 contentsProperties.propertyTreeState.clip()); |
| 2034 EXPECT_EQ(clipProperties->overflowClip(), contentsTreeState.clip); | |
| 2035 | 2035 |
| 2036 EXPECT_EQ(framePreTranslation(), childProperties->localBorderBoxProperties() | 2036 EXPECT_EQ(framePreTranslation(), childProperties->localBorderBoxProperties() |
| 2037 ->geometryPropertyTreeState.transform); | 2037 ->propertyTreeState.transform()); |
| 2038 EXPECT_EQ(clipProperties->overflowClip(), | 2038 EXPECT_EQ( |
| 2039 childProperties->localBorderBoxProperties() | 2039 clipProperties->overflowClip(), |
| 2040 ->geometryPropertyTreeState.clip); | 2040 childProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 2041 | 2041 |
| 2042 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties() | 2042 EXPECT_NE( |
| 2043 ->geometryPropertyTreeState.effect); | 2043 nullptr, |
| 2044 childProperties->localBorderBoxProperties()->propertyTreeState.effect()); |
| 2044 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 500, 600), child, clipper); | 2045 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 500, 600), child, clipper); |
| 2045 } | 2046 } |
| 2046 | 2047 |
| 2047 TEST_P(PaintPropertyTreeBuilderTest, ContainsPaintContentsTreeState) { | 2048 TEST_P(PaintPropertyTreeBuilderTest, ContainsPaintContentsTreeState) { |
| 2048 setBodyInnerHTML( | 2049 setBodyInnerHTML( |
| 2049 "<style>body { margin: 20px 30px; }</style>" | 2050 "<style>body { margin: 20px 30px; }</style>" |
| 2050 "<div id='clipper' style='contain:paint; width:300px; height:200px;'>" | 2051 "<div id='clipper' style='contain:paint; width:300px; height:200px;'>" |
| 2051 " <div id='child' style='position:relative; width:400px; height: " | 2052 " <div id='child' style='position:relative; width:400px; height: " |
| 2052 "500px;'></div>" | 2053 "500px;'></div>" |
| 2053 "</div>"); | 2054 "</div>"); |
| 2054 | 2055 |
| 2055 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( | 2056 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( |
| 2056 document().getElementById("clipper")->layoutObject()); | 2057 document().getElementById("clipper")->layoutObject()); |
| 2057 const ObjectPaintProperties* clipProperties = | 2058 const ObjectPaintProperties* clipProperties = |
| 2058 clipper->objectPaintProperties(); | 2059 clipper->objectPaintProperties(); |
| 2059 LayoutObject* child = document().getElementById("child")->layoutObject(); | 2060 LayoutObject* child = document().getElementById("child")->layoutObject(); |
| 2060 const ObjectPaintProperties* childProperties = child->objectPaintProperties(); | 2061 const ObjectPaintProperties* childProperties = child->objectPaintProperties(); |
| 2061 | 2062 |
| 2062 // No scroll translation because the document does not scroll (not enough cont
ent). | 2063 // No scroll translation because the document does not scroll (not enough cont
ent). |
| 2063 EXPECT_TRUE(!frameScrollTranslation()); | 2064 EXPECT_TRUE(!frameScrollTranslation()); |
| 2064 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() | 2065 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() |
| 2065 ->geometryPropertyTreeState.transform); | 2066 ->propertyTreeState.transform()); |
| 2066 EXPECT_EQ(frameContentClip(), clipProperties->localBorderBoxProperties() | 2067 EXPECT_EQ( |
| 2067 ->geometryPropertyTreeState.clip); | 2068 frameContentClip(), |
| 2069 clipProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 2068 | 2070 |
| 2069 GeometryPropertyTreeState contentsTreeState; | 2071 auto contentsProperties = clipProperties->contentsProperties(); |
| 2070 LayoutPoint paintOffsetFromContentsTreeState; | 2072 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset); |
| 2071 clipProperties->getContentsPropertyTreeState( | 2073 EXPECT_EQ(framePreTranslation(), |
| 2072 contentsTreeState, paintOffsetFromContentsTreeState); | 2074 contentsProperties.propertyTreeState.transform()); |
| 2073 EXPECT_EQ(LayoutPoint(30, 20), paintOffsetFromContentsTreeState); | 2075 EXPECT_EQ(clipProperties->overflowClip(), |
| 2074 EXPECT_EQ(framePreTranslation(), contentsTreeState.transform); | 2076 contentsProperties.propertyTreeState.clip()); |
| 2075 EXPECT_EQ(clipProperties->overflowClip(), contentsTreeState.clip); | |
| 2076 | 2077 |
| 2077 EXPECT_EQ(framePreTranslation(), childProperties->localBorderBoxProperties() | 2078 EXPECT_EQ(framePreTranslation(), childProperties->localBorderBoxProperties() |
| 2078 ->geometryPropertyTreeState.transform); | 2079 ->propertyTreeState.transform()); |
| 2079 EXPECT_EQ(clipProperties->overflowClip(), | 2080 EXPECT_EQ( |
| 2080 childProperties->localBorderBoxProperties() | 2081 clipProperties->overflowClip(), |
| 2081 ->geometryPropertyTreeState.clip); | 2082 childProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 2082 | 2083 |
| 2083 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties() | 2084 EXPECT_NE( |
| 2084 ->geometryPropertyTreeState.effect); | 2085 nullptr, |
| 2086 childProperties->localBorderBoxProperties()->propertyTreeState.effect()); |
| 2085 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 500), child, clipper); | 2087 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 500), child, clipper); |
| 2086 } | 2088 } |
| 2087 | 2089 |
| 2088 TEST_P(PaintPropertyTreeBuilderTest, OverflowScrollContentsTreeState) { | 2090 TEST_P(PaintPropertyTreeBuilderTest, OverflowScrollContentsTreeState) { |
| 2089 // This test verifies the tree builder correctly computes and records the prop
erty tree context | 2091 // This test verifies the tree builder correctly computes and records the prop
erty tree context |
| 2090 // for a (pseudo) stacking context that is scrolled by a containing block that
is not one of | 2092 // for a (pseudo) stacking context that is scrolled by a containing block that
is not one of |
| 2091 // the painting ancestors. | 2093 // the painting ancestors. |
| 2092 setBodyInnerHTML( | 2094 setBodyInnerHTML( |
| 2093 "<style>body { margin: 20px 30px; }</style>" | 2095 "<style>body { margin: 20px 30px; }</style>" |
| 2094 "<div id='clipper' style='overflow:scroll; width:400px; height:300px;'>" | 2096 "<div id='clipper' style='overflow:scroll; width:400px; height:300px;'>" |
| 2095 " <div id='child' style='position:relative; width:500px; height: " | 2097 " <div id='child' style='position:relative; width:500px; height: " |
| 2096 "600px;'></div>" | 2098 "600px;'></div>" |
| 2097 " <div style='width: 200px; height: 10000px'></div>" | 2099 " <div style='width: 200px; height: 10000px'></div>" |
| 2098 "</div>" | 2100 "</div>" |
| 2099 "<div id='forceScroll' style='height: 4000px;'></div>"); | 2101 "<div id='forceScroll' style='height: 4000px;'></div>"); |
| 2100 | 2102 |
| 2101 Element* clipperElement = document().getElementById("clipper"); | 2103 Element* clipperElement = document().getElementById("clipper"); |
| 2102 clipperElement->scrollTo(1, 2); | 2104 clipperElement->scrollTo(1, 2); |
| 2103 | 2105 |
| 2104 LayoutBoxModelObject* clipper = | 2106 LayoutBoxModelObject* clipper = |
| 2105 toLayoutBoxModelObject(clipperElement->layoutObject()); | 2107 toLayoutBoxModelObject(clipperElement->layoutObject()); |
| 2106 const ObjectPaintProperties* clipProperties = | 2108 const ObjectPaintProperties* clipProperties = |
| 2107 clipper->objectPaintProperties(); | 2109 clipper->objectPaintProperties(); |
| 2108 LayoutObject* child = document().getElementById("child")->layoutObject(); | 2110 LayoutObject* child = document().getElementById("child")->layoutObject(); |
| 2109 const ObjectPaintProperties* childProperties = child->objectPaintProperties(); | 2111 const ObjectPaintProperties* childProperties = child->objectPaintProperties(); |
| 2110 | 2112 |
| 2111 EXPECT_EQ(frameScrollTranslation(), | 2113 EXPECT_EQ(frameScrollTranslation(), clipProperties->localBorderBoxProperties() |
| 2112 clipProperties->localBorderBoxProperties() | 2114 ->propertyTreeState.transform()); |
| 2113 ->geometryPropertyTreeState.transform); | 2115 EXPECT_EQ( |
| 2114 EXPECT_EQ(frameContentClip(), clipProperties->localBorderBoxProperties() | 2116 frameContentClip(), |
| 2115 ->geometryPropertyTreeState.clip); | 2117 clipProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 2116 | 2118 |
| 2117 GeometryPropertyTreeState contentsTreeState; | 2119 auto contentsProperties = clipProperties->contentsProperties(); |
| 2118 LayoutPoint paintOffsetFromContentsTreeState; | 2120 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset); |
| 2119 clipProperties->getContentsPropertyTreeState( | 2121 EXPECT_EQ(clipProperties->scrollTranslation(), |
| 2120 contentsTreeState, paintOffsetFromContentsTreeState); | 2122 contentsProperties.propertyTreeState.transform()); |
| 2121 EXPECT_EQ(LayoutPoint(30, 20), paintOffsetFromContentsTreeState); | 2123 EXPECT_EQ(clipProperties->overflowClip(), |
| 2122 EXPECT_EQ(clipProperties->scrollTranslation(), contentsTreeState.transform); | 2124 contentsProperties.propertyTreeState.clip()); |
| 2123 EXPECT_EQ(clipProperties->overflowClip(), contentsTreeState.clip); | |
| 2124 | 2125 |
| 2125 EXPECT_EQ(clipProperties->scrollTranslation(), | 2126 EXPECT_EQ(clipProperties->scrollTranslation(), |
| 2126 childProperties->localBorderBoxProperties() | 2127 childProperties->localBorderBoxProperties() |
| 2127 ->geometryPropertyTreeState.transform); | 2128 ->propertyTreeState.transform()); |
| 2128 EXPECT_EQ(clipProperties->overflowClip(), | 2129 EXPECT_EQ( |
| 2129 childProperties->localBorderBoxProperties() | 2130 clipProperties->overflowClip(), |
| 2130 ->geometryPropertyTreeState.clip); | 2131 childProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 2131 | 2132 |
| 2132 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 500, 600), child, clipper); | 2133 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 500, 600), child, clipper); |
| 2133 } | 2134 } |
| 2134 | 2135 |
| 2135 TEST_P(PaintPropertyTreeBuilderTest, OverflowScrollWithRoundedRect) { | 2136 TEST_P(PaintPropertyTreeBuilderTest, OverflowScrollWithRoundedRect) { |
| 2136 setBodyInnerHTML( | 2137 setBodyInnerHTML( |
| 2137 "<style>" | 2138 "<style>" |
| 2138 " * { margin: 0; }" | 2139 " * { margin: 0; }" |
| 2139 " ::-webkit-scrollbar {" | 2140 " ::-webkit-scrollbar {" |
| 2140 " width: 13px;" | 2141 " width: 13px;" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2190 | 2191 |
| 2191 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( | 2192 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( |
| 2192 document().getElementById("clipper")->layoutObject()); | 2193 document().getElementById("clipper")->layoutObject()); |
| 2193 const ObjectPaintProperties* clipProperties = | 2194 const ObjectPaintProperties* clipProperties = |
| 2194 clipper->objectPaintProperties(); | 2195 clipper->objectPaintProperties(); |
| 2195 LayoutObject* child = document().getElementById("child")->layoutObject(); | 2196 LayoutObject* child = document().getElementById("child")->layoutObject(); |
| 2196 | 2197 |
| 2197 // No scroll translation because the document does not scroll (not enough cont
ent). | 2198 // No scroll translation because the document does not scroll (not enough cont
ent). |
| 2198 EXPECT_TRUE(!frameScrollTranslation()); | 2199 EXPECT_TRUE(!frameScrollTranslation()); |
| 2199 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() | 2200 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() |
| 2200 ->geometryPropertyTreeState.transform); | 2201 ->propertyTreeState.transform()); |
| 2201 // CSS clip on an element causes it to clip itself, not just descendants. | 2202 // CSS clip on an element causes it to clip itself, not just descendants. |
| 2203 EXPECT_EQ( |
| 2204 clipProperties->cssClip(), |
| 2205 clipProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 2206 |
| 2207 auto contentsProperties = clipProperties->contentsProperties(); |
| 2208 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset); |
| 2209 EXPECT_EQ(framePreTranslation(), |
| 2210 contentsProperties.propertyTreeState.transform()); |
| 2202 EXPECT_EQ(clipProperties->cssClip(), | 2211 EXPECT_EQ(clipProperties->cssClip(), |
| 2203 clipProperties->localBorderBoxProperties() | 2212 contentsProperties.propertyTreeState.clip()); |
| 2204 ->geometryPropertyTreeState.clip); | |
| 2205 | |
| 2206 GeometryPropertyTreeState contentsTreeState; | |
| 2207 LayoutPoint paintOffsetFromContentsTreeState; | |
| 2208 clipProperties->getContentsPropertyTreeState( | |
| 2209 contentsTreeState, paintOffsetFromContentsTreeState); | |
| 2210 EXPECT_EQ(LayoutPoint(30, 20), paintOffsetFromContentsTreeState); | |
| 2211 EXPECT_EQ(framePreTranslation(), contentsTreeState.transform); | |
| 2212 EXPECT_EQ(clipProperties->cssClip(), contentsTreeState.clip); | |
| 2213 | 2213 |
| 2214 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 500), child, clipper); | 2214 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 500), child, clipper); |
| 2215 } | 2215 } |
| 2216 | 2216 |
| 2217 TEST_P(PaintPropertyTreeBuilderTest, | 2217 TEST_P(PaintPropertyTreeBuilderTest, |
| 2218 SvgLocalToBorderBoxTransformContentsTreeState) { | 2218 SvgLocalToBorderBoxTransformContentsTreeState) { |
| 2219 setBodyInnerHTML( | 2219 setBodyInnerHTML( |
| 2220 "<style>" | 2220 "<style>" |
| 2221 " body {" | 2221 " body {" |
| 2222 " margin: 20px 30px;" | 2222 " margin: 20px 30px;" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2233 " <rect id='rect' width='100px' height='100px' />" | 2233 " <rect id='rect' width='100px' height='100px' />" |
| 2234 "</svg>"); | 2234 "</svg>"); |
| 2235 | 2235 |
| 2236 LayoutObject& svgWithViewBox = | 2236 LayoutObject& svgWithViewBox = |
| 2237 *document().getElementById("svgWithViewBox")->layoutObject(); | 2237 *document().getElementById("svgWithViewBox")->layoutObject(); |
| 2238 const ObjectPaintProperties* svgWithViewBoxProperties = | 2238 const ObjectPaintProperties* svgWithViewBoxProperties = |
| 2239 svgWithViewBox.objectPaintProperties(); | 2239 svgWithViewBox.objectPaintProperties(); |
| 2240 | 2240 |
| 2241 EXPECT_EQ(framePreTranslation(), | 2241 EXPECT_EQ(framePreTranslation(), |
| 2242 svgWithViewBoxProperties->localBorderBoxProperties() | 2242 svgWithViewBoxProperties->localBorderBoxProperties() |
| 2243 ->geometryPropertyTreeState.transform); | 2243 ->propertyTreeState.transform()); |
| 2244 | 2244 |
| 2245 GeometryPropertyTreeState contentsTreeState; | 2245 auto contentsProperties = svgWithViewBoxProperties->contentsProperties(); |
| 2246 LayoutPoint paintOffsetFromContentsTreeState; | 2246 EXPECT_EQ(LayoutPoint(), contentsProperties.paintOffset); |
| 2247 svgWithViewBoxProperties->getContentsPropertyTreeState( | |
| 2248 contentsTreeState, paintOffsetFromContentsTreeState); | |
| 2249 EXPECT_EQ(LayoutPoint(), paintOffsetFromContentsTreeState); | |
| 2250 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), | 2247 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), |
| 2251 contentsTreeState.transform); | 2248 contentsProperties.propertyTreeState.transform()); |
| 2252 } | 2249 } |
| 2253 | 2250 |
| 2254 TEST_P(PaintPropertyTreeBuilderTest, OverflowHiddenScrollProperties) { | 2251 TEST_P(PaintPropertyTreeBuilderTest, OverflowHiddenScrollProperties) { |
| 2255 setBodyInnerHTML( | 2252 setBodyInnerHTML( |
| 2256 "<style>" | 2253 "<style>" |
| 2257 " body {" | 2254 " body {" |
| 2258 " margin: 0px;" | 2255 " margin: 0px;" |
| 2259 " }" | 2256 " }" |
| 2260 " #overflowHidden {" | 2257 " #overflowHidden {" |
| 2261 " overflow: hidden;" | 2258 " overflow: hidden;" |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2736 EXPECT_FALSE( | 2733 EXPECT_FALSE( |
| 2737 overflowB->layoutObject() | 2734 overflowB->layoutObject() |
| 2738 ->objectPaintProperties() | 2735 ->objectPaintProperties() |
| 2739 ->scroll() | 2736 ->scroll() |
| 2740 ->parent() | 2737 ->parent() |
| 2741 ->hasMainThreadScrollingReasons( | 2738 ->hasMainThreadScrollingReasons( |
| 2742 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2739 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2743 } | 2740 } |
| 2744 | 2741 |
| 2745 } // namespace blink | 2742 } // namespace blink |
| OLD | NEW |