| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/LayoutTestHelper.h" | 5 #include "core/layout/LayoutTestHelper.h" |
| 6 #include "core/layout/LayoutTreeAsText.h" | 6 #include "core/layout/LayoutTreeAsText.h" |
| 7 #include "core/layout/api/LayoutViewItem.h" | 7 #include "core/layout/api/LayoutViewItem.h" |
| 8 #include "core/paint/ObjectPaintProperties.h" | 8 #include "core/paint/ObjectPaintProperties.h" |
| 9 #include "platform/graphics/paint/GeometryMapper.h" | 9 #include "platform/graphics/paint/GeometryMapper.h" |
| 10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 { | 45 { |
| 46 RenderingTest::TearDown(); | 46 RenderingTest::TearDown(); |
| 47 | 47 |
| 48 Settings::setMockScrollbarsEnabled(false); | 48 Settings::setMockScrollbarsEnabled(false); |
| 49 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); | 49 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool m_originalSlimmingPaintV2Enabled; | 52 bool m_originalSlimmingPaintV2Enabled; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 #define CHECK_VISUAL_RECT(sourceLayoutObject, ancestorLayoutObject) \ | 55 #define CHECK_VISUAL_RECT(sourceLayoutObject, ancestorLayoutObject, slopFactor)
\ |
| 56 do { \ | 56 do { \ |
| 57 GeometryMapper geometryMapper; \ | 57 GeometryMapper geometryMapper; \ |
| 58 LayoutRect source(sourceLayoutObject->localOverflowRectForPaintInvalidation(
)); \ | 58 LayoutRect source(sourceLayoutObject->localOverflowRectForPaintInvalidation(
)); \ |
| 59 source.moveBy(sourceLayoutObject->objectPaintProperties()->localBorderBoxPro
perties()->paintOffset); \ | 59 source.moveBy(sourceLayoutObject->objectPaintProperties()->localBorderBoxPro
perties()->paintOffset); \ |
| 60 bool success = false; \ | 60 bool success = false; \ |
| 61 FloatRect actual = geometryMapper.mapToVisualRectInDestinationSpace( \ | 61 FloatRect actual = geometryMapper.mapToVisualRectInDestinationSpace( \ |
| 62 FloatRect(source), \ | 62 FloatRect(source), \ |
| 63 sourceLayoutObject->objectPaintProperties()->localBorderBoxProperties()-
>propertyTreeState, \ | 63 sourceLayoutObject->objectPaintProperties()->localBorderBoxProperties()-
>propertyTreeState, \ |
| 64 ancestorLayoutObject->objectPaintProperties()->localBorderBoxProperties(
)->propertyTreeState, success); \ | 64 ancestorLayoutObject->objectPaintProperties()->localBorderBoxProperties(
)->propertyTreeState, success); \ |
| 65 EXPECT_TRUE(success); \ | 65 EXPECT_TRUE(success); \ |
| 66 \ | 66 \ |
| 67 LayoutRect expected = sourceLayoutObject->localOverflowRectForPaintInvalidat
ion(); \ | 67 LayoutRect expected = sourceLayoutObject->localOverflowRectForPaintInvalidat
ion(); \ |
| 68 sourceLayoutObject->mapToVisualRectInAncestorSpace(ancestorLayoutObject, exp
ected); \ | 68 sourceLayoutObject->mapToVisualRectInAncestorSpace(ancestorLayoutObject, exp
ected); \ |
| 69 EXPECT_EQ(expected, LayoutRect(actual)); \ | 69 EXPECT_TRUE(expected.contains(LayoutRect(actual))); \ |
| 70 actual.inflate(slopFactor); \ |
| 71 EXPECT_TRUE(LayoutRect(actual).contains(expected)); \ |
| 70 } while (0); | 72 } while (0); |
| 71 | 73 |
| 74 #define CHECK_EXACT_VISUAL_RECT(sourceLayoutObject, ancestorLayoutObject) CHECK_
VISUAL_RECT(sourceLayoutObject, ancestorLayoutObject, 0) |
| 75 |
| 72 TEST_F(PaintPropertyTreeBuilderTest, FixedPosition) | 76 TEST_F(PaintPropertyTreeBuilderTest, FixedPosition) |
| 73 { | 77 { |
| 74 loadTestData("fixed-position.html"); | 78 loadTestData("fixed-position.html"); |
| 75 | 79 |
| 76 FrameView* frameView = document().view(); | 80 FrameView* frameView = document().view(); |
| 77 | 81 |
| 78 // target1 is a fixed-position element inside an absolute-position scrolling
element. | 82 // target1 is a fixed-position element inside an absolute-position scrolling
element. |
| 79 // It should be attached under the viewport to skip scrolling and offset of
the parent. | 83 // It should be attached under the viewport to skip scrolling and offset of
the parent. |
| 80 Element* target1 = document().getElementById("target1"); | 84 Element* target1 = document().getElementById("target1"); |
| 81 const ObjectPaintProperties* target1Properties = target1->layoutObject()->ob
jectPaintProperties(); | 85 const ObjectPaintProperties* target1Properties = target1->layoutObject()->ob
jectPaintProperties(); |
| 82 EXPECT_EQ(TransformationMatrix().translate(200, 150), target1Properties->pai
ntOffsetTranslation()->matrix()); | 86 EXPECT_EQ(TransformationMatrix().translate(200, 150), target1Properties->pai
ntOffsetTranslation()->matrix()); |
| 83 EXPECT_EQ(frameView->preTranslation(), target1Properties->paintOffsetTransla
tion()->parent()); | 87 EXPECT_EQ(frameView->preTranslation(), target1Properties->paintOffsetTransla
tion()->parent()); |
| 84 EXPECT_EQ(target1Properties->paintOffsetTranslation(), target1Properties->ov
erflowClip()->localTransformSpace()); | 88 EXPECT_EQ(target1Properties->paintOffsetTranslation(), target1Properties->ov
erflowClip()->localTransformSpace()); |
| 85 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target1Properties->overflowClip(
)->clipRect()); | 89 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target1Properties->overflowClip(
)->clipRect()); |
| 86 // Likewise, it inherits clip from the viewport, skipping overflow clip of t
he scroller. | 90 // Likewise, it inherits clip from the viewport, skipping overflow clip of t
he scroller. |
| 87 EXPECT_EQ(frameView->contentClip(), target1Properties->overflowClip()->paren
t()); | 91 EXPECT_EQ(frameView->contentClip(), target1Properties->overflowClip()->paren
t()); |
| 88 CHECK_VISUAL_RECT(target1->layoutObject(), frameView->layoutView()); | 92 CHECK_EXACT_VISUAL_RECT(target1->layoutObject(), frameView->layoutView()); |
| 89 | 93 |
| 90 // target2 is a fixed-position element inside a transformed scrolling elemen
t. | 94 // target2 is a fixed-position element inside a transformed scrolling elemen
t. |
| 91 // It should be attached under the scrolled box of the transformed element. | 95 // It should be attached under the scrolled box of the transformed element. |
| 92 Element* target2 = document().getElementById("target2"); | 96 Element* target2 = document().getElementById("target2"); |
| 93 const ObjectPaintProperties* target2Properties = target2->layoutObject()->ob
jectPaintProperties(); | 97 const ObjectPaintProperties* target2Properties = target2->layoutObject()->ob
jectPaintProperties(); |
| 94 Element* scroller = document().getElementById("scroller"); | 98 Element* scroller = document().getElementById("scroller"); |
| 95 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->
objectPaintProperties(); | 99 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->
objectPaintProperties(); |
| 96 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai
ntOffsetTranslation()->matrix()); | 100 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai
ntOffsetTranslation()->matrix()); |
| 97 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO
ffsetTranslation()->parent()); | 101 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO
ffsetTranslation()->parent()); |
| 98 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov
erflowClip()->localTransformSpace()); | 102 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov
erflowClip()->localTransformSpace()); |
| 99 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip(
)->clipRect()); | 103 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip(
)->clipRect()); |
| 100 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli
p()->parent()); | 104 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli
p()->parent()); |
| 101 CHECK_VISUAL_RECT(target2->layoutObject(), frameView->layoutView()); | 105 CHECK_EXACT_VISUAL_RECT(target2->layoutObject(), frameView->layoutView()); |
| 102 } | 106 } |
| 103 | 107 |
| 104 TEST_F(PaintPropertyTreeBuilderTest, PositionAndScroll) | 108 TEST_F(PaintPropertyTreeBuilderTest, PositionAndScroll) |
| 105 { | 109 { |
| 106 loadTestData("position-and-scroll.html"); | 110 loadTestData("position-and-scroll.html"); |
| 107 | 111 |
| 108 Element* scroller = document().getElementById("scroller"); | 112 Element* scroller = document().getElementById("scroller"); |
| 109 scroller->scrollTo(0, 100); | 113 scroller->scrollTo(0, 100); |
| 110 FrameView* frameView = document().view(); | 114 FrameView* frameView = document().view(); |
| 111 frameView->updateAllLifecyclePhases(); | 115 frameView->updateAllLifecyclePhases(); |
| 112 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->
objectPaintProperties(); | 116 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()->
objectPaintProperties(); |
| 113 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr
ollTranslation()->matrix()); | 117 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr
ollTranslation()->matrix()); |
| 114 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->scrollTranslat
ion()->parent()); | 118 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->scrollTranslat
ion()->parent()); |
| 115 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->overflowClip()
->localTransformSpace()); | 119 EXPECT_EQ(frameView->scrollTranslation(), scrollerProperties->overflowClip()
->localTransformSpace()); |
| 116 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow
Clip()->clipRect()); | 120 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow
Clip()->clipRect()); |
| 117 EXPECT_EQ(frameView->contentClip(), scrollerProperties->overflowClip()->pare
nt()); | 121 EXPECT_EQ(frameView->contentClip(), scrollerProperties->overflowClip()->pare
nt()); |
| 118 CHECK_VISUAL_RECT(scroller->layoutObject(), frameView->layoutView()); | 122 CHECK_EXACT_VISUAL_RECT(scroller->layoutObject(), frameView->layoutView()); |
| 119 | 123 |
| 120 // The relative-positioned element should have accumulated box offset (exclu
de scrolling), | 124 // The relative-positioned element should have accumulated box offset (exclu
de scrolling), |
| 121 // and should be affected by ancestor scroll transforms. | 125 // and should be affected by ancestor scroll transforms. |
| 122 Element* relPos = document().getElementById("rel-pos"); | 126 Element* relPos = document().getElementById("rel-pos"); |
| 123 const ObjectPaintProperties* relPosProperties = relPos->layoutObject()->obje
ctPaintProperties(); | 127 const ObjectPaintProperties* relPosProperties = relPos->layoutObject()->obje
ctPaintProperties(); |
| 124 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai
ntOffsetTranslation()->matrix()); | 128 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai
ntOffsetTranslation()->matrix()); |
| 125 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf
fsetTranslation()->parent()); | 129 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf
fsetTranslation()->parent()); |
| 126 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l
ocalTransformSpace()); | 130 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l
ocalTransformSpace()); |
| 127 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 200), relPosProperties->overflowClip()
->clipRect()); | 131 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 200), relPosProperties->overflowClip()
->clipRect()); |
| 128 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip
()->parent()); | 132 EXPECT_EQ(scrollerProperties->overflowClip(), relPosProperties->overflowClip
()->parent()); |
| 129 CHECK_VISUAL_RECT(relPos->layoutObject(), frameView->layoutView()); | 133 CHECK_EXACT_VISUAL_RECT(relPos->layoutObject(), frameView->layoutView()); |
| 130 | 134 |
| 131 // The absolute-positioned element should not be affected by non-positioned
scroller at all. | 135 // The absolute-positioned element should not be affected by non-positioned
scroller at all. |
| 132 Element* absPos = document().getElementById("abs-pos"); | 136 Element* absPos = document().getElementById("abs-pos"); |
| 133 const ObjectPaintProperties* absPosProperties = absPos->layoutObject()->obje
ctPaintProperties(); | 137 const ObjectPaintProperties* absPosProperties = absPos->layoutObject()->obje
ctPaintProperties(); |
| 134 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain
tOffsetTranslation()->matrix()); | 138 EXPECT_EQ(TransformationMatrix().translate(123, 456), absPosProperties->pain
tOffsetTranslation()->matrix()); |
| 135 EXPECT_EQ(frameView->scrollTranslation(), absPosProperties->paintOffsetTrans
lation()->parent()); | 139 EXPECT_EQ(frameView->scrollTranslation(), absPosProperties->paintOffsetTrans
lation()->parent()); |
| 136 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l
ocalTransformSpace()); | 140 EXPECT_EQ(absPosProperties->transform(), absPosProperties->overflowClip()->l
ocalTransformSpace()); |
| 137 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400), absPosProperties->overflowClip()
->clipRect()); | 141 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400), absPosProperties->overflowClip()
->clipRect()); |
| 138 EXPECT_EQ(frameView->contentClip(), absPosProperties->overflowClip()->parent
()); | 142 EXPECT_EQ(frameView->contentClip(), absPosProperties->overflowClip()->parent
()); |
| 139 CHECK_VISUAL_RECT(absPos->layoutObject(), frameView->layoutView()); | 143 CHECK_EXACT_VISUAL_RECT(absPos->layoutObject(), frameView->layoutView()); |
| 140 } | 144 } |
| 141 | 145 |
| 142 TEST_F(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) | 146 TEST_F(PaintPropertyTreeBuilderTest, FrameScrollingTraditional) |
| 143 { | 147 { |
| 144 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); | 148 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); |
| 145 | 149 |
| 146 document().domWindow()->scrollTo(0, 100); | 150 document().domWindow()->scrollTo(0, 100); |
| 147 | 151 |
| 148 FrameView* frameView = document().view(); | 152 FrameView* frameView = document().view(); |
| 149 frameView->updateAllLifecyclePhases(); | 153 frameView->updateAllLifecyclePhases(); |
| 150 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); | 154 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); |
| 151 EXPECT_EQ(frameView->rootTransform(), frameView->preTranslation()->parent())
; | 155 EXPECT_EQ(frameView->rootTransform(), frameView->preTranslation()->parent())
; |
| 152 EXPECT_EQ(nullptr, frameView->rootTransform()->parent()); | 156 EXPECT_EQ(nullptr, frameView->rootTransform()->parent()); |
| 153 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl
ation()->matrix()); | 157 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl
ation()->matrix()); |
| 154 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren
t()); | 158 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren
t()); |
| 155 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf
ormSpace()); | 159 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf
ormSpace()); |
| 156 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe
ct()); | 160 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe
ct()); |
| 157 EXPECT_EQ(frameView->rootClip(), frameView->contentClip()->parent()); | 161 EXPECT_EQ(frameView->rootClip(), frameView->contentClip()->parent()); |
| 158 EXPECT_EQ(nullptr, frameView->rootClip()->parent()); | 162 EXPECT_EQ(nullptr, frameView->rootClip()->parent()); |
| 159 | 163 |
| 160 LayoutViewItem layoutViewItem = document().layoutViewItem(); | 164 LayoutViewItem layoutViewItem = document().layoutViewItem(); |
| 161 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai
ntProperties(); | 165 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai
ntProperties(); |
| 162 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation()); | 166 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation()); |
| 163 CHECK_VISUAL_RECT(document().body()->layoutObject(), frameView->layoutView()
); | 167 CHECK_EXACT_VISUAL_RECT(document().body()->layoutObject(), frameView->layout
View()); |
| 164 } | 168 } |
| 165 | 169 |
| 166 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame
being created. | 170 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame
being created. |
| 167 // Need to set it during test setup. Besides that, the test still won't work bec
ause | 171 // Need to set it during test setup. Besides that, the test still won't work bec
ause |
| 168 // root layer scrolling mode is not compatible with SPv2 at this moment. | 172 // root layer scrolling mode is not compatible with SPv2 at this moment. |
| 169 // (Duplicate display item ID for FrameView and LayoutView.) | 173 // (Duplicate display item ID for FrameView and LayoutView.) |
| 170 TEST_F(PaintPropertyTreeBuilderTest, DISABLED_FrameScrollingRootLayerScrolls) | 174 TEST_F(PaintPropertyTreeBuilderTest, DISABLED_FrameScrollingRootLayerScrolls) |
| 171 { | 175 { |
| 172 document().settings()->setRootLayerScrolls(true); | 176 document().settings()->setRootLayerScrolls(true); |
| 173 | 177 |
| 174 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); | 178 setBodyInnerHTML("<style> body { height: 10000px; } </style>"); |
| 175 | 179 |
| 176 document().domWindow()->scrollTo(0, 100); | 180 document().domWindow()->scrollTo(0, 100); |
| 177 | 181 |
| 178 FrameView* frameView = document().view(); | 182 FrameView* frameView = document().view(); |
| 179 frameView->updateAllLifecyclePhases(); | 183 frameView->updateAllLifecyclePhases(); |
| 180 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); | 184 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); |
| 181 EXPECT_EQ(nullptr, frameView->preTranslation()->parent()); | 185 EXPECT_EQ(nullptr, frameView->preTranslation()->parent()); |
| 182 EXPECT_EQ(TransformationMatrix(), frameView->scrollTranslation()->matrix()); | 186 EXPECT_EQ(TransformationMatrix(), frameView->scrollTranslation()->matrix()); |
| 183 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren
t()); | 187 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren
t()); |
| 184 | 188 |
| 185 LayoutViewItem layoutViewItem = document().layoutViewItem(); | 189 LayoutViewItem layoutViewItem = document().layoutViewItem(); |
| 186 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai
ntProperties(); | 190 const ObjectPaintProperties* layoutViewProperties = layoutViewItem.objectPai
ntProperties(); |
| 187 EXPECT_EQ(TransformationMatrix().translate(0, -100), layoutViewProperties->s
crollTranslation()->matrix()); | 191 EXPECT_EQ(TransformationMatrix().translate(0, -100), layoutViewProperties->s
crollTranslation()->matrix()); |
| 188 EXPECT_EQ(frameView->scrollTranslation(), layoutViewProperties->scrollTransl
ation()->parent()); | 192 EXPECT_EQ(frameView->scrollTranslation(), layoutViewProperties->scrollTransl
ation()->parent()); |
| 189 CHECK_VISUAL_RECT(document().body()->layoutObject(), frameView->layoutView()
); | 193 CHECK_EXACT_VISUAL_RECT(document().body()->layoutObject(), frameView->layout
View()); |
| 190 } | 194 } |
| 191 | 195 |
| 192 TEST_F(PaintPropertyTreeBuilderTest, Perspective) | 196 TEST_F(PaintPropertyTreeBuilderTest, Perspective) |
| 193 { | 197 { |
| 194 loadTestData("perspective.html"); | 198 loadTestData("perspective.html"); |
| 195 | 199 |
| 196 Element* perspective = document().getElementById("perspective"); | 200 Element* perspective = document().getElementById("perspective"); |
| 197 const ObjectPaintProperties* perspectiveProperties = perspective->layoutObje
ct()->objectPaintProperties(); | 201 const ObjectPaintProperties* perspectiveProperties = perspective->layoutObje
ct()->objectPaintProperties(); |
| 198 EXPECT_EQ(TransformationMatrix().applyPerspective(100), perspectivePropertie
s->perspective()->matrix()); | 202 EXPECT_EQ(TransformationMatrix().applyPerspective(100), perspectivePropertie
s->perspective()->matrix()); |
| 199 // The perspective origin is the center of the border box plus accumulated p
aint offset. | 203 // The perspective origin is the center of the border box plus accumulated p
aint offset. |
| 200 EXPECT_EQ(FloatPoint3D(250, 250, 0), perspectiveProperties->perspective()->o
rigin()); | 204 EXPECT_EQ(FloatPoint3D(250, 250, 0), perspectiveProperties->perspective()->o
rigin()); |
| 201 EXPECT_EQ(document().view()->scrollTranslation(), perspectiveProperties->per
spective()->parent()); | 205 EXPECT_EQ(document().view()->scrollTranslation(), perspectiveProperties->per
spective()->parent()); |
| 202 | 206 |
| 203 // Adding perspective doesn't clear paint offset. The paint offset will be p
assed down to children. | 207 // Adding perspective doesn't clear paint offset. The paint offset will be p
assed down to children. |
| 204 Element* inner = document().getElementById("inner"); | 208 Element* inner = document().getElementById("inner"); |
| 205 const ObjectPaintProperties* innerProperties = inner->layoutObject()->object
PaintProperties(); | 209 const ObjectPaintProperties* innerProperties = inner->layoutObject()->object
PaintProperties(); |
| 206 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO
ffsetTranslation()->matrix()); | 210 EXPECT_EQ(TransformationMatrix().translate(50, 100), innerProperties->paintO
ffsetTranslation()->matrix()); |
| 207 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset
Translation()->parent()); | 211 EXPECT_EQ(perspectiveProperties->perspective(), innerProperties->paintOffset
Translation()->parent()); |
| 208 CHECK_VISUAL_RECT(inner->layoutObject(), document().view()->layoutView()); | 212 CHECK_EXACT_VISUAL_RECT(inner->layoutObject(), document().view()->layoutView
()); |
| 209 } | 213 } |
| 210 | 214 |
| 211 TEST_F(PaintPropertyTreeBuilderTest, Transform) | 215 TEST_F(PaintPropertyTreeBuilderTest, Transform) |
| 212 { | 216 { |
| 213 loadTestData("transform.html"); | 217 loadTestData("transform.html"); |
| 214 | 218 |
| 215 Element* transform = document().getElementById("transform"); | 219 Element* transform = document().getElementById("transform"); |
| 216 const ObjectPaintProperties* transformProperties = transform->layoutObject()
->objectPaintProperties(); | 220 const ObjectPaintProperties* transformProperties = transform->layoutObject()
->objectPaintProperties(); |
| 217 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper
ties->transform()->matrix()); | 221 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), transformProper
ties->transform()->matrix()); |
| 218 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi
n()); | 222 EXPECT_EQ(FloatPoint3D(200, 150, 0), transformProperties->transform()->origi
n()); |
| 219 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties
->transform()->parent()); | 223 EXPECT_EQ(transformProperties->paintOffsetTranslation(), transformProperties
->transform()->parent()); |
| 220 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa
intOffsetTranslation()->matrix()); | 224 EXPECT_EQ(TransformationMatrix().translate(50, 100), transformProperties->pa
intOffsetTranslation()->matrix()); |
| 221 EXPECT_EQ(document().view()->scrollTranslation(), transformProperties->paint
OffsetTranslation()->parent()); | 225 EXPECT_EQ(document().view()->scrollTranslation(), transformProperties->paint
OffsetTranslation()->parent()); |
| 222 CHECK_VISUAL_RECT(transform->layoutObject(), document().view()->layoutView()
); | 226 CHECK_EXACT_VISUAL_RECT(transform->layoutObject(), document().view()->layout
View()); |
| 223 } | 227 } |
| 224 | 228 |
| 225 TEST_F(PaintPropertyTreeBuilderTest, RelativePositionInline) | 229 TEST_F(PaintPropertyTreeBuilderTest, RelativePositionInline) |
| 226 { | 230 { |
| 227 loadTestData("relative-position-inline.html"); | 231 loadTestData("relative-position-inline.html"); |
| 228 | 232 |
| 229 Element* inlineBlock = document().getElementById("inline-block"); | 233 Element* inlineBlock = document().getElementById("inline-block"); |
| 230 const ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObje
ct()->objectPaintProperties(); | 234 const ObjectPaintProperties* inlineBlockProperties = inlineBlock->layoutObje
ct()->objectPaintProperties(); |
| 231 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties-
>paintOffsetTranslation()->matrix()); | 235 EXPECT_EQ(TransformationMatrix().translate(135, 490), inlineBlockProperties-
>paintOffsetTranslation()->matrix()); |
| 232 EXPECT_EQ(document().view()->scrollTranslation(), inlineBlockProperties->pai
ntOffsetTranslation()->parent()); | 236 EXPECT_EQ(document().view()->scrollTranslation(), inlineBlockProperties->pai
ntOffsetTranslation()->parent()); |
| 233 CHECK_VISUAL_RECT(inlineBlock->layoutObject(), document().view()->layoutView
()); | 237 CHECK_EXACT_VISUAL_RECT(inlineBlock->layoutObject(), document().view()->layo
utView()); |
| 234 } | 238 } |
| 235 | 239 |
| 236 TEST_F(PaintPropertyTreeBuilderTest, NestedOpacityEffect) | 240 TEST_F(PaintPropertyTreeBuilderTest, NestedOpacityEffect) |
| 237 { | 241 { |
| 238 setBodyInnerHTML( | 242 setBodyInnerHTML( |
| 239 "<div id='nodeWithoutOpacity' style='width: 100px; height: 200px'>" | 243 "<div id='nodeWithoutOpacity' style='width: 100px; height: 200px'>" |
| 240 " <div id='childWithOpacity' style='opacity: 0.5; width: 50px; height:
60px;'>" | 244 " <div id='childWithOpacity' style='opacity: 0.5; width: 50px; height:
60px;'>" |
| 241 " <div id='grandChildWithoutOpacity' style='width: 20px; height: 30px
'>" | 245 " <div id='grandChildWithoutOpacity' style='width: 20px; height: 30px
'>" |
| 242 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2; width:
10px; height: 15px'/>" | 246 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2; width:
10px; height: 15px'/>" |
| 243 " </div>" | 247 " </div>" |
| 244 " </div>" | 248 " </div>" |
| 245 "</div>"); | 249 "</div>"); |
| 246 | 250 |
| 247 LayoutObject* nodeWithoutOpacity = document().getElementById("nodeWithoutOpa
city")->layoutObject(); | 251 LayoutObject* nodeWithoutOpacity = document().getElementById("nodeWithoutOpa
city")->layoutObject(); |
| 248 const ObjectPaintProperties* nodeWithoutOpacityProperties = nodeWithoutOpaci
ty->objectPaintProperties(); | 252 const ObjectPaintProperties* nodeWithoutOpacityProperties = nodeWithoutOpaci
ty->objectPaintProperties(); |
| 249 EXPECT_NE(nullptr, nodeWithoutOpacityProperties); | 253 EXPECT_NE(nullptr, nodeWithoutOpacityProperties); |
| 250 CHECK_VISUAL_RECT(nodeWithoutOpacity, document().view()->layoutView()); | 254 CHECK_EXACT_VISUAL_RECT(nodeWithoutOpacity, document().view()->layoutView())
; |
| 251 | 255 |
| 252 LayoutObject* childWithOpacity = document().getElementById("childWithOpacity
")->layoutObject(); | 256 LayoutObject* childWithOpacity = document().getElementById("childWithOpacity
")->layoutObject(); |
| 253 const ObjectPaintProperties* childWithOpacityProperties = childWithOpacity->
objectPaintProperties(); | 257 const ObjectPaintProperties* childWithOpacityProperties = childWithOpacity->
objectPaintProperties(); |
| 254 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity()); | 258 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity()); |
| 255 // childWithOpacity is the root effect node. | 259 // childWithOpacity is the root effect node. |
| 256 EXPECT_NE(nullptr, childWithOpacityProperties->effect()->parent()); | 260 EXPECT_NE(nullptr, childWithOpacityProperties->effect()->parent()); |
| 257 CHECK_VISUAL_RECT(childWithOpacity, document().view()->layoutView()); | 261 CHECK_EXACT_VISUAL_RECT(childWithOpacity, document().view()->layoutView()); |
| 258 | 262 |
| 259 LayoutObject* grandChildWithoutOpacity = document().getElementById("grandChi
ldWithoutOpacity")->layoutObject(); | 263 LayoutObject* grandChildWithoutOpacity = document().getElementById("grandChi
ldWithoutOpacity")->layoutObject(); |
| 260 EXPECT_NE(nullptr, grandChildWithoutOpacity->objectPaintProperties()); | 264 EXPECT_NE(nullptr, grandChildWithoutOpacity->objectPaintProperties()); |
| 261 CHECK_VISUAL_RECT(grandChildWithoutOpacity, document().view()->layoutView())
; | 265 CHECK_EXACT_VISUAL_RECT(grandChildWithoutOpacity, document().view()->layoutV
iew()); |
| 262 | 266 |
| 263 LayoutObject* greatGrandChildWithOpacity = document().getElementById("greatG
randChildWithOpacity")->layoutObject(); | 267 LayoutObject* greatGrandChildWithOpacity = document().getElementById("greatG
randChildWithOpacity")->layoutObject(); |
| 264 const ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGra
ndChildWithOpacity->objectPaintProperties(); | 268 const ObjectPaintProperties* greatGrandChildWithOpacityProperties = greatGra
ndChildWithOpacity->objectPaintProperties(); |
| 265 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); | 269 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); |
| 266 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr
operties->effect()->parent()); | 270 EXPECT_EQ(childWithOpacityProperties->effect(), greatGrandChildWithOpacityPr
operties->effect()->parent()); |
| 267 CHECK_VISUAL_RECT(greatGrandChildWithOpacity, document().view()->layoutView(
)); | 271 CHECK_EXACT_VISUAL_RECT(greatGrandChildWithOpacity, document().view()->layou
tView()); |
| 268 } | 272 } |
| 269 | 273 |
| 270 TEST_F(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) | 274 TEST_F(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) |
| 271 { | 275 { |
| 272 setBodyInnerHTML( | 276 setBodyInnerHTML( |
| 273 "<div id='nodeWithOpacity' style='opacity: 0.6' style='width: 100px; hei
ght: 200px'>" | 277 "<div id='nodeWithOpacity' style='opacity: 0.6' style='width: 100px; hei
ght: 200px'>" |
| 274 " <div id='childWithTransform' style='transform: translate3d(10px, 10px
, 0px); width: 50px; height: 60px;'>" | 278 " <div id='childWithTransform' style='transform: translate3d(10px, 10px
, 0px); width: 50px; height: 60px;'>" |
| 275 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; h
eight: 30px'/>" | 279 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; h
eight: 30px'/>" |
| 276 " </div>" | 280 " </div>" |
| 277 "</div>"); | 281 "</div>"); |
| 278 | 282 |
| 279 LayoutObject* nodeWithOpacity = document().getElementById("nodeWithOpacity")
->layoutObject(); | 283 LayoutObject* nodeWithOpacity = document().getElementById("nodeWithOpacity")
->layoutObject(); |
| 280 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity->ob
jectPaintProperties(); | 284 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity->ob
jectPaintProperties(); |
| 281 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); | 285 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); |
| 282 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); | 286 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); |
| 283 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); | 287 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); |
| 284 CHECK_VISUAL_RECT(nodeWithOpacity, document().view()->layoutView()); | 288 CHECK_EXACT_VISUAL_RECT(nodeWithOpacity, document().view()->layoutView()); |
| 285 | 289 |
| 286 LayoutObject* childWithTransform = document().getElementById("childWithTrans
form")->layoutObject(); | 290 LayoutObject* childWithTransform = document().getElementById("childWithTrans
form")->layoutObject(); |
| 287 const ObjectPaintProperties* childWithTransformProperties = childWithTransfo
rm->objectPaintProperties(); | 291 const ObjectPaintProperties* childWithTransformProperties = childWithTransfo
rm->objectPaintProperties(); |
| 288 EXPECT_EQ(nullptr, childWithTransformProperties->effect()); | 292 EXPECT_EQ(nullptr, childWithTransformProperties->effect()); |
| 289 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper
ties->transform()->matrix()); | 293 EXPECT_EQ(TransformationMatrix().translate(10, 10), childWithTransformProper
ties->transform()->matrix()); |
| 290 CHECK_VISUAL_RECT(childWithTransform, document().view()->layoutView()); | 294 CHECK_EXACT_VISUAL_RECT(childWithTransform, document().view()->layoutView())
; |
| 291 | 295 |
| 292 LayoutObject* grandChildWithOpacity = document().getElementById("grandChildW
ithOpacity")->layoutObject(); | 296 LayoutObject* grandChildWithOpacity = document().getElementById("grandChildW
ithOpacity")->layoutObject(); |
| 293 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit
hOpacity->objectPaintProperties(); | 297 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit
hOpacity->objectPaintProperties(); |
| 294 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); | 298 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); |
| 295 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); | 299 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); |
| 296 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); | 300 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); |
| 297 CHECK_VISUAL_RECT(grandChildWithOpacity, document().view()->layoutView()); | 301 CHECK_EXACT_VISUAL_RECT(grandChildWithOpacity, document().view()->layoutView
()); |
| 298 } | 302 } |
| 299 | 303 |
| 300 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) | 304 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) |
| 301 { | 305 { |
| 302 setBodyInnerHTML( | 306 setBodyInnerHTML( |
| 303 "<div id='nodeWithOpacity' style='opacity: 0.6; width: 100px; height: 20
0px'>" | 307 "<div id='nodeWithOpacity' style='opacity: 0.6; width: 100px; height: 20
0px'>" |
| 304 " <div id='childWithStackingContext' style='position:absolute; width: 5
0px; height: 60px;'>" | 308 " <div id='childWithStackingContext' style='position:absolute; width: 5
0px; height: 60px;'>" |
| 305 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; h
eight: 30px'/>" | 309 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; h
eight: 30px'/>" |
| 306 " </div>" | 310 " </div>" |
| 307 "</div>"); | 311 "</div>"); |
| 308 | 312 |
| 309 LayoutObject* nodeWithOpacity = document().getElementById("nodeWithOpacity")
->layoutObject(); | 313 LayoutObject* nodeWithOpacity = document().getElementById("nodeWithOpacity")
->layoutObject(); |
| 310 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity->ob
jectPaintProperties(); | 314 const ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity->ob
jectPaintProperties(); |
| 311 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); | 315 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); |
| 312 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); | 316 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); |
| 313 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); | 317 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); |
| 314 CHECK_VISUAL_RECT(nodeWithOpacity, document().view()->layoutView()); | 318 CHECK_EXACT_VISUAL_RECT(nodeWithOpacity, document().view()->layoutView()); |
| 315 | 319 |
| 316 LayoutObject* childWithStackingContext = document().getElementById("childWit
hStackingContext")->layoutObject(); | 320 LayoutObject* childWithStackingContext = document().getElementById("childWit
hStackingContext")->layoutObject(); |
| 317 const ObjectPaintProperties* childWithStackingContextProperties = childWithS
tackingContext->objectPaintProperties(); | 321 const ObjectPaintProperties* childWithStackingContextProperties = childWithS
tackingContext->objectPaintProperties(); |
| 318 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect()); | 322 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect()); |
| 319 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); | 323 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); |
| 320 CHECK_VISUAL_RECT(childWithStackingContext, document().view()->layoutView())
; | 324 CHECK_EXACT_VISUAL_RECT(childWithStackingContext, document().view()->layoutV
iew()); |
| 321 | 325 |
| 322 LayoutObject* grandChildWithOpacity = document().getElementById("grandChildW
ithOpacity")->layoutObject(); | 326 LayoutObject* grandChildWithOpacity = document().getElementById("grandChildW
ithOpacity")->layoutObject(); |
| 323 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit
hOpacity->objectPaintProperties(); | 327 const ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWit
hOpacity->objectPaintProperties(); |
| 324 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); | 328 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); |
| 325 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); | 329 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti
es->effect()->parent()); |
| 326 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); | 330 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); |
| 327 CHECK_VISUAL_RECT(grandChildWithOpacity, document().view()->layoutView()); | 331 CHECK_EXACT_VISUAL_RECT(grandChildWithOpacity, document().view()->layoutView
()); |
| 328 } | 332 } |
| 329 | 333 |
| 330 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesInSVG) | 334 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesInSVG) |
| 331 { | 335 { |
| 332 setBodyInnerHTML( | 336 setBodyInnerHTML( |
| 333 "<svg id='svgRoot'>" | 337 "<svg id='svgRoot'>" |
| 334 " <g id='groupWithOpacity' opacity='0.6'>" | 338 " <g id='groupWithOpacity' opacity='0.6'>" |
| 335 " <rect id='rectWithoutOpacity' />" | 339 " <rect id='rectWithoutOpacity' />" |
| 336 " <rect id='rectWithOpacity' opacity='0.4' />" | 340 " <rect id='rectWithOpacity' opacity='0.4' />" |
| 337 " <text id='textWithOpacity' opacity='0.2'>" | 341 " <text id='textWithOpacity' opacity='0.2'>" |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 " }" | 631 " }" |
| 628 "</style>" | 632 "</style>" |
| 629 "<input id='button' type='button' style='width:345px; height:123px' valu
e='some text'/>"); | 633 "<input id='button' type='button' style='width:345px; height:123px' valu
e='some text'/>"); |
| 630 | 634 |
| 631 FrameView* frameView = document().view(); | 635 FrameView* frameView = document().view(); |
| 632 LayoutObject* button = document().getElementById("button")->layoutObject(); | 636 LayoutObject* button = document().getElementById("button")->layoutObject(); |
| 633 const ObjectPaintProperties* buttonProperties = button->objectPaintPropertie
s(); | 637 const ObjectPaintProperties* buttonProperties = button->objectPaintPropertie
s(); |
| 634 EXPECT_EQ(frameView->scrollTranslation(), buttonProperties->overflowClip()->
localTransformSpace()); | 638 EXPECT_EQ(frameView->scrollTranslation(), buttonProperties->overflowClip()->
localTransformSpace()); |
| 635 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip()
->clipRect()); | 639 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), buttonProperties->overflowClip()
->clipRect()); |
| 636 EXPECT_EQ(frameView->contentClip(), buttonProperties->overflowClip()->parent
()); | 640 EXPECT_EQ(frameView->contentClip(), buttonProperties->overflowClip()->parent
()); |
| 637 CHECK_VISUAL_RECT(button, frameView->layoutView()); | 641 CHECK_EXACT_VISUAL_RECT(button, frameView->layoutView()); |
| 638 } | 642 } |
| 639 | 643 |
| 640 TEST_F(PaintPropertyTreeBuilderTest, BorderRadiusClip) | 644 TEST_F(PaintPropertyTreeBuilderTest, BorderRadiusClip) |
| 641 { | 645 { |
| 642 setBodyInnerHTML( | 646 setBodyInnerHTML( |
| 643 "<style>" | 647 "<style>" |
| 644 " body {" | 648 " body {" |
| 645 " margin: 0px;" | 649 " margin: 0px;" |
| 646 " }" | 650 " }" |
| 647 " #div {" | 651 " #div {" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 673 // may transition from one value to the other. i.e. being an ellipse. | 677 // may transition from one value to the other. i.e. being an ellipse. |
| 674 EXPECT_EQ( | 678 EXPECT_EQ( |
| 675 FloatRoundedRect( | 679 FloatRoundedRect( |
| 676 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs
et(110, 100) | 680 FloatRect(60, 45, 500, 400), // = border box(610, 500) - border outs
et(110, 100) |
| 677 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0,
0)) | 681 FloatSize(0, 0), // (top left) = max((12, 12) - (60, 45), (0,
0)) |
| 678 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0,
0)) | 682 FloatSize(0, 0), // (top right) = max((34, 34) - (50, 45), (0,
0)) |
| 679 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0,
0)) | 683 FloatSize(18, 23), // (bottom left) = max((78, 78) - (60, 55), (0,
0)) |
| 680 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0,
0)) | 684 FloatSize(6, 1)), // (bottom right) = max((56, 56) - (50, 55), (0,
0)) |
| 681 borderRadiusClip->clipRect()); | 685 borderRadiusClip->clipRect()); |
| 682 EXPECT_EQ(frameView->contentClip(), borderRadiusClip->parent()); | 686 EXPECT_EQ(frameView->contentClip(), borderRadiusClip->parent()); |
| 683 CHECK_VISUAL_RECT(div, frameView->layoutView()); | 687 CHECK_EXACT_VISUAL_RECT(div, frameView->layoutView()); |
| 684 } | 688 } |
| 685 | 689 |
| 686 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes) | 690 TEST_F(PaintPropertyTreeBuilderTest, TransformNodesAcrossSubframes) |
| 687 { | 691 { |
| 688 setBodyInnerHTML( | 692 setBodyInnerHTML( |
| 689 "<style>body { margin: 0; }</style>" | 693 "<style>body { margin: 0; }</style>" |
| 690 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" | 694 "<div id='divWithTransform' style='transform: translate3d(1px, 2px, 3px)
;'>" |
| 691 " <iframe id='frame'></iframe>" | 695 " <iframe id='frame'></iframe>" |
| 692 "</div>"); | 696 "</div>"); |
| 693 Document& frameDocument = setupChildIframe("frame", | 697 Document& frameDocument = setupChildIframe("frame", |
| 694 "<style>body { margin: 0; }</style><div id='transform' style='transform:
translate3d(4px, 5px, 6px); width: 100px; height: 200px'></div>"); | 698 "<style>body { margin: 0; }</style><div id='transform' style='transform:
translate3d(4px, 5px, 6px); width: 100px; height: 200px'></div>"); |
| 695 FrameView* frameView = document().view(); | 699 FrameView* frameView = document().view(); |
| 696 frameView->updateAllLifecyclePhases(); | 700 frameView->updateAllLifecyclePhases(); |
| 697 | 701 |
| 698 LayoutObject* divWithTransform = document().getElementById("divWithTransform
")->layoutObject(); | 702 LayoutObject* divWithTransform = document().getElementById("divWithTransform
")->layoutObject(); |
| 699 const ObjectPaintProperties* divWithTransformProperties = divWithTransform->
objectPaintProperties(); | 703 const ObjectPaintProperties* divWithTransformProperties = divWithTransform->
objectPaintProperties(); |
| 700 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope
rties->transform()->matrix()); | 704 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope
rties->transform()->matrix()); |
| 701 CHECK_VISUAL_RECT(divWithTransform, frameView->layoutView()); | 705 CHECK_EXACT_VISUAL_RECT(divWithTransform, frameView->layoutView()); |
| 702 | 706 |
| 703 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); | 707 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); |
| 704 const ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithT
ransform->objectPaintProperties(); | 708 const ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithT
ransform->objectPaintProperties(); |
| 705 auto* innerDivTransform = innerDivWithTransformProperties->transform(); | 709 auto* innerDivTransform = innerDivWithTransformProperties->transform(); |
| 706 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivTransform->ma
trix()); | 710 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivTransform->ma
trix()); |
| 707 CHECK_VISUAL_RECT(innerDivWithTransform, frameView->layoutView()); | 711 CHECK_EXACT_VISUAL_RECT(innerDivWithTransform, frameView->layoutView()); |
| 708 | 712 |
| 709 // Ensure that the inner div's transform is correctly rooted in the root fra
me's transform tree. | 713 // Ensure that the inner div's transform is correctly rooted in the root fra
me's transform tree. |
| 710 // This asserts that we have the following tree structure: | 714 // This asserts that we have the following tree structure: |
| 711 // ... | 715 // ... |
| 712 // Transform transform=translation=1.000000,2.000000,3.000000 | 716 // Transform transform=translation=1.000000,2.000000,3.000000 |
| 713 // PreTranslation transform=translation=2.000000,2.000000,0.000000 | 717 // PreTranslation transform=translation=2.000000,2.000000,0.000000 |
| 714 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000 | 718 // ScrollTranslation transform=translation=0.000000,0.000000,0.000000 |
| 715 // Transform transform=translation=4.000000,5.000000,6.000000 | 719 // Transform transform=translation=4.000000,5.000000,6.000000 |
| 716 auto* innerDocumentScrollTranslation = innerDivTransform->parent(); | 720 auto* innerDocumentScrollTranslation = innerDivTransform->parent(); |
| 717 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr
anslation->matrix()); | 721 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr
anslation->matrix()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 738 // PaintOffsetTranslation transform=translation=7.000000,7.000000,0.0000
00 | 742 // PaintOffsetTranslation transform=translation=7.000000,7.000000,0.0000
00 |
| 739 // Transform transform=translation=4.000000,5.000000,6.000000 | 743 // Transform transform=translation=4.000000,5.000000,6.000000 |
| 740 // PreTranslation transform=translation=42.000000,42.000000,0.000000 | 744 // PreTranslation transform=translation=42.000000,42.000000,0.000000 |
| 741 // ScrollTranslation transform=translation=0.000000,0.000000,0.000
000 | 745 // ScrollTranslation transform=translation=0.000000,0.000000,0.000
000 |
| 742 // PaintOffsetTranslation transform=translation=31.000000,31.000
000,0.000000 | 746 // PaintOffsetTranslation transform=translation=31.000000,31.000
000,0.000000 |
| 743 // Transform transform=translation=7.000000,8.000000,9.000000 | 747 // Transform transform=translation=7.000000,8.000000,9.000000 |
| 744 | 748 |
| 745 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); | 749 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor
m")->layoutObject(); |
| 746 auto* innerDivTransform = innerDivWithTransform->objectPaintProperties()->tr
ansform(); | 750 auto* innerDivTransform = innerDivWithTransform->objectPaintProperties()->tr
ansform(); |
| 747 EXPECT_EQ(TransformationMatrix().translate3d(7, 8, 9), innerDivTransform->ma
trix()); | 751 EXPECT_EQ(TransformationMatrix().translate3d(7, 8, 9), innerDivTransform->ma
trix()); |
| 748 CHECK_VISUAL_RECT(innerDivWithTransform, frameView->layoutView()); | 752 CHECK_EXACT_VISUAL_RECT(innerDivWithTransform, frameView->layoutView()); |
| 749 | 753 |
| 750 auto* innerDocumentPaintOffsetTranslation = innerDivTransform->parent(); | 754 auto* innerDocumentPaintOffsetTranslation = innerDivTransform->parent(); |
| 751 EXPECT_EQ(TransformationMatrix().translate3d(31, 31, 0), innerDocumentPaintO
ffsetTranslation->matrix()); | 755 EXPECT_EQ(TransformationMatrix().translate3d(31, 31, 0), innerDocumentPaintO
ffsetTranslation->matrix()); |
| 752 auto* innerDocumentScrollTranslation = innerDocumentPaintOffsetTranslation->
parent(); | 756 auto* innerDocumentScrollTranslation = innerDocumentPaintOffsetTranslation->
parent(); |
| 753 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr
anslation->matrix()); | 757 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), innerDocumentScrollTr
anslation->matrix()); |
| 754 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); | 758 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); |
| 755 EXPECT_EQ(TransformationMatrix().translate3d(42, 42, 0), iframePreTranslatio
n->matrix()); | 759 EXPECT_EQ(TransformationMatrix().translate3d(42, 42, 0), iframePreTranslatio
n->matrix()); |
| 756 auto* iframeTransform = iframePreTranslation->parent(); | 760 auto* iframeTransform = iframePreTranslation->parent(); |
| 757 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), iframeTransform->matr
ix()); | 761 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), iframeTransform->matr
ix()); |
| 758 auto* iframePaintOffsetTranslation = iframeTransform->parent(); | 762 auto* iframePaintOffsetTranslation = iframeTransform->parent(); |
| 759 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePaintOffsetTran
slation->matrix()); | 763 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), iframePaintOffsetTran
slation->matrix()); |
| 760 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); | 764 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); |
| 761 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformTrans
form->matrix()); | 765 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformTrans
form->matrix()); |
| 762 | 766 |
| 763 LayoutObject* divWithTransform = document().getElementById("divWithTransform
")->layoutObject(); | 767 LayoutObject* divWithTransform = document().getElementById("divWithTransform
")->layoutObject(); |
| 764 EXPECT_EQ(divWithTransformTransform, divWithTransform->objectPaintProperties
()->transform()); | 768 EXPECT_EQ(divWithTransformTransform, divWithTransform->objectPaintProperties
()->transform()); |
| 765 CHECK_VISUAL_RECT(divWithTransform, frameView->layoutView()); | 769 CHECK_EXACT_VISUAL_RECT(divWithTransform, frameView->layoutView()); |
| 766 } | 770 } |
| 767 | 771 |
| 768 TEST_F(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) | 772 TEST_F(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) |
| 769 { | 773 { |
| 770 // This test verifies the tree builder correctly computes and records the pr
operty tree context | 774 // This test verifies the tree builder correctly computes and records the pr
operty tree context |
| 771 // for a (pseudo) stacking context that is scrolled by a containing block th
at is not one of | 775 // for a (pseudo) stacking context that is scrolled by a containing block th
at is not one of |
| 772 // the painting ancestors. | 776 // the painting ancestors. |
| 773 setBodyInnerHTML( | 777 setBodyInnerHTML( |
| 774 "<style>body { margin: 0; }</style>" | 778 "<style>body { margin: 0; }</style>" |
| 775 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>
" | 779 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>
" |
| 776 " <div id='child' style='position:relative; width:100px; height: 200px;
'></div>" | 780 " <div id='child' style='position:relative; width:100px; height: 200px;
'></div>" |
| 777 " <div style='height:10000px;'></div>" | 781 " <div style='height:10000px;'></div>" |
| 778 "</div>" | 782 "</div>" |
| 779 ); | 783 ); |
| 780 FrameView* frameView = document().view(); | 784 FrameView* frameView = document().view(); |
| 781 | 785 |
| 782 LayoutObject* scroller = document().getElementById("scroller")->layoutObject
(); | 786 LayoutObject* scroller = document().getElementById("scroller")->layoutObject
(); |
| 783 const ObjectPaintProperties* scrollerProperties = scroller->objectPaintPrope
rties(); | 787 const ObjectPaintProperties* scrollerProperties = scroller->objectPaintPrope
rties(); |
| 784 LayoutObject* child = document().getElementById("child")->layoutObject(); | 788 LayoutObject* child = document().getElementById("child")->layoutObject(); |
| 785 const ObjectPaintProperties* childProperties = child->objectPaintProperties(
); | 789 const ObjectPaintProperties* childProperties = child->objectPaintProperties(
); |
| 786 | 790 |
| 787 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo
xProperties()->propertyTreeState.clip); | 791 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo
xProperties()->propertyTreeState.clip); |
| 788 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor
derBoxProperties()->propertyTreeState.transform); | 792 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor
derBoxProperties()->propertyTreeState.transform); |
| 789 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTree
State.effect); | 793 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->propertyTree
State.effect); |
| 790 CHECK_VISUAL_RECT(scroller, frameView->layoutView()); | 794 CHECK_EXACT_VISUAL_RECT(scroller, frameView->layoutView()); |
| 791 CHECK_VISUAL_RECT(child, frameView->layoutView()); | 795 CHECK_EXACT_VISUAL_RECT(child, frameView->layoutView()); |
| 792 } | 796 } |
| 793 | 797 |
| 794 TEST_F(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext) | 798 TEST_F(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext) |
| 795 { | 799 { |
| 796 // This test verifies the tree builder correctly computes and records the pr
operty tree context | 800 // This test verifies the tree builder correctly computes and records the pr
operty tree context |
| 797 // for a (pseudo) stacking context that has a scrolling painting ancestor th
at is not its | 801 // for a (pseudo) stacking context that has a scrolling painting ancestor th
at is not its |
| 798 // containing block (thus should not be scrolled by it). | 802 // containing block (thus should not be scrolled by it). |
| 799 | 803 |
| 800 setBodyInnerHTML( | 804 setBodyInnerHTML( |
| 801 "<style>body { margin: 0; }</style>" | 805 "<style>body { margin: 0; }</style>" |
| 802 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" | 806 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" |
| 803 " <div id='child' style='position:absolute; left:0; top:0; width: 100px
; height: 200px'></div>" | 807 " <div id='child' style='position:absolute; left:0; top:0; width: 100px
; height: 200px'></div>" |
| 804 " <div style='height:10000px;'></div>" | 808 " <div style='height:10000px;'></div>" |
| 805 "</div>" | 809 "</div>" |
| 806 ); | 810 ); |
| 807 | 811 |
| 808 FrameView* frameView = document().view(); | 812 FrameView* frameView = document().view(); |
| 809 LayoutObject* scroller = document().getElementById("scroller")->layoutObject
(); | 813 LayoutObject* scroller = document().getElementById("scroller")->layoutObject
(); |
| 810 const ObjectPaintProperties* scrollerProperties = scroller->objectPaintPrope
rties(); | 814 const ObjectPaintProperties* scrollerProperties = scroller->objectPaintPrope
rties(); |
| 811 LayoutObject* child = document().getElementById("child")->layoutObject(); | 815 LayoutObject* child = document().getElementById("child")->layoutObject(); |
| 812 const ObjectPaintProperties* childProperties = child->objectPaintProperties(
); | 816 const ObjectPaintProperties* childProperties = child->objectPaintProperties(
); |
| 813 | 817 |
| 814 EXPECT_EQ(frameView->contentClip(), childProperties->localBorderBoxPropertie
s()->propertyTreeState.clip); | 818 EXPECT_EQ(frameView->contentClip(), childProperties->localBorderBoxPropertie
s()->propertyTreeState.clip); |
| 815 EXPECT_EQ(frameView->scrollTranslation(), childProperties->localBorderBoxPro
perties()->propertyTreeState.transform); | 819 EXPECT_EQ(frameView->scrollTranslation(), childProperties->localBorderBoxPro
perties()->propertyTreeState.transform); |
| 816 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope
rties()->propertyTreeState.effect); | 820 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope
rties()->propertyTreeState.effect); |
| 817 CHECK_VISUAL_RECT(scroller, frameView->layoutView()); | 821 CHECK_EXACT_VISUAL_RECT(scroller, frameView->layoutView()); |
| 818 CHECK_VISUAL_RECT(child, frameView->layoutView()); | 822 CHECK_EXACT_VISUAL_RECT(child, frameView->layoutView()); |
| 819 } | 823 } |
| 820 | 824 |
| 821 TEST_F(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) | 825 TEST_F(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) |
| 822 { | 826 { |
| 823 // This test verifies that the border box space of a table cell is being cor
rectly computed. | 827 // This test verifies that the border box space of a table cell is being cor
rectly computed. |
| 824 // Table cells have weird location adjustment in our layout/paint implementa
tion. | 828 // Table cells have weird location adjustment in our layout/paint implementa
tion. |
| 825 setBodyInnerHTML( | 829 setBodyInnerHTML( |
| 826 "<style>" | 830 "<style>" |
| 827 " body {" | 831 " body {" |
| 828 " margin: 0;" | 832 " margin: 0;" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 849 " <tr><td></td><td><div id='target'></div></td></tr>" | 853 " <tr><td></td><td><div id='target'></div></td></tr>" |
| 850 "</table>" | 854 "</table>" |
| 851 ); | 855 ); |
| 852 | 856 |
| 853 FrameView* frameView = document().view(); | 857 FrameView* frameView = document().view(); |
| 854 LayoutObject* target = document().getElementById("target")->layoutObject(); | 858 LayoutObject* target = document().getElementById("target")->layoutObject(); |
| 855 const ObjectPaintProperties* targetProperties = target->objectPaintPropertie
s(); | 859 const ObjectPaintProperties* targetProperties = target->objectPaintPropertie
s(); |
| 856 | 860 |
| 857 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties(
)->paintOffset); | 861 EXPECT_EQ(LayoutPoint(170, 170), targetProperties->localBorderBoxProperties(
)->paintOffset); |
| 858 EXPECT_EQ(frameView->scrollTranslation(), targetProperties->localBorderBoxPr
operties()->propertyTreeState.transform); | 862 EXPECT_EQ(frameView->scrollTranslation(), targetProperties->localBorderBoxPr
operties()->propertyTreeState.transform); |
| 859 CHECK_VISUAL_RECT(target, frameView->layoutView()); | 863 CHECK_EXACT_VISUAL_RECT(target, frameView->layoutView()); |
| 860 } | 864 } |
| 861 | 865 |
| 862 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) | 866 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) |
| 863 { | 867 { |
| 864 // This test verifies that clip tree hierarchy being generated correctly for
the hard case | 868 // This test verifies that clip tree hierarchy being generated correctly for
the hard case |
| 865 // such that a fixed position element getting clipped by an absolute positio
n CSS clip. | 869 // such that a fixed position element getting clipped by an absolute positio
n CSS clip. |
| 866 setBodyInnerHTML( | 870 setBodyInnerHTML( |
| 867 "<style>" | 871 "<style>" |
| 868 " #clip {" | 872 " #clip {" |
| 869 " position: absolute;" | 873 " position: absolute;" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 889 | 893 |
| 890 FrameView* frameView = document().view(); | 894 FrameView* frameView = document().view(); |
| 891 | 895 |
| 892 LayoutObject* clip = document().getElementById("clip")->layoutObject(); | 896 LayoutObject* clip = document().getElementById("clip")->layoutObject(); |
| 893 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); | 897 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); |
| 894 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); | 898 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClip()->parent()); |
| 895 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr
ansformSpace()); | 899 EXPECT_EQ(frameView->scrollTranslation(), clipProperties->cssClip()->localTr
ansformSpace()); |
| 896 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); | 900 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
| 897 // TODO(chrishtr): GeomeryMapper rports 40x60 size (i.e. including clip), wh
ereas the old code reports 100x100 (unclipped). | 901 // TODO(chrishtr): GeomeryMapper rports 40x60 size (i.e. including clip), wh
ereas the old code reports 100x100 (unclipped). |
| 898 // Fix. | 902 // Fix. |
| 899 // CHECK_VISUAL_RECT(clip, frameView->layoutView()); | 903 // CHECK_EXACT_VISUAL_RECT(clip, frameView->layoutView()); |
| 900 | 904 |
| 901 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 905 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 902 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); | 906 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); |
| 903 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti
es()->propertyTreeState.clip); | 907 EXPECT_EQ(clipProperties->cssClip(), fixedProperties->localBorderBoxProperti
es()->propertyTreeState.clip); |
| 904 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); | 908 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); |
| 905 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); | 909 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); |
| 906 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); | 910 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); |
| 907 CHECK_VISUAL_RECT(fixed, frameView->layoutView()); | 911 CHECK_EXACT_VISUAL_RECT(fixed, frameView->layoutView()); |
| 908 } | 912 } |
| 909 | 913 |
| 910 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) | 914 TEST_F(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) |
| 911 { | 915 { |
| 912 // This test is similar to CSSClipFixedPositionDescendant above, except that | 916 // This test is similar to CSSClipFixedPositionDescendant above, except that |
| 913 // now we have a parent overflow clip that should be escaped by the fixed de
scendant. | 917 // now we have a parent overflow clip that should be escaped by the fixed de
scendant. |
| 914 setBodyInnerHTML( | 918 setBodyInnerHTML( |
| 915 "<style>" | 919 "<style>" |
| 916 " body {" | 920 " body {" |
| 917 " margin: 0;" | 921 " margin: 0;" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 941 LayoutRect localClipRect(40, 10, 40, 60); | 945 LayoutRect localClipRect(40, 10, 40, 60); |
| 942 LayoutRect absoluteClipRect = localClipRect; | 946 LayoutRect absoluteClipRect = localClipRect; |
| 943 absoluteClipRect.move(123, 456); | 947 absoluteClipRect.move(123, 456); |
| 944 | 948 |
| 945 FrameView* frameView = document().view(); | 949 FrameView* frameView = document().view(); |
| 946 | 950 |
| 947 LayoutObject* overflow = document().getElementById("overflow")->layoutObject
(); | 951 LayoutObject* overflow = document().getElementById("overflow")->layoutObject
(); |
| 948 const ObjectPaintProperties* overflowProperties = overflow->objectPaintPrope
rties(); | 952 const ObjectPaintProperties* overflowProperties = overflow->objectPaintPrope
rties(); |
| 949 EXPECT_EQ(frameView->contentClip(), overflowProperties->overflowClip()->pare
nt()); | 953 EXPECT_EQ(frameView->contentClip(), overflowProperties->overflowClip()->pare
nt()); |
| 950 EXPECT_EQ(frameView->scrollTranslation(), overflowProperties->scrollTranslat
ion()->parent()); | 954 EXPECT_EQ(frameView->scrollTranslation(), overflowProperties->scrollTranslat
ion()->parent()); |
| 951 CHECK_VISUAL_RECT(overflow, frameView->layoutView()); | 955 CHECK_EXACT_VISUAL_RECT(overflow, frameView->layoutView()); |
| 952 | 956 |
| 953 LayoutObject* clip = document().getElementById("clip")->layoutObject(); | 957 LayoutObject* clip = document().getElementById("clip")->layoutObject(); |
| 954 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); | 958 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); |
| 955 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par
ent()); | 959 EXPECT_EQ(overflowProperties->overflowClip(), clipProperties->cssClip()->par
ent()); |
| 956 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClip()
->localTransformSpace()); | 960 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClip()
->localTransformSpace()); |
| 957 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); | 961 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
Clip()->clipRect()); |
| 958 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClipFixedPosition()->
parent()); | 962 EXPECT_EQ(frameView->contentClip(), clipProperties->cssClipFixedPosition()->
parent()); |
| 959 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClipFi
xedPosition()->localTransformSpace()); | 963 EXPECT_EQ(overflowProperties->scrollTranslation(), clipProperties->cssClipFi
xedPosition()->localTransformSpace()); |
| 960 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
ClipFixedPosition()->clipRect()); | 964 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), clipProperties->css
ClipFixedPosition()->clipRect()); |
| 961 CHECK_VISUAL_RECT(clip, frameView->layoutView()); | 965 CHECK_EXACT_VISUAL_RECT(clip, frameView->layoutView()); |
| 962 | 966 |
| 963 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 967 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 964 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); | 968 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); |
| 965 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord
erBoxProperties()->propertyTreeState.clip); | 969 EXPECT_EQ(clipProperties->cssClipFixedPosition(), fixedProperties->localBord
erBoxProperties()->propertyTreeState.clip); |
| 966 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); | 970 EXPECT_EQ(frameView->preTranslation(), fixedProperties->localBorderBoxProper
ties()->propertyTreeState.transform->parent()); |
| 967 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); | 971 EXPECT_EQ(TransformationMatrix().translate(654, 321), fixedProperties->local
BorderBoxProperties()->propertyTreeState.transform->matrix()); |
| 968 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); | 972 EXPECT_EQ(LayoutPoint(), fixedProperties->localBorderBoxProperties()->paintO
ffset); |
| 969 CHECK_VISUAL_RECT(fixed, frameView->layoutView()); | 973 CHECK_EXACT_VISUAL_RECT(fixed, frameView->layoutView()); |
| 970 } | 974 } |
| 971 | 975 |
| 972 TEST_F(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) | 976 TEST_F(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) |
| 973 { | 977 { |
| 974 setBodyInnerHTML( | 978 setBodyInnerHTML( |
| 975 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" | 979 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" |
| 976 " <div style='position: relative; top: 100px; left: 100px'>" | 980 " <div style='position: relative; top: 100px; left: 100px'>" |
| 977 " <div id='spanner' style='column-span: all; opacity: 0.5; width: 100
px; height: 100px;'></div>" | 981 " <div id='spanner' style='column-span: all; opacity: 0.5; width: 100
px; height: 100px;'></div>" |
| 978 " </div>" | 982 " </div>" |
| 979 "</div>" | 983 "</div>" |
| 980 ); | 984 ); |
| 981 | 985 |
| 982 LayoutObject* spanner = getLayoutObjectByElementId("spanner"); | 986 LayoutObject* spanner = getLayoutObjectByElementId("spanner"); |
| 983 EXPECT_EQ(LayoutPoint(55, 44), spanner->objectPaintProperties()->localBorder
BoxProperties()->paintOffset); | 987 EXPECT_EQ(LayoutPoint(55, 44), spanner->objectPaintProperties()->localBorder
BoxProperties()->paintOffset); |
| 984 CHECK_VISUAL_RECT(spanner, document().view()->layoutView()); | 988 CHECK_EXACT_VISUAL_RECT(spanner, document().view()->layoutView()); |
| 985 } | 989 } |
| 986 | 990 |
| 987 TEST_F(PaintPropertyTreeBuilderTest, FractionalPaintOffset) | 991 TEST_F(PaintPropertyTreeBuilderTest, FractionalPaintOffset) |
| 988 { | 992 { |
| 989 setBodyInnerHTML( | 993 setBodyInnerHTML( |
| 990 "<style>" | 994 "<style>" |
| 991 " * { margin: 0; }" | 995 " * { margin: 0; }" |
| 992 " div { position: absolute; }" | 996 " div { position: absolute; }" |
| 993 "</style>" | 997 "</style>" |
| 994 "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;'
>" | 998 "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;'
>" |
| 995 " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: 11.1p
x;'></div>" | 999 " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: 11.1p
x;'></div>" |
| 996 "</div>" | 1000 "</div>" |
| 997 ); | 1001 ); |
| 998 FrameView* frameView = document().view(); | 1002 FrameView* frameView = document().view(); |
| 999 | 1003 |
| 1000 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1004 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1001 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1005 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); |
| 1002 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3)); | 1006 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3)); |
| 1003 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset
); | 1007 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset
); |
| 1004 CHECK_VISUAL_RECT(a, frameView->layoutView()); | 1008 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); |
| 1005 | 1009 |
| 1006 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1010 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1007 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1011 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1008 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1))
; | 1012 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1))
; |
| 1009 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset
); | 1013 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset
); |
| 1010 CHECK_VISUAL_RECT(a, frameView->layoutView()); | 1014 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); |
| 1011 } | 1015 } |
| 1012 | 1016 |
| 1013 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping) | 1017 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping) |
| 1014 { | 1018 { |
| 1015 setBodyInnerHTML( | 1019 setBodyInnerHTML( |
| 1016 "<style>" | 1020 "<style>" |
| 1017 " * { margin: 0; }" | 1021 " * { margin: 0; }" |
| 1018 " div { position: relative; }" | 1022 " div { position: relative; }" |
| 1019 "</style>" | 1023 "</style>" |
| 1020 "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;'
>" | 1024 "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;'
>" |
| 1021 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" | 1025 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" |
| 1022 " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: 0.1
px;'></div>" | 1026 " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: 0.1
px;'></div>" |
| 1023 " </div>" | 1027 " </div>" |
| 1024 "</div>" | 1028 "</div>" |
| 1025 ); | 1029 ); |
| 1026 FrameView* frameView = document().view(); | 1030 FrameView* frameView = document().view(); |
| 1027 | 1031 |
| 1028 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1032 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1029 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1033 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1030 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); | 1034 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); |
| 1031 // The paint offset transform should be snapped from (0.3,0.3) to (0,0). | 1035 // The paint offset transform should be snapped from (0.3,0.3) to (0,0). |
| 1032 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()->
parent()->matrix()); | 1036 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()->
parent()->matrix()); |
| 1033 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3). | 1037 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3). |
| 1034 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3)); | 1038 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3)); |
| 1035 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); | 1039 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); |
| 1036 CHECK_VISUAL_RECT(b, frameView->layoutView()); | 1040 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); |
| 1037 | 1041 |
| 1038 // c should be painted starting at subpixelAccumulation + (0.1,0.1) = (0.4,0
.4). | 1042 // c should be painted starting at subpixelAccumulation + (0.1,0.1) = (0.4,0
.4). |
| 1039 LayoutObject* c = document().getElementById("c")->layoutObject(); | 1043 LayoutObject* c = document().getElementById("c")->layoutObject(); |
| 1040 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.1
, 0.1)); | 1044 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.1
, 0.1)); |
| 1041 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); | 1045 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); |
| 1042 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); | 1046 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); |
| 1043 // TODO(chrishtr): results differ by pixel snapping | 1047 // Visual rects via the non-paint properties system use enclosingIntRect bef
ore applying transforms, |
| 1044 // CHECK_VISUAL_RECT(c, frameView->layoutView()); | 1048 // because they are computed bottom-up and therefore can't apply pixel snapp
ing. Therefore apply a |
| 1049 // slop of 1px. |
| 1050 CHECK_VISUAL_RECT(c, frameView->layoutView(), 1); |
| 1045 } | 1051 } |
| 1046 | 1052 |
| 1047 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughTransfor
m) | 1053 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughTransfor
m) |
| 1048 { | 1054 { |
| 1049 setBodyInnerHTML( | 1055 setBodyInnerHTML( |
| 1050 "<style>" | 1056 "<style>" |
| 1051 " * { margin: 0; }" | 1057 " * { margin: 0; }" |
| 1052 " div { position: relative; }" | 1058 " div { position: relative; }" |
| 1053 "</style>" | 1059 "</style>" |
| 1054 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" | 1060 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" |
| 1055 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" | 1061 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
);'>" |
| 1056 " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: 0.7
px;'></div>" | 1062 " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: 0.7
px;'></div>" |
| 1057 " </div>" | 1063 " </div>" |
| 1058 "</div>" | 1064 "</div>" |
| 1059 ); | 1065 ); |
| 1060 FrameView* frameView = document().view(); | 1066 FrameView* frameView = document().view(); |
| 1061 | 1067 |
| 1062 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1068 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1063 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1069 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1064 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); | 1070 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), bProperties->transfor
m()->matrix()); |
| 1065 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). | 1071 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). |
| 1066 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()->
parent()->matrix()); | 1072 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()->
parent()->matrix()); |
| 1067 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3
). | 1073 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3
). |
| 1068 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
.7)) - LayoutPoint(1, 1)); | 1074 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
.7)) - LayoutPoint(1, 1)); |
| 1069 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); | 1075 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); |
| 1070 CHECK_VISUAL_RECT(b, frameView->layoutView()); | 1076 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); |
| 1071 | 1077 |
| 1072 // c should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). | 1078 // c should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). |
| 1073 LayoutObject* c = document().getElementById("c")->layoutObject(); | 1079 LayoutObject* c = document().getElementById("c")->layoutObject(); |
| 1074 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); | 1080 LayoutPoint cPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); |
| 1075 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); | 1081 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); |
| 1076 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); | 1082 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset
); |
| 1077 // TODO(chrishtr): results differ by pixel snapping | 1083 // Visual rects via the non-paint properties system use enclosingIntRect bef
ore applying transforms, |
| 1078 // CHECK_VISUAL_RECT(c, frameView->layoutView()); | 1084 // because they are computed bottom-up and therefore can't apply pixel snapp
ing. Therefore apply a |
| 1085 // slop of 1px. |
| 1086 CHECK_VISUAL_RECT(c, frameView->layoutView(), 1); |
| 1079 } | 1087 } |
| 1080 | 1088 |
| 1081 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughMultiple
Transforms) | 1089 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingThroughMultiple
Transforms) |
| 1082 { | 1090 { |
| 1083 setBodyInnerHTML( | 1091 setBodyInnerHTML( |
| 1084 "<style>" | 1092 "<style>" |
| 1085 " * { margin: 0; }" | 1093 " * { margin: 0; }" |
| 1086 " div { position: relative; }" | 1094 " div { position: relative; }" |
| 1087 "</style>" | 1095 "</style>" |
| 1088 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" | 1096 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'
>" |
| 1089 " <div id='b' style='width: 40px; height: 40px; transform: translate3d(
5px, 7px, 0);'>" | 1097 " <div id='b' style='width: 40px; height: 40px; transform: translate3d(
5px, 7px, 0);'>" |
| 1090 " <div id='c' style='width: 40px; height: 40px; transform: translate3
d(11px, 13px, 0);'>" | 1098 " <div id='c' style='width: 40px; height: 40px; transform: translate3
d(11px, 13px, 0);'>" |
| 1091 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: 0
.7px;'></div>" | 1099 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: 0
.7px;'></div>" |
| 1092 " </div>" | 1100 " </div>" |
| 1093 " </div>" | 1101 " </div>" |
| 1094 "</div>" | 1102 "</div>" |
| 1095 ); | 1103 ); |
| 1096 FrameView* frameView = document().view(); | 1104 FrameView* frameView = document().view(); |
| 1097 | 1105 |
| 1098 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1106 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1099 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1107 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1100 EXPECT_EQ(TransformationMatrix().translate3d(5, 7, 0), bProperties->transfor
m()->matrix()); | 1108 EXPECT_EQ(TransformationMatrix().translate3d(5, 7, 0), bProperties->transfor
m()->matrix()); |
| 1101 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). | 1109 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). |
| 1102 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()->
parent()->matrix()); | 1110 EXPECT_EQ(TransformationMatrix().translate(1, 1), bProperties->transform()->
parent()->matrix()); |
| 1103 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3
). | 1111 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3
). |
| 1104 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
.7)) - LayoutPoint(1, 1)); | 1112 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
.7)) - LayoutPoint(1, 1)); |
| 1105 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); | 1113 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); |
| 1106 CHECK_VISUAL_RECT(b, frameView->layoutView()); | 1114 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); |
| 1107 | 1115 |
| 1108 LayoutObject* c = document().getElementById("c")->layoutObject(); | 1116 LayoutObject* c = document().getElementById("c")->layoutObject(); |
| 1109 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); | 1117 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); |
| 1110 EXPECT_EQ(TransformationMatrix().translate3d(11, 13, 0), cProperties->transf
orm()->matrix()); | 1118 EXPECT_EQ(TransformationMatrix().translate3d(11, 13, 0), cProperties->transf
orm()->matrix()); |
| 1111 // The paint offset should be (-0.3,-0.3) but the paint offset transform sho
uld still be at | 1119 // The paint offset should be (-0.3,-0.3) but the paint offset transform sho
uld still be at |
| 1112 // (0,0) because it should be snapped. | 1120 // (0,0) because it should be snapped. |
| 1113 EXPECT_EQ(TransformationMatrix().translate(0, 0), cProperties->transform()->
parent()->matrix()); | 1121 EXPECT_EQ(TransformationMatrix().translate(0, 0), cProperties->transform()->
parent()->matrix()); |
| 1114 // The residual subpixel adjustment should still be (-0.3,-0.3). | 1122 // The residual subpixel adjustment should still be (-0.3,-0.3). |
| 1115 EXPECT_EQ(subpixelAccumulation, cProperties->localBorderBoxProperties()->pai
ntOffset); | 1123 EXPECT_EQ(subpixelAccumulation, cProperties->localBorderBoxProperties()->pai
ntOffset); |
| 1116 CHECK_VISUAL_RECT(c, frameView->layoutView()); | 1124 CHECK_EXACT_VISUAL_RECT(c, frameView->layoutView()); |
| 1117 | 1125 |
| 1118 // d should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). | 1126 // d should be painted starting at subpixelAccumulation + (0.7,0.7) = (0.4,0
.4). |
| 1119 LayoutObject* d = document().getElementById("d")->layoutObject(); | 1127 LayoutObject* d = document().getElementById("d")->layoutObject(); |
| 1120 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); | 1128 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0.7)); |
| 1121 const ObjectPaintProperties* dProperties = d->objectPaintProperties(); | 1129 const ObjectPaintProperties* dProperties = d->objectPaintProperties(); |
| 1122 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); | 1130 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); |
| 1123 // TODO(chrishtr): results differ by pixel snapping | 1131 // Visual rects via the non-paint properties system use enclosingIntRect bef
ore applying transforms, |
| 1124 // CHECK_VISUAL_RECT(d, frameView->layoutView()); | 1132 // because they are computed bottom-up and therefore can't apply pixel snapp
ing. Therefore apply a |
| 1133 // slop of 1px. |
| 1134 CHECK_VISUAL_RECT(d, frameView->layoutView(), 1); |
| 1125 } | 1135 } |
| 1126 | 1136 |
| 1127 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) | 1137 TEST_F(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) |
| 1128 { | 1138 { |
| 1129 setBodyInnerHTML( | 1139 setBodyInnerHTML( |
| 1130 "<style>" | 1140 "<style>" |
| 1131 " * { margin: 0; }" | 1141 " * { margin: 0; }" |
| 1132 "</style>" | 1142 "</style>" |
| 1133 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: re
lative;'>" | 1143 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: re
lative;'>" |
| 1134 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
); position: relative;'>" | 1144 " <div id='b' style='width: 40px; height: 40px; transform: translateZ(0
); position: relative;'>" |
| 1135 " <div id='fixed' style='width: 40px; height: 40px; position: fixed;'
>" | 1145 " <div id='fixed' style='width: 40px; height: 40px; position: fixed;'
>" |
| 1136 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; positi
on: relative;'></div>" | 1146 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; positi
on: relative;'></div>" |
| 1137 " </div>" | 1147 " </div>" |
| 1138 " </div>" | 1148 " </div>" |
| 1139 "</div>" | 1149 "</div>" |
| 1140 ); | 1150 ); |
| 1141 FrameView* frameView = document().view(); | 1151 FrameView* frameView = document().view(); |
| 1142 | 1152 |
| 1143 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1153 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1144 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1154 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1145 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()->
matrix()); | 1155 EXPECT_EQ(TransformationMatrix().translate(0, 0), bProperties->transform()->
matrix()); |
| 1146 // The paint offset transform should be snapped from (0.7,0) to (1,0). | 1156 // The paint offset transform should be snapped from (0.7,0) to (1,0). |
| 1147 EXPECT_EQ(TransformationMatrix().translate(1, 0), bProperties->transform()->
parent()->matrix()); | 1157 EXPECT_EQ(TransformationMatrix().translate(1, 0), bProperties->transform()->
parent()->matrix()); |
| 1148 // The residual subpixel adjustment should be (0.7,0) - (1,0) = (-0.3,0). | 1158 // The residual subpixel adjustment should be (0.7,0) - (1,0) = (-0.3,0). |
| 1149 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
)) - LayoutPoint(1, 0)); | 1159 LayoutPoint subpixelAccumulation = LayoutPoint(LayoutPoint(FloatPoint(0.7, 0
)) - LayoutPoint(1, 0)); |
| 1150 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); | 1160 EXPECT_EQ(subpixelAccumulation, bProperties->localBorderBoxProperties()->pai
ntOffset); |
| 1151 CHECK_VISUAL_RECT(b, frameView->layoutView()); | 1161 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); |
| 1152 | 1162 |
| 1153 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 1163 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 1154 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); | 1164 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(
); |
| 1155 // The residual subpixel adjustment should still be (-0.3,0). | 1165 // The residual subpixel adjustment should still be (-0.3,0). |
| 1156 EXPECT_EQ(subpixelAccumulation, fixedProperties->localBorderBoxProperties()-
>paintOffset); | 1166 EXPECT_EQ(subpixelAccumulation, fixedProperties->localBorderBoxProperties()-
>paintOffset); |
| 1157 CHECK_VISUAL_RECT(fixed, frameView->layoutView()); | 1167 CHECK_EXACT_VISUAL_RECT(fixed, frameView->layoutView()); |
| 1158 | 1168 |
| 1159 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0). | 1169 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0). |
| 1160 LayoutObject* d = document().getElementById("d")->layoutObject(); | 1170 LayoutObject* d = document().getElementById("d")->layoutObject(); |
| 1161 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0)); | 1171 LayoutPoint dPaintOffset = subpixelAccumulation + LayoutPoint(FloatPoint(0.7
, 0)); |
| 1162 const ObjectPaintProperties* dProperties = d->objectPaintProperties(); | 1172 const ObjectPaintProperties* dProperties = d->objectPaintProperties(); |
| 1163 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); | 1173 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset
); |
| 1164 // TODO(chrishtr): results differ by pixel snapping | 1174 // Visual rects via the non-paint properties system use enclosingIntRect bef
ore applying transforms, |
| 1165 // CHECK_VISUAL_RECT(d, frameView->layoutView()); | 1175 // because they are computed bottom-up and therefore can't apply pixel snapp
ing. Therefore apply a |
| 1176 // slop of 1px. |
| 1177 CHECK_VISUAL_RECT(d, frameView->layoutView(), 1); |
| 1166 } | 1178 } |
| 1167 | 1179 |
| 1168 TEST_F(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) | 1180 TEST_F(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) |
| 1169 { | 1181 { |
| 1170 setBodyInnerHTML( | 1182 setBodyInnerHTML( |
| 1171 "<svg id='svg' style='position: relative; left: 0.1px; transform: matrix
(1, 0, 0, 1, 0, 0);'>" | 1183 "<svg id='svg' style='position: relative; left: 0.1px; transform: matrix
(1, 0, 0, 1, 0, 0);'>" |
| 1172 " <rect id='rect' transform='translate(1, 1)'/>" | 1184 " <rect id='rect' transform='translate(1, 1)'/>" |
| 1173 "</svg>"); | 1185 "</svg>"); |
| 1174 | 1186 |
| 1175 LayoutObject& svgWithTransform = *document().getElementById("svg")->layoutOb
ject(); | 1187 LayoutObject& svgWithTransform = *document().getElementById("svg")->layoutOb
ject(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1206 | 1218 |
| 1207 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1219 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1208 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1220 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); |
| 1209 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1221 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1210 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1222 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1211 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); | 1223 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); |
| 1212 EXPECT_NE(aProperties->transform(), bProperties->transform()); | 1224 EXPECT_NE(aProperties->transform(), bProperties->transform()); |
| 1213 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); | 1225 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); |
| 1214 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); | 1226 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); |
| 1215 EXPECT_EQ(aProperties->transform()->renderingContextID(), bProperties->trans
form()->renderingContextID()); | 1227 EXPECT_EQ(aProperties->transform()->renderingContextID(), bProperties->trans
form()->renderingContextID()); |
| 1216 CHECK_VISUAL_RECT(a, frameView->layoutView()); | 1228 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); |
| 1217 CHECK_VISUAL_RECT(b, frameView->layoutView()); | 1229 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); |
| 1218 } | 1230 } |
| 1219 | 1231 |
| 1220 TEST_F(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext) | 1232 TEST_F(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext) |
| 1221 { | 1233 { |
| 1222 setBodyInnerHTML( | 1234 setBodyInnerHTML( |
| 1223 "<div style='transform-style: preserve-3d'>" | 1235 "<div style='transform-style: preserve-3d'>" |
| 1224 " <div id='a' style='transform: translateZ(0); width: 30px; height: 40p
x'>" | 1236 " <div id='a' style='transform: translateZ(0); width: 30px; height: 40p
x'>" |
| 1225 " <div id='b' style='transform: translateZ(0); width: 10px; height: 2
0px'></div>" | 1237 " <div id='b' style='transform: translateZ(0); width: 10px; height: 2
0px'></div>" |
| 1226 " </div>" | 1238 " </div>" |
| 1227 "</div>"); | 1239 "</div>"); |
| 1228 FrameView* frameView = document().view(); | 1240 FrameView* frameView = document().view(); |
| 1229 | 1241 |
| 1230 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1242 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1231 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1243 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); |
| 1232 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1244 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1233 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1245 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1234 ASSERT_FALSE(a->styleRef().preserves3D()); | 1246 ASSERT_FALSE(a->styleRef().preserves3D()); |
| 1235 | 1247 |
| 1236 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); | 1248 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); |
| 1237 | 1249 |
| 1238 // #a should participate in a rendering context (due to its parent), but its | 1250 // #a should participate in a rendering context (due to its parent), but its |
| 1239 // child #b should not. | 1251 // child #b should not. |
| 1240 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); | 1252 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); |
| 1241 EXPECT_FALSE(bProperties->transform()->hasRenderingContext()); | 1253 EXPECT_FALSE(bProperties->transform()->hasRenderingContext()); |
| 1242 CHECK_VISUAL_RECT(a, frameView->layoutView()); | 1254 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); |
| 1243 CHECK_VISUAL_RECT(b, frameView->layoutView()); | 1255 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); |
| 1244 } | 1256 } |
| 1245 | 1257 |
| 1246 TEST_F(PaintPropertyTreeBuilderTest, NestedRenderingContexts) | 1258 TEST_F(PaintPropertyTreeBuilderTest, NestedRenderingContexts) |
| 1247 { | 1259 { |
| 1248 setBodyInnerHTML( | 1260 setBodyInnerHTML( |
| 1249 "<div style='transform-style: preserve-3d'>" | 1261 "<div style='transform-style: preserve-3d'>" |
| 1250 " <div id='a' style='transform: translateZ(0); width: 50px; height: 60p
x'>" | 1262 " <div id='a' style='transform: translateZ(0); width: 50px; height: 60p
x'>" |
| 1251 " <div style='transform-style: preserve-3d; width: 30px; height: 40px
'>" | 1263 " <div style='transform-style: preserve-3d; width: 30px; height: 40px
'>" |
| 1252 " <div id='b' style='transform: translateZ(0); width: 10px; height:
20px'>" | 1264 " <div id='b' style='transform: translateZ(0); width: 10px; height:
20px'>" |
| 1253 " </div>" | 1265 " </div>" |
| 1254 " </div>" | 1266 " </div>" |
| 1255 "</div>"); | 1267 "</div>"); |
| 1256 FrameView* frameView = document().view(); | 1268 FrameView* frameView = document().view(); |
| 1257 | 1269 |
| 1258 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1270 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1259 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1271 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); |
| 1260 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1272 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1261 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1273 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1262 ASSERT_FALSE(a->styleRef().preserves3D()); | 1274 ASSERT_FALSE(a->styleRef().preserves3D()); |
| 1263 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); | 1275 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); |
| 1264 | 1276 |
| 1265 // #a should participate in a rendering context (due to its parent). Its | 1277 // #a should participate in a rendering context (due to its parent). Its |
| 1266 // child does preserve 3D, but since #a does not, #a's rendering context is | 1278 // child does preserve 3D, but since #a does not, #a's rendering context is |
| 1267 // not passed on to its children. Thus #b ends up in a separate rendering | 1279 // not passed on to its children. Thus #b ends up in a separate rendering |
| 1268 // context rooted at its parent. | 1280 // context rooted at its parent. |
| 1269 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); | 1281 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); |
| 1270 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); | 1282 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); |
| 1271 EXPECT_NE(aProperties->transform()->renderingContextID(), bProperties->trans
form()->renderingContextID()); | 1283 EXPECT_NE(aProperties->transform()->renderingContextID(), bProperties->trans
form()->renderingContextID()); |
| 1272 CHECK_VISUAL_RECT(a, frameView->layoutView()); | 1284 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); |
| 1273 CHECK_VISUAL_RECT(b, frameView->layoutView()); | 1285 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); |
| 1274 } | 1286 } |
| 1275 | 1287 |
| 1276 // Returns true if the first node has the second as an ancestor. | 1288 // Returns true if the first node has the second as an ancestor. |
| 1277 static bool nodeHasAncestor(const TransformPaintPropertyNode* node, const Transf
ormPaintPropertyNode* ancestor) | 1289 static bool nodeHasAncestor(const TransformPaintPropertyNode* node, const Transf
ormPaintPropertyNode* ancestor) |
| 1278 { | 1290 { |
| 1279 while (node) { | 1291 while (node) { |
| 1280 if (node == ancestor) | 1292 if (node == ancestor) |
| 1281 return true; | 1293 return true; |
| 1282 node = node->parent(); | 1294 node = node->parent(); |
| 1283 } | 1295 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1308 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1320 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1309 const auto* aTransform = a->objectPaintProperties()->transform(); | 1321 const auto* aTransform = a->objectPaintProperties()->transform(); |
| 1310 ASSERT_TRUE(aTransform); | 1322 ASSERT_TRUE(aTransform); |
| 1311 const auto* bTransform = b->objectPaintProperties()->transform(); | 1323 const auto* bTransform = b->objectPaintProperties()->transform(); |
| 1312 ASSERT_TRUE(bTransform); | 1324 ASSERT_TRUE(bTransform); |
| 1313 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); | 1325 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); |
| 1314 | 1326 |
| 1315 // Some node must flatten the inherited transform from #a before it reaches | 1327 // Some node must flatten the inherited transform from #a before it reaches |
| 1316 // #b's transform. | 1328 // #b's transform. |
| 1317 EXPECT_TRUE(someNodeFlattensTransform(bTransform, aTransform)); | 1329 EXPECT_TRUE(someNodeFlattensTransform(bTransform, aTransform)); |
| 1318 CHECK_VISUAL_RECT(a, frameView->layoutView()); | 1330 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); |
| 1319 CHECK_VISUAL_RECT(b, frameView->layoutView()); | 1331 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); |
| 1320 } | 1332 } |
| 1321 | 1333 |
| 1322 TEST_F(PaintPropertyTreeBuilderTest, Preserve3DTransformStylePropagatesToChildre
n) | 1334 TEST_F(PaintPropertyTreeBuilderTest, Preserve3DTransformStylePropagatesToChildre
n) |
| 1323 { | 1335 { |
| 1324 setBodyInnerHTML( | 1336 setBodyInnerHTML( |
| 1325 "<div id='a' style='transform: translateZ(0); transform-style: preserve-
3d; width: 30px; height: 40px'>" | 1337 "<div id='a' style='transform: translateZ(0); transform-style: preserve-
3d; width: 30px; height: 40px'>" |
| 1326 " <div id='b' style='transform: translateZ(0); width: 10px; height: 10p
x'></div>" | 1338 " <div id='b' style='transform: translateZ(0); width: 10px; height: 10p
x'></div>" |
| 1327 "</div>"); | 1339 "</div>"); |
| 1328 FrameView* frameView = document().view(); | 1340 FrameView* frameView = document().view(); |
| 1329 | 1341 |
| 1330 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1342 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1331 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1343 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1332 const auto* aTransform = a->objectPaintProperties()->transform(); | 1344 const auto* aTransform = a->objectPaintProperties()->transform(); |
| 1333 ASSERT_TRUE(aTransform); | 1345 ASSERT_TRUE(aTransform); |
| 1334 const auto* bTransform = b->objectPaintProperties()->transform(); | 1346 const auto* bTransform = b->objectPaintProperties()->transform(); |
| 1335 ASSERT_TRUE(bTransform); | 1347 ASSERT_TRUE(bTransform); |
| 1336 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); | 1348 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); |
| 1337 | 1349 |
| 1338 // No node may flatten the inherited transform from #a before it reaches | 1350 // No node may flatten the inherited transform from #a before it reaches |
| 1339 // #b's transform. | 1351 // #b's transform. |
| 1340 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aTransform)); | 1352 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aTransform)); |
| 1341 CHECK_VISUAL_RECT(a, frameView->layoutView()); | 1353 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); |
| 1342 CHECK_VISUAL_RECT(b, frameView->layoutView()); | 1354 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); |
| 1343 } | 1355 } |
| 1344 | 1356 |
| 1345 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveIsNotFlattened) | 1357 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveIsNotFlattened) |
| 1346 { | 1358 { |
| 1347 // It's necessary to make nodes from the one that applies perspective to | 1359 // It's necessary to make nodes from the one that applies perspective to |
| 1348 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't | 1360 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't |
| 1349 // do anything. | 1361 // do anything. |
| 1350 setBodyInnerHTML( | 1362 setBodyInnerHTML( |
| 1351 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" | 1363 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" |
| 1352 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20p
x'></div>" | 1364 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20p
x'></div>" |
| 1353 "</div>"); | 1365 "</div>"); |
| 1354 FrameView* frameView = document().view(); | 1366 FrameView* frameView = document().view(); |
| 1355 | 1367 |
| 1356 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1368 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1357 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1369 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1358 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1370 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); |
| 1359 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1371 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1360 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); | 1372 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); |
| 1361 ASSERT_TRUE(aPerspective); | 1373 ASSERT_TRUE(aPerspective); |
| 1362 const TransformPaintPropertyNode* bTransform = bProperties->transform(); | 1374 const TransformPaintPropertyNode* bTransform = bProperties->transform(); |
| 1363 ASSERT_TRUE(bTransform); | 1375 ASSERT_TRUE(bTransform); |
| 1364 ASSERT_TRUE(nodeHasAncestor(bTransform, aPerspective)); | 1376 ASSERT_TRUE(nodeHasAncestor(bTransform, aPerspective)); |
| 1365 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aPerspective)); | 1377 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aPerspective)); |
| 1366 CHECK_VISUAL_RECT(a, frameView->layoutView()); | 1378 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); |
| 1367 CHECK_VISUAL_RECT(b, frameView->layoutView()); | 1379 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); |
| 1368 } | 1380 } |
| 1369 | 1381 |
| 1370 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveDoesNotEstablishRenderingContext
) | 1382 TEST_F(PaintPropertyTreeBuilderTest, PerspectiveDoesNotEstablishRenderingContext
) |
| 1371 { | 1383 { |
| 1372 // It's necessary to make nodes from the one that applies perspective to | 1384 // It's necessary to make nodes from the one that applies perspective to |
| 1373 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't | 1385 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't |
| 1374 // do anything. | 1386 // do anything. |
| 1375 setBodyInnerHTML( | 1387 setBodyInnerHTML( |
| 1376 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" | 1388 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" |
| 1377 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20p
x'></div>" | 1389 " <div id='b' style='transform: translateZ(0); width: 10px; height: 20p
x'></div>" |
| 1378 "</div>"); | 1390 "</div>"); |
| 1379 FrameView* frameView = document().view(); | 1391 FrameView* frameView = document().view(); |
| 1380 | 1392 |
| 1381 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1393 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1382 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1394 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1383 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1395 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); |
| 1384 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1396 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); |
| 1385 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); | 1397 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); |
| 1386 ASSERT_TRUE(aPerspective); | 1398 ASSERT_TRUE(aPerspective); |
| 1387 EXPECT_FALSE(aPerspective->hasRenderingContext()); | 1399 EXPECT_FALSE(aPerspective->hasRenderingContext()); |
| 1388 const TransformPaintPropertyNode* bTransform = bProperties->transform(); | 1400 const TransformPaintPropertyNode* bTransform = bProperties->transform(); |
| 1389 ASSERT_TRUE(bTransform); | 1401 ASSERT_TRUE(bTransform); |
| 1390 EXPECT_FALSE(bTransform->hasRenderingContext()); | 1402 EXPECT_FALSE(bTransform->hasRenderingContext()); |
| 1391 CHECK_VISUAL_RECT(a, frameView->layoutView()); | 1403 CHECK_EXACT_VISUAL_RECT(a, frameView->layoutView()); |
| 1392 CHECK_VISUAL_RECT(b, frameView->layoutView()); | 1404 CHECK_EXACT_VISUAL_RECT(b, frameView->layoutView()); |
| 1393 } | 1405 } |
| 1394 | 1406 |
| 1395 TEST_F(PaintPropertyTreeBuilderTest, CachedProperties) | 1407 TEST_F(PaintPropertyTreeBuilderTest, CachedProperties) |
| 1396 { | 1408 { |
| 1397 setBodyInnerHTML( | 1409 setBodyInnerHTML( |
| 1398 "<div id='a' style='transform: translate(33px, 44px); width: 50px; heigh
t: 60px'>" | 1410 "<div id='a' style='transform: translate(33px, 44px); width: 50px; heigh
t: 60px'>" |
| 1399 " <div id='b' style='transform: translate(55px, 66px); width: 30px; hei
ght: 40px'>" | 1411 " <div id='b' style='transform: translate(55px, 66px); width: 30px; hei
ght: 40px'>" |
| 1400 " <div id='c' style='transform: translate(77px, 88px); width: 10px; h
eight: 20px'>C<div>" | 1412 " <div id='c' style='transform: translate(77px, 88px); width: 10px; h
eight: 20px'>C<div>" |
| 1401 " </div>" | 1413 " </div>" |
| 1402 "</div>"); | 1414 "</div>"); |
| 1403 FrameView* frameView = document().view(); | 1415 FrameView* frameView = document().view(); |
| 1404 | 1416 |
| 1405 Element* a = document().getElementById("a"); | 1417 Element* a = document().getElementById("a"); |
| 1406 const ObjectPaintProperties* aProperties = a->layoutObject()->objectPaintPro
perties(); | 1418 const ObjectPaintProperties* aProperties = a->layoutObject()->objectPaintPro
perties(); |
| 1407 const TransformPaintPropertyNode* aTransformNode = aProperties->transform(); | 1419 const TransformPaintPropertyNode* aTransformNode = aProperties->transform(); |
| 1408 EXPECT_EQ(TransformationMatrix().translate(33, 44), aTransformNode->matrix()
); | 1420 EXPECT_EQ(TransformationMatrix().translate(33, 44), aTransformNode->matrix()
); |
| 1409 | 1421 |
| 1410 Element* b = document().getElementById("b"); | 1422 Element* b = document().getElementById("b"); |
| 1411 const ObjectPaintProperties* bProperties = b->layoutObject()->objectPaintPro
perties(); | 1423 const ObjectPaintProperties* bProperties = b->layoutObject()->objectPaintPro
perties(); |
| 1412 const TransformPaintPropertyNode* bTransformNode = bProperties->transform(); | 1424 const TransformPaintPropertyNode* bTransformNode = bProperties->transform(); |
| 1413 EXPECT_EQ(TransformationMatrix().translate(55, 66), bTransformNode->matrix()
); | 1425 EXPECT_EQ(TransformationMatrix().translate(55, 66), bTransformNode->matrix()
); |
| 1414 | 1426 |
| 1415 Element* c = document().getElementById("c"); | 1427 Element* c = document().getElementById("c"); |
| 1416 const ObjectPaintProperties* cProperties = c->layoutObject()->objectPaintPro
perties(); | 1428 const ObjectPaintProperties* cProperties = c->layoutObject()->objectPaintPro
perties(); |
| 1417 const TransformPaintPropertyNode* cTransformNode = cProperties->transform(); | 1429 const TransformPaintPropertyNode* cTransformNode = cProperties->transform(); |
| 1418 EXPECT_EQ(TransformationMatrix().translate(77, 88), cTransformNode->matrix()
); | 1430 EXPECT_EQ(TransformationMatrix().translate(77, 88), cTransformNode->matrix()
); |
| 1419 | 1431 |
| 1420 CHECK_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); | 1432 CHECK_EXACT_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); |
| 1421 CHECK_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); | 1433 CHECK_EXACT_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); |
| 1422 CHECK_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); | 1434 CHECK_EXACT_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); |
| 1423 | 1435 |
| 1424 // Change transform of b. B's transform node should be a new node with the n
ew value, | 1436 // Change transform of b. B's transform node should be a new node with the n
ew value, |
| 1425 // and a and c's transform nodes should be unchanged (with c's parent adjust
ed). | 1437 // and a and c's transform nodes should be unchanged (with c's parent adjust
ed). |
| 1426 b->setAttribute(HTMLNames::styleAttr, "transform: translate(111px, 222px)"); | 1438 b->setAttribute(HTMLNames::styleAttr, "transform: translate(111px, 222px)"); |
| 1427 document().view()->updateAllLifecyclePhases(); | 1439 document().view()->updateAllLifecyclePhases(); |
| 1428 | 1440 |
| 1429 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); | 1441 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); |
| 1430 EXPECT_EQ(aTransformNode, aProperties->transform()); | 1442 EXPECT_EQ(aTransformNode, aProperties->transform()); |
| 1431 | 1443 |
| 1432 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); | 1444 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); |
| 1433 bTransformNode = bProperties->transform(); | 1445 bTransformNode = bProperties->transform(); |
| 1434 EXPECT_EQ(TransformationMatrix().translate(111, 222), bTransformNode->matrix
()); | 1446 EXPECT_EQ(TransformationMatrix().translate(111, 222), bTransformNode->matrix
()); |
| 1435 EXPECT_EQ(aTransformNode, bTransformNode->parent()); | 1447 EXPECT_EQ(aTransformNode, bTransformNode->parent()); |
| 1436 | 1448 |
| 1437 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); | 1449 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); |
| 1438 EXPECT_EQ(cTransformNode, cProperties->transform()); | 1450 EXPECT_EQ(cTransformNode, cProperties->transform()); |
| 1439 EXPECT_EQ(bTransformNode, cTransformNode->parent()); | 1451 EXPECT_EQ(bTransformNode, cTransformNode->parent()); |
| 1440 | 1452 |
| 1441 CHECK_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); | 1453 CHECK_EXACT_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); |
| 1442 CHECK_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); | 1454 CHECK_EXACT_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); |
| 1443 CHECK_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); | 1455 CHECK_EXACT_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); |
| 1444 | 1456 |
| 1445 // Remove transform from b. B's transform node should be removed from the tr
ee, | 1457 // Remove transform from b. B's transform node should be removed from the tr
ee, |
| 1446 // and a and c's transform nodes should be unchanged (with c's parent adjust
ed). | 1458 // and a and c's transform nodes should be unchanged (with c's parent adjust
ed). |
| 1447 b->setAttribute(HTMLNames::styleAttr, ""); | 1459 b->setAttribute(HTMLNames::styleAttr, ""); |
| 1448 document().view()->updateAllLifecyclePhases(); | 1460 document().view()->updateAllLifecyclePhases(); |
| 1449 | 1461 |
| 1450 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); | 1462 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); |
| 1451 EXPECT_EQ(aTransformNode, aProperties->transform()); | 1463 EXPECT_EQ(aTransformNode, aProperties->transform()); |
| 1452 | 1464 |
| 1453 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); | 1465 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); |
| 1454 EXPECT_EQ(nullptr, bProperties->transform()); | 1466 EXPECT_EQ(nullptr, bProperties->transform()); |
| 1455 | 1467 |
| 1456 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); | 1468 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); |
| 1457 EXPECT_EQ(cTransformNode, cProperties->transform()); | 1469 EXPECT_EQ(cTransformNode, cProperties->transform()); |
| 1458 EXPECT_EQ(aTransformNode, cTransformNode->parent()); | 1470 EXPECT_EQ(aTransformNode, cTransformNode->parent()); |
| 1459 | 1471 |
| 1460 CHECK_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); | 1472 CHECK_EXACT_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); |
| 1461 CHECK_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); | 1473 CHECK_EXACT_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); |
| 1462 CHECK_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); | 1474 CHECK_EXACT_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); |
| 1463 | 1475 |
| 1464 // Re-add transform to b. B's transform node should be inserted into the tre
e, | 1476 // Re-add transform to b. B's transform node should be inserted into the tre
e, |
| 1465 // and a and c's transform nodes should be unchanged (with c's parent adjust
ed). | 1477 // and a and c's transform nodes should be unchanged (with c's parent adjust
ed). |
| 1466 b->setAttribute(HTMLNames::styleAttr, "transform: translate(4px, 5px)"); | 1478 b->setAttribute(HTMLNames::styleAttr, "transform: translate(4px, 5px)"); |
| 1467 document().view()->updateAllLifecyclePhases(); | 1479 document().view()->updateAllLifecyclePhases(); |
| 1468 | 1480 |
| 1469 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); | 1481 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); |
| 1470 EXPECT_EQ(aTransformNode, aProperties->transform()); | 1482 EXPECT_EQ(aTransformNode, aProperties->transform()); |
| 1471 | 1483 |
| 1472 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); | 1484 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); |
| 1473 bTransformNode = bProperties->transform(); | 1485 bTransformNode = bProperties->transform(); |
| 1474 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix()); | 1486 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix()); |
| 1475 EXPECT_EQ(aTransformNode, bTransformNode->parent()); | 1487 EXPECT_EQ(aTransformNode, bTransformNode->parent()); |
| 1476 | 1488 |
| 1477 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); | 1489 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); |
| 1478 EXPECT_EQ(cTransformNode, cProperties->transform()); | 1490 EXPECT_EQ(cTransformNode, cProperties->transform()); |
| 1479 EXPECT_EQ(bTransformNode, cTransformNode->parent()); | 1491 EXPECT_EQ(bTransformNode, cTransformNode->parent()); |
| 1480 | 1492 |
| 1481 CHECK_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); | 1493 CHECK_EXACT_VISUAL_RECT(a->layoutObject(), frameView->layoutView()); |
| 1482 CHECK_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); | 1494 CHECK_EXACT_VISUAL_RECT(b->layoutObject(), frameView->layoutView()); |
| 1483 CHECK_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); | 1495 CHECK_EXACT_VISUAL_RECT(c->layoutObject(), frameView->layoutView()); |
| 1484 } | 1496 } |
| 1485 | 1497 |
| 1486 } // namespace blink | 1498 } // namespace blink |
| OLD | NEW |