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