| 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 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 LayoutRect absoluteClipRect = localClipRect; | 891 LayoutRect absoluteClipRect = localClipRect; |
| 892 absoluteClipRect.move(123, 456); | 892 absoluteClipRect.move(123, 456); |
| 893 | 893 |
| 894 FrameView* frameView = document().view(); | 894 FrameView* frameView = document().view(); |
| 895 | 895 |
| 896 LayoutObject* clip = document().getElementById("clip")->layoutObject(); | 896 LayoutObject* clip = document().getElementById("clip")->layoutObject(); |
| 897 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); | 897 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); |
| 898 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); | 898 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); |
| 899 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr
ansformSpace()); | 899 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr
ansformSpace()); |
| 900 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); | 900 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
| 901 // TODO(chrishtr): GeomeryMapper rports 40x60 size (i.e. including clip), wh
ereas the old code reports 100x100 (unclipped). | 901 // TODO(chrishtr): the old visual rect code is not able to apply CSS clip to fix
ed-position elements. |
| 902 // Fix. | 902 // CHECK_EXACT_VISUAL_RECT(clip, frameView->layoutView()); |
| 903 // CHECK_EXACT_VISUAL_RECT(clip, frameView->layoutView()); | |
| 904 | 903 |
| 905 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 904 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 906 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); | 905 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); |
| 907 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti
es()->propertyTreeState.clip); | 906 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti
es()->propertyTreeState.clip); |
| 908 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); | 907 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); |
| 909 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); | 908 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); |
| 910 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); | 909 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); |
| 911 CHECK_EXACT_VISUAL_RECT(fixed, frameView->layoutView()); | 910 CHECK_EXACT_VISUAL_RECT(fixed, frameView->layoutView()); |
| 912 } | 911 } |
| 913 | 912 |
| 913 TEST_F(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) |
| 914 { |
| 915 // This test verifies that clip tree hierarchy being generated correctly for
the hard case |
| 916 // such that a fixed position element getting clipped by an absolute positio
n CSS clip. |
| 917 setBodyInnerHTML( |
| 918 "<style>" |
| 919 " #clip {" |
| 920 " position: absolute;" |
| 921 " left: 123px;" |
| 922 " top: 456px;" |
| 923 " clip: rect(10px, 80px, 70px, 40px);" |
| 924 " width: 100px;" |
| 925 " height: 100px;" |
| 926 " }" |
| 927 " #abs {" |
| 928 " position: absolute;" |
| 929 " left: 654px;" |
| 930 " top: 321px;" |
| 931 " width: 10px;" |
| 932 " heght: 20px" |
| 933 " }" |
| 934 "</style>" |
| 935 "<div id='clip'><div id='absolute'></div></div>" |
| 936 ); |
| 937 LayoutRect localClipRect(40, 10, 40, 60); |
| 938 LayoutRect absoluteClipRect = localClipRect; |
| 939 absoluteClipRect.move(123, 456); |
| 940 |
| 941 FrameView* frameView = document().view(); |
| 942 |
| 943 LayoutObject* clip = document().getElementById("clip")->layoutObject(); |
| 944 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); |
| 945 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); |
| 946 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr
ansformSpace()); |
| 947 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
| 948 // TODO(chrishtr): the old visual rect code is not able to apply CSS clip to fix
ed-position elements. |
| 949 // CHECK_VISUAL_RECT(clip, frameView->layoutView()); |
| 950 |
| 951 LayoutObject* absolute = document().getElementById("absolute")->layoutObject
(); |
| 952 const ObjectPaintProperties* absPosProperties = absolute->objectPaintPropert
ies(); |
| 953 EXPECT_EQ(clipProperties->cssClip(), absPosProperties->localBorderBoxPropert
ies()->propertyTreeState.clip); |
| 954 EXPECT_EQ(frameView->preTranslation(), absPosProperties->localBorderBoxPrope
rties()->propertyTreeState.transform->parent()); |
| 955 EXPECT_EQ(LayoutPoint(123, 456), absPosProperties->localBorderBoxProperties(
)->paintOffset); |
| 956 CHECK_EXACT_VISUAL_RECT(absolute, frameView->layoutView()); |
| 957 } |
| 958 |
| 914 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) | 959 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) |
| 915 { | 960 { |
| 916 // This test is similar to CSSClipFixedPositionDescendant above, except that | 961 // This test is similar to CSSClipFixedPositionDescendant above, except that |
| 917 // now we have a parent overflow clip that should be escaped by the fixed de
scendant. | 962 // now we have a parent overflow clip that should be escaped by the fixed de
scendant. |
| 918 setBodyInnerHTML( | 963 setBodyInnerHTML( |
| 919 "<style>" | 964 "<style>" |
| 920 " body {" | 965 " body {" |
| 921 " margin: 0;" | 966 " margin: 0;" |
| 922 " }" | 967 " }" |
| 923 " #overflow {" | 968 " #overflow {" |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1489 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); | 1534 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); |
| 1490 EXPECT_EQ(cTransformNode, cProperties->transform()); | 1535 EXPECT_EQ(cTransformNode, cProperties->transform()); |
| 1491 EXPECT_EQ(bTransformNode, cTransformNode->parent()); | 1536 EXPECT_EQ(bTransformNode, cTransformNode->parent()); |
| 1492 | 1537 |
| 1493 CHECK_EXACT_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); | 1538 CHECK_EXACT_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); |
| 1494 CHECK_EXACT_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); | 1539 CHECK_EXACT_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); |
| 1495 CHECK_EXACT_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); | 1540 CHECK_EXACT_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); |
| 1496 } | 1541 } |
| 1497 | 1542 |
| 1498 } // namespace blink | 1543 } // namespace blink |
| OLD | NEW |