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

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

Issue 2392443009: reflow comments in core/paint (Closed)
Patch Set: Created 4 years, 2 months 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 loadTestData("fixed-position.html"); 145 loadTestData("fixed-position.html");
146 146
147 Element* positionedScroll = document().getElementById("positionedScroll"); 147 Element* positionedScroll = document().getElementById("positionedScroll");
148 positionedScroll->setScrollTop(3); 148 positionedScroll->setScrollTop(3);
149 Element* transformedScroll = document().getElementById("transformedScroll"); 149 Element* transformedScroll = document().getElementById("transformedScroll");
150 transformedScroll->setScrollTop(5); 150 transformedScroll->setScrollTop(5);
151 151
152 FrameView* frameView = document().view(); 152 FrameView* frameView = document().view();
153 frameView->updateAllLifecyclePhases(); 153 frameView->updateAllLifecyclePhases();
154 154
155 // target1 is a fixed-position element inside an absolute-position scrolling e lement. 155 // target1 is a fixed-position element inside an absolute-position scrolling
156 // It should be attached under the viewport to skip scrolling and offset of th e parent. 156 // element. It should be attached under the viewport to skip scrolling and
157 // offset of the parent.
157 Element* target1 = document().getElementById("target1"); 158 Element* target1 = document().getElementById("target1");
158 const ObjectPaintProperties* target1Properties = 159 const ObjectPaintProperties* target1Properties =
159 target1->layoutObject()->objectPaintProperties(); 160 target1->layoutObject()->objectPaintProperties();
160 EXPECT_EQ(TransformationMatrix().translate(200, 150), 161 EXPECT_EQ(TransformationMatrix().translate(200, 150),
161 target1Properties->paintOffsetTranslation()->matrix()); 162 target1Properties->paintOffsetTranslation()->matrix());
162 EXPECT_EQ(framePreTranslation(), 163 EXPECT_EQ(framePreTranslation(),
163 target1Properties->paintOffsetTranslation()->parent()); 164 target1Properties->paintOffsetTranslation()->parent());
164 EXPECT_EQ(target1Properties->paintOffsetTranslation(), 165 EXPECT_EQ(target1Properties->paintOffsetTranslation(),
165 target1Properties->overflowClip()->localTransformSpace()); 166 target1Properties->overflowClip()->localTransformSpace());
166 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), 167 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100),
167 target1Properties->overflowClip()->clipRect()); 168 target1Properties->overflowClip()->clipRect());
168 // Likewise, it inherits clip from the viewport, skipping overflow clip of the scroller. 169 // Likewise, it inherits clip from the viewport, skipping overflow clip of the
170 // scroller.
169 EXPECT_EQ(frameContentClip(), target1Properties->overflowClip()->parent()); 171 EXPECT_EQ(frameContentClip(), target1Properties->overflowClip()->parent());
170 // target1 should not have it's own scroll node and instead should inherit pos itionedScroll's. 172 // target1 should not have it's own scroll node and instead should inherit
173 // positionedScroll's.
171 const ObjectPaintProperties* positionedScrollProperties = 174 const ObjectPaintProperties* positionedScrollProperties =
172 positionedScroll->layoutObject()->objectPaintProperties(); 175 positionedScroll->layoutObject()->objectPaintProperties();
173 EXPECT_TRUE(positionedScrollProperties->scroll()->parent()->isRoot()); 176 EXPECT_TRUE(positionedScrollProperties->scroll()->parent()->isRoot());
174 EXPECT_EQ(TransformationMatrix().translate(0, -3), 177 EXPECT_EQ(TransformationMatrix().translate(0, -3),
175 positionedScrollProperties->scroll() 178 positionedScrollProperties->scroll()
176 ->scrollOffsetTranslation() 179 ->scrollOffsetTranslation()
177 ->matrix()); 180 ->matrix());
178 EXPECT_EQ(nullptr, target1Properties->scroll()); 181 EXPECT_EQ(nullptr, target1Properties->scroll());
179 182
180 CHECK_EXACT_VISUAL_RECT(LayoutRect(200, 150, 100, 100), 183 CHECK_EXACT_VISUAL_RECT(LayoutRect(200, 150, 100, 100),
(...skipping 10 matching lines...) Expand all
191 EXPECT_EQ(TransformationMatrix().translate(200, 150), 194 EXPECT_EQ(TransformationMatrix().translate(200, 150),
192 target2Properties->paintOffsetTranslation()->matrix()); 195 target2Properties->paintOffsetTranslation()->matrix());
193 EXPECT_EQ(scrollerProperties->scrollTranslation(), 196 EXPECT_EQ(scrollerProperties->scrollTranslation(),
194 target2Properties->paintOffsetTranslation()->parent()); 197 target2Properties->paintOffsetTranslation()->parent());
195 EXPECT_EQ(target2Properties->paintOffsetTranslation(), 198 EXPECT_EQ(target2Properties->paintOffsetTranslation(),
196 target2Properties->overflowClip()->localTransformSpace()); 199 target2Properties->overflowClip()->localTransformSpace());
197 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), 200 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100),
198 target2Properties->overflowClip()->clipRect()); 201 target2Properties->overflowClip()->clipRect());
199 EXPECT_EQ(scrollerProperties->overflowClip(), 202 EXPECT_EQ(scrollerProperties->overflowClip(),
200 target2Properties->overflowClip()->parent()); 203 target2Properties->overflowClip()->parent());
201 // target2 should not have it's own scroll node and instead should inherit tra nsformedScroll's. 204 // target2 should not have it's own scroll node and instead should inherit
205 // transformedScroll's.
202 const ObjectPaintProperties* transformedScrollProperties = 206 const ObjectPaintProperties* transformedScrollProperties =
203 transformedScroll->layoutObject()->objectPaintProperties(); 207 transformedScroll->layoutObject()->objectPaintProperties();
204 EXPECT_TRUE(transformedScrollProperties->scroll()->parent()->isRoot()); 208 EXPECT_TRUE(transformedScrollProperties->scroll()->parent()->isRoot());
205 EXPECT_EQ(TransformationMatrix().translate(0, -5), 209 EXPECT_EQ(TransformationMatrix().translate(0, -5),
206 transformedScrollProperties->scroll() 210 transformedScrollProperties->scroll()
207 ->scrollOffsetTranslation() 211 ->scrollOffsetTranslation()
208 ->matrix()); 212 ->matrix());
209 EXPECT_EQ(nullptr, target2Properties->scroll()); 213 EXPECT_EQ(nullptr, target2Properties->scroll());
210 214
211 CHECK_EXACT_VISUAL_RECT(LayoutRect(208, 153, 200, 100), 215 CHECK_EXACT_VISUAL_RECT(LayoutRect(208, 153, 200, 100),
(...skipping 22 matching lines...) Expand all
234 EXPECT_TRUE(scrollerProperties->scroll()->userScrollableVertical()); 238 EXPECT_TRUE(scrollerProperties->scroll()->userScrollableVertical());
235 EXPECT_EQ(FloatRoundedRect(120, 340, 413, 317), 239 EXPECT_EQ(FloatRoundedRect(120, 340, 413, 317),
236 scrollerProperties->overflowClip()->clipRect()); 240 scrollerProperties->overflowClip()->clipRect());
237 EXPECT_EQ(frameContentClip(), scrollerProperties->overflowClip()->parent()); 241 EXPECT_EQ(frameContentClip(), scrollerProperties->overflowClip()->parent());
238 // http://crbug.com/638415 242 // http://crbug.com/638415
239 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 243 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
240 CHECK_EXACT_VISUAL_RECT(LayoutRect(120, 340, 413, 317), 244 CHECK_EXACT_VISUAL_RECT(LayoutRect(120, 340, 413, 317),
241 scroller->layoutObject(), frameView->layoutView()); 245 scroller->layoutObject(), frameView->layoutView());
242 } 246 }
243 247
244 // The relative-positioned element should have accumulated box offset (exclude scrolling), 248 // The relative-positioned element should have accumulated box offset (exclude
245 // and should be affected by ancestor scroll transforms. 249 // scrolling), and should be affected by ancestor scroll transforms.
246 Element* relPos = document().getElementById("rel-pos"); 250 Element* relPos = document().getElementById("rel-pos");
247 const ObjectPaintProperties* relPosProperties = 251 const ObjectPaintProperties* relPosProperties =
248 relPos->layoutObject()->objectPaintProperties(); 252 relPos->layoutObject()->objectPaintProperties();
249 EXPECT_EQ(TransformationMatrix().translate(680, 1120), 253 EXPECT_EQ(TransformationMatrix().translate(680, 1120),
250 relPosProperties->paintOffsetTranslation()->matrix()); 254 relPosProperties->paintOffsetTranslation()->matrix());
251 EXPECT_EQ(scrollerProperties->scrollTranslation(), 255 EXPECT_EQ(scrollerProperties->scrollTranslation(),
252 relPosProperties->paintOffsetTranslation()->parent()); 256 relPosProperties->paintOffsetTranslation()->parent());
253 EXPECT_EQ(relPosProperties->transform(), 257 EXPECT_EQ(relPosProperties->transform(),
254 relPosProperties->overflowClip()->localTransformSpace()); 258 relPosProperties->overflowClip()->localTransformSpace());
255 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 200), 259 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 200),
256 relPosProperties->overflowClip()->clipRect()); 260 relPosProperties->overflowClip()->clipRect());
257 EXPECT_EQ(scrollerProperties->overflowClip(), 261 EXPECT_EQ(scrollerProperties->overflowClip(),
258 relPosProperties->overflowClip()->parent()); 262 relPosProperties->overflowClip()->parent());
259 CHECK_EXACT_VISUAL_RECT(LayoutRect(), relPos->layoutObject(), 263 CHECK_EXACT_VISUAL_RECT(LayoutRect(), relPos->layoutObject(),
260 frameView->layoutView()); 264 frameView->layoutView());
261 265
262 // The absolute-positioned element should not be affected by non-positioned sc roller at all. 266 // The absolute-positioned element should not be affected by non-positioned
267 // scroller at all.
263 Element* absPos = document().getElementById("abs-pos"); 268 Element* absPos = document().getElementById("abs-pos");
264 const ObjectPaintProperties* absPosProperties = 269 const ObjectPaintProperties* absPosProperties =
265 absPos->layoutObject()->objectPaintProperties(); 270 absPos->layoutObject()->objectPaintProperties();
266 EXPECT_EQ(TransformationMatrix().translate(123, 456), 271 EXPECT_EQ(TransformationMatrix().translate(123, 456),
267 absPosProperties->paintOffsetTranslation()->matrix()); 272 absPosProperties->paintOffsetTranslation()->matrix());
268 EXPECT_EQ(frameScrollTranslation(), 273 EXPECT_EQ(frameScrollTranslation(),
269 absPosProperties->paintOffsetTranslation()->parent()); 274 absPosProperties->paintOffsetTranslation()->parent());
270 EXPECT_EQ(absPosProperties->transform(), 275 EXPECT_EQ(absPosProperties->transform(),
271 absPosProperties->overflowClip()->localTransformSpace()); 276 absPosProperties->overflowClip()->localTransformSpace());
272 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400), 277 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 } 314 }
310 315
311 TEST_P(PaintPropertyTreeBuilderTest, Perspective) { 316 TEST_P(PaintPropertyTreeBuilderTest, Perspective) {
312 loadTestData("perspective.html"); 317 loadTestData("perspective.html");
313 318
314 Element* perspective = document().getElementById("perspective"); 319 Element* perspective = document().getElementById("perspective");
315 const ObjectPaintProperties* perspectiveProperties = 320 const ObjectPaintProperties* perspectiveProperties =
316 perspective->layoutObject()->objectPaintProperties(); 321 perspective->layoutObject()->objectPaintProperties();
317 EXPECT_EQ(TransformationMatrix().applyPerspective(100), 322 EXPECT_EQ(TransformationMatrix().applyPerspective(100),
318 perspectiveProperties->perspective()->matrix()); 323 perspectiveProperties->perspective()->matrix());
319 // The perspective origin is the center of the border box plus accumulated pai nt offset. 324 // The perspective origin is the center of the border box plus accumulated
325 // paint offset.
320 EXPECT_EQ(FloatPoint3D(250, 250, 0), 326 EXPECT_EQ(FloatPoint3D(250, 250, 0),
321 perspectiveProperties->perspective()->origin()); 327 perspectiveProperties->perspective()->origin());
322 EXPECT_EQ(framePreTranslation(), 328 EXPECT_EQ(framePreTranslation(),
323 perspectiveProperties->perspective()->parent()); 329 perspectiveProperties->perspective()->parent());
324 330
325 // Adding perspective doesn't clear paint offset. The paint offset will be pas sed down to children. 331 // Adding perspective doesn't clear paint offset. The paint offset will be
332 // passed down to children.
326 Element* inner = document().getElementById("inner"); 333 Element* inner = document().getElementById("inner");
327 const ObjectPaintProperties* innerProperties = 334 const ObjectPaintProperties* innerProperties =
328 inner->layoutObject()->objectPaintProperties(); 335 inner->layoutObject()->objectPaintProperties();
329 EXPECT_EQ(TransformationMatrix().translate(50, 100), 336 EXPECT_EQ(TransformationMatrix().translate(50, 100),
330 innerProperties->paintOffsetTranslation()->matrix()); 337 innerProperties->paintOffsetTranslation()->matrix());
331 EXPECT_EQ(perspectiveProperties->perspective(), 338 EXPECT_EQ(perspectiveProperties->perspective(),
332 innerProperties->paintOffsetTranslation()->parent()); 339 innerProperties->paintOffsetTranslation()->parent());
333 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 100, 200), inner->layoutObject(), 340 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 100, 200), inner->layoutObject(),
334 document().view()->layoutView()); 341 document().view()->layoutView());
335 } 342 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 EXPECT_EQ(nullptr, rectWithoutOpacityProperties); 539 EXPECT_EQ(nullptr, rectWithoutOpacityProperties);
533 540
534 LayoutObject& rectWithOpacity = 541 LayoutObject& rectWithOpacity =
535 *document().getElementById("rectWithOpacity")->layoutObject(); 542 *document().getElementById("rectWithOpacity")->layoutObject();
536 const ObjectPaintProperties* rectWithOpacityProperties = 543 const ObjectPaintProperties* rectWithOpacityProperties =
537 rectWithOpacity.objectPaintProperties(); 544 rectWithOpacity.objectPaintProperties();
538 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity()); 545 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity());
539 EXPECT_EQ(groupWithOpacityProperties->effect(), 546 EXPECT_EQ(groupWithOpacityProperties->effect(),
540 rectWithOpacityProperties->effect()->parent()); 547 rectWithOpacityProperties->effect()->parent());
541 548
542 // Ensure that opacity nodes are created for LayoutSVGText which inherits from LayoutSVGBlock instead of LayoutSVGModelObject. 549 // Ensure that opacity nodes are created for LayoutSVGText which inherits from
550 // LayoutSVGBlock instead of LayoutSVGModelObject.
543 LayoutObject& textWithOpacity = 551 LayoutObject& textWithOpacity =
544 *document().getElementById("textWithOpacity")->layoutObject(); 552 *document().getElementById("textWithOpacity")->layoutObject();
545 const ObjectPaintProperties* textWithOpacityProperties = 553 const ObjectPaintProperties* textWithOpacityProperties =
546 textWithOpacity.objectPaintProperties(); 554 textWithOpacity.objectPaintProperties();
547 EXPECT_EQ(0.2f, textWithOpacityProperties->effect()->opacity()); 555 EXPECT_EQ(0.2f, textWithOpacityProperties->effect()->opacity());
548 EXPECT_EQ(groupWithOpacityProperties->effect(), 556 EXPECT_EQ(groupWithOpacityProperties->effect(),
549 textWithOpacityProperties->effect()->parent()); 557 textWithOpacityProperties->effect()->parent());
550 558
551 // Ensure that opacity nodes are created for LayoutSVGTSpan which inherits fro m LayoutSVGInline instead of LayoutSVGModelObject. 559 // Ensure that opacity nodes are created for LayoutSVGTSpan which inherits
560 // from LayoutSVGInline instead of LayoutSVGModelObject.
552 LayoutObject& tspanWithOpacity = 561 LayoutObject& tspanWithOpacity =
553 *document().getElementById("tspanWithOpacity")->layoutObject(); 562 *document().getElementById("tspanWithOpacity")->layoutObject();
554 const ObjectPaintProperties* tspanWithOpacityProperties = 563 const ObjectPaintProperties* tspanWithOpacityProperties =
555 tspanWithOpacity.objectPaintProperties(); 564 tspanWithOpacity.objectPaintProperties();
556 EXPECT_EQ(0.1f, tspanWithOpacityProperties->effect()->opacity()); 565 EXPECT_EQ(0.1f, tspanWithOpacityProperties->effect()->opacity());
557 EXPECT_EQ(textWithOpacityProperties->effect(), 566 EXPECT_EQ(textWithOpacityProperties->effect(),
558 tspanWithOpacityProperties->effect()->parent()); 567 tspanWithOpacityProperties->effect()->parent());
559 } 568 }
560 569
561 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossHTMLSVGBoundary) { 570 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossHTMLSVGBoundary) {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 svgProperties->paintOffsetTranslation()->matrix()); 759 svgProperties->paintOffsetTranslation()->matrix());
751 EXPECT_EQ(TransformationMatrix().translate(5, 7), 760 EXPECT_EQ(TransformationMatrix().translate(5, 7),
752 svgProperties->transform()->matrix()); 761 svgProperties->transform()->matrix());
753 EXPECT_EQ(TransformationMatrix().translate(11, 11).scale(100.0 / 13.0), 762 EXPECT_EQ(TransformationMatrix().translate(11, 11).scale(100.0 / 13.0),
754 svgProperties->svgLocalToBorderBoxTransform()->matrix()); 763 svgProperties->svgLocalToBorderBoxTransform()->matrix());
755 EXPECT_EQ(svgProperties->paintOffsetTranslation(), 764 EXPECT_EQ(svgProperties->paintOffsetTranslation(),
756 svgProperties->transform()->parent()); 765 svgProperties->transform()->parent());
757 EXPECT_EQ(svgProperties->transform(), 766 EXPECT_EQ(svgProperties->transform(),
758 svgProperties->svgLocalToBorderBoxTransform()->parent()); 767 svgProperties->svgLocalToBorderBoxTransform()->parent());
759 768
760 // Ensure the rect's transform is a child of the local to border box transform . 769 // Ensure the rect's transform is a child of the local to border box
770 // transform.
761 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); 771 LayoutObject& rect = *document().getElementById("rect")->layoutObject();
762 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); 772 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties();
763 EXPECT_EQ(TransformationMatrix().translate(17, 19), 773 EXPECT_EQ(TransformationMatrix().translate(17, 19),
764 rectProperties->transform()->matrix()); 774 rectProperties->transform()->matrix());
765 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), 775 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(),
766 rectProperties->transform()->parent()); 776 rectProperties->transform()->parent());
767 } 777 }
768 778
769 TEST_P(PaintPropertyTreeBuilderTest, SVGNestedViewboxTransforms) { 779 TEST_P(PaintPropertyTreeBuilderTest, SVGNestedViewboxTransforms) {
770 setBodyInnerHTML( 780 setBodyInnerHTML(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 EXPECT_EQ(TransformationMatrix().translate(20, 30), 869 EXPECT_EQ(TransformationMatrix().translate(20, 30),
860 containerProperties->transform()->matrix()); 870 containerProperties->transform()->matrix());
861 EXPECT_EQ(svgProperties->transform(), 871 EXPECT_EQ(svgProperties->transform(),
862 containerProperties->transform()->parent()); 872 containerProperties->transform()->parent());
863 873
864 Element* fixed = document().getElementById("fixed"); 874 Element* fixed = document().getElementById("fixed");
865 const ObjectPaintProperties* fixedProperties = 875 const ObjectPaintProperties* fixedProperties =
866 fixed->layoutObject()->objectPaintProperties(); 876 fixed->layoutObject()->objectPaintProperties();
867 EXPECT_EQ(TransformationMatrix().translate(200, 150), 877 EXPECT_EQ(TransformationMatrix().translate(200, 150),
868 fixedProperties->paintOffsetTranslation()->matrix()); 878 fixedProperties->paintOffsetTranslation()->matrix());
869 // Ensure the fixed position element is rooted at the nearest transform contai ner. 879 // Ensure the fixed position element is rooted at the nearest transform
880 // container.
870 EXPECT_EQ(containerProperties->transform(), 881 EXPECT_EQ(containerProperties->transform(),
871 fixedProperties->paintOffsetTranslation()->parent()); 882 fixedProperties->paintOffsetTranslation()->parent());
872 } 883 }
873 884
874 TEST_P(PaintPropertyTreeBuilderTest, ControlClip) { 885 TEST_P(PaintPropertyTreeBuilderTest, ControlClip) {
875 setBodyInnerHTML( 886 setBodyInnerHTML(
876 "<style>" 887 "<style>"
877 " body {" 888 " body {"
878 " margin: 0;" 889 " margin: 0;"
879 " }" 890 " }"
880 " input {" 891 " input {"
881 " border-width: 5px;" 892 " border-width: 5px;"
882 " padding: 0;" 893 " padding: 0;"
883 " }" 894 " }"
884 "</style>" 895 "</style>"
885 "<input id='button' type='button' style='width:345px; height:123px' " 896 "<input id='button' type='button' style='width:345px; height:123px' "
886 "value='some text'/>"); 897 "value='some text'/>");
887 898
888 LayoutObject& button = *document().getElementById("button")->layoutObject(); 899 LayoutObject& button = *document().getElementById("button")->layoutObject();
889 const ObjectPaintProperties* buttonProperties = 900 const ObjectPaintProperties* buttonProperties =
890 button.objectPaintProperties(); 901 button.objectPaintProperties();
891 // No scroll translation because the document does not scroll (not enough cont ent). 902 // No scroll translation because the document does not scroll (not enough
903 // content).
892 EXPECT_TRUE(!frameScrollTranslation()); 904 EXPECT_TRUE(!frameScrollTranslation());
893 EXPECT_EQ(framePreTranslation(), 905 EXPECT_EQ(framePreTranslation(),
894 buttonProperties->overflowClip()->localTransformSpace()); 906 buttonProperties->overflowClip()->localTransformSpace());
895 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), 907 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113),
896 buttonProperties->overflowClip()->clipRect()); 908 buttonProperties->overflowClip()->clipRect());
897 EXPECT_EQ(frameContentClip(), buttonProperties->overflowClip()->parent()); 909 EXPECT_EQ(frameContentClip(), buttonProperties->overflowClip()->parent());
898 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 345, 123), &button, 910 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 345, 123), &button,
899 document().view()->layoutView()); 911 document().view()->layoutView());
900 } 912 }
901 913
(...skipping 11 matching lines...) Expand all
913 " border-left: 60px solid;" 925 " border-left: 60px solid;"
914 " width: 500px;" 926 " width: 500px;"
915 " height: 400px;" 927 " height: 400px;"
916 " overflow: scroll;" 928 " overflow: scroll;"
917 " }" 929 " }"
918 "</style>" 930 "</style>"
919 "<div id='div'></div>"); 931 "<div id='div'></div>");
920 932
921 LayoutObject& div = *document().getElementById("div")->layoutObject(); 933 LayoutObject& div = *document().getElementById("div")->layoutObject();
922 const ObjectPaintProperties* divProperties = div.objectPaintProperties(); 934 const ObjectPaintProperties* divProperties = div.objectPaintProperties();
923 // No scroll translation because the document does not scroll (not enough cont ent). 935 // No scroll translation because the document does not scroll (not enough
936 // content).
924 EXPECT_TRUE(!frameScrollTranslation()); 937 EXPECT_TRUE(!frameScrollTranslation());
925 EXPECT_EQ(framePreTranslation(), 938 EXPECT_EQ(framePreTranslation(),
926 divProperties->overflowClip()->localTransformSpace()); 939 divProperties->overflowClip()->localTransformSpace());
927 // The overflow clip rect includes only the padding box. 940 // The overflow clip rect includes only the padding box.
928 // padding box = border box(500+60+50, 400+45+55) - border outset(60+50, 45+55 ) - scrollbars(15, 15) 941 // padding box = border box(500+60+50, 400+45+55) - border outset(60+50,
942 // 45+55) - scrollbars(15, 15)
929 EXPECT_EQ(FloatRoundedRect(60, 45, 500, 400), 943 EXPECT_EQ(FloatRoundedRect(60, 45, 500, 400),
930 divProperties->overflowClip()->clipRect()); 944 divProperties->overflowClip()->clipRect());
931 const ClipPaintPropertyNode* borderRadiusClip = 945 const ClipPaintPropertyNode* borderRadiusClip =
932 divProperties->overflowClip()->parent(); 946 divProperties->overflowClip()->parent();
933 EXPECT_EQ(framePreTranslation(), borderRadiusClip->localTransformSpace()); 947 EXPECT_EQ(framePreTranslation(), borderRadiusClip->localTransformSpace());
934 // The border radius clip is the area enclosed by inner border edge, including the scrollbars. 948 // The border radius clip is the area enclosed by inner border edge, including
935 // As the border-radius is specified in outer radius, the inner radius is calc ulated by: 949 // the scrollbars. As the border-radius is specified in outer radius, the
950 // inner radius is calculated by:
936 // inner radius = max(outer radius - border width, 0) 951 // inner radius = max(outer radius - border width, 0)
937 // In the case that two adjacent borders have different width, the inner radiu s of the corner 952 // In the case that two adjacent borders have different width, the inner
938 // may transition from one value to the other. i.e. being an ellipse. 953 // radius of the corner may transition from one value to the other. i.e. being
954 // an ellipse.
939 EXPECT_EQ( 955 EXPECT_EQ(
940 FloatRoundedRect( 956 FloatRoundedRect(
941 FloatRect(60, 45, 500, 957 FloatRect(60, 45, 500,
942 400), // = border box(610, 500) - border outset(110, 100) 958 400), // = border box(610, 500) - border outset(110, 100)
943 FloatSize(0, 959 FloatSize(0,
944 0), // (top left) = max((12, 12) - (60, 45), (0, 0)) 960 0), // (top left) = max((12, 12) - (60, 45), (0, 0))
945 FloatSize(0, 961 FloatSize(0,
946 0), // (top right) = max((34, 34) - (50, 45), (0, 0)) 962 0), // (top right) = max((34, 34) - (50, 45), (0, 0))
947 FloatSize(18, 963 FloatSize(18,
948 23), // (bottom left) = max((78, 78) - (60, 55), (0, 0)) 964 23), // (bottom left) = max((78, 78) - (60, 55), (0, 0))
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 LayoutObject* innerDivWithTransform = 999 LayoutObject* innerDivWithTransform =
984 frameDocument.getElementById("transform")->layoutObject(); 1000 frameDocument.getElementById("transform")->layoutObject();
985 const ObjectPaintProperties* innerDivWithTransformProperties = 1001 const ObjectPaintProperties* innerDivWithTransformProperties =
986 innerDivWithTransform->objectPaintProperties(); 1002 innerDivWithTransform->objectPaintProperties();
987 auto* innerDivTransform = innerDivWithTransformProperties->transform(); 1003 auto* innerDivTransform = innerDivWithTransformProperties->transform();
988 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), 1004 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6),
989 innerDivTransform->matrix()); 1005 innerDivTransform->matrix());
990 CHECK_EXACT_VISUAL_RECT(LayoutRect(12, 14, 100, 145), innerDivWithTransform, 1006 CHECK_EXACT_VISUAL_RECT(LayoutRect(12, 14, 100, 145), innerDivWithTransform,
991 frameView->layoutView()); 1007 frameView->layoutView());
992 1008
993 // Ensure that the inner div's transform is correctly rooted in the root frame 's transform tree. 1009 // Ensure that the inner div's transform is correctly rooted in the root
1010 // frame's transform tree.
994 // This asserts that we have the following tree structure: 1011 // This asserts that we have the following tree structure:
995 // ... 1012 // ...
996 // Transform transform=translation=1.000000,2.000000,3.000000 1013 // Transform transform=translation=1.000000,2.000000,3.000000
997 // PreTranslation transform=translation=7.000000,7.000000,0.000000 1014 // PreTranslation transform=translation=7.000000,7.000000,0.000000
998 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000 1015 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000
999 // Transform transform=translation=4.000000,5.000000,6.000000 1016 // Transform transform=translation=4.000000,5.000000,6.000000
1000 auto* innerDocumentScrollTranslation = innerDivTransform->parent(); 1017 auto* innerDocumentScrollTranslation = innerDivTransform->parent();
1001 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), 1018 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0),
1002 innerDocumentScrollTranslation->matrix()); 1019 innerDocumentScrollTranslation->matrix());
1003 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); 1020 auto* iframePreTranslation = innerDocumentScrollTranslation->parent();
(...skipping 18 matching lines...) Expand all
1022 "9px); width: 100px; height: 200px'></div>"); 1039 "9px); width: 100px; height: 200px'></div>");
1023 FrameView* frameView = document().view(); 1040 FrameView* frameView = document().view();
1024 frameView->updateAllLifecyclePhases(); 1041 frameView->updateAllLifecyclePhases();
1025 1042
1026 // Assert that we have the following tree structure: 1043 // Assert that we have the following tree structure:
1027 // ... 1044 // ...
1028 // Transform transform=translation=1.000000,2.000000,3.000000 1045 // Transform transform=translation=1.000000,2.000000,3.000000
1029 // PaintOffsetTranslation transform=translation=7.000000,7.000000,0.000000 1046 // PaintOffsetTranslation transform=translation=7.000000,7.000000,0.000000
1030 // Transform transform=translation=4.000000,5.000000,6.000000 1047 // Transform transform=translation=4.000000,5.000000,6.000000
1031 // PreTranslation transform=translation=42.000000,42.000000,0.000000 1048 // PreTranslation transform=translation=42.000000,42.000000,0.000000
1032 // ScrollTranslation transform=translation=0.000000,0.000000,0.00000 0 1049 // ScrollTranslation transform=translation=0.000000,0.000000,0.00000
1033 // PaintOffsetTranslation transform=translation=31.000000,31.00000 0,0.000000 1050 // PaintOffsetTranslation transform=translation=31.00,31.00,0.00
1034 // Transform transform=translation=7.000000,8.000000,9.000000 1051 // Transform transform=translation=7.000000,8.000000,9.000000
1035 1052
1036 LayoutObject* innerDivWithTransform = 1053 LayoutObject* innerDivWithTransform =
1037 frameDocument.getElementById("transform")->layoutObject(); 1054 frameDocument.getElementById("transform")->layoutObject();
1038 auto* innerDivTransform = 1055 auto* innerDivTransform =
1039 innerDivWithTransform->objectPaintProperties()->transform(); 1056 innerDivWithTransform->objectPaintProperties()->transform();
1040 EXPECT_EQ(TransformationMatrix().translate3d(7, 8, 9), 1057 EXPECT_EQ(TransformationMatrix().translate3d(7, 8, 9),
1041 innerDivTransform->matrix()); 1058 innerDivTransform->matrix());
1042 CHECK_EXACT_VISUAL_RECT(LayoutRect(92, 95, 100, 111), innerDivWithTransform, 1059 CHECK_EXACT_VISUAL_RECT(LayoutRect(92, 95, 100, 111), innerDivWithTransform,
1043 frameView->layoutView()); 1060 frameView->layoutView());
(...skipping 23 matching lines...) Expand all
1067 EXPECT_EQ(divWithTransformTransform, 1084 EXPECT_EQ(divWithTransformTransform,
1068 divWithTransform->objectPaintProperties()->transform()); 1085 divWithTransform->objectPaintProperties()->transform());
1069 // http://crbug.com/638415 1086 // http://crbug.com/638415
1070 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 1087 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
1071 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 248), divWithTransform, 1088 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 248), divWithTransform,
1072 frameView->layoutView()); 1089 frameView->layoutView());
1073 } 1090 }
1074 } 1091 }
1075 1092
1076 TEST_P(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) { 1093 TEST_P(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) {
1077 // This test verifies the tree builder correctly computes and records the prop erty tree context 1094 // This test verifies the tree builder correctly computes and records the
1078 // for a (pseudo) stacking context that is scrolled by a containing block that is not one of 1095 // property tree context for a (pseudo) stacking context that is scrolled by a
1079 // the painting ancestors. 1096 // containing block that is not one of the painting ancestors.
1080 setBodyInnerHTML( 1097 setBodyInnerHTML(
1081 "<style>body { margin: 0; }</style>" 1098 "<style>body { margin: 0; }</style>"
1082 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>" 1099 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>"
1083 " <div id='child' style='position:relative; width:100px; height: " 1100 " <div id='child' style='position:relative; width:100px; height: "
1084 "200px;'></div>" 1101 "200px;'></div>"
1085 " <div style='height:10000px;'></div>" 1102 " <div style='height:10000px;'></div>"
1086 "</div>"); 1103 "</div>");
1087 FrameView* frameView = document().view(); 1104 FrameView* frameView = document().view();
1088 1105
1089 LayoutObject* scroller = 1106 LayoutObject* scroller =
(...skipping 13 matching lines...) Expand all
1103 nullptr, 1120 nullptr,
1104 childProperties->localBorderBoxProperties()->propertyTreeState.effect()); 1121 childProperties->localBorderBoxProperties()->propertyTreeState.effect());
1105 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 300), scroller, 1122 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 300), scroller,
1106 frameView->layoutView()); 1123 frameView->layoutView());
1107 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), child, 1124 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), child,
1108 frameView->layoutView()); 1125 frameView->layoutView());
1109 } 1126 }
1110 1127
1111 TEST_P(PaintPropertyTreeBuilderTest, 1128 TEST_P(PaintPropertyTreeBuilderTest,
1112 TreeContextUnclipFromParentStackingContext) { 1129 TreeContextUnclipFromParentStackingContext) {
1113 // This test verifies the tree builder correctly computes and records the prop erty tree context 1130 // This test verifies the tree builder correctly computes and records the
1114 // for a (pseudo) stacking context that has a scrolling painting ancestor that is not its 1131 // property tree context for a (pseudo) stacking context that has a scrolling
1115 // containing block (thus should not be scrolled by it). 1132 // painting ancestor that is not its containing block (thus should not be
1133 // scrolled by it).
1116 1134
1117 setBodyInnerHTML( 1135 setBodyInnerHTML(
1118 "<style>body { margin: 0; }</style>" 1136 "<style>body { margin: 0; }</style>"
1119 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" 1137 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>"
1120 " <div id='child' style='position:absolute; left:0; top:0; width: " 1138 " <div id='child' style='position:absolute; left:0; top:0; width: "
1121 "100px; height: 200px'></div>" 1139 "100px; height: 200px'></div>"
1122 " <div style='height:10000px;'></div>" 1140 " <div style='height:10000px;'></div>"
1123 "</div>"); 1141 "</div>");
1124 1142
1125 LayoutObject& scroller = 1143 LayoutObject& scroller =
(...skipping 14 matching lines...) Expand all
1140 childProperties->localBorderBoxProperties()->propertyTreeState.effect()); 1158 childProperties->localBorderBoxProperties()->propertyTreeState.effect());
1141 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 1159 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
1142 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 800, 10000), &scroller, 1160 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 800, 10000), &scroller,
1143 document().view()->layoutView()); 1161 document().view()->layoutView());
1144 } 1162 }
1145 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), &child, 1163 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), &child,
1146 document().view()->layoutView()); 1164 document().view()->layoutView());
1147 } 1165 }
1148 1166
1149 TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) { 1167 TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) {
1150 // This test verifies that the border box space of a table cell is being corre ctly computed. 1168 // This test verifies that the border box space of a table cell is being
1151 // Table cells have weird location adjustment in our layout/paint implementati on. 1169 // correctly computed. Table cells have weird location adjustment in our
1170 // layout/paint implementation.
1152 setBodyInnerHTML( 1171 setBodyInnerHTML(
1153 "<style>" 1172 "<style>"
1154 " body {" 1173 " body {"
1155 " margin: 0;" 1174 " margin: 0;"
1156 " }" 1175 " }"
1157 " table {" 1176 " table {"
1158 " border-spacing: 0;" 1177 " border-spacing: 0;"
1159 " margin: 20px;" 1178 " margin: 20px;"
1160 " padding: 40px;" 1179 " padding: 40px;"
1161 " border: 10px solid black;" 1180 " border: 10px solid black;"
(...skipping 20 matching lines...) Expand all
1182 1201
1183 EXPECT_EQ(LayoutPoint(170, 170), 1202 EXPECT_EQ(LayoutPoint(170, 170),
1184 targetProperties->localBorderBoxProperties()->paintOffset); 1203 targetProperties->localBorderBoxProperties()->paintOffset);
1185 EXPECT_EQ(framePreTranslation(), targetProperties->localBorderBoxProperties() 1204 EXPECT_EQ(framePreTranslation(), targetProperties->localBorderBoxProperties()
1186 ->propertyTreeState.transform()); 1205 ->propertyTreeState.transform());
1187 CHECK_EXACT_VISUAL_RECT(LayoutRect(170, 170, 100, 100), &target, 1206 CHECK_EXACT_VISUAL_RECT(LayoutRect(170, 170, 100, 100), &target,
1188 document().view()->layoutView()); 1207 document().view()->layoutView());
1189 } 1208 }
1190 1209
1191 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) { 1210 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) {
1192 // This test verifies that clip tree hierarchy being generated correctly for t he hard case 1211 // This test verifies that clip tree hierarchy being generated correctly for
1193 // such that a fixed position element getting clipped by an absolute position CSS clip. 1212 // the hard case such that a fixed position element getting clipped by an
1213 // absolute position CSS clip.
1194 setBodyInnerHTML( 1214 setBodyInnerHTML(
1195 "<style>" 1215 "<style>"
1196 " #clip {" 1216 " #clip {"
1197 " position: absolute;" 1217 " position: absolute;"
1198 " left: 123px;" 1218 " left: 123px;"
1199 " top: 456px;" 1219 " top: 456px;"
1200 " clip: rect(10px, 80px, 70px, 40px);" 1220 " clip: rect(10px, 80px, 70px, 40px);"
1201 " width: 100px;" 1221 " width: 100px;"
1202 " height: 100px;" 1222 " height: 100px;"
1203 " }" 1223 " }"
(...skipping 10 matching lines...) Expand all
1214 LayoutRect absoluteClipRect = localClipRect; 1234 LayoutRect absoluteClipRect = localClipRect;
1215 absoluteClipRect.move(123, 456); 1235 absoluteClipRect.move(123, 456);
1216 1236
1217 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); 1237 LayoutObject& clip = *document().getElementById("clip")->layoutObject();
1218 const ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); 1238 const ObjectPaintProperties* clipProperties = clip.objectPaintProperties();
1219 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent()); 1239 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent());
1220 EXPECT_EQ(framePreTranslation(), 1240 EXPECT_EQ(framePreTranslation(),
1221 clipProperties->cssClip()->localTransformSpace()); 1241 clipProperties->cssClip()->localTransformSpace());
1222 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), 1242 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)),
1223 clipProperties->cssClip()->clipRect()); 1243 clipProperties->cssClip()->clipRect());
1224 CHECK_VISUAL_RECT( 1244 CHECK_VISUAL_RECT(absoluteClipRect, &clip, document().view()->layoutView(),
1225 absoluteClipRect, &clip, document().view()->layoutView(), 1245 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace()
1226 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() doesn't apply css clip on the object itself. 1246 // doesn't apply css clip on the object itself.
1227 LayoutUnit::max()); 1247 LayoutUnit::max());
1228 1248
1229 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); 1249 LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
1230 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(); 1250 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties();
1231 EXPECT_EQ( 1251 EXPECT_EQ(
1232 clipProperties->cssClip(), 1252 clipProperties->cssClip(),
1233 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); 1253 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip());
1234 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() 1254 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties()
1235 ->propertyTreeState.transform() 1255 ->propertyTreeState.transform()
1236 ->parent()); 1256 ->parent());
1237 EXPECT_EQ(TransformationMatrix().translate(654, 321), 1257 EXPECT_EQ(TransformationMatrix().translate(654, 321),
1238 fixedProperties->localBorderBoxProperties() 1258 fixedProperties->localBorderBoxProperties()
1239 ->propertyTreeState.transform() 1259 ->propertyTreeState.transform()
1240 ->matrix()); 1260 ->matrix());
1241 EXPECT_EQ(LayoutPoint(), 1261 EXPECT_EQ(LayoutPoint(),
1242 fixedProperties->localBorderBoxProperties()->paintOffset); 1262 fixedProperties->localBorderBoxProperties()->paintOffset);
1243 CHECK_VISUAL_RECT( 1263 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(),
1244 LayoutRect(), fixed, document().view()->layoutView(), 1264 // TODO(crbug.com/599939): CSS clip of fixed-position
1245 // TODO(crbug.com/599939): CSS clip of fixed-position descendants is broke n in mapToVisualRectInAncestorSpace(). 1265 // descendants is broken in
1246 LayoutUnit::max()); 1266 // mapToVisualRectInAncestorSpace().
1267 LayoutUnit::max());
1247 } 1268 }
1248 1269
1249 TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) { 1270 TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) {
1250 // This test verifies that clip tree hierarchy being generated correctly for t he hard case 1271 // This test verifies that clip tree hierarchy being generated correctly for
1251 // such that a fixed position element getting clipped by an absolute position CSS clip. 1272 // the hard case such that a fixed position element getting clipped by an
1273 // absolute position CSS clip.
1252 setBodyInnerHTML( 1274 setBodyInnerHTML(
1253 "<style>" 1275 "<style>"
1254 " #clip {" 1276 " #clip {"
1255 " position: absolute;" 1277 " position: absolute;"
1256 " left: 123px;" 1278 " left: 123px;"
1257 " top: 456px;" 1279 " top: 456px;"
1258 " clip: rect(10px, 80px, 70px, 40px);" 1280 " clip: rect(10px, 80px, 70px, 40px);"
1259 " width: 100px;" 1281 " width: 100px;"
1260 " height: 100px;" 1282 " height: 100px;"
1261 " }" 1283 " }"
1262 " #abs {" 1284 " #abs {"
1263 " position: absolute;" 1285 " position: absolute;"
1264 " left: 654px;" 1286 " left: 654px;"
1265 " top: 321px;" 1287 " top: 321px;"
1266 " width: 10px;" 1288 " width: 10px;"
1267 " heght: 20px" 1289 " heght: 20px"
1268 " }" 1290 " }"
1269 "</style>" 1291 "</style>"
1270 "<div id='clip'><div id='absolute'></div></div>"); 1292 "<div id='clip'><div id='absolute'></div></div>");
1271 1293
1272 LayoutRect localClipRect(40, 10, 40, 60); 1294 LayoutRect localClipRect(40, 10, 40, 60);
1273 LayoutRect absoluteClipRect = localClipRect; 1295 LayoutRect absoluteClipRect = localClipRect;
1274 absoluteClipRect.move(123, 456); 1296 absoluteClipRect.move(123, 456);
1275 1297
1276 LayoutObject* clip = document().getElementById("clip")->layoutObject(); 1298 LayoutObject* clip = document().getElementById("clip")->layoutObject();
1277 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); 1299 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties();
1278 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent()); 1300 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent());
1279 // No scroll translation because the document does not scroll (not enough cont ent). 1301 // No scroll translation because the document does not scroll (not enough
1302 // content).
1280 EXPECT_TRUE(!frameScrollTranslation()); 1303 EXPECT_TRUE(!frameScrollTranslation());
1281 EXPECT_EQ(framePreTranslation(), 1304 EXPECT_EQ(framePreTranslation(),
1282 clipProperties->cssClip()->localTransformSpace()); 1305 clipProperties->cssClip()->localTransformSpace());
1283 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), 1306 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)),
1284 clipProperties->cssClip()->clipRect()); 1307 clipProperties->cssClip()->clipRect());
1285 CHECK_VISUAL_RECT( 1308 CHECK_VISUAL_RECT(absoluteClipRect, clip, document().view()->layoutView(),
1286 absoluteClipRect, clip, document().view()->layoutView(), 1309 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace()
1287 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() doesn't apply css clip on the object itself. 1310 // doesn't apply css clip on the object itself.
1288 LayoutUnit::max()); 1311 LayoutUnit::max());
1289 1312
1290 LayoutObject* absolute = 1313 LayoutObject* absolute =
1291 document().getElementById("absolute")->layoutObject(); 1314 document().getElementById("absolute")->layoutObject();
1292 const ObjectPaintProperties* absPosProperties = 1315 const ObjectPaintProperties* absPosProperties =
1293 absolute->objectPaintProperties(); 1316 absolute->objectPaintProperties();
1294 EXPECT_EQ( 1317 EXPECT_EQ(
1295 clipProperties->cssClip(), 1318 clipProperties->cssClip(),
1296 absPosProperties->localBorderBoxProperties()->propertyTreeState.clip()); 1319 absPosProperties->localBorderBoxProperties()->propertyTreeState.clip());
1297 EXPECT_EQ(framePreTranslation(), absPosProperties->localBorderBoxProperties() 1320 EXPECT_EQ(framePreTranslation(), absPosProperties->localBorderBoxProperties()
1298 ->propertyTreeState.transform()); 1321 ->propertyTreeState.transform());
1299 EXPECT_EQ(LayoutPoint(123, 456), 1322 EXPECT_EQ(LayoutPoint(123, 456),
1300 absPosProperties->localBorderBoxProperties()->paintOffset); 1323 absPosProperties->localBorderBoxProperties()->paintOffset);
1301 CHECK_VISUAL_RECT( 1324 CHECK_VISUAL_RECT(LayoutRect(), absolute, document().view()->layoutView(),
1302 LayoutRect(), absolute, document().view()->layoutView(), 1325 // TODO(crbug.com/599939): CSS clip of fixed-position
1303 // TODO(crbug.com/599939): CSS clip of fixed-position descendants is broke n in mapToVisualRectInAncestorSpace(). 1326 // descendants is broken in
1304 LayoutUnit::max()); 1327 // mapToVisualRectInAncestorSpace().
1328 LayoutUnit::max());
1305 } 1329 }
1306 1330
1307 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) { 1331 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) {
1308 // This test is similar to CSSClipFixedPositionDescendant above, except that 1332 // This test is similar to CSSClipFixedPositionDescendant above, except that
1309 // now we have a parent overflow clip that should be escaped by the fixed desc endant. 1333 // now we have a parent overflow clip that should be escaped by the fixed
1334 // descendant.
1310 setBodyInnerHTML( 1335 setBodyInnerHTML(
1311 "<style>" 1336 "<style>"
1312 " body {" 1337 " body {"
1313 " margin: 0;" 1338 " margin: 0;"
1314 " }" 1339 " }"
1315 " #overflow {" 1340 " #overflow {"
1316 " position: relative;" 1341 " position: relative;"
1317 " width: 50px;" 1342 " width: 50px;"
1318 " height: 50px;" 1343 " height: 50px;"
1319 " overflow: scroll;" 1344 " overflow: scroll;"
(...skipping 15 matching lines...) Expand all
1335 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>"); 1360 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>");
1336 LayoutRect localClipRect(40, 10, 40, 60); 1361 LayoutRect localClipRect(40, 10, 40, 60);
1337 LayoutRect absoluteClipRect = localClipRect; 1362 LayoutRect absoluteClipRect = localClipRect;
1338 absoluteClipRect.move(123, 456); 1363 absoluteClipRect.move(123, 456);
1339 1364
1340 LayoutObject& overflow = 1365 LayoutObject& overflow =
1341 *document().getElementById("overflow")->layoutObject(); 1366 *document().getElementById("overflow")->layoutObject();
1342 const ObjectPaintProperties* overflowProperties = 1367 const ObjectPaintProperties* overflowProperties =
1343 overflow.objectPaintProperties(); 1368 overflow.objectPaintProperties();
1344 EXPECT_EQ(frameContentClip(), overflowProperties->overflowClip()->parent()); 1369 EXPECT_EQ(frameContentClip(), overflowProperties->overflowClip()->parent());
1345 // No scroll translation because the document does not scroll (not enough cont ent). 1370 // No scroll translation because the document does not scroll (not enough
1371 // content).
1346 EXPECT_TRUE(!frameScrollTranslation()); 1372 EXPECT_TRUE(!frameScrollTranslation());
1347 EXPECT_EQ(framePreTranslation(), 1373 EXPECT_EQ(framePreTranslation(),
1348 overflowProperties->scrollTranslation()->parent()); 1374 overflowProperties->scrollTranslation()->parent());
1349 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 50, 50), &overflow, 1375 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 50, 50), &overflow,
1350 document().view()->layoutView()); 1376 document().view()->layoutView());
1351 1377
1352 LayoutObject* clip = document().getElementById("clip")->layoutObject(); 1378 LayoutObject* clip = document().getElementById("clip")->layoutObject();
1353 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); 1379 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties();
1354 EXPECT_EQ(overflowProperties->overflowClip(), 1380 EXPECT_EQ(overflowProperties->overflowClip(),
1355 clipProperties->cssClip()->parent()); 1381 clipProperties->cssClip()->parent());
(...skipping 16 matching lines...) Expand all
1372 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); 1398 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip());
1373 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() 1399 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties()
1374 ->propertyTreeState.transform() 1400 ->propertyTreeState.transform()
1375 ->parent()); 1401 ->parent());
1376 EXPECT_EQ(TransformationMatrix().translate(654, 321), 1402 EXPECT_EQ(TransformationMatrix().translate(654, 321),
1377 fixedProperties->localBorderBoxProperties() 1403 fixedProperties->localBorderBoxProperties()
1378 ->propertyTreeState.transform() 1404 ->propertyTreeState.transform()
1379 ->matrix()); 1405 ->matrix());
1380 EXPECT_EQ(LayoutPoint(), 1406 EXPECT_EQ(LayoutPoint(),
1381 fixedProperties->localBorderBoxProperties()->paintOffset); 1407 fixedProperties->localBorderBoxProperties()->paintOffset);
1382 CHECK_VISUAL_RECT( 1408 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(),
1383 LayoutRect(), fixed, document().view()->layoutView(), 1409 // TODO(crbug.com/599939): CSS clip of fixed-position
1384 // TODO(crbug.com/599939): CSS clip of fixed-position descendants is broke n in geometry mapping. 1410 // descendants is broken in geometry mapping.
1385 LayoutUnit::max()); 1411 LayoutUnit::max());
1386 } 1412 }
1387 1413
1388 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) { 1414 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) {
1389 setBodyInnerHTML( 1415 setBodyInnerHTML(
1390 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" 1416 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>"
1391 " <div style='position: relative; top: 100px; left: 100px'>" 1417 " <div style='position: relative; top: 100px; left: 100px'>"
1392 " <div id='spanner' style='column-span: all; opacity: 0.5; width: " 1418 " <div id='spanner' style='column-span: all; opacity: 0.5; width: "
1393 "100px; height: 100px;'></div>" 1419 "100px; height: 100px;'></div>"
1394 " </div>" 1420 " </div>"
1395 "</div>"); 1421 "</div>");
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 // The paint offset transform should be snapped from (0.3,0.3) to (0,0). 1479 // The paint offset transform should be snapped from (0.3,0.3) to (0,0).
1454 EXPECT_EQ(TransformationMatrix().translate(0, 0), 1480 EXPECT_EQ(TransformationMatrix().translate(0, 0),
1455 bProperties->transform()->parent()->matrix()); 1481 bProperties->transform()->parent()->matrix());
1456 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3). 1482 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3).
1457 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3)); 1483 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3));
1458 EXPECT_EQ(subpixelAccumulation, 1484 EXPECT_EQ(subpixelAccumulation,
1459 bProperties->localBorderBoxProperties()->paintOffset); 1485 bProperties->localBorderBoxProperties()->paintOffset);
1460 CHECK_EXACT_VISUAL_RECT(LayoutRect(FloatRect(0.3, 0.3, 40, 40)), b, 1486 CHECK_EXACT_VISUAL_RECT(LayoutRect(FloatRect(0.3, 0.3, 40, 40)), b,
1461 frameView->layoutView()); 1487 frameView->layoutView());
1462 1488
1463 // c should be painted starting at subpixelAccumulation + (0.1,0.1) = (0.4,0.4 ). 1489 // c should be painted starting at subpixelAccumulation + (0.1,0.1) =
1490 // (0.4,0.4).
1464 LayoutObject* c = document().getElementById("c")->layoutObject(); 1491 LayoutObject* c = document().getElementById("c")->layoutObject();
1465 LayoutPoint cPaintOffset = 1492 LayoutPoint cPaintOffset =
1466 subpixelAccumulation + LayoutPoint(FloatPoint(0.1, 0.1)); 1493 subpixelAccumulation + LayoutPoint(FloatPoint(0.1, 0.1));
1467 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); 1494 const ObjectPaintProperties* cProperties = c->objectPaintProperties();
1468 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset); 1495 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset);
1469 // Visual rects via the non-paint properties system use enclosingIntRect befor e applying transforms, 1496 // Visual rects via the non-paint properties system use enclosingIntRect
1470 // because they are computed bottom-up and therefore can't apply pixel snappin g. Therefore apply a 1497 // before applying transforms, because they are computed bottom-up and
1471 // slop of 1px. 1498 // therefore can't apply pixel snapping. Therefore apply a slop of 1px.
1472 CHECK_VISUAL_RECT(LayoutRect(FloatRect(0.4, 0.4, 40, 40)), c, 1499 CHECK_VISUAL_RECT(LayoutRect(FloatRect(0.4, 0.4, 40, 40)), c,
1473 frameView->layoutView(), 1); 1500 frameView->layoutView(), 1);
1474 } 1501 }
1475 1502
1476 TEST_P(PaintPropertyTreeBuilderTest, 1503 TEST_P(PaintPropertyTreeBuilderTest,
1477 PaintOffsetWithPixelSnappingThroughTransform) { 1504 PaintOffsetWithPixelSnappingThroughTransform) {
1478 setBodyInnerHTML( 1505 setBodyInnerHTML(
1479 "<style>" 1506 "<style>"
1480 " * { margin: 0; }" 1507 " * { margin: 0; }"
1481 " div { position: relative; }" 1508 " div { position: relative; }"
(...skipping 16 matching lines...) Expand all
1498 bProperties->transform()->parent()->matrix()); 1525 bProperties->transform()->parent()->matrix());
1499 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3). 1526 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3).
1500 LayoutPoint subpixelAccumulation = 1527 LayoutPoint subpixelAccumulation =
1501 LayoutPoint(LayoutPoint(FloatPoint(0.7, 0.7)) - LayoutPoint(1, 1)); 1528 LayoutPoint(LayoutPoint(FloatPoint(0.7, 0.7)) - LayoutPoint(1, 1));
1502 EXPECT_EQ(subpixelAccumulation, 1529 EXPECT_EQ(subpixelAccumulation,
1503 bProperties->localBorderBoxProperties()->paintOffset); 1530 bProperties->localBorderBoxProperties()->paintOffset);
1504 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0.7), 1531 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0.7),
1505 LayoutUnit(40), LayoutUnit(40)), 1532 LayoutUnit(40), LayoutUnit(40)),
1506 b, frameView->layoutView()); 1533 b, frameView->layoutView());
1507 1534
1508 // c should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0.4 ). 1535 // c should be painted starting at subpixelAccumulation + (0.7,0.7) =
1536 // (0.4,0.4).
1509 LayoutObject* c = document().getElementById("c")->layoutObject(); 1537 LayoutObject* c = document().getElementById("c")->layoutObject();
1510 LayoutPoint cPaintOffset = 1538 LayoutPoint cPaintOffset =
1511 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0.7)); 1539 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0.7));
1512 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); 1540 const ObjectPaintProperties* cProperties = c->objectPaintProperties();
1513 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset); 1541 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset);
1514 // Visual rects via the non-paint properties system use enclosingIntRect befor e applying transforms, 1542 // Visual rects via the non-paint properties system use enclosingIntRect
1515 // because they are computed bottom-up and therefore can't apply pixel snappin g. Therefore apply a 1543 // before applying transforms, because they are computed bottom-up and
1516 // slop of 1px. 1544 // therefore can't apply pixel snapping. Therefore apply a slop of 1px.
1517 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7), 1545 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7),
1518 LayoutUnit(0.7) + LayoutUnit(0.7), 1546 LayoutUnit(0.7) + LayoutUnit(0.7),
1519 LayoutUnit(40), LayoutUnit(40)), 1547 LayoutUnit(40), LayoutUnit(40)),
1520 c, frameView->layoutView(), 1); 1548 c, frameView->layoutView(), 1);
1521 } 1549 }
1522 1550
1523 TEST_P(PaintPropertyTreeBuilderTest, 1551 TEST_P(PaintPropertyTreeBuilderTest,
1524 PaintOffsetWithPixelSnappingThroughMultipleTransforms) { 1552 PaintOffsetWithPixelSnappingThroughMultipleTransforms) {
1525 setBodyInnerHTML( 1553 setBodyInnerHTML(
1526 "<style>" 1554 "<style>"
(...skipping 25 matching lines...) Expand all
1552 EXPECT_EQ(subpixelAccumulation, 1580 EXPECT_EQ(subpixelAccumulation,
1553 bProperties->localBorderBoxProperties()->paintOffset); 1581 bProperties->localBorderBoxProperties()->paintOffset);
1554 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(5.7), LayoutUnit(7.7), 1582 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(5.7), LayoutUnit(7.7),
1555 LayoutUnit(40), LayoutUnit(40)), 1583 LayoutUnit(40), LayoutUnit(40)),
1556 b, frameView->layoutView()); 1584 b, frameView->layoutView());
1557 1585
1558 LayoutObject* c = document().getElementById("c")->layoutObject(); 1586 LayoutObject* c = document().getElementById("c")->layoutObject();
1559 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); 1587 const ObjectPaintProperties* cProperties = c->objectPaintProperties();
1560 EXPECT_EQ(TransformationMatrix().translate3d(11, 13, 0), 1588 EXPECT_EQ(TransformationMatrix().translate3d(11, 13, 0),
1561 cProperties->transform()->matrix()); 1589 cProperties->transform()->matrix());
1562 // The paint offset should be (-0.3,-0.3) but the paint offset transform shoul d still be at 1590 // The paint offset should be (-0.3,-0.3) but the paint offset transform
1563 // (0,0) because it should be snapped. 1591 // should still be at (0,0) because it should be snapped.
1564 EXPECT_EQ(TransformationMatrix().translate(0, 0), 1592 EXPECT_EQ(TransformationMatrix().translate(0, 0),
1565 cProperties->transform()->parent()->matrix()); 1593 cProperties->transform()->parent()->matrix());
1566 // The residual subpixel adjustment should still be (-0.3,-0.3). 1594 // The residual subpixel adjustment should still be (-0.3,-0.3).
1567 EXPECT_EQ(subpixelAccumulation, 1595 EXPECT_EQ(subpixelAccumulation,
1568 cProperties->localBorderBoxProperties()->paintOffset); 1596 cProperties->localBorderBoxProperties()->paintOffset);
1569 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(16.7), LayoutUnit(20.7), 1597 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(16.7), LayoutUnit(20.7),
1570 LayoutUnit(40), LayoutUnit(40)), 1598 LayoutUnit(40), LayoutUnit(40)),
1571 c, frameView->layoutView()); 1599 c, frameView->layoutView());
1572 1600
1573 // d should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0.4 ). 1601 // d should be painted starting at subpixelAccumulation + (0.7,0.7) =
1602 // (0.4,0.4).
1574 LayoutObject* d = document().getElementById("d")->layoutObject(); 1603 LayoutObject* d = document().getElementById("d")->layoutObject();
1575 LayoutPoint dPaintOffset = 1604 LayoutPoint dPaintOffset =
1576 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0.7)); 1605 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0.7));
1577 const ObjectPaintProperties* dProperties = d->objectPaintProperties(); 1606 const ObjectPaintProperties* dProperties = d->objectPaintProperties();
1578 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset); 1607 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset);
1579 // Visual rects via the non-paint properties system use enclosingIntRect befor e applying transforms, 1608 // Visual rects via the non-paint properties system use enclosingIntRect
1580 // because they are computed bottom-up and therefore can't apply pixel snappin g. Therefore apply a 1609 // before applying transforms, because they are computed bottom-up and
1581 // slop of 1px. 1610 // therefore can't apply pixel snapping. Therefore apply a slop of 1px.
1582 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(16.7) + LayoutUnit(0.7), 1611 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(16.7) + LayoutUnit(0.7),
1583 LayoutUnit(20.7) + LayoutUnit(0.7), 1612 LayoutUnit(20.7) + LayoutUnit(0.7),
1584 LayoutUnit(40), LayoutUnit(40)), 1613 LayoutUnit(40), LayoutUnit(40)),
1585 d, frameView->layoutView(), 1); 1614 d, frameView->layoutView(), 1);
1586 } 1615 }
1587 1616
1588 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) { 1617 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) {
1589 setBodyInnerHTML( 1618 setBodyInnerHTML(
1590 "<style>" 1619 "<style>"
1591 " * { margin: 0; }" 1620 " * { margin: 0; }"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0), 1655 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0),
1627 LayoutUnit(40), LayoutUnit(40)), 1656 LayoutUnit(40), LayoutUnit(40)),
1628 fixed, frameView->layoutView()); 1657 fixed, frameView->layoutView());
1629 1658
1630 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0). 1659 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0).
1631 LayoutObject* d = document().getElementById("d")->layoutObject(); 1660 LayoutObject* d = document().getElementById("d")->layoutObject();
1632 LayoutPoint dPaintOffset = 1661 LayoutPoint dPaintOffset =
1633 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0)); 1662 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0));
1634 const ObjectPaintProperties* dProperties = d->objectPaintProperties(); 1663 const ObjectPaintProperties* dProperties = d->objectPaintProperties();
1635 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset); 1664 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset);
1636 // Visual rects via the non-paint properties system use enclosingIntRect befor e applying transforms, 1665 // Visual rects via the non-paint properties system use enclosingIntRect
1637 // because they are computed bottom-up and therefore can't apply pixel snappin g. Therefore apply a 1666 // before applying transforms, because they are computed bottom-up and
1638 // slop of 1px. 1667 // therefore can't apply pixel snapping. Therefore apply a slop of 1px.
1639 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7), LayoutUnit(), 1668 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7), LayoutUnit(),
1640 LayoutUnit(40), LayoutUnit(40)), 1669 LayoutUnit(40), LayoutUnit(40)),
1641 d, frameView->layoutView(), 1); 1670 d, frameView->layoutView(), 1);
1642 } 1671 }
1643 1672
1644 TEST_P(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) { 1673 TEST_P(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) {
1645 setBodyInnerHTML( 1674 setBodyInnerHTML(
1646 "<svg id='svg' style='position: relative; left: 0.1px; transform: " 1675 "<svg id='svg' style='position: relative; left: 0.1px; transform: "
1647 "matrix(1, 0, 0, 1, 0, 0);'>" 1676 "matrix(1, 0, 0, 1, 0, 0);'>"
1648 " <rect id='rect' transform='translate(1, 1)'/>" 1677 " <rect id='rect' transform='translate(1, 1)'/>"
(...skipping 11 matching lines...) Expand all
1660 EXPECT_EQ(nullptr, 1689 EXPECT_EQ(nullptr,
1661 svgWithTransformProperties->svgLocalToBorderBoxTransform()); 1690 svgWithTransformProperties->svgLocalToBorderBoxTransform());
1662 1691
1663 LayoutObject& rectWithTransform = 1692 LayoutObject& rectWithTransform =
1664 *document().getElementById("rect")->layoutObject(); 1693 *document().getElementById("rect")->layoutObject();
1665 const ObjectPaintProperties* rectWithTransformProperties = 1694 const ObjectPaintProperties* rectWithTransformProperties =
1666 rectWithTransform.objectPaintProperties(); 1695 rectWithTransform.objectPaintProperties();
1667 EXPECT_EQ(TransformationMatrix().translate(1, 1), 1696 EXPECT_EQ(TransformationMatrix().translate(1, 1),
1668 rectWithTransformProperties->transform()->matrix()); 1697 rectWithTransformProperties->transform()->matrix());
1669 1698
1670 // Ensure there is no PaintOffset transform between the rect and the svg's tra nsform. 1699 // Ensure there is no PaintOffset transform between the rect and the svg's
1700 // transform.
1671 EXPECT_EQ(svgWithTransformProperties->transform(), 1701 EXPECT_EQ(svgWithTransformProperties->transform(),
1672 rectWithTransformProperties->transform()->parent()); 1702 rectWithTransformProperties->transform()->parent());
1673 } 1703 }
1674 1704
1675 TEST_P(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) { 1705 TEST_P(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) {
1676 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>"); 1706 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>");
1677 1707
1678 const ObjectPaintProperties* properties = 1708 const ObjectPaintProperties* properties =
1679 document().body()->firstChild()->layoutObject()->objectPaintProperties(); 1709 document().body()->firstChild()->layoutObject()->objectPaintProperties();
1680 ASSERT_TRUE(properties->transform()); 1710 ASSERT_TRUE(properties->transform());
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 const TransformPaintPropertyNode* cTransformNode = cProperties->transform(); 1951 const TransformPaintPropertyNode* cTransformNode = cProperties->transform();
1922 EXPECT_EQ(TransformationMatrix().translate(77, 88), cTransformNode->matrix()); 1952 EXPECT_EQ(TransformationMatrix().translate(77, 88), cTransformNode->matrix());
1923 1953
1924 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), 1954 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(),
1925 frameView->layoutView()); 1955 frameView->layoutView());
1926 CHECK_EXACT_VISUAL_RECT(LayoutRect(88, 110, 30, 40), b->layoutObject(), 1956 CHECK_EXACT_VISUAL_RECT(LayoutRect(88, 110, 30, 40), b->layoutObject(),
1927 frameView->layoutView()); 1957 frameView->layoutView());
1928 CHECK_EXACT_VISUAL_RECT(LayoutRect(165, 198, 10, 20), c->layoutObject(), 1958 CHECK_EXACT_VISUAL_RECT(LayoutRect(165, 198, 10, 20), c->layoutObject(),
1929 frameView->layoutView()); 1959 frameView->layoutView());
1930 1960
1931 // Change transform of b. B's transform node should be a new node with the new value, 1961 // Change transform of b. B's transform node should be a new node with the new
1932 // and a and c's transform nodes should be unchanged (with c's parent adjusted ). 1962 // value, and a and c's transform nodes should be unchanged (with c's parent
1963 // adjusted).
1933 b->setAttribute(HTMLNames::styleAttr, "transform: translate(111px, 222px)"); 1964 b->setAttribute(HTMLNames::styleAttr, "transform: translate(111px, 222px)");
1934 document().view()->updateAllLifecyclePhases(); 1965 document().view()->updateAllLifecyclePhases();
1935 1966
1936 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); 1967 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties());
1937 EXPECT_EQ(aTransformNode, aProperties->transform()); 1968 EXPECT_EQ(aTransformNode, aProperties->transform());
1938 1969
1939 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); 1970 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties());
1940 bTransformNode = bProperties->transform(); 1971 bTransformNode = bProperties->transform();
1941 EXPECT_EQ(TransformationMatrix().translate(111, 222), 1972 EXPECT_EQ(TransformationMatrix().translate(111, 222),
1942 bTransformNode->matrix()); 1973 bTransformNode->matrix());
1943 EXPECT_EQ(aTransformNode, bTransformNode->parent()); 1974 EXPECT_EQ(aTransformNode, bTransformNode->parent());
1944 1975
1945 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); 1976 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties());
1946 EXPECT_EQ(cTransformNode, cProperties->transform()); 1977 EXPECT_EQ(cTransformNode, cProperties->transform());
1947 EXPECT_EQ(bTransformNode, cTransformNode->parent()); 1978 EXPECT_EQ(bTransformNode, cTransformNode->parent());
1948 1979
1949 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), 1980 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(),
1950 frameView->layoutView()); 1981 frameView->layoutView());
1951 CHECK_EXACT_VISUAL_RECT(LayoutRect(144, 266, 50, 20), b->layoutObject(), 1982 CHECK_EXACT_VISUAL_RECT(LayoutRect(144, 266, 50, 20), b->layoutObject(),
1952 frameView->layoutView()); 1983 frameView->layoutView());
1953 CHECK_EXACT_VISUAL_RECT(LayoutRect(221, 354, 10, 20), c->layoutObject(), 1984 CHECK_EXACT_VISUAL_RECT(LayoutRect(221, 354, 10, 20), c->layoutObject(),
1954 frameView->layoutView()); 1985 frameView->layoutView());
1955 1986
1956 // Remove transform from b. B's transform node should be removed from the tree , 1987 // Remove transform from b. B's transform node should be removed from the
1957 // and a and c's transform nodes should be unchanged (with c's parent adjusted ). 1988 // tree, and a and c's transform nodes should be unchanged (with c's parent
1989 // adjusted).
1958 b->setAttribute(HTMLNames::styleAttr, ""); 1990 b->setAttribute(HTMLNames::styleAttr, "");
1959 document().view()->updateAllLifecyclePhases(); 1991 document().view()->updateAllLifecyclePhases();
1960 1992
1961 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); 1993 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties());
1962 EXPECT_EQ(aTransformNode, aProperties->transform()); 1994 EXPECT_EQ(aTransformNode, aProperties->transform());
1963 1995
1964 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); 1996 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties());
1965 EXPECT_EQ(nullptr, bProperties->transform()); 1997 EXPECT_EQ(nullptr, bProperties->transform());
1966 1998
1967 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); 1999 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties());
1968 EXPECT_EQ(cTransformNode, cProperties->transform()); 2000 EXPECT_EQ(cTransformNode, cProperties->transform());
1969 EXPECT_EQ(aTransformNode, cTransformNode->parent()); 2001 EXPECT_EQ(aTransformNode, cTransformNode->parent());
1970 2002
1971 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), 2003 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(),
1972 frameView->layoutView()); 2004 frameView->layoutView());
1973 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 20), b->layoutObject(), 2005 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 20), b->layoutObject(),
1974 frameView->layoutView()); 2006 frameView->layoutView());
1975 CHECK_EXACT_VISUAL_RECT(LayoutRect(110, 132, 10, 20), c->layoutObject(), 2007 CHECK_EXACT_VISUAL_RECT(LayoutRect(110, 132, 10, 20), c->layoutObject(),
1976 frameView->layoutView()); 2008 frameView->layoutView());
1977 2009
1978 // Re-add transform to b. B's transform node should be inserted into the tree, 2010 // Re-add transform to b. B's transform node should be inserted into the tree,
1979 // and a and c's transform nodes should be unchanged (with c's parent adjusted ). 2011 // and a and c's transform nodes should be unchanged (with c's parent
2012 // adjusted).
1980 b->setAttribute(HTMLNames::styleAttr, "transform: translate(4px, 5px)"); 2013 b->setAttribute(HTMLNames::styleAttr, "transform: translate(4px, 5px)");
1981 document().view()->updateAllLifecyclePhases(); 2014 document().view()->updateAllLifecyclePhases();
1982 2015
1983 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); 2016 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties());
1984 EXPECT_EQ(aTransformNode, aProperties->transform()); 2017 EXPECT_EQ(aTransformNode, aProperties->transform());
1985 2018
1986 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); 2019 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties());
1987 bTransformNode = bProperties->transform(); 2020 bTransformNode = bProperties->transform();
1988 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix()); 2021 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix());
1989 EXPECT_EQ(aTransformNode, bTransformNode->parent()); 2022 EXPECT_EQ(aTransformNode, bTransformNode->parent());
1990 2023
1991 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); 2024 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties());
1992 EXPECT_EQ(cTransformNode, cProperties->transform()); 2025 EXPECT_EQ(cTransformNode, cProperties->transform());
1993 EXPECT_EQ(bTransformNode, cTransformNode->parent()); 2026 EXPECT_EQ(bTransformNode, cTransformNode->parent());
1994 2027
1995 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), 2028 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(),
1996 frameView->layoutView()); 2029 frameView->layoutView());
1997 CHECK_EXACT_VISUAL_RECT(LayoutRect(37, 49, 50, 20), b->layoutObject(), 2030 CHECK_EXACT_VISUAL_RECT(LayoutRect(37, 49, 50, 20), b->layoutObject(),
1998 frameView->layoutView()); 2031 frameView->layoutView());
1999 CHECK_EXACT_VISUAL_RECT(LayoutRect(114, 137, 10, 20), c->layoutObject(), 2032 CHECK_EXACT_VISUAL_RECT(LayoutRect(114, 137, 10, 20), c->layoutObject(),
2000 frameView->layoutView()); 2033 frameView->layoutView());
2001 } 2034 }
2002 2035
2003 TEST_P(PaintPropertyTreeBuilderTest, OverflowClipContentsTreeState) { 2036 TEST_P(PaintPropertyTreeBuilderTest, OverflowClipContentsTreeState) {
2004 // This test verifies the tree builder correctly computes and records the prop erty tree context 2037 // This test verifies the tree builder correctly computes and records the
2005 // for a (pseudo) stacking context that is scrolled by a containing block that is not one of 2038 // property tree context for a (pseudo) stacking context that is scrolled by a
2006 // the painting ancestors. 2039 // containing block that is not one of the painting ancestors.
2007 setBodyInnerHTML( 2040 setBodyInnerHTML(
2008 "<style>body { margin: 20px 30px; }</style>" 2041 "<style>body { margin: 20px 30px; }</style>"
2009 "<div id='clipper' style='overflow:hidden; width:400px; height:300px;'>" 2042 "<div id='clipper' style='overflow:hidden; width:400px; height:300px;'>"
2010 " <div id='child' style='position:relative; width:500px; height: " 2043 " <div id='child' style='position:relative; width:500px; height: "
2011 "600px;'></div>" 2044 "600px;'></div>"
2012 "</div>"); 2045 "</div>");
2013 2046
2014 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( 2047 LayoutBoxModelObject* clipper = toLayoutBoxModelObject(
2015 document().getElementById("clipper")->layoutObject()); 2048 document().getElementById("clipper")->layoutObject());
2016 const ObjectPaintProperties* clipProperties = 2049 const ObjectPaintProperties* clipProperties =
2017 clipper->objectPaintProperties(); 2050 clipper->objectPaintProperties();
2018 LayoutObject* child = document().getElementById("child")->layoutObject(); 2051 LayoutObject* child = document().getElementById("child")->layoutObject();
2019 const ObjectPaintProperties* childProperties = child->objectPaintProperties(); 2052 const ObjectPaintProperties* childProperties = child->objectPaintProperties();
2020 2053
2021 // No scroll translation because the document does not scroll (not enough cont ent). 2054 // No scroll translation because the document does not scroll (not enough
2055 // content).
2022 EXPECT_TRUE(!frameScrollTranslation()); 2056 EXPECT_TRUE(!frameScrollTranslation());
2023 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() 2057 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties()
2024 ->propertyTreeState.transform()); 2058 ->propertyTreeState.transform());
2025 EXPECT_EQ( 2059 EXPECT_EQ(
2026 frameContentClip(), 2060 frameContentClip(),
2027 clipProperties->localBorderBoxProperties()->propertyTreeState.clip()); 2061 clipProperties->localBorderBoxProperties()->propertyTreeState.clip());
2028 2062
2029 auto contentsProperties = clipProperties->contentsProperties(); 2063 auto contentsProperties = clipProperties->contentsProperties();
2030 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset); 2064 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset);
2031 EXPECT_EQ(framePreTranslation(), 2065 EXPECT_EQ(framePreTranslation(),
(...skipping 21 matching lines...) Expand all
2053 "500px;'></div>" 2087 "500px;'></div>"
2054 "</div>"); 2088 "</div>");
2055 2089
2056 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( 2090 LayoutBoxModelObject* clipper = toLayoutBoxModelObject(
2057 document().getElementById("clipper")->layoutObject()); 2091 document().getElementById("clipper")->layoutObject());
2058 const ObjectPaintProperties* clipProperties = 2092 const ObjectPaintProperties* clipProperties =
2059 clipper->objectPaintProperties(); 2093 clipper->objectPaintProperties();
2060 LayoutObject* child = document().getElementById("child")->layoutObject(); 2094 LayoutObject* child = document().getElementById("child")->layoutObject();
2061 const ObjectPaintProperties* childProperties = child->objectPaintProperties(); 2095 const ObjectPaintProperties* childProperties = child->objectPaintProperties();
2062 2096
2063 // No scroll translation because the document does not scroll (not enough cont ent). 2097 // No scroll translation because the document does not scroll (not enough
2098 // content).
2064 EXPECT_TRUE(!frameScrollTranslation()); 2099 EXPECT_TRUE(!frameScrollTranslation());
2065 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() 2100 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties()
2066 ->propertyTreeState.transform()); 2101 ->propertyTreeState.transform());
2067 EXPECT_EQ( 2102 EXPECT_EQ(
2068 frameContentClip(), 2103 frameContentClip(),
2069 clipProperties->localBorderBoxProperties()->propertyTreeState.clip()); 2104 clipProperties->localBorderBoxProperties()->propertyTreeState.clip());
2070 2105
2071 auto contentsProperties = clipProperties->contentsProperties(); 2106 auto contentsProperties = clipProperties->contentsProperties();
2072 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset); 2107 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset);
2073 EXPECT_EQ(framePreTranslation(), 2108 EXPECT_EQ(framePreTranslation(),
2074 contentsProperties.propertyTreeState.transform()); 2109 contentsProperties.propertyTreeState.transform());
2075 EXPECT_EQ(clipProperties->overflowClip(), 2110 EXPECT_EQ(clipProperties->overflowClip(),
2076 contentsProperties.propertyTreeState.clip()); 2111 contentsProperties.propertyTreeState.clip());
2077 2112
2078 EXPECT_EQ(framePreTranslation(), childProperties->localBorderBoxProperties() 2113 EXPECT_EQ(framePreTranslation(), childProperties->localBorderBoxProperties()
2079 ->propertyTreeState.transform()); 2114 ->propertyTreeState.transform());
2080 EXPECT_EQ( 2115 EXPECT_EQ(
2081 clipProperties->overflowClip(), 2116 clipProperties->overflowClip(),
2082 childProperties->localBorderBoxProperties()->propertyTreeState.clip()); 2117 childProperties->localBorderBoxProperties()->propertyTreeState.clip());
2083 2118
2084 EXPECT_NE( 2119 EXPECT_NE(
2085 nullptr, 2120 nullptr,
2086 childProperties->localBorderBoxProperties()->propertyTreeState.effect()); 2121 childProperties->localBorderBoxProperties()->propertyTreeState.effect());
2087 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 500), child, clipper); 2122 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 500), child, clipper);
2088 } 2123 }
2089 2124
2090 TEST_P(PaintPropertyTreeBuilderTest, OverflowScrollContentsTreeState) { 2125 TEST_P(PaintPropertyTreeBuilderTest, OverflowScrollContentsTreeState) {
2091 // This test verifies the tree builder correctly computes and records the prop erty tree context 2126 // This test verifies the tree builder correctly computes and records the
2092 // for a (pseudo) stacking context that is scrolled by a containing block that is not one of 2127 // property tree context for a (pseudo) stacking context that is scrolled by a
2093 // the painting ancestors. 2128 // containing block that is not one of the painting ancestors.
2094 setBodyInnerHTML( 2129 setBodyInnerHTML(
2095 "<style>body { margin: 20px 30px; }</style>" 2130 "<style>body { margin: 20px 30px; }</style>"
2096 "<div id='clipper' style='overflow:scroll; width:400px; height:300px;'>" 2131 "<div id='clipper' style='overflow:scroll; width:400px; height:300px;'>"
2097 " <div id='child' style='position:relative; width:500px; height: " 2132 " <div id='child' style='position:relative; width:500px; height: "
2098 "600px;'></div>" 2133 "600px;'></div>"
2099 " <div style='width: 200px; height: 10000px'></div>" 2134 " <div style='width: 200px; height: 10000px'></div>"
2100 "</div>" 2135 "</div>"
2101 "<div id='forceScroll' style='height: 4000px;'></div>"); 2136 "<div id='forceScroll' style='height: 4000px;'></div>");
2102 2137
2103 Element* clipperElement = document().getElementById("clipper"); 2138 Element* clipperElement = document().getElementById("clipper");
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 2196
2162 LayoutObject& roundedBox = 2197 LayoutObject& roundedBox =
2163 *document().getElementById("roundedBox")->layoutObject(); 2198 *document().getElementById("roundedBox")->layoutObject();
2164 const ObjectPaintProperties* roundedBoxProperties = 2199 const ObjectPaintProperties* roundedBoxProperties =
2165 roundedBox.objectPaintProperties(); 2200 roundedBox.objectPaintProperties();
2166 EXPECT_EQ( 2201 EXPECT_EQ(
2167 FloatRoundedRect(FloatRect(50, 50, 200, 200), FloatSize(50, 50), 2202 FloatRoundedRect(FloatRect(50, 50, 200, 200), FloatSize(50, 50),
2168 FloatSize(50, 50), FloatSize(50, 50), FloatSize(50, 50)), 2203 FloatSize(50, 50), FloatSize(50, 50), FloatSize(50, 50)),
2169 roundedBoxProperties->innerBorderRadiusClip()->clipRect()); 2204 roundedBoxProperties->innerBorderRadiusClip()->clipRect());
2170 2205
2171 // Unlike the inner border radius clip, the overflow clip is inset by the scro llbars (13px). 2206 // Unlike the inner border radius clip, the overflow clip is inset by the
2207 // scrollbars (13px).
2172 EXPECT_EQ(FloatRoundedRect(50, 50, 187, 187), 2208 EXPECT_EQ(FloatRoundedRect(50, 50, 187, 187),
2173 roundedBoxProperties->overflowClip()->clipRect()); 2209 roundedBoxProperties->overflowClip()->clipRect());
2174 EXPECT_EQ(frameContentClip(), 2210 EXPECT_EQ(frameContentClip(),
2175 roundedBoxProperties->innerBorderRadiusClip()->parent()); 2211 roundedBoxProperties->innerBorderRadiusClip()->parent());
2176 EXPECT_EQ(roundedBoxProperties->innerBorderRadiusClip(), 2212 EXPECT_EQ(roundedBoxProperties->innerBorderRadiusClip(),
2177 roundedBoxProperties->overflowClip()->parent()); 2213 roundedBoxProperties->overflowClip()->parent());
2178 } 2214 }
2179 2215
2180 TEST_P(PaintPropertyTreeBuilderTest, CssClipContentsTreeState) { 2216 TEST_P(PaintPropertyTreeBuilderTest, CssClipContentsTreeState) {
2181 // This test verifies the tree builder correctly computes and records the prop erty tree context 2217 // This test verifies the tree builder correctly computes and records the
2182 // for a (pseudo) stacking context that is scrolled by a containing block that is not one of 2218 // property tree context for a (pseudo) stacking context that is scrolled by a
2183 // the painting ancestors. 2219 // containing block that is not one of the painting ancestors.
2184 setBodyInnerHTML( 2220 setBodyInnerHTML(
2185 "<style>body { margin: 20px 30px; }</style>" 2221 "<style>body { margin: 20px 30px; }</style>"
2186 "<div id='clipper' style='position: absolute; clip: rect(10px, 80px, " 2222 "<div id='clipper' style='position: absolute; clip: rect(10px, 80px, "
2187 "70px, 40px); width:300px; height:200px;'>" 2223 "70px, 40px); width:300px; height:200px;'>"
2188 " <div id='child' style='position:relative; width:400px; height: " 2224 " <div id='child' style='position:relative; width:400px; height: "
2189 "500px;'></div>" 2225 "500px;'></div>"
2190 "</div>"); 2226 "</div>");
2191 2227
2192 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( 2228 LayoutBoxModelObject* clipper = toLayoutBoxModelObject(
2193 document().getElementById("clipper")->layoutObject()); 2229 document().getElementById("clipper")->layoutObject());
2194 const ObjectPaintProperties* clipProperties = 2230 const ObjectPaintProperties* clipProperties =
2195 clipper->objectPaintProperties(); 2231 clipper->objectPaintProperties();
2196 LayoutObject* child = document().getElementById("child")->layoutObject(); 2232 LayoutObject* child = document().getElementById("child")->layoutObject();
2197 2233
2198 // No scroll translation because the document does not scroll (not enough cont ent). 2234 // No scroll translation because the document does not scroll (not enough
2235 // content).
2199 EXPECT_TRUE(!frameScrollTranslation()); 2236 EXPECT_TRUE(!frameScrollTranslation());
2200 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() 2237 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties()
2201 ->propertyTreeState.transform()); 2238 ->propertyTreeState.transform());
2202 // CSS clip on an element causes it to clip itself, not just descendants. 2239 // CSS clip on an element causes it to clip itself, not just descendants.
2203 EXPECT_EQ( 2240 EXPECT_EQ(
2204 clipProperties->cssClip(), 2241 clipProperties->cssClip(),
2205 clipProperties->localBorderBoxProperties()->propertyTreeState.clip()); 2242 clipProperties->localBorderBoxProperties()->propertyTreeState.clip());
2206 2243
2207 auto contentsProperties = clipProperties->contentsProperties(); 2244 auto contentsProperties = clipProperties->contentsProperties();
2208 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset); 2245 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 " <div class='forceScroll'></div>" 2304 " <div class='forceScroll'></div>"
2268 "</div>"); 2305 "</div>");
2269 2306
2270 Element* overflowHidden = document().getElementById("overflowHidden"); 2307 Element* overflowHidden = document().getElementById("overflowHidden");
2271 overflowHidden->setScrollTop(37); 2308 overflowHidden->setScrollTop(37);
2272 2309
2273 document().view()->updateAllLifecyclePhases(); 2310 document().view()->updateAllLifecyclePhases();
2274 2311
2275 const ObjectPaintProperties* overflowHiddenScrollProperties = 2312 const ObjectPaintProperties* overflowHiddenScrollProperties =
2276 overflowHidden->layoutObject()->objectPaintProperties(); 2313 overflowHidden->layoutObject()->objectPaintProperties();
2277 // Because the frameView is does not scroll, overflowHidden's scroll should be under the root. 2314 // Because the frameView is does not scroll, overflowHidden's scroll should be
2315 // under the root.
2278 EXPECT_TRUE(overflowHiddenScrollProperties->scroll()->parent()->isRoot()); 2316 EXPECT_TRUE(overflowHiddenScrollProperties->scroll()->parent()->isRoot());
2279 EXPECT_EQ(TransformationMatrix().translate(0, -37), 2317 EXPECT_EQ(TransformationMatrix().translate(0, -37),
2280 overflowHiddenScrollProperties->scroll() 2318 overflowHiddenScrollProperties->scroll()
2281 ->scrollOffsetTranslation() 2319 ->scrollOffsetTranslation()
2282 ->matrix()); 2320 ->matrix());
2283 // This should match the overflow's dimensions. 2321 // This should match the overflow's dimensions.
2284 EXPECT_EQ(IntSize(5, 3), overflowHiddenScrollProperties->scroll()->clip()); 2322 EXPECT_EQ(IntSize(5, 3), overflowHiddenScrollProperties->scroll()->clip());
2285 // The scrolling content's bounds should include both the overflow's dimension s (5x3) and the 2323 // The scrolling content's bounds should include both the overflow's
2286 // 0x79 "forceScroll" object. 2324 // dimensions (5x3) and the 0x79 "forceScroll" object.
2287 EXPECT_EQ(IntSize(5, 79), overflowHiddenScrollProperties->scroll()->bounds()); 2325 EXPECT_EQ(IntSize(5, 79), overflowHiddenScrollProperties->scroll()->bounds());
2288 // Although overflow: hidden is programmatically scrollable, it is not user sc rollable. 2326 // Although overflow: hidden is programmatically scrollable, it is not user
2327 // scrollable.
2289 EXPECT_FALSE( 2328 EXPECT_FALSE(
2290 overflowHiddenScrollProperties->scroll()->userScrollableHorizontal()); 2329 overflowHiddenScrollProperties->scroll()->userScrollableHorizontal());
2291 EXPECT_FALSE( 2330 EXPECT_FALSE(
2292 overflowHiddenScrollProperties->scroll()->userScrollableVertical()); 2331 overflowHiddenScrollProperties->scroll()->userScrollableVertical());
2293 } 2332 }
2294 2333
2295 TEST_P(PaintPropertyTreeBuilderTest, NestedScrollProperties) { 2334 TEST_P(PaintPropertyTreeBuilderTest, NestedScrollProperties) {
2296 setBodyInnerHTML( 2335 setBodyInnerHTML(
2297 "<style>" 2336 "<style>"
2298 " * {" 2337 " * {"
(...skipping 22 matching lines...) Expand all
2321 2360
2322 Element* overflowA = document().getElementById("overflowA"); 2361 Element* overflowA = document().getElementById("overflowA");
2323 overflowA->setScrollTop(37); 2362 overflowA->setScrollTop(37);
2324 Element* overflowB = document().getElementById("overflowB"); 2363 Element* overflowB = document().getElementById("overflowB");
2325 overflowB->setScrollTop(41); 2364 overflowB->setScrollTop(41);
2326 2365
2327 document().view()->updateAllLifecyclePhases(); 2366 document().view()->updateAllLifecyclePhases();
2328 2367
2329 const ObjectPaintProperties* overflowAScrollProperties = 2368 const ObjectPaintProperties* overflowAScrollProperties =
2330 overflowA->layoutObject()->objectPaintProperties(); 2369 overflowA->layoutObject()->objectPaintProperties();
2331 // Because the frameView is does not scroll, overflowA's scroll should be unde r the root. 2370 // Because the frameView is does not scroll, overflowA's scroll should be
2371 // under the root.
2332 EXPECT_TRUE(overflowAScrollProperties->scroll()->parent()->isRoot()); 2372 EXPECT_TRUE(overflowAScrollProperties->scroll()->parent()->isRoot());
2333 EXPECT_EQ( 2373 EXPECT_EQ(
2334 TransformationMatrix().translate(0, -37), 2374 TransformationMatrix().translate(0, -37),
2335 overflowAScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); 2375 overflowAScrollProperties->scroll()->scrollOffsetTranslation()->matrix());
2336 EXPECT_EQ(IntSize(5, 3), overflowAScrollProperties->scroll()->clip()); 2376 EXPECT_EQ(IntSize(5, 3), overflowAScrollProperties->scroll()->clip());
2337 // 107 is the forceScroll element plus the height of the overflow scroll child (overflowB). 2377 // 107 is the forceScroll element plus the height of the overflow scroll child
2378 // (overflowB).
2338 EXPECT_EQ(IntSize(9, 107), overflowAScrollProperties->scroll()->bounds()); 2379 EXPECT_EQ(IntSize(9, 107), overflowAScrollProperties->scroll()->bounds());
2339 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableHorizontal()); 2380 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableHorizontal());
2340 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableVertical()); 2381 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableVertical());
2341 2382
2342 const ObjectPaintProperties* overflowBScrollProperties = 2383 const ObjectPaintProperties* overflowBScrollProperties =
2343 overflowB->layoutObject()->objectPaintProperties(); 2384 overflowB->layoutObject()->objectPaintProperties();
2344 // The overflow child's scroll node should be a child of the parent's (overflo wA) scroll node. 2385 // The overflow child's scroll node should be a child of the parent's
2386 // (overflowA) scroll node.
2345 EXPECT_EQ(overflowAScrollProperties->scroll(), 2387 EXPECT_EQ(overflowAScrollProperties->scroll(),
2346 overflowBScrollProperties->scroll()->parent()); 2388 overflowBScrollProperties->scroll()->parent());
2347 EXPECT_EQ( 2389 EXPECT_EQ(
2348 TransformationMatrix().translate(0, -41), 2390 TransformationMatrix().translate(0, -41),
2349 overflowBScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); 2391 overflowBScrollProperties->scroll()->scrollOffsetTranslation()->matrix());
2350 EXPECT_EQ(IntSize(9, 7), overflowBScrollProperties->scroll()->clip()); 2392 EXPECT_EQ(IntSize(9, 7), overflowBScrollProperties->scroll()->clip());
2351 EXPECT_EQ(IntSize(9, 100), overflowBScrollProperties->scroll()->bounds()); 2393 EXPECT_EQ(IntSize(9, 100), overflowBScrollProperties->scroll()->bounds());
2352 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableHorizontal()); 2394 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableHorizontal());
2353 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableVertical()); 2395 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableVertical());
2354 } 2396 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2407 // The frame should scroll due to the "forceScroll" element. 2449 // The frame should scroll due to the "forceScroll" element.
2408 EXPECT_NE(nullptr, frameScroll()); 2450 EXPECT_NE(nullptr, frameScroll());
2409 2451
2410 const ObjectPaintProperties* overflowScrollProperties = 2452 const ObjectPaintProperties* overflowScrollProperties =
2411 overflow->layoutObject()->objectPaintProperties(); 2453 overflow->layoutObject()->objectPaintProperties();
2412 EXPECT_EQ(frameScroll(), overflowScrollProperties->scroll()->parent()); 2454 EXPECT_EQ(frameScroll(), overflowScrollProperties->scroll()->parent());
2413 EXPECT_EQ( 2455 EXPECT_EQ(
2414 TransformationMatrix().translate(0, -37), 2456 TransformationMatrix().translate(0, -37),
2415 overflowScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); 2457 overflowScrollProperties->scroll()->scrollOffsetTranslation()->matrix());
2416 EXPECT_EQ(IntSize(5, 3), overflowScrollProperties->scroll()->clip()); 2458 EXPECT_EQ(IntSize(5, 3), overflowScrollProperties->scroll()->clip());
2417 // The height should be 4000px because the (dom-order) overflow children are p ositioned and do not 2459 // The height should be 4000px because the (dom-order) overflow children are
2418 // contribute to the height. Only the 4000px "forceScroll" height is present. 2460 // positioned and do not contribute to the height. Only the 4000px
2461 // "forceScroll" height is present.
2419 EXPECT_EQ(IntSize(5, 4000), overflowScrollProperties->scroll()->bounds()); 2462 EXPECT_EQ(IntSize(5, 4000), overflowScrollProperties->scroll()->bounds());
2420 2463
2421 const ObjectPaintProperties* absposOverflowScrollProperties = 2464 const ObjectPaintProperties* absposOverflowScrollProperties =
2422 absposOverflow->layoutObject()->objectPaintProperties(); 2465 absposOverflow->layoutObject()->objectPaintProperties();
2423 // The absolute position overflow scroll node is parented under the frame, not the dom-order parent. 2466 // The absolute position overflow scroll node is parented under the frame, not
2467 // the dom-order parent.
2424 EXPECT_EQ(frameScroll(), absposOverflowScrollProperties->scroll()->parent()); 2468 EXPECT_EQ(frameScroll(), absposOverflowScrollProperties->scroll()->parent());
2425 EXPECT_EQ(TransformationMatrix().translate(0, -41), 2469 EXPECT_EQ(TransformationMatrix().translate(0, -41),
2426 absposOverflowScrollProperties->scroll() 2470 absposOverflowScrollProperties->scroll()
2427 ->scrollOffsetTranslation() 2471 ->scrollOffsetTranslation()
2428 ->matrix()); 2472 ->matrix());
2429 EXPECT_EQ(IntSize(9, 7), absposOverflowScrollProperties->scroll()->clip()); 2473 EXPECT_EQ(IntSize(9, 7), absposOverflowScrollProperties->scroll()->clip());
2430 EXPECT_EQ(IntSize(9, 4000), 2474 EXPECT_EQ(IntSize(9, 4000),
2431 absposOverflowScrollProperties->scroll()->bounds()); 2475 absposOverflowScrollProperties->scroll()->bounds());
2432 2476
2433 const ObjectPaintProperties* fixedOverflowScrollProperties = 2477 const ObjectPaintProperties* fixedOverflowScrollProperties =
2434 fixedOverflow->layoutObject()->objectPaintProperties(); 2478 fixedOverflow->layoutObject()->objectPaintProperties();
2435 // The fixed position overflow scroll node is parented under the root, not the dom-order parent or frame's scroll. 2479 // The fixed position overflow scroll node is parented under the root, not the
2480 // dom-order parent or frame's scroll.
2436 EXPECT_TRUE(fixedOverflowScrollProperties->scroll()->parent()->isRoot()); 2481 EXPECT_TRUE(fixedOverflowScrollProperties->scroll()->parent()->isRoot());
2437 EXPECT_EQ(TransformationMatrix().translate(0, -43), 2482 EXPECT_EQ(TransformationMatrix().translate(0, -43),
2438 fixedOverflowScrollProperties->scroll() 2483 fixedOverflowScrollProperties->scroll()
2439 ->scrollOffsetTranslation() 2484 ->scrollOffsetTranslation()
2440 ->matrix()); 2485 ->matrix());
2441 EXPECT_EQ(IntSize(13, 11), fixedOverflowScrollProperties->scroll()->clip()); 2486 EXPECT_EQ(IntSize(13, 11), fixedOverflowScrollProperties->scroll()->clip());
2442 EXPECT_EQ(IntSize(13, 4000), 2487 EXPECT_EQ(IntSize(13, 4000),
2443 fixedOverflowScrollProperties->scroll()->bounds()); 2488 fixedOverflowScrollProperties->scroll()->bounds());
2444 } 2489 }
2445 2490
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 2523
2479 Element* overflowA = document().getElementById("overflowA"); 2524 Element* overflowA = document().getElementById("overflowA");
2480 overflowA->setScrollTop(37); 2525 overflowA->setScrollTop(37);
2481 Element* overflowB = document().getElementById("overflowB"); 2526 Element* overflowB = document().getElementById("overflowB");
2482 overflowB->setScrollTop(41); 2527 overflowB->setScrollTop(41);
2483 2528
2484 document().view()->updateAllLifecyclePhases(); 2529 document().view()->updateAllLifecyclePhases();
2485 2530
2486 const ObjectPaintProperties* overflowAScrollProperties = 2531 const ObjectPaintProperties* overflowAScrollProperties =
2487 overflowA->layoutObject()->objectPaintProperties(); 2532 overflowA->layoutObject()->objectPaintProperties();
2488 // Because the frameView is does not scroll, overflowA's scroll should be unde r the root. 2533 // Because the frameView is does not scroll, overflowA's scroll should be
2534 // under the root.
2489 EXPECT_TRUE(overflowAScrollProperties->scroll()->parent()->isRoot()); 2535 EXPECT_TRUE(overflowAScrollProperties->scroll()->parent()->isRoot());
2490 EXPECT_EQ( 2536 EXPECT_EQ(
2491 TransformationMatrix().translate(0, -37), 2537 TransformationMatrix().translate(0, -37),
2492 overflowAScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); 2538 overflowAScrollProperties->scroll()->scrollOffsetTranslation()->matrix());
2493 EXPECT_EQ(IntSize(20, 20), overflowAScrollProperties->scroll()->clip()); 2539 EXPECT_EQ(IntSize(20, 20), overflowAScrollProperties->scroll()->clip());
2494 // 100 is the forceScroll element's height because the overflow child does not contribute to the height. 2540 // 100 is the forceScroll element's height because the overflow child does not
2541 // contribute to the height.
2495 EXPECT_EQ(IntSize(20, 100), overflowAScrollProperties->scroll()->bounds()); 2542 EXPECT_EQ(IntSize(20, 100), overflowAScrollProperties->scroll()->bounds());
2496 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableHorizontal()); 2543 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableHorizontal());
2497 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableVertical()); 2544 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableVertical());
2498 2545
2499 const ObjectPaintProperties* overflowBScrollProperties = 2546 const ObjectPaintProperties* overflowBScrollProperties =
2500 overflowB->layoutObject()->objectPaintProperties(); 2547 overflowB->layoutObject()->objectPaintProperties();
2501 // The overflow child's scroll node should be a child of the parent's (overflo wA) scroll node. 2548 // The overflow child's scroll node should be a child of the parent's
2549 // (overflowA) scroll node.
2502 EXPECT_EQ(overflowAScrollProperties->scroll(), 2550 EXPECT_EQ(overflowAScrollProperties->scroll(),
2503 overflowBScrollProperties->scroll()->parent()); 2551 overflowBScrollProperties->scroll()->parent());
2504 EXPECT_EQ( 2552 EXPECT_EQ(
2505 TransformationMatrix().translate(0, -41), 2553 TransformationMatrix().translate(0, -41),
2506 overflowBScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); 2554 overflowBScrollProperties->scroll()->scrollOffsetTranslation()->matrix());
2507 EXPECT_EQ(IntSize(5, 3), overflowBScrollProperties->scroll()->clip()); 2555 EXPECT_EQ(IntSize(5, 3), overflowBScrollProperties->scroll()->clip());
2508 EXPECT_EQ(IntSize(5, 100), overflowBScrollProperties->scroll()->bounds()); 2556 EXPECT_EQ(IntSize(5, 100), overflowBScrollProperties->scroll()->bounds());
2509 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableHorizontal()); 2557 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableHorizontal());
2510 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableVertical()); 2558 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableVertical());
2511 } 2559 }
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
2733 EXPECT_FALSE( 2781 EXPECT_FALSE(
2734 overflowB->layoutObject() 2782 overflowB->layoutObject()
2735 ->objectPaintProperties() 2783 ->objectPaintProperties()
2736 ->scroll() 2784 ->scroll()
2737 ->parent() 2785 ->parent()
2738 ->hasMainThreadScrollingReasons( 2786 ->hasMainThreadScrollingReasons(
2739 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); 2787 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects));
2740 } 2788 }
2741 2789
2742 } // namespace blink 2790 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698