| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 { | 93 { |
| 94 RenderingTest::TearDown(); | 94 RenderingTest::TearDown(); |
| 95 | 95 |
| 96 Settings::setMockScrollbarsEnabled(false); | 96 Settings::setMockScrollbarsEnabled(false); |
| 97 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); | 97 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool m_originalSlimmingPaintV2Enabled; | 100 bool m_originalSlimmingPaintV2Enabled; |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 #define CHECK_VISUAL_RECT(sourceLayoutObject, ancestorLayoutObject, slopFactor)
\ | 103 #define CHECK_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObject, sl
opFactor) \ |
| 104 do { \ | 104 do { \ |
| 105 GeometryMapper geometryMapper; \ | 105 GeometryMapper geometryMapper; \ |
| 106 LayoutRect source(sourceLayoutObject->localOverflowRectForPaintInvalidation(
)); \ | 106 LayoutRect source((sourceLayoutObject)->localOverflowRectForPaintInvalidatio
n()); \ |
| 107 source.moveBy(sourceLayoutObject->objectPaintProperties()->localBorderBoxPro
perties()->paintOffset); \ | 107 source.moveBy((sourceLayoutObject)->objectPaintProperties()->localBorderBoxP
roperties()->paintOffset); \ |
| 108 bool success = false; \ | 108 bool success = false; \ |
| 109 FloatRect actual = geometryMapper.mapToVisualRectInDestinationSpace( \ | 109 FloatRect actual = geometryMapper.mapToVisualRectInDestinationSpace( \ |
| 110 FloatRect(source), \ | 110 FloatRect(source), \ |
| 111 sourceLayoutObject->objectPaintProperties()->localBorderBoxProperties()-
>propertyTreeState, \ | 111 (sourceLayoutObject)->objectPaintProperties()->localBorderBoxProperties(
)->propertyTreeState, \ |
| 112 ancestorLayoutObject->objectPaintProperties()->localBorderBoxProperties(
)->propertyTreeState, success); \ | 112 (ancestorLayoutObject)->objectPaintProperties()->localBorderBoxPropertie
s()->propertyTreeState, success); \ |
| 113 EXPECT_TRUE(success); \ | 113 ASSERT_TRUE(success); \ |
| 114 EXPECT_EQ(expected, LayoutRect(actual)); \ |
| 114 \ | 115 \ |
| 115 LayoutRect expected = sourceLayoutObject->localOverflowRectForPaintInvalidat
ion(); \ | 116 if (slopFactor == LayoutUnit::max()) \ |
| 116 sourceLayoutObject->mapToVisualRectInAncestorSpace(ancestorLayoutObject, exp
ected); \ | 117 break; \ |
| 117 EXPECT_TRUE(expected.contains(LayoutRect(actual))); \ | 118 LayoutRect slowPathRect = (sourceLayoutObject)->localOverflowRectForPaintInv
alidation(); \ |
| 118 actual.inflate(slopFactor); \ | 119 (sourceLayoutObject)->mapToVisualRectInAncestorSpace(ancestorLayoutObject, s
lowPathRect); \ |
| 119 EXPECT_TRUE(LayoutRect(actual).contains(expected)); \ | 120 if (slopFactor) { \ |
| 120 } while (0); | 121 LayoutRect inflatedActual = LayoutRect(actual); \ |
| 122 inflatedActual.inflate(slopFactor); \ |
| 123 SCOPED_TRACE(String::format("Old path rect: %s, Actual: %s, Inflated act
ual: %s", slowPathRect.toString().ascii().data(), actual.toString().ascii().data
(), inflatedActual.toString().ascii().data())); \ |
| 124 EXPECT_TRUE(slowPathRect.contains(LayoutRect(actual))); \ |
| 125 EXPECT_TRUE(inflatedActual.contains(slowPathRect)); \ |
| 126 } else { \ |
| 127 EXPECT_EQ(slowPathRect, LayoutRect(actual)); \ |
| 128 } \ |
| 129 } while (0) |
| 121 | 130 |
| 122 #define CHECK_EXACT_VISUAL_RECT(sourceLayoutObject, ancestorLayoutObject) CHECK_
VISUAL_RECT(sourceLayoutObject, ancestorLayoutObject, 0) | 131 #define CHECK_EXACT_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObje
ct) CHECK_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObject, 0) |
| 123 | 132 |
| 124 INSTANTIATE_TEST_CASE_P(All, PaintPropertyTreeBuilderTest, ::testing::Values(nul
lptr, &RootLayerScrollsFrameSettingOverride)); | 133 INSTANTIATE_TEST_CASE_P(All, PaintPropertyTreeBuilderTest, ::testing::Values(nul
lptr, &RootLayerScrollsFrameSettingOverride)); |
| 125 | 134 |
| 126 TEST_P(PaintPropertyTreeBuilderTest, FixedPosition) | 135 TEST_P(PaintPropertyTreeBuilderTest, FixedPosition) |
| 127 { | 136 { |
| 128 loadTestData("fixed-position.html"); | 137 loadTestData("fixed-position.html"); |
| 129 | 138 |
| 130 FrameView* frameView = document().view(); | 139 FrameView* frameView = document().view(); |
| 131 | 140 |
| 132 // target1 is a fixed-position element inside an absolute-position scrolling
element. | 141 // target1 is a fixed-position element inside an absolute-position scrolling
element. |
| 133 // It should be attached under the viewport to skip scrolling and offset of
the parent. | 142 // It should be attached under the viewport to skip scrolling and offset of
the parent. |
| 134 Element* target1 = document().getElementById("target1"); | 143 Element* target1 = document().getElementById("target1"); |
| 135 const ObjectPaintProperties* target1Properties = target1->layoutObject()->ob
jectPaintProperties(); | 144 const ObjectPaintProperties* target1Properties = target1->layoutObject()->ob
jectPaintProperties(); |
| 136 EXPECT_EQ(TransformationMatrix().translate(200, 150), target1Properties->pai
ntOffsetTranslation()->matrix()); | 145 EXPECT_EQ(TransformationMatrix().translate(200, 150), target1Properties->pai
ntOffsetTranslation()->matrix()); |
| 137 EXPECT_EQ(framePreTranslation(), target1Properties->paintOffsetTranslation()
->parent()); | 146 EXPECT_EQ(framePreTranslation(), target1Properties->paintOffsetTranslation()
->parent()); |
| 138 EXPECT_EQ(target1Properties->paintOffsetTranslation(), target1Properties->ov
erflowClip()->localTransformSpace()); | 147 EXPECT_EQ(target1Properties->paintOffsetTranslation(), target1Properties->ov
erflowClip()->localTransformSpace()); |
| 139 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target1Properties->overflowClip(
)->clipRect()); | 148 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target1Properties->overflowClip(
)->clipRect()); |
| 140 // Likewise, it inherits clip from the viewport, skipping overflow clip of t
he scroller. | 149 // Likewise, it inherits clip from the viewport, skipping overflow clip of t
he scroller. |
| 141 EXPECT_EQ(frameContentClip(), target1Properties->overflowClip()->parent()); | 150 EXPECT_EQ(frameContentClip(), target1Properties->overflowClip()->parent()); |
| 142 CHECK_EXACT_VISUAL_RECT(target1->layoutObject(), frameView->layoutView()); | 151 CHECK_EXACT_VISUAL_RECT(LayoutRect(200, 150, 100, 100), target1->layoutObjec
t(), frameView->layoutView()); |
| 143 | 152 |
| 144 // target2 is a fixed-position element inside a transformed scrolling elemen
t. | 153 // target2 is a fixed-position element inside a transformed scrolling elemen
t. |
| 145 // It should be attached under the scrolled box of the transformed element. | 154 // It should be attached under the scrolled box of the transformed element. |
| 146 Element* target2 = document().getElementById("target2"); | 155 Element* target2 = document().getElementById("target2"); |
| 147 const ObjectPaintProperties* target2Properties = target2->layoutObject()->ob
jectPaintProperties(); | 156 const ObjectPaintProperties* target2Properties = target2->layoutObject()->ob
jectPaintProperties(); |
| 148 Element* scroller = document().getElementById("scroller"); | 157 Element* scroller = document().getElementById("scroller"); |
| 149 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->
objectPaintProperties(); | 158 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->
objectPaintProperties(); |
| 150 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai
ntOffsetTranslation()->matrix()); | 159 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai
ntOffsetTranslation()->matrix()); |
| 151 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO
ffsetTranslation()->parent()); | 160 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO
ffsetTranslation()->parent()); |
| 152 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov
erflowClip()->localTransformSpace()); | 161 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov
erflowClip()->localTransformSpace()); |
| 153 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip(
)->clipRect()); | 162 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip(
)->clipRect()); |
| 154 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli
p()->parent()); | 163 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli
p()->parent()); |
| 155 CHECK_EXACT_VISUAL_RECT(target2->layoutObject(), frameView->layoutView()); | 164 CHECK_EXACT_VISUAL_RECT(LayoutRect(208, 158, 200, 100), target2->layoutObjec
t(), frameView->layoutView()); |
| 156 } | 165 } |
| 157 | 166 |
| 158 TEST_P(PaintPropertyTreeBuilderTest, PositionAndScroll) | 167 TEST_P(PaintPropertyTreeBuilderTest, PositionAndScroll) |
| 159 { | 168 { |
| 160 loadTestData("position-and-scroll.html"); | 169 loadTestData("position-and-scroll.html"); |
| 161 | 170 |
| 162 Element* scroller = document().getElementById("scroller"); | 171 Element* scroller = document().getElementById("scroller"); |
| 163 scroller->scrollTo(0, 100); | 172 scroller->scrollTo(0, 100); |
| 164 FrameView* frameView = document().view(); | 173 FrameView* frameView = document().view(); |
| 165 frameView->updateAllLifecyclePhases(); | 174 frameView->updateAllLifecyclePhases(); |
| 166 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->
objectPaintProperties(); | 175 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->
objectPaintProperties(); |
| 167 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr
ollTranslation()->matrix()); | 176 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr
ollTranslation()->matrix()); |
| 168 EXPECT_EQ(frameScrollTranslation(), scrollerProperties->scrollTranslation()-
>parent()); | 177 EXPECT_EQ(frameScrollTranslation(), scrollerProperties->scrollTranslation()-
>parent()); |
| 169 EXPECT_EQ(frameScrollTranslation(), scrollerProperties->overflowClip()->loca
lTransformSpace()); | 178 EXPECT_EQ(frameScrollTranslation(), scrollerProperties->overflowClip()->loca
lTransformSpace()); |
| 170 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow
Clip()->clipRect()); | 179 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow
Clip()->clipRect()); |
| 171 EXPECT_EQ(frameContentClip(), scrollerProperties->overflowClip()->parent()); | 180 EXPECT_EQ(frameContentClip(), scrollerProperties->overflowClip()->parent()); |
| 172 // http://crbug.com/638415 | 181 // http://crbug.com/638415 |
| 173 if (!rootLayerScrolls()) { | 182 if (!rootLayerScrolls()) { |
| 174 CHECK_EXACT_VISUAL_RECT(scroller->layoutObject(), frameView->layoutView(
)); | 183 CHECK_EXACT_VISUAL_RECT(LayoutRect(120, 340, 400, 300), scroller->layout
Object(), frameView->layoutView()); |
| 175 } | 184 } |
| 176 | 185 |
| 177 // The relative-positioned element should have accumulated box offset (exclu
de scrolling), | 186 // The relative-positioned element should have accumulated box offset (exclu
de scrolling), |
| 178 // and should be affected by ancestor scroll transforms. | 187 // and should be affected by ancestor scroll transforms. |
| 179 Element* relPos = document().getElementById("rel-pos"); | 188 Element* relPos = document().getElementById("rel-pos"); |
| 180 const ObjectPaintProperties* relPosProperties = relPos->layoutObject()->obje
ctPaintProperties(); | 189 const ObjectPaintProperties* relPosProperties = relPos->layoutObject()->obje
ctPaintProperties(); |
| 181 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai
ntOffsetTranslation()->matrix()); | 190 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai
ntOffsetTranslation()->matrix()); |
| 182 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf
fsetTranslation()->parent()); | 191 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf
fsetTranslation()->parent()); |
| 183 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l
ocalTransformSpace()); | 192 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l
ocalTransformSpace()); |
| 184 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 200), relPosProperties->overflowClip()
->clipRect()); | 193 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 200), relPosProperties->overflowClip()
->clipRect()); |
| 185 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip
()->parent()); | 194 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip
()->parent()); |
| 186 CHECK_EXACT_VISUAL_RECT(relPos->layoutObject(), frameView->layoutView()); | 195 CHECK_EXACT_VISUAL_RECT(LayoutRect(), relPos->layoutObject(), frameView->lay
outView()); |
| 187 | 196 |
| 188 // The absolute-positioned element should not be affected by non-positioned
scroller at all. | 197 // The absolute-positioned element should not be affected by non-positioned
scroller at all. |
| 189 Element* absPos = document().getElementById("abs-pos"); | 198 Element* absPos = document().getElementById("abs-pos"); |
| 190 const ObjectPaintProperties* absPosProperties = absPos->layoutObject()->obje
ctPaintProperties(); | 199 const ObjectPaintProperties* absPosProperties = absPos->layoutObject()->obje
ctPaintProperties(); |
| 191 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain
tOffsetTranslation()->matrix()); | 200 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain
tOffsetTranslation()->matrix()); |
| 192 EXPECT_EQ(frameScrollTranslation(), absPosProperties->paintOffsetTranslation
()->parent()); | 201 EXPECT_EQ(frameScrollTranslation(), absPosProperties->paintOffsetTranslation
()->parent()); |
| 193 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l
ocalTransformSpace()); | 202 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l
ocalTransformSpace()); |
| 194 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400), absPosProperties->overflowClip()
->clipRect()); | 203 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400), absPosProperties->overflowClip()
->clipRect()); |
| 195 EXPECT_EQ(frameContentClip(), absPosProperties->overflowClip()->parent()); | 204 EXPECT_EQ(frameContentClip(), absPosProperties->overflowClip()->parent()); |
| 196 // http://crbug.com/638415 | 205 // http://crbug.com/638415 |
| 197 if (!rootLayerScrolls()) { | 206 if (!rootLayerScrolls()) { |
| 198 CHECK_EXACT_VISUAL_RECT(absPos->layoutObject(), frameView->layoutView())
; | 207 CHECK_EXACT_VISUAL_RECT(LayoutRect(123, 456, 300, 400), absPos->layoutOb
ject(), frameView->layoutView()); |
| 199 } | 208 } |
| 200 } | 209 } |
| 201 | 210 |
| 202 TEST_P(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) | 211 TEST_P(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) |
| 203 { | 212 { |
| 204 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); | 213 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); |
| 205 | 214 |
| 206 document().domWindow()->scrollTo(0, 100); | 215 document().domWindow()->scrollTo(0, 100); |
| 207 | 216 |
| 208 FrameView* frameView = document().view(); | 217 FrameView* frameView = document().view(); |
| 209 frameView->updateAllLifecyclePhases(); | 218 frameView->updateAllLifecyclePhases(); |
| 210 EXPECT_EQ(TransformationMatrix(), framePreTranslation()->matrix()); | 219 EXPECT_EQ(TransformationMatrix(), framePreTranslation()->matrix()); |
| 211 if (!rootLayerScrolls()) | 220 if (!rootLayerScrolls()) |
| 212 EXPECT_EQ(rootTransform(), framePreTranslation()->parent()); | 221 EXPECT_EQ(rootTransform(), framePreTranslation()->parent()); |
| 213 EXPECT_EQ(nullptr, rootTransform()->parent()); | 222 EXPECT_EQ(nullptr, rootTransform()->parent()); |
| 214 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameScrollTranslation(
)->matrix()); | 223 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameScrollTranslation(
)->matrix()); |
| 215 EXPECT_EQ(framePreTranslation(), frameScrollTranslation()->parent()); | 224 EXPECT_EQ(framePreTranslation(), frameScrollTranslation()->parent()); |
| 216 EXPECT_EQ(framePreTranslation(), frameContentClip()->localTransformSpace()); | 225 EXPECT_EQ(framePreTranslation(), frameContentClip()->localTransformSpace()); |
| 217 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameContentClip()->clipRect()); | 226 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameContentClip()->clipRect()); |
| 218 EXPECT_EQ(rootClip(), frameContentClip()->parent()); | 227 EXPECT_EQ(rootClip(), frameContentClip()->parent()); |
| 219 if (!rootLayerScrolls()) | 228 if (!rootLayerScrolls()) |
| 220 EXPECT_EQ(nullptr, rootClip()->parent()); | 229 EXPECT_EQ(nullptr, rootClip()->parent()); |
| 221 | 230 |
| 222 LayoutViewItem layoutViewItem = document().layoutViewItem(); | 231 LayoutViewItem layoutViewItem = document().layoutViewItem(); |
| 223 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai
ntProperties(); | 232 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai
ntProperties(); |
| 233 // http://crbug.com/638415 |
| 224 if (!rootLayerScrolls()) { | 234 if (!rootLayerScrolls()) { |
| 225 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation()); | 235 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation()); |
| 226 // http://crbug.com/638415 | 236 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 784, 10000), document().body()-
>layoutObject(), frameView->layoutView()); |
| 227 CHECK_EXACT_VISUAL_RECT(document().body()->layoutObject(), frameView->la
youtView()); | |
| 228 } | 237 } |
| 229 } | 238 } |
| 230 | 239 |
| 231 TEST_P(PaintPropertyTreeBuilderTest, Perspective) | 240 TEST_P(PaintPropertyTreeBuilderTest, Perspective) |
| 232 { | 241 { |
| 233 loadTestData("perspective.html"); | 242 loadTestData("perspective.html"); |
| 234 | 243 |
| 235 Element* perspective = document().getElementById("perspective"); | 244 Element* perspective = document().getElementById("perspective"); |
| 236 const ObjectPaintProperties* perspectiveProperties = perspective->layoutObje
ct()->objectPaintProperties(); | 245 const ObjectPaintProperties* perspectiveProperties = perspective->layoutObje
ct()->objectPaintProperties(); |
| 237 EXPECT_EQ(TransformationMatrix().applyPerspective(100), perspectivePropertie
s->perspective()->matrix()); | 246 EXPECT_EQ(TransformationMatrix().applyPerspective(100), perspectivePropertie
s->perspective()->matrix()); |
| 238 // The perspective origin is the center of the border box plus accumulated p
aint offset. | 247 // The perspective origin is the center of the border box plus accumulated p
aint offset. |
| 239 EXPECT_EQ(FloatPoint3D(250, 250, 0), perspectiveProperties->perspective()->o
rigin()); | 248 EXPECT_EQ(FloatPoint3D(250, 250, 0), perspectiveProperties->perspective()->o
rigin()); |
| 240 EXPECT_EQ(frameScrollTranslation(), perspectiveProperties->perspective()->pa
rent()); | 249 EXPECT_EQ(frameScrollTranslation(), perspectiveProperties->perspective()->pa
rent()); |
| 241 | 250 |
| 242 // Adding perspective doesn't clear paint offset. The paint offset will be p
assed down to children. | 251 // Adding perspective doesn't clear paint offset. The paint offset will be p
assed down to children. |
| 243 Element* inner = document().getElementById("inner"); | 252 Element* inner = document().getElementById("inner"); |
| 244 const ObjectPaintProperties* innerProperties = inner->layoutObject()->object
PaintProperties(); | 253 const ObjectPaintProperties* innerProperties = inner->layoutObject()->object
PaintProperties(); |
| 245 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO
ffsetTranslation()->matrix()); | 254 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO
ffsetTranslation()->matrix()); |
| 246 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset
Translation()->parent()); | 255 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset
Translation()->parent()); |
| 247 CHECK_EXACT_VISUAL_RECT(inner->layoutObject(), document().view()->layoutView
()); | 256 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 100, 200), inner->layoutObject()
, document().view()->layoutView()); |
| 248 } | 257 } |
| 249 | 258 |
| 250 TEST_P(PaintPropertyTreeBuilderTest, Transform) | 259 TEST_P(PaintPropertyTreeBuilderTest, Transform) |
| 251 { | 260 { |
| 252 loadTestData("transform.html"); | 261 loadTestData("transform.html"); |
| 253 | 262 |
| 254 Element* transform = document().getElementById("transform"); | 263 Element* transform = document().getElementById("transform"); |
| 255 const ObjectPaintProperties* transformProperties = transform->layoutObject()
->objectPaintProperties(); | 264 const ObjectPaintProperties* transformProperties = transform->layoutObject()
->objectPaintProperties(); |
| 256 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper
ties->transform()->matrix()); | 265 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper
ties->transform()->matrix()); |
| 257 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi
n()); | 266 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi
n()); |
| 258 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties
->transform()->parent()); | 267 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties
->transform()->parent()); |
| 259 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa
intOffsetTranslation()->matrix()); | 268 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa
intOffsetTranslation()->matrix()); |
| 260 EXPECT_EQ(frameScrollTranslation(), transformProperties->paintOffsetTranslat
ion()->parent()); | 269 EXPECT_EQ(frameScrollTranslation(), transformProperties->paintOffsetTranslat
ion()->parent()); |
| 261 // http://crbug.com/638415 | 270 // http://crbug.com/638415 |
| 262 if (!rootLayerScrolls()) { | 271 if (!rootLayerScrolls()) { |
| 263 CHECK_EXACT_VISUAL_RECT(transform->layoutObject(), document().view()->la
youtView()); | 272 CHECK_EXACT_VISUAL_RECT(LayoutRect(173, 556, 400, 300), transform->layou
tObject(), document().view()->layoutView()); |
| 264 } | 273 } |
| 265 } | 274 } |
| 266 | 275 |
| 267 TEST_P(PaintPropertyTreeBuilderTest, RelativePositionInline) | 276 TEST_P(PaintPropertyTreeBuilderTest, RelativePositionInline) |
| 268 { | 277 { |
| 269 loadTestData("relative-position-inline.html"); | 278 loadTestData("relative-position-inline.html"); |
| 270 | 279 |
| 271 Element* inlineBlock = document().getElementById("inline-block"); | 280 Element* inlineBlock = document().getElementById("inline-block"); |
| 272 const ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObje
ct()->objectPaintProperties(); | 281 const ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObje
ct()->objectPaintProperties(); |
| 273 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties-
>paintOffsetTranslation()->matrix()); | 282 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties-
>paintOffsetTranslation()->matrix()); |
| 274 EXPECT_EQ(frameScrollTranslation(), inlineBlockProperties->paintOffsetTransl
ation()->parent()); | 283 EXPECT_EQ(frameScrollTranslation(), inlineBlockProperties->paintOffsetTransl
ation()->parent()); |
| 275 CHECK_EXACT_VISUAL_RECT(inlineBlock->layoutObject(), document().view()->layo
utView()); | 284 CHECK_EXACT_VISUAL_RECT(LayoutRect(135, 490, 10, 20), inlineBlock->layoutObj
ect(), document().view()->layoutView()); |
| 276 } | 285 } |
| 277 | 286 |
| 278 TEST_P(PaintPropertyTreeBuilderTest, NestedOpacityEffect) | 287 TEST_P(PaintPropertyTreeBuilderTest, NestedOpacityEffect) |
| 279 { | 288 { |
| 280 setBodyInnerHTML( | 289 setBodyInnerHTML( |
| 281 "<div id='nodeWithoutOpacity' style='width: 100px; height: 200px'>" | 290 "<div id='nodeWithoutOpacity' style='width: 100px; height: 200px'>" |
| 282 " <div id='childWithOpacity' style='opacity: 0.5; width: 50px; height:
60px;'>" | 291 " <div id='childWithOpacity' style='opacity: 0.5; width: 50px; height:
60px;'>" |
| 283 " <div id='grandChildWithoutOpacity' style='width: 20px; height: 30px
'>" | 292 " <div id='grandChildWithoutOpacity' style='width: 20px; height: 30px
'>" |
| 284 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2; width:
10px; height: 15px'/>" | 293 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2; width:
10px; height: 15px'/>" |
| 285 " </div>" | 294 " </div>" |
| 286 " </div>" | 295 " </div>" |
| 287 "</div>"); | 296 "</div>"); |
| 288 | 297 |
| 289 LayoutObject* nodeWithoutOpacity = document().getElementById("nodeWithoutOpa
city")->layoutObject(); | 298 LayoutObject* nodeWithoutOpacity = document().getElementById("nodeWithoutOpa
city")->layoutObject(); |
| 290 const ObjectPaintProperties* nodeWithoutOpacityProperties = nodeWithoutOpaci
ty->objectPaintProperties(); | 299 const ObjectPaintProperties* nodeWithoutOpacityProperties = nodeWithoutOpaci
ty->objectPaintProperties(); |
| 291 EXPECT_NE(nullptr, nodeWithoutOpacityProperties); | 300 EXPECT_NE(nullptr, nodeWithoutOpacityProperties); |
| 292 CHECK_EXACT_VISUAL_RECT(nodeWithoutOpacity, document().view()->layoutView())
; | 301 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 100, 200), nodeWithoutOpacity, docu
ment().view()->layoutView()); |
| 293 | 302 |
| 294 LayoutObject* childWithOpacity = document().getElementById("childWithOpacity
")->layoutObject(); | 303 LayoutObject* childWithOpacity = document().getElementById("childWithOpacity
")->layoutObject(); |
| 295 const ObjectPaintProperties* childWithOpacityProperties = childWithOpacity->
objectPaintProperties(); | 304 const ObjectPaintProperties* childWithOpacityProperties = childWithOpacity->
objectPaintProperties(); |
| 296 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity()); | 305 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity()); |
| 297 // childWithOpacity is the root effect node. | 306 // childWithOpacity is the root effect node. |
| 298 EXPECT_NE(nullptr, childWithOpacityProperties->effect()->parent()); | 307 EXPECT_NE(nullptr, childWithOpacityProperties->effect()->parent()); |
| 299 CHECK_EXACT_VISUAL_RECT(childWithOpacity, document().view()->layoutView()); | 308 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 50, 60), childWithOpacity, document
().view()->layoutView()); |
| 300 | 309 |
| 301 LayoutObject* grandChildWithoutOpacity = document().getElementById("grandChi
ldWithoutOpacity")->layoutObject(); | 310 LayoutObject* grandChildWithoutOpacity = document().getElementById("grandChi
ldWithoutOpacity")->layoutObject(); |
| 302 EXPECT_NE(nullptr, grandChildWithoutOpacity->objectPaintProperties()); | 311 EXPECT_NE(nullptr, grandChildWithoutOpacity->objectPaintProperties()); |
| 303 CHECK_EXACT_VISUAL_RECT(grandChildWithoutOpacity, document().view()->layoutV
iew()); | 312 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 20, 30), grandChildWithoutOpacity,
document().view()->layoutView()); |
| 304 | 313 |
| 305 LayoutObject* greatGrandChildWithOpacity = document().getElementById("greatG
randChildWithOpacity")->layoutObject(); | 314 LayoutObject* greatGrandChildWithOpacity = document().getElementById("greatG
randChildWithOpacity")->layoutObject(); |
| 306 const ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGra
ndChildWithOpacity->objectPaintProperties(); | 315 const ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGra
ndChildWithOpacity->objectPaintProperties(); |
| 307 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); | 316 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); |
| 308 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr
operties->effect()->parent()); | 317 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr
operties->effect()->parent()); |
| 309 CHECK_EXACT_VISUAL_RECT(greatGrandChildWithOpacity, document().view()->layou
tView()); | 318 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 15), greatGrandChildWithOpacity
, document().view()->layoutView()); |
| 310 } | 319 } |
| 311 | 320 |
| 312 TEST_P(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) | 321 TEST_P(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) |
| 313 { | 322 { |
| 314 setBodyInnerHTML( | 323 setBodyInnerHTML( |
| 315 "<div id='nodeWithOpacity' style='opacity: 0.6' style='width: 100px; hei
ght: 200px'>" | 324 "<div id='nodeWithOpacity' style='opacity: 0.6' style='width: 100px; hei
ght: 200px'>" |
| 316 " <div id='childWithTransform' style='transform: translate3d(10px, 10px
, 0px); width: 50px; height: 60px;'>" | 325 " <div id='childWithTransform' style='transform: translate3d(10px, 10px
, 0px); width: 50px; height: 60px;'>" |
| 317 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; h
eight: 30px'/>" | 326 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; h
eight: 30px'/>" |
| 318 " </div>" | 327 " </div>" |
| 319 "</div>"); | 328 "</div>"); |
| 320 | 329 |
| 321 LayoutObject* nodeWithOpacity = document().getElementById("nodeWithOpacity")
->layoutObject(); | 330 LayoutObject* nodeWithOpacity = document().getElementById("nodeWithOpacity")
->layoutObject(); |
| 322 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity->ob
jectPaintProperties(); | 331 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity->ob
jectPaintProperties(); |
| 323 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); | 332 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); |
| 324 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); | 333 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); |
| 325 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); | 334 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); |
| 326 CHECK_EXACT_VISUAL_RECT(nodeWithOpacity, document().view()->layoutView()); | 335 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 784, 60), nodeWithOpacity, document
().view()->layoutView()); |
| 327 | 336 |
| 328 LayoutObject* childWithTransform = document().getElementById("childWithTrans
form")->layoutObject(); | 337 LayoutObject* childWithTransform = document().getElementById("childWithTrans
form")->layoutObject(); |
| 329 const ObjectPaintProperties* childWithTransformProperties = childWithTransfo
rm->objectPaintProperties(); | 338 const ObjectPaintProperties* childWithTransformProperties = childWithTransfo
rm->objectPaintProperties(); |
| 330 EXPECT_EQ(nullptr, childWithTransformProperties->effect()); | 339 EXPECT_EQ(nullptr, childWithTransformProperties->effect()); |
| 331 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper
ties->transform()->matrix()); | 340 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper
ties->transform()->matrix()); |
| 332 CHECK_EXACT_VISUAL_RECT(childWithTransform, document().view()->layoutView())
; | 341 CHECK_EXACT_VISUAL_RECT(LayoutRect(18, 18, 50, 60), childWithTransform, docu
ment().view()->layoutView()); |
| 333 | 342 |
| 334 LayoutObject* grandChildWithOpacity = document().getElementById("grandChildW
ithOpacity")->layoutObject(); | 343 LayoutObject* grandChildWithOpacity = document().getElementById("grandChildW
ithOpacity")->layoutObject(); |
| 335 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit
hOpacity->objectPaintProperties(); | 344 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit
hOpacity->objectPaintProperties(); |
| 336 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); | 345 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); |
| 337 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); | 346 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); |
| 338 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); | 347 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); |
| 339 CHECK_EXACT_VISUAL_RECT(grandChildWithOpacity, document().view()->layoutView
()); | 348 CHECK_EXACT_VISUAL_RECT(LayoutRect(18, 18, 20, 30), grandChildWithOpacity, d
ocument().view()->layoutView()); |
| 340 } | 349 } |
| 341 | 350 |
| 342 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) | 351 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) |
| 343 { | 352 { |
| 344 setBodyInnerHTML( | 353 setBodyInnerHTML( |
| 345 "<div id='nodeWithOpacity' style='opacity: 0.6; width: 100px; height: 20
0px'>" | 354 "<div id='nodeWithOpacity' style='opacity: 0.6; width: 100px; height: 20
0px'>" |
| 346 " <div id='childWithStackingContext' style='position:absolute; width: 5
0px; height: 60px;'>" | 355 " <div id='childWithStackingContext' style='position:absolute; width: 5
0px; height: 60px;'>" |
| 347 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; h
eight: 30px'/>" | 356 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; h
eight: 30px'/>" |
| 348 " </div>" | 357 " </div>" |
| 349 "</div>"); | 358 "</div>"); |
| 350 | 359 |
| 351 LayoutObject* nodeWithOpacity = document().getElementById("nodeWithOpacity")
->layoutObject(); | 360 LayoutObject* nodeWithOpacity = document().getElementById("nodeWithOpacity")
->layoutObject(); |
| 352 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity->ob
jectPaintProperties(); | 361 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity->ob
jectPaintProperties(); |
| 353 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); | 362 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); |
| 354 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); | 363 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); |
| 355 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); | 364 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); |
| 356 CHECK_EXACT_VISUAL_RECT(nodeWithOpacity, document().view()->layoutView()); | 365 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 100, 200), nodeWithOpacity, documen
t().view()->layoutView()); |
| 357 | 366 |
| 358 LayoutObject* childWithStackingContext = document().getElementById("childWit
hStackingContext")->layoutObject(); | 367 LayoutObject* childWithStackingContext = document().getElementById("childWit
hStackingContext")->layoutObject(); |
| 359 const ObjectPaintProperties* childWithStackingContextProperties = childWithS
tackingContext->objectPaintProperties(); | 368 const ObjectPaintProperties* childWithStackingContextProperties = childWithS
tackingContext->objectPaintProperties(); |
| 360 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect()); | 369 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect()); |
| 361 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); | 370 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); |
| 362 CHECK_EXACT_VISUAL_RECT(childWithStackingContext, document().view()->layoutV
iew()); | 371 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 50, 60), childWithStackingContext,
document().view()->layoutView()); |
| 363 | 372 |
| 364 LayoutObject* grandChildWithOpacity = document().getElementById("grandChildW
ithOpacity")->layoutObject(); | 373 LayoutObject* grandChildWithOpacity = document().getElementById("grandChildW
ithOpacity")->layoutObject(); |
| 365 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit
hOpacity->objectPaintProperties(); | 374 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit
hOpacity->objectPaintProperties(); |
| 366 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); | 375 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); |
| 367 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); | 376 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); |
| 368 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); | 377 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); |
| 369 CHECK_EXACT_VISUAL_RECT(grandChildWithOpacity, document().view()->layoutView
()); | 378 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 20, 30), grandChildWithOpacity, doc
ument().view()->layoutView()); |
| 370 } | 379 } |
| 371 | 380 |
| 372 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesInSVG) | 381 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesInSVG) |
| 373 { | 382 { |
| 374 setBodyInnerHTML( | 383 setBodyInnerHTML( |
| 375 "<svg id='svgRoot'>" | 384 "<svg id='svgRoot'>" |
| 376 " <g id='groupWithOpacity' opacity='0.6'>" | 385 " <g id='groupWithOpacity' opacity='0.6'>" |
| 377 " <rect id='rectWithoutOpacity' />" | 386 " <rect id='rectWithoutOpacity' />" |
| 378 " <rect id='rectWithOpacity' opacity='0.4' />" | 387 " <rect id='rectWithOpacity' opacity='0.4' />" |
| 379 " <text id='textWithOpacity' opacity='0.2'>" | 388 " <text id='textWithOpacity' opacity='0.2'>" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 " padding: 0;" | 677 " padding: 0;" |
| 669 " }" | 678 " }" |
| 670 "</style>" | 679 "</style>" |
| 671 "<input id='button' type='button' style='width:345px; height:123px' valu
e='some text'/>"); | 680 "<input id='button' type='button' style='width:345px; height:123px' valu
e='some text'/>"); |
| 672 | 681 |
| 673 LayoutObject& button = *document().getElementById("button")->layoutObject(); | 682 LayoutObject& button = *document().getElementById("button")->layoutObject(); |
| 674 const ObjectPaintProperties* buttonProperties = button.objectPaintProperties
(); | 683 const ObjectPaintProperties* buttonProperties = button.objectPaintProperties
(); |
| 675 EXPECT_EQ(frameScrollTranslation(), buttonProperties->overflowClip()->localT
ransformSpace()); | 684 EXPECT_EQ(frameScrollTranslation(), buttonProperties->overflowClip()->localT
ransformSpace()); |
| 676 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip()
->clipRect()); | 685 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip()
->clipRect()); |
| 677 EXPECT_EQ(frameContentClip(), buttonProperties->overflowClip()->parent()); | 686 EXPECT_EQ(frameContentClip(), buttonProperties->overflowClip()->parent()); |
| 678 CHECK_EXACT_VISUAL_RECT((&button), document().view()->layoutView()); | 687 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 345, 123), &button, document().view
()->layoutView()); |
| 679 } | 688 } |
| 680 | 689 |
| 681 TEST_P(PaintPropertyTreeBuilderTest, BorderRadiusClip) | 690 TEST_P(PaintPropertyTreeBuilderTest, BorderRadiusClip) |
| 682 { | 691 { |
| 683 setBodyInnerHTML( | 692 setBodyInnerHTML( |
| 684 "<style>" | 693 "<style>" |
| 685 " body {" | 694 " body {" |
| 686 " margin: 0px;" | 695 " margin: 0px;" |
| 687 " }" | 696 " }" |
| 688 " #div {" | 697 " #div {" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 713 // may transition from one value to the other. i.e. being an ellipse. | 722 // may transition from one value to the other. i.e. being an ellipse. |
| 714 EXPECT_EQ( | 723 EXPECT_EQ( |
| 715 FloatRoundedRect( | 724 FloatRoundedRect( |
| 716 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs
et(110, 100) | 725 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs
et(110, 100) |
| 717 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0,
0)) | 726 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0,
0)) |
| 718 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0,
0)) | 727 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0,
0)) |
| 719 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0,
0)) | 728 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0,
0)) |
| 720 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0,
0)) | 729 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0,
0)) |
| 721 borderRadiusClip->clipRect()); | 730 borderRadiusClip->clipRect()); |
| 722 EXPECT_EQ(frameContentClip(), borderRadiusClip->parent()); | 731 EXPECT_EQ(frameContentClip(), borderRadiusClip->parent()); |
| 723 CHECK_EXACT_VISUAL_RECT((&div), document().view()->layoutView()); | 732 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 610, 500), &div, document().view()-
>layoutView()); |
| 724 } | 733 } |
| 725 | 734 |
| 726 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes) | 735 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes) |
| 727 { | 736 { |
| 728 setBodyInnerHTML( | 737 setBodyInnerHTML( |
| 729 "<style>body { margin: 0; }</style>" | 738 "<style>body { margin: 0; }</style>" |
| 730 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" | 739 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" |
| 731 " <iframe style='border: 7px solid black' id='frame'></iframe>" | 740 " <iframe style='border: 7px solid black' id='frame'></iframe>" |
| 732 "</div>"); | 741 "</div>"); |
| 733 Document& frameDocument = setupChildIframe("frame", | 742 Document& frameDocument = setupChildIframe("frame", |
| 734 "<style>body { margin: 0; }</style><div id='transform' style='transform:
translate3d(4px, 5px, 6px); width: 100px; height: 200px'></div>"); | 743 "<style>body { margin: 0; }</style><div id='transform' style='transform:
translate3d(4px, 5px, 6px); width: 100px; height: 200px'></div>"); |
| 735 FrameView* frameView = document().view(); | 744 FrameView* frameView = document().view(); |
| 736 frameView->updateAllLifecyclePhases(); | 745 frameView->updateAllLifecyclePhases(); |
| 737 | 746 |
| 738 LayoutObject* divWithTransform = document().getElementById("divWithTransform
")->layoutObject(); | 747 LayoutObject* divWithTransform = document().getElementById("divWithTransform
")->layoutObject(); |
| 739 const ObjectPaintProperties* divWithTransformProperties = divWithTransform->
objectPaintProperties(); | 748 const ObjectPaintProperties* divWithTransformProperties = divWithTransform->
objectPaintProperties(); |
| 740 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope
rties->transform()->matrix()); | 749 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope
rties->transform()->matrix()); |
| 741 // http://crbug.com/638415 | 750 // http://crbug.com/638415 |
| 742 if (!rootLayerScrolls()) { | 751 if (!rootLayerScrolls()) { |
| 743 CHECK_EXACT_VISUAL_RECT(divWithTransform, frameView->layoutView()); | 752 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 164), divWithTransform, fr
ameView->layoutView()); |
| 744 } | 753 } |
| 745 | 754 |
| 746 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); | 755 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); |
| 747 const ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithT
ransform->objectPaintProperties(); | 756 const ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithT
ransform->objectPaintProperties(); |
| 748 auto* innerDivTransform = innerDivWithTransformProperties->transform(); | 757 auto* innerDivTransform = innerDivWithTransformProperties->transform(); |
| 749 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivTransform->ma
trix()); | 758 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivTransform->ma
trix()); |
| 750 CHECK_EXACT_VISUAL_RECT(innerDivWithTransform, frameView->layoutView()); | 759 CHECK_EXACT_VISUAL_RECT(LayoutRect(12, 14, 100, 145), innerDivWithTransform,
frameView->layoutView()); |
| 751 | 760 |
| 752 // Ensure that the inner div's transform is correctly rooted in the root fra
me's transform tree. | 761 // Ensure that the inner div's transform is correctly rooted in the root fra
me's transform tree. |
| 753 // This asserts that we have the following tree structure: | 762 // This asserts that we have the following tree structure: |
| 754 // ... | 763 // ... |
| 755 // Transform transform=translation=1.000000,2.000000,3.000000 | 764 // Transform transform=translation=1.000000,2.000000,3.000000 |
| 756 // PreTranslation transform=translation=7.000000,7.000000,0.000000 | 765 // PreTranslation transform=translation=7.000000,7.000000,0.000000 |
| 757 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000 | 766 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000 |
| 758 // Transform transform=translation=4.000000,5.000000,6.000000 | 767 // Transform transform=translation=4.000000,5.000000,6.000000 |
| 759 auto* innerDocumentScrollTranslation = innerDivTransform->parent(); | 768 auto* innerDocumentScrollTranslation = innerDivTransform->parent(); |
| 760 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr
anslation->matrix()); | 769 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr
anslation->matrix()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 781 // PaintOffsetTranslation transform=translation=7.000000,7.000000,0.0000
00 | 790 // PaintOffsetTranslation transform=translation=7.000000,7.000000,0.0000
00 |
| 782 // Transform transform=translation=4.000000,5.000000,6.000000 | 791 // Transform transform=translation=4.000000,5.000000,6.000000 |
| 783 // PreTranslation transform=translation=42.000000,42.000000,0.000000 | 792 // PreTranslation transform=translation=42.000000,42.000000,0.000000 |
| 784 // ScrollTranslation transform=translation=0.000000,0.000000,0.000
000 | 793 // ScrollTranslation transform=translation=0.000000,0.000000,0.000
000 |
| 785 // PaintOffsetTranslation transform=translation=31.000000,31.000
000,0.000000 | 794 // PaintOffsetTranslation transform=translation=31.000000,31.000
000,0.000000 |
| 786 // Transform transform=translation=7.000000,8.000000,9.000000 | 795 // Transform transform=translation=7.000000,8.000000,9.000000 |
| 787 | 796 |
| 788 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); | 797 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); |
| 789 auto* innerDivTransform = innerDivWithTransform->objectPaintProperties()->tr
ansform(); | 798 auto* innerDivTransform = innerDivWithTransform->objectPaintProperties()->tr
ansform(); |
| 790 EXPECT_EQ(TransformationMatrix().translate3d(7, 8, 9), innerDivTransform->ma
trix()); | 799 EXPECT_EQ(TransformationMatrix().translate3d(7, 8, 9), innerDivTransform->ma
trix()); |
| 791 CHECK_EXACT_VISUAL_RECT(innerDivWithTransform, frameView->layoutView()); | 800 CHECK_EXACT_VISUAL_RECT(LayoutRect(92, 95, 100, 111), innerDivWithTransform,
frameView->layoutView()); |
| 792 | 801 |
| 793 auto* innerDocumentPaintOffsetTranslation = innerDivTransform->parent(); | 802 auto* innerDocumentPaintOffsetTranslation = innerDivTransform->parent(); |
| 794 EXPECT_EQ(TransformationMatrix().translate3d(31, 31, 0), innerDocumentPaintO
ffsetTranslation->matrix()); | 803 EXPECT_EQ(TransformationMatrix().translate3d(31, 31, 0), innerDocumentPaintO
ffsetTranslation->matrix()); |
| 795 auto* innerDocumentScrollTranslation = innerDocumentPaintOffsetTranslation->
parent(); | 804 auto* innerDocumentScrollTranslation = innerDocumentPaintOffsetTranslation->
parent(); |
| 796 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr
anslation->matrix()); | 805 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr
anslation->matrix()); |
| 797 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); | 806 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); |
| 798 EXPECT_EQ(TransformationMatrix().translate3d(42, 42, 0), iframePreTranslatio
n->matrix()); | 807 EXPECT_EQ(TransformationMatrix().translate3d(42, 42, 0), iframePreTranslatio
n->matrix()); |
| 799 auto* iframeTransform = iframePreTranslation->parent(); | 808 auto* iframeTransform = iframePreTranslation->parent(); |
| 800 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), iframeTransform->matr
ix()); | 809 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), iframeTransform->matr
ix()); |
| 801 auto* iframePaintOffsetTranslation = iframeTransform->parent(); | 810 auto* iframePaintOffsetTranslation = iframeTransform->parent(); |
| 802 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePaintOffsetTran
slation->matrix()); | 811 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePaintOffsetTran
slation->matrix()); |
| 803 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); | 812 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); |
| 804 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformTrans
form->matrix()); | 813 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformTrans
form->matrix()); |
| 805 | 814 |
| 806 LayoutObject* divWithTransform = document().getElementById("divWithTransform
")->layoutObject(); | 815 LayoutObject* divWithTransform = document().getElementById("divWithTransform
")->layoutObject(); |
| 807 EXPECT_EQ(divWithTransformTransform, divWithTransform->objectPaintProperties
()->transform()); | 816 EXPECT_EQ(divWithTransformTransform, divWithTransform->objectPaintProperties
()->transform()); |
| 808 // http://crbug.com/638415 | 817 // http://crbug.com/638415 |
| 809 if (!rootLayerScrolls()) { | 818 if (!rootLayerScrolls()) { |
| 810 CHECK_EXACT_VISUAL_RECT(divWithTransform, frameView->layoutView()); | 819 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 248), divWithTransform, fr
ameView->layoutView()); |
| 811 } | 820 } |
| 812 } | 821 } |
| 813 | 822 |
| 814 TEST_P(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) | 823 TEST_P(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) |
| 815 { | 824 { |
| 816 // This test verifies the tree builder correctly computes and records the pr
operty tree context | 825 // This test verifies the tree builder correctly computes and records the pr
operty tree context |
| 817 // for a (pseudo) stacking context that is scrolled by a containing block th
at is not one of | 826 // for a (pseudo) stacking context that is scrolled by a containing block th
at is not one of |
| 818 // the painting ancestors. | 827 // the painting ancestors. |
| 819 setBodyInnerHTML( | 828 setBodyInnerHTML( |
| 820 "<style>body { margin: 0; }</style>" | 829 "<style>body { margin: 0; }</style>" |
| 821 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>
" | 830 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>
" |
| 822 " <div id='child' style='position:relative; width:100px; height: 200px;
'></div>" | 831 " <div id='child' style='position:relative; width:100px; height: 200px;
'></div>" |
| 823 " <div style='height:10000px;'></div>" | 832 " <div style='height:10000px;'></div>" |
| 824 "</div>" | 833 "</div>" |
| 825 ); | 834 ); |
| 826 FrameView* frameView = document().view(); | 835 FrameView* frameView = document().view(); |
| 827 | 836 |
| 828 LayoutObject* scroller = document().getElementById("scroller")->layoutObject
(); | 837 LayoutObject* scroller = document().getElementById("scroller")->layoutObject
(); |
| 829 const ObjectPaintProperties* scrollerProperties = scroller->objectPaintPrope
rties(); | 838 const ObjectPaintProperties* scrollerProperties = scroller->objectPaintPrope
rties(); |
| 830 LayoutObject* child = document().getElementById("child")->layoutObject(); | 839 LayoutObject* child = document().getElementById("child")->layoutObject(); |
| 831 const ObjectPaintProperties* childProperties = child->objectPaintProperties(
); | 840 const ObjectPaintProperties* childProperties = child->objectPaintProperties(
); |
| 832 | 841 |
| 833 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo
xProperties()->propertyTreeState.clip); | 842 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo
xProperties()->propertyTreeState.clip); |
| 834 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor
derBoxProperties()->propertyTreeState.transform); | 843 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor
derBoxProperties()->propertyTreeState.transform); |
| 835 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTree
State.effect); | 844 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTree
State.effect); |
| 836 CHECK_EXACT_VISUAL_RECT(scroller, frameView->layoutView()); | 845 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 300), scroller, frameView->lay
outView()); |
| 837 CHECK_EXACT_VISUAL_RECT(child, frameView->layoutView()); | 846 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), child, frameView->layout
View()); |
| 838 } | 847 } |
| 839 | 848 |
| 840 TEST_P(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext) | 849 TEST_P(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext) |
| 841 { | 850 { |
| 842 // This test verifies the tree builder correctly computes and records the pr
operty tree context | 851 // This test verifies the tree builder correctly computes and records the pr
operty tree context |
| 843 // for a (pseudo) stacking context that has a scrolling painting ancestor th
at is not its | 852 // for a (pseudo) stacking context that has a scrolling painting ancestor th
at is not its |
| 844 // containing block (thus should not be scrolled by it). | 853 // containing block (thus should not be scrolled by it). |
| 845 | 854 |
| 846 setBodyInnerHTML( | 855 setBodyInnerHTML( |
| 847 "<style>body { margin: 0; }</style>" | 856 "<style>body { margin: 0; }</style>" |
| 848 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" | 857 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" |
| 849 " <div id='child' style='position:absolute; left:0; top:0; width: 100px
; height: 200px'></div>" | 858 " <div id='child' style='position:absolute; left:0; top:0; width: 100px
; height: 200px'></div>" |
| 850 " <div style='height:10000px;'></div>" | 859 " <div style='height:10000px;'></div>" |
| 851 "</div>" | 860 "</div>" |
| 852 ); | 861 ); |
| 853 | 862 |
| 854 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec
t(); | 863 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec
t(); |
| 855 const ObjectPaintProperties* scrollerProperties = scroller.objectPaintProper
ties(); | 864 const ObjectPaintProperties* scrollerProperties = scroller.objectPaintProper
ties(); |
| 856 LayoutObject& child = *document().getElementById("child")->layoutObject(); | 865 LayoutObject& child = *document().getElementById("child")->layoutObject(); |
| 857 const ObjectPaintProperties* childProperties = child.objectPaintProperties()
; | 866 const ObjectPaintProperties* childProperties = child.objectPaintProperties()
; |
| 858 | 867 |
| 859 EXPECT_EQ(frameContentClip(), childProperties->localBorderBoxProperties()->p
ropertyTreeState.clip); | 868 EXPECT_EQ(frameContentClip(), childProperties->localBorderBoxProperties()->p
ropertyTreeState.clip); |
| 860 EXPECT_EQ(frameScrollTranslation(), childProperties->localBorderBoxPropertie
s()->propertyTreeState.transform); | 869 EXPECT_EQ(frameScrollTranslation(), childProperties->localBorderBoxPropertie
s()->propertyTreeState.transform); |
| 861 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope
rties()->propertyTreeState.effect); | 870 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope
rties()->propertyTreeState.effect); |
| 862 if (!rootLayerScrolls()) { | 871 if (!rootLayerScrolls()) { |
| 863 CHECK_EXACT_VISUAL_RECT((&scroller), document().view()->layoutView()); | 872 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 800, 10000), &scroller, documen
t().view()->layoutView()); |
| 864 } | 873 } |
| 865 CHECK_EXACT_VISUAL_RECT((&child), document().view()->layoutView()); | 874 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), &child, document().view(
)->layoutView()); |
| 866 } | 875 } |
| 867 | 876 |
| 868 TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) | 877 TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) |
| 869 { | 878 { |
| 870 // This test verifies that the border box space of a table cell is being cor
rectly computed. | 879 // This test verifies that the border box space of a table cell is being cor
rectly computed. |
| 871 // Table cells have weird location adjustment in our layout/paint implementa
tion. | 880 // Table cells have weird location adjustment in our layout/paint implementa
tion. |
| 872 setBodyInnerHTML( | 881 setBodyInnerHTML( |
| 873 "<style>" | 882 "<style>" |
| 874 " body {" | 883 " body {" |
| 875 " margin: 0;" | 884 " margin: 0;" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 895 " <tr><td></td><td></td></tr>" | 904 " <tr><td></td><td></td></tr>" |
| 896 " <tr><td></td><td><div id='target'></div></td></tr>" | 905 " <tr><td></td><td><div id='target'></div></td></tr>" |
| 897 "</table>" | 906 "</table>" |
| 898 ); | 907 ); |
| 899 | 908 |
| 900 LayoutObject& target = *document().getElementById("target")->layoutObject(); | 909 LayoutObject& target = *document().getElementById("target")->layoutObject(); |
| 901 const ObjectPaintProperties* targetProperties = target.objectPaintProperties
(); | 910 const ObjectPaintProperties* targetProperties = target.objectPaintProperties
(); |
| 902 | 911 |
| 903 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties(
)->paintOffset); | 912 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties(
)->paintOffset); |
| 904 EXPECT_EQ(frameScrollTranslation(), targetProperties->localBorderBoxProperti
es()->propertyTreeState.transform); | 913 EXPECT_EQ(frameScrollTranslation(), targetProperties->localBorderBoxProperti
es()->propertyTreeState.transform); |
| 905 CHECK_EXACT_VISUAL_RECT((&target), document().view()->layoutView()); | 914 CHECK_EXACT_VISUAL_RECT(LayoutRect(170, 170, 100, 100), &target, document().
view()->layoutView()); |
| 906 } | 915 } |
| 907 | 916 |
| 908 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) | 917 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) |
| 909 { | 918 { |
| 910 // This test verifies that clip tree hierarchy being generated correctly for
the hard case | 919 // This test verifies that clip tree hierarchy being generated correctly for
the hard case |
| 911 // such that a fixed position element getting clipped by an absolute positio
n CSS clip. | 920 // such that a fixed position element getting clipped by an absolute positio
n CSS clip. |
| 912 setBodyInnerHTML( | 921 setBodyInnerHTML( |
| 913 "<style>" | 922 "<style>" |
| 914 " #clip {" | 923 " #clip {" |
| 915 " position: absolute;" | 924 " position: absolute;" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 931 ); | 940 ); |
| 932 LayoutRect localClipRect(40, 10, 40, 60); | 941 LayoutRect localClipRect(40, 10, 40, 60); |
| 933 LayoutRect absoluteClipRect = localClipRect; | 942 LayoutRect absoluteClipRect = localClipRect; |
| 934 absoluteClipRect.move(123, 456); | 943 absoluteClipRect.move(123, 456); |
| 935 | 944 |
| 936 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); | 945 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); |
| 937 const ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); | 946 const ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); |
| 938 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent()); | 947 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent()); |
| 939 EXPECT_EQ(frameScrollTranslation(), clipProperties->cssClip()->localTransfor
mSpace()); | 948 EXPECT_EQ(frameScrollTranslation(), clipProperties->cssClip()->localTransfor
mSpace()); |
| 940 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); | 949 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
| 941 // TODO(chrishtr): the old visual rect code is not able to apply CSS clip to fix
ed-position elements. | 950 CHECK_VISUAL_RECT(absoluteClipRect, &clip, document().view()->layoutView(), |
| 942 // CHECK_EXACT_VISUAL_RECT(clip, frameView->layoutView()); | 951 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() doesn't appl
y css clip on the object itself. |
| 952 LayoutUnit::max()); |
| 943 | 953 |
| 944 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 954 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 945 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); | 955 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); |
| 946 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti
es()->propertyTreeState.clip); | 956 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti
es()->propertyTreeState.clip); |
| 947 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties()
->propertyTreeState.transform->parent()); | 957 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties()
->propertyTreeState.transform->parent()); |
| 948 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); | 958 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); |
| 949 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); | 959 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); |
| 950 // http://crbug.com/638386 | 960 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(), |
| 951 if (!rootLayerScrolls()) { | 961 // TODO(crbug.com/599939): CSS clip of fixed-position descendants is bro
ken in mapToVisualRectInAncestorSpace(). |
| 952 CHECK_EXACT_VISUAL_RECT(fixed, document().view()->layoutView()); | 962 LayoutUnit::max()); |
| 953 } | |
| 954 } | 963 } |
| 955 | 964 |
| 956 TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) | 965 TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) |
| 957 { | 966 { |
| 958 // This test verifies that clip tree hierarchy being generated correctly for
the hard case | 967 // This test verifies that clip tree hierarchy being generated correctly for
the hard case |
| 959 // such that a fixed position element getting clipped by an absolute positio
n CSS clip. | 968 // such that a fixed position element getting clipped by an absolute positio
n CSS clip. |
| 960 setBodyInnerHTML( | 969 setBodyInnerHTML( |
| 961 "<style>" | 970 "<style>" |
| 962 " #clip {" | 971 " #clip {" |
| 963 " position: absolute;" | 972 " position: absolute;" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 974 " width: 10px;" | 983 " width: 10px;" |
| 975 " heght: 20px" | 984 " heght: 20px" |
| 976 " }" | 985 " }" |
| 977 "</style>" | 986 "</style>" |
| 978 "<div id='clip'><div id='absolute'></div></div>" | 987 "<div id='clip'><div id='absolute'></div></div>" |
| 979 ); | 988 ); |
| 980 LayoutRect localClipRect(40, 10, 40, 60); | 989 LayoutRect localClipRect(40, 10, 40, 60); |
| 981 LayoutRect absoluteClipRect = localClipRect; | 990 LayoutRect absoluteClipRect = localClipRect; |
| 982 absoluteClipRect.move(123, 456); | 991 absoluteClipRect.move(123, 456); |
| 983 | 992 |
| 984 FrameView* frameView = document().view(); | |
| 985 | |
| 986 LayoutObject* clip = document().getElementById("clip")->layoutObject(); | 993 LayoutObject* clip = document().getElementById("clip")->layoutObject(); |
| 987 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); | 994 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); |
| 988 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent()); | 995 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent()); |
| 989 EXPECT_EQ(frameScrollTranslation(), clipProperties->cssClip()->localTransfor
mSpace()); | 996 EXPECT_EQ(frameScrollTranslation(), clipProperties->cssClip()->localTransfor
mSpace()); |
| 990 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); | 997 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
| 991 // TODO(chrishtr): the old visual rect code is not able to apply CSS clip to fix
ed-position elements. | 998 CHECK_VISUAL_RECT(absoluteClipRect, clip, document().view()->layoutView(), |
| 992 // CHECK_VISUAL_RECT(clip, frameView->layoutView()); | 999 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() doesn't appl
y css clip on the object itself. |
| 1000 LayoutUnit::max()); |
| 993 | 1001 |
| 994 LayoutObject* absolute = document().getElementById("absolute")->layoutObject
(); | 1002 LayoutObject* absolute = document().getElementById("absolute")->layoutObject
(); |
| 995 const ObjectPaintProperties* absPosProperties = absolute->objectPaintPropert
ies(); | 1003 const ObjectPaintProperties* absPosProperties = absolute->objectPaintPropert
ies(); |
| 996 EXPECT_EQ(clipProperties->cssClip(), absPosProperties->localBorderBoxPropert
ies()->propertyTreeState.clip); | 1004 EXPECT_EQ(clipProperties->cssClip(), absPosProperties->localBorderBoxPropert
ies()->propertyTreeState.clip); |
| 997 EXPECT_EQ(framePreTranslation(), absPosProperties->localBorderBoxProperties(
)->propertyTreeState.transform->parent()); | 1005 EXPECT_EQ(framePreTranslation(), absPosProperties->localBorderBoxProperties(
)->propertyTreeState.transform->parent()); |
| 998 EXPECT_EQ(LayoutPoint(123, 456), absPosProperties->localBorderBoxProperties(
)->paintOffset); | 1006 EXPECT_EQ(LayoutPoint(123, 456), absPosProperties->localBorderBoxProperties(
)->paintOffset); |
| 999 // http://crbug.com/638386 | 1007 CHECK_VISUAL_RECT(LayoutRect(), absolute, document().view()->layoutView(), |
| 1000 if (!rootLayerScrolls()) { | 1008 // TODO(crbug.com/599939): CSS clip of fixed-position descendants is bro
ken in mapToVisualRectInAncestorSpace(). |
| 1001 CHECK_EXACT_VISUAL_RECT(absolute, frameView->layoutView()); | 1009 LayoutUnit::max()); |
| 1002 } | |
| 1003 } | 1010 } |
| 1004 | 1011 |
| 1005 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) | 1012 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) |
| 1006 { | 1013 { |
| 1007 // This test is similar to CSSClipFixedPositionDescendant above, except that | 1014 // This test is similar to CSSClipFixedPositionDescendant above, except that |
| 1008 // now we have a parent overflow clip that should be escaped by the fixed de
scendant. | 1015 // now we have a parent overflow clip that should be escaped by the fixed de
scendant. |
| 1009 setBodyInnerHTML( | 1016 setBodyInnerHTML( |
| 1010 "<style>" | 1017 "<style>" |
| 1011 " body {" | 1018 " body {" |
| 1012 " margin: 0;" | 1019 " margin: 0;" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1034 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>" | 1041 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>" |
| 1035 ); | 1042 ); |
| 1036 LayoutRect localClipRect(40, 10, 40, 60); | 1043 LayoutRect localClipRect(40, 10, 40, 60); |
| 1037 LayoutRect absoluteClipRect = localClipRect; | 1044 LayoutRect absoluteClipRect = localClipRect; |
| 1038 absoluteClipRect.move(123, 456); | 1045 absoluteClipRect.move(123, 456); |
| 1039 | 1046 |
| 1040 LayoutObject& overflow = *document().getElementById("overflow")->layoutObjec
t(); | 1047 LayoutObject& overflow = *document().getElementById("overflow")->layoutObjec
t(); |
| 1041 const ObjectPaintProperties* overflowProperties = overflow.objectPaintProper
ties(); | 1048 const ObjectPaintProperties* overflowProperties = overflow.objectPaintProper
ties(); |
| 1042 EXPECT_EQ(frameContentClip(), overflowProperties->overflowClip()->parent()); | 1049 EXPECT_EQ(frameContentClip(), overflowProperties->overflowClip()->parent()); |
| 1043 EXPECT_EQ(frameScrollTranslation(), overflowProperties->scrollTranslation()-
>parent()); | 1050 EXPECT_EQ(frameScrollTranslation(), overflowProperties->scrollTranslation()-
>parent()); |
| 1044 CHECK_EXACT_VISUAL_RECT((&overflow), document().view()->layoutView()); | 1051 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 50, 50), &overflow, document().view
()->layoutView()); |
| 1045 | 1052 |
| 1046 LayoutObject* clip = document().getElementById("clip")->layoutObject(); | 1053 LayoutObject* clip = document().getElementById("clip")->layoutObject(); |
| 1047 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); | 1054 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); |
| 1048 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par
ent()); | 1055 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par
ent()); |
| 1049 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClip()
->localTransformSpace()); | 1056 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClip()
->localTransformSpace()); |
| 1050 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); | 1057 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
| 1051 EXPECT_EQ(frameContentClip(), clipProperties->cssClipFixedPosition()->parent
()); | 1058 EXPECT_EQ(frameContentClip(), clipProperties->cssClipFixedPosition()->parent
()); |
| 1052 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClipFi
xedPosition()->localTransformSpace()); | 1059 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClipFi
xedPosition()->localTransformSpace()); |
| 1053 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
ClipFixedPosition()->clipRect()); | 1060 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
ClipFixedPosition()->clipRect()); |
| 1054 CHECK_EXACT_VISUAL_RECT(clip, document().view()->layoutView()); | 1061 CHECK_EXACT_VISUAL_RECT(LayoutRect(), clip, document().view()->layoutView())
; |
| 1055 | 1062 |
| 1056 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 1063 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 1057 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); | 1064 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); |
| 1058 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord
erBoxProperties()->propertyTreeState.clip); | 1065 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord
erBoxProperties()->propertyTreeState.clip); |
| 1059 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties()
->propertyTreeState.transform->parent()); | 1066 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties()
->propertyTreeState.transform->parent()); |
| 1060 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); | 1067 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); |
| 1061 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); | 1068 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); |
| 1062 // http://crbug.com/638386 | 1069 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(), |
| 1063 if (!rootLayerScrolls()) { | 1070 // TODO(crbug.com/599939): CSS clip of fixed-position descendants is bro
ken in geometry mapping. |
| 1064 CHECK_EXACT_VISUAL_RECT(fixed, document().view()->layoutView()); | 1071 LayoutUnit::max()); |
| 1065 } | |
| 1066 } | 1072 } |
| 1067 | 1073 |
| 1068 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) | 1074 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) |
| 1069 { | 1075 { |
| 1070 setBodyInnerHTML( | 1076 setBodyInnerHTML( |
| 1071 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" | 1077 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" |
| 1072 " <div style='position: relative; top: 100px; left: 100px'>" | 1078 " <div style='position: relative; top: 100px; left: 100px'>" |
| 1073 " <div id='spanner' style='column-span: all; opacity: 0.5; width: 100
px; height: 100px;'></div>" | 1079 " <div id='spanner' style='column-span: all; opacity: 0.5; width: 100
px; height: 100px;'></div>" |
| 1074 " </div>" | 1080 " </div>" |
| 1075 "</div>" | 1081 "</div>" |
| 1076 ); | 1082 ); |
| 1077 | 1083 |
| 1078 LayoutObject* spanner = getLayoutObjectByElementId("spanner"); | 1084 LayoutObject* spanner = getLayoutObjectByElementId("spanner"); |
| 1079 EXPECT_EQ(LayoutPoint(55, 44), spanner->objectPaintProperties()->localBorder
BoxProperties()->paintOffset); | 1085 EXPECT_EQ(LayoutPoint(55, 44), spanner->objectPaintProperties()->localBorder
BoxProperties()->paintOffset); |
| 1080 CHECK_EXACT_VISUAL_RECT(spanner, document().view()->layoutView()); | 1086 CHECK_EXACT_VISUAL_RECT(LayoutRect(55, 44, 100, 100), spanner, document().vi
ew()->layoutView()); |
| 1081 } | 1087 } |
| 1082 | 1088 |
| 1083 TEST_P(PaintPropertyTreeBuilderTest, FractionalPaintOffset) | 1089 TEST_P(PaintPropertyTreeBuilderTest, FractionalPaintOffset) |
| 1084 { | 1090 { |
| 1085 setBodyInnerHTML( | 1091 setBodyInnerHTML( |
| 1086 "<style>" | 1092 "<style>" |
| 1087 " * { margin: 0; }" | 1093 " * { margin: 0; }" |
| 1088 " div { position: absolute; }" | 1094 " div { position: absolute; }" |
| 1089 "</style>" | 1095 "</style>" |
| 1090 "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;'
>" | 1096 "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;'
>" |
| 1091 " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: 11.1p
x;'></div>" | 1097 " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: 11.1p
x;'></div>" |
| 1092 "</div>" | 1098 "</div>" |
| 1093 ); | 1099 ); |
| 1094 FrameView* frameView = document().view(); | 1100 FrameView* frameView = document().view(); |
| 1095 | 1101 |
| 1096 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1102 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1097 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1103 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); |
| 1098 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3)); | 1104 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3)); |
| 1099 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset
); | 1105 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset
); |
| 1100 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); | 1106 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.1), LayoutUnit(0.3), LayoutU
nit(70), LayoutUnit(70)), a, frameView->layoutView()); |
| 1101 | 1107 |
| 1102 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1108 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1103 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1109 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1104 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1))
; | 1110 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1))
; |
| 1105 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset
); | 1111 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset
); |
| 1106 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); | 1112 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.1), LayoutUnit(0.3), LayoutU
nit(70), LayoutUnit(70)), a, frameView->layoutView()); |
| 1107 } | 1113 } |
| 1108 | 1114 |
| 1109 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping) | 1115 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping) |
| 1110 { | 1116 { |
| 1111 setBodyInnerHTML( | 1117 setBodyInnerHTML( |
| 1112 "<style>" | 1118 "<style>" |
| 1113 " * { margin: 0; }" | 1119 " * { margin: 0; }" |
| 1114 " div { position: relative; }" | 1120 " div { position: relative; }" |
| 1115 "</style>" | 1121 "</style>" |
| 1116 "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;'
>" | 1122 "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;'
>" |
| 1117 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" | 1123 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" |
| 1118 " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: 0.1
px;'></div>" | 1124 " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: 0.1
px;'></div>" |
| 1119 " </div>" | 1125 " </div>" |
| 1120 "</div>" | 1126 "</div>" |
| 1121 ); | 1127 ); |
| 1122 FrameView* frameView = document().view(); | 1128 FrameView* frameView = document().view(); |
| 1123 | 1129 |
| 1124 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1130 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1125 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1131 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1126 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); | 1132 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); |
| 1127 // The paint offset transform should be snapped from (0.3,0.3) to (0,0). | 1133 // The paint offset transform should be snapped from (0.3,0.3) to (0,0). |
| 1128 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()->
parent()->matrix()); | 1134 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()->
parent()->matrix()); |
| 1129 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3). | 1135 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3). |
| 1130 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3)); | 1136 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3)); |
| 1131 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); | 1137 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); |
| 1132 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); | 1138 CHECK_EXACT_VISUAL_RECT(LayoutRect(FloatRect(0.3, 0.3, 40, 40)), b, frameVie
w->layoutView()); |
| 1133 | 1139 |
| 1134 // c should be painted starting at subpixelAccumulation + (0.1,0.1) = (0.4,0
.4). | 1140 // c should be painted starting at subpixelAccumulation + (0.1,0.1) = (0.4,0
.4). |
| 1135 LayoutObject* c = document().getElementById("c")->layoutObject(); | 1141 LayoutObject* c = document().getElementById("c")->layoutObject(); |
| 1136 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.1
, 0.1)); | 1142 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.1
, 0.1)); |
| 1137 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); | 1143 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); |
| 1138 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); | 1144 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); |
| 1139 // Visual rects via the non-paint properties system use enclosingIntRect bef
ore applying transforms, | 1145 // Visual rects via the non-paint properties system use enclosingIntRect bef
ore applying transforms, |
| 1140 // because they are computed bottom-up and therefore can't apply pixel snapp
ing. Therefore apply a | 1146 // because they are computed bottom-up and therefore can't apply pixel snapp
ing. Therefore apply a |
| 1141 // slop of 1px. | 1147 // slop of 1px. |
| 1142 CHECK_VISUAL_RECT(c, frameView->layoutView(), 1); | 1148 CHECK_VISUAL_RECT(LayoutRect(FloatRect(0.4, 0.4, 40, 40)), c, frameView->lay
outView(), 1); |
| 1143 } | 1149 } |
| 1144 | 1150 |
| 1145 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughTransfor
m) | 1151 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughTransfor
m) |
| 1146 { | 1152 { |
| 1147 setBodyInnerHTML( | 1153 setBodyInnerHTML( |
| 1148 "<style>" | 1154 "<style>" |
| 1149 " * { margin: 0; }" | 1155 " * { margin: 0; }" |
| 1150 " div { position: relative; }" | 1156 " div { position: relative; }" |
| 1151 "</style>" | 1157 "</style>" |
| 1152 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" | 1158 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" |
| 1153 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" | 1159 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" |
| 1154 " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: 0.7
px;'></div>" | 1160 " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: 0.7
px;'></div>" |
| 1155 " </div>" | 1161 " </div>" |
| 1156 "</div>" | 1162 "</div>" |
| 1157 ); | 1163 ); |
| 1158 FrameView* frameView = document().view(); | 1164 FrameView* frameView = document().view(); |
| 1159 | 1165 |
| 1160 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1166 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1161 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1167 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1162 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); | 1168 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); |
| 1163 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). | 1169 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). |
| 1164 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()->
parent()->matrix()); | 1170 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()->
parent()->matrix()); |
| 1165 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3
). | 1171 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3
). |
| 1166 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
.7)) - LayoutPoint(1, 1)); | 1172 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
.7)) - LayoutPoint(1, 1)); |
| 1167 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); | 1173 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); |
| 1168 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); | 1174 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0.7), LayoutU
nit(40), LayoutUnit(40)), b, frameView->layoutView()); |
| 1169 | 1175 |
| 1170 // c should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). | 1176 // c should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). |
| 1171 LayoutObject* c = document().getElementById("c")->layoutObject(); | 1177 LayoutObject* c = document().getElementById("c")->layoutObject(); |
| 1172 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); | 1178 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); |
| 1173 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); | 1179 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); |
| 1174 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); | 1180 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); |
| 1175 // Visual rects via the non-paint properties system use enclosingIntRect bef
ore applying transforms, | 1181 // Visual rects via the non-paint properties system use enclosingIntRect bef
ore applying transforms, |
| 1176 // because they are computed bottom-up and therefore can't apply pixel snapp
ing. Therefore apply a | 1182 // because they are computed bottom-up and therefore can't apply pixel snapp
ing. Therefore apply a |
| 1177 // slop of 1px. | 1183 // slop of 1px. |
| 1178 CHECK_VISUAL_RECT(c, frameView->layoutView(), 1); | 1184 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7), LayoutUnit(0
.7) + LayoutUnit(0.7), LayoutUnit(40), LayoutUnit(40)), c, frameView->layoutView
(), 1); |
| 1179 } | 1185 } |
| 1180 | 1186 |
| 1181 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughMultiple
Transforms) | 1187 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughMultiple
Transforms) |
| 1182 { | 1188 { |
| 1183 setBodyInnerHTML( | 1189 setBodyInnerHTML( |
| 1184 "<style>" | 1190 "<style>" |
| 1185 " * { margin: 0; }" | 1191 " * { margin: 0; }" |
| 1186 " div { position: relative; }" | 1192 " div { position: relative; }" |
| 1187 "</style>" | 1193 "</style>" |
| 1188 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" | 1194 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" |
| 1189 " <div id='b' style='width: 40px; height: 40px; transform: translate3d(
5px, 7px, 0);'>" | 1195 " <div id='b' style='width: 40px; height: 40px; transform: translate3d(
5px, 7px, 0);'>" |
| 1190 " <div id='c' style='width: 40px; height: 40px; transform: translate3
d(11px, 13px, 0);'>" | 1196 " <div id='c' style='width: 40px; height: 40px; transform: translate3
d(11px, 13px, 0);'>" |
| 1191 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: 0
.7px;'></div>" | 1197 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: 0
.7px;'></div>" |
| 1192 " </div>" | 1198 " </div>" |
| 1193 " </div>" | 1199 " </div>" |
| 1194 "</div>" | 1200 "</div>" |
| 1195 ); | 1201 ); |
| 1196 FrameView* frameView = document().view(); | 1202 FrameView* frameView = document().view(); |
| 1197 | 1203 |
| 1198 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1204 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1199 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1205 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1200 EXPECT_EQ(TransformationMatrix().translate3d(5, 7, 0), bProperties->transfor
m()->matrix()); | 1206 EXPECT_EQ(TransformationMatrix().translate3d(5, 7, 0), bProperties->transfor
m()->matrix()); |
| 1201 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). | 1207 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). |
| 1202 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()->
parent()->matrix()); | 1208 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()->
parent()->matrix()); |
| 1203 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3
). | 1209 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3
). |
| 1204 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
.7)) - LayoutPoint(1, 1)); | 1210 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
.7)) - LayoutPoint(1, 1)); |
| 1205 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); | 1211 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); |
| 1206 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); | 1212 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(5.7), LayoutUnit(7.7), LayoutU
nit(40), LayoutUnit(40)), b, frameView->layoutView()); |
| 1207 | 1213 |
| 1208 LayoutObject* c = document().getElementById("c")->layoutObject(); | 1214 LayoutObject* c = document().getElementById("c")->layoutObject(); |
| 1209 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); | 1215 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); |
| 1210 EXPECT_EQ(TransformationMatrix().translate3d(11, 13, 0), cProperties->transf
orm()->matrix()); | 1216 EXPECT_EQ(TransformationMatrix().translate3d(11, 13, 0), cProperties->transf
orm()->matrix()); |
| 1211 // The paint offset should be (-0.3,-0.3) but the paint offset transform sho
uld still be at | 1217 // The paint offset should be (-0.3,-0.3) but the paint offset transform sho
uld still be at |
| 1212 // (0,0) because it should be snapped. | 1218 // (0,0) because it should be snapped. |
| 1213 EXPECT_EQ(TransformationMatrix().translate(0, 0), cProperties->transform()->
parent()->matrix()); | 1219 EXPECT_EQ(TransformationMatrix().translate(0, 0), cProperties->transform()->
parent()->matrix()); |
| 1214 // The residual subpixel adjustment should still be (-0.3,-0.3). | 1220 // The residual subpixel adjustment should still be (-0.3,-0.3). |
| 1215 EXPECT_EQ(subpixelAccumulation, cProperties->localBorderBoxProperties()->pai
ntOffset); | 1221 EXPECT_EQ(subpixelAccumulation, cProperties->localBorderBoxProperties()->pai
ntOffset); |
| 1216 CHECK_EXACT_VISUAL_RECT(c, frameView->layoutView()); | 1222 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(16.7), LayoutUnit(20.7), Layou
tUnit(40), LayoutUnit(40)), c, frameView->layoutView()); |
| 1217 | 1223 |
| 1218 // d should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). | 1224 // d should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). |
| 1219 LayoutObject* d = document().getElementById("d")->layoutObject(); | 1225 LayoutObject* d = document().getElementById("d")->layoutObject(); |
| 1220 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); | 1226 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); |
| 1221 const ObjectPaintProperties* dProperties = d->objectPaintProperties(); | 1227 const ObjectPaintProperties* dProperties = d->objectPaintProperties(); |
| 1222 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); | 1228 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); |
| 1223 // Visual rects via the non-paint properties system use enclosingIntRect bef
ore applying transforms, | 1229 // Visual rects via the non-paint properties system use enclosingIntRect bef
ore applying transforms, |
| 1224 // because they are computed bottom-up and therefore can't apply pixel snapp
ing. Therefore apply a | 1230 // because they are computed bottom-up and therefore can't apply pixel snapp
ing. Therefore apply a |
| 1225 // slop of 1px. | 1231 // slop of 1px. |
| 1226 CHECK_VISUAL_RECT(d, frameView->layoutView(), 1); | 1232 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(16.7) + LayoutUnit(0.7), LayoutUnit(
20.7) + LayoutUnit(0.7), LayoutUnit(40), LayoutUnit(40)), d, frameView->layoutVi
ew(), 1); |
| 1227 } | 1233 } |
| 1228 | 1234 |
| 1229 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) | 1235 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) |
| 1230 { | 1236 { |
| 1231 setBodyInnerHTML( | 1237 setBodyInnerHTML( |
| 1232 "<style>" | 1238 "<style>" |
| 1233 " * { margin: 0; }" | 1239 " * { margin: 0; }" |
| 1234 "</style>" | 1240 "</style>" |
| 1235 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: re
lative;'>" | 1241 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: re
lative;'>" |
| 1236 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
); position: relative;'>" | 1242 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
); position: relative;'>" |
| 1237 " <div id='fixed' style='width: 40px; height: 40px; position: fixed;'
>" | 1243 " <div id='fixed' style='width: 40px; height: 40px; position: fixed;'
>" |
| 1238 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; positi
on: relative;'></div>" | 1244 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; positi
on: relative;'></div>" |
| 1239 " </div>" | 1245 " </div>" |
| 1240 " </div>" | 1246 " </div>" |
| 1241 "</div>" | 1247 "</div>" |
| 1242 ); | 1248 ); |
| 1243 FrameView* frameView = document().view(); | 1249 FrameView* frameView = document().view(); |
| 1244 | 1250 |
| 1245 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1251 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1246 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1252 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1247 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()->
matrix()); | 1253 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()->
matrix()); |
| 1248 // The paint offset transform should be snapped from (0.7,0) to (1,0). | 1254 // The paint offset transform should be snapped from (0.7,0) to (1,0). |
| 1249 EXPECT_EQ(TransformationMatrix().translate(1, 0), bProperties->transform()->
parent()->matrix()); | 1255 EXPECT_EQ(TransformationMatrix().translate(1, 0), bProperties->transform()->
parent()->matrix()); |
| 1250 // The residual subpixel adjustment should be (0.7,0) - (1,0) = (-0.3,0). | 1256 // The residual subpixel adjustment should be (0.7,0) - (1,0) = (-0.3,0). |
| 1251 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
)) - LayoutPoint(1, 0)); | 1257 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
)) - LayoutPoint(1, 0)); |
| 1252 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); | 1258 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); |
| 1253 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); | 1259 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0), LayoutUni
t(40), LayoutUnit(40)), b, frameView->layoutView()); |
| 1254 | 1260 |
| 1255 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 1261 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 1256 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); | 1262 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); |
| 1257 // The residual subpixel adjustment should still be (-0.3,0). | 1263 // The residual subpixel adjustment should still be (-0.3,0). |
| 1258 EXPECT_EQ(subpixelAccumulation, fixedProperties->localBorderBoxProperties()-
>paintOffset); | 1264 EXPECT_EQ(subpixelAccumulation, fixedProperties->localBorderBoxProperties()-
>paintOffset); |
| 1259 CHECK_EXACT_VISUAL_RECT(fixed, frameView->layoutView()); | 1265 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0), LayoutUni
t(40), LayoutUnit(40)), fixed, frameView->layoutView()); |
| 1260 | 1266 |
| 1261 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0). | 1267 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0). |
| 1262 LayoutObject* d = document().getElementById("d")->layoutObject(); | 1268 LayoutObject* d = document().getElementById("d")->layoutObject(); |
| 1263 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0)); | 1269 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0)); |
| 1264 const ObjectPaintProperties* dProperties = d->objectPaintProperties(); | 1270 const ObjectPaintProperties* dProperties = d->objectPaintProperties(); |
| 1265 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); | 1271 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); |
| 1266 // Visual rects via the non-paint properties system use enclosingIntRect bef
ore applying transforms, | 1272 // Visual rects via the non-paint properties system use enclosingIntRect bef
ore applying transforms, |
| 1267 // because they are computed bottom-up and therefore can't apply pixel snapp
ing. Therefore apply a | 1273 // because they are computed bottom-up and therefore can't apply pixel snapp
ing. Therefore apply a |
| 1268 // slop of 1px. | 1274 // slop of 1px. |
| 1269 CHECK_VISUAL_RECT(d, frameView->layoutView(), 1); | 1275 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7), LayoutUnit()
, LayoutUnit(40), LayoutUnit(40)), d, frameView->layoutView(), 1); |
| 1270 } | 1276 } |
| 1271 | 1277 |
| 1272 TEST_P(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) | 1278 TEST_P(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) |
| 1273 { | 1279 { |
| 1274 setBodyInnerHTML( | 1280 setBodyInnerHTML( |
| 1275 "<svg id='svg' style='position: relative; left: 0.1px; transform: matrix
(1, 0, 0, 1, 0, 0);'>" | 1281 "<svg id='svg' style='position: relative; left: 0.1px; transform: matrix
(1, 0, 0, 1, 0, 0);'>" |
| 1276 " <rect id='rect' transform='translate(1, 1)'/>" | 1282 " <rect id='rect' transform='translate(1, 1)'/>" |
| 1277 "</svg>"); | 1283 "</svg>"); |
| 1278 | 1284 |
| 1279 LayoutObject& svgWithTransform = *document().getElementById("svg")->layoutOb
ject(); | 1285 LayoutObject& svgWithTransform = *document().getElementById("svg")->layoutOb
ject(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1310 | 1316 |
| 1311 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1317 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1312 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1318 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); |
| 1313 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1319 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1314 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1320 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1315 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); | 1321 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); |
| 1316 EXPECT_NE(aProperties->transform(), bProperties->transform()); | 1322 EXPECT_NE(aProperties->transform(), bProperties->transform()); |
| 1317 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); | 1323 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); |
| 1318 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); | 1324 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); |
| 1319 EXPECT_EQ(aProperties->transform()->renderingContextID(), bProperties->trans
form()->renderingContextID()); | 1325 EXPECT_EQ(aProperties->transform()->renderingContextID(), bProperties->trans
form()->renderingContextID()); |
| 1320 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); | 1326 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()
); |
| 1321 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); | 1327 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 48, 20, 10), b, frameView->layoutView(
)); |
| 1322 } | 1328 } |
| 1323 | 1329 |
| 1324 TEST_P(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext) | 1330 TEST_P(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext) |
| 1325 { | 1331 { |
| 1326 setBodyInnerHTML( | 1332 setBodyInnerHTML( |
| 1327 "<div style='transform-style: preserve-3d'>" | 1333 "<div style='transform-style: preserve-3d'>" |
| 1328 " <div id='a' style='transform: translateZ(0); width: 30px; height: 40p
x'>" | 1334 " <div id='a' style='transform: translateZ(0); width: 30px; height: 40p
x'>" |
| 1329 " <div id='b' style='transform: translateZ(0); width: 10px; height: 2
0px'></div>" | 1335 " <div id='b' style='transform: translateZ(0); width: 10px; height: 2
0px'></div>" |
| 1330 " </div>" | 1336 " </div>" |
| 1331 "</div>"); | 1337 "</div>"); |
| 1332 FrameView* frameView = document().view(); | 1338 FrameView* frameView = document().view(); |
| 1333 | 1339 |
| 1334 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1340 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1335 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1341 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); |
| 1336 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1342 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1337 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1343 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1338 ASSERT_FALSE(a->styleRef().preserves3D()); | 1344 ASSERT_FALSE(a->styleRef().preserves3D()); |
| 1339 | 1345 |
| 1340 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); | 1346 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); |
| 1341 | 1347 |
| 1342 // #a should participate in a rendering context (due to its parent), but its | 1348 // #a should participate in a rendering context (due to its parent), but its |
| 1343 // child #b should not. | 1349 // child #b should not. |
| 1344 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); | 1350 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); |
| 1345 EXPECT_FALSE(bProperties->transform()->hasRenderingContext()); | 1351 EXPECT_FALSE(bProperties->transform()->hasRenderingContext()); |
| 1346 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); | 1352 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()
); |
| 1347 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); | 1353 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 20), b, frameView->layoutView()
); |
| 1348 } | 1354 } |
| 1349 | 1355 |
| 1350 TEST_P(PaintPropertyTreeBuilderTest, NestedRenderingContexts) | 1356 TEST_P(PaintPropertyTreeBuilderTest, NestedRenderingContexts) |
| 1351 { | 1357 { |
| 1352 setBodyInnerHTML( | 1358 setBodyInnerHTML( |
| 1353 "<div style='transform-style: preserve-3d'>" | 1359 "<div style='transform-style: preserve-3d'>" |
| 1354 " <div id='a' style='transform: translateZ(0); width: 50px; height: 60p
x'>" | 1360 " <div id='a' style='transform: translateZ(0); width: 50px; height: 60p
x'>" |
| 1355 " <div style='transform-style: preserve-3d; width: 30px; height: 40px
'>" | 1361 " <div style='transform-style: preserve-3d; width: 30px; height: 40px
'>" |
| 1356 " <div id='b' style='transform: translateZ(0); width: 10px; height:
20px'>" | 1362 " <div id='b' style='transform: translateZ(0); width: 10px; height:
20px'>" |
| 1357 " </div>" | 1363 " </div>" |
| 1358 " </div>" | 1364 " </div>" |
| 1359 "</div>"); | 1365 "</div>"); |
| 1360 FrameView* frameView = document().view(); | 1366 FrameView* frameView = document().view(); |
| 1361 | 1367 |
| 1362 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1368 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1363 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1369 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); |
| 1364 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1370 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1365 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1371 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1366 ASSERT_FALSE(a->styleRef().preserves3D()); | 1372 ASSERT_FALSE(a->styleRef().preserves3D()); |
| 1367 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); | 1373 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); |
| 1368 | 1374 |
| 1369 // #a should participate in a rendering context (due to its parent). Its | 1375 // #a should participate in a rendering context (due to its parent). Its |
| 1370 // child does preserve 3D, but since #a does not, #a's rendering context is | 1376 // child does preserve 3D, but since #a does not, #a's rendering context is |
| 1371 // not passed on to its children. Thus #b ends up in a separate rendering | 1377 // not passed on to its children. Thus #b ends up in a separate rendering |
| 1372 // context rooted at its parent. | 1378 // context rooted at its parent. |
| 1373 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); | 1379 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); |
| 1374 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); | 1380 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); |
| 1375 EXPECT_NE(aProperties->transform()->renderingContextID(), bProperties->trans
form()->renderingContextID()); | 1381 EXPECT_NE(aProperties->transform()->renderingContextID(), bProperties->trans
form()->renderingContextID()); |
| 1376 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); | 1382 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 50, 60), a, frameView->layoutView()
); |
| 1377 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); | 1383 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 20), b, frameView->layoutView()
); |
| 1378 } | 1384 } |
| 1379 | 1385 |
| 1380 // Returns true if the first node has the second as an ancestor. | 1386 // Returns true if the first node has the second as an ancestor. |
| 1381 static bool nodeHasAncestor(const TransformPaintPropertyNode* node, const Transf
ormPaintPropertyNode* ancestor) | 1387 static bool nodeHasAncestor(const TransformPaintPropertyNode* node, const Transf
ormPaintPropertyNode* ancestor) |
| 1382 { | 1388 { |
| 1383 while (node) { | 1389 while (node) { |
| 1384 if (node == ancestor) | 1390 if (node == ancestor) |
| 1385 return true; | 1391 return true; |
| 1386 node = node->parent(); | 1392 node = node->parent(); |
| 1387 } | 1393 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1412 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1418 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1413 const auto* aTransform = a->objectPaintProperties()->transform(); | 1419 const auto* aTransform = a->objectPaintProperties()->transform(); |
| 1414 ASSERT_TRUE(aTransform); | 1420 ASSERT_TRUE(aTransform); |
| 1415 const auto* bTransform = b->objectPaintProperties()->transform(); | 1421 const auto* bTransform = b->objectPaintProperties()->transform(); |
| 1416 ASSERT_TRUE(bTransform); | 1422 ASSERT_TRUE(bTransform); |
| 1417 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); | 1423 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); |
| 1418 | 1424 |
| 1419 // Some node must flatten the inherited transform from #a before it reaches | 1425 // Some node must flatten the inherited transform from #a before it reaches |
| 1420 // #b's transform. | 1426 // #b's transform. |
| 1421 EXPECT_TRUE(someNodeFlattensTransform(bTransform, aTransform)); | 1427 EXPECT_TRUE(someNodeFlattensTransform(bTransform, aTransform)); |
| 1422 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); | 1428 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()
); |
| 1423 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); | 1429 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 10), b, frameView->layoutView()
); |
| 1424 } | 1430 } |
| 1425 | 1431 |
| 1426 TEST_P(PaintPropertyTreeBuilderTest, Preserve3DTransformStylePropagatesToChildre
n) | 1432 TEST_P(PaintPropertyTreeBuilderTest, Preserve3DTransformStylePropagatesToChildre
n) |
| 1427 { | 1433 { |
| 1428 setBodyInnerHTML( | 1434 setBodyInnerHTML( |
| 1429 "<div id='a' style='transform: translateZ(0); transform-style: preserve-
3d; width: 30px; height: 40px'>" | 1435 "<div id='a' style='transform: translateZ(0); transform-style: preserve-
3d; width: 30px; height: 40px'>" |
| 1430 " <div id='b' style='transform: translateZ(0); width: 10px; height: 10p
x'></div>" | 1436 " <div id='b' style='transform: translateZ(0); width: 10px; height: 10p
x'></div>" |
| 1431 "</div>"); | 1437 "</div>"); |
| 1432 FrameView* frameView = document().view(); | 1438 FrameView* frameView = document().view(); |
| 1433 | 1439 |
| 1434 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1440 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1435 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1441 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1436 const auto* aTransform = a->objectPaintProperties()->transform(); | 1442 const auto* aTransform = a->objectPaintProperties()->transform(); |
| 1437 ASSERT_TRUE(aTransform); | 1443 ASSERT_TRUE(aTransform); |
| 1438 const auto* bTransform = b->objectPaintProperties()->transform(); | 1444 const auto* bTransform = b->objectPaintProperties()->transform(); |
| 1439 ASSERT_TRUE(bTransform); | 1445 ASSERT_TRUE(bTransform); |
| 1440 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); | 1446 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); |
| 1441 | 1447 |
| 1442 // No node may flatten the inherited transform from #a before it reaches | 1448 // No node may flatten the inherited transform from #a before it reaches |
| 1443 // #b's transform. | 1449 // #b's transform. |
| 1444 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aTransform)); | 1450 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aTransform)); |
| 1445 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); | 1451 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()
); |
| 1446 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); | 1452 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 10), b, frameView->layoutView()
); |
| 1447 } | 1453 } |
| 1448 | 1454 |
| 1449 TEST_P(PaintPropertyTreeBuilderTest, PerspectiveIsNotFlattened) | 1455 TEST_P(PaintPropertyTreeBuilderTest, PerspectiveIsNotFlattened) |
| 1450 { | 1456 { |
| 1451 // It's necessary to make nodes from the one that applies perspective to | 1457 // It's necessary to make nodes from the one that applies perspective to |
| 1452 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't | 1458 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't |
| 1453 // do anything. | 1459 // do anything. |
| 1454 setBodyInnerHTML( | 1460 setBodyInnerHTML( |
| 1455 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" | 1461 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" |
| 1456 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20p
x'></div>" | 1462 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20p
x'></div>" |
| 1457 "</div>"); | 1463 "</div>"); |
| 1458 FrameView* frameView = document().view(); | 1464 FrameView* frameView = document().view(); |
| 1459 | 1465 |
| 1460 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1466 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1461 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1467 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1462 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1468 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); |
| 1463 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1469 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1464 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); | 1470 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); |
| 1465 ASSERT_TRUE(aPerspective); | 1471 ASSERT_TRUE(aPerspective); |
| 1466 const TransformPaintPropertyNode* bTransform = bProperties->transform(); | 1472 const TransformPaintPropertyNode* bTransform = bProperties->transform(); |
| 1467 ASSERT_TRUE(bTransform); | 1473 ASSERT_TRUE(bTransform); |
| 1468 ASSERT_TRUE(nodeHasAncestor(bTransform, aPerspective)); | 1474 ASSERT_TRUE(nodeHasAncestor(bTransform, aPerspective)); |
| 1469 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aPerspective)); | 1475 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aPerspective)); |
| 1470 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); | 1476 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()
); |
| 1471 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); | 1477 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 20), b, frameView->layoutView()
); |
| 1472 } | 1478 } |
| 1473 | 1479 |
| 1474 TEST_P(PaintPropertyTreeBuilderTest, PerspectiveDoesNotEstablishRenderingContext
) | 1480 TEST_P(PaintPropertyTreeBuilderTest, PerspectiveDoesNotEstablishRenderingContext
) |
| 1475 { | 1481 { |
| 1476 // It's necessary to make nodes from the one that applies perspective to | 1482 // It's necessary to make nodes from the one that applies perspective to |
| 1477 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't | 1483 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't |
| 1478 // do anything. | 1484 // do anything. |
| 1479 setBodyInnerHTML( | 1485 setBodyInnerHTML( |
| 1480 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" | 1486 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" |
| 1481 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20p
x'></div>" | 1487 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20p
x'></div>" |
| 1482 "</div>"); | 1488 "</div>"); |
| 1483 FrameView* frameView = document().view(); | 1489 FrameView* frameView = document().view(); |
| 1484 | 1490 |
| 1485 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1491 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1486 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1492 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1487 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1493 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); |
| 1488 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1494 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1489 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); | 1495 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); |
| 1490 ASSERT_TRUE(aPerspective); | 1496 ASSERT_TRUE(aPerspective); |
| 1491 EXPECT_FALSE(aPerspective->hasRenderingContext()); | 1497 EXPECT_FALSE(aPerspective->hasRenderingContext()); |
| 1492 const TransformPaintPropertyNode* bTransform = bProperties->transform(); | 1498 const TransformPaintPropertyNode* bTransform = bProperties->transform(); |
| 1493 ASSERT_TRUE(bTransform); | 1499 ASSERT_TRUE(bTransform); |
| 1494 EXPECT_FALSE(bTransform->hasRenderingContext()); | 1500 EXPECT_FALSE(bTransform->hasRenderingContext()); |
| 1495 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); | 1501 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()
); |
| 1496 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); | 1502 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 20), b, frameView->layoutView()
); |
| 1497 } | 1503 } |
| 1498 | 1504 |
| 1499 TEST_P(PaintPropertyTreeBuilderTest, CachedProperties) | 1505 TEST_P(PaintPropertyTreeBuilderTest, CachedProperties) |
| 1500 { | 1506 { |
| 1501 setBodyInnerHTML( | 1507 setBodyInnerHTML( |
| 1508 "<style>body { margin: 0 }</style>" |
| 1502 "<div id='a' style='transform: translate(33px, 44px); width: 50px; heigh
t: 60px'>" | 1509 "<div id='a' style='transform: translate(33px, 44px); width: 50px; heigh
t: 60px'>" |
| 1503 " <div id='b' style='transform: translate(55px, 66px); width: 30px; hei
ght: 40px'>" | 1510 " <div id='b' style='transform: translate(55px, 66px); width: 30px; hei
ght: 40px'>" |
| 1504 " <div id='c' style='transform: translate(77px, 88px); width: 10px; h
eight: 20px'>C<div>" | 1511 " <div id='c' style='transform: translate(77px, 88px); width: 10px; h
eight: 20px'>C<div>" |
| 1505 " </div>" | 1512 " </div>" |
| 1506 "</div>"); | 1513 "</div>"); |
| 1507 FrameView* frameView = document().view(); | 1514 FrameView* frameView = document().view(); |
| 1508 | 1515 |
| 1509 Element* a = document().getElementById("a"); | 1516 Element* a = document().getElementById("a"); |
| 1510 const ObjectPaintProperties* aProperties = a->layoutObject()->objectPaintPro
perties(); | 1517 const ObjectPaintProperties* aProperties = a->layoutObject()->objectPaintPro
perties(); |
| 1511 const TransformPaintPropertyNode* aTransformNode = aProperties->transform(); | 1518 const TransformPaintPropertyNode* aTransformNode = aProperties->transform(); |
| 1512 EXPECT_EQ(TransformationMatrix().translate(33, 44), aTransformNode->matrix()
); | 1519 EXPECT_EQ(TransformationMatrix().translate(33, 44), aTransformNode->matrix()
); |
| 1513 | 1520 |
| 1514 Element* b = document().getElementById("b"); | 1521 Element* b = document().getElementById("b"); |
| 1515 const ObjectPaintProperties* bProperties = b->layoutObject()->objectPaintPro
perties(); | 1522 const ObjectPaintProperties* bProperties = b->layoutObject()->objectPaintPro
perties(); |
| 1516 const TransformPaintPropertyNode* bTransformNode = bProperties->transform(); | 1523 const TransformPaintPropertyNode* bTransformNode = bProperties->transform(); |
| 1517 EXPECT_EQ(TransformationMatrix().translate(55, 66), bTransformNode->matrix()
); | 1524 EXPECT_EQ(TransformationMatrix().translate(55, 66), bTransformNode->matrix()
); |
| 1518 | 1525 |
| 1519 Element* c = document().getElementById("c"); | 1526 Element* c = document().getElementById("c"); |
| 1520 const ObjectPaintProperties* cProperties = c->layoutObject()->objectPaintPro
perties(); | 1527 const ObjectPaintProperties* cProperties = c->layoutObject()->objectPaintPro
perties(); |
| 1521 const TransformPaintPropertyNode* cTransformNode = cProperties->transform(); | 1528 const TransformPaintPropertyNode* cTransformNode = cProperties->transform(); |
| 1522 EXPECT_EQ(TransformationMatrix().translate(77, 88), cTransformNode->matrix()
); | 1529 EXPECT_EQ(TransformationMatrix().translate(77, 88), cTransformNode->matrix()
); |
| 1523 | 1530 |
| 1524 CHECK_EXACT_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); | 1531 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), frame
View->layoutView()); |
| 1525 CHECK_EXACT_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); | 1532 CHECK_EXACT_VISUAL_RECT(LayoutRect(88, 110, 30, 40), b->layoutObject(), fram
eView->layoutView()); |
| 1526 CHECK_EXACT_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); | 1533 CHECK_EXACT_VISUAL_RECT(LayoutRect(165, 198, 10, 20), c->layoutObject(), fra
meView->layoutView()); |
| 1527 | 1534 |
| 1528 // Change transform of b. B's transform node should be a new node with the n
ew value, | 1535 // Change transform of b. B's transform node should be a new node with the n
ew value, |
| 1529 // and a and c's transform nodes should be unchanged (with c's parent adjust
ed). | 1536 // and a and c's transform nodes should be unchanged (with c's parent adjust
ed). |
| 1530 b->setAttribute(HTMLNames::styleAttr, "transform: translate(111px, 222px)"); | 1537 b->setAttribute(HTMLNames::styleAttr, "transform: translate(111px, 222px)"); |
| 1531 document().view()->updateAllLifecyclePhases(); | 1538 document().view()->updateAllLifecyclePhases(); |
| 1532 | 1539 |
| 1533 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); | 1540 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); |
| 1534 EXPECT_EQ(aTransformNode, aProperties->transform()); | 1541 EXPECT_EQ(aTransformNode, aProperties->transform()); |
| 1535 | 1542 |
| 1536 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); | 1543 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); |
| 1537 bTransformNode = bProperties->transform(); | 1544 bTransformNode = bProperties->transform(); |
| 1538 EXPECT_EQ(TransformationMatrix().translate(111, 222), bTransformNode->matrix
()); | 1545 EXPECT_EQ(TransformationMatrix().translate(111, 222), bTransformNode->matrix
()); |
| 1539 EXPECT_EQ(aTransformNode, bTransformNode->parent()); | 1546 EXPECT_EQ(aTransformNode, bTransformNode->parent()); |
| 1540 | 1547 |
| 1541 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); | 1548 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); |
| 1542 EXPECT_EQ(cTransformNode, cProperties->transform()); | 1549 EXPECT_EQ(cTransformNode, cProperties->transform()); |
| 1543 EXPECT_EQ(bTransformNode, cTransformNode->parent()); | 1550 EXPECT_EQ(bTransformNode, cTransformNode->parent()); |
| 1544 | 1551 |
| 1545 CHECK_EXACT_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); | 1552 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), frame
View->layoutView()); |
| 1546 CHECK_EXACT_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); | 1553 CHECK_EXACT_VISUAL_RECT(LayoutRect(144, 266, 50, 20), b->layoutObject(), fra
meView->layoutView()); |
| 1547 CHECK_EXACT_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); | 1554 CHECK_EXACT_VISUAL_RECT(LayoutRect(221, 354, 10, 20), c->layoutObject(), fra
meView->layoutView()); |
| 1548 | 1555 |
| 1549 // Remove transform from b. B's transform node should be removed from the tr
ee, | 1556 // Remove transform from b. B's transform node should be removed from the tr
ee, |
| 1550 // and a and c's transform nodes should be unchanged (with c's parent adjust
ed). | 1557 // and a and c's transform nodes should be unchanged (with c's parent adjust
ed). |
| 1551 b->setAttribute(HTMLNames::styleAttr, ""); | 1558 b->setAttribute(HTMLNames::styleAttr, ""); |
| 1552 document().view()->updateAllLifecyclePhases(); | 1559 document().view()->updateAllLifecyclePhases(); |
| 1553 | 1560 |
| 1554 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); | 1561 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); |
| 1555 EXPECT_EQ(aTransformNode, aProperties->transform()); | 1562 EXPECT_EQ(aTransformNode, aProperties->transform()); |
| 1556 | 1563 |
| 1557 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); | 1564 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); |
| 1558 EXPECT_EQ(nullptr, bProperties->transform()); | 1565 EXPECT_EQ(nullptr, bProperties->transform()); |
| 1559 | 1566 |
| 1560 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); | 1567 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); |
| 1561 EXPECT_EQ(cTransformNode, cProperties->transform()); | 1568 EXPECT_EQ(cTransformNode, cProperties->transform()); |
| 1562 EXPECT_EQ(aTransformNode, cTransformNode->parent()); | 1569 EXPECT_EQ(aTransformNode, cTransformNode->parent()); |
| 1563 | 1570 |
| 1564 CHECK_EXACT_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); | 1571 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), frame
View->layoutView()); |
| 1565 CHECK_EXACT_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); | 1572 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 20), b->layoutObject(), frame
View->layoutView()); |
| 1566 CHECK_EXACT_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); | 1573 CHECK_EXACT_VISUAL_RECT(LayoutRect(110, 132, 10, 20), c->layoutObject(), fra
meView->layoutView()); |
| 1567 | 1574 |
| 1568 // Re-add transform to b. B's transform node should be inserted into the tre
e, | 1575 // Re-add transform to b. B's transform node should be inserted into the tre
e, |
| 1569 // and a and c's transform nodes should be unchanged (with c's parent adjust
ed). | 1576 // and a and c's transform nodes should be unchanged (with c's parent adjust
ed). |
| 1570 b->setAttribute(HTMLNames::styleAttr, "transform: translate(4px, 5px)"); | 1577 b->setAttribute(HTMLNames::styleAttr, "transform: translate(4px, 5px)"); |
| 1571 document().view()->updateAllLifecyclePhases(); | 1578 document().view()->updateAllLifecyclePhases(); |
| 1572 | 1579 |
| 1573 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); | 1580 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); |
| 1574 EXPECT_EQ(aTransformNode, aProperties->transform()); | 1581 EXPECT_EQ(aTransformNode, aProperties->transform()); |
| 1575 | 1582 |
| 1576 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); | 1583 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); |
| 1577 bTransformNode = bProperties->transform(); | 1584 bTransformNode = bProperties->transform(); |
| 1578 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix()); | 1585 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix()); |
| 1579 EXPECT_EQ(aTransformNode, bTransformNode->parent()); | 1586 EXPECT_EQ(aTransformNode, bTransformNode->parent()); |
| 1580 | 1587 |
| 1581 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); | 1588 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); |
| 1582 EXPECT_EQ(cTransformNode, cProperties->transform()); | 1589 EXPECT_EQ(cTransformNode, cProperties->transform()); |
| 1583 EXPECT_EQ(bTransformNode, cTransformNode->parent()); | 1590 EXPECT_EQ(bTransformNode, cTransformNode->parent()); |
| 1584 | 1591 |
| 1585 CHECK_EXACT_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); | 1592 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), frame
View->layoutView()); |
| 1586 CHECK_EXACT_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); | 1593 CHECK_EXACT_VISUAL_RECT(LayoutRect(37, 49, 50, 20), b->layoutObject(), frame
View->layoutView()); |
| 1587 CHECK_EXACT_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); | 1594 CHECK_EXACT_VISUAL_RECT(LayoutRect(114, 137, 10, 20), c->layoutObject(), fra
meView->layoutView()); |
| 1588 } | 1595 } |
| 1589 | 1596 |
| 1590 } // namespace blink | 1597 } // namespace blink |
| OLD | NEW |