| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/LayoutTestHelper.h" | 5 #include "core/layout/LayoutTestHelper.h" |
| 6 #include "core/layout/LayoutTreeAsText.h" | 6 #include "core/layout/LayoutTreeAsText.h" |
| 7 #include "core/layout/api/LayoutViewItem.h" | 7 #include "core/layout/api/LayoutViewItem.h" |
| 8 #include "core/paint/ObjectPaintProperties.h" | 8 #include "core/paint/ObjectPaintProperties.h" |
| 9 #include "platform/graphics/paint/GeometryMapper.h" | 9 #include "platform/graphics/paint/GeometryMapper.h" |
| 10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 LayoutRect absoluteClipRect = localClipRect; | 887 LayoutRect absoluteClipRect = localClipRect; |
| 888 absoluteClipRect.move(123, 456); | 888 absoluteClipRect.move(123, 456); |
| 889 | 889 |
| 890 FrameView* frameView = document().view(); | 890 FrameView* frameView = document().view(); |
| 891 | 891 |
| 892 LayoutObject* clip = document().getElementById("clip")->layoutObject(); | 892 LayoutObject* clip = document().getElementById("clip")->layoutObject(); |
| 893 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); | 893 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); |
| 894 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); | 894 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); |
| 895 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr
ansformSpace()); | 895 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr
ansformSpace()); |
| 896 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); | 896 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
| 897 // TODO(chrishtr): GeomeryMapper rports 40x60 size (i.e. including clip), wh
ereas the old code reports 100x100 (unclipped). | 897 // TODO(chrishtr): the old visual rect code is not able to apply CSS clip to fix
ed-position elements. |
| 898 // Fix. | 898 // CHECK_VISUAL_RECT(clip, frameView->layoutView()); |
| 899 // CHECK_VISUAL_RECT(clip, frameView->layoutView()); | |
| 900 | 899 |
| 901 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 900 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 902 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); | 901 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); |
| 903 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti
es()->propertyTreeState.clip); | 902 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti
es()->propertyTreeState.clip); |
| 904 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); | 903 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); |
| 905 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); | 904 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); |
| 906 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); | 905 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); |
| 907 CHECK_VISUAL_RECT(fixed, frameView->layoutView()); | 906 CHECK_VISUAL_RECT(fixed, frameView->layoutView()); |
| 908 } | 907 } |
| 909 | 908 |
| 909 TEST_F(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) |
| 910 { |
| 911 // This test verifies that clip tree hierarchy being generated correctly for
the hard case |
| 912 // such that a fixed position element getting clipped by an absolute positio
n CSS clip. |
| 913 setBodyInnerHTML( |
| 914 "<style>" |
| 915 " #clip {" |
| 916 " position: absolute;" |
| 917 " left: 123px;" |
| 918 " top: 456px;" |
| 919 " clip: rect(10px, 80px, 70px, 40px);" |
| 920 " width: 100px;" |
| 921 " height: 100px;" |
| 922 " }" |
| 923 " #abs {" |
| 924 " position: absolute;" |
| 925 " left: 654px;" |
| 926 " top: 321px;" |
| 927 " width: 10px;" |
| 928 " heght: 20px" |
| 929 " }" |
| 930 "</style>" |
| 931 "<div id='clip'><div id='absolute'></div></div>" |
| 932 ); |
| 933 LayoutRect localClipRect(40, 10, 40, 60); |
| 934 LayoutRect absoluteClipRect = localClipRect; |
| 935 absoluteClipRect.move(123, 456); |
| 936 |
| 937 FrameView* frameView = document().view(); |
| 938 |
| 939 LayoutObject* clip = document().getElementById("clip")->layoutObject(); |
| 940 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); |
| 941 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); |
| 942 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr
ansformSpace()); |
| 943 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
| 944 // TODO(chrishtr): the old visual rect code is not able to apply CSS clip to fix
ed-position elements. |
| 945 // CHECK_VISUAL_RECT(clip, frameView->layoutView()); |
| 946 |
| 947 LayoutObject* absolute = document().getElementById("absolute")->layoutObject
(); |
| 948 const ObjectPaintProperties* absPosProperties = absolute->objectPaintPropert
ies(); |
| 949 EXPECT_EQ(clipProperties->cssClip(), absPosProperties->localBorderBoxPropert
ies()->propertyTreeState.clip); |
| 950 EXPECT_EQ(frameView->preTranslation(), absPosProperties->localBorderBoxPrope
rties()->propertyTreeState.transform->parent()); |
| 951 EXPECT_EQ(LayoutPoint(123, 456), absPosProperties->localBorderBoxProperties(
)->paintOffset); |
| 952 CHECK_VISUAL_RECT(absolute, frameView->layoutView()); |
| 953 } |
| 954 |
| 910 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) | 955 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) |
| 911 { | 956 { |
| 912 // This test is similar to CSSClipFixedPositionDescendant above, except that | 957 // This test is similar to CSSClipFixedPositionDescendant above, except that |
| 913 // now we have a parent overflow clip that should be escaped by the fixed de
scendant. | 958 // now we have a parent overflow clip that should be escaped by the fixed de
scendant. |
| 914 setBodyInnerHTML( | 959 setBodyInnerHTML( |
| 915 "<style>" | 960 "<style>" |
| 916 " body {" | 961 " body {" |
| 917 " margin: 0;" | 962 " margin: 0;" |
| 918 " }" | 963 " }" |
| 919 " #overflow {" | 964 " #overflow {" |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); | 1522 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); |
| 1478 EXPECT_EQ(cTransformNode, cProperties->transform()); | 1523 EXPECT_EQ(cTransformNode, cProperties->transform()); |
| 1479 EXPECT_EQ(bTransformNode, cTransformNode->parent()); | 1524 EXPECT_EQ(bTransformNode, cTransformNode->parent()); |
| 1480 | 1525 |
| 1481 CHECK_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); | 1526 CHECK_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); |
| 1482 CHECK_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); | 1527 CHECK_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); |
| 1483 CHECK_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); | 1528 CHECK_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); |
| 1484 } | 1529 } |
| 1485 | 1530 |
| 1486 } // namespace blink | 1531 } // namespace blink |
| OLD | NEW |