| 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 "core/paint/PaintPropertyTreePrinter.h" |
| 9 #include "platform/graphics/paint/GeometryMapper.h" | 10 #include "platform/graphics/paint/GeometryMapper.h" |
| 10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 11 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 11 #include "platform/testing/UnitTestHelpers.h" | 12 #include "platform/testing/UnitTestHelpers.h" |
| 12 #include "platform/text/TextStream.h" | 13 #include "platform/text/TextStream.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "wtf/HashMap.h" | 15 #include "wtf/HashMap.h" |
| 15 #include "wtf/Vector.h" | 16 #include "wtf/Vector.h" |
| 16 | 17 |
| 17 namespace blink { | 18 namespace blink { |
| 18 | 19 |
| 19 class PaintPropertyTreeBuilderTest : public RenderingTest { | 20 class PaintPropertyTreeBuilderTest |
| 21 : public RenderingTest |
| 22 , public ::testing::WithParamInterface<FrameSettingOverrideFunction> { |
| 20 public: | 23 public: |
| 21 PaintPropertyTreeBuilderTest() | 24 PaintPropertyTreeBuilderTest() |
| 22 : RenderingTest(SingleChildFrameLoaderClient::create()) | 25 : RenderingTest(SingleChildFrameLoaderClient::create()) |
| 23 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } | 26 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } |
| 24 | 27 |
| 25 void loadTestData(const char* fileName) | 28 void loadTestData(const char* fileName) |
| 26 { | 29 { |
| 27 String fullPath = testing::blinkRootDir(); | 30 String fullPath = testing::blinkRootDir(); |
| 28 fullPath.append("/Source/core/paint/test_data/"); | 31 fullPath.append("/Source/core/paint/test_data/"); |
| 29 fullPath.append(fileName); | 32 fullPath.append(fileName); |
| 30 RefPtr<SharedBuffer> inputBuffer = testing::readFromFile(fullPath); | 33 RefPtr<SharedBuffer> inputBuffer = testing::readFromFile(fullPath); |
| 31 setBodyInnerHTML(String(inputBuffer->data(), inputBuffer->size())); | 34 setBodyInnerHTML(String(inputBuffer->data(), inputBuffer->size())); |
| 32 } | 35 } |
| 33 | 36 |
| 37 bool rootLayerScrolls() |
| 38 { |
| 39 return document().settings() && document().settings()->rootLayerScrolls(
); |
| 40 } |
| 41 |
| 42 const TransformPaintPropertyNode* rootTransform() |
| 43 { |
| 44 FrameView* frameView = document().view(); |
| 45 if (rootLayerScrolls()) |
| 46 return frameView->layoutView()->objectPaintProperties()->paintOffset
Translation(); |
| 47 return frameView->rootTransform(); |
| 48 } |
| 49 |
| 50 const ClipPaintPropertyNode* rootClip() |
| 51 { |
| 52 return rootLayerScrolls() ? nullptr : document().view()->rootClip(); |
| 53 } |
| 54 |
| 55 const TransformPaintPropertyNode* framePreTranslation() |
| 56 { |
| 57 FrameView* frameView = document().view(); |
| 58 if (rootLayerScrolls()) |
| 59 return frameView->layoutView()->objectPaintProperties()->paintOffset
Translation(); |
| 60 return frameView->preTranslation(); |
| 61 } |
| 62 |
| 63 const TransformPaintPropertyNode* frameScrollTranslation() |
| 64 { |
| 65 FrameView* frameView = document().view(); |
| 66 if (rootLayerScrolls()) |
| 67 return frameView->layoutView()->objectPaintProperties()->scrollTrans
lation(); |
| 68 return frameView->scrollTranslation(); |
| 69 } |
| 70 |
| 71 const ClipPaintPropertyNode* frameContentClip() |
| 72 { |
| 73 FrameView* frameView = document().view(); |
| 74 if (rootLayerScrolls()) |
| 75 return frameView->layoutView()->objectPaintProperties()->overflowCli
p(); |
| 76 return frameView->contentClip(); |
| 77 } |
| 78 |
| 79 FrameSettingOverrideFunction settingOverrider() const override { return GetP
aram(); } |
| 80 |
| 34 private: | 81 private: |
| 35 void SetUp() override | 82 void SetUp() override |
| 36 { | 83 { |
| 37 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | 84 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
| 38 Settings::setMockScrollbarsEnabled(true); | 85 Settings::setMockScrollbarsEnabled(true); |
| 39 | 86 |
| 40 RenderingTest::SetUp(); | 87 RenderingTest::SetUp(); |
| 41 enableCompositing(); | 88 enableCompositing(); |
| 42 } | 89 } |
| 43 | 90 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 62 FloatRect(source), \ | 109 FloatRect(source), \ |
| 63 sourceLayoutObject->objectPaintProperties()->localBorderBoxProperties()-
>propertyTreeState, \ | 110 sourceLayoutObject->objectPaintProperties()->localBorderBoxProperties()-
>propertyTreeState, \ |
| 64 ancestorLayoutObject->objectPaintProperties()->localBorderBoxProperties(
)->propertyTreeState, success); \ | 111 ancestorLayoutObject->objectPaintProperties()->localBorderBoxProperties(
)->propertyTreeState, success); \ |
| 65 EXPECT_TRUE(success); \ | 112 EXPECT_TRUE(success); \ |
| 66 \ | 113 \ |
| 67 LayoutRect expected = sourceLayoutObject->localOverflowRectForPaintInvalidat
ion(); \ | 114 LayoutRect expected = sourceLayoutObject->localOverflowRectForPaintInvalidat
ion(); \ |
| 68 sourceLayoutObject->mapToVisualRectInAncestorSpace(ancestorLayoutObject, exp
ected); \ | 115 sourceLayoutObject->mapToVisualRectInAncestorSpace(ancestorLayoutObject, exp
ected); \ |
| 69 EXPECT_EQ(expected, LayoutRect(actual)); \ | 116 EXPECT_EQ(expected, LayoutRect(actual)); \ |
| 70 } while (0); | 117 } while (0); |
| 71 | 118 |
| 72 TEST_F(PaintPropertyTreeBuilderTest, FixedPosition) | 119 INSTANTIATE_TEST_CASE_P(All, PaintPropertyTreeBuilderTest, ::testing::Values(nul
lptr, &RootLayerScrollsFrameSettingOverride)); |
| 120 |
| 121 TEST_P(PaintPropertyTreeBuilderTest, FixedPosition) |
| 73 { | 122 { |
| 74 loadTestData("fixed-position.html"); | 123 loadTestData("fixed-position.html"); |
| 75 | 124 |
| 76 FrameView* frameView = document().view(); | 125 FrameView* frameView = document().view(); |
| 77 | 126 |
| 78 // target1 is a fixed-position element inside an absolute-position scrolling
element. | 127 // target1 is a fixed-position element inside an absolute-position scrolling
element. |
| 79 // It should be attached under the viewport to skip scrolling and offset of
the parent. | 128 // It should be attached under the viewport to skip scrolling and offset of
the parent. |
| 80 Element* target1 = document().getElementById("target1"); | 129 Element* target1 = document().getElementById("target1"); |
| 81 const ObjectPaintProperties* target1Properties = target1->layoutObject()->ob
jectPaintProperties(); | 130 const ObjectPaintProperties* target1Properties = target1->layoutObject()->ob
jectPaintProperties(); |
| 82 EXPECT_EQ(TransformationMatrix().translate(200, 150), target1Properties->pai
ntOffsetTranslation()->matrix()); | 131 EXPECT_EQ(TransformationMatrix().translate(200, 150), target1Properties->pai
ntOffsetTranslation()->matrix()); |
| 83 EXPECT_EQ(frameView->preTranslation(), target1Properties->paintOffsetTransla
tion()->parent()); | 132 EXPECT_EQ(framePreTranslation(), target1Properties->paintOffsetTranslation()
->parent()); |
| 84 EXPECT_EQ(target1Properties->paintOffsetTranslation(), target1Properties->ov
erflowClip()->localTransformSpace()); | 133 EXPECT_EQ(target1Properties->paintOffsetTranslation(), target1Properties->ov
erflowClip()->localTransformSpace()); |
| 85 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target1Properties->overflowClip(
)->clipRect()); | 134 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target1Properties->overflowClip(
)->clipRect()); |
| 86 // Likewise, it inherits clip from the viewport, skipping overflow clip of t
he scroller. | 135 // Likewise, it inherits clip from the viewport, skipping overflow clip of t
he scroller. |
| 87 EXPECT_EQ(frameView->contentClip(), target1Properties->overflowClip()->paren
t()); | 136 EXPECT_EQ(frameContentClip(), target1Properties->overflowClip()->parent()); |
| 88 | 137 |
| 89 // target2 is a fixed-position element inside a transformed scrolling elemen
t. | 138 // target2 is a fixed-position element inside a transformed scrolling elemen
t. |
| 90 // It should be attached under the scrolled box of the transformed element. | 139 // It should be attached under the scrolled box of the transformed element. |
| 91 Element* target2 = document().getElementById("target2"); | 140 Element* target2 = document().getElementById("target2"); |
| 92 const ObjectPaintProperties* target2Properties = target2->layoutObject()->ob
jectPaintProperties(); | 141 const ObjectPaintProperties* target2Properties = target2->layoutObject()->ob
jectPaintProperties(); |
| 93 Element* scroller = document().getElementById("scroller"); | 142 Element* scroller = document().getElementById("scroller"); |
| 94 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->
objectPaintProperties(); | 143 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->
objectPaintProperties(); |
| 95 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai
ntOffsetTranslation()->matrix()); | 144 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai
ntOffsetTranslation()->matrix()); |
| 96 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO
ffsetTranslation()->parent()); | 145 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO
ffsetTranslation()->parent()); |
| 97 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov
erflowClip()->localTransformSpace()); | 146 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov
erflowClip()->localTransformSpace()); |
| 98 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip(
)->clipRect()); | 147 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip(
)->clipRect()); |
| 99 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli
p()->parent()); | 148 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli
p()->parent()); |
| 100 | 149 |
| 101 CHECK_VISUAL_RECT(target1->layoutObject(), frameView->layoutView()); | 150 CHECK_VISUAL_RECT(target1->layoutObject(), frameView->layoutView()); |
| 102 CHECK_VISUAL_RECT(target2->layoutObject(), frameView->layoutView()); | 151 CHECK_VISUAL_RECT(target2->layoutObject(), frameView->layoutView()); |
| 103 } | 152 } |
| 104 | 153 |
| 105 TEST_F(PaintPropertyTreeBuilderTest, PositionAndScroll) | 154 TEST_P(PaintPropertyTreeBuilderTest, PositionAndScroll) |
| 106 { | 155 { |
| 107 loadTestData("position-and-scroll.html"); | 156 loadTestData("position-and-scroll.html"); |
| 108 | 157 |
| 109 Element* scroller = document().getElementById("scroller"); | 158 Element* scroller = document().getElementById("scroller"); |
| 110 scroller->scrollTo(0, 100); | 159 scroller->scrollTo(0, 100); |
| 111 FrameView* frameView = document().view(); | 160 FrameView* frameView = document().view(); |
| 112 frameView->updateAllLifecyclePhases(); | 161 frameView->updateAllLifecyclePhases(); |
| 113 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->
objectPaintProperties(); | 162 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->
objectPaintProperties(); |
| 114 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr
ollTranslation()->matrix()); | 163 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr
ollTranslation()->matrix()); |
| 115 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->scrollTranslat
ion()->parent()); | 164 EXPECT_EQ(frameScrollTranslation(), scrollerProperties->scrollTranslation()-
>parent()); |
| 116 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->overflowClip()
->localTransformSpace()); | 165 EXPECT_EQ(frameScrollTranslation(), scrollerProperties->overflowClip()->loca
lTransformSpace()); |
| 117 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow
Clip()->clipRect()); | 166 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow
Clip()->clipRect()); |
| 118 EXPECT_EQ(frameView->contentClip(), scrollerProperties->overflowClip()->pare
nt()); | 167 EXPECT_EQ(frameContentClip(), scrollerProperties->overflowClip()->parent()); |
| 119 | 168 |
| 120 // The relative-positioned element should have accumulated box offset (exclu
de scrolling), | 169 // The relative-positioned element should have accumulated box offset (exclu
de scrolling), |
| 121 // and should be affected by ancestor scroll transforms. | 170 // and should be affected by ancestor scroll transforms. |
| 122 Element* relPos = document().getElementById("rel-pos"); | 171 Element* relPos = document().getElementById("rel-pos"); |
| 123 const ObjectPaintProperties* relPosProperties = relPos->layoutObject()->obje
ctPaintProperties(); | 172 const ObjectPaintProperties* relPosProperties = relPos->layoutObject()->obje
ctPaintProperties(); |
| 124 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai
ntOffsetTranslation()->matrix()); | 173 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai
ntOffsetTranslation()->matrix()); |
| 125 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf
fsetTranslation()->parent()); | 174 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf
fsetTranslation()->parent()); |
| 126 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l
ocalTransformSpace()); | 175 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l
ocalTransformSpace()); |
| 127 EXPECT_EQ(FloatRoundedRect(0, 0, 400, 0), relPosProperties->overflowClip()->
clipRect()); | 176 EXPECT_EQ(FloatRoundedRect(0, 0, 400, 0), relPosProperties->overflowClip()->
clipRect()); |
| 128 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip
()->parent()); | 177 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip
()->parent()); |
| 129 | 178 |
| 130 // The absolute-positioned element should not be affected by non-positioned
scroller at all. | 179 // The absolute-positioned element should not be affected by non-positioned
scroller at all. |
| 131 Element* absPos = document().getElementById("abs-pos"); | 180 Element* absPos = document().getElementById("abs-pos"); |
| 132 const ObjectPaintProperties* absPosProperties = absPos->layoutObject()->obje
ctPaintProperties(); | 181 const ObjectPaintProperties* absPosProperties = absPos->layoutObject()->obje
ctPaintProperties(); |
| 133 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain
tOffsetTranslation()->matrix()); | 182 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain
tOffsetTranslation()->matrix()); |
| 134 EXPECT_EQ(frameView->scrollTranslation(), absPosProperties->paintOffsetTrans
lation()->parent()); | 183 EXPECT_EQ(frameScrollTranslation(), absPosProperties->paintOffsetTranslation
()->parent()); |
| 135 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l
ocalTransformSpace()); | 184 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l
ocalTransformSpace()); |
| 136 EXPECT_EQ(FloatRoundedRect(), absPosProperties->overflowClip()->clipRect()); | 185 EXPECT_EQ(FloatRoundedRect(), absPosProperties->overflowClip()->clipRect()); |
| 137 EXPECT_EQ(frameView->contentClip(), absPosProperties->overflowClip()->parent
()); | 186 EXPECT_EQ(frameContentClip(), absPosProperties->overflowClip()->parent()); |
| 138 } | 187 } |
| 139 | 188 |
| 140 TEST_F(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) | 189 TEST_P(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) |
| 141 { | 190 { |
| 142 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); | 191 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); |
| 143 | 192 |
| 144 document().domWindow()->scrollTo(0, 100); | 193 document().domWindow()->scrollTo(0, 100); |
| 145 | 194 |
| 146 FrameView* frameView = document().view(); | 195 FrameView* frameView = document().view(); |
| 147 frameView->updateAllLifecyclePhases(); | 196 frameView->updateAllLifecyclePhases(); |
| 148 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); | 197 EXPECT_EQ(TransformationMatrix(), framePreTranslation()->matrix()); |
| 149 EXPECT_EQ(frameView->rootTransform(), frameView->preTranslation()->parent())
; | 198 if (!rootLayerScrolls()) |
| 150 EXPECT_EQ(nullptr, frameView->rootTransform()->parent()); | 199 EXPECT_EQ(rootTransform(), framePreTranslation()->parent()); |
| 151 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl
ation()->matrix()); | 200 EXPECT_EQ(nullptr, rootTransform()->parent()); |
| 152 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren
t()); | 201 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameScrollTranslation(
)->matrix()); |
| 153 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf
ormSpace()); | 202 EXPECT_EQ(framePreTranslation(), frameScrollTranslation()->parent()); |
| 154 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe
ct()); | 203 EXPECT_EQ(framePreTranslation(), frameContentClip()->localTransformSpace()); |
| 155 EXPECT_EQ(frameView->rootClip(), frameView->contentClip()->parent()); | 204 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameContentClip()->clipRect()); |
| 156 EXPECT_EQ(nullptr, frameView->rootClip()->parent()); | 205 EXPECT_EQ(rootClip(), frameContentClip()->parent()); |
| 206 if (!rootLayerScrolls()) |
| 207 EXPECT_EQ(nullptr, rootClip()->parent()); |
| 157 | 208 |
| 158 LayoutViewItem layoutViewItem = document().layoutViewItem(); | 209 LayoutViewItem layoutViewItem = document().layoutViewItem(); |
| 159 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai
ntProperties(); | 210 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai
ntProperties(); |
| 160 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation()); | 211 if (!rootLayerScrolls()) |
| 212 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation()); |
| 161 } | 213 } |
| 162 | 214 |
| 163 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame
being created. | 215 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame
being created. |
| 164 // Need to set it during test setup. Besides that, the test still won't work bec
ause | 216 // Need to set it during test setup. Besides that, the test still won't work bec
ause |
| 165 // root layer scrolling mode is not compatible with SPv2 at this moment. | 217 // root layer scrolling mode is not compatible with SPv2 at this moment. |
| 166 // (Duplicate display item ID for FrameView and LayoutView.) | 218 // (Duplicate display item ID for FrameView and LayoutView.) |
| 167 TEST_F(PaintPropertyTreeBuilderTest, DISABLED_FrameScrollingRootLayerScrolls) | 219 TEST_P(PaintPropertyTreeBuilderTest, DISABLED_FrameScrollingRootLayerScrolls) |
| 168 { | 220 { |
| 169 document().settings()->setRootLayerScrolls(true); | |
| 170 | |
| 171 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); | 221 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); |
| 172 | 222 |
| 173 document().domWindow()->scrollTo(0, 100); | 223 document().domWindow()->scrollTo(0, 100); |
| 174 | 224 |
| 175 FrameView* frameView = document().view(); | 225 FrameView* frameView = document().view(); |
| 176 frameView->updateAllLifecyclePhases(); | 226 frameView->updateAllLifecyclePhases(); |
| 177 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); | 227 EXPECT_EQ(TransformationMatrix(), framePreTranslation()->matrix()); |
| 178 EXPECT_EQ(nullptr, frameView->preTranslation()->parent()); | 228 EXPECT_EQ(nullptr, framePreTranslation()->parent()); |
| 179 EXPECT_EQ(TransformationMatrix(), frameView->scrollTranslation()->matrix()); | 229 EXPECT_EQ(TransformationMatrix(), frameScrollTranslation()->matrix()); |
| 180 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren
t()); | 230 EXPECT_EQ(framePreTranslation(), frameScrollTranslation()->parent()); |
| 181 | 231 |
| 182 LayoutViewItem layoutViewItem = document().layoutViewItem(); | 232 LayoutViewItem layoutViewItem = document().layoutViewItem(); |
| 183 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai
ntProperties(); | 233 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai
ntProperties(); |
| 184 EXPECT_EQ(TransformationMatrix().translate(0, -100), layoutViewProperties->s
crollTranslation()->matrix()); | 234 EXPECT_EQ(TransformationMatrix().translate(0, -100), layoutViewProperties->s
crollTranslation()->matrix()); |
| 185 EXPECT_EQ(frameView->scrollTranslation(), layoutViewProperties->scrollTransl
ation()->parent()); | 235 EXPECT_EQ(frameScrollTranslation(), layoutViewProperties->scrollTranslation(
)->parent()); |
| 186 } | 236 } |
| 187 | 237 |
| 188 TEST_F(PaintPropertyTreeBuilderTest, Perspective) | 238 TEST_P(PaintPropertyTreeBuilderTest, Perspective) |
| 189 { | 239 { |
| 190 loadTestData("perspective.html"); | 240 loadTestData("perspective.html"); |
| 191 | 241 |
| 192 Element* perspective = document().getElementById("perspective"); | 242 Element* perspective = document().getElementById("perspective"); |
| 193 const ObjectPaintProperties* perspectiveProperties = perspective->layoutObje
ct()->objectPaintProperties(); | 243 const ObjectPaintProperties* perspectiveProperties = perspective->layoutObje
ct()->objectPaintProperties(); |
| 194 EXPECT_EQ(TransformationMatrix().applyPerspective(100), perspectivePropertie
s->perspective()->matrix()); | 244 EXPECT_EQ(TransformationMatrix().applyPerspective(100), perspectivePropertie
s->perspective()->matrix()); |
| 195 // The perspective origin is the center of the border box plus accumulated p
aint offset. | 245 // The perspective origin is the center of the border box plus accumulated p
aint offset. |
| 196 EXPECT_EQ(FloatPoint3D(250, 250, 0), perspectiveProperties->perspective()->o
rigin()); | 246 EXPECT_EQ(FloatPoint3D(250, 250, 0), perspectiveProperties->perspective()->o
rigin()); |
| 197 EXPECT_EQ(document().view()->scrollTranslation(), perspectiveProperties->per
spective()->parent()); | 247 EXPECT_EQ(frameScrollTranslation(), perspectiveProperties->perspective()->pa
rent()); |
| 198 | 248 |
| 199 // Adding perspective doesn't clear paint offset. The paint offset will be p
assed down to children. | 249 // Adding perspective doesn't clear paint offset. The paint offset will be p
assed down to children. |
| 200 Element* inner = document().getElementById("inner"); | 250 Element* inner = document().getElementById("inner"); |
| 201 const ObjectPaintProperties* innerProperties = inner->layoutObject()->object
PaintProperties(); | 251 const ObjectPaintProperties* innerProperties = inner->layoutObject()->object
PaintProperties(); |
| 202 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO
ffsetTranslation()->matrix()); | 252 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO
ffsetTranslation()->matrix()); |
| 203 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset
Translation()->parent()); | 253 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset
Translation()->parent()); |
| 204 } | 254 } |
| 205 | 255 |
| 206 TEST_F(PaintPropertyTreeBuilderTest, Transform) | 256 TEST_P(PaintPropertyTreeBuilderTest, Transform) |
| 207 { | 257 { |
| 208 loadTestData("transform.html"); | 258 loadTestData("transform.html"); |
| 209 | 259 |
| 210 Element* transform = document().getElementById("transform"); | 260 Element* transform = document().getElementById("transform"); |
| 211 const ObjectPaintProperties* transformProperties = transform->layoutObject()
->objectPaintProperties(); | 261 const ObjectPaintProperties* transformProperties = transform->layoutObject()
->objectPaintProperties(); |
| 212 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper
ties->transform()->matrix()); | 262 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper
ties->transform()->matrix()); |
| 213 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi
n()); | 263 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi
n()); |
| 214 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties
->transform()->parent()); | 264 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties
->transform()->parent()); |
| 215 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa
intOffsetTranslation()->matrix()); | 265 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa
intOffsetTranslation()->matrix()); |
| 216 EXPECT_EQ(document().view()->scrollTranslation(), transformProperties->paint
OffsetTranslation()->parent()); | 266 EXPECT_EQ(frameScrollTranslation(), transformProperties->paintOffsetTranslat
ion()->parent()); |
| 217 } | 267 } |
| 218 | 268 |
| 219 TEST_F(PaintPropertyTreeBuilderTest, RelativePositionInline) | 269 TEST_P(PaintPropertyTreeBuilderTest, RelativePositionInline) |
| 220 { | 270 { |
| 221 loadTestData("relative-position-inline.html"); | 271 loadTestData("relative-position-inline.html"); |
| 222 | 272 |
| 223 Element* inlineBlock = document().getElementById("inline-block"); | 273 Element* inlineBlock = document().getElementById("inline-block"); |
| 224 const ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObje
ct()->objectPaintProperties(); | 274 const ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObje
ct()->objectPaintProperties(); |
| 225 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties-
>paintOffsetTranslation()->matrix()); | 275 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties-
>paintOffsetTranslation()->matrix()); |
| 226 EXPECT_EQ(document().view()->scrollTranslation(), inlineBlockProperties->pai
ntOffsetTranslation()->parent()); | 276 EXPECT_EQ(frameScrollTranslation(), inlineBlockProperties->paintOffsetTransl
ation()->parent()); |
| 227 } | 277 } |
| 228 | 278 |
| 229 TEST_F(PaintPropertyTreeBuilderTest, NestedOpacityEffect) | 279 TEST_P(PaintPropertyTreeBuilderTest, NestedOpacityEffect) |
| 230 { | 280 { |
| 231 setBodyInnerHTML( | 281 setBodyInnerHTML( |
| 232 "<div id='nodeWithoutOpacity'>" | 282 "<div id='nodeWithoutOpacity'>" |
| 233 " <div id='childWithOpacity' style='opacity: 0.5'>" | 283 " <div id='childWithOpacity' style='opacity: 0.5'>" |
| 234 " <div id='grandChildWithoutOpacity'>" | 284 " <div id='grandChildWithoutOpacity'>" |
| 235 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2'/>" | 285 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2'/>" |
| 236 " </div>" | 286 " </div>" |
| 237 " </div>" | 287 " </div>" |
| 238 "</div>"); | 288 "</div>"); |
| 239 | 289 |
| 240 LayoutObject& nodeWithoutOpacity = *document().getElementById("nodeWithoutOp
acity")->layoutObject(); | 290 LayoutObject& nodeWithoutOpacity = *document().getElementById("nodeWithoutOp
acity")->layoutObject(); |
| 241 const ObjectPaintProperties* nodeWithoutOpacityProperties = nodeWithoutOpaci
ty.objectPaintProperties(); | 291 const ObjectPaintProperties* nodeWithoutOpacityProperties = nodeWithoutOpaci
ty.objectPaintProperties(); |
| 242 EXPECT_NE(nullptr, nodeWithoutOpacityProperties); | 292 EXPECT_NE(nullptr, nodeWithoutOpacityProperties); |
| 243 | 293 |
| 244 LayoutObject& childWithOpacity = *document().getElementById("childWithOpacit
y")->layoutObject(); | 294 LayoutObject& childWithOpacity = *document().getElementById("childWithOpacit
y")->layoutObject(); |
| 245 const ObjectPaintProperties* childWithOpacityProperties = childWithOpacity.o
bjectPaintProperties(); | 295 const ObjectPaintProperties* childWithOpacityProperties = childWithOpacity.o
bjectPaintProperties(); |
| 246 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity()); | 296 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity()); |
| 247 // childWithOpacity is the root effect node. | 297 // childWithOpacity is the root effect node. |
| 248 EXPECT_NE(nullptr, childWithOpacityProperties->effect()->parent()); | 298 EXPECT_NE(nullptr, childWithOpacityProperties->effect()->parent()); |
| 249 | 299 |
| 250 LayoutObject& grandChildWithoutOpacity = *document().getElementById("grandCh
ildWithoutOpacity")->layoutObject(); | 300 LayoutObject& grandChildWithoutOpacity = *document().getElementById("grandCh
ildWithoutOpacity")->layoutObject(); |
| 251 EXPECT_NE(nullptr, grandChildWithoutOpacity.objectPaintProperties()); | 301 EXPECT_NE(nullptr, grandChildWithoutOpacity.objectPaintProperties()); |
| 252 | 302 |
| 253 LayoutObject& greatGrandChildWithOpacity = *document().getElementById("great
GrandChildWithOpacity")->layoutObject(); | 303 LayoutObject& greatGrandChildWithOpacity = *document().getElementById("great
GrandChildWithOpacity")->layoutObject(); |
| 254 const ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGra
ndChildWithOpacity.objectPaintProperties(); | 304 const ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGra
ndChildWithOpacity.objectPaintProperties(); |
| 255 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); | 305 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); |
| 256 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr
operties->effect()->parent()); | 306 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr
operties->effect()->parent()); |
| 257 } | 307 } |
| 258 | 308 |
| 259 TEST_F(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) | 309 TEST_P(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) |
| 260 { | 310 { |
| 261 setBodyInnerHTML( | 311 setBodyInnerHTML( |
| 262 "<div id='nodeWithOpacity' style='opacity: 0.6'>" | 312 "<div id='nodeWithOpacity' style='opacity: 0.6'>" |
| 263 " <div id='childWithTransform' style='transform: translate3d(10px, 10px
, 0px);'>" | 313 " <div id='childWithTransform' style='transform: translate3d(10px, 10px
, 0px);'>" |
| 264 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" | 314 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" |
| 265 " </div>" | 315 " </div>" |
| 266 "</div>"); | 316 "</div>"); |
| 267 | 317 |
| 268 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity"
)->layoutObject(); | 318 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity"
)->layoutObject(); |
| 269 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.obj
ectPaintProperties(); | 319 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.obj
ectPaintProperties(); |
| 270 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); | 320 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); |
| 271 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); | 321 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); |
| 272 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); | 322 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); |
| 273 | 323 |
| 274 LayoutObject& childWithTransform = *document().getElementById("childWithTran
sform")->layoutObject(); | 324 LayoutObject& childWithTransform = *document().getElementById("childWithTran
sform")->layoutObject(); |
| 275 const ObjectPaintProperties* childWithTransformProperties = childWithTransfo
rm.objectPaintProperties(); | 325 const ObjectPaintProperties* childWithTransformProperties = childWithTransfo
rm.objectPaintProperties(); |
| 276 EXPECT_EQ(nullptr, childWithTransformProperties->effect()); | 326 EXPECT_EQ(nullptr, childWithTransformProperties->effect()); |
| 277 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper
ties->transform()->matrix()); | 327 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper
ties->transform()->matrix()); |
| 278 | 328 |
| 279 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild
WithOpacity")->layoutObject(); | 329 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild
WithOpacity")->layoutObject(); |
| 280 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit
hOpacity.objectPaintProperties(); | 330 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit
hOpacity.objectPaintProperties(); |
| 281 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); | 331 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); |
| 282 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); | 332 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); |
| 283 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); | 333 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); |
| 284 } | 334 } |
| 285 | 335 |
| 286 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) | 336 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) |
| 287 { | 337 { |
| 288 setBodyInnerHTML( | 338 setBodyInnerHTML( |
| 289 "<div id='nodeWithOpacity' style='opacity: 0.6'>" | 339 "<div id='nodeWithOpacity' style='opacity: 0.6'>" |
| 290 " <div id='childWithStackingContext' style='position:absolute;'>" | 340 " <div id='childWithStackingContext' style='position:absolute;'>" |
| 291 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" | 341 " <div id='grandChildWithOpacity' style='opacity: 0.4'/>" |
| 292 " </div>" | 342 " </div>" |
| 293 "</div>"); | 343 "</div>"); |
| 294 | 344 |
| 295 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity"
)->layoutObject(); | 345 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity"
)->layoutObject(); |
| 296 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.obj
ectPaintProperties(); | 346 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.obj
ectPaintProperties(); |
| 297 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); | 347 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); |
| 298 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); | 348 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); |
| 299 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); | 349 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); |
| 300 | 350 |
| 301 LayoutObject& childWithStackingContext = *document().getElementById("childWi
thStackingContext")->layoutObject(); | 351 LayoutObject& childWithStackingContext = *document().getElementById("childWi
thStackingContext")->layoutObject(); |
| 302 const ObjectPaintProperties* childWithStackingContextProperties = childWithS
tackingContext.objectPaintProperties(); | 352 const ObjectPaintProperties* childWithStackingContextProperties = childWithS
tackingContext.objectPaintProperties(); |
| 303 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect()); | 353 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect()); |
| 304 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); | 354 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); |
| 305 | 355 |
| 306 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild
WithOpacity")->layoutObject(); | 356 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild
WithOpacity")->layoutObject(); |
| 307 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit
hOpacity.objectPaintProperties(); | 357 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit
hOpacity.objectPaintProperties(); |
| 308 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); | 358 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); |
| 309 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); | 359 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); |
| 310 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); | 360 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); |
| 311 } | 361 } |
| 312 | 362 |
| 313 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesInSVG) | 363 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesInSVG) |
| 314 { | 364 { |
| 315 setBodyInnerHTML( | 365 setBodyInnerHTML( |
| 316 "<svg id='svgRoot'>" | 366 "<svg id='svgRoot'>" |
| 317 " <g id='groupWithOpacity' opacity='0.6'>" | 367 " <g id='groupWithOpacity' opacity='0.6'>" |
| 318 " <rect id='rectWithoutOpacity' />" | 368 " <rect id='rectWithoutOpacity' />" |
| 319 " <rect id='rectWithOpacity' opacity='0.4' />" | 369 " <rect id='rectWithOpacity' opacity='0.4' />" |
| 320 " <text id='textWithOpacity' opacity='0.2'>" | 370 " <text id='textWithOpacity' opacity='0.2'>" |
| 321 " <tspan id='tspanWithOpacity' opacity='0.1' />" | 371 " <tspan id='tspanWithOpacity' opacity='0.1' />" |
| 322 " </text>" | 372 " </text>" |
| 323 " </g>" | 373 " </g>" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 343 EXPECT_EQ(0.2f, textWithOpacityProperties->effect()->opacity()); | 393 EXPECT_EQ(0.2f, textWithOpacityProperties->effect()->opacity()); |
| 344 EXPECT_EQ(groupWithOpacityProperties->effect(), textWithOpacityProperties->e
ffect()->parent()); | 394 EXPECT_EQ(groupWithOpacityProperties->effect(), textWithOpacityProperties->e
ffect()->parent()); |
| 345 | 395 |
| 346 // Ensure that opacity nodes are created for LayoutSVGTSpan which inherits f
rom LayoutSVGInline instead of LayoutSVGModelObject. | 396 // Ensure that opacity nodes are created for LayoutSVGTSpan which inherits f
rom LayoutSVGInline instead of LayoutSVGModelObject. |
| 347 LayoutObject& tspanWithOpacity = *document().getElementById("tspanWithOpacit
y")->layoutObject(); | 397 LayoutObject& tspanWithOpacity = *document().getElementById("tspanWithOpacit
y")->layoutObject(); |
| 348 const ObjectPaintProperties* tspanWithOpacityProperties = tspanWithOpacity.o
bjectPaintProperties(); | 398 const ObjectPaintProperties* tspanWithOpacityProperties = tspanWithOpacity.o
bjectPaintProperties(); |
| 349 EXPECT_EQ(0.1f, tspanWithOpacityProperties->effect()->opacity()); | 399 EXPECT_EQ(0.1f, tspanWithOpacityProperties->effect()->opacity()); |
| 350 EXPECT_EQ(textWithOpacityProperties->effect(), tspanWithOpacityProperties->e
ffect()->parent()); | 400 EXPECT_EQ(textWithOpacityProperties->effect(), tspanWithOpacityProperties->e
ffect()->parent()); |
| 351 } | 401 } |
| 352 | 402 |
| 353 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossHTMLSVGBoundary) | 403 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossHTMLSVGBoundary) |
| 354 { | 404 { |
| 355 setBodyInnerHTML( | 405 setBodyInnerHTML( |
| 356 "<div id='divWithOpacity' style='opacity: 0.2;'>" | 406 "<div id='divWithOpacity' style='opacity: 0.2;'>" |
| 357 " <svg id='svgRootWithOpacity' style='opacity: 0.3;'>" | 407 " <svg id='svgRootWithOpacity' style='opacity: 0.3;'>" |
| 358 " <rect id='rectWithOpacity' opacity='0.4' />" | 408 " <rect id='rectWithOpacity' opacity='0.4' />" |
| 359 " </svg>" | 409 " </svg>" |
| 360 "</div>"); | 410 "</div>"); |
| 361 | 411 |
| 362 LayoutObject& divWithOpacity = *document().getElementById("divWithOpacity")-
>layoutObject(); | 412 LayoutObject& divWithOpacity = *document().getElementById("divWithOpacity")-
>layoutObject(); |
| 363 const ObjectPaintProperties* divWithOpacityProperties = divWithOpacity.objec
tPaintProperties(); | 413 const ObjectPaintProperties* divWithOpacityProperties = divWithOpacity.objec
tPaintProperties(); |
| 364 EXPECT_EQ(0.2f, divWithOpacityProperties->effect()->opacity()); | 414 EXPECT_EQ(0.2f, divWithOpacityProperties->effect()->opacity()); |
| 365 EXPECT_NE(nullptr, divWithOpacityProperties->effect()->parent()); | 415 EXPECT_NE(nullptr, divWithOpacityProperties->effect()->parent()); |
| 366 | 416 |
| 367 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp
acity")->layoutObject(); | 417 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp
acity")->layoutObject(); |
| 368 const ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpaci
ty.objectPaintProperties(); | 418 const ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpaci
ty.objectPaintProperties(); |
| 369 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); | 419 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); |
| 370 EXPECT_EQ(divWithOpacityProperties->effect(), svgRootWithOpacityProperties->
effect()->parent()); | 420 EXPECT_EQ(divWithOpacityProperties->effect(), svgRootWithOpacityProperties->
effect()->parent()); |
| 371 | 421 |
| 372 LayoutObject& rectWithOpacity = *document().getElementById("rectWithOpacity"
)->layoutObject(); | 422 LayoutObject& rectWithOpacity = *document().getElementById("rectWithOpacity"
)->layoutObject(); |
| 373 const ObjectPaintProperties* rectWithOpacityProperties = rectWithOpacity.obj
ectPaintProperties(); | 423 const ObjectPaintProperties* rectWithOpacityProperties = rectWithOpacity.obj
ectPaintProperties(); |
| 374 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity()); | 424 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity()); |
| 375 EXPECT_EQ(svgRootWithOpacityProperties->effect(), rectWithOpacityProperties-
>effect()->parent()); | 425 EXPECT_EQ(svgRootWithOpacityProperties->effect(), rectWithOpacityProperties-
>effect()->parent()); |
| 376 } | 426 } |
| 377 | 427 |
| 378 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossSVGHTMLBoundary) | 428 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossSVGHTMLBoundary) |
| 379 { | 429 { |
| 380 setBodyInnerHTML( | 430 setBodyInnerHTML( |
| 381 "<svg id='svgRootWithOpacity' style='opacity: 0.3;'>" | 431 "<svg id='svgRootWithOpacity' style='opacity: 0.3;'>" |
| 382 " <foreignObject id='foreignObjectWithOpacity' opacity='0.4'>" | 432 " <foreignObject id='foreignObjectWithOpacity' opacity='0.4'>" |
| 383 " <body>" | 433 " <body>" |
| 384 " <span id='spanWithOpacity' style='opacity: 0.5'/>" | 434 " <span id='spanWithOpacity' style='opacity: 0.5'/>" |
| 385 " </body>" | 435 " </body>" |
| 386 " </foreignObject>" | 436 " </foreignObject>" |
| 387 "</svg>"); | 437 "</svg>"); |
| 388 | 438 |
| 389 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp
acity")->layoutObject(); | 439 LayoutObject& svgRootWithOpacity = *document().getElementById("svgRootWithOp
acity")->layoutObject(); |
| 390 const ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpaci
ty.objectPaintProperties(); | 440 const ObjectPaintProperties* svgRootWithOpacityProperties = svgRootWithOpaci
ty.objectPaintProperties(); |
| 391 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); | 441 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); |
| 392 EXPECT_NE(nullptr, svgRootWithOpacityProperties->effect()->parent()); | 442 EXPECT_NE(nullptr, svgRootWithOpacityProperties->effect()->parent()); |
| 393 | 443 |
| 394 LayoutObject& foreignObjectWithOpacity = *document().getElementById("foreign
ObjectWithOpacity")->layoutObject(); | 444 LayoutObject& foreignObjectWithOpacity = *document().getElementById("foreign
ObjectWithOpacity")->layoutObject(); |
| 395 const ObjectPaintProperties* foreignObjectWithOpacityProperties = foreignObj
ectWithOpacity.objectPaintProperties(); | 445 const ObjectPaintProperties* foreignObjectWithOpacityProperties = foreignObj
ectWithOpacity.objectPaintProperties(); |
| 396 EXPECT_EQ(0.4f, foreignObjectWithOpacityProperties->effect()->opacity()); | 446 EXPECT_EQ(0.4f, foreignObjectWithOpacityProperties->effect()->opacity()); |
| 397 EXPECT_EQ(svgRootWithOpacityProperties->effect(), foreignObjectWithOpacityPr
operties->effect()->parent()); | 447 EXPECT_EQ(svgRootWithOpacityProperties->effect(), foreignObjectWithOpacityPr
operties->effect()->parent()); |
| 398 | 448 |
| 399 LayoutObject& spanWithOpacity = *document().getElementById("spanWithOpacity"
)->layoutObject(); | 449 LayoutObject& spanWithOpacity = *document().getElementById("spanWithOpacity"
)->layoutObject(); |
| 400 const ObjectPaintProperties* spanWithOpacityProperties = spanWithOpacity.obj
ectPaintProperties(); | 450 const ObjectPaintProperties* spanWithOpacityProperties = spanWithOpacity.obj
ectPaintProperties(); |
| 401 EXPECT_EQ(0.5f, spanWithOpacityProperties->effect()->opacity()); | 451 EXPECT_EQ(0.5f, spanWithOpacityProperties->effect()->opacity()); |
| 402 EXPECT_EQ(foreignObjectWithOpacityProperties->effect(), spanWithOpacityPrope
rties->effect()->parent()); | 452 EXPECT_EQ(foreignObjectWithOpacityProperties->effect(), spanWithOpacityPrope
rties->effect()->parent()); |
| 403 } | 453 } |
| 404 | 454 |
| 405 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesInSVG) | 455 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesInSVG) |
| 406 { | 456 { |
| 407 setBodyInnerHTML( | 457 setBodyInnerHTML( |
| 408 "<style>" | 458 "<style>" |
| 409 " body {" | 459 " body {" |
| 410 " margin: 0px;" | 460 " margin: 0px;" |
| 411 " }" | 461 " }" |
| 412 " svg {" | 462 " svg {" |
| 413 " margin-left: 50px;" | 463 " margin-left: 50px;" |
| 414 " transform: translate3d(1px, 2px, 3px);" | 464 " transform: translate3d(1px, 2px, 3px);" |
| 415 " position: absolute;" | 465 " position: absolute;" |
| 416 " left: 20px;" | 466 " left: 20px;" |
| 417 " top: 25px;" | 467 " top: 25px;" |
| 418 " }" | 468 " }" |
| 419 " rect {" | 469 " rect {" |
| 420 " transform: translate(100px, 100px) rotate(45deg);" | 470 " transform: translate(100px, 100px) rotate(45deg);" |
| 421 " transform-origin: 50px 25px;" | 471 " transform-origin: 50px 25px;" |
| 422 " }" | 472 " }" |
| 423 "</style>" | 473 "</style>" |
| 424 "<svg id='svgRootWith3dTransform' width='100px' height='100px'>" | 474 "<svg id='svgRootWith3dTransform' width='100px' height='100px'>" |
| 425 " <rect id='rectWith2dTransform' width='100px' height='100px' />" | 475 " <rect id='rectWith2dTransform' width='100px' height='100px' />" |
| 426 "</svg>"); | 476 "</svg>"); |
| 427 | 477 |
| 428 LayoutObject& svgRootWith3dTransform = *document().getElementById("svgRootWi
th3dTransform")->layoutObject(); | 478 LayoutObject& svgRootWith3dTransform = *document().getElementById("svgRootWi
th3dTransform")->layoutObject(); |
| 429 const ObjectPaintProperties* svgRootWith3dTransformProperties = svgRootWith3
dTransform.objectPaintProperties(); | 479 const ObjectPaintProperties* svgRootWith3dTransformProperties = svgRootWith3
dTransform.objectPaintProperties(); |
| 430 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgRootWith3dTransfor
mProperties->transform()->matrix()); | 480 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgRootWith3dTransfor
mProperties->transform()->matrix()); |
| 431 EXPECT_EQ(FloatPoint3D(50, 50, 0), svgRootWith3dTransformProperties->transfo
rm()->origin()); | 481 EXPECT_EQ(FloatPoint3D(50, 50, 0), svgRootWith3dTransformProperties->transfo
rm()->origin()); |
| 432 EXPECT_EQ(svgRootWith3dTransformProperties->paintOffsetTranslation(), svgRoo
tWith3dTransformProperties->transform()->parent()); | 482 EXPECT_EQ(svgRootWith3dTransformProperties->paintOffsetTranslation(), svgRoo
tWith3dTransformProperties->transform()->parent()); |
| 433 EXPECT_EQ(TransformationMatrix().translate(70, 25), svgRootWith3dTransformPr
operties->paintOffsetTranslation()->matrix()); | 483 EXPECT_EQ(TransformationMatrix().translate(70, 25), svgRootWith3dTransformPr
operties->paintOffsetTranslation()->matrix()); |
| 434 EXPECT_EQ(document().view()->scrollTranslation(), svgRootWith3dTransformProp
erties->paintOffsetTranslation()->parent()); | 484 EXPECT_EQ(frameScrollTranslation(), svgRootWith3dTransformProperties->paintO
ffsetTranslation()->parent()); |
| 435 | 485 |
| 436 LayoutObject& rectWith2dTransform = *document().getElementById("rectWith2dTr
ansform")->layoutObject(); | 486 LayoutObject& rectWith2dTransform = *document().getElementById("rectWith2dTr
ansform")->layoutObject(); |
| 437 const ObjectPaintProperties* rectWith2dTransformProperties = rectWith2dTrans
form.objectPaintProperties(); | 487 const ObjectPaintProperties* rectWith2dTransformProperties = rectWith2dTrans
form.objectPaintProperties(); |
| 438 TransformationMatrix matrix; | 488 TransformationMatrix matrix; |
| 439 matrix.translate(100, 100); | 489 matrix.translate(100, 100); |
| 440 matrix.rotate(45); | 490 matrix.rotate(45); |
| 441 // SVG's transform origin is baked into the transform. | 491 // SVG's transform origin is baked into the transform. |
| 442 matrix.applyTransformOrigin(50, 25, 0); | 492 matrix.applyTransformOrigin(50, 25, 0); |
| 443 EXPECT_EQ(matrix, rectWith2dTransformProperties->transform()->matrix()); | 493 EXPECT_EQ(matrix, rectWith2dTransformProperties->transform()->matrix()); |
| 444 EXPECT_EQ(FloatPoint3D(0, 0, 0), rectWith2dTransformProperties->transform()-
>origin()); | 494 EXPECT_EQ(FloatPoint3D(0, 0, 0), rectWith2dTransformProperties->transform()-
>origin()); |
| 445 // SVG does not use paint offset. | 495 // SVG does not use paint offset. |
| 446 EXPECT_EQ(nullptr, rectWith2dTransformProperties->paintOffsetTranslation()); | 496 EXPECT_EQ(nullptr, rectWith2dTransformProperties->paintOffsetTranslation()); |
| 447 } | 497 } |
| 448 | 498 |
| 449 TEST_F(PaintPropertyTreeBuilderTest, SVGViewBoxTransform) | 499 TEST_P(PaintPropertyTreeBuilderTest, SVGViewBoxTransform) |
| 450 { | 500 { |
| 451 setBodyInnerHTML( | 501 setBodyInnerHTML( |
| 452 "<style>" | 502 "<style>" |
| 453 " body {" | 503 " body {" |
| 454 " margin: 0px;" | 504 " margin: 0px;" |
| 455 " }" | 505 " }" |
| 456 " svg {" | 506 " svg {" |
| 457 " transform: translate3d(1px, 2px, 3px);" | 507 " transform: translate3d(1px, 2px, 3px);" |
| 458 " position: absolute;" | 508 " position: absolute;" |
| 459 " }" | 509 " }" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 470 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithViewBoxPropert
ies->transform()->matrix()); | 520 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithViewBoxPropert
ies->transform()->matrix()); |
| 471 EXPECT_EQ(TransformationMatrix().translate(-50, -50), svgWithViewBoxProperti
es->svgLocalToBorderBoxTransform()->matrix()); | 521 EXPECT_EQ(TransformationMatrix().translate(-50, -50), svgWithViewBoxProperti
es->svgLocalToBorderBoxTransform()->matrix()); |
| 472 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform()->parent()
, svgWithViewBoxProperties->transform()); | 522 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform()->parent()
, svgWithViewBoxProperties->transform()); |
| 473 | 523 |
| 474 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); | 524 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); |
| 475 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); | 525 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); |
| 476 EXPECT_EQ(TransformationMatrix().translate(100, 100), rectProperties->transf
orm()->matrix()); | 526 EXPECT_EQ(TransformationMatrix().translate(100, 100), rectProperties->transf
orm()->matrix()); |
| 477 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), rectProp
erties->transform()->parent()); | 527 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), rectProp
erties->transform()->parent()); |
| 478 } | 528 } |
| 479 | 529 |
| 480 TEST_F(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode) | 530 TEST_P(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode) |
| 481 { | 531 { |
| 482 setBodyInnerHTML( | 532 setBodyInnerHTML( |
| 483 "<style>body { margin: 0px; } </style>" | 533 "<style>body { margin: 0px; } </style>" |
| 484 "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px;
height: 100px;' />"); | 534 "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px;
height: 100px;' />"); |
| 485 | 535 |
| 486 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); | 536 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
| 487 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); | 537 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); |
| 488 // Ensure that a paint offset transform is not unnecessarily emitted. | 538 // Ensure that a paint offset transform is not unnecessarily emitted. |
| 489 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation()); | 539 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation()); |
| 490 EXPECT_EQ(TransformationMatrix().translate(50, 25), svgProperties->svgLocalT
oBorderBoxTransform()->matrix()); | 540 EXPECT_EQ(TransformationMatrix().translate(50, 25), svgProperties->svgLocalT
oBorderBoxTransform()->matrix()); |
| 491 EXPECT_EQ(document().view()->scrollTranslation(), svgProperties->svgLocalToB
orderBoxTransform()->parent()); | 541 EXPECT_EQ(frameScrollTranslation(), svgProperties->svgLocalToBorderBoxTransf
orm()->parent()); |
| 492 } | 542 } |
| 493 | 543 |
| 494 TEST_F(PaintPropertyTreeBuilderTest, SVGRootLocalToBorderBoxTransformNode) | 544 TEST_P(PaintPropertyTreeBuilderTest, SVGRootLocalToBorderBoxTransformNode) |
| 495 { | 545 { |
| 496 setBodyInnerHTML( | 546 setBodyInnerHTML( |
| 497 "<style>" | 547 "<style>" |
| 498 " body { margin: 0px; }" | 548 " body { margin: 0px; }" |
| 499 " svg { margin-left: 2px; margin-top: 3px; transform: translate(5px, 7p
x); border: 11px solid green; }" | 549 " svg { margin-left: 2px; margin-top: 3px; transform: translate(5px, 7p
x); border: 11px solid green; }" |
| 500 "</style>" | 550 "</style>" |
| 501 "<svg id='svg' width='100px' height='100px' viewBox='0 0 13 13'>" | 551 "<svg id='svg' width='100px' height='100px' viewBox='0 0 13 13'>" |
| 502 " <rect id='rect' transform='translate(17 19)' />" | 552 " <rect id='rect' transform='translate(17 19)' />" |
| 503 "</svg>"); | 553 "</svg>"); |
| 504 | 554 |
| 505 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); | 555 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
| 506 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); | 556 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); |
| 507 EXPECT_EQ(TransformationMatrix().translate(2, 3), svgProperties->paintOffset
Translation()->matrix()); | 557 EXPECT_EQ(TransformationMatrix().translate(2, 3), svgProperties->paintOffset
Translation()->matrix()); |
| 508 EXPECT_EQ(TransformationMatrix().translate(5, 7), svgProperties->transform()
->matrix()); | 558 EXPECT_EQ(TransformationMatrix().translate(5, 7), svgProperties->transform()
->matrix()); |
| 509 EXPECT_EQ(TransformationMatrix().translate(11, 11).scale(100.0 / 13.0), svgP
roperties->svgLocalToBorderBoxTransform()->matrix()); | 559 EXPECT_EQ(TransformationMatrix().translate(11, 11).scale(100.0 / 13.0), svgP
roperties->svgLocalToBorderBoxTransform()->matrix()); |
| 510 EXPECT_EQ(svgProperties->paintOffsetTranslation(), svgProperties->transform(
)->parent()); | 560 EXPECT_EQ(svgProperties->paintOffsetTranslation(), svgProperties->transform(
)->parent()); |
| 511 EXPECT_EQ(svgProperties->transform(), svgProperties->svgLocalToBorderBoxTran
sform()->parent()); | 561 EXPECT_EQ(svgProperties->transform(), svgProperties->svgLocalToBorderBoxTran
sform()->parent()); |
| 512 | 562 |
| 513 // Ensure the rect's transform is a child of the local to border box transfo
rm. | 563 // Ensure the rect's transform is a child of the local to border box transfo
rm. |
| 514 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); | 564 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); |
| 515 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); | 565 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); |
| 516 EXPECT_EQ(TransformationMatrix().translate(17, 19), rectProperties->transfor
m()->matrix()); | 566 EXPECT_EQ(TransformationMatrix().translate(17, 19), rectProperties->transfor
m()->matrix()); |
| 517 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), rectProperties->tra
nsform()->parent()); | 567 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), rectProperties->tra
nsform()->parent()); |
| 518 } | 568 } |
| 519 | 569 |
| 520 TEST_F(PaintPropertyTreeBuilderTest, SVGNestedViewboxTransforms) | 570 TEST_P(PaintPropertyTreeBuilderTest, SVGNestedViewboxTransforms) |
| 521 { | 571 { |
| 522 setBodyInnerHTML( | 572 setBodyInnerHTML( |
| 523 "<style>body { margin: 0px; } </style>" | 573 "<style>body { margin: 0px; } </style>" |
| 524 "<svg id='svg' width='100px' height='100px' viewBox='0 0 50 50' style='t
ransform: translate(11px, 11px);'>" | 574 "<svg id='svg' width='100px' height='100px' viewBox='0 0 50 50' style='t
ransform: translate(11px, 11px);'>" |
| 525 " <svg id='nestedSvg' width='50px' height='50px' viewBox='0 0 5 5'>" | 575 " <svg id='nestedSvg' width='50px' height='50px' viewBox='0 0 5 5'>" |
| 526 " <rect id='rect' transform='translate(13 13)' />" | 576 " <rect id='rect' transform='translate(13 13)' />" |
| 527 " </svg>" | 577 " </svg>" |
| 528 "</svg>"); | 578 "</svg>"); |
| 529 | 579 |
| 530 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); | 580 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
| 531 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); | 581 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); |
| 532 EXPECT_EQ(TransformationMatrix().translate(11, 11), svgProperties->transform
()->matrix()); | 582 EXPECT_EQ(TransformationMatrix().translate(11, 11), svgProperties->transform
()->matrix()); |
| 533 EXPECT_EQ(TransformationMatrix().scale(2), svgProperties->svgLocalToBorderBo
xTransform()->matrix()); | 583 EXPECT_EQ(TransformationMatrix().scale(2), svgProperties->svgLocalToBorderBo
xTransform()->matrix()); |
| 534 | 584 |
| 535 LayoutObject& nestedSvg = *document().getElementById("nestedSvg")->layoutObj
ect(); | 585 LayoutObject& nestedSvg = *document().getElementById("nestedSvg")->layoutObj
ect(); |
| 536 const ObjectPaintProperties* nestedSvgProperties = nestedSvg.objectPaintProp
erties(); | 586 const ObjectPaintProperties* nestedSvgProperties = nestedSvg.objectPaintProp
erties(); |
| 537 EXPECT_EQ(TransformationMatrix().scale(10), nestedSvgProperties->transform()
->matrix()); | 587 EXPECT_EQ(TransformationMatrix().scale(10), nestedSvgProperties->transform()
->matrix()); |
| 538 EXPECT_EQ(nullptr, nestedSvgProperties->svgLocalToBorderBoxTransform()); | 588 EXPECT_EQ(nullptr, nestedSvgProperties->svgLocalToBorderBoxTransform()); |
| 539 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), nestedSvgProperties
->transform()->parent()); | 589 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), nestedSvgProperties
->transform()->parent()); |
| 540 | 590 |
| 541 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); | 591 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); |
| 542 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); | 592 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); |
| 543 EXPECT_EQ(TransformationMatrix().translate(13, 13), rectProperties->transfor
m()->matrix()); | 593 EXPECT_EQ(TransformationMatrix().translate(13, 13), rectProperties->transfor
m()->matrix()); |
| 544 EXPECT_EQ(nestedSvgProperties->transform(), rectProperties->transform()->par
ent()); | 594 EXPECT_EQ(nestedSvgProperties->transform(), rectProperties->transform()->par
ent()); |
| 545 } | 595 } |
| 546 | 596 |
| 547 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSVGHTMLBoundary) | 597 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesAcrossSVGHTMLBoundary) |
| 548 { | 598 { |
| 549 setBodyInnerHTML( | 599 setBodyInnerHTML( |
| 550 "<style> body { margin: 0px; } </style>" | 600 "<style> body { margin: 0px; } </style>" |
| 551 "<svg id='svgWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" | 601 "<svg id='svgWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" |
| 552 " <foreignObject>" | 602 " <foreignObject>" |
| 553 " <body>" | 603 " <body>" |
| 554 " <div id='divWithTransform' style='transform: translate3d(3px, 4px
, 5px);'></div>" | 604 " <div id='divWithTransform' style='transform: translate3d(3px, 4px
, 5px);'></div>" |
| 555 " </body>" | 605 " </body>" |
| 556 " </foreignObject>" | 606 " </foreignObject>" |
| 557 "</svg>"); | 607 "</svg>"); |
| 558 | 608 |
| 559 LayoutObject& svgWithTransform = *document().getElementById("svgWithTransfor
m")->layoutObject(); | 609 LayoutObject& svgWithTransform = *document().getElementById("svgWithTransfor
m")->layoutObject(); |
| 560 const ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.o
bjectPaintProperties(); | 610 const ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.o
bjectPaintProperties(); |
| 561 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithTransformPrope
rties->transform()->matrix()); | 611 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgWithTransformPrope
rties->transform()->matrix()); |
| 562 | 612 |
| 563 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor
m")->layoutObject(); | 613 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor
m")->layoutObject(); |
| 564 const ObjectPaintProperties* divWithTransformProperties = divWithTransform.o
bjectPaintProperties(); | 614 const ObjectPaintProperties* divWithTransformProperties = divWithTransform.o
bjectPaintProperties(); |
| 565 EXPECT_EQ(TransformationMatrix().translate3d(3, 4, 5), divWithTransformPrope
rties->transform()->matrix()); | 615 EXPECT_EQ(TransformationMatrix().translate3d(3, 4, 5), divWithTransformPrope
rties->transform()->matrix()); |
| 566 // Ensure the div's transform node is a child of the svg's transform node. | 616 // Ensure the div's transform node is a child of the svg's transform node. |
| 567 EXPECT_EQ(svgWithTransformProperties->transform(), divWithTransformPropertie
s->transform()->parent()); | 617 EXPECT_EQ(svgWithTransformProperties->transform(), divWithTransformPropertie
s->transform()->parent()); |
| 568 } | 618 } |
| 569 | 619 |
| 570 TEST_F(PaintPropertyTreeBuilderTest, FixedTransformAncestorAcrossSVGHTMLBoundary
) | 620 TEST_P(PaintPropertyTreeBuilderTest, FixedTransformAncestorAcrossSVGHTMLBoundary
) |
| 571 { | 621 { |
| 572 setBodyInnerHTML( | 622 setBodyInnerHTML( |
| 573 "<style> body { margin: 0px; } </style>" | 623 "<style> body { margin: 0px; } </style>" |
| 574 "<svg id='svg' style='transform: translate3d(1px, 2px, 3px);'>" | 624 "<svg id='svg' style='transform: translate3d(1px, 2px, 3px);'>" |
| 575 " <g id='container' transform='translate(20 30)'>" | 625 " <g id='container' transform='translate(20 30)'>" |
| 576 " <foreignObject>" | 626 " <foreignObject>" |
| 577 " <body>" | 627 " <body>" |
| 578 " <div id='fixed' style='position: fixed; left: 200px; top: 150px
;'></div>" | 628 " <div id='fixed' style='position: fixed; left: 200px; top: 150px
;'></div>" |
| 579 " </body>" | 629 " </body>" |
| 580 " </foreignObject>" | 630 " </foreignObject>" |
| 581 " </g>" | 631 " </g>" |
| 582 "</svg>"); | 632 "</svg>"); |
| 583 | 633 |
| 584 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); | 634 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
| 585 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); | 635 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); |
| 586 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgProperties->transf
orm()->matrix()); | 636 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), svgProperties->transf
orm()->matrix()); |
| 587 | 637 |
| 588 LayoutObject& container = *document().getElementById("container")->layoutObj
ect(); | 638 LayoutObject& container = *document().getElementById("container")->layoutObj
ect(); |
| 589 const ObjectPaintProperties* containerProperties = container.objectPaintProp
erties(); | 639 const ObjectPaintProperties* containerProperties = container.objectPaintProp
erties(); |
| 590 EXPECT_EQ(TransformationMatrix().translate(20, 30), containerProperties->tra
nsform()->matrix()); | 640 EXPECT_EQ(TransformationMatrix().translate(20, 30), containerProperties->tra
nsform()->matrix()); |
| 591 EXPECT_EQ(svgProperties->transform(), containerProperties->transform()->pare
nt()); | 641 EXPECT_EQ(svgProperties->transform(), containerProperties->transform()->pare
nt()); |
| 592 | 642 |
| 593 Element* fixed = document().getElementById("fixed"); | 643 Element* fixed = document().getElementById("fixed"); |
| 594 const ObjectPaintProperties* fixedProperties = fixed->layoutObject()->object
PaintProperties(); | 644 const ObjectPaintProperties* fixedProperties = fixed->layoutObject()->object
PaintProperties(); |
| 595 EXPECT_EQ(TransformationMatrix().translate(200, 150), fixedProperties->paint
OffsetTranslation()->matrix()); | 645 EXPECT_EQ(TransformationMatrix().translate(200, 150), fixedProperties->paint
OffsetTranslation()->matrix()); |
| 596 // Ensure the fixed position element is rooted at the nearest transform cont
ainer. | 646 // Ensure the fixed position element is rooted at the nearest transform cont
ainer. |
| 597 EXPECT_EQ(containerProperties->transform(), fixedProperties->paintOffsetTran
slation()->parent()); | 647 EXPECT_EQ(containerProperties->transform(), fixedProperties->paintOffsetTran
slation()->parent()); |
| 598 } | 648 } |
| 599 | 649 |
| 600 TEST_F(PaintPropertyTreeBuilderTest, ControlClip) | 650 TEST_P(PaintPropertyTreeBuilderTest, ControlClip) |
| 601 { | 651 { |
| 602 setBodyInnerHTML( | 652 setBodyInnerHTML( |
| 603 "<style>" | 653 "<style>" |
| 604 " body {" | 654 " body {" |
| 605 " margin: 0;" | 655 " margin: 0;" |
| 606 " }" | 656 " }" |
| 607 " input {" | 657 " input {" |
| 608 " border-width: 5px;" | 658 " border-width: 5px;" |
| 609 " padding: 0;" | 659 " padding: 0;" |
| 610 " }" | 660 " }" |
| 611 "</style>" | 661 "</style>" |
| 612 "<input id='button' type='button' style='width:345px; height:123px' valu
e='some text'/>"); | 662 "<input id='button' type='button' style='width:345px; height:123px' valu
e='some text'/>"); |
| 613 | 663 |
| 614 FrameView* frameView = document().view(); | |
| 615 LayoutObject& button = *document().getElementById("button")->layoutObject(); | 664 LayoutObject& button = *document().getElementById("button")->layoutObject(); |
| 616 const ObjectPaintProperties* buttonProperties = button.objectPaintProperties
(); | 665 const ObjectPaintProperties* buttonProperties = button.objectPaintProperties
(); |
| 617 EXPECT_EQ(frameView->scrollTranslation(), buttonProperties->overflowClip()->
localTransformSpace()); | 666 EXPECT_EQ(frameScrollTranslation(), buttonProperties->overflowClip()->localT
ransformSpace()); |
| 618 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip()
->clipRect()); | 667 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip()
->clipRect()); |
| 619 EXPECT_EQ(frameView->contentClip(), buttonProperties->overflowClip()->parent
()); | 668 EXPECT_EQ(frameContentClip(), buttonProperties->overflowClip()->parent()); |
| 620 } | 669 } |
| 621 | 670 |
| 622 TEST_F(PaintPropertyTreeBuilderTest, BorderRadiusClip) | 671 TEST_P(PaintPropertyTreeBuilderTest, BorderRadiusClip) |
| 623 { | 672 { |
| 624 setBodyInnerHTML( | 673 setBodyInnerHTML( |
| 625 "<style>" | 674 "<style>" |
| 626 " body {" | 675 " body {" |
| 627 " margin: 0px;" | 676 " margin: 0px;" |
| 628 " }" | 677 " }" |
| 629 " #div {" | 678 " #div {" |
| 630 " border-radius: 12px 34px 56px 78px;" | 679 " border-radius: 12px 34px 56px 78px;" |
| 631 " border-top: 45px solid;" | 680 " border-top: 45px solid;" |
| 632 " border-right: 50px solid;" | 681 " border-right: 50px solid;" |
| 633 " border-bottom: 55px solid;" | 682 " border-bottom: 55px solid;" |
| 634 " border-left: 60px solid;" | 683 " border-left: 60px solid;" |
| 635 " width: 500px;" | 684 " width: 500px;" |
| 636 " height: 400px;" | 685 " height: 400px;" |
| 637 " overflow: scroll;" | 686 " overflow: scroll;" |
| 638 " }" | 687 " }" |
| 639 "</style>" | 688 "</style>" |
| 640 "<div id='div'></div>"); | 689 "<div id='div'></div>"); |
| 641 | 690 |
| 642 FrameView* frameView = document().view(); | |
| 643 LayoutObject& div = *document().getElementById("div")->layoutObject(); | 691 LayoutObject& div = *document().getElementById("div")->layoutObject(); |
| 644 const ObjectPaintProperties* divProperties = div.objectPaintProperties(); | 692 const ObjectPaintProperties* divProperties = div.objectPaintProperties(); |
| 645 EXPECT_EQ(frameView->scrollTranslation(), divProperties->overflowClip()->loc
alTransformSpace()); | 693 EXPECT_EQ(frameScrollTranslation(), divProperties->overflowClip()->localTran
sformSpace()); |
| 646 // The overflow clip rect includes only the padding box. | 694 // The overflow clip rect includes only the padding box. |
| 647 // padding box = border box(500+60+50, 400+45+55) - border outset(60+50, 45+
55) - scrollbars(15, 15) | 695 // padding box = border box(500+60+50, 400+45+55) - border outset(60+50, 45+
55) - scrollbars(15, 15) |
| 648 EXPECT_EQ(FloatRoundedRect(60, 45, 500, 400), divProperties->overflowClip()-
>clipRect()); | 696 EXPECT_EQ(FloatRoundedRect(60, 45, 500, 400), divProperties->overflowClip()-
>clipRect()); |
| 649 const ClipPaintPropertyNode* borderRadiusClip = divProperties->overflowClip(
)->parent(); | 697 const ClipPaintPropertyNode* borderRadiusClip = divProperties->overflowClip(
)->parent(); |
| 650 EXPECT_EQ(frameView->scrollTranslation(), borderRadiusClip->localTransformSp
ace()); | 698 EXPECT_EQ(frameScrollTranslation(), borderRadiusClip->localTransformSpace())
; |
| 651 // The border radius clip is the area enclosed by inner border edge, includi
ng the scrollbars. | 699 // The border radius clip is the area enclosed by inner border edge, includi
ng the scrollbars. |
| 652 // As the border-radius is specified in outer radius, the inner radius is ca
lculated by: | 700 // As the border-radius is specified in outer radius, the inner radius is ca
lculated by: |
| 653 // inner radius = max(outer radius - border width, 0) | 701 // inner radius = max(outer radius - border width, 0) |
| 654 // In the case that two adjacent borders have different width, the inner rad
ius of the corner | 702 // In the case that two adjacent borders have different width, the inner rad
ius of the corner |
| 655 // may transition from one value to the other. i.e. being an ellipse. | 703 // may transition from one value to the other. i.e. being an ellipse. |
| 656 EXPECT_EQ( | 704 EXPECT_EQ( |
| 657 FloatRoundedRect( | 705 FloatRoundedRect( |
| 658 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs
et(110, 100) | 706 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs
et(110, 100) |
| 659 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0,
0)) | 707 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0,
0)) |
| 660 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0,
0)) | 708 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0,
0)) |
| 661 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0,
0)) | 709 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0,
0)) |
| 662 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0,
0)) | 710 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0,
0)) |
| 663 borderRadiusClip->clipRect()); | 711 borderRadiusClip->clipRect()); |
| 664 EXPECT_EQ(frameView->contentClip(), borderRadiusClip->parent()); | 712 EXPECT_EQ(frameContentClip(), borderRadiusClip->parent()); |
| 665 } | 713 } |
| 666 | 714 |
| 667 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes) | 715 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes) |
| 668 { | 716 { |
| 669 setBodyInnerHTML( | 717 setBodyInnerHTML( |
| 670 "<style>body { margin: 0; }</style>" | 718 "<style>body { margin: 0; }</style>" |
| 671 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" | 719 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" |
| 672 " <iframe id='frame'></iframe>" | 720 " <iframe style='border: 7px solid black' id='frame'></iframe>" |
| 673 "</div>"); | 721 "</div>"); |
| 674 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 0
; }</style><div id='transform' style='transform: translate3d(4px, 5px, 6px);'></
div>"); | 722 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 0
; }</style><div id='transform' style='transform: translate3d(4px, 5px, 6px);'></
div>"); |
| 675 document().view()->updateAllLifecyclePhases(); | 723 document().view()->updateAllLifecyclePhases(); |
| 676 | 724 |
| 677 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor
m")->layoutObject(); | 725 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor
m")->layoutObject(); |
| 678 const ObjectPaintProperties* divWithTransformProperties = divWithTransform.o
bjectPaintProperties(); | 726 const ObjectPaintProperties* divWithTransformProperties = divWithTransform.o
bjectPaintProperties(); |
| 679 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope
rties->transform()->matrix()); | 727 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope
rties->transform()->matrix()); |
| 680 | 728 |
| 681 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); | 729 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); |
| 682 const ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithT
ransform->objectPaintProperties(); | 730 const ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithT
ransform->objectPaintProperties(); |
| 683 auto* innerDivTransform = innerDivWithTransformProperties->transform(); | 731 auto* innerDivTransform = innerDivWithTransformProperties->transform(); |
| 684 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivTransform->ma
trix()); | 732 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivTransform->ma
trix()); |
| 685 | 733 |
| 686 // Ensure that the inner div's transform is correctly rooted in the root fra
me's transform tree. | 734 // Ensure that the inner div's transform is correctly rooted in the root fra
me's transform tree. |
| 687 // This asserts that we have the following tree structure: | 735 // This asserts that we have the following tree structure: |
| 688 // ... | 736 // ... |
| 689 // Transform transform=translation=1.000000,2.000000,3.000000 | 737 // Transform transform=translation=1.000000,2.000000,3.000000 |
| 690 // PreTranslation transform=translation=2.000000,2.000000,0.000000 | 738 // PreTranslation transform=translation=7.000000,7.000000,0.000000 |
| 691 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000 | 739 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000 |
| 692 // Transform transform=translation=4.000000,5.000000,6.000000 | 740 // Transform transform=translation=4.000000,5.000000,6.000000 |
| 693 auto* innerDocumentScrollTranslation = innerDivTransform->parent(); | 741 auto* innerDocumentScrollTranslation = innerDivTransform->parent(); |
| 694 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr
anslation->matrix()); | 742 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr
anslation->matrix()); |
| 695 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); | 743 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); |
| 696 EXPECT_EQ(TransformationMatrix().translate3d(2, 2, 0), iframePreTranslation-
>matrix()); | 744 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePreTranslation-
>matrix()); |
| 697 EXPECT_EQ(divWithTransformProperties->transform(), iframePreTranslation->par
ent()); | 745 EXPECT_EQ(divWithTransformProperties->transform(), iframePreTranslation->par
ent()); |
| 698 } | 746 } |
| 699 | 747 |
| 700 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesInTransformedSubframes) | 748 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesInTransformedSubframes) |
| 701 { | 749 { |
| 702 setBodyInnerHTML( | 750 setBodyInnerHTML( |
| 703 "<style>body { margin: 0; }</style>" | 751 "<style>body { margin: 0; }</style>" |
| 704 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" | 752 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" |
| 705 " <iframe id='frame' style='transform: translate3d(4px, 5px, 6px); bord
er: 42px solid; margin: 7px;'></iframe>" | 753 " <iframe id='frame' style='transform: translate3d(4px, 5px, 6px); bord
er: 42px solid; margin: 7px;'></iframe>" |
| 706 "</div>"); | 754 "</div>"); |
| 707 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 3
1px; }</style><div id='transform' style='transform: translate3d(7px, 8px, 9px);'
></div>"); | 755 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 3
1px; }</style><div id='transform' style='transform: translate3d(7px, 8px, 9px);'
></div>"); |
| 708 document().view()->updateAllLifecyclePhases(); | 756 document().view()->updateAllLifecyclePhases(); |
| 709 | 757 |
| 710 // Assert that we have the following tree structure: | 758 // Assert that we have the following tree structure: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 731 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), iframeTransform->matr
ix()); | 779 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), iframeTransform->matr
ix()); |
| 732 auto* iframePaintOffsetTranslation = iframeTransform->parent(); | 780 auto* iframePaintOffsetTranslation = iframeTransform->parent(); |
| 733 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePaintOffsetTran
slation->matrix()); | 781 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePaintOffsetTran
slation->matrix()); |
| 734 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); | 782 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); |
| 735 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformTrans
form->matrix()); | 783 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformTrans
form->matrix()); |
| 736 | 784 |
| 737 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor
m")->layoutObject(); | 785 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor
m")->layoutObject(); |
| 738 EXPECT_EQ(divWithTransformTransform, divWithTransform.objectPaintProperties(
)->transform()); | 786 EXPECT_EQ(divWithTransformTransform, divWithTransform.objectPaintProperties(
)->transform()); |
| 739 } | 787 } |
| 740 | 788 |
| 741 TEST_F(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) | 789 TEST_P(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) |
| 742 { | 790 { |
| 743 // This test verifies the tree builder correctly computes and records the pr
operty tree context | 791 // This test verifies the tree builder correctly computes and records the pr
operty tree context |
| 744 // for a (pseudo) stacking context that is scrolled by a containing block th
at is not one of | 792 // for a (pseudo) stacking context that is scrolled by a containing block th
at is not one of |
| 745 // the painting ancestors. | 793 // the painting ancestors. |
| 746 setBodyInnerHTML( | 794 setBodyInnerHTML( |
| 747 "<style>body { margin: 0; }</style>" | 795 "<style>body { margin: 0; }</style>" |
| 748 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>
" | 796 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>
" |
| 749 " <div id='child' style='position:relative;'></div>" | 797 " <div id='child' style='position:relative;'></div>" |
| 750 " <div style='height:10000px;'></div>" | 798 " <div style='height:10000px;'></div>" |
| 751 "</div>" | 799 "</div>" |
| 752 ); | 800 ); |
| 753 | 801 |
| 754 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec
t(); | 802 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec
t(); |
| 755 const ObjectPaintProperties* scrollerProperties = scroller.objectPaintProper
ties(); | 803 const ObjectPaintProperties* scrollerProperties = scroller.objectPaintProper
ties(); |
| 756 LayoutObject& child = *document().getElementById("child")->layoutObject(); | 804 LayoutObject& child = *document().getElementById("child")->layoutObject(); |
| 757 const ObjectPaintProperties* childProperties = child.objectPaintProperties()
; | 805 const ObjectPaintProperties* childProperties = child.objectPaintProperties()
; |
| 758 | 806 |
| 759 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo
xProperties()->propertyTreeState.clip); | 807 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo
xProperties()->propertyTreeState.clip); |
| 760 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor
derBoxProperties()->propertyTreeState.transform); | 808 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor
derBoxProperties()->propertyTreeState.transform); |
| 761 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTree
State.effect); | 809 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTree
State.effect); |
| 762 } | 810 } |
| 763 | 811 |
| 764 TEST_F(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext) | 812 TEST_P(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext) |
| 765 { | 813 { |
| 766 // This test verifies the tree builder correctly computes and records the pr
operty tree context | 814 // This test verifies the tree builder correctly computes and records the pr
operty tree context |
| 767 // for a (pseudo) stacking context that has a scrolling painting ancestor th
at is not its | 815 // for a (pseudo) stacking context that has a scrolling painting ancestor th
at is not its |
| 768 // containing block (thus should not be scrolled by it). | 816 // containing block (thus should not be scrolled by it). |
| 769 | 817 |
| 770 setBodyInnerHTML( | 818 setBodyInnerHTML( |
| 771 "<style>body { margin: 0; }</style>" | 819 "<style>body { margin: 0; }</style>" |
| 772 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" | 820 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" |
| 773 " <div id='child' style='position:absolute; left:0; top:0;'></div>" | 821 " <div id='child' style='position:absolute; left:0; top:0;'></div>" |
| 774 " <div style='height:10000px;'></div>" | 822 " <div style='height:10000px;'></div>" |
| 775 "</div>" | 823 "</div>" |
| 776 ); | 824 ); |
| 777 | 825 |
| 778 FrameView* frameView = document().view(); | |
| 779 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec
t(); | 826 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec
t(); |
| 780 const ObjectPaintProperties* scrollerProperties = scroller.objectPaintProper
ties(); | 827 const ObjectPaintProperties* scrollerProperties = scroller.objectPaintProper
ties(); |
| 781 LayoutObject& child = *document().getElementById("child")->layoutObject(); | 828 LayoutObject& child = *document().getElementById("child")->layoutObject(); |
| 782 const ObjectPaintProperties* childProperties = child.objectPaintProperties()
; | 829 const ObjectPaintProperties* childProperties = child.objectPaintProperties()
; |
| 783 | 830 |
| 784 EXPECT_EQ(frameView->contentClip(), childProperties->localBorderBoxPropertie
s()->propertyTreeState.clip); | 831 EXPECT_EQ(frameContentClip(), childProperties->localBorderBoxProperties()->p
ropertyTreeState.clip); |
| 785 EXPECT_EQ(frameView->scrollTranslation(), childProperties->localBorderBoxPro
perties()->propertyTreeState.transform); | 832 EXPECT_EQ(frameScrollTranslation(), childProperties->localBorderBoxPropertie
s()->propertyTreeState.transform); |
| 786 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope
rties()->propertyTreeState.effect); | 833 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope
rties()->propertyTreeState.effect); |
| 787 } | 834 } |
| 788 | 835 |
| 789 TEST_F(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) | 836 TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) |
| 790 { | 837 { |
| 791 // This test verifies that the border box space of a table cell is being cor
rectly computed. | 838 // This test verifies that the border box space of a table cell is being cor
rectly computed. |
| 792 // Table cells have weird location adjustment in our layout/paint implementa
tion. | 839 // Table cells have weird location adjustment in our layout/paint implementa
tion. |
| 793 setBodyInnerHTML( | 840 setBodyInnerHTML( |
| 794 "<style>" | 841 "<style>" |
| 795 " body {" | 842 " body {" |
| 796 " margin: 0;" | 843 " margin: 0;" |
| 797 " }" | 844 " }" |
| 798 " table {" | 845 " table {" |
| 799 " border-spacing: 0;" | 846 " border-spacing: 0;" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 811 " width: 100px;" | 858 " width: 100px;" |
| 812 " height: 100px;" | 859 " height: 100px;" |
| 813 " }" | 860 " }" |
| 814 "</style>" | 861 "</style>" |
| 815 "<table>" | 862 "<table>" |
| 816 " <tr><td></td><td></td></tr>" | 863 " <tr><td></td><td></td></tr>" |
| 817 " <tr><td></td><td><div id='target'></div></td></tr>" | 864 " <tr><td></td><td><div id='target'></div></td></tr>" |
| 818 "</table>" | 865 "</table>" |
| 819 ); | 866 ); |
| 820 | 867 |
| 821 FrameView* frameView = document().view(); | |
| 822 LayoutObject& target = *document().getElementById("target")->layoutObject(); | 868 LayoutObject& target = *document().getElementById("target")->layoutObject(); |
| 823 const ObjectPaintProperties* targetProperties = target.objectPaintProperties
(); | 869 const ObjectPaintProperties* targetProperties = target.objectPaintProperties
(); |
| 824 | 870 |
| 825 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties(
)->paintOffset); | 871 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties(
)->paintOffset); |
| 826 EXPECT_EQ(frameView->scrollTranslation(), targetProperties->localBorderBoxPr
operties()->propertyTreeState.transform); | 872 EXPECT_EQ(frameScrollTranslation(), targetProperties->localBorderBoxProperti
es()->propertyTreeState.transform); |
| 827 } | 873 } |
| 828 | 874 |
| 829 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) | 875 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) |
| 830 { | 876 { |
| 831 // This test verifies that clip tree hierarchy being generated correctly for
the hard case | 877 // This test verifies that clip tree hierarchy being generated correctly for
the hard case |
| 832 // such that a fixed position element getting clipped by an absolute positio
n CSS clip. | 878 // such that a fixed position element getting clipped by an absolute positio
n CSS clip. |
| 833 setBodyInnerHTML( | 879 setBodyInnerHTML( |
| 834 "<style>" | 880 "<style>" |
| 835 " #clip {" | 881 " #clip {" |
| 836 " position: absolute;" | 882 " position: absolute;" |
| 837 " left: 123px;" | 883 " left: 123px;" |
| 838 " top: 456px;" | 884 " top: 456px;" |
| 839 " clip: rect(10px, 80px, 70px, 40px);" | 885 " clip: rect(10px, 80px, 70px, 40px);" |
| 840 " width: 100px;" | 886 " width: 100px;" |
| 841 " height: 100px;" | 887 " height: 100px;" |
| 842 " }" | 888 " }" |
| 843 " #fixed {" | 889 " #fixed {" |
| 844 " position: fixed;" | 890 " position: fixed;" |
| 845 " left: 654px;" | 891 " left: 654px;" |
| 846 " top: 321px;" | 892 " top: 321px;" |
| 847 " }" | 893 " }" |
| 848 "</style>" | 894 "</style>" |
| 849 "<div id='clip'><div id='fixed'></div></div>" | 895 "<div id='clip'><div id='fixed'></div></div>" |
| 850 ); | 896 ); |
| 851 LayoutRect localClipRect(40, 10, 40, 60); | 897 LayoutRect localClipRect(40, 10, 40, 60); |
| 852 LayoutRect absoluteClipRect = localClipRect; | 898 LayoutRect absoluteClipRect = localClipRect; |
| 853 absoluteClipRect.move(123, 456); | 899 absoluteClipRect.move(123, 456); |
| 854 | 900 |
| 855 FrameView* frameView = document().view(); | |
| 856 | |
| 857 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); | 901 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); |
| 858 const ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); | 902 const ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); |
| 859 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); | 903 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent()); |
| 860 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr
ansformSpace()); | 904 EXPECT_EQ(frameScrollTranslation(), clipProperties->cssClip()->localTransfor
mSpace()); |
| 861 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); | 905 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
| 862 | 906 |
| 863 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); | 907 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); |
| 864 const ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties()
; | 908 const ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties()
; |
| 865 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti
es()->propertyTreeState.clip); | 909 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti
es()->propertyTreeState.clip); |
| 866 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); | 910 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties()
->propertyTreeState.transform->parent()); |
| 867 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); | 911 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); |
| 868 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); | 912 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); |
| 869 } | 913 } |
| 870 | 914 |
| 871 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) | 915 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) |
| 872 { | 916 { |
| 873 // This test is similar to CSSClipFixedPositionDescendant above, except that | 917 // This test is similar to CSSClipFixedPositionDescendant above, except that |
| 874 // now we have a parent overflow clip that should be escaped by the fixed de
scendant. | 918 // now we have a parent overflow clip that should be escaped by the fixed de
scendant. |
| 875 setBodyInnerHTML( | 919 setBodyInnerHTML( |
| 876 "<style>" | 920 "<style>" |
| 877 " body {" | 921 " body {" |
| 878 " margin: 0;" | 922 " margin: 0;" |
| 879 " }" | 923 " }" |
| 880 " #overflow {" | 924 " #overflow {" |
| 881 " position: relative;" | 925 " position: relative;" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 896 " left: 654px;" | 940 " left: 654px;" |
| 897 " top: 321px;" | 941 " top: 321px;" |
| 898 " }" | 942 " }" |
| 899 "</style>" | 943 "</style>" |
| 900 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>" | 944 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>" |
| 901 ); | 945 ); |
| 902 LayoutRect localClipRect(40, 10, 40, 60); | 946 LayoutRect localClipRect(40, 10, 40, 60); |
| 903 LayoutRect absoluteClipRect = localClipRect; | 947 LayoutRect absoluteClipRect = localClipRect; |
| 904 absoluteClipRect.move(123, 456); | 948 absoluteClipRect.move(123, 456); |
| 905 | 949 |
| 906 FrameView* frameView = document().view(); | |
| 907 | |
| 908 LayoutObject& overflow = *document().getElementById("overflow")->layoutObjec
t(); | 950 LayoutObject& overflow = *document().getElementById("overflow")->layoutObjec
t(); |
| 909 const ObjectPaintProperties* overflowProperties = overflow.objectPaintProper
ties(); | 951 const ObjectPaintProperties* overflowProperties = overflow.objectPaintProper
ties(); |
| 910 EXPECT_EQ(frameView->contentClip(), overflowProperties->overflowClip()->pare
nt()); | 952 EXPECT_EQ(frameContentClip(), overflowProperties->overflowClip()->parent()); |
| 911 EXPECT_EQ(frameView->scrollTranslation(), overflowProperties->scrollTranslat
ion()->parent()); | 953 EXPECT_EQ(frameScrollTranslation(), overflowProperties->scrollTranslation()-
>parent()); |
| 912 | 954 |
| 913 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); | 955 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); |
| 914 const ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); | 956 const ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); |
| 915 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par
ent()); | 957 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par
ent()); |
| 916 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClip()
->localTransformSpace()); | 958 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClip()
->localTransformSpace()); |
| 917 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); | 959 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
| 918 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClipFixedPosition()->
parent()); | 960 EXPECT_EQ(frameContentClip(), clipProperties->cssClipFixedPosition()->parent
()); |
| 919 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClipFi
xedPosition()->localTransformSpace()); | 961 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClipFi
xedPosition()->localTransformSpace()); |
| 920 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
ClipFixedPosition()->clipRect()); | 962 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
ClipFixedPosition()->clipRect()); |
| 921 | 963 |
| 922 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); | 964 LayoutObject& fixed = *document().getElementById("fixed")->layoutObject(); |
| 923 const ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties()
; | 965 const ObjectPaintProperties* fixedProperties = fixed.objectPaintProperties()
; |
| 924 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord
erBoxProperties()->propertyTreeState.clip); | 966 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord
erBoxProperties()->propertyTreeState.clip); |
| 925 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); | 967 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties()
->propertyTreeState.transform->parent()); |
| 926 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); | 968 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); |
| 927 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); | 969 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); |
| 928 } | 970 } |
| 929 | 971 |
| 930 TEST_F(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) | 972 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) |
| 931 { | 973 { |
| 932 setBodyInnerHTML( | 974 setBodyInnerHTML( |
| 933 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" | 975 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" |
| 934 " <div style='position: relative; top: 100px; left: 100px'>" | 976 " <div style='position: relative; top: 100px; left: 100px'>" |
| 935 " <div id='spanner' style='column-span: all; opacity: 0.5; width: 100
px; height: 100px;'></div>" | 977 " <div id='spanner' style='column-span: all; opacity: 0.5; width: 100
px; height: 100px;'></div>" |
| 936 " </div>" | 978 " </div>" |
| 937 "</div>" | 979 "</div>" |
| 938 ); | 980 ); |
| 939 | 981 |
| 940 LayoutObject& spanner = *getLayoutObjectByElementId("spanner"); | 982 LayoutObject& spanner = *getLayoutObjectByElementId("spanner"); |
| 941 EXPECT_EQ(LayoutPoint(55, 44), spanner.objectPaintProperties()->localBorderB
oxProperties()->paintOffset); | 983 EXPECT_EQ(LayoutPoint(55, 44), spanner.objectPaintProperties()->localBorderB
oxProperties()->paintOffset); |
| 942 } | 984 } |
| 943 | 985 |
| 944 TEST_F(PaintPropertyTreeBuilderTest, FractionalPaintOffset) | 986 TEST_P(PaintPropertyTreeBuilderTest, FractionalPaintOffset) |
| 945 { | 987 { |
| 946 setBodyInnerHTML( | 988 setBodyInnerHTML( |
| 947 "<style>" | 989 "<style>" |
| 948 " * { margin: 0; }" | 990 " * { margin: 0; }" |
| 949 " div { position: absolute; }" | 991 " div { position: absolute; }" |
| 950 "</style>" | 992 "</style>" |
| 951 "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;'
>" | 993 "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;'
>" |
| 952 " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: 11.1p
x;'></div>" | 994 " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: 11.1p
x;'></div>" |
| 953 "</div>" | 995 "</div>" |
| 954 ); | 996 ); |
| 955 | 997 |
| 956 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); | 998 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); |
| 957 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3)); | 999 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3)); |
| 958 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset
); | 1000 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset
); |
| 959 | 1001 |
| 960 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); | 1002 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
| 961 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1))
; | 1003 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1))
; |
| 962 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset
); | 1004 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset
); |
| 963 } | 1005 } |
| 964 | 1006 |
| 965 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping) | 1007 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping) |
| 966 { | 1008 { |
| 967 setBodyInnerHTML( | 1009 setBodyInnerHTML( |
| 968 "<style>" | 1010 "<style>" |
| 969 " * { margin: 0; }" | 1011 " * { margin: 0; }" |
| 970 " div { position: relative; }" | 1012 " div { position: relative; }" |
| 971 "</style>" | 1013 "</style>" |
| 972 "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;'
>" | 1014 "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;'
>" |
| 973 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" | 1015 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" |
| 974 " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: 0.1
px;'></div>" | 1016 " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: 0.1
px;'></div>" |
| 975 " </div>" | 1017 " </div>" |
| 976 "</div>" | 1018 "</div>" |
| 977 ); | 1019 ); |
| 978 | 1020 |
| 979 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); | 1021 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
| 980 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); | 1022 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); |
| 981 // The paint offset transform should be snapped from (0.3,0.3) to (0,0). | 1023 // The paint offset transform should be snapped from (0.3,0.3) to (0,0). |
| 982 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()->
parent()->matrix()); | 1024 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()->
parent()->matrix()); |
| 983 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3). | 1025 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3). |
| 984 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3)); | 1026 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3)); |
| 985 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); | 1027 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); |
| 986 | 1028 |
| 987 // c should be painted starting at subpixelAccumulation + (0.1,0.1) = (0.4,0
.4). | 1029 // c should be painted starting at subpixelAccumulation + (0.1,0.1) = (0.4,0
.4). |
| 988 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.1
, 0.1)); | 1030 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.1
, 0.1)); |
| 989 const ObjectPaintProperties* cProperties = document().getElementById("c")->l
ayoutObject()->objectPaintProperties(); | 1031 const ObjectPaintProperties* cProperties = document().getElementById("c")->l
ayoutObject()->objectPaintProperties(); |
| 990 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); | 1032 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); |
| 991 } | 1033 } |
| 992 | 1034 |
| 993 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughTransfor
m) | 1035 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughTransfor
m) |
| 994 { | 1036 { |
| 995 setBodyInnerHTML( | 1037 setBodyInnerHTML( |
| 996 "<style>" | 1038 "<style>" |
| 997 " * { margin: 0; }" | 1039 " * { margin: 0; }" |
| 998 " div { position: relative; }" | 1040 " div { position: relative; }" |
| 999 "</style>" | 1041 "</style>" |
| 1000 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" | 1042 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" |
| 1001 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" | 1043 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" |
| 1002 " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: 0.7
px;'></div>" | 1044 " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: 0.7
px;'></div>" |
| 1003 " </div>" | 1045 " </div>" |
| 1004 "</div>" | 1046 "</div>" |
| 1005 ); | 1047 ); |
| 1006 | 1048 |
| 1007 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); | 1049 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
| 1008 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); | 1050 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); |
| 1009 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). | 1051 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). |
| 1010 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()->
parent()->matrix()); | 1052 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()->
parent()->matrix()); |
| 1011 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3
). | 1053 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3
). |
| 1012 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
.7)) - LayoutPoint(1, 1)); | 1054 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
.7)) - LayoutPoint(1, 1)); |
| 1013 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); | 1055 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); |
| 1014 | 1056 |
| 1015 // c should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). | 1057 // c should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). |
| 1016 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); | 1058 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); |
| 1017 const ObjectPaintProperties* cProperties = document().getElementById("c")->l
ayoutObject()->objectPaintProperties(); | 1059 const ObjectPaintProperties* cProperties = document().getElementById("c")->l
ayoutObject()->objectPaintProperties(); |
| 1018 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); | 1060 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); |
| 1019 } | 1061 } |
| 1020 | 1062 |
| 1021 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughMultiple
Transforms) | 1063 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughMultiple
Transforms) |
| 1022 { | 1064 { |
| 1023 setBodyInnerHTML( | 1065 setBodyInnerHTML( |
| 1024 "<style>" | 1066 "<style>" |
| 1025 " * { margin: 0; }" | 1067 " * { margin: 0; }" |
| 1026 " div { position: relative; }" | 1068 " div { position: relative; }" |
| 1027 "</style>" | 1069 "</style>" |
| 1028 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" | 1070 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" |
| 1029 " <div id='b' style='width: 40px; height: 40px; transform: translate3d(
5px, 7px, 0);'>" | 1071 " <div id='b' style='width: 40px; height: 40px; transform: translate3d(
5px, 7px, 0);'>" |
| 1030 " <div id='c' style='width: 40px; height: 40px; transform: translate3
d(11px, 13px, 0);'>" | 1072 " <div id='c' style='width: 40px; height: 40px; transform: translate3
d(11px, 13px, 0);'>" |
| 1031 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: 0
.7px;'></div>" | 1073 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: 0
.7px;'></div>" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1049 EXPECT_EQ(TransformationMatrix().translate(0, 0), cProperties->transform()->
parent()->matrix()); | 1091 EXPECT_EQ(TransformationMatrix().translate(0, 0), cProperties->transform()->
parent()->matrix()); |
| 1050 // The residual subpixel adjustment should still be (-0.3,-0.3). | 1092 // The residual subpixel adjustment should still be (-0.3,-0.3). |
| 1051 EXPECT_EQ(subpixelAccumulation, cProperties->localBorderBoxProperties()->pai
ntOffset); | 1093 EXPECT_EQ(subpixelAccumulation, cProperties->localBorderBoxProperties()->pai
ntOffset); |
| 1052 | 1094 |
| 1053 // d should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). | 1095 // d should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). |
| 1054 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); | 1096 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); |
| 1055 const ObjectPaintProperties* dProperties = document().getElementById("d")->l
ayoutObject()->objectPaintProperties(); | 1097 const ObjectPaintProperties* dProperties = document().getElementById("d")->l
ayoutObject()->objectPaintProperties(); |
| 1056 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); | 1098 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); |
| 1057 } | 1099 } |
| 1058 | 1100 |
| 1059 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) | 1101 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) |
| 1060 { | 1102 { |
| 1061 setBodyInnerHTML( | 1103 setBodyInnerHTML( |
| 1062 "<style>" | 1104 "<style>" |
| 1063 " * { margin: 0; }" | 1105 " * { margin: 0; }" |
| 1064 "</style>" | 1106 "</style>" |
| 1065 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: re
lative;'>" | 1107 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: re
lative;'>" |
| 1066 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
); position: relative;'>" | 1108 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
); position: relative;'>" |
| 1067 " <div id='fixed' style='width: 40px; height: 40px; position: fixed;'
>" | 1109 " <div id='fixed' style='width: 40px; height: 40px; position: fixed;'
>" |
| 1068 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; positi
on: relative;'></div>" | 1110 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; positi
on: relative;'></div>" |
| 1069 " </div>" | 1111 " </div>" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1082 const ObjectPaintProperties* fixedProperties = document().getElementById("fi
xed")->layoutObject()->objectPaintProperties(); | 1124 const ObjectPaintProperties* fixedProperties = document().getElementById("fi
xed")->layoutObject()->objectPaintProperties(); |
| 1083 // The residual subpixel adjustment should still be (-0.3,0). | 1125 // The residual subpixel adjustment should still be (-0.3,0). |
| 1084 EXPECT_EQ(subpixelAccumulation, fixedProperties->localBorderBoxProperties()-
>paintOffset); | 1126 EXPECT_EQ(subpixelAccumulation, fixedProperties->localBorderBoxProperties()-
>paintOffset); |
| 1085 | 1127 |
| 1086 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0). | 1128 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0). |
| 1087 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0)); | 1129 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0)); |
| 1088 const ObjectPaintProperties* dProperties = document().getElementById("d")->l
ayoutObject()->objectPaintProperties(); | 1130 const ObjectPaintProperties* dProperties = document().getElementById("d")->l
ayoutObject()->objectPaintProperties(); |
| 1089 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); | 1131 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); |
| 1090 } | 1132 } |
| 1091 | 1133 |
| 1092 TEST_F(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) | 1134 TEST_P(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) |
| 1093 { | 1135 { |
| 1094 setBodyInnerHTML( | 1136 setBodyInnerHTML( |
| 1095 "<svg id='svg' style='position: relative; left: 0.1px; transform: matrix
(1, 0, 0, 1, 0, 0);'>" | 1137 "<svg id='svg' style='position: relative; left: 0.1px; transform: matrix
(1, 0, 0, 1, 0, 0);'>" |
| 1096 " <rect id='rect' transform='translate(1, 1)'/>" | 1138 " <rect id='rect' transform='translate(1, 1)'/>" |
| 1097 "</svg>"); | 1139 "</svg>"); |
| 1098 | 1140 |
| 1099 LayoutObject& svgWithTransform = *document().getElementById("svg")->layoutOb
ject(); | 1141 LayoutObject& svgWithTransform = *document().getElementById("svg")->layoutOb
ject(); |
| 1100 const ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.o
bjectPaintProperties(); | 1142 const ObjectPaintProperties* svgWithTransformProperties = svgWithTransform.o
bjectPaintProperties(); |
| 1101 EXPECT_EQ(TransformationMatrix(), svgWithTransformProperties->transform()->m
atrix()); | 1143 EXPECT_EQ(TransformationMatrix(), svgWithTransformProperties->transform()->m
atrix()); |
| 1102 EXPECT_EQ(LayoutPoint(FloatPoint(0.1, 0)), svgWithTransformProperties->local
BorderBoxProperties()->paintOffset); | 1144 EXPECT_EQ(LayoutPoint(FloatPoint(0.1, 0)), svgWithTransformProperties->local
BorderBoxProperties()->paintOffset); |
| 1103 EXPECT_EQ(nullptr, svgWithTransformProperties->svgLocalToBorderBoxTransform(
)); | 1145 EXPECT_EQ(nullptr, svgWithTransformProperties->svgLocalToBorderBoxTransform(
)); |
| 1104 | 1146 |
| 1105 LayoutObject& rectWithTransform = *document().getElementById("rect")->layout
Object(); | 1147 LayoutObject& rectWithTransform = *document().getElementById("rect")->layout
Object(); |
| 1106 const ObjectPaintProperties* rectWithTransformProperties = rectWithTransform
.objectPaintProperties(); | 1148 const ObjectPaintProperties* rectWithTransformProperties = rectWithTransform
.objectPaintProperties(); |
| 1107 EXPECT_EQ(TransformationMatrix().translate(1, 1), rectWithTransformPropertie
s->transform()->matrix()); | 1149 EXPECT_EQ(TransformationMatrix().translate(1, 1), rectWithTransformPropertie
s->transform()->matrix()); |
| 1108 | 1150 |
| 1109 // Ensure there is no PaintOffset transform between the rect and the svg's t
ransform. | 1151 // Ensure there is no PaintOffset transform between the rect and the svg's t
ransform. |
| 1110 EXPECT_EQ(svgWithTransformProperties->transform(), rectWithTransformProperti
es->transform()->parent()); | 1152 EXPECT_EQ(svgWithTransformProperties->transform(), rectWithTransformProperti
es->transform()->parent()); |
| 1111 } | 1153 } |
| 1112 | 1154 |
| 1113 TEST_F(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) | 1155 TEST_P(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) |
| 1114 { | 1156 { |
| 1115 setBodyInnerHTML("<div style=\"transform: translateZ(0)\"></div>"); | 1157 setBodyInnerHTML("<div style=\"transform: translateZ(0)\"></div>"); |
| 1116 | 1158 |
| 1117 const ObjectPaintProperties* properties = document().body()->firstChild()->l
ayoutObject()->objectPaintProperties(); | 1159 const ObjectPaintProperties* properties = document().body()->firstChild()->l
ayoutObject()->objectPaintProperties(); |
| 1118 ASSERT_TRUE(properties->transform()); | 1160 ASSERT_TRUE(properties->transform()); |
| 1119 EXPECT_FALSE(properties->transform()->hasRenderingContext()); | 1161 EXPECT_FALSE(properties->transform()->hasRenderingContext()); |
| 1120 } | 1162 } |
| 1121 | 1163 |
| 1122 TEST_F(PaintPropertyTreeBuilderTest, Preserve3DCreatesSharedRenderingContext) | 1164 TEST_P(PaintPropertyTreeBuilderTest, Preserve3DCreatesSharedRenderingContext) |
| 1123 { | 1165 { |
| 1124 setBodyInnerHTML( | 1166 setBodyInnerHTML( |
| 1125 "<div style=\"transform-style: preserve-3d\">" | 1167 "<div style=\"transform-style: preserve-3d\">" |
| 1126 " <div id=\"a\" style=\"transform: translateZ(0)\"></div>" | 1168 " <div id=\"a\" style=\"transform: translateZ(0)\"></div>" |
| 1127 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" | 1169 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" |
| 1128 "</div>"); | 1170 "</div>"); |
| 1129 | 1171 |
| 1130 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); | 1172 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); |
| 1131 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); | 1173 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
| 1132 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); | 1174 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); |
| 1133 EXPECT_NE(aProperties->transform(), bProperties->transform()); | 1175 EXPECT_NE(aProperties->transform(), bProperties->transform()); |
| 1134 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); | 1176 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); |
| 1135 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); | 1177 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); |
| 1136 EXPECT_EQ(aProperties->transform()->renderingContextID(), bProperties->trans
form()->renderingContextID()); | 1178 EXPECT_EQ(aProperties->transform()->renderingContextID(), bProperties->trans
form()->renderingContextID()); |
| 1137 } | 1179 } |
| 1138 | 1180 |
| 1139 TEST_F(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext) | 1181 TEST_P(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext) |
| 1140 { | 1182 { |
| 1141 setBodyInnerHTML( | 1183 setBodyInnerHTML( |
| 1142 "<div style=\"transform-style: preserve-3d\">" | 1184 "<div style=\"transform-style: preserve-3d\">" |
| 1143 " <div id=\"a\" style=\"transform: translateZ(0)\">" | 1185 " <div id=\"a\" style=\"transform: translateZ(0)\">" |
| 1144 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" | 1186 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" |
| 1145 " </div>" | 1187 " </div>" |
| 1146 "</div>"); | 1188 "</div>"); |
| 1147 | 1189 |
| 1148 ASSERT_FALSE(document().getElementById("a")->layoutObject()->styleRef().pres
erves3D()); | 1190 ASSERT_FALSE(document().getElementById("a")->layoutObject()->styleRef().pres
erves3D()); |
| 1149 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); | 1191 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); |
| 1150 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); | 1192 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
| 1151 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); | 1193 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); |
| 1152 | 1194 |
| 1153 // #a should participate in a rendering context (due to its parent), but its | 1195 // #a should participate in a rendering context (due to its parent), but its |
| 1154 // child #b should not. | 1196 // child #b should not. |
| 1155 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); | 1197 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); |
| 1156 EXPECT_FALSE(bProperties->transform()->hasRenderingContext()); | 1198 EXPECT_FALSE(bProperties->transform()->hasRenderingContext()); |
| 1157 } | 1199 } |
| 1158 | 1200 |
| 1159 TEST_F(PaintPropertyTreeBuilderTest, NestedRenderingContexts) | 1201 TEST_P(PaintPropertyTreeBuilderTest, NestedRenderingContexts) |
| 1160 { | 1202 { |
| 1161 setBodyInnerHTML( | 1203 setBodyInnerHTML( |
| 1162 "<div style=\"transform-style: preserve-3d\">" | 1204 "<div style=\"transform-style: preserve-3d\">" |
| 1163 " <div id=\"a\" style=\"transform: translateZ(0)\">" | 1205 " <div id=\"a\" style=\"transform: translateZ(0)\">" |
| 1164 " <div style=\"transform-style: preserve-3d\">" | 1206 " <div style=\"transform-style: preserve-3d\">" |
| 1165 " <div id=\"b\" style=\"transform: translateZ(0)\">" | 1207 " <div id=\"b\" style=\"transform: translateZ(0)\">" |
| 1166 " </div>" | 1208 " </div>" |
| 1167 " </div>" | 1209 " </div>" |
| 1168 "</div>"); | 1210 "</div>"); |
| 1169 | 1211 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1197 static bool someNodeFlattensTransform(const TransformPaintPropertyNode* node, co
nst TransformPaintPropertyNode* ancestor) | 1239 static bool someNodeFlattensTransform(const TransformPaintPropertyNode* node, co
nst TransformPaintPropertyNode* ancestor) |
| 1198 { | 1240 { |
| 1199 while (node != ancestor) { | 1241 while (node != ancestor) { |
| 1200 if (node->flattensInheritedTransform()) | 1242 if (node->flattensInheritedTransform()) |
| 1201 return true; | 1243 return true; |
| 1202 node = node->parent(); | 1244 node = node->parent(); |
| 1203 } | 1245 } |
| 1204 return false; | 1246 return false; |
| 1205 } | 1247 } |
| 1206 | 1248 |
| 1207 TEST_F(PaintPropertyTreeBuilderTest, FlatTransformStylePropagatesToChildren) | 1249 TEST_P(PaintPropertyTreeBuilderTest, FlatTransformStylePropagatesToChildren) |
| 1208 { | 1250 { |
| 1209 setBodyInnerHTML( | 1251 setBodyInnerHTML( |
| 1210 "<div id=\"a\" style=\"transform: translateZ(0); transform-style: flat\"
>" | 1252 "<div id=\"a\" style=\"transform: translateZ(0); transform-style: flat\"
>" |
| 1211 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" | 1253 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" |
| 1212 "</div>"); | 1254 "</div>"); |
| 1213 | 1255 |
| 1214 const auto* aTransform = document().getElementById("a")->layoutObject()->obj
ectPaintProperties()->transform(); | 1256 const auto* aTransform = document().getElementById("a")->layoutObject()->obj
ectPaintProperties()->transform(); |
| 1215 ASSERT_TRUE(aTransform); | 1257 ASSERT_TRUE(aTransform); |
| 1216 const auto* bTransform = document().getElementById("b")->layoutObject()->obj
ectPaintProperties()->transform(); | 1258 const auto* bTransform = document().getElementById("b")->layoutObject()->obj
ectPaintProperties()->transform(); |
| 1217 ASSERT_TRUE(bTransform); | 1259 ASSERT_TRUE(bTransform); |
| 1218 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); | 1260 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); |
| 1219 | 1261 |
| 1220 // Some node must flatten the inherited transform from #a before it reaches | 1262 // Some node must flatten the inherited transform from #a before it reaches |
| 1221 // #b's transform. | 1263 // #b's transform. |
| 1222 EXPECT_TRUE(someNodeFlattensTransform(bTransform, aTransform)); | 1264 EXPECT_TRUE(someNodeFlattensTransform(bTransform, aTransform)); |
| 1223 } | 1265 } |
| 1224 | 1266 |
| 1225 TEST_F(PaintPropertyTreeBuilderTest, Preserve3DTransformStylePropagatesToChildre
n) | 1267 TEST_P(PaintPropertyTreeBuilderTest, Preserve3DTransformStylePropagatesToChildre
n) |
| 1226 { | 1268 { |
| 1227 setBodyInnerHTML( | 1269 setBodyInnerHTML( |
| 1228 "<div id=\"a\" style=\"transform: translateZ(0); transform-style: preser
ve-3d\">" | 1270 "<div id=\"a\" style=\"transform: translateZ(0); transform-style: preser
ve-3d\">" |
| 1229 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" | 1271 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" |
| 1230 "</div>"); | 1272 "</div>"); |
| 1231 | 1273 |
| 1232 const auto* aTransform = document().getElementById("a")->layoutObject()->obj
ectPaintProperties()->transform(); | 1274 const auto* aTransform = document().getElementById("a")->layoutObject()->obj
ectPaintProperties()->transform(); |
| 1233 ASSERT_TRUE(aTransform); | 1275 ASSERT_TRUE(aTransform); |
| 1234 const auto* bTransform = document().getElementById("b")->layoutObject()->obj
ectPaintProperties()->transform(); | 1276 const auto* bTransform = document().getElementById("b")->layoutObject()->obj
ectPaintProperties()->transform(); |
| 1235 ASSERT_TRUE(bTransform); | 1277 ASSERT_TRUE(bTransform); |
| 1236 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); | 1278 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); |
| 1237 | 1279 |
| 1238 // No node may flatten the inherited transform from #a before it reaches | 1280 // No node may flatten the inherited transform from #a before it reaches |
| 1239 // #b's transform. | 1281 // #b's transform. |
| 1240 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aTransform)); | 1282 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aTransform)); |
| 1241 } | 1283 } |
| 1242 | 1284 |
| 1243 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveIsNotFlattened) | 1285 TEST_P(PaintPropertyTreeBuilderTest, PerspectiveIsNotFlattened) |
| 1244 { | 1286 { |
| 1245 // It's necessary to make nodes from the one that applies perspective to | 1287 // It's necessary to make nodes from the one that applies perspective to |
| 1246 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't | 1288 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't |
| 1247 // do anything. | 1289 // do anything. |
| 1248 setBodyInnerHTML( | 1290 setBodyInnerHTML( |
| 1249 "<div id=\"a\" style=\"perspective: 800px\">" | 1291 "<div id=\"a\" style=\"perspective: 800px\">" |
| 1250 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" | 1292 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" |
| 1251 "</div>"); | 1293 "</div>"); |
| 1252 | 1294 |
| 1253 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); | 1295 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); |
| 1254 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); | 1296 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
| 1255 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); | 1297 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); |
| 1256 ASSERT_TRUE(aPerspective); | 1298 ASSERT_TRUE(aPerspective); |
| 1257 const TransformPaintPropertyNode* bTransform = bProperties->transform(); | 1299 const TransformPaintPropertyNode* bTransform = bProperties->transform(); |
| 1258 ASSERT_TRUE(bTransform); | 1300 ASSERT_TRUE(bTransform); |
| 1259 ASSERT_TRUE(nodeHasAncestor(bTransform, aPerspective)); | 1301 ASSERT_TRUE(nodeHasAncestor(bTransform, aPerspective)); |
| 1260 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aPerspective)); | 1302 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aPerspective)); |
| 1261 } | 1303 } |
| 1262 | 1304 |
| 1263 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveDoesNotEstablishRenderingContext
) | 1305 TEST_P(PaintPropertyTreeBuilderTest, PerspectiveDoesNotEstablishRenderingContext
) |
| 1264 { | 1306 { |
| 1265 // It's necessary to make nodes from the one that applies perspective to | 1307 // It's necessary to make nodes from the one that applies perspective to |
| 1266 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't | 1308 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't |
| 1267 // do anything. | 1309 // do anything. |
| 1268 setBodyInnerHTML( | 1310 setBodyInnerHTML( |
| 1269 "<div id=\"a\" style=\"perspective: 800px\">" | 1311 "<div id=\"a\" style=\"perspective: 800px\">" |
| 1270 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" | 1312 " <div id=\"b\" style=\"transform: translateZ(0)\"></div>" |
| 1271 "</div>"); | 1313 "</div>"); |
| 1272 | 1314 |
| 1273 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); | 1315 const ObjectPaintProperties* aProperties = document().getElementById("a")->l
ayoutObject()->objectPaintProperties(); |
| 1274 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); | 1316 const ObjectPaintProperties* bProperties = document().getElementById("b")->l
ayoutObject()->objectPaintProperties(); |
| 1275 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); | 1317 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); |
| 1276 ASSERT_TRUE(aPerspective); | 1318 ASSERT_TRUE(aPerspective); |
| 1277 EXPECT_FALSE(aPerspective->hasRenderingContext()); | 1319 EXPECT_FALSE(aPerspective->hasRenderingContext()); |
| 1278 const TransformPaintPropertyNode* bTransform = bProperties->transform(); | 1320 const TransformPaintPropertyNode* bTransform = bProperties->transform(); |
| 1279 ASSERT_TRUE(bTransform); | 1321 ASSERT_TRUE(bTransform); |
| 1280 EXPECT_FALSE(bTransform->hasRenderingContext()); | 1322 EXPECT_FALSE(bTransform->hasRenderingContext()); |
| 1281 } | 1323 } |
| 1282 | 1324 |
| 1283 TEST_F(PaintPropertyTreeBuilderTest, CachedProperties) | 1325 TEST_P(PaintPropertyTreeBuilderTest, CachedProperties) |
| 1284 { | 1326 { |
| 1285 setBodyInnerHTML( | 1327 setBodyInnerHTML( |
| 1286 "<div id='a' style='transform: translate(33px, 44px)'>" | 1328 "<div id='a' style='transform: translate(33px, 44px)'>" |
| 1287 " <div id='b' style='transform: translate(55px, 66px)'>" | 1329 " <div id='b' style='transform: translate(55px, 66px)'>" |
| 1288 " <div id='c' style='transform: translate(77px, 88px)'>C<div>" | 1330 " <div id='c' style='transform: translate(77px, 88px)'>C<div>" |
| 1289 " </div>" | 1331 " </div>" |
| 1290 "</div>"); | 1332 "</div>"); |
| 1291 | 1333 |
| 1292 Element* a = document().getElementById("a"); | 1334 Element* a = document().getElementById("a"); |
| 1293 const ObjectPaintProperties* aProperties = a->layoutObject()->objectPaintPro
perties(); | 1335 const ObjectPaintProperties* aProperties = a->layoutObject()->objectPaintPro
perties(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 bTransformNode = bProperties->transform(); | 1390 bTransformNode = bProperties->transform(); |
| 1349 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix()); | 1391 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix()); |
| 1350 EXPECT_EQ(aTransformNode, bTransformNode->parent()); | 1392 EXPECT_EQ(aTransformNode, bTransformNode->parent()); |
| 1351 | 1393 |
| 1352 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); | 1394 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); |
| 1353 EXPECT_EQ(cTransformNode, cProperties->transform()); | 1395 EXPECT_EQ(cTransformNode, cProperties->transform()); |
| 1354 EXPECT_EQ(bTransformNode, cTransformNode->parent()); | 1396 EXPECT_EQ(bTransformNode, cTransformNode->parent()); |
| 1355 } | 1397 } |
| 1356 | 1398 |
| 1357 } // namespace blink | 1399 } // namespace blink |
| OLD | NEW |