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