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

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

Issue 1829493002: [SPv2] Implement CSS clip property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change argument order & add unit tests Created 4 years, 9 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 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 ); 712 );
713 713
714 FrameView* frameView = document().view(); 714 FrameView* frameView = document().view();
715 LayoutObject& target = *document().getElementById("target")->layoutObject(); 715 LayoutObject& target = *document().getElementById("target")->layoutObject();
716 ObjectPaintProperties* targetProperties = target.objectPaintProperties(); 716 ObjectPaintProperties* targetProperties = target.objectPaintProperties();
717 717
718 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties( )->paintOffset); 718 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties( )->paintOffset);
719 EXPECT_EQ(frameView->scrollTranslation(), targetProperties->localBorderBoxPr operties()->transform); 719 EXPECT_EQ(frameView->scrollTranslation(), targetProperties->localBorderBoxPr operties()->transform);
720 } 720 }
721 721
722 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant)
723 {
724 // This test verifies that clip tree hierarchy being generated correctly for the hard case
725 // such that a fixed position element getting clipped by an absolute positio n CSS clip.
726 setBodyInnerHTML(
727 "<style>"
728 " #clip {"
729 " position: absolute;"
730 " left: 123px;"
731 " top: 456px;"
732 " clip: rect(10px, 80px, 70px, 40px);"
733 " width: 100px;"
734 " height: 100px;"
735 " }"
736 " #fixed {"
737 " position: fixed;"
738 " left: 654px;"
739 " top: 321px;"
740 " }"
741 "</style>"
742 "<div id='clip'><div id='fixed'></div></div>"
743 );
744 LayoutRect localClipRect(40, 10, 40, 60);
745 LayoutRect absoluteClipRect = localClipRect;
746 absoluteClipRect.move(123, 456);
747
748 FrameView* frameView = document().view();
749
750 LayoutObject& clip = *document().getElementById("clip")->layoutObject();
751 ObjectPaintProperties* clipProperties = clip.objectPaintProperties();
752 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent());
753 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr ansformSpace());
754 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css Clip()->clipRect());
755
756 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject();
757 ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties();
758 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti es()->clip);
759 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper ties()->transform->parent());
760 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local BorderBoxProperties()->transform->matrix());
761 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO ffset);
762 }
763
764 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared)
765 {
766 // This test is similar to CSSClipFixedPositionDescendant above, except that
767 // now we have a parent overflow clip that should be escaped by the fixed de scendant.
768 setBodyInnerHTML(
769 "<style>"
770 " body {"
771 " margin: 0;"
772 " }"
773 " #overflow {"
774 " position: relative;"
775 " width: 50px;"
776 " height: 50px;"
777 " overflow: scroll;"
778 " }"
779 " #clip {"
780 " position: absolute;"
781 " left: 123px;"
782 " top: 456px;"
783 " clip: rect(10px, 80px, 70px, 40px);"
784 " width: 100px;"
785 " height: 100px;"
786 " }"
787 " #fixed {"
788 " position: fixed;"
789 " left: 654px;"
790 " top: 321px;"
791 " }"
792 "</style>"
793 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>"
794 );
795 LayoutRect localClipRect(40, 10, 40, 60);
796 LayoutRect absoluteClipRect = localClipRect;
797 absoluteClipRect.move(123, 456);
798
799 FrameView* frameView = document().view();
800
801 LayoutObject& overflow = *document().getElementById("overflow")->layoutObjec t();
802 ObjectPaintProperties* overflowProperties = overflow.objectPaintProperties() ;
803 EXPECT_EQ(frameView->contentClip(), overflowProperties->overflowClip()->pare nt());
804 EXPECT_EQ(frameView->scrollTranslation(), overflowProperties->scrollTranslat ion()->parent());
805
806 LayoutObject& clip = *document().getElementById("clip")->layoutObject();
807 ObjectPaintProperties* clipProperties = clip.objectPaintProperties();
808 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par ent());
809 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClip() ->localTransformSpace());
810 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css Clip()->clipRect());
811 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClipFixedPosition()-> parent());
812 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClipFi xedPosition()->localTransformSpace());
813 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css ClipFixedPosition()->clipRect());
814
815 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject();
816 ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties();
817 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord erBoxProperties()->clip);
818 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper ties()->transform->parent());
819 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local BorderBoxProperties()->transform->matrix());
820 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO ffset);
821 }
822
722 } // namespace blink 823 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698