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

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

Issue 1865093004: Add a transform paint property for local SVG transforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dcheck that SVG does not scroll and describe it in a comment Created 4 years, 8 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/LayoutView.h" 7 #include "core/layout/LayoutView.h"
8 #include "core/paint/ObjectPaintProperties.h" 8 #include "core/paint/ObjectPaintProperties.h"
9 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 9 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
10 #include "platform/testing/UnitTestHelpers.h" 10 #include "platform/testing/UnitTestHelpers.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 EXPECT_EQ(TransformationMatrix().translate(70, 25), svgRootWith3dTransformPr operties->paintOffsetTranslation()->matrix()); 410 EXPECT_EQ(TransformationMatrix().translate(70, 25), svgRootWith3dTransformPr operties->paintOffsetTranslation()->matrix());
411 EXPECT_EQ(document().view()->scrollTranslation(), svgRootWith3dTransformProp erties->paintOffsetTranslation()->parent()); 411 EXPECT_EQ(document().view()->scrollTranslation(), svgRootWith3dTransformProp erties->paintOffsetTranslation()->parent());
412 412
413 LayoutObject& rectWith2dTransform = *document().getElementById("rectWith2dTr ansform")->layoutObject(); 413 LayoutObject& rectWith2dTransform = *document().getElementById("rectWith2dTr ansform")->layoutObject();
414 ObjectPaintProperties* rectWith2dTransformProperties = rectWith2dTransform.o bjectPaintProperties(); 414 ObjectPaintProperties* rectWith2dTransformProperties = rectWith2dTransform.o bjectPaintProperties();
415 TransformationMatrix matrix; 415 TransformationMatrix matrix;
416 matrix.translate(100, 100); 416 matrix.translate(100, 100);
417 matrix.rotate(45); 417 matrix.rotate(45);
418 // SVG's transform origin is baked into the transform. 418 // SVG's transform origin is baked into the transform.
419 matrix.applyTransformOrigin(50, 25, 0); 419 matrix.applyTransformOrigin(50, 25, 0);
420 EXPECT_EQ(matrix, rectWith2dTransformProperties->transform()->matrix()); 420 EXPECT_EQ(matrix, rectWith2dTransformProperties->svgLocalTransform()->matrix ());
421 EXPECT_EQ(FloatPoint3D(0, 0, 0), rectWith2dTransformProperties->transform()- >origin()); 421 EXPECT_EQ(FloatPoint3D(0, 0, 0), rectWith2dTransformProperties->svgLocalTran sform()->origin());
422 // SVG does not use paint offset. 422 // SVG does not use paint offset.
423 EXPECT_EQ(nullptr, rectWith2dTransformProperties->paintOffsetTranslation()); 423 EXPECT_EQ(nullptr, rectWith2dTransformProperties->paintOffsetTranslation());
424 } 424 }
425 425
426 TEST_F(PaintPropertyTreeBuilderTest, SVGViewBoxTransform)
427 {
428 setBodyInnerHTML(
429 "<style>"
430 " body {"
431 " margin: 0px;"
432 " }"
433 " svg {"
434 " transform: translate3d(1px, 2px, 3px);"
435 " position: absolute;"
436 " }"
437 " rect {"
438 " transform: translate(100px, 100px);"
439 " }"
440 "</style>"
441 "<svg id='svgWithViewBox' width='100px' height='100px' viewBox='50 50 10 0 100'>"
442 " <rect id='rect' width='100px' height='100px' />"
443 "</svg>");
444
445 LayoutObject& svgWithViewBox = *document().getElementById("svgWithViewBox")- >layoutObject();
446 ObjectPaintProperties* svgWithViewBoxProperties = svgWithViewBox.objectPaint Properties();
447 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithViewBoxPropert ies->transform()->matrix());
448 EXPECT_EQ(TransformationMatrix().translate(-50, -50), svgWithViewBoxProperti es->svgLocalTransform()->matrix());
449 EXPECT_EQ(svgWithViewBoxProperties->svgLocalTransform()->parent(), svgWithVi ewBoxProperties->transform());
450
451 LayoutObject& rect = *document().getElementById("rect")->layoutObject();
452 ObjectPaintProperties* rectProperties = rect.objectPaintProperties();
453 EXPECT_EQ(TransformationMatrix().translate(100, 100), rectProperties->svgLoc alTransform()->matrix());
454 EXPECT_EQ(svgWithViewBoxProperties->svgLocalTransform(), rectProperties->svg LocalTransform()->parent());
455 }
456
426 TEST_F(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode) 457 TEST_F(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode)
427 { 458 {
428 setBodyInnerHTML( 459 setBodyInnerHTML(
429 "<style>body { margin: 0px; } </style>" 460 "<style>body { margin: 0px; } </style>"
430 "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px; height: 100px;' />"); 461 "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px; height: 100px;' />");
431 462
432 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); 463 LayoutObject& svg = *document().getElementById("svg")->layoutObject();
433 ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); 464 ObjectPaintProperties* svgProperties = svg.objectPaintProperties();
434 // Ensure that a paint offset transform is emitted for SVG, even without a C SS transform. 465 // Ensure that a paint offset transform is emitted for SVG, even without a C SS transform.
435 EXPECT_EQ(nullptr, svgProperties->transform()); 466 EXPECT_EQ(nullptr, svgProperties->transform());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 " </foreignObject>" 504 " </foreignObject>"
474 " </g>" 505 " </g>"
475 "</svg>"); 506 "</svg>");
476 507
477 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); 508 LayoutObject& svg = *document().getElementById("svg")->layoutObject();
478 ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); 509 ObjectPaintProperties* svgProperties = svg.objectPaintProperties();
479 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgProperties->transf orm()->matrix()); 510 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgProperties->transf orm()->matrix());
480 511
481 LayoutObject& container = *document().getElementById("container")->layoutObj ect(); 512 LayoutObject& container = *document().getElementById("container")->layoutObj ect();
482 ObjectPaintProperties* containerProperties = container.objectPaintProperties (); 513 ObjectPaintProperties* containerProperties = container.objectPaintProperties ();
483 EXPECT_EQ(TransformationMatrix().translate(20, 30), containerProperties->tra nsform()->matrix()); 514 EXPECT_EQ(TransformationMatrix().translate(20, 30), containerProperties->svg LocalTransform()->matrix());
484 EXPECT_EQ(svgProperties->transform(), containerProperties->transform()->pare nt()); 515 EXPECT_EQ(svgProperties->transform(), containerProperties->svgLocalTransform ()->parent());
485 516
486 Element* fixed = document().getElementById("fixed"); 517 Element* fixed = document().getElementById("fixed");
487 ObjectPaintProperties* fixedProperties = fixed->layoutObject()->objectPaintP roperties(); 518 ObjectPaintProperties* fixedProperties = fixed->layoutObject()->objectPaintP roperties();
488 EXPECT_EQ(TransformationMatrix().translate(200, 150), fixedProperties->paint OffsetTranslation()->matrix()); 519 EXPECT_EQ(TransformationMatrix().translate(200, 150), fixedProperties->paint OffsetTranslation()->matrix());
489 // Ensure the fixed position element is rooted at the nearest transform cont ainer. 520 // Ensure the fixed position element is rooted at the nearest transform cont ainer.
490 EXPECT_EQ(containerProperties->transform(), fixedProperties->paintOffsetTran slation()->parent()); 521 EXPECT_EQ(containerProperties->svgLocalTransform(), fixedProperties->paintOf fsetTranslation()->parent());
491 } 522 }
492 523
493 TEST_F(PaintPropertyTreeBuilderTest, ControlClip) 524 TEST_F(PaintPropertyTreeBuilderTest, ControlClip)
494 { 525 {
495 setBodyInnerHTML( 526 setBodyInnerHTML(
496 "<style>" 527 "<style>"
497 " body {" 528 " body {"
498 " margin: 0;" 529 " margin: 0;"
499 " }" 530 " }"
500 " input {" 531 " input {"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 845
815 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); 846 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject();
816 ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties(); 847 ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties();
817 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord erBoxProperties()->clip); 848 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord erBoxProperties()->clip);
818 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper ties()->transform->parent()); 849 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper ties()->transform->parent());
819 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local BorderBoxProperties()->transform->matrix()); 850 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local BorderBoxProperties()->transform->matrix());
820 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO ffset); 851 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO ffset);
821 } 852 }
822 853
823 } // namespace blink 854 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698