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

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

Issue 1791543005: InPrePaint document state and PrePaintTreeWalk class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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"
11 #include "platform/text/TextStream.h" 11 #include "platform/text/TextStream.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "wtf/HashMap.h" 13 #include "wtf/HashMap.h"
14 #include "wtf/Vector.h" 14 #include "wtf/Vector.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 class PaintPropertyTreeBuilderTest : public RenderingTest { 18 class PrePaintTreeWalkTest : public RenderingTest {
19 public: 19 public:
20 PaintPropertyTreeBuilderTest() 20 PrePaintTreeWalkTest()
21 : RenderingTest(SingleChildFrameLoaderClient::create()) 21 : RenderingTest(SingleChildFrameLoaderClient::create())
22 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled()) { } 22 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled()) { }
23 23
24 void loadTestData(const char* fileName) 24 void loadTestData(const char* fileName)
25 { 25 {
26 String fullPath = testing::blinkRootDir(); 26 String fullPath = testing::blinkRootDir();
27 fullPath.append("/Source/core/paint/test_data/"); 27 fullPath.append("/Source/core/paint/test_data/");
28 fullPath.append(fileName); 28 fullPath.append(fileName);
29 RefPtr<SharedBuffer> inputBuffer = testing::readFromFile(fullPath); 29 RefPtr<SharedBuffer> inputBuffer = testing::readFromFile(fullPath);
30 setBodyInnerHTML(String(inputBuffer->data(), inputBuffer->size())); 30 setBodyInnerHTML(String(inputBuffer->data(), inputBuffer->size()));
(...skipping 13 matching lines...) Expand all
44 { 44 {
45 RenderingTest::TearDown(); 45 RenderingTest::TearDown();
46 46
47 Settings::setMockScrollbarsEnabled(false); 47 Settings::setMockScrollbarsEnabled(false);
48 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain tV2Enabled); 48 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain tV2Enabled);
49 } 49 }
50 50
51 bool m_originalSlimmingPaintV2Enabled; 51 bool m_originalSlimmingPaintV2Enabled;
52 }; 52 };
53 53
54 TEST_F(PaintPropertyTreeBuilderTest, FixedPosition) 54 TEST_F(PrePaintTreeWalkTest, FixedPosition)
55 { 55 {
56 loadTestData("fixed-position.html"); 56 loadTestData("fixed-position.html");
57 57
58 FrameView* frameView = document().view(); 58 FrameView* frameView = document().view();
59 59
60 // target1 is a fixed-position element inside an absolute-position scrolling element. 60 // target1 is a fixed-position element inside an absolute-position scrolling element.
61 // It should be attached under the viewport to skip scrolling and offset of the parent. 61 // It should be attached under the viewport to skip scrolling and offset of the parent.
62 Element* target1 = document().getElementById("target1"); 62 Element* target1 = document().getElementById("target1");
63 ObjectPaintProperties* target1Properties = target1->layoutObject()->objectPa intProperties(); 63 ObjectPaintProperties* target1Properties = target1->layoutObject()->objectPa intProperties();
64 EXPECT_EQ(TransformationMatrix().translate(200, 150), target1Properties->pai ntOffsetTranslation()->matrix()); 64 EXPECT_EQ(TransformationMatrix().translate(200, 150), target1Properties->pai ntOffsetTranslation()->matrix());
65 EXPECT_EQ(frameView->preTranslation(), target1Properties->paintOffsetTransla tion()->parent()); 65 EXPECT_EQ(frameView->preTranslation(), target1Properties->paintOffsetTransla tion()->parent());
66 EXPECT_EQ(target1Properties->paintOffsetTranslation(), target1Properties->ov erflowClip()->localTransformSpace()); 66 EXPECT_EQ(target1Properties->paintOffsetTranslation(), target1Properties->ov erflowClip()->localTransformSpace());
67 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target1Properties->overflowClip( )->clipRect()); 67 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target1Properties->overflowClip( )->clipRect());
68 // Likewise, it inherits clip from the viewport, skipping overflow clip of t he scroller. 68 // Likewise, it inherits clip from the viewport, skipping overflow clip of t he scroller.
69 EXPECT_EQ(frameView->contentClip(), target1Properties->overflowClip()->paren t()); 69 EXPECT_EQ(frameView->contentClip(), target1Properties->overflowClip()->paren t());
70 70
71 // target2 is a fixed-position element inside a transformed scrolling elemen t. 71 // target2 is a fixed-position element inside a transformed scrolling elemen t.
72 // It should be attached under the scrolled box of the transformed element. 72 // It should be attached under the scrolled box of the transformed element.
73 Element* target2 = document().getElementById("target2"); 73 Element* target2 = document().getElementById("target2");
74 ObjectPaintProperties* target2Properties = target2->layoutObject()->objectPa intProperties(); 74 ObjectPaintProperties* target2Properties = target2->layoutObject()->objectPa intProperties();
75 Element* scroller = document().getElementById("scroller"); 75 Element* scroller = document().getElementById("scroller");
76 ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->object PaintProperties(); 76 ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->object PaintProperties();
77 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai ntOffsetTranslation()->matrix()); 77 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai ntOffsetTranslation()->matrix());
78 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO ffsetTranslation()->parent()); 78 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO ffsetTranslation()->parent());
79 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov erflowClip()->localTransformSpace()); 79 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov erflowClip()->localTransformSpace());
80 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip( )->clipRect()); 80 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip( )->clipRect());
81 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli p()->parent()); 81 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli p()->parent());
82 } 82 }
83 83
84 TEST_F(PaintPropertyTreeBuilderTest, PositionAndScroll) 84 TEST_F(PrePaintTreeWalkTest, PositionAndScroll)
85 { 85 {
86 loadTestData("position-and-scroll.html"); 86 loadTestData("position-and-scroll.html");
87 87
88 Element* scroller = document().getElementById("scroller"); 88 Element* scroller = document().getElementById("scroller");
89 scroller->scrollTo(0, 100); 89 scroller->scrollTo(0, 100);
90 FrameView* frameView = document().view(); 90 FrameView* frameView = document().view();
91 frameView->updateAllLifecyclePhases(); 91 frameView->updateAllLifecyclePhases();
92 ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->object PaintProperties(); 92 ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->object PaintProperties();
93 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr ollTranslation()->matrix()); 93 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr ollTranslation()->matrix());
94 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->scrollTranslat ion()->parent()); 94 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->scrollTranslat ion()->parent());
(...skipping 14 matching lines...) Expand all
109 // The absolute-positioned element should not be affected by non-positioned scroller at all. 109 // The absolute-positioned element should not be affected by non-positioned scroller at all.
110 Element* absPos = document().getElementById("abs-pos"); 110 Element* absPos = document().getElementById("abs-pos");
111 ObjectPaintProperties* absPosProperties = absPos->layoutObject()->objectPain tProperties(); 111 ObjectPaintProperties* absPosProperties = absPos->layoutObject()->objectPain tProperties();
112 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain tOffsetTranslation()->matrix()); 112 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain tOffsetTranslation()->matrix());
113 EXPECT_EQ(frameView->scrollTranslation(), absPosProperties->paintOffsetTrans lation()->parent()); 113 EXPECT_EQ(frameView->scrollTranslation(), absPosProperties->paintOffsetTrans lation()->parent());
114 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l ocalTransformSpace()); 114 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l ocalTransformSpace());
115 EXPECT_EQ(FloatRoundedRect(), absPosProperties->overflowClip()->clipRect()); 115 EXPECT_EQ(FloatRoundedRect(), absPosProperties->overflowClip()->clipRect());
116 EXPECT_EQ(frameView->contentClip(), absPosProperties->overflowClip()->parent ()); 116 EXPECT_EQ(frameView->contentClip(), absPosProperties->overflowClip()->parent ());
117 } 117 }
118 118
119 TEST_F(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) 119 TEST_F(PrePaintTreeWalkTest, FrameScrollingTraditional)
120 { 120 {
121 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); 121 setBodyInnerHTML("<style> body { height: 10000px; } </style>");
122 122
123 document().domWindow()->scrollTo(0, 100); 123 document().domWindow()->scrollTo(0, 100);
124 124
125 FrameView* frameView = document().view(); 125 FrameView* frameView = document().view();
126 frameView->updateAllLifecyclePhases(); 126 frameView->updateAllLifecyclePhases();
127 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); 127 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix());
128 EXPECT_EQ(nullptr, frameView->preTranslation()->parent()); 128 EXPECT_EQ(nullptr, frameView->preTranslation()->parent());
129 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl ation()->matrix()); 129 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl ation()->matrix());
130 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren t()); 130 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren t());
131 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf ormSpace()); 131 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf ormSpace());
132 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe ct()); 132 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe ct());
133 EXPECT_EQ(nullptr, frameView->contentClip()->parent()); 133 EXPECT_EQ(nullptr, frameView->contentClip()->parent());
134 134
135 LayoutView* layoutView = document().layoutView(); 135 LayoutView* layoutView = document().layoutView();
136 ObjectPaintProperties* layoutViewProperties = layoutView->objectPaintPropert ies(); 136 ObjectPaintProperties* layoutViewProperties = layoutView->objectPaintPropert ies();
137 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation()); 137 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation());
138 } 138 }
139 139
140 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame being created. 140 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame being created.
141 // Need to set it during test setup. Besides that, the test still won't work bec ause 141 // Need to set it during test setup. Besides that, the test still won't work bec ause
142 // root layer scrolling mode is not compatible with SPv2 at this moment. 142 // root layer scrolling mode is not compatible with SPv2 at this moment.
143 // (Duplicate display item ID for FrameView and LayoutView.) 143 // (Duplicate display item ID for FrameView and LayoutView.)
144 TEST_F(PaintPropertyTreeBuilderTest, DISABLED_FrameScrollingRootLayerScrolls) 144 TEST_F(PrePaintTreeWalkTest, DISABLED_FrameScrollingRootLayerScrolls)
145 { 145 {
146 document().settings()->setRootLayerScrolls(true); 146 document().settings()->setRootLayerScrolls(true);
147 147
148 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); 148 setBodyInnerHTML("<style> body { height: 10000px; } </style>");
149 149
150 document().domWindow()->scrollTo(0, 100); 150 document().domWindow()->scrollTo(0, 100);
151 151
152 FrameView* frameView = document().view(); 152 FrameView* frameView = document().view();
153 frameView->updateAllLifecyclePhases(); 153 frameView->updateAllLifecyclePhases();
154 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); 154 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix());
155 EXPECT_EQ(nullptr, frameView->preTranslation()->parent()); 155 EXPECT_EQ(nullptr, frameView->preTranslation()->parent());
156 EXPECT_EQ(TransformationMatrix(), frameView->scrollTranslation()->matrix()); 156 EXPECT_EQ(TransformationMatrix(), frameView->scrollTranslation()->matrix());
157 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren t()); 157 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren t());
158 158
159 LayoutView* layoutView = document().layoutView(); 159 LayoutView* layoutView = document().layoutView();
160 ObjectPaintProperties* layoutViewProperties = layoutView->objectPaintPropert ies(); 160 ObjectPaintProperties* layoutViewProperties = layoutView->objectPaintPropert ies();
161 EXPECT_EQ(TransformationMatrix().translate(0, -100), layoutViewProperties->s crollTranslation()->matrix()); 161 EXPECT_EQ(TransformationMatrix().translate(0, -100), layoutViewProperties->s crollTranslation()->matrix());
162 EXPECT_EQ(frameView->scrollTranslation(), layoutViewProperties->scrollTransl ation()->parent()); 162 EXPECT_EQ(frameView->scrollTranslation(), layoutViewProperties->scrollTransl ation()->parent());
163 } 163 }
164 164
165 TEST_F(PaintPropertyTreeBuilderTest, Perspective) 165 TEST_F(PrePaintTreeWalkTest, Perspective)
166 { 166 {
167 loadTestData("perspective.html"); 167 loadTestData("perspective.html");
168 168
169 Element* perspective = document().getElementById("perspective"); 169 Element* perspective = document().getElementById("perspective");
170 ObjectPaintProperties* perspectiveProperties = perspective->layoutObject()-> objectPaintProperties(); 170 ObjectPaintProperties* perspectiveProperties = perspective->layoutObject()-> objectPaintProperties();
171 EXPECT_EQ(TransformationMatrix().applyPerspective(100), perspectivePropertie s->perspective()->matrix()); 171 EXPECT_EQ(TransformationMatrix().applyPerspective(100), perspectivePropertie s->perspective()->matrix());
172 // The perspective origin is the center of the border box plus accumulated p aint offset. 172 // The perspective origin is the center of the border box plus accumulated p aint offset.
173 EXPECT_EQ(FloatPoint3D(250, 250, 0), perspectiveProperties->perspective()->o rigin()); 173 EXPECT_EQ(FloatPoint3D(250, 250, 0), perspectiveProperties->perspective()->o rigin());
174 EXPECT_EQ(document().view()->scrollTranslation(), perspectiveProperties->per spective()->parent()); 174 EXPECT_EQ(document().view()->scrollTranslation(), perspectiveProperties->per spective()->parent());
175 175
176 // Adding perspective doesn't clear paint offset. The paint offset will be p assed down to children. 176 // Adding perspective doesn't clear paint offset. The paint offset will be p assed down to children.
177 Element* inner = document().getElementById("inner"); 177 Element* inner = document().getElementById("inner");
178 ObjectPaintProperties* innerProperties = inner->layoutObject()->objectPaintP roperties(); 178 ObjectPaintProperties* innerProperties = inner->layoutObject()->objectPaintP roperties();
179 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO ffsetTranslation()->matrix()); 179 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO ffsetTranslation()->matrix());
180 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset Translation()->parent()); 180 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset Translation()->parent());
181 } 181 }
182 182
183 TEST_F(PaintPropertyTreeBuilderTest, Transform) 183 TEST_F(PrePaintTreeWalkTest, Transform)
184 { 184 {
185 loadTestData("transform.html"); 185 loadTestData("transform.html");
186 186
187 Element* transform = document().getElementById("transform"); 187 Element* transform = document().getElementById("transform");
188 ObjectPaintProperties* transformProperties = transform->layoutObject()->obje ctPaintProperties(); 188 ObjectPaintProperties* transformProperties = transform->layoutObject()->obje ctPaintProperties();
189 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper ties->transform()->matrix()); 189 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper ties->transform()->matrix());
190 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi n()); 190 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi n());
191 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties ->transform()->parent()); 191 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties ->transform()->parent());
192 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa intOffsetTranslation()->matrix()); 192 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa intOffsetTranslation()->matrix());
193 EXPECT_EQ(document().view()->scrollTranslation(), transformProperties->paint OffsetTranslation()->parent()); 193 EXPECT_EQ(document().view()->scrollTranslation(), transformProperties->paint OffsetTranslation()->parent());
194 } 194 }
195 195
196 TEST_F(PaintPropertyTreeBuilderTest, RelativePositionInline) 196 TEST_F(PrePaintTreeWalkTest, RelativePositionInline)
197 { 197 {
198 loadTestData("relative-position-inline.html"); 198 loadTestData("relative-position-inline.html");
199 199
200 Element* inlineBlock = document().getElementById("inline-block"); 200 Element* inlineBlock = document().getElementById("inline-block");
201 ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObject()-> objectPaintProperties(); 201 ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObject()-> objectPaintProperties();
202 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties- >paintOffsetTranslation()->matrix()); 202 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties- >paintOffsetTranslation()->matrix());
203 EXPECT_EQ(document().view()->scrollTranslation(), inlineBlockProperties->pai ntOffsetTranslation()->parent()); 203 EXPECT_EQ(document().view()->scrollTranslation(), inlineBlockProperties->pai ntOffsetTranslation()->parent());
204 } 204 }
205 205
206 TEST_F(PaintPropertyTreeBuilderTest, NestedOpacityEffect) 206 TEST_F(PrePaintTreeWalkTest, NestedOpacityEffect)
207 { 207 {
208 setBodyInnerHTML( 208 setBodyInnerHTML(
209 "<div id='nodeWithoutOpacity'>" 209 "<div id='nodeWithoutOpacity'>"
210 " <div id='childWithOpacity' style='opacity: 0.5'>" 210 " <div id='childWithOpacity' style='opacity: 0.5'>"
211 " <div id='grandChildWithoutOpacity'>" 211 " <div id='grandChildWithoutOpacity'>"
212 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2'/>" 212 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2'/>"
213 " </div>" 213 " </div>"
214 " </div>" 214 " </div>"
215 "</div>"); 215 "</div>");
216 216
217 LayoutObject& nodeWithoutOpacity = *document().getElementById("nodeWithoutOp acity")->layoutObject(); 217 LayoutObject& nodeWithoutOpacity = *document().getElementById("nodeWithoutOp acity")->layoutObject();
218 ObjectPaintProperties* nodeWithoutOpacityProperties = nodeWithoutOpacity.obj ectPaintProperties(); 218 ObjectPaintProperties* nodeWithoutOpacityProperties = nodeWithoutOpacity.obj ectPaintProperties();
219 EXPECT_EQ(nullptr, nodeWithoutOpacityProperties); 219 EXPECT_EQ(nullptr, nodeWithoutOpacityProperties);
220 220
221 LayoutObject& childWithOpacity = *document().getElementById("childWithOpacit y")->layoutObject(); 221 LayoutObject& childWithOpacity = *document().getElementById("childWithOpacit y")->layoutObject();
222 ObjectPaintProperties* childWithOpacityProperties = childWithOpacity.objectP aintProperties(); 222 ObjectPaintProperties* childWithOpacityProperties = childWithOpacity.objectP aintProperties();
223 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity()); 223 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity());
224 // childWithOpacity is the root effect node. 224 // childWithOpacity is the root effect node.
225 EXPECT_EQ(nullptr, childWithOpacityProperties->effect()->parent()); 225 EXPECT_EQ(nullptr, childWithOpacityProperties->effect()->parent());
226 226
227 LayoutObject& grandChildWithoutOpacity = *document().getElementById("grandCh ildWithoutOpacity")->layoutObject(); 227 LayoutObject& grandChildWithoutOpacity = *document().getElementById("grandCh ildWithoutOpacity")->layoutObject();
228 EXPECT_EQ(nullptr, grandChildWithoutOpacity.objectPaintProperties()); 228 EXPECT_EQ(nullptr, grandChildWithoutOpacity.objectPaintProperties());
229 229
230 LayoutObject& greatGrandChildWithOpacity = *document().getElementById("great GrandChildWithOpacity")->layoutObject(); 230 LayoutObject& greatGrandChildWithOpacity = *document().getElementById("great GrandChildWithOpacity")->layoutObject();
231 ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGrandChil dWithOpacity.objectPaintProperties(); 231 ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGrandChil dWithOpacity.objectPaintProperties();
232 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); 232 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity());
233 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr operties->effect()->parent()); 233 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr operties->effect()->parent());
234 } 234 }
235 235
236 TEST_F(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) 236 TEST_F(PrePaintTreeWalkTest, TransformNodeDoesNotAffectEffectNodes)
237 { 237 {
238 setBodyInnerHTML( 238 setBodyInnerHTML(
239 "<div id='nodeWithOpacity' style='opacity: 0.6'>" 239 "<div id='nodeWithOpacity' style='opacity: 0.6'>"
240 " <div id='childWithTransform' style='transform: translate3d(10px, 10px , 0px);'>" 240 " <div id='childWithTransform' style='transform: translate3d(10px, 10px , 0px);'>"
241 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" 241 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>"
242 " </div>" 242 " </div>"
243 "</div>"); 243 "</div>");
244 244
245 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity" )->layoutObject(); 245 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity" )->layoutObject();
246 ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.objectPai ntProperties(); 246 ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.objectPai ntProperties();
247 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); 247 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity());
248 EXPECT_EQ(nullptr, nodeWithOpacityProperties->effect()->parent()); 248 EXPECT_EQ(nullptr, nodeWithOpacityProperties->effect()->parent());
249 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); 249 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform());
250 250
251 LayoutObject& childWithTransform = *document().getElementById("childWithTran sform")->layoutObject(); 251 LayoutObject& childWithTransform = *document().getElementById("childWithTran sform")->layoutObject();
252 ObjectPaintProperties* childWithTransformProperties = childWithTransform.obj ectPaintProperties(); 252 ObjectPaintProperties* childWithTransformProperties = childWithTransform.obj ectPaintProperties();
253 EXPECT_EQ(nullptr, childWithTransformProperties->effect()); 253 EXPECT_EQ(nullptr, childWithTransformProperties->effect());
254 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper ties->transform()->matrix()); 254 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper ties->transform()->matrix());
255 255
256 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild WithOpacity")->layoutObject(); 256 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild WithOpacity")->layoutObject();
257 ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWithOpaci ty.objectPaintProperties(); 257 ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWithOpaci ty.objectPaintProperties();
258 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); 258 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity());
259 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti es->effect()->parent()); 259 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti es->effect()->parent());
260 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); 260 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform());
261 } 261 }
262 262
263 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) 263 TEST_F(PrePaintTreeWalkTest, EffectNodesAcrossStackingContext)
264 { 264 {
265 setBodyInnerHTML( 265 setBodyInnerHTML(
266 "<div id='nodeWithOpacity' style='opacity: 0.6'>" 266 "<div id='nodeWithOpacity' style='opacity: 0.6'>"
267 " <div id='childWithStackingContext' style='position:absolute;'>" 267 " <div id='childWithStackingContext' style='position:absolute;'>"
268 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" 268 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>"
269 " </div>" 269 " </div>"
270 "</div>"); 270 "</div>");
271 271
272 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity" )->layoutObject(); 272 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity" )->layoutObject();
273 ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.objectPai ntProperties(); 273 ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.objectPai ntProperties();
274 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); 274 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity());
275 EXPECT_EQ(nullptr, nodeWithOpacityProperties->effect()->parent()); 275 EXPECT_EQ(nullptr, nodeWithOpacityProperties->effect()->parent());
276 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); 276 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform());
277 277
278 LayoutObject& childWithStackingContext = *document().getElementById("childWi thStackingContext")->layoutObject(); 278 LayoutObject& childWithStackingContext = *document().getElementById("childWi thStackingContext")->layoutObject();
279 ObjectPaintProperties* childWithStackingContextProperties = childWithStackin gContext.objectPaintProperties(); 279 ObjectPaintProperties* childWithStackingContextProperties = childWithStackin gContext.objectPaintProperties();
280 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect()); 280 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect());
281 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); 281 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform());
282 282
283 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild WithOpacity")->layoutObject(); 283 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild WithOpacity")->layoutObject();
284 ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWithOpaci ty.objectPaintProperties(); 284 ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWithOpaci ty.objectPaintProperties();
285 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); 285 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity());
286 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti es->effect()->parent()); 286 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti es->effect()->parent());
287 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); 287 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform());
288 } 288 }
289 289
290 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesInSVG) 290 TEST_F(PrePaintTreeWalkTest, EffectNodesInSVG)
291 { 291 {
292 setBodyInnerHTML( 292 setBodyInnerHTML(
293 "<svg id='svgRoot'>" 293 "<svg id='svgRoot'>"
294 " <g id='groupWithOpacity' opacity='0.6'>" 294 " <g id='groupWithOpacity' opacity='0.6'>"
295 " <rect id='rectWithoutOpacity' />" 295 " <rect id='rectWithoutOpacity' />"
296 " <rect id='rectWithOpacity' opacity='0.4' />" 296 " <rect id='rectWithOpacity' opacity='0.4' />"
297 " <text id='textWithOpacity' opacity='0.2'>" 297 " <text id='textWithOpacity' opacity='0.2'>"
298 " <tspan id='tspanWithOpacity' opacity='0.1' />" 298 " <tspan id='tspanWithOpacity' opacity='0.1' />"
299 " </text>" 299 " </text>"
300 " </g>" 300 " </g>"
(...skipping 19 matching lines...) Expand all
320 EXPECT_EQ(0.2f, textWithOpacityProperties->effect()->opacity()); 320 EXPECT_EQ(0.2f, textWithOpacityProperties->effect()->opacity());
321 EXPECT_EQ(groupWithOpacityProperties->effect(), textWithOpacityProperties->e ffect()->parent()); 321 EXPECT_EQ(groupWithOpacityProperties->effect(), textWithOpacityProperties->e ffect()->parent());
322 322
323 // Ensure that opacity nodes are created for LayoutSVGTSpan which inherits f rom LayoutSVGInline instead of LayoutSVGModelObject. 323 // Ensure that opacity nodes are created for LayoutSVGTSpan which inherits f rom LayoutSVGInline instead of LayoutSVGModelObject.
324 LayoutObject& tspanWithOpacity = *document().getElementById("tspanWithOpacit y")->layoutObject(); 324 LayoutObject& tspanWithOpacity = *document().getElementById("tspanWithOpacit y")->layoutObject();
325 ObjectPaintProperties* tspanWithOpacityProperties = tspanWithOpacity.objectP aintProperties(); 325 ObjectPaintProperties* tspanWithOpacityProperties = tspanWithOpacity.objectP aintProperties();
326 EXPECT_EQ(0.1f, tspanWithOpacityProperties->effect()->opacity()); 326 EXPECT_EQ(0.1f, tspanWithOpacityProperties->effect()->opacity());
327 EXPECT_EQ(textWithOpacityProperties->effect(), tspanWithOpacityProperties->e ffect()->parent()); 327 EXPECT_EQ(textWithOpacityProperties->effect(), tspanWithOpacityProperties->e ffect()->parent());
328 } 328 }
329 329
330 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossHTMLSVGBoundary) 330 TEST_F(PrePaintTreeWalkTest, EffectNodesAcrossHTMLSVGBoundary)
331 { 331 {
332 setBodyInnerHTML( 332 setBodyInnerHTML(
333 "<div id='divWithOpacity' style='opacity: 0.2;'>" 333 "<div id='divWithOpacity' style='opacity: 0.2;'>"
334 " <svg id='svgRootWithOpacity' style='opacity: 0.3;'>" 334 " <svg id='svgRootWithOpacity' style='opacity: 0.3;'>"
335 " <rect id='rectWithOpacity' opacity='0.4' />" 335 " <rect id='rectWithOpacity' opacity='0.4' />"
336 " </svg>" 336 " </svg>"
337 "</div>"); 337 "</div>");
338 338
339 LayoutObject& divWithOpacity = *document().getElementById("divWithOpacity")- >layoutObject(); 339 LayoutObject& divWithOpacity = *document().getElementById("divWithOpacity")- >layoutObject();
340 ObjectPaintProperties* divWithOpacityProperties = divWithOpacity.objectPaint Properties(); 340 ObjectPaintProperties* divWithOpacityProperties = divWithOpacity.objectPaint Properties();
341 EXPECT_EQ(0.2f, divWithOpacityProperties->effect()->opacity()); 341 EXPECT_EQ(0.2f, divWithOpacityProperties->effect()->opacity());
342 EXPECT_EQ(nullptr, divWithOpacityProperties->effect()->parent()); 342 EXPECT_EQ(nullptr, divWithOpacityProperties->effect()->parent());
343 343
344 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp acity")->layoutObject(); 344 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp acity")->layoutObject();
345 ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpacity.obj ectPaintProperties(); 345 ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpacity.obj ectPaintProperties();
346 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); 346 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity());
347 EXPECT_EQ(divWithOpacityProperties->effect(), svgRootWithOpacityProperties-> effect()->parent()); 347 EXPECT_EQ(divWithOpacityProperties->effect(), svgRootWithOpacityProperties-> effect()->parent());
348 348
349 LayoutObject& rectWithOpacity = *document().getElementById("rectWithOpacity" )->layoutObject(); 349 LayoutObject& rectWithOpacity = *document().getElementById("rectWithOpacity" )->layoutObject();
350 ObjectPaintProperties* rectWithOpacityProperties = rectWithOpacity.objectPai ntProperties(); 350 ObjectPaintProperties* rectWithOpacityProperties = rectWithOpacity.objectPai ntProperties();
351 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity()); 351 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity());
352 EXPECT_EQ(svgRootWithOpacityProperties->effect(), rectWithOpacityProperties- >effect()->parent()); 352 EXPECT_EQ(svgRootWithOpacityProperties->effect(), rectWithOpacityProperties- >effect()->parent());
353 } 353 }
354 354
355 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossSVGHTMLBoundary) 355 TEST_F(PrePaintTreeWalkTest, EffectNodesAcrossSVGHTMLBoundary)
356 { 356 {
357 setBodyInnerHTML( 357 setBodyInnerHTML(
358 "<svg id='svgRootWithOpacity' style='opacity: 0.3;'>" 358 "<svg id='svgRootWithOpacity' style='opacity: 0.3;'>"
359 " <foreignObject id='foreignObjectWithOpacity' opacity='0.4'>" 359 " <foreignObject id='foreignObjectWithOpacity' opacity='0.4'>"
360 " <body>" 360 " <body>"
361 " <span id='spanWithOpacity' style='opacity: 0.5'/>" 361 " <span id='spanWithOpacity' style='opacity: 0.5'/>"
362 " </body>" 362 " </body>"
363 " </foreignObject>" 363 " </foreignObject>"
364 "</svg>"); 364 "</svg>");
365 365
366 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp acity")->layoutObject(); 366 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp acity")->layoutObject();
367 ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpacity.obj ectPaintProperties(); 367 ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpacity.obj ectPaintProperties();
368 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); 368 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity());
369 EXPECT_EQ(nullptr, svgRootWithOpacityProperties->effect()->parent()); 369 EXPECT_EQ(nullptr, svgRootWithOpacityProperties->effect()->parent());
370 370
371 LayoutObject& foreignObjectWithOpacity = *document().getElementById("foreign ObjectWithOpacity")->layoutObject(); 371 LayoutObject& foreignObjectWithOpacity = *document().getElementById("foreign ObjectWithOpacity")->layoutObject();
372 ObjectPaintProperties* foreignObjectWithOpacityProperties = foreignObjectWit hOpacity.objectPaintProperties(); 372 ObjectPaintProperties* foreignObjectWithOpacityProperties = foreignObjectWit hOpacity.objectPaintProperties();
373 EXPECT_EQ(0.4f, foreignObjectWithOpacityProperties->effect()->opacity()); 373 EXPECT_EQ(0.4f, foreignObjectWithOpacityProperties->effect()->opacity());
374 EXPECT_EQ(svgRootWithOpacityProperties->effect(), foreignObjectWithOpacityPr operties->effect()->parent()); 374 EXPECT_EQ(svgRootWithOpacityProperties->effect(), foreignObjectWithOpacityPr operties->effect()->parent());
375 375
376 LayoutObject& spanWithOpacity = *document().getElementById("spanWithOpacity" )->layoutObject(); 376 LayoutObject& spanWithOpacity = *document().getElementById("spanWithOpacity" )->layoutObject();
377 ObjectPaintProperties* spanWithOpacityProperties = spanWithOpacity.objectPai ntProperties(); 377 ObjectPaintProperties* spanWithOpacityProperties = spanWithOpacity.objectPai ntProperties();
378 EXPECT_EQ(0.5f, spanWithOpacityProperties->effect()->opacity()); 378 EXPECT_EQ(0.5f, spanWithOpacityProperties->effect()->opacity());
379 EXPECT_EQ(foreignObjectWithOpacityProperties->effect(), spanWithOpacityPrope rties->effect()->parent()); 379 EXPECT_EQ(foreignObjectWithOpacityProperties->effect(), spanWithOpacityPrope rties->effect()->parent());
380 } 380 }
381 381
382 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesInSVG) 382 TEST_F(PrePaintTreeWalkTest, TransformNodesInSVG)
383 { 383 {
384 setBodyInnerHTML( 384 setBodyInnerHTML(
385 "<style>" 385 "<style>"
386 " body {" 386 " body {"
387 " margin: 0px;" 387 " margin: 0px;"
388 " }" 388 " }"
389 " svg {" 389 " svg {"
390 " margin-left: 50px;" 390 " margin-left: 50px;"
391 " transform: translate3d(1px, 2px, 3px);" 391 " transform: translate3d(1px, 2px, 3px);"
392 " position: absolute;" 392 " position: absolute;"
(...skipping 23 matching lines...) Expand all
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->transform()->matrix());
421 EXPECT_EQ(FloatPoint3D(0, 0, 0), rectWith2dTransformProperties->transform()- >origin()); 421 EXPECT_EQ(FloatPoint3D(0, 0, 0), rectWith2dTransformProperties->transform()- >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, SVGRootPaintOffsetTransformNode) 426 TEST_F(PrePaintTreeWalkTest, SVGRootPaintOffsetTransformNode)
427 { 427 {
428 setBodyInnerHTML( 428 setBodyInnerHTML(
429 "<style>body { margin: 0px; } </style>" 429 "<style>body { margin: 0px; } </style>"
430 "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px; height: 100px;' />"); 430 "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px; height: 100px;' />");
431 431
432 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); 432 LayoutObject& svg = *document().getElementById("svg")->layoutObject();
433 ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); 433 ObjectPaintProperties* svgProperties = svg.objectPaintProperties();
434 // Ensure that a paint offset transform is emitted for SVG, even without a C SS transform. 434 // Ensure that a paint offset transform is emitted for SVG, even without a C SS transform.
435 EXPECT_EQ(nullptr, svgProperties->transform()); 435 EXPECT_EQ(nullptr, svgProperties->transform());
436 EXPECT_EQ(TransformationMatrix().translate(50, 25), svgProperties->paintOffs etTranslation()->matrix()); 436 EXPECT_EQ(TransformationMatrix().translate(50, 25), svgProperties->paintOffs etTranslation()->matrix());
437 EXPECT_EQ(document().view()->scrollTranslation(), svgProperties->paintOffset Translation()->parent()); 437 EXPECT_EQ(document().view()->scrollTranslation(), svgProperties->paintOffset Translation()->parent());
438 } 438 }
439 439
440 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSVGHTMLBoundary) 440 TEST_F(PrePaintTreeWalkTest, TransformNodesAcrossSVGHTMLBoundary)
441 { 441 {
442 setBodyInnerHTML( 442 setBodyInnerHTML(
443 "<style> body { margin: 0px; } </style>" 443 "<style> body { margin: 0px; } </style>"
444 "<svg id='svgWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>" 444 "<svg id='svgWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>"
445 " <foreignObject>" 445 " <foreignObject>"
446 " <body>" 446 " <body>"
447 " <div id='divWithTransform' style='transform: translate3d(3px, 4px , 5px);'></div>" 447 " <div id='divWithTransform' style='transform: translate3d(3px, 4px , 5px);'></div>"
448 " </body>" 448 " </body>"
449 " </foreignObject>" 449 " </foreignObject>"
450 "</svg>"); 450 "</svg>");
451 451
452 LayoutObject& svgWithTransform = *document().getElementById("svgWithTransfor m")->layoutObject(); 452 LayoutObject& svgWithTransform = *document().getElementById("svgWithTransfor m")->layoutObject();
453 ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.objectP aintProperties(); 453 ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.objectP aintProperties();
454 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithTransformPrope rties->transform()->matrix()); 454 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithTransformPrope rties->transform()->matrix());
455 455
456 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor m")->layoutObject(); 456 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor m")->layoutObject();
457 ObjectPaintProperties* divWithTransformProperties = divWithTransform.objectP aintProperties(); 457 ObjectPaintProperties* divWithTransformProperties = divWithTransform.objectP aintProperties();
458 EXPECT_EQ(TransformationMatrix().translate3d(3, 4, 5), divWithTransformPrope rties->transform()->matrix()); 458 EXPECT_EQ(TransformationMatrix().translate3d(3, 4, 5), divWithTransformPrope rties->transform()->matrix());
459 // Ensure the div's transform node is a child of the svg's transform node. 459 // Ensure the div's transform node is a child of the svg's transform node.
460 EXPECT_EQ(svgWithTransformProperties->transform(), divWithTransformPropertie s->transform()->parent()); 460 EXPECT_EQ(svgWithTransformProperties->transform(), divWithTransformPropertie s->transform()->parent());
461 } 461 }
462 462
463 TEST_F(PaintPropertyTreeBuilderTest, FixedTransformAncestorAcrossSVGHTMLBoundary ) 463 TEST_F(PrePaintTreeWalkTest, FixedTransformAncestorAcrossSVGHTMLBoundary)
464 { 464 {
465 setBodyInnerHTML( 465 setBodyInnerHTML(
466 "<style> body { margin: 0px; } </style>" 466 "<style> body { margin: 0px; } </style>"
467 "<svg id='svg' style='transform: translate3d(1px, 2px, 3px);'>" 467 "<svg id='svg' style='transform: translate3d(1px, 2px, 3px);'>"
468 " <g id='container' transform='translate(20 30)'>" 468 " <g id='container' transform='translate(20 30)'>"
469 " <foreignObject>" 469 " <foreignObject>"
470 " <body>" 470 " <body>"
471 " <div id='fixed' style='position: fixed; left: 200px; top: 150px ;'></div>" 471 " <div id='fixed' style='position: fixed; left: 200px; top: 150px ;'></div>"
472 " </body>" 472 " </body>"
473 " </foreignObject>" 473 " </foreignObject>"
474 " </g>" 474 " </g>"
475 "</svg>"); 475 "</svg>");
476 476
477 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); 477 LayoutObject& svg = *document().getElementById("svg")->layoutObject();
478 ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); 478 ObjectPaintProperties* svgProperties = svg.objectPaintProperties();
479 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgProperties->transf orm()->matrix()); 479 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgProperties->transf orm()->matrix());
480 480
481 LayoutObject& container = *document().getElementById("container")->layoutObj ect(); 481 LayoutObject& container = *document().getElementById("container")->layoutObj ect();
482 ObjectPaintProperties* containerProperties = container.objectPaintProperties (); 482 ObjectPaintProperties* containerProperties = container.objectPaintProperties ();
483 EXPECT_EQ(TransformationMatrix().translate(20, 30), containerProperties->tra nsform()->matrix()); 483 EXPECT_EQ(TransformationMatrix().translate(20, 30), containerProperties->tra nsform()->matrix());
484 EXPECT_EQ(svgProperties->transform(), containerProperties->transform()->pare nt()); 484 EXPECT_EQ(svgProperties->transform(), containerProperties->transform()->pare nt());
485 485
486 Element* fixed = document().getElementById("fixed"); 486 Element* fixed = document().getElementById("fixed");
487 ObjectPaintProperties* fixedProperties = fixed->layoutObject()->objectPaintP roperties(); 487 ObjectPaintProperties* fixedProperties = fixed->layoutObject()->objectPaintP roperties();
488 EXPECT_EQ(TransformationMatrix().translate(200, 150), fixedProperties->paint OffsetTranslation()->matrix()); 488 EXPECT_EQ(TransformationMatrix().translate(200, 150), fixedProperties->paint OffsetTranslation()->matrix());
489 // Ensure the fixed position element is rooted at the nearest transform cont ainer. 489 // Ensure the fixed position element is rooted at the nearest transform cont ainer.
490 EXPECT_EQ(containerProperties->transform(), fixedProperties->paintOffsetTran slation()->parent()); 490 EXPECT_EQ(containerProperties->transform(), fixedProperties->paintOffsetTran slation()->parent());
491 } 491 }
492 492
493 TEST_F(PaintPropertyTreeBuilderTest, ControlClip) 493 TEST_F(PrePaintTreeWalkTest, ControlClip)
494 { 494 {
495 setBodyInnerHTML( 495 setBodyInnerHTML(
496 "<style>" 496 "<style>"
497 " body {" 497 " body {"
498 " margin: 0;" 498 " margin: 0;"
499 " }" 499 " }"
500 " input {" 500 " input {"
501 " border-width: 5px;" 501 " border-width: 5px;"
502 " padding: 0;" 502 " padding: 0;"
503 " }" 503 " }"
504 "</style>" 504 "</style>"
505 "<input id='button' type='button' style='width:345px; height:123px' valu e='some text'/>"); 505 "<input id='button' type='button' style='width:345px; height:123px' valu e='some text'/>");
506 506
507 FrameView* frameView = document().view(); 507 FrameView* frameView = document().view();
508 LayoutObject& button = *document().getElementById("button")->layoutObject(); 508 LayoutObject& button = *document().getElementById("button")->layoutObject();
509 ObjectPaintProperties* buttonProperties = button.objectPaintProperties(); 509 ObjectPaintProperties* buttonProperties = button.objectPaintProperties();
510 EXPECT_EQ(frameView->scrollTranslation(), buttonProperties->overflowClip()-> localTransformSpace()); 510 EXPECT_EQ(frameView->scrollTranslation(), buttonProperties->overflowClip()-> localTransformSpace());
511 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip() ->clipRect()); 511 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip() ->clipRect());
512 EXPECT_EQ(frameView->contentClip(), buttonProperties->overflowClip()->parent ()); 512 EXPECT_EQ(frameView->contentClip(), buttonProperties->overflowClip()->parent ());
513 } 513 }
514 514
515 TEST_F(PaintPropertyTreeBuilderTest, BorderRadiusClip) 515 TEST_F(PrePaintTreeWalkTest, BorderRadiusClip)
516 { 516 {
517 setBodyInnerHTML( 517 setBodyInnerHTML(
518 "<style>" 518 "<style>"
519 " body {" 519 " body {"
520 " margin: 0px;" 520 " margin: 0px;"
521 " }" 521 " }"
522 " #div {" 522 " #div {"
523 " border-radius: 12px 34px 56px 78px;" 523 " border-radius: 12px 34px 56px 78px;"
524 " border-top: 45px solid;" 524 " border-top: 45px solid;"
525 " border-right: 50px solid;" 525 " border-right: 50px solid;"
(...skipping 24 matching lines...) Expand all
550 FloatRoundedRect( 550 FloatRoundedRect(
551 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs et(110, 100) 551 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs et(110, 100)
552 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0, 0)) 552 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0, 0))
553 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0, 0)) 553 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0, 0))
554 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0, 0)) 554 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0, 0))
555 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0, 0)) 555 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0, 0))
556 borderRadiusClip->clipRect()); 556 borderRadiusClip->clipRect());
557 EXPECT_EQ(frameView->contentClip(), borderRadiusClip->parent()); 557 EXPECT_EQ(frameView->contentClip(), borderRadiusClip->parent());
558 } 558 }
559 559
560 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes) 560 TEST_F(PrePaintTreeWalkTest, TransformNodesAcrossSubframes)
561 { 561 {
562 setBodyInnerHTML( 562 setBodyInnerHTML(
563 "<style>body { margin: 0; }</style>" 563 "<style>body { margin: 0; }</style>"
564 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>" 564 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>"
565 " <iframe id='frame'></iframe>" 565 " <iframe id='frame'></iframe>"
566 "</div>"); 566 "</div>");
567 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 0 ; }</style><div id='transform' style='transform: translate3d(4px, 5px, 6px);'></ div>"); 567 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 0 ; }</style><div id='transform' style='transform: translate3d(4px, 5px, 6px);'></ div>");
568 document().view()->updateAllLifecyclePhases(); 568 document().view()->updateAllLifecyclePhases();
569 569
570 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor m")->layoutObject(); 570 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor m")->layoutObject();
(...skipping 12 matching lines...) Expand all
583 // PreTranslation transform=translation=2.000000,2.000000,0.000000 583 // PreTranslation transform=translation=2.000000,2.000000,0.000000
584 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000 584 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000
585 // Transform transform=translation=4.000000,5.000000,6.000000 585 // Transform transform=translation=4.000000,5.000000,6.000000
586 auto* innerDocumentScrollTranslation = innerDivTransform->parent(); 586 auto* innerDocumentScrollTranslation = innerDivTransform->parent();
587 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr anslation->matrix()); 587 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr anslation->matrix());
588 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); 588 auto* iframePreTranslation = innerDocumentScrollTranslation->parent();
589 EXPECT_EQ(TransformationMatrix().translate3d(2, 2, 0), iframePreTranslation- >matrix()); 589 EXPECT_EQ(TransformationMatrix().translate3d(2, 2, 0), iframePreTranslation- >matrix());
590 EXPECT_EQ(divWithTransformProperties->transform(), iframePreTranslation->par ent()); 590 EXPECT_EQ(divWithTransformProperties->transform(), iframePreTranslation->par ent());
591 } 591 }
592 592
593 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesInTransformedSubframes) 593 TEST_F(PrePaintTreeWalkTest, TransformNodesInTransformedSubframes)
594 { 594 {
595 setBodyInnerHTML( 595 setBodyInnerHTML(
596 "<style>body { margin: 0; }</style>" 596 "<style>body { margin: 0; }</style>"
597 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>" 597 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px) ;'>"
598 " <iframe id='frame' style='transform: translate3d(4px, 5px, 6px); bord er: 42px solid; margin: 7px;'></iframe>" 598 " <iframe id='frame' style='transform: translate3d(4px, 5px, 6px); bord er: 42px solid; margin: 7px;'></iframe>"
599 "</div>"); 599 "</div>");
600 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 3 1px; }</style><div id='transform' style='transform: translate3d(7px, 8px, 9px);' ></div>"); 600 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 3 1px; }</style><div id='transform' style='transform: translate3d(7px, 8px, 9px);' ></div>");
601 document().view()->updateAllLifecyclePhases(); 601 document().view()->updateAllLifecyclePhases();
602 602
603 // Assert that we have the following tree structure: 603 // Assert that we have the following tree structure:
(...skipping 20 matching lines...) Expand all
624 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), iframeTransform->matr ix()); 624 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), iframeTransform->matr ix());
625 auto* iframePaintOffsetTranslation = iframeTransform->parent(); 625 auto* iframePaintOffsetTranslation = iframeTransform->parent();
626 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePaintOffsetTran slation->matrix()); 626 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePaintOffsetTran slation->matrix());
627 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); 627 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent();
628 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformTrans form->matrix()); 628 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformTrans form->matrix());
629 629
630 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor m")->layoutObject(); 630 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor m")->layoutObject();
631 EXPECT_EQ(divWithTransformTransform, divWithTransform.objectPaintProperties( )->transform()); 631 EXPECT_EQ(divWithTransformTransform, divWithTransform.objectPaintProperties( )->transform());
632 } 632 }
633 633
634 TEST_F(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) 634 TEST_F(PrePaintTreeWalkTest, TreeContextClipByNonStackingContext)
635 { 635 {
636 // This test verifies the tree builder correctly computes and records the pr operty tree context 636 // This test verifies the tree builder correctly computes and records the pr operty tree context
637 // for a (pseudo) stacking context that is scrolled by a containing block th at is not one of 637 // for a (pseudo) stacking context that is scrolled by a containing block th at is not one of
638 // the painting ancestors. 638 // the painting ancestors.
639 setBodyInnerHTML( 639 setBodyInnerHTML(
640 "<style>body { margin: 0; }</style>" 640 "<style>body { margin: 0; }</style>"
641 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'> " 641 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'> "
642 " <div id='child' style='position:relative;'></div>" 642 " <div id='child' style='position:relative;'></div>"
643 " <div style='height:10000px;'></div>" 643 " <div style='height:10000px;'></div>"
644 "</div>" 644 "</div>"
645 ); 645 );
646 646
647 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec t(); 647 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec t();
648 ObjectPaintProperties* scrollerProperties = scroller.objectPaintProperties() ; 648 ObjectPaintProperties* scrollerProperties = scroller.objectPaintProperties() ;
649 LayoutObject& child = *document().getElementById("child")->layoutObject(); 649 LayoutObject& child = *document().getElementById("child")->layoutObject();
650 ObjectPaintProperties* childProperties = child.objectPaintProperties(); 650 ObjectPaintProperties* childProperties = child.objectPaintProperties();
651 651
652 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo xProperties()->clip); 652 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo xProperties()->clip);
653 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor derBoxProperties()->transform); 653 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor derBoxProperties()->transform);
654 EXPECT_EQ(nullptr, childProperties->localBorderBoxProperties()->effect); 654 EXPECT_EQ(nullptr, childProperties->localBorderBoxProperties()->effect);
655 } 655 }
656 656
657 TEST_F(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext) 657 TEST_F(PrePaintTreeWalkTest, TreeContextUnclipFromParentStackingContext)
658 { 658 {
659 // This test verifies the tree builder correctly computes and records the pr operty tree context 659 // This test verifies the tree builder correctly computes and records the pr operty tree context
660 // for a (pseudo) stacking context that has a scrolling painting ancestor th at is not its 660 // for a (pseudo) stacking context that has a scrolling painting ancestor th at is not its
661 // containing block (thus should not be scrolled by it). 661 // containing block (thus should not be scrolled by it).
662 662
663 setBodyInnerHTML( 663 setBodyInnerHTML(
664 "<style>body { margin: 0; }</style>" 664 "<style>body { margin: 0; }</style>"
665 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" 665 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>"
666 " <div id='child' style='position:absolute; left:0; top:0;'></div>" 666 " <div id='child' style='position:absolute; left:0; top:0;'></div>"
667 " <div style='height:10000px;'></div>" 667 " <div style='height:10000px;'></div>"
668 "</div>" 668 "</div>"
669 ); 669 );
670 670
671 FrameView* frameView = document().view(); 671 FrameView* frameView = document().view();
672 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec t(); 672 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec t();
673 ObjectPaintProperties* scrollerProperties = scroller.objectPaintProperties() ; 673 ObjectPaintProperties* scrollerProperties = scroller.objectPaintProperties() ;
674 LayoutObject& child = *document().getElementById("child")->layoutObject(); 674 LayoutObject& child = *document().getElementById("child")->layoutObject();
675 ObjectPaintProperties* childProperties = child.objectPaintProperties(); 675 ObjectPaintProperties* childProperties = child.objectPaintProperties();
676 676
677 EXPECT_EQ(frameView->contentClip(), childProperties->localBorderBoxPropertie s()->clip); 677 EXPECT_EQ(frameView->contentClip(), childProperties->localBorderBoxPropertie s()->clip);
678 EXPECT_EQ(frameView->scrollTranslation(), childProperties->localBorderBoxPro perties()->transform); 678 EXPECT_EQ(frameView->scrollTranslation(), childProperties->localBorderBoxPro perties()->transform);
679 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope rties()->effect); 679 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope rties()->effect);
680 } 680 }
681 681
682 } // namespace blink 682 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698