Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp

Issue 2504573002: Don't call isURLAllowed() from layout. (Closed)
Patch Set: Fix bad formatting that caused clang-format-diff to get confused. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 absPos->layoutObject()->paintProperties(); 267 absPos->layoutObject()->paintProperties();
268 EXPECT_EQ(TransformationMatrix().translate(123, 456), 268 EXPECT_EQ(TransformationMatrix().translate(123, 456),
269 absPosProperties->paintOffsetTranslation()->matrix()); 269 absPosProperties->paintOffsetTranslation()->matrix());
270 EXPECT_EQ(frameScrollTranslation(), 270 EXPECT_EQ(frameScrollTranslation(),
271 absPosProperties->paintOffsetTranslation()->parent()); 271 absPosProperties->paintOffsetTranslation()->parent());
272 EXPECT_EQ(absPosProperties->transform(), 272 EXPECT_EQ(absPosProperties->transform(),
273 absPosProperties->overflowClip()->localTransformSpace()); 273 absPosProperties->overflowClip()->localTransformSpace());
274 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400), 274 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400),
275 absPosProperties->overflowClip()->clipRect()); 275 absPosProperties->overflowClip()->clipRect());
276 EXPECT_EQ(frameContentClip(), absPosProperties->overflowClip()->parent()); 276 EXPECT_EQ(frameContentClip(), absPosProperties->overflowClip()->parent());
277 CHECK_EXACT_VISUAL_RECT(LayoutRect(123, 456, 300, 400), 277 CHECK_EXACT_VISUAL_RECT(LayoutRect(123, 456, 300, 400),
278 absPos->layoutObject(), frameView->layoutView()); 278 absPos->layoutObject(), frameView->layoutView());
279 } 279 }
280 280
281 TEST_P(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) { 281 TEST_P(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) {
282 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); 282 setBodyInnerHTML("<style> body { height: 10000px; } </style>");
283 283
284 document().domWindow()->scrollTo(0, 100); 284 document().domWindow()->scrollTo(0, 100);
285 285
286 FrameView* frameView = document().view(); 286 FrameView* frameView = document().view();
287 frameView->updateAllLifecyclePhases(); 287 frameView->updateAllLifecyclePhases();
288 EXPECT_EQ(TransformationMatrix(), framePreTranslation()->matrix()); 288 EXPECT_EQ(TransformationMatrix(), framePreTranslation()->matrix());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), 341 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789),
342 transformProperties->transform()->matrix()); 342 transformProperties->transform()->matrix());
343 EXPECT_EQ(FloatPoint3D(200, 150, 0), 343 EXPECT_EQ(FloatPoint3D(200, 150, 0),
344 transformProperties->transform()->origin()); 344 transformProperties->transform()->origin());
345 EXPECT_EQ(transformProperties->paintOffsetTranslation(), 345 EXPECT_EQ(transformProperties->paintOffsetTranslation(),
346 transformProperties->transform()->parent()); 346 transformProperties->transform()->parent());
347 EXPECT_EQ(TransformationMatrix().translate(50, 100), 347 EXPECT_EQ(TransformationMatrix().translate(50, 100),
348 transformProperties->paintOffsetTranslation()->matrix()); 348 transformProperties->paintOffsetTranslation()->matrix());
349 EXPECT_EQ(frameScrollTranslation(), 349 EXPECT_EQ(frameScrollTranslation(),
350 transformProperties->paintOffsetTranslation()->parent()); 350 transformProperties->paintOffsetTranslation()->parent());
351 CHECK_EXACT_VISUAL_RECT(LayoutRect(173, 556, 400, 300), 351 CHECK_EXACT_VISUAL_RECT(LayoutRect(173, 556, 400, 300),
352 transform->layoutObject(), 352 transform->layoutObject(),
353 document().view()->layoutView()); 353 document().view()->layoutView());
354 } 354 }
355 355
356 TEST_P(PaintPropertyTreeBuilderTest, RelativePositionInline) { 356 TEST_P(PaintPropertyTreeBuilderTest, RelativePositionInline) {
357 loadTestData("relative-position-inline.html"); 357 loadTestData("relative-position-inline.html");
358 358
359 Element* inlineBlock = document().getElementById("inline-block"); 359 Element* inlineBlock = document().getElementById("inline-block");
360 const ObjectPaintProperties* inlineBlockProperties = 360 const ObjectPaintProperties* inlineBlockProperties =
361 inlineBlock->layoutObject()->paintProperties(); 361 inlineBlock->layoutObject()->paintProperties();
362 EXPECT_EQ(TransformationMatrix().translate(135, 490), 362 EXPECT_EQ(TransformationMatrix().translate(135, 490),
363 inlineBlockProperties->paintOffsetTranslation()->matrix()); 363 inlineBlockProperties->paintOffsetTranslation()->matrix());
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 EXPECT_EQ(frameContentClip(), borderRadiusClip->parent()); 955 EXPECT_EQ(frameContentClip(), borderRadiusClip->parent());
956 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 610, 500), &div, 956 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 610, 500), &div,
957 document().view()->layoutView()); 957 document().view()->layoutView());
958 } 958 }
959 959
960 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes) { 960 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes) {
961 setBodyInnerHTML( 961 setBodyInnerHTML(
962 "<style>body { margin: 0; }</style>" 962 "<style>body { margin: 0; }</style>"
963 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, " 963 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, "
964 "3px);'>" 964 "3px);'>"
965 " <iframe style='border: 7px solid black' id='frame'></iframe>" 965 " <iframe style='border: 7px solid black'></iframe>"
966 "</div>"); 966 "</div>");
967 Document& frameDocument = setupChildIframe( 967 setChildFrameHTML(
968 "frame",
969 "<style>body { margin: 0; }</style><div id='transform' style='transform: " 968 "<style>body { margin: 0; }</style><div id='transform' style='transform: "
970 "translate3d(4px, 5px, 6px); width: 100px; height: 200px'></div>"); 969 "translate3d(4px, 5px, 6px); width: 100px; height: 200px'></div>");
970
971 FrameView* frameView = document().view(); 971 FrameView* frameView = document().view();
972 frameView->updateAllLifecyclePhases(); 972 frameView->updateAllLifecyclePhases();
973 973
974 LayoutObject* divWithTransform = 974 LayoutObject* divWithTransform =
975 document().getElementById("divWithTransform")->layoutObject(); 975 document().getElementById("divWithTransform")->layoutObject();
976 const ObjectPaintProperties* divWithTransformProperties = 976 const ObjectPaintProperties* divWithTransformProperties =
977 divWithTransform->paintProperties(); 977 divWithTransform->paintProperties();
978 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), 978 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3),
979 divWithTransformProperties->transform()->matrix()); 979 divWithTransformProperties->transform()->matrix());
980 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 164), divWithTransform, 980 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 164), divWithTransform,
981 frameView->layoutView()); 981 frameView->layoutView());
982 982
983 LayoutObject* innerDivWithTransform = 983 LayoutObject* innerDivWithTransform =
984 frameDocument.getElementById("transform")->layoutObject(); 984 childDocument().getElementById("transform")->layoutObject();
985 const ObjectPaintProperties* innerDivWithTransformProperties = 985 const ObjectPaintProperties* innerDivWithTransformProperties =
986 innerDivWithTransform->paintProperties(); 986 innerDivWithTransform->paintProperties();
987 auto* innerDivTransform = innerDivWithTransformProperties->transform(); 987 auto* innerDivTransform = innerDivWithTransformProperties->transform();
988 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), 988 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6),
989 innerDivTransform->matrix()); 989 innerDivTransform->matrix());
990 CHECK_EXACT_VISUAL_RECT(LayoutRect(12, 14, 100, 145), innerDivWithTransform, 990 CHECK_EXACT_VISUAL_RECT(LayoutRect(12, 14, 100, 145), innerDivWithTransform,
991 frameView->layoutView()); 991 frameView->layoutView());
992 992
993 // Ensure that the inner div's transform is correctly rooted in the root 993 // Ensure that the inner div's transform is correctly rooted in the root
994 // frame's transform tree. 994 // frame's transform tree.
(...skipping 11 matching lines...) Expand all
1006 iframePreTranslation->matrix()); 1006 iframePreTranslation->matrix());
1007 EXPECT_EQ(divWithTransformProperties->transform(), 1007 EXPECT_EQ(divWithTransformProperties->transform(),
1008 iframePreTranslation->parent()); 1008 iframePreTranslation->parent());
1009 } 1009 }
1010 1010
1011 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesInTransformedSubframes) { 1011 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesInTransformedSubframes) {
1012 setBodyInnerHTML( 1012 setBodyInnerHTML(
1013 "<style>body { margin: 0; }</style>" 1013 "<style>body { margin: 0; }</style>"
1014 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, " 1014 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, "
1015 "3px);'>" 1015 "3px);'>"
1016 " <iframe id='frame' style='transform: translate3d(4px, 5px, 6px); " 1016 " <iframe style='transform: translate3d(4px, 5px, 6px); "
1017 "border: 42px solid; margin: 7px;'></iframe>" 1017 "border: 42px solid; margin: 7px;'></iframe>"
1018 "</div>"); 1018 "</div>");
1019 Document& frameDocument = 1019 setChildFrameHTML(
1020 setupChildIframe("frame", 1020 "<style>body { margin: 31px; }</style><div "
1021 "<style>body { margin: 31px; }</style><div " 1021 "id='transform' style='transform: translate3d(7px, 8px, "
1022 "id='transform' style='transform: translate3d(7px, 8px, " 1022 "9px); width: 100px; height: 200px'></div>");
1023 "9px); width: 100px; height: 200px'></div>");
1024 FrameView* frameView = document().view(); 1023 FrameView* frameView = document().view();
1025 frameView->updateAllLifecyclePhases(); 1024 frameView->updateAllLifecyclePhases();
1026 1025
1027 // Assert that we have the following tree structure: 1026 // Assert that we have the following tree structure:
1028 // ... 1027 // ...
1029 // Transform transform=translation=1.000000,2.000000,3.000000 1028 // Transform transform=translation=1.000000,2.000000,3.000000
1030 // PaintOffsetTranslation transform=translation=7.000000,7.000000,0.000000 1029 // PaintOffsetTranslation transform=translation=7.000000,7.000000,0.000000
1031 // Transform transform=translation=4.000000,5.000000,6.000000 1030 // Transform transform=translation=4.000000,5.000000,6.000000
1032 // PreTranslation transform=translation=42.000000,42.000000,0.000000 1031 // PreTranslation transform=translation=42.000000,42.000000,0.000000
1033 // ScrollTranslation transform=translation=0.000000,0.000000,0.00000 1032 // ScrollTranslation transform=translation=0.000000,0.000000,0.00000
1034 // PaintOffsetTranslation transform=translation=31.00,31.00,0.00 1033 // PaintOffsetTranslation transform=translation=31.00,31.00,0.00
1035 // Transform transform=translation=7.000000,8.000000,9.000000 1034 // Transform transform=translation=7.000000,8.000000,9.000000
1036 1035
1037 LayoutObject* innerDivWithTransform = 1036 LayoutObject* innerDivWithTransform =
1038 frameDocument.getElementById("transform")->layoutObject(); 1037 childDocument().getElementById("transform")->layoutObject();
1039 auto* innerDivTransform = 1038 auto* innerDivTransform =
1040 innerDivWithTransform->paintProperties()->transform(); 1039 innerDivWithTransform->paintProperties()->transform();
1041 EXPECT_EQ(TransformationMatrix().translate3d(7, 8, 9), 1040 EXPECT_EQ(TransformationMatrix().translate3d(7, 8, 9),
1042 innerDivTransform->matrix()); 1041 innerDivTransform->matrix());
1043 CHECK_EXACT_VISUAL_RECT(LayoutRect(92, 95, 100, 111), innerDivWithTransform, 1042 CHECK_EXACT_VISUAL_RECT(LayoutRect(92, 95, 100, 111), innerDivWithTransform,
1044 frameView->layoutView()); 1043 frameView->layoutView());
1045 1044
1046 auto* innerDocumentPaintOffsetTranslation = innerDivTransform->parent(); 1045 auto* innerDocumentPaintOffsetTranslation = innerDivTransform->parent();
1047 EXPECT_EQ(TransformationMatrix().translate3d(31, 31, 0), 1046 EXPECT_EQ(TransformationMatrix().translate3d(31, 31, 0),
1048 innerDocumentPaintOffsetTranslation->matrix()); 1047 innerDocumentPaintOffsetTranslation->matrix());
(...skipping 11 matching lines...) Expand all
1060 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), 1059 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0),
1061 iframePaintOffsetTranslation->matrix()); 1060 iframePaintOffsetTranslation->matrix());
1062 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); 1061 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent();
1063 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), 1062 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3),
1064 divWithTransformTransform->matrix()); 1063 divWithTransformTransform->matrix());
1065 1064
1066 LayoutObject* divWithTransform = 1065 LayoutObject* divWithTransform =
1067 document().getElementById("divWithTransform")->layoutObject(); 1066 document().getElementById("divWithTransform")->layoutObject();
1068 EXPECT_EQ(divWithTransformTransform, 1067 EXPECT_EQ(divWithTransformTransform,
1069 divWithTransform->paintProperties()->transform()); 1068 divWithTransform->paintProperties()->transform());
1070 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 248), divWithTransform, 1069 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 248), divWithTransform,
1071 frameView->layoutView()); 1070 frameView->layoutView());
1072 } 1071 }
1073 1072
1074 TEST_P(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) { 1073 TEST_P(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) {
1075 // This test verifies the tree builder correctly computes and records the 1074 // This test verifies the tree builder correctly computes and records the
1076 // property tree context for a (pseudo) stacking context that is scrolled by a 1075 // property tree context for a (pseudo) stacking context that is scrolled by a
1077 // containing block that is not one of the painting ancestors. 1076 // containing block that is not one of the painting ancestors.
1078 setBodyInnerHTML( 1077 setBodyInnerHTML(
1079 "<style>body { margin: 0; }</style>" 1078 "<style>body { margin: 0; }</style>"
1080 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>" 1079 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>"
1081 " <div id='child' style='position:relative; width:100px; height: " 1080 " <div id='child' style='position:relative; width:100px; height: "
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 1127
1129 EXPECT_EQ( 1128 EXPECT_EQ(
1130 frameContentClip(), 1129 frameContentClip(),
1131 childProperties->localBorderBoxProperties()->propertyTreeState.clip()); 1130 childProperties->localBorderBoxProperties()->propertyTreeState.clip());
1132 EXPECT_EQ(frameScrollTranslation(), 1131 EXPECT_EQ(frameScrollTranslation(),
1133 childProperties->localBorderBoxProperties() 1132 childProperties->localBorderBoxProperties()
1134 ->propertyTreeState.transform()); 1133 ->propertyTreeState.transform());
1135 EXPECT_EQ( 1134 EXPECT_EQ(
1136 scrollerProperties->effect(), 1135 scrollerProperties->effect(),
1137 childProperties->localBorderBoxProperties()->propertyTreeState.effect()); 1136 childProperties->localBorderBoxProperties()->propertyTreeState.effect());
1138 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 800, 10000), &scroller, 1137 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 800, 10000), &scroller,
1139 document().view()->layoutView()); 1138 document().view()->layoutView());
1140 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), &child, 1139 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), &child,
1141 document().view()->layoutView()); 1140 document().view()->layoutView());
1142 } 1141 }
1143 1142
1144 TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) { 1143 TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) {
1145 // This test verifies that the border box space of a table cell is being 1144 // This test verifies that the border box space of a table cell is being
1146 // correctly computed. Table cells have weird location adjustment in our 1145 // correctly computed. Table cells have weird location adjustment in our
1147 // layout/paint implementation. 1146 // layout/paint implementation.
1148 setBodyInnerHTML( 1147 setBodyInnerHTML(
1149 "<style>" 1148 "<style>"
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after
2920 EXPECT_EQ(framePreTranslation(), 2919 EXPECT_EQ(framePreTranslation(),
2921 childProperties->paintOffsetTranslation()->parent()); 2920 childProperties->paintOffsetTranslation()->parent());
2922 EXPECT_EQ(childProperties->paintOffsetTranslation(), 2921 EXPECT_EQ(childProperties->paintOffsetTranslation(),
2923 childPaintState.transform()); 2922 childPaintState.transform());
2924 // This will change once we added clip expansion node. 2923 // This will change once we added clip expansion node.
2925 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); 2924 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip());
2926 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); 2925 EXPECT_EQ(filterProperties->effect(), childPaintState.effect());
2927 } 2926 }
2928 2927
2929 } // namespace blink 2928 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698