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