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

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

Issue 2570423003: Remove paintOffsetTranslation for fixed-position elements. (Closed)
Patch Set: none Created 3 years, 11 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/paint/PaintPropertyTreeBuilderTest.h" 5 #include "core/paint/PaintPropertyTreeBuilderTest.h"
6 6
7 #include "core/html/HTMLIFrameElement.h" 7 #include "core/html/HTMLIFrameElement.h"
8 #include "core/layout/LayoutTreeAsText.h" 8 #include "core/layout/LayoutTreeAsText.h"
9 #include "core/paint/ObjectPaintProperties.h" 9 #include "core/paint/ObjectPaintProperties.h"
10 #include "core/paint/PaintPropertyTreePrinter.h" 10 #include "core/paint/PaintPropertyTreePrinter.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 FrameView* frameView = document().view(); 134 FrameView* frameView = document().view();
135 frameView->updateAllLifecyclePhases(); 135 frameView->updateAllLifecyclePhases();
136 136
137 // target1 is a fixed-position element inside an absolute-position scrolling 137 // target1 is a fixed-position element inside an absolute-position scrolling
138 // element. It should be attached under the viewport to skip scrolling and 138 // element. It should be attached under the viewport to skip scrolling and
139 // offset of the parent. 139 // offset of the parent.
140 Element* target1 = document().getElementById("target1"); 140 Element* target1 = document().getElementById("target1");
141 const ObjectPaintProperties* target1Properties = 141 const ObjectPaintProperties* target1Properties =
142 target1->layoutObject()->paintProperties(); 142 target1->layoutObject()->paintProperties();
143 EXPECT_EQ(TransformationMatrix().translate(200, 150), 143 EXPECT_EQ(FloatRoundedRect(200, 150, 100, 100),
144 target1Properties->paintOffsetTranslation()->matrix());
145 EXPECT_EQ(framePreTranslation(),
146 target1Properties->paintOffsetTranslation()->parent());
147 EXPECT_EQ(target1Properties->paintOffsetTranslation(),
148 target1Properties->overflowClip()->localTransformSpace());
149 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100),
150 target1Properties->overflowClip()->clipRect()); 144 target1Properties->overflowClip()->clipRect());
151 // Likewise, it inherits clip from the viewport, skipping overflow clip of the 145 // Likewise, it inherits clip from the viewport, skipping overflow clip of the
152 // scroller. 146 // scroller.
153 EXPECT_EQ(frameContentClip(), target1Properties->overflowClip()->parent()); 147 EXPECT_EQ(frameContentClip(), target1Properties->overflowClip()->parent());
154 // target1 should not have it's own scroll node and instead should inherit 148 // target1 should not have its own scroll node and instead should inherit
155 // positionedScroll's. 149 // positionedScroll's.
156 const ObjectPaintProperties* positionedScrollProperties = 150 const ObjectPaintProperties* positionedScrollProperties =
157 positionedScroll->layoutObject()->paintProperties(); 151 positionedScroll->layoutObject()->paintProperties();
158 EXPECT_TRUE(positionedScrollProperties->scroll()->parent()->isRoot()); 152 EXPECT_TRUE(positionedScrollProperties->scroll()->parent()->isRoot());
159 EXPECT_EQ(TransformationMatrix().translate(0, -3), 153 EXPECT_EQ(TransformationMatrix().translate(0, -3),
160 positionedScrollProperties->scroll() 154 positionedScrollProperties->scroll()
161 ->scrollOffsetTranslation() 155 ->scrollOffsetTranslation()
162 ->matrix()); 156 ->matrix());
163 EXPECT_EQ(nullptr, target1Properties->scroll()); 157 EXPECT_EQ(nullptr, target1Properties->scroll());
164
165 CHECK_EXACT_VISUAL_RECT(LayoutRect(200, 150, 100, 100), 158 CHECK_EXACT_VISUAL_RECT(LayoutRect(200, 150, 100, 100),
166 target1->layoutObject(), frameView->layoutView()); 159 target1->layoutObject(), frameView->layoutView());
167 160
168 // target2 is a fixed-position element inside a transformed scrolling element. 161 // target2 is a fixed-position element inside a transformed scrolling element.
169 // It should be attached under the scrolled box of the transformed element. 162 // It should be attached under the scrolled box of the transformed element.
170 Element* target2 = document().getElementById("target2"); 163 Element* target2 = document().getElementById("target2");
171 const ObjectPaintProperties* target2Properties = 164 const ObjectPaintProperties* target2Properties =
172 target2->layoutObject()->paintProperties(); 165 target2->layoutObject()->paintProperties();
173 Element* scroller = document().getElementById("transformedScroll"); 166 Element* scroller = document().getElementById("transformedScroll");
174 const ObjectPaintProperties* scrollerProperties = 167 const ObjectPaintProperties* scrollerProperties =
175 scroller->layoutObject()->paintProperties(); 168 scroller->layoutObject()->paintProperties();
176 EXPECT_EQ(TransformationMatrix().translate(200, 150), 169 EXPECT_EQ(FloatRoundedRect(200, 150, 100, 100),
177 target2Properties->paintOffsetTranslation()->matrix());
178 EXPECT_EQ(scrollerProperties->scrollTranslation(),
179 target2Properties->paintOffsetTranslation()->parent());
180 EXPECT_EQ(target2Properties->paintOffsetTranslation(),
181 target2Properties->overflowClip()->localTransformSpace());
182 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100),
183 target2Properties->overflowClip()->clipRect()); 170 target2Properties->overflowClip()->clipRect());
184 EXPECT_EQ(scrollerProperties->overflowClip(), 171 EXPECT_EQ(scrollerProperties->overflowClip(),
185 target2Properties->overflowClip()->parent()); 172 target2Properties->overflowClip()->parent());
186 // target2 should not have it's own scroll node and instead should inherit 173 // target2 should not have it's own scroll node and instead should inherit
187 // transformedScroll's. 174 // transformedScroll's.
188 const ObjectPaintProperties* transformedScrollProperties = 175 const ObjectPaintProperties* transformedScrollProperties =
189 transformedScroll->layoutObject()->paintProperties(); 176 transformedScroll->layoutObject()->paintProperties();
190 EXPECT_TRUE(transformedScrollProperties->scroll()->parent()->isRoot()); 177 EXPECT_TRUE(transformedScrollProperties->scroll()->parent()->isRoot());
191 EXPECT_EQ(TransformationMatrix().translate(0, -5), 178 EXPECT_EQ(TransformationMatrix().translate(0, -5),
192 transformedScrollProperties->scroll() 179 transformedScrollProperties->scroll()
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 const ObjectPaintProperties* containerProperties = 1029 const ObjectPaintProperties* containerProperties =
1043 container.paintProperties(); 1030 container.paintProperties();
1044 EXPECT_EQ(TransformationMatrix().translate(20, 30), 1031 EXPECT_EQ(TransformationMatrix().translate(20, 30),
1045 containerProperties->transform()->matrix()); 1032 containerProperties->transform()->matrix());
1046 EXPECT_EQ(svgProperties->transform(), 1033 EXPECT_EQ(svgProperties->transform(),
1047 containerProperties->transform()->parent()); 1034 containerProperties->transform()->parent());
1048 1035
1049 Element* fixed = document().getElementById("fixed"); 1036 Element* fixed = document().getElementById("fixed");
1050 const ObjectPaintProperties* fixedProperties = 1037 const ObjectPaintProperties* fixedProperties =
1051 fixed->layoutObject()->paintProperties(); 1038 fixed->layoutObject()->paintProperties();
1052 EXPECT_EQ(TransformationMatrix().translate(200, 150),
1053 fixedProperties->paintOffsetTranslation()->matrix());
1054 // Ensure the fixed position element is rooted at the nearest transform 1039 // Ensure the fixed position element is rooted at the nearest transform
1055 // container. 1040 // container.
1056 EXPECT_EQ(containerProperties->transform(), 1041 EXPECT_EQ(containerProperties->transform(),
1057 fixedProperties->paintOffsetTranslation()->parent()); 1042 fixedProperties->localBorderBoxProperties()
1043 ->propertyTreeState.transform());
1058 } 1044 }
1059 1045
1060 TEST_P(PaintPropertyTreeBuilderTest, ControlClip) { 1046 TEST_P(PaintPropertyTreeBuilderTest, ControlClip) {
1061 setBodyInnerHTML( 1047 setBodyInnerHTML(
1062 "<style>" 1048 "<style>"
1063 " body {" 1049 " body {"
1064 " margin: 0;" 1050 " margin: 0;"
1065 " }" 1051 " }"
1066 " input {" 1052 " input {"
1067 " border-width: 5px;" 1053 " border-width: 5px;"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() 1426 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace()
1441 // doesn't apply css clip on the object itself. 1427 // doesn't apply css clip on the object itself.
1442 LayoutUnit::max()); 1428 LayoutUnit::max());
1443 1429
1444 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); 1430 LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
1445 const ObjectPaintProperties* fixedProperties = fixed->paintProperties(); 1431 const ObjectPaintProperties* fixedProperties = fixed->paintProperties();
1446 EXPECT_EQ( 1432 EXPECT_EQ(
1447 clipProperties->cssClip(), 1433 clipProperties->cssClip(),
1448 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); 1434 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip());
1449 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() 1435 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties()
1450 ->propertyTreeState.transform() 1436 ->propertyTreeState.transform());
1451 ->parent()); 1437 EXPECT_EQ(LayoutPoint(654, 321),
1452 EXPECT_EQ(TransformationMatrix().translate(654, 321),
1453 fixedProperties->localBorderBoxProperties()
1454 ->propertyTreeState.transform()
1455 ->matrix());
1456 EXPECT_EQ(LayoutPoint(),
1457 fixedProperties->localBorderBoxProperties()->paintOffset); 1438 fixedProperties->localBorderBoxProperties()->paintOffset);
1458 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(), 1439 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(),
1459 // TODO(crbug.com/599939): CSS clip of fixed-position 1440 // TODO(crbug.com/599939): CSS clip of fixed-position
1460 // descendants is broken in 1441 // descendants is broken in
1461 // mapToVisualRectInAncestorSpace(). 1442 // mapToVisualRectInAncestorSpace().
1462 LayoutUnit::max()); 1443 LayoutUnit::max());
1463 } 1444 }
1464 1445
1465 TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) { 1446 TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) {
1466 // This test verifies that clip tree hierarchy being generated correctly for 1447 // This test verifies that clip tree hierarchy being generated correctly for
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), 1563 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)),
1583 clipProperties->cssClipFixedPosition()->clipRect()); 1564 clipProperties->cssClipFixedPosition()->clipRect());
1584 CHECK_EXACT_VISUAL_RECT(LayoutRect(), clip, document().view()->layoutView()); 1565 CHECK_EXACT_VISUAL_RECT(LayoutRect(), clip, document().view()->layoutView());
1585 1566
1586 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); 1567 LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
1587 const ObjectPaintProperties* fixedProperties = fixed->paintProperties(); 1568 const ObjectPaintProperties* fixedProperties = fixed->paintProperties();
1588 EXPECT_EQ( 1569 EXPECT_EQ(
1589 clipProperties->cssClipFixedPosition(), 1570 clipProperties->cssClipFixedPosition(),
1590 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); 1571 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip());
1591 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() 1572 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties()
1592 ->propertyTreeState.transform() 1573 ->propertyTreeState.transform());
1593 ->parent()); 1574 EXPECT_EQ(LayoutPoint(654, 321),
1594 EXPECT_EQ(TransformationMatrix().translate(654, 321),
1595 fixedProperties->localBorderBoxProperties()
1596 ->propertyTreeState.transform()
1597 ->matrix());
1598 EXPECT_EQ(LayoutPoint(),
1599 fixedProperties->localBorderBoxProperties()->paintOffset); 1575 fixedProperties->localBorderBoxProperties()->paintOffset);
1600 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(), 1576 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(),
1601 // TODO(crbug.com/599939): CSS clip of fixed-position 1577 // TODO(crbug.com/599939): CSS clip of fixed-position
1602 // descendants is broken in geometry mapping. 1578 // descendants is broken in geometry mapping.
1603 LayoutUnit::max()); 1579 LayoutUnit::max());
1604 } 1580 }
1605 1581
1606 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) { 1582 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) {
1607 setBodyInnerHTML( 1583 setBodyInnerHTML(
1608 "<style>" 1584 "<style>"
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
3071 EXPECT_TRUE(filterProperties->effect()->parent()->isRoot()); 3047 EXPECT_TRUE(filterProperties->effect()->parent()->isRoot());
3072 EXPECT_EQ(frameScrollTranslation(), 3048 EXPECT_EQ(frameScrollTranslation(),
3073 filterProperties->effect()->localTransformSpace()); 3049 filterProperties->effect()->localTransformSpace());
3074 EXPECT_EQ(clipProperties->overflowClip(), 3050 EXPECT_EQ(clipProperties->overflowClip(),
3075 filterProperties->effect()->outputClip()); 3051 filterProperties->effect()->outputClip());
3076 3052
3077 const ObjectPaintProperties* childProperties = 3053 const ObjectPaintProperties* childProperties =
3078 getLayoutObjectByElementId("child")->paintProperties(); 3054 getLayoutObjectByElementId("child")->paintProperties();
3079 const PropertyTreeState& childPaintState = 3055 const PropertyTreeState& childPaintState =
3080 childProperties->localBorderBoxProperties()->propertyTreeState; 3056 childProperties->localBorderBoxProperties()->propertyTreeState;
3081 EXPECT_EQ(framePreTranslation(), 3057
3082 childProperties->paintOffsetTranslation()->parent());
3083 EXPECT_EQ(childProperties->paintOffsetTranslation(),
3084 childPaintState.transform());
3085 // This will change once we added clip expansion node. 3058 // This will change once we added clip expansion node.
3086 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); 3059 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip());
3087 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); 3060 EXPECT_EQ(filterProperties->effect(), childPaintState.effect());
3088 } 3061 }
3089 3062
3090 TEST_P(PaintPropertyTreeBuilderTest, TransformOriginWithAndWithoutTransform) { 3063 TEST_P(PaintPropertyTreeBuilderTest, TransformOriginWithAndWithoutTransform) {
3091 setBodyInnerHTML( 3064 setBodyInnerHTML(
3092 "<style>" 3065 "<style>"
3093 " body { margin: 0 }" 3066 " body { margin: 0 }"
3094 " div {" 3067 " div {"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
3177 toElement(ancestor->node()) 3150 toElement(ancestor->node())
3178 ->setAttribute(HTMLNames::styleAttr, "position: static"); 3151 ->setAttribute(HTMLNames::styleAttr, "position: static");
3179 document().view()->updateAllLifecyclePhases(); 3152 document().view()->updateAllLifecyclePhases();
3180 EXPECT_NE(ancestor->paintProperties()->overflowClip(), 3153 EXPECT_NE(ancestor->paintProperties()->overflowClip(),
3181 descendant->paintProperties() 3154 descendant->paintProperties()
3182 ->localBorderBoxProperties() 3155 ->localBorderBoxProperties()
3183 ->propertyTreeState.clip()); 3156 ->propertyTreeState.clip());
3184 } 3157 }
3185 3158
3186 } // namespace blink 3159 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698