| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/layout/LayoutTestHelper.h" | 5 #include "core/layout/LayoutTestHelper.h" |
| 6 #include "core/layout/LayoutTreeAsText.h" | 6 #include "core/layout/LayoutTreeAsText.h" |
| 7 #include "core/layout/api/LayoutViewItem.h" | 7 #include "core/layout/api/LayoutViewItem.h" |
| 8 #include "core/paint/ObjectPaintProperties.h" | 8 #include "core/paint/ObjectPaintProperties.h" |
| 9 #include "core/paint/PaintPropertyTreePrinter.h" | 9 #include "core/paint/PaintPropertyTreePrinter.h" |
| 10 #include "platform/graphics/paint/GeometryMapper.h" | 10 #include "platform/graphics/paint/GeometryMapper.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 fullPath.append("/Source/core/paint/test_data/"); | 36 fullPath.append("/Source/core/paint/test_data/"); |
| 37 fullPath.append(fileName); | 37 fullPath.append(fileName); |
| 38 RefPtr<SharedBuffer> inputBuffer = testing::readFromFile(fullPath); | 38 RefPtr<SharedBuffer> inputBuffer = testing::readFromFile(fullPath); |
| 39 setBodyInnerHTML(String(inputBuffer->data(), inputBuffer->size())); | 39 setBodyInnerHTML(String(inputBuffer->data(), inputBuffer->size())); |
| 40 } | 40 } |
| 41 | 41 |
| 42 const TransformPaintPropertyNode* framePreTranslation() { | 42 const TransformPaintPropertyNode* framePreTranslation() { |
| 43 FrameView* frameView = document().view(); | 43 FrameView* frameView = document().view(); |
| 44 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | 44 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
| 45 return frameView->layoutView() | 45 return frameView->layoutView() |
| 46 ->objectPaintProperties() | 46 ->paintProperties() |
| 47 ->paintOffsetTranslation(); | 47 ->paintOffsetTranslation(); |
| 48 return frameView->preTranslation(); | 48 return frameView->preTranslation(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 const TransformPaintPropertyNode* frameScrollTranslation() { | 51 const TransformPaintPropertyNode* frameScrollTranslation() { |
| 52 FrameView* frameView = document().view(); | 52 FrameView* frameView = document().view(); |
| 53 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | 53 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
| 54 return frameView->layoutView() | 54 return frameView->layoutView()->paintProperties()->scrollTranslation(); |
| 55 ->objectPaintProperties() | |
| 56 ->scrollTranslation(); | |
| 57 return frameView->scrollTranslation(); | 55 return frameView->scrollTranslation(); |
| 58 } | 56 } |
| 59 | 57 |
| 60 const ClipPaintPropertyNode* frameContentClip() { | 58 const ClipPaintPropertyNode* frameContentClip() { |
| 61 FrameView* frameView = document().view(); | 59 FrameView* frameView = document().view(); |
| 62 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | 60 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
| 63 return frameView->layoutView()->objectPaintProperties()->overflowClip(); | 61 return frameView->layoutView()->paintProperties()->overflowClip(); |
| 64 return frameView->contentClip(); | 62 return frameView->contentClip(); |
| 65 } | 63 } |
| 66 | 64 |
| 67 const ScrollPaintPropertyNode* frameScroll() { | 65 const ScrollPaintPropertyNode* frameScroll() { |
| 68 FrameView* frameView = document().view(); | 66 FrameView* frameView = document().view(); |
| 69 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | 67 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
| 70 return frameView->layoutView()->objectPaintProperties()->scroll(); | 68 return frameView->layoutView()->paintProperties()->scroll(); |
| 71 return frameView->scroll(); | 69 return frameView->scroll(); |
| 72 } | 70 } |
| 73 | 71 |
| 74 LayoutPoint paintOffset(const LayoutObject* object) { | 72 LayoutPoint paintOffset(const LayoutObject* object) { |
| 75 return object->objectPaintProperties() | 73 return object->paintProperties()->localBorderBoxProperties()->paintOffset; |
| 76 ->localBorderBoxProperties() | |
| 77 ->paintOffset; | |
| 78 } | 74 } |
| 79 | 75 |
| 80 private: | 76 private: |
| 81 void SetUp() override { | 77 void SetUp() override { |
| 82 Settings::setMockScrollbarsEnabled(true); | 78 Settings::setMockScrollbarsEnabled(true); |
| 83 | 79 |
| 84 RenderingTest::SetUp(); | 80 RenderingTest::SetUp(); |
| 85 enableCompositing(); | 81 enableCompositing(); |
| 86 } | 82 } |
| 87 | 83 |
| 88 void TearDown() override { | 84 void TearDown() override { |
| 89 RenderingTest::TearDown(); | 85 RenderingTest::TearDown(); |
| 90 | 86 |
| 91 Settings::setMockScrollbarsEnabled(false); | 87 Settings::setMockScrollbarsEnabled(false); |
| 92 } | 88 } |
| 93 }; | 89 }; |
| 94 | 90 |
| 95 #define CHECK_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObject, \ | 91 #define CHECK_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObject, \ |
| 96 slopFactor) \ | 92 slopFactor) \ |
| 97 do { \ | 93 do { \ |
| 98 GeometryMapper geometryMapper; \ | 94 GeometryMapper geometryMapper; \ |
| 99 LayoutRect source( \ | 95 LayoutRect source( \ |
| 100 (sourceLayoutObject)->localOverflowRectForPaintInvalidation()); \ | 96 (sourceLayoutObject)->localOverflowRectForPaintInvalidation()); \ |
| 101 source.moveBy((sourceLayoutObject) \ | 97 source.moveBy((sourceLayoutObject) \ |
| 102 ->objectPaintProperties() \ | 98 ->paintProperties() \ |
| 103 ->localBorderBoxProperties() \ | 99 ->localBorderBoxProperties() \ |
| 104 ->paintOffset); \ | 100 ->paintOffset); \ |
| 105 bool success = false; \ | 101 bool success = false; \ |
| 106 auto contentsProperties = \ | 102 auto contentsProperties = \ |
| 107 (ancestorLayoutObject)->objectPaintProperties()->contentsProperties(); \ | 103 (ancestorLayoutObject)->paintProperties()->contentsProperties(); \ |
| 108 LayoutRect actual = \ | 104 LayoutRect actual = \ |
| 109 LayoutRect(geometryMapper.mapToVisualRectInDestinationSpace( \ | 105 LayoutRect(geometryMapper.mapToVisualRectInDestinationSpace( \ |
| 110 FloatRect(source), (sourceLayoutObject) \ | 106 FloatRect(source), (sourceLayoutObject) \ |
| 111 ->objectPaintProperties() \ | 107 ->paintProperties() \ |
| 112 ->localBorderBoxProperties() \ | 108 ->localBorderBoxProperties() \ |
| 113 ->propertyTreeState, \ | 109 ->propertyTreeState, \ |
| 114 contentsProperties.propertyTreeState, success)); \ | 110 contentsProperties.propertyTreeState, success)); \ |
| 115 ASSERT_TRUE(success); \ | 111 ASSERT_TRUE(success); \ |
| 116 actual.moveBy(-contentsProperties.paintOffset); \ | 112 actual.moveBy(-contentsProperties.paintOffset); \ |
| 117 EXPECT_EQ(expected, actual) \ | 113 EXPECT_EQ(expected, actual) \ |
| 118 << "GeometryMapper: expected: " << expected.toString() \ | 114 << "GeometryMapper: expected: " << expected.toString() \ |
| 119 << ", actual: " << actual.toString(); \ | 115 << ", actual: " << actual.toString(); \ |
| 120 \ | 116 \ |
| 121 if (slopFactor == LayoutUnit::max()) \ | 117 if (slopFactor == LayoutUnit::max()) \ |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 transformedScroll->setScrollTop(5); | 152 transformedScroll->setScrollTop(5); |
| 157 | 153 |
| 158 FrameView* frameView = document().view(); | 154 FrameView* frameView = document().view(); |
| 159 frameView->updateAllLifecyclePhases(); | 155 frameView->updateAllLifecyclePhases(); |
| 160 | 156 |
| 161 // target1 is a fixed-position element inside an absolute-position scrolling | 157 // target1 is a fixed-position element inside an absolute-position scrolling |
| 162 // element. It should be attached under the viewport to skip scrolling and | 158 // element. It should be attached under the viewport to skip scrolling and |
| 163 // offset of the parent. | 159 // offset of the parent. |
| 164 Element* target1 = document().getElementById("target1"); | 160 Element* target1 = document().getElementById("target1"); |
| 165 const ObjectPaintProperties* target1Properties = | 161 const ObjectPaintProperties* target1Properties = |
| 166 target1->layoutObject()->objectPaintProperties(); | 162 target1->layoutObject()->paintProperties(); |
| 167 EXPECT_EQ(TransformationMatrix().translate(200, 150), | 163 EXPECT_EQ(TransformationMatrix().translate(200, 150), |
| 168 target1Properties->paintOffsetTranslation()->matrix()); | 164 target1Properties->paintOffsetTranslation()->matrix()); |
| 169 EXPECT_EQ(framePreTranslation(), | 165 EXPECT_EQ(framePreTranslation(), |
| 170 target1Properties->paintOffsetTranslation()->parent()); | 166 target1Properties->paintOffsetTranslation()->parent()); |
| 171 EXPECT_EQ(target1Properties->paintOffsetTranslation(), | 167 EXPECT_EQ(target1Properties->paintOffsetTranslation(), |
| 172 target1Properties->overflowClip()->localTransformSpace()); | 168 target1Properties->overflowClip()->localTransformSpace()); |
| 173 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), | 169 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), |
| 174 target1Properties->overflowClip()->clipRect()); | 170 target1Properties->overflowClip()->clipRect()); |
| 175 // Likewise, it inherits clip from the viewport, skipping overflow clip of the | 171 // Likewise, it inherits clip from the viewport, skipping overflow clip of the |
| 176 // scroller. | 172 // scroller. |
| 177 EXPECT_EQ(frameContentClip(), target1Properties->overflowClip()->parent()); | 173 EXPECT_EQ(frameContentClip(), target1Properties->overflowClip()->parent()); |
| 178 // target1 should not have it's own scroll node and instead should inherit | 174 // target1 should not have it's own scroll node and instead should inherit |
| 179 // positionedScroll's. | 175 // positionedScroll's. |
| 180 const ObjectPaintProperties* positionedScrollProperties = | 176 const ObjectPaintProperties* positionedScrollProperties = |
| 181 positionedScroll->layoutObject()->objectPaintProperties(); | 177 positionedScroll->layoutObject()->paintProperties(); |
| 182 EXPECT_TRUE(positionedScrollProperties->scroll()->parent()->isRoot()); | 178 EXPECT_TRUE(positionedScrollProperties->scroll()->parent()->isRoot()); |
| 183 EXPECT_EQ(TransformationMatrix().translate(0, -3), | 179 EXPECT_EQ(TransformationMatrix().translate(0, -3), |
| 184 positionedScrollProperties->scroll() | 180 positionedScrollProperties->scroll() |
| 185 ->scrollOffsetTranslation() | 181 ->scrollOffsetTranslation() |
| 186 ->matrix()); | 182 ->matrix()); |
| 187 EXPECT_EQ(nullptr, target1Properties->scroll()); | 183 EXPECT_EQ(nullptr, target1Properties->scroll()); |
| 188 | 184 |
| 189 CHECK_EXACT_VISUAL_RECT(LayoutRect(200, 150, 100, 100), | 185 CHECK_EXACT_VISUAL_RECT(LayoutRect(200, 150, 100, 100), |
| 190 target1->layoutObject(), frameView->layoutView()); | 186 target1->layoutObject(), frameView->layoutView()); |
| 191 | 187 |
| 192 // target2 is a fixed-position element inside a transformed scrolling element. | 188 // target2 is a fixed-position element inside a transformed scrolling element. |
| 193 // It should be attached under the scrolled box of the transformed element. | 189 // It should be attached under the scrolled box of the transformed element. |
| 194 Element* target2 = document().getElementById("target2"); | 190 Element* target2 = document().getElementById("target2"); |
| 195 const ObjectPaintProperties* target2Properties = | 191 const ObjectPaintProperties* target2Properties = |
| 196 target2->layoutObject()->objectPaintProperties(); | 192 target2->layoutObject()->paintProperties(); |
| 197 Element* scroller = document().getElementById("transformedScroll"); | 193 Element* scroller = document().getElementById("transformedScroll"); |
| 198 const ObjectPaintProperties* scrollerProperties = | 194 const ObjectPaintProperties* scrollerProperties = |
| 199 scroller->layoutObject()->objectPaintProperties(); | 195 scroller->layoutObject()->paintProperties(); |
| 200 EXPECT_EQ(TransformationMatrix().translate(200, 150), | 196 EXPECT_EQ(TransformationMatrix().translate(200, 150), |
| 201 target2Properties->paintOffsetTranslation()->matrix()); | 197 target2Properties->paintOffsetTranslation()->matrix()); |
| 202 EXPECT_EQ(scrollerProperties->scrollTranslation(), | 198 EXPECT_EQ(scrollerProperties->scrollTranslation(), |
| 203 target2Properties->paintOffsetTranslation()->parent()); | 199 target2Properties->paintOffsetTranslation()->parent()); |
| 204 EXPECT_EQ(target2Properties->paintOffsetTranslation(), | 200 EXPECT_EQ(target2Properties->paintOffsetTranslation(), |
| 205 target2Properties->overflowClip()->localTransformSpace()); | 201 target2Properties->overflowClip()->localTransformSpace()); |
| 206 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), | 202 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), |
| 207 target2Properties->overflowClip()->clipRect()); | 203 target2Properties->overflowClip()->clipRect()); |
| 208 EXPECT_EQ(scrollerProperties->overflowClip(), | 204 EXPECT_EQ(scrollerProperties->overflowClip(), |
| 209 target2Properties->overflowClip()->parent()); | 205 target2Properties->overflowClip()->parent()); |
| 210 // target2 should not have it's own scroll node and instead should inherit | 206 // target2 should not have it's own scroll node and instead should inherit |
| 211 // transformedScroll's. | 207 // transformedScroll's. |
| 212 const ObjectPaintProperties* transformedScrollProperties = | 208 const ObjectPaintProperties* transformedScrollProperties = |
| 213 transformedScroll->layoutObject()->objectPaintProperties(); | 209 transformedScroll->layoutObject()->paintProperties(); |
| 214 EXPECT_TRUE(transformedScrollProperties->scroll()->parent()->isRoot()); | 210 EXPECT_TRUE(transformedScrollProperties->scroll()->parent()->isRoot()); |
| 215 EXPECT_EQ(TransformationMatrix().translate(0, -5), | 211 EXPECT_EQ(TransformationMatrix().translate(0, -5), |
| 216 transformedScrollProperties->scroll() | 212 transformedScrollProperties->scroll() |
| 217 ->scrollOffsetTranslation() | 213 ->scrollOffsetTranslation() |
| 218 ->matrix()); | 214 ->matrix()); |
| 219 EXPECT_EQ(nullptr, target2Properties->scroll()); | 215 EXPECT_EQ(nullptr, target2Properties->scroll()); |
| 220 | 216 |
| 221 CHECK_EXACT_VISUAL_RECT(LayoutRect(208, 153, 200, 100), | 217 CHECK_EXACT_VISUAL_RECT(LayoutRect(208, 153, 200, 100), |
| 222 target2->layoutObject(), frameView->layoutView()); | 218 target2->layoutObject(), frameView->layoutView()); |
| 223 } | 219 } |
| 224 | 220 |
| 225 TEST_P(PaintPropertyTreeBuilderTest, PositionAndScroll) { | 221 TEST_P(PaintPropertyTreeBuilderTest, PositionAndScroll) { |
| 226 loadTestData("position-and-scroll.html"); | 222 loadTestData("position-and-scroll.html"); |
| 227 | 223 |
| 228 Element* scroller = document().getElementById("scroller"); | 224 Element* scroller = document().getElementById("scroller"); |
| 229 scroller->scrollTo(0, 100); | 225 scroller->scrollTo(0, 100); |
| 230 FrameView* frameView = document().view(); | 226 FrameView* frameView = document().view(); |
| 231 frameView->updateAllLifecyclePhases(); | 227 frameView->updateAllLifecyclePhases(); |
| 232 const ObjectPaintProperties* scrollerProperties = | 228 const ObjectPaintProperties* scrollerProperties = |
| 233 scroller->layoutObject()->objectPaintProperties(); | 229 scroller->layoutObject()->paintProperties(); |
| 234 EXPECT_EQ(TransformationMatrix().translate(0, -100), | 230 EXPECT_EQ(TransformationMatrix().translate(0, -100), |
| 235 scrollerProperties->scrollTranslation()->matrix()); | 231 scrollerProperties->scrollTranslation()->matrix()); |
| 236 EXPECT_EQ(frameScrollTranslation(), | 232 EXPECT_EQ(frameScrollTranslation(), |
| 237 scrollerProperties->scrollTranslation()->parent()); | 233 scrollerProperties->scrollTranslation()->parent()); |
| 238 EXPECT_EQ(frameScrollTranslation(), | 234 EXPECT_EQ(frameScrollTranslation(), |
| 239 scrollerProperties->overflowClip()->localTransformSpace()); | 235 scrollerProperties->overflowClip()->localTransformSpace()); |
| 240 EXPECT_EQ(frameScroll(), scrollerProperties->scroll()->parent()); | 236 EXPECT_EQ(frameScroll(), scrollerProperties->scroll()->parent()); |
| 241 EXPECT_EQ(FloatSize(413, 317), scrollerProperties->scroll()->clip()); | 237 EXPECT_EQ(FloatSize(413, 317), scrollerProperties->scroll()->clip()); |
| 242 EXPECT_EQ(FloatSize(660, 10200), scrollerProperties->scroll()->bounds()); | 238 EXPECT_EQ(FloatSize(660, 10200), scrollerProperties->scroll()->bounds()); |
| 243 EXPECT_FALSE(scrollerProperties->scroll()->userScrollableHorizontal()); | 239 EXPECT_FALSE(scrollerProperties->scroll()->userScrollableHorizontal()); |
| 244 EXPECT_TRUE(scrollerProperties->scroll()->userScrollableVertical()); | 240 EXPECT_TRUE(scrollerProperties->scroll()->userScrollableVertical()); |
| 245 EXPECT_EQ(FloatRoundedRect(120, 340, 413, 317), | 241 EXPECT_EQ(FloatRoundedRect(120, 340, 413, 317), |
| 246 scrollerProperties->overflowClip()->clipRect()); | 242 scrollerProperties->overflowClip()->clipRect()); |
| 247 EXPECT_EQ(frameContentClip(), scrollerProperties->overflowClip()->parent()); | 243 EXPECT_EQ(frameContentClip(), scrollerProperties->overflowClip()->parent()); |
| 248 // http://crbug.com/638415 | 244 // http://crbug.com/638415 |
| 249 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 245 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 250 CHECK_EXACT_VISUAL_RECT(LayoutRect(120, 340, 413, 317), | 246 CHECK_EXACT_VISUAL_RECT(LayoutRect(120, 340, 413, 317), |
| 251 scroller->layoutObject(), frameView->layoutView()); | 247 scroller->layoutObject(), frameView->layoutView()); |
| 252 } | 248 } |
| 253 | 249 |
| 254 // The relative-positioned element should have accumulated box offset (exclude | 250 // The relative-positioned element should have accumulated box offset (exclude |
| 255 // scrolling), and should be affected by ancestor scroll transforms. | 251 // scrolling), and should be affected by ancestor scroll transforms. |
| 256 Element* relPos = document().getElementById("rel-pos"); | 252 Element* relPos = document().getElementById("rel-pos"); |
| 257 const ObjectPaintProperties* relPosProperties = | 253 const ObjectPaintProperties* relPosProperties = |
| 258 relPos->layoutObject()->objectPaintProperties(); | 254 relPos->layoutObject()->paintProperties(); |
| 259 EXPECT_EQ(TransformationMatrix().translate(680, 1120), | 255 EXPECT_EQ(TransformationMatrix().translate(680, 1120), |
| 260 relPosProperties->paintOffsetTranslation()->matrix()); | 256 relPosProperties->paintOffsetTranslation()->matrix()); |
| 261 EXPECT_EQ(scrollerProperties->scrollTranslation(), | 257 EXPECT_EQ(scrollerProperties->scrollTranslation(), |
| 262 relPosProperties->paintOffsetTranslation()->parent()); | 258 relPosProperties->paintOffsetTranslation()->parent()); |
| 263 EXPECT_EQ(relPosProperties->transform(), | 259 EXPECT_EQ(relPosProperties->transform(), |
| 264 relPosProperties->overflowClip()->localTransformSpace()); | 260 relPosProperties->overflowClip()->localTransformSpace()); |
| 265 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 200), | 261 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 200), |
| 266 relPosProperties->overflowClip()->clipRect()); | 262 relPosProperties->overflowClip()->clipRect()); |
| 267 EXPECT_EQ(scrollerProperties->overflowClip(), | 263 EXPECT_EQ(scrollerProperties->overflowClip(), |
| 268 relPosProperties->overflowClip()->parent()); | 264 relPosProperties->overflowClip()->parent()); |
| 269 CHECK_EXACT_VISUAL_RECT(LayoutRect(), relPos->layoutObject(), | 265 CHECK_EXACT_VISUAL_RECT(LayoutRect(), relPos->layoutObject(), |
| 270 frameView->layoutView()); | 266 frameView->layoutView()); |
| 271 | 267 |
| 272 // The absolute-positioned element should not be affected by non-positioned | 268 // The absolute-positioned element should not be affected by non-positioned |
| 273 // scroller at all. | 269 // scroller at all. |
| 274 Element* absPos = document().getElementById("abs-pos"); | 270 Element* absPos = document().getElementById("abs-pos"); |
| 275 const ObjectPaintProperties* absPosProperties = | 271 const ObjectPaintProperties* absPosProperties = |
| 276 absPos->layoutObject()->objectPaintProperties(); | 272 absPos->layoutObject()->paintProperties(); |
| 277 EXPECT_EQ(TransformationMatrix().translate(123, 456), | 273 EXPECT_EQ(TransformationMatrix().translate(123, 456), |
| 278 absPosProperties->paintOffsetTranslation()->matrix()); | 274 absPosProperties->paintOffsetTranslation()->matrix()); |
| 279 EXPECT_EQ(frameScrollTranslation(), | 275 EXPECT_EQ(frameScrollTranslation(), |
| 280 absPosProperties->paintOffsetTranslation()->parent()); | 276 absPosProperties->paintOffsetTranslation()->parent()); |
| 281 EXPECT_EQ(absPosProperties->transform(), | 277 EXPECT_EQ(absPosProperties->transform(), |
| 282 absPosProperties->overflowClip()->localTransformSpace()); | 278 absPosProperties->overflowClip()->localTransformSpace()); |
| 283 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400), | 279 EXPECT_EQ(FloatRoundedRect(0, 0, 300, 400), |
| 284 absPosProperties->overflowClip()->clipRect()); | 280 absPosProperties->overflowClip()->clipRect()); |
| 285 EXPECT_EQ(frameContentClip(), absPosProperties->overflowClip()->parent()); | 281 EXPECT_EQ(frameContentClip(), absPosProperties->overflowClip()->parent()); |
| 286 // http://crbug.com/638415 | 282 // http://crbug.com/638415 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 302 | 298 |
| 303 EXPECT_EQ(TransformationMatrix().translate(0, -100), | 299 EXPECT_EQ(TransformationMatrix().translate(0, -100), |
| 304 frameScrollTranslation()->matrix()); | 300 frameScrollTranslation()->matrix()); |
| 305 EXPECT_EQ(framePreTranslation(), frameScrollTranslation()->parent()); | 301 EXPECT_EQ(framePreTranslation(), frameScrollTranslation()->parent()); |
| 306 EXPECT_EQ(framePreTranslation(), frameContentClip()->localTransformSpace()); | 302 EXPECT_EQ(framePreTranslation(), frameContentClip()->localTransformSpace()); |
| 307 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameContentClip()->clipRect()); | 303 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameContentClip()->clipRect()); |
| 308 EXPECT_TRUE(frameContentClip()->parent()->isRoot()); | 304 EXPECT_TRUE(frameContentClip()->parent()->isRoot()); |
| 309 | 305 |
| 310 LayoutViewItem layoutViewItem = document().layoutViewItem(); | 306 LayoutViewItem layoutViewItem = document().layoutViewItem(); |
| 311 const ObjectPaintProperties* layoutViewProperties = | 307 const ObjectPaintProperties* layoutViewProperties = |
| 312 layoutViewItem.objectPaintProperties(); | 308 layoutViewItem.paintProperties(); |
| 313 // http://crbug.com/638415 | 309 // http://crbug.com/638415 |
| 314 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 310 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 315 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation()); | 311 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation()); |
| 316 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 784, 10000), | 312 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 784, 10000), |
| 317 document().body()->layoutObject(), | 313 document().body()->layoutObject(), |
| 318 frameView->layoutView()); | 314 frameView->layoutView()); |
| 319 } | 315 } |
| 320 } | 316 } |
| 321 | 317 |
| 322 TEST_P(PaintPropertyTreeBuilderTest, Perspective) { | 318 TEST_P(PaintPropertyTreeBuilderTest, Perspective) { |
| 323 loadTestData("perspective.html"); | 319 loadTestData("perspective.html"); |
| 324 | 320 |
| 325 Element* perspective = document().getElementById("perspective"); | 321 Element* perspective = document().getElementById("perspective"); |
| 326 const ObjectPaintProperties* perspectiveProperties = | 322 const ObjectPaintProperties* perspectiveProperties = |
| 327 perspective->layoutObject()->objectPaintProperties(); | 323 perspective->layoutObject()->paintProperties(); |
| 328 EXPECT_EQ(TransformationMatrix().applyPerspective(100), | 324 EXPECT_EQ(TransformationMatrix().applyPerspective(100), |
| 329 perspectiveProperties->perspective()->matrix()); | 325 perspectiveProperties->perspective()->matrix()); |
| 330 // The perspective origin is the center of the border box plus accumulated | 326 // The perspective origin is the center of the border box plus accumulated |
| 331 // paint offset. | 327 // paint offset. |
| 332 EXPECT_EQ(FloatPoint3D(250, 250, 0), | 328 EXPECT_EQ(FloatPoint3D(250, 250, 0), |
| 333 perspectiveProperties->perspective()->origin()); | 329 perspectiveProperties->perspective()->origin()); |
| 334 EXPECT_EQ(framePreTranslation(), | 330 EXPECT_EQ(framePreTranslation(), |
| 335 perspectiveProperties->perspective()->parent()); | 331 perspectiveProperties->perspective()->parent()); |
| 336 | 332 |
| 337 // Adding perspective doesn't clear paint offset. The paint offset will be | 333 // Adding perspective doesn't clear paint offset. The paint offset will be |
| 338 // passed down to children. | 334 // passed down to children. |
| 339 Element* inner = document().getElementById("inner"); | 335 Element* inner = document().getElementById("inner"); |
| 340 const ObjectPaintProperties* innerProperties = | 336 const ObjectPaintProperties* innerProperties = |
| 341 inner->layoutObject()->objectPaintProperties(); | 337 inner->layoutObject()->paintProperties(); |
| 342 EXPECT_EQ(TransformationMatrix().translate(50, 100), | 338 EXPECT_EQ(TransformationMatrix().translate(50, 100), |
| 343 innerProperties->paintOffsetTranslation()->matrix()); | 339 innerProperties->paintOffsetTranslation()->matrix()); |
| 344 EXPECT_EQ(perspectiveProperties->perspective(), | 340 EXPECT_EQ(perspectiveProperties->perspective(), |
| 345 innerProperties->paintOffsetTranslation()->parent()); | 341 innerProperties->paintOffsetTranslation()->parent()); |
| 346 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 100, 200), inner->layoutObject(), | 342 CHECK_EXACT_VISUAL_RECT(LayoutRect(50, 100, 100, 200), inner->layoutObject(), |
| 347 document().view()->layoutView()); | 343 document().view()->layoutView()); |
| 348 } | 344 } |
| 349 | 345 |
| 350 TEST_P(PaintPropertyTreeBuilderTest, Transform) { | 346 TEST_P(PaintPropertyTreeBuilderTest, Transform) { |
| 351 loadTestData("transform.html"); | 347 loadTestData("transform.html"); |
| 352 | 348 |
| 353 Element* transform = document().getElementById("transform"); | 349 Element* transform = document().getElementById("transform"); |
| 354 const ObjectPaintProperties* transformProperties = | 350 const ObjectPaintProperties* transformProperties = |
| 355 transform->layoutObject()->objectPaintProperties(); | 351 transform->layoutObject()->paintProperties(); |
| 356 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), | 352 EXPECT_EQ(TransformationMatrix().translate3d(123, 456, 789), |
| 357 transformProperties->transform()->matrix()); | 353 transformProperties->transform()->matrix()); |
| 358 EXPECT_EQ(FloatPoint3D(200, 150, 0), | 354 EXPECT_EQ(FloatPoint3D(200, 150, 0), |
| 359 transformProperties->transform()->origin()); | 355 transformProperties->transform()->origin()); |
| 360 EXPECT_EQ(transformProperties->paintOffsetTranslation(), | 356 EXPECT_EQ(transformProperties->paintOffsetTranslation(), |
| 361 transformProperties->transform()->parent()); | 357 transformProperties->transform()->parent()); |
| 362 EXPECT_EQ(TransformationMatrix().translate(50, 100), | 358 EXPECT_EQ(TransformationMatrix().translate(50, 100), |
| 363 transformProperties->paintOffsetTranslation()->matrix()); | 359 transformProperties->paintOffsetTranslation()->matrix()); |
| 364 EXPECT_EQ(frameScrollTranslation(), | 360 EXPECT_EQ(frameScrollTranslation(), |
| 365 transformProperties->paintOffsetTranslation()->parent()); | 361 transformProperties->paintOffsetTranslation()->parent()); |
| 366 // http://crbug.com/638415 | 362 // http://crbug.com/638415 |
| 367 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 363 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 368 CHECK_EXACT_VISUAL_RECT(LayoutRect(173, 556, 400, 300), | 364 CHECK_EXACT_VISUAL_RECT(LayoutRect(173, 556, 400, 300), |
| 369 transform->layoutObject(), | 365 transform->layoutObject(), |
| 370 document().view()->layoutView()); | 366 document().view()->layoutView()); |
| 371 } | 367 } |
| 372 } | 368 } |
| 373 | 369 |
| 374 TEST_P(PaintPropertyTreeBuilderTest, RelativePositionInline) { | 370 TEST_P(PaintPropertyTreeBuilderTest, RelativePositionInline) { |
| 375 loadTestData("relative-position-inline.html"); | 371 loadTestData("relative-position-inline.html"); |
| 376 | 372 |
| 377 Element* inlineBlock = document().getElementById("inline-block"); | 373 Element* inlineBlock = document().getElementById("inline-block"); |
| 378 const ObjectPaintProperties* inlineBlockProperties = | 374 const ObjectPaintProperties* inlineBlockProperties = |
| 379 inlineBlock->layoutObject()->objectPaintProperties(); | 375 inlineBlock->layoutObject()->paintProperties(); |
| 380 EXPECT_EQ(TransformationMatrix().translate(135, 490), | 376 EXPECT_EQ(TransformationMatrix().translate(135, 490), |
| 381 inlineBlockProperties->paintOffsetTranslation()->matrix()); | 377 inlineBlockProperties->paintOffsetTranslation()->matrix()); |
| 382 EXPECT_EQ(framePreTranslation(), | 378 EXPECT_EQ(framePreTranslation(), |
| 383 inlineBlockProperties->paintOffsetTranslation()->parent()); | 379 inlineBlockProperties->paintOffsetTranslation()->parent()); |
| 384 CHECK_EXACT_VISUAL_RECT(LayoutRect(135, 490, 10, 20), | 380 CHECK_EXACT_VISUAL_RECT(LayoutRect(135, 490, 10, 20), |
| 385 inlineBlock->layoutObject(), | 381 inlineBlock->layoutObject(), |
| 386 document().view()->layoutView()); | 382 document().view()->layoutView()); |
| 387 } | 383 } |
| 388 | 384 |
| 389 TEST_P(PaintPropertyTreeBuilderTest, NestedOpacityEffect) { | 385 TEST_P(PaintPropertyTreeBuilderTest, NestedOpacityEffect) { |
| 390 setBodyInnerHTML( | 386 setBodyInnerHTML( |
| 391 "<div id='nodeWithoutOpacity' style='width: 100px; height: 200px'>" | 387 "<div id='nodeWithoutOpacity' style='width: 100px; height: 200px'>" |
| 392 " <div id='childWithOpacity' style='opacity: 0.5; width: 50px; height: " | 388 " <div id='childWithOpacity' style='opacity: 0.5; width: 50px; height: " |
| 393 "60px;'>" | 389 "60px;'>" |
| 394 " <div id='grandChildWithoutOpacity' style='width: 20px; height: " | 390 " <div id='grandChildWithoutOpacity' style='width: 20px; height: " |
| 395 "30px'>" | 391 "30px'>" |
| 396 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2; width: " | 392 " <div id='greatGrandChildWithOpacity' style='opacity: 0.2; width: " |
| 397 "10px; height: 15px'/>" | 393 "10px; height: 15px'/>" |
| 398 " </div>" | 394 " </div>" |
| 399 " </div>" | 395 " </div>" |
| 400 "</div>"); | 396 "</div>"); |
| 401 | 397 |
| 402 LayoutObject* nodeWithoutOpacity = | 398 LayoutObject* nodeWithoutOpacity = |
| 403 document().getElementById("nodeWithoutOpacity")->layoutObject(); | 399 document().getElementById("nodeWithoutOpacity")->layoutObject(); |
| 404 const ObjectPaintProperties* nodeWithoutOpacityProperties = | 400 const ObjectPaintProperties* nodeWithoutOpacityProperties = |
| 405 nodeWithoutOpacity->objectPaintProperties(); | 401 nodeWithoutOpacity->paintProperties(); |
| 406 EXPECT_NE(nullptr, nodeWithoutOpacityProperties); | 402 EXPECT_NE(nullptr, nodeWithoutOpacityProperties); |
| 407 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 100, 200), nodeWithoutOpacity, | 403 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 100, 200), nodeWithoutOpacity, |
| 408 document().view()->layoutView()); | 404 document().view()->layoutView()); |
| 409 | 405 |
| 410 LayoutObject* childWithOpacity = | 406 LayoutObject* childWithOpacity = |
| 411 document().getElementById("childWithOpacity")->layoutObject(); | 407 document().getElementById("childWithOpacity")->layoutObject(); |
| 412 const ObjectPaintProperties* childWithOpacityProperties = | 408 const ObjectPaintProperties* childWithOpacityProperties = |
| 413 childWithOpacity->objectPaintProperties(); | 409 childWithOpacity->paintProperties(); |
| 414 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity()); | 410 EXPECT_EQ(0.5f, childWithOpacityProperties->effect()->opacity()); |
| 415 // childWithOpacity is the root effect node. | 411 // childWithOpacity is the root effect node. |
| 416 EXPECT_NE(nullptr, childWithOpacityProperties->effect()->parent()); | 412 EXPECT_NE(nullptr, childWithOpacityProperties->effect()->parent()); |
| 417 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 50, 60), childWithOpacity, | 413 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 50, 60), childWithOpacity, |
| 418 document().view()->layoutView()); | 414 document().view()->layoutView()); |
| 419 | 415 |
| 420 LayoutObject* grandChildWithoutOpacity = | 416 LayoutObject* grandChildWithoutOpacity = |
| 421 document().getElementById("grandChildWithoutOpacity")->layoutObject(); | 417 document().getElementById("grandChildWithoutOpacity")->layoutObject(); |
| 422 EXPECT_NE(nullptr, grandChildWithoutOpacity->objectPaintProperties()); | 418 EXPECT_NE(nullptr, grandChildWithoutOpacity->paintProperties()); |
| 423 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 20, 30), grandChildWithoutOpacity, | 419 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 20, 30), grandChildWithoutOpacity, |
| 424 document().view()->layoutView()); | 420 document().view()->layoutView()); |
| 425 | 421 |
| 426 LayoutObject* greatGrandChildWithOpacity = | 422 LayoutObject* greatGrandChildWithOpacity = |
| 427 document().getElementById("greatGrandChildWithOpacity")->layoutObject(); | 423 document().getElementById("greatGrandChildWithOpacity")->layoutObject(); |
| 428 const ObjectPaintProperties* greatGrandChildWithOpacityProperties = | 424 const ObjectPaintProperties* greatGrandChildWithOpacityProperties = |
| 429 greatGrandChildWithOpacity->objectPaintProperties(); | 425 greatGrandChildWithOpacity->paintProperties(); |
| 430 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); | 426 EXPECT_EQ(0.2f, greatGrandChildWithOpacityProperties->effect()->opacity()); |
| 431 EXPECT_EQ(childWithOpacityProperties->effect(), | 427 EXPECT_EQ(childWithOpacityProperties->effect(), |
| 432 greatGrandChildWithOpacityProperties->effect()->parent()); | 428 greatGrandChildWithOpacityProperties->effect()->parent()); |
| 433 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 15), greatGrandChildWithOpacity, | 429 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 15), greatGrandChildWithOpacity, |
| 434 document().view()->layoutView()); | 430 document().view()->layoutView()); |
| 435 } | 431 } |
| 436 | 432 |
| 437 TEST_P(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) { | 433 TEST_P(PaintPropertyTreeBuilderTest, TransformNodeDoesNotAffectEffectNodes) { |
| 438 setBodyInnerHTML( | 434 setBodyInnerHTML( |
| 439 "<div id='nodeWithOpacity' style='opacity: 0.6' style='width: 100px; " | 435 "<div id='nodeWithOpacity' style='opacity: 0.6' style='width: 100px; " |
| 440 "height: 200px'>" | 436 "height: 200px'>" |
| 441 " <div id='childWithTransform' style='transform: translate3d(10px, " | 437 " <div id='childWithTransform' style='transform: translate3d(10px, " |
| 442 "10px, 0px); width: 50px; height: 60px;'>" | 438 "10px, 0px); width: 50px; height: 60px;'>" |
| 443 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; " | 439 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; " |
| 444 "height: 30px'/>" | 440 "height: 30px'/>" |
| 445 " </div>" | 441 " </div>" |
| 446 "</div>"); | 442 "</div>"); |
| 447 | 443 |
| 448 LayoutObject* nodeWithOpacity = | 444 LayoutObject* nodeWithOpacity = |
| 449 document().getElementById("nodeWithOpacity")->layoutObject(); | 445 document().getElementById("nodeWithOpacity")->layoutObject(); |
| 450 const ObjectPaintProperties* nodeWithOpacityProperties = | 446 const ObjectPaintProperties* nodeWithOpacityProperties = |
| 451 nodeWithOpacity->objectPaintProperties(); | 447 nodeWithOpacity->paintProperties(); |
| 452 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); | 448 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); |
| 453 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); | 449 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); |
| 454 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); | 450 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); |
| 455 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 784, 60), nodeWithOpacity, | 451 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 784, 60), nodeWithOpacity, |
| 456 document().view()->layoutView()); | 452 document().view()->layoutView()); |
| 457 | 453 |
| 458 LayoutObject* childWithTransform = | 454 LayoutObject* childWithTransform = |
| 459 document().getElementById("childWithTransform")->layoutObject(); | 455 document().getElementById("childWithTransform")->layoutObject(); |
| 460 const ObjectPaintProperties* childWithTransformProperties = | 456 const ObjectPaintProperties* childWithTransformProperties = |
| 461 childWithTransform->objectPaintProperties(); | 457 childWithTransform->paintProperties(); |
| 462 EXPECT_EQ(nullptr, childWithTransformProperties->effect()); | 458 EXPECT_EQ(nullptr, childWithTransformProperties->effect()); |
| 463 EXPECT_EQ(TransformationMatrix().translate(10, 10), | 459 EXPECT_EQ(TransformationMatrix().translate(10, 10), |
| 464 childWithTransformProperties->transform()->matrix()); | 460 childWithTransformProperties->transform()->matrix()); |
| 465 CHECK_EXACT_VISUAL_RECT(LayoutRect(18, 18, 50, 60), childWithTransform, | 461 CHECK_EXACT_VISUAL_RECT(LayoutRect(18, 18, 50, 60), childWithTransform, |
| 466 document().view()->layoutView()); | 462 document().view()->layoutView()); |
| 467 | 463 |
| 468 LayoutObject* grandChildWithOpacity = | 464 LayoutObject* grandChildWithOpacity = |
| 469 document().getElementById("grandChildWithOpacity")->layoutObject(); | 465 document().getElementById("grandChildWithOpacity")->layoutObject(); |
| 470 const ObjectPaintProperties* grandChildWithOpacityProperties = | 466 const ObjectPaintProperties* grandChildWithOpacityProperties = |
| 471 grandChildWithOpacity->objectPaintProperties(); | 467 grandChildWithOpacity->paintProperties(); |
| 472 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); | 468 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); |
| 473 EXPECT_EQ(nodeWithOpacityProperties->effect(), | 469 EXPECT_EQ(nodeWithOpacityProperties->effect(), |
| 474 grandChildWithOpacityProperties->effect()->parent()); | 470 grandChildWithOpacityProperties->effect()->parent()); |
| 475 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); | 471 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); |
| 476 CHECK_EXACT_VISUAL_RECT(LayoutRect(18, 18, 20, 30), grandChildWithOpacity, | 472 CHECK_EXACT_VISUAL_RECT(LayoutRect(18, 18, 20, 30), grandChildWithOpacity, |
| 477 document().view()->layoutView()); | 473 document().view()->layoutView()); |
| 478 } | 474 } |
| 479 | 475 |
| 480 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) { | 476 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossStackingContext) { |
| 481 setBodyInnerHTML( | 477 setBodyInnerHTML( |
| 482 "<div id='nodeWithOpacity' style='opacity: 0.6; width: 100px; height: " | 478 "<div id='nodeWithOpacity' style='opacity: 0.6; width: 100px; height: " |
| 483 "200px'>" | 479 "200px'>" |
| 484 " <div id='childWithStackingContext' style='position:absolute; width: " | 480 " <div id='childWithStackingContext' style='position:absolute; width: " |
| 485 "50px; height: 60px;'>" | 481 "50px; height: 60px;'>" |
| 486 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; " | 482 " <div id='grandChildWithOpacity' style='opacity: 0.4; width: 20px; " |
| 487 "height: 30px'/>" | 483 "height: 30px'/>" |
| 488 " </div>" | 484 " </div>" |
| 489 "</div>"); | 485 "</div>"); |
| 490 | 486 |
| 491 LayoutObject* nodeWithOpacity = | 487 LayoutObject* nodeWithOpacity = |
| 492 document().getElementById("nodeWithOpacity")->layoutObject(); | 488 document().getElementById("nodeWithOpacity")->layoutObject(); |
| 493 const ObjectPaintProperties* nodeWithOpacityProperties = | 489 const ObjectPaintProperties* nodeWithOpacityProperties = |
| 494 nodeWithOpacity->objectPaintProperties(); | 490 nodeWithOpacity->paintProperties(); |
| 495 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); | 491 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); |
| 496 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); | 492 EXPECT_NE(nullptr, nodeWithOpacityProperties->effect()->parent()); |
| 497 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); | 493 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); |
| 498 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 100, 200), nodeWithOpacity, | 494 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 100, 200), nodeWithOpacity, |
| 499 document().view()->layoutView()); | 495 document().view()->layoutView()); |
| 500 | 496 |
| 501 LayoutObject* childWithStackingContext = | 497 LayoutObject* childWithStackingContext = |
| 502 document().getElementById("childWithStackingContext")->layoutObject(); | 498 document().getElementById("childWithStackingContext")->layoutObject(); |
| 503 const ObjectPaintProperties* childWithStackingContextProperties = | 499 const ObjectPaintProperties* childWithStackingContextProperties = |
| 504 childWithStackingContext->objectPaintProperties(); | 500 childWithStackingContext->paintProperties(); |
| 505 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect()); | 501 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect()); |
| 506 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); | 502 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform()); |
| 507 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 50, 60), childWithStackingContext, | 503 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 50, 60), childWithStackingContext, |
| 508 document().view()->layoutView()); | 504 document().view()->layoutView()); |
| 509 | 505 |
| 510 LayoutObject* grandChildWithOpacity = | 506 LayoutObject* grandChildWithOpacity = |
| 511 document().getElementById("grandChildWithOpacity")->layoutObject(); | 507 document().getElementById("grandChildWithOpacity")->layoutObject(); |
| 512 const ObjectPaintProperties* grandChildWithOpacityProperties = | 508 const ObjectPaintProperties* grandChildWithOpacityProperties = |
| 513 grandChildWithOpacity->objectPaintProperties(); | 509 grandChildWithOpacity->paintProperties(); |
| 514 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); | 510 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); |
| 515 EXPECT_EQ(nodeWithOpacityProperties->effect(), | 511 EXPECT_EQ(nodeWithOpacityProperties->effect(), |
| 516 grandChildWithOpacityProperties->effect()->parent()); | 512 grandChildWithOpacityProperties->effect()->parent()); |
| 517 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); | 513 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); |
| 518 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 20, 30), grandChildWithOpacity, | 514 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 20, 30), grandChildWithOpacity, |
| 519 document().view()->layoutView()); | 515 document().view()->layoutView()); |
| 520 } | 516 } |
| 521 | 517 |
| 522 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesInSVG) { | 518 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesInSVG) { |
| 523 setBodyInnerHTML( | 519 setBodyInnerHTML( |
| 524 "<svg id='svgRoot'>" | 520 "<svg id='svgRoot'>" |
| 525 " <g id='groupWithOpacity' opacity='0.6'>" | 521 " <g id='groupWithOpacity' opacity='0.6'>" |
| 526 " <rect id='rectWithoutOpacity' />" | 522 " <rect id='rectWithoutOpacity' />" |
| 527 " <rect id='rectWithOpacity' opacity='0.4' />" | 523 " <rect id='rectWithOpacity' opacity='0.4' />" |
| 528 " <text id='textWithOpacity' opacity='0.2'>" | 524 " <text id='textWithOpacity' opacity='0.2'>" |
| 529 " <tspan id='tspanWithOpacity' opacity='0.1' />" | 525 " <tspan id='tspanWithOpacity' opacity='0.1' />" |
| 530 " </text>" | 526 " </text>" |
| 531 " </g>" | 527 " </g>" |
| 532 "</svg>"); | 528 "</svg>"); |
| 533 | 529 |
| 534 LayoutObject* groupWithOpacity = | 530 LayoutObject* groupWithOpacity = |
| 535 document().getElementById("groupWithOpacity")->layoutObject(); | 531 document().getElementById("groupWithOpacity")->layoutObject(); |
| 536 const ObjectPaintProperties* groupWithOpacityProperties = | 532 const ObjectPaintProperties* groupWithOpacityProperties = |
| 537 groupWithOpacity->objectPaintProperties(); | 533 groupWithOpacity->paintProperties(); |
| 538 EXPECT_EQ(0.6f, groupWithOpacityProperties->effect()->opacity()); | 534 EXPECT_EQ(0.6f, groupWithOpacityProperties->effect()->opacity()); |
| 539 EXPECT_NE(nullptr, groupWithOpacityProperties->effect()->parent()); | 535 EXPECT_NE(nullptr, groupWithOpacityProperties->effect()->parent()); |
| 540 | 536 |
| 541 LayoutObject& rectWithoutOpacity = | 537 LayoutObject& rectWithoutOpacity = |
| 542 *document().getElementById("rectWithoutOpacity")->layoutObject(); | 538 *document().getElementById("rectWithoutOpacity")->layoutObject(); |
| 543 const ObjectPaintProperties* rectWithoutOpacityProperties = | 539 const ObjectPaintProperties* rectWithoutOpacityProperties = |
| 544 rectWithoutOpacity.objectPaintProperties(); | 540 rectWithoutOpacity.paintProperties(); |
| 545 EXPECT_EQ(nullptr, rectWithoutOpacityProperties); | 541 EXPECT_EQ(nullptr, rectWithoutOpacityProperties); |
| 546 | 542 |
| 547 LayoutObject& rectWithOpacity = | 543 LayoutObject& rectWithOpacity = |
| 548 *document().getElementById("rectWithOpacity")->layoutObject(); | 544 *document().getElementById("rectWithOpacity")->layoutObject(); |
| 549 const ObjectPaintProperties* rectWithOpacityProperties = | 545 const ObjectPaintProperties* rectWithOpacityProperties = |
| 550 rectWithOpacity.objectPaintProperties(); | 546 rectWithOpacity.paintProperties(); |
| 551 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity()); | 547 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity()); |
| 552 EXPECT_EQ(groupWithOpacityProperties->effect(), | 548 EXPECT_EQ(groupWithOpacityProperties->effect(), |
| 553 rectWithOpacityProperties->effect()->parent()); | 549 rectWithOpacityProperties->effect()->parent()); |
| 554 | 550 |
| 555 // Ensure that opacity nodes are created for LayoutSVGText which inherits from | 551 // Ensure that opacity nodes are created for LayoutSVGText which inherits from |
| 556 // LayoutSVGBlock instead of LayoutSVGModelObject. | 552 // LayoutSVGBlock instead of LayoutSVGModelObject. |
| 557 LayoutObject& textWithOpacity = | 553 LayoutObject& textWithOpacity = |
| 558 *document().getElementById("textWithOpacity")->layoutObject(); | 554 *document().getElementById("textWithOpacity")->layoutObject(); |
| 559 const ObjectPaintProperties* textWithOpacityProperties = | 555 const ObjectPaintProperties* textWithOpacityProperties = |
| 560 textWithOpacity.objectPaintProperties(); | 556 textWithOpacity.paintProperties(); |
| 561 EXPECT_EQ(0.2f, textWithOpacityProperties->effect()->opacity()); | 557 EXPECT_EQ(0.2f, textWithOpacityProperties->effect()->opacity()); |
| 562 EXPECT_EQ(groupWithOpacityProperties->effect(), | 558 EXPECT_EQ(groupWithOpacityProperties->effect(), |
| 563 textWithOpacityProperties->effect()->parent()); | 559 textWithOpacityProperties->effect()->parent()); |
| 564 | 560 |
| 565 // Ensure that opacity nodes are created for LayoutSVGTSpan which inherits | 561 // Ensure that opacity nodes are created for LayoutSVGTSpan which inherits |
| 566 // from LayoutSVGInline instead of LayoutSVGModelObject. | 562 // from LayoutSVGInline instead of LayoutSVGModelObject. |
| 567 LayoutObject& tspanWithOpacity = | 563 LayoutObject& tspanWithOpacity = |
| 568 *document().getElementById("tspanWithOpacity")->layoutObject(); | 564 *document().getElementById("tspanWithOpacity")->layoutObject(); |
| 569 const ObjectPaintProperties* tspanWithOpacityProperties = | 565 const ObjectPaintProperties* tspanWithOpacityProperties = |
| 570 tspanWithOpacity.objectPaintProperties(); | 566 tspanWithOpacity.paintProperties(); |
| 571 EXPECT_EQ(0.1f, tspanWithOpacityProperties->effect()->opacity()); | 567 EXPECT_EQ(0.1f, tspanWithOpacityProperties->effect()->opacity()); |
| 572 EXPECT_EQ(textWithOpacityProperties->effect(), | 568 EXPECT_EQ(textWithOpacityProperties->effect(), |
| 573 tspanWithOpacityProperties->effect()->parent()); | 569 tspanWithOpacityProperties->effect()->parent()); |
| 574 } | 570 } |
| 575 | 571 |
| 576 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossHTMLSVGBoundary) { | 572 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossHTMLSVGBoundary) { |
| 577 setBodyInnerHTML( | 573 setBodyInnerHTML( |
| 578 "<div id='divWithOpacity' style='opacity: 0.2;'>" | 574 "<div id='divWithOpacity' style='opacity: 0.2;'>" |
| 579 " <svg id='svgRootWithOpacity' style='opacity: 0.3;'>" | 575 " <svg id='svgRootWithOpacity' style='opacity: 0.3;'>" |
| 580 " <rect id='rectWithOpacity' opacity='0.4' />" | 576 " <rect id='rectWithOpacity' opacity='0.4' />" |
| 581 " </svg>" | 577 " </svg>" |
| 582 "</div>"); | 578 "</div>"); |
| 583 | 579 |
| 584 LayoutObject& divWithOpacity = | 580 LayoutObject& divWithOpacity = |
| 585 *document().getElementById("divWithOpacity")->layoutObject(); | 581 *document().getElementById("divWithOpacity")->layoutObject(); |
| 586 const ObjectPaintProperties* divWithOpacityProperties = | 582 const ObjectPaintProperties* divWithOpacityProperties = |
| 587 divWithOpacity.objectPaintProperties(); | 583 divWithOpacity.paintProperties(); |
| 588 EXPECT_EQ(0.2f, divWithOpacityProperties->effect()->opacity()); | 584 EXPECT_EQ(0.2f, divWithOpacityProperties->effect()->opacity()); |
| 589 EXPECT_NE(nullptr, divWithOpacityProperties->effect()->parent()); | 585 EXPECT_NE(nullptr, divWithOpacityProperties->effect()->parent()); |
| 590 | 586 |
| 591 LayoutObject& svgRootWithOpacity = | 587 LayoutObject& svgRootWithOpacity = |
| 592 *document().getElementById("svgRootWithOpacity")->layoutObject(); | 588 *document().getElementById("svgRootWithOpacity")->layoutObject(); |
| 593 const ObjectPaintProperties* svgRootWithOpacityProperties = | 589 const ObjectPaintProperties* svgRootWithOpacityProperties = |
| 594 svgRootWithOpacity.objectPaintProperties(); | 590 svgRootWithOpacity.paintProperties(); |
| 595 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); | 591 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); |
| 596 EXPECT_EQ(divWithOpacityProperties->effect(), | 592 EXPECT_EQ(divWithOpacityProperties->effect(), |
| 597 svgRootWithOpacityProperties->effect()->parent()); | 593 svgRootWithOpacityProperties->effect()->parent()); |
| 598 | 594 |
| 599 LayoutObject& rectWithOpacity = | 595 LayoutObject& rectWithOpacity = |
| 600 *document().getElementById("rectWithOpacity")->layoutObject(); | 596 *document().getElementById("rectWithOpacity")->layoutObject(); |
| 601 const ObjectPaintProperties* rectWithOpacityProperties = | 597 const ObjectPaintProperties* rectWithOpacityProperties = |
| 602 rectWithOpacity.objectPaintProperties(); | 598 rectWithOpacity.paintProperties(); |
| 603 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity()); | 599 EXPECT_EQ(0.4f, rectWithOpacityProperties->effect()->opacity()); |
| 604 EXPECT_EQ(svgRootWithOpacityProperties->effect(), | 600 EXPECT_EQ(svgRootWithOpacityProperties->effect(), |
| 605 rectWithOpacityProperties->effect()->parent()); | 601 rectWithOpacityProperties->effect()->parent()); |
| 606 } | 602 } |
| 607 | 603 |
| 608 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossSVGHTMLBoundary) { | 604 TEST_P(PaintPropertyTreeBuilderTest, EffectNodesAcrossSVGHTMLBoundary) { |
| 609 setBodyInnerHTML( | 605 setBodyInnerHTML( |
| 610 "<svg id='svgRootWithOpacity' style='opacity: 0.3;'>" | 606 "<svg id='svgRootWithOpacity' style='opacity: 0.3;'>" |
| 611 " <foreignObject id='foreignObjectWithOpacity' opacity='0.4'>" | 607 " <foreignObject id='foreignObjectWithOpacity' opacity='0.4'>" |
| 612 " <body>" | 608 " <body>" |
| 613 " <span id='spanWithOpacity' style='opacity: 0.5'/>" | 609 " <span id='spanWithOpacity' style='opacity: 0.5'/>" |
| 614 " </body>" | 610 " </body>" |
| 615 " </foreignObject>" | 611 " </foreignObject>" |
| 616 "</svg>"); | 612 "</svg>"); |
| 617 | 613 |
| 618 LayoutObject& svgRootWithOpacity = | 614 LayoutObject& svgRootWithOpacity = |
| 619 *document().getElementById("svgRootWithOpacity")->layoutObject(); | 615 *document().getElementById("svgRootWithOpacity")->layoutObject(); |
| 620 const ObjectPaintProperties* svgRootWithOpacityProperties = | 616 const ObjectPaintProperties* svgRootWithOpacityProperties = |
| 621 svgRootWithOpacity.objectPaintProperties(); | 617 svgRootWithOpacity.paintProperties(); |
| 622 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); | 618 EXPECT_EQ(0.3f, svgRootWithOpacityProperties->effect()->opacity()); |
| 623 EXPECT_NE(nullptr, svgRootWithOpacityProperties->effect()->parent()); | 619 EXPECT_NE(nullptr, svgRootWithOpacityProperties->effect()->parent()); |
| 624 | 620 |
| 625 LayoutObject& foreignObjectWithOpacity = | 621 LayoutObject& foreignObjectWithOpacity = |
| 626 *document().getElementById("foreignObjectWithOpacity")->layoutObject(); | 622 *document().getElementById("foreignObjectWithOpacity")->layoutObject(); |
| 627 const ObjectPaintProperties* foreignObjectWithOpacityProperties = | 623 const ObjectPaintProperties* foreignObjectWithOpacityProperties = |
| 628 foreignObjectWithOpacity.objectPaintProperties(); | 624 foreignObjectWithOpacity.paintProperties(); |
| 629 EXPECT_EQ(0.4f, foreignObjectWithOpacityProperties->effect()->opacity()); | 625 EXPECT_EQ(0.4f, foreignObjectWithOpacityProperties->effect()->opacity()); |
| 630 EXPECT_EQ(svgRootWithOpacityProperties->effect(), | 626 EXPECT_EQ(svgRootWithOpacityProperties->effect(), |
| 631 foreignObjectWithOpacityProperties->effect()->parent()); | 627 foreignObjectWithOpacityProperties->effect()->parent()); |
| 632 | 628 |
| 633 LayoutObject& spanWithOpacity = | 629 LayoutObject& spanWithOpacity = |
| 634 *document().getElementById("spanWithOpacity")->layoutObject(); | 630 *document().getElementById("spanWithOpacity")->layoutObject(); |
| 635 const ObjectPaintProperties* spanWithOpacityProperties = | 631 const ObjectPaintProperties* spanWithOpacityProperties = |
| 636 spanWithOpacity.objectPaintProperties(); | 632 spanWithOpacity.paintProperties(); |
| 637 EXPECT_EQ(0.5f, spanWithOpacityProperties->effect()->opacity()); | 633 EXPECT_EQ(0.5f, spanWithOpacityProperties->effect()->opacity()); |
| 638 EXPECT_EQ(foreignObjectWithOpacityProperties->effect(), | 634 EXPECT_EQ(foreignObjectWithOpacityProperties->effect(), |
| 639 spanWithOpacityProperties->effect()->parent()); | 635 spanWithOpacityProperties->effect()->parent()); |
| 640 } | 636 } |
| 641 | 637 |
| 642 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesInSVG) { | 638 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesInSVG) { |
| 643 setBodyInnerHTML( | 639 setBodyInnerHTML( |
| 644 "<style>" | 640 "<style>" |
| 645 " body {" | 641 " body {" |
| 646 " margin: 0px;" | 642 " margin: 0px;" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 657 " transform-origin: 50px 25px;" | 653 " transform-origin: 50px 25px;" |
| 658 " }" | 654 " }" |
| 659 "</style>" | 655 "</style>" |
| 660 "<svg id='svgRootWith3dTransform' width='100px' height='100px'>" | 656 "<svg id='svgRootWith3dTransform' width='100px' height='100px'>" |
| 661 " <rect id='rectWith2dTransform' width='100px' height='100px' />" | 657 " <rect id='rectWith2dTransform' width='100px' height='100px' />" |
| 662 "</svg>"); | 658 "</svg>"); |
| 663 | 659 |
| 664 LayoutObject& svgRootWith3dTransform = | 660 LayoutObject& svgRootWith3dTransform = |
| 665 *document().getElementById("svgRootWith3dTransform")->layoutObject(); | 661 *document().getElementById("svgRootWith3dTransform")->layoutObject(); |
| 666 const ObjectPaintProperties* svgRootWith3dTransformProperties = | 662 const ObjectPaintProperties* svgRootWith3dTransformProperties = |
| 667 svgRootWith3dTransform.objectPaintProperties(); | 663 svgRootWith3dTransform.paintProperties(); |
| 668 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), | 664 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), |
| 669 svgRootWith3dTransformProperties->transform()->matrix()); | 665 svgRootWith3dTransformProperties->transform()->matrix()); |
| 670 EXPECT_EQ(FloatPoint3D(50, 50, 0), | 666 EXPECT_EQ(FloatPoint3D(50, 50, 0), |
| 671 svgRootWith3dTransformProperties->transform()->origin()); | 667 svgRootWith3dTransformProperties->transform()->origin()); |
| 672 EXPECT_EQ(svgRootWith3dTransformProperties->paintOffsetTranslation(), | 668 EXPECT_EQ(svgRootWith3dTransformProperties->paintOffsetTranslation(), |
| 673 svgRootWith3dTransformProperties->transform()->parent()); | 669 svgRootWith3dTransformProperties->transform()->parent()); |
| 674 EXPECT_EQ( | 670 EXPECT_EQ( |
| 675 TransformationMatrix().translate(70, 25), | 671 TransformationMatrix().translate(70, 25), |
| 676 svgRootWith3dTransformProperties->paintOffsetTranslation()->matrix()); | 672 svgRootWith3dTransformProperties->paintOffsetTranslation()->matrix()); |
| 677 EXPECT_EQ( | 673 EXPECT_EQ( |
| 678 framePreTranslation(), | 674 framePreTranslation(), |
| 679 svgRootWith3dTransformProperties->paintOffsetTranslation()->parent()); | 675 svgRootWith3dTransformProperties->paintOffsetTranslation()->parent()); |
| 680 | 676 |
| 681 LayoutObject& rectWith2dTransform = | 677 LayoutObject& rectWith2dTransform = |
| 682 *document().getElementById("rectWith2dTransform")->layoutObject(); | 678 *document().getElementById("rectWith2dTransform")->layoutObject(); |
| 683 const ObjectPaintProperties* rectWith2dTransformProperties = | 679 const ObjectPaintProperties* rectWith2dTransformProperties = |
| 684 rectWith2dTransform.objectPaintProperties(); | 680 rectWith2dTransform.paintProperties(); |
| 685 TransformationMatrix matrix; | 681 TransformationMatrix matrix; |
| 686 matrix.translate(100, 100); | 682 matrix.translate(100, 100); |
| 687 matrix.rotate(45); | 683 matrix.rotate(45); |
| 688 // SVG's transform origin is baked into the transform. | 684 // SVG's transform origin is baked into the transform. |
| 689 matrix.applyTransformOrigin(50, 25, 0); | 685 matrix.applyTransformOrigin(50, 25, 0); |
| 690 EXPECT_EQ(matrix, rectWith2dTransformProperties->transform()->matrix()); | 686 EXPECT_EQ(matrix, rectWith2dTransformProperties->transform()->matrix()); |
| 691 EXPECT_EQ(FloatPoint3D(0, 0, 0), | 687 EXPECT_EQ(FloatPoint3D(0, 0, 0), |
| 692 rectWith2dTransformProperties->transform()->origin()); | 688 rectWith2dTransformProperties->transform()->origin()); |
| 693 // SVG does not use paint offset. | 689 // SVG does not use paint offset. |
| 694 EXPECT_EQ(nullptr, rectWith2dTransformProperties->paintOffsetTranslation()); | 690 EXPECT_EQ(nullptr, rectWith2dTransformProperties->paintOffsetTranslation()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 709 " }" | 705 " }" |
| 710 "</style>" | 706 "</style>" |
| 711 "<svg id='svgWithViewBox' width='100px' height='100px' viewBox='50 50 " | 707 "<svg id='svgWithViewBox' width='100px' height='100px' viewBox='50 50 " |
| 712 "100 100'>" | 708 "100 100'>" |
| 713 " <rect id='rect' width='100px' height='100px' />" | 709 " <rect id='rect' width='100px' height='100px' />" |
| 714 "</svg>"); | 710 "</svg>"); |
| 715 | 711 |
| 716 LayoutObject& svgWithViewBox = | 712 LayoutObject& svgWithViewBox = |
| 717 *document().getElementById("svgWithViewBox")->layoutObject(); | 713 *document().getElementById("svgWithViewBox")->layoutObject(); |
| 718 const ObjectPaintProperties* svgWithViewBoxProperties = | 714 const ObjectPaintProperties* svgWithViewBoxProperties = |
| 719 svgWithViewBox.objectPaintProperties(); | 715 svgWithViewBox.paintProperties(); |
| 720 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), | 716 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), |
| 721 svgWithViewBoxProperties->transform()->matrix()); | 717 svgWithViewBoxProperties->transform()->matrix()); |
| 722 EXPECT_EQ(TransformationMatrix().translate(-50, -50), | 718 EXPECT_EQ(TransformationMatrix().translate(-50, -50), |
| 723 svgWithViewBoxProperties->svgLocalToBorderBoxTransform()->matrix()); | 719 svgWithViewBoxProperties->svgLocalToBorderBoxTransform()->matrix()); |
| 724 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform()->parent(), | 720 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform()->parent(), |
| 725 svgWithViewBoxProperties->transform()); | 721 svgWithViewBoxProperties->transform()); |
| 726 | 722 |
| 727 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); | 723 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); |
| 728 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); | 724 const ObjectPaintProperties* rectProperties = rect.paintProperties(); |
| 729 EXPECT_EQ(TransformationMatrix().translate(100, 100), | 725 EXPECT_EQ(TransformationMatrix().translate(100, 100), |
| 730 rectProperties->transform()->matrix()); | 726 rectProperties->transform()->matrix()); |
| 731 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), | 727 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), |
| 732 rectProperties->transform()->parent()); | 728 rectProperties->transform()->parent()); |
| 733 } | 729 } |
| 734 | 730 |
| 735 TEST_P(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode) { | 731 TEST_P(PaintPropertyTreeBuilderTest, SVGRootPaintOffsetTransformNode) { |
| 736 setBodyInnerHTML( | 732 setBodyInnerHTML( |
| 737 "<style>body { margin: 0px; } </style>" | 733 "<style>body { margin: 0px; } </style>" |
| 738 "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px; " | 734 "<svg id='svg' style='margin-left: 50px; margin-top: 25px; width: 100px; " |
| 739 "height: 100px;' />"); | 735 "height: 100px;' />"); |
| 740 | 736 |
| 741 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); | 737 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
| 742 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); | 738 const ObjectPaintProperties* svgProperties = svg.paintProperties(); |
| 743 // Ensure that a paint offset transform is not unnecessarily emitted. | 739 // Ensure that a paint offset transform is not unnecessarily emitted. |
| 744 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation()); | 740 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation()); |
| 745 EXPECT_EQ(TransformationMatrix().translate(50, 25), | 741 EXPECT_EQ(TransformationMatrix().translate(50, 25), |
| 746 svgProperties->svgLocalToBorderBoxTransform()->matrix()); | 742 svgProperties->svgLocalToBorderBoxTransform()->matrix()); |
| 747 EXPECT_EQ(framePreTranslation(), | 743 EXPECT_EQ(framePreTranslation(), |
| 748 svgProperties->svgLocalToBorderBoxTransform()->parent()); | 744 svgProperties->svgLocalToBorderBoxTransform()->parent()); |
| 749 } | 745 } |
| 750 | 746 |
| 751 TEST_P(PaintPropertyTreeBuilderTest, SVGRootLocalToBorderBoxTransformNode) { | 747 TEST_P(PaintPropertyTreeBuilderTest, SVGRootLocalToBorderBoxTransformNode) { |
| 752 setBodyInnerHTML( | 748 setBodyInnerHTML( |
| 753 "<style>" | 749 "<style>" |
| 754 " body { margin: 0px; }" | 750 " body { margin: 0px; }" |
| 755 " svg { margin-left: 2px; margin-top: 3px; transform: translate(5px, " | 751 " svg { margin-left: 2px; margin-top: 3px; transform: translate(5px, " |
| 756 "7px); border: 11px solid green; }" | 752 "7px); border: 11px solid green; }" |
| 757 "</style>" | 753 "</style>" |
| 758 "<svg id='svg' width='100px' height='100px' viewBox='0 0 13 13'>" | 754 "<svg id='svg' width='100px' height='100px' viewBox='0 0 13 13'>" |
| 759 " <rect id='rect' transform='translate(17 19)' />" | 755 " <rect id='rect' transform='translate(17 19)' />" |
| 760 "</svg>"); | 756 "</svg>"); |
| 761 | 757 |
| 762 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); | 758 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
| 763 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); | 759 const ObjectPaintProperties* svgProperties = svg.paintProperties(); |
| 764 EXPECT_EQ(TransformationMatrix().translate(2, 3), | 760 EXPECT_EQ(TransformationMatrix().translate(2, 3), |
| 765 svgProperties->paintOffsetTranslation()->matrix()); | 761 svgProperties->paintOffsetTranslation()->matrix()); |
| 766 EXPECT_EQ(TransformationMatrix().translate(5, 7), | 762 EXPECT_EQ(TransformationMatrix().translate(5, 7), |
| 767 svgProperties->transform()->matrix()); | 763 svgProperties->transform()->matrix()); |
| 768 EXPECT_EQ(TransformationMatrix().translate(11, 11).scale(100.0 / 13.0), | 764 EXPECT_EQ(TransformationMatrix().translate(11, 11).scale(100.0 / 13.0), |
| 769 svgProperties->svgLocalToBorderBoxTransform()->matrix()); | 765 svgProperties->svgLocalToBorderBoxTransform()->matrix()); |
| 770 EXPECT_EQ(svgProperties->paintOffsetTranslation(), | 766 EXPECT_EQ(svgProperties->paintOffsetTranslation(), |
| 771 svgProperties->transform()->parent()); | 767 svgProperties->transform()->parent()); |
| 772 EXPECT_EQ(svgProperties->transform(), | 768 EXPECT_EQ(svgProperties->transform(), |
| 773 svgProperties->svgLocalToBorderBoxTransform()->parent()); | 769 svgProperties->svgLocalToBorderBoxTransform()->parent()); |
| 774 | 770 |
| 775 // Ensure the rect's transform is a child of the local to border box | 771 // Ensure the rect's transform is a child of the local to border box |
| 776 // transform. | 772 // transform. |
| 777 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); | 773 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); |
| 778 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); | 774 const ObjectPaintProperties* rectProperties = rect.paintProperties(); |
| 779 EXPECT_EQ(TransformationMatrix().translate(17, 19), | 775 EXPECT_EQ(TransformationMatrix().translate(17, 19), |
| 780 rectProperties->transform()->matrix()); | 776 rectProperties->transform()->matrix()); |
| 781 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), | 777 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), |
| 782 rectProperties->transform()->parent()); | 778 rectProperties->transform()->parent()); |
| 783 } | 779 } |
| 784 | 780 |
| 785 TEST_P(PaintPropertyTreeBuilderTest, SVGNestedViewboxTransforms) { | 781 TEST_P(PaintPropertyTreeBuilderTest, SVGNestedViewboxTransforms) { |
| 786 setBodyInnerHTML( | 782 setBodyInnerHTML( |
| 787 "<style>body { margin: 0px; } </style>" | 783 "<style>body { margin: 0px; } </style>" |
| 788 "<svg id='svg' width='100px' height='100px' viewBox='0 0 50 50' " | 784 "<svg id='svg' width='100px' height='100px' viewBox='0 0 50 50' " |
| 789 "style='transform: translate(11px, 11px);'>" | 785 "style='transform: translate(11px, 11px);'>" |
| 790 " <svg id='nestedSvg' width='50px' height='50px' viewBox='0 0 5 5'>" | 786 " <svg id='nestedSvg' width='50px' height='50px' viewBox='0 0 5 5'>" |
| 791 " <rect id='rect' transform='translate(13 13)' />" | 787 " <rect id='rect' transform='translate(13 13)' />" |
| 792 " </svg>" | 788 " </svg>" |
| 793 "</svg>"); | 789 "</svg>"); |
| 794 | 790 |
| 795 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); | 791 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
| 796 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); | 792 const ObjectPaintProperties* svgProperties = svg.paintProperties(); |
| 797 EXPECT_EQ(TransformationMatrix().translate(11, 11), | 793 EXPECT_EQ(TransformationMatrix().translate(11, 11), |
| 798 svgProperties->transform()->matrix()); | 794 svgProperties->transform()->matrix()); |
| 799 EXPECT_EQ(TransformationMatrix().scale(2), | 795 EXPECT_EQ(TransformationMatrix().scale(2), |
| 800 svgProperties->svgLocalToBorderBoxTransform()->matrix()); | 796 svgProperties->svgLocalToBorderBoxTransform()->matrix()); |
| 801 | 797 |
| 802 LayoutObject& nestedSvg = | 798 LayoutObject& nestedSvg = |
| 803 *document().getElementById("nestedSvg")->layoutObject(); | 799 *document().getElementById("nestedSvg")->layoutObject(); |
| 804 const ObjectPaintProperties* nestedSvgProperties = | 800 const ObjectPaintProperties* nestedSvgProperties = |
| 805 nestedSvg.objectPaintProperties(); | 801 nestedSvg.paintProperties(); |
| 806 EXPECT_EQ(TransformationMatrix().scale(10), | 802 EXPECT_EQ(TransformationMatrix().scale(10), |
| 807 nestedSvgProperties->transform()->matrix()); | 803 nestedSvgProperties->transform()->matrix()); |
| 808 EXPECT_EQ(nullptr, nestedSvgProperties->svgLocalToBorderBoxTransform()); | 804 EXPECT_EQ(nullptr, nestedSvgProperties->svgLocalToBorderBoxTransform()); |
| 809 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), | 805 EXPECT_EQ(svgProperties->svgLocalToBorderBoxTransform(), |
| 810 nestedSvgProperties->transform()->parent()); | 806 nestedSvgProperties->transform()->parent()); |
| 811 | 807 |
| 812 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); | 808 LayoutObject& rect = *document().getElementById("rect")->layoutObject(); |
| 813 const ObjectPaintProperties* rectProperties = rect.objectPaintProperties(); | 809 const ObjectPaintProperties* rectProperties = rect.paintProperties(); |
| 814 EXPECT_EQ(TransformationMatrix().translate(13, 13), | 810 EXPECT_EQ(TransformationMatrix().translate(13, 13), |
| 815 rectProperties->transform()->matrix()); | 811 rectProperties->transform()->matrix()); |
| 816 EXPECT_EQ(nestedSvgProperties->transform(), | 812 EXPECT_EQ(nestedSvgProperties->transform(), |
| 817 rectProperties->transform()->parent()); | 813 rectProperties->transform()->parent()); |
| 818 } | 814 } |
| 819 | 815 |
| 820 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesAcrossSVGHTMLBoundary) { | 816 TEST_P(PaintPropertyTreeBuilderTest, TransformNodesAcrossSVGHTMLBoundary) { |
| 821 setBodyInnerHTML( | 817 setBodyInnerHTML( |
| 822 "<style> body { margin: 0px; } </style>" | 818 "<style> body { margin: 0px; } </style>" |
| 823 "<svg id='svgWithTransform' style='transform: translate3d(1px, 2px, " | 819 "<svg id='svgWithTransform' style='transform: translate3d(1px, 2px, " |
| 824 "3px);'>" | 820 "3px);'>" |
| 825 " <foreignObject>" | 821 " <foreignObject>" |
| 826 " <body>" | 822 " <body>" |
| 827 " <div id='divWithTransform' style='transform: translate3d(3px, " | 823 " <div id='divWithTransform' style='transform: translate3d(3px, " |
| 828 "4px, 5px);'></div>" | 824 "4px, 5px);'></div>" |
| 829 " </body>" | 825 " </body>" |
| 830 " </foreignObject>" | 826 " </foreignObject>" |
| 831 "</svg>"); | 827 "</svg>"); |
| 832 | 828 |
| 833 LayoutObject& svgWithTransform = | 829 LayoutObject& svgWithTransform = |
| 834 *document().getElementById("svgWithTransform")->layoutObject(); | 830 *document().getElementById("svgWithTransform")->layoutObject(); |
| 835 const ObjectPaintProperties* svgWithTransformProperties = | 831 const ObjectPaintProperties* svgWithTransformProperties = |
| 836 svgWithTransform.objectPaintProperties(); | 832 svgWithTransform.paintProperties(); |
| 837 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), | 833 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), |
| 838 svgWithTransformProperties->transform()->matrix()); | 834 svgWithTransformProperties->transform()->matrix()); |
| 839 | 835 |
| 840 LayoutObject& divWithTransform = | 836 LayoutObject& divWithTransform = |
| 841 *document().getElementById("divWithTransform")->layoutObject(); | 837 *document().getElementById("divWithTransform")->layoutObject(); |
| 842 const ObjectPaintProperties* divWithTransformProperties = | 838 const ObjectPaintProperties* divWithTransformProperties = |
| 843 divWithTransform.objectPaintProperties(); | 839 divWithTransform.paintProperties(); |
| 844 EXPECT_EQ(TransformationMatrix().translate3d(3, 4, 5), | 840 EXPECT_EQ(TransformationMatrix().translate3d(3, 4, 5), |
| 845 divWithTransformProperties->transform()->matrix()); | 841 divWithTransformProperties->transform()->matrix()); |
| 846 // Ensure the div's transform node is a child of the svg's transform node. | 842 // Ensure the div's transform node is a child of the svg's transform node. |
| 847 EXPECT_EQ(svgWithTransformProperties->transform(), | 843 EXPECT_EQ(svgWithTransformProperties->transform(), |
| 848 divWithTransformProperties->transform()->parent()); | 844 divWithTransformProperties->transform()->parent()); |
| 849 } | 845 } |
| 850 | 846 |
| 851 TEST_P(PaintPropertyTreeBuilderTest, | 847 TEST_P(PaintPropertyTreeBuilderTest, |
| 852 FixedTransformAncestorAcrossSVGHTMLBoundary) { | 848 FixedTransformAncestorAcrossSVGHTMLBoundary) { |
| 853 setBodyInnerHTML( | 849 setBodyInnerHTML( |
| 854 "<style> body { margin: 0px; } </style>" | 850 "<style> body { margin: 0px; } </style>" |
| 855 "<svg id='svg' style='transform: translate3d(1px, 2px, 3px);'>" | 851 "<svg id='svg' style='transform: translate3d(1px, 2px, 3px);'>" |
| 856 " <g id='container' transform='translate(20 30)'>" | 852 " <g id='container' transform='translate(20 30)'>" |
| 857 " <foreignObject>" | 853 " <foreignObject>" |
| 858 " <body>" | 854 " <body>" |
| 859 " <div id='fixed' style='position: fixed; left: 200px; top: " | 855 " <div id='fixed' style='position: fixed; left: 200px; top: " |
| 860 "150px;'></div>" | 856 "150px;'></div>" |
| 861 " </body>" | 857 " </body>" |
| 862 " </foreignObject>" | 858 " </foreignObject>" |
| 863 " </g>" | 859 " </g>" |
| 864 "</svg>"); | 860 "</svg>"); |
| 865 | 861 |
| 866 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); | 862 LayoutObject& svg = *document().getElementById("svg")->layoutObject(); |
| 867 const ObjectPaintProperties* svgProperties = svg.objectPaintProperties(); | 863 const ObjectPaintProperties* svgProperties = svg.paintProperties(); |
| 868 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), | 864 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), |
| 869 svgProperties->transform()->matrix()); | 865 svgProperties->transform()->matrix()); |
| 870 | 866 |
| 871 LayoutObject& container = | 867 LayoutObject& container = |
| 872 *document().getElementById("container")->layoutObject(); | 868 *document().getElementById("container")->layoutObject(); |
| 873 const ObjectPaintProperties* containerProperties = | 869 const ObjectPaintProperties* containerProperties = |
| 874 container.objectPaintProperties(); | 870 container.paintProperties(); |
| 875 EXPECT_EQ(TransformationMatrix().translate(20, 30), | 871 EXPECT_EQ(TransformationMatrix().translate(20, 30), |
| 876 containerProperties->transform()->matrix()); | 872 containerProperties->transform()->matrix()); |
| 877 EXPECT_EQ(svgProperties->transform(), | 873 EXPECT_EQ(svgProperties->transform(), |
| 878 containerProperties->transform()->parent()); | 874 containerProperties->transform()->parent()); |
| 879 | 875 |
| 880 Element* fixed = document().getElementById("fixed"); | 876 Element* fixed = document().getElementById("fixed"); |
| 881 const ObjectPaintProperties* fixedProperties = | 877 const ObjectPaintProperties* fixedProperties = |
| 882 fixed->layoutObject()->objectPaintProperties(); | 878 fixed->layoutObject()->paintProperties(); |
| 883 EXPECT_EQ(TransformationMatrix().translate(200, 150), | 879 EXPECT_EQ(TransformationMatrix().translate(200, 150), |
| 884 fixedProperties->paintOffsetTranslation()->matrix()); | 880 fixedProperties->paintOffsetTranslation()->matrix()); |
| 885 // Ensure the fixed position element is rooted at the nearest transform | 881 // Ensure the fixed position element is rooted at the nearest transform |
| 886 // container. | 882 // container. |
| 887 EXPECT_EQ(containerProperties->transform(), | 883 EXPECT_EQ(containerProperties->transform(), |
| 888 fixedProperties->paintOffsetTranslation()->parent()); | 884 fixedProperties->paintOffsetTranslation()->parent()); |
| 889 } | 885 } |
| 890 | 886 |
| 891 TEST_P(PaintPropertyTreeBuilderTest, ControlClip) { | 887 TEST_P(PaintPropertyTreeBuilderTest, ControlClip) { |
| 892 setBodyInnerHTML( | 888 setBodyInnerHTML( |
| 893 "<style>" | 889 "<style>" |
| 894 " body {" | 890 " body {" |
| 895 " margin: 0;" | 891 " margin: 0;" |
| 896 " }" | 892 " }" |
| 897 " input {" | 893 " input {" |
| 898 " border-width: 5px;" | 894 " border-width: 5px;" |
| 899 " padding: 0;" | 895 " padding: 0;" |
| 900 " }" | 896 " }" |
| 901 "</style>" | 897 "</style>" |
| 902 "<input id='button' type='button' style='width:345px; height:123px' " | 898 "<input id='button' type='button' style='width:345px; height:123px' " |
| 903 "value='some text'/>"); | 899 "value='some text'/>"); |
| 904 | 900 |
| 905 LayoutObject& button = *document().getElementById("button")->layoutObject(); | 901 LayoutObject& button = *document().getElementById("button")->layoutObject(); |
| 906 const ObjectPaintProperties* buttonProperties = | 902 const ObjectPaintProperties* buttonProperties = button.paintProperties(); |
| 907 button.objectPaintProperties(); | |
| 908 // No scroll translation because the document does not scroll (not enough | 903 // No scroll translation because the document does not scroll (not enough |
| 909 // content). | 904 // content). |
| 910 EXPECT_TRUE(!frameScrollTranslation()); | 905 EXPECT_TRUE(!frameScrollTranslation()); |
| 911 EXPECT_EQ(framePreTranslation(), | 906 EXPECT_EQ(framePreTranslation(), |
| 912 buttonProperties->overflowClip()->localTransformSpace()); | 907 buttonProperties->overflowClip()->localTransformSpace()); |
| 913 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), | 908 EXPECT_EQ(FloatRoundedRect(5, 5, 335, 113), |
| 914 buttonProperties->overflowClip()->clipRect()); | 909 buttonProperties->overflowClip()->clipRect()); |
| 915 EXPECT_EQ(frameContentClip(), buttonProperties->overflowClip()->parent()); | 910 EXPECT_EQ(frameContentClip(), buttonProperties->overflowClip()->parent()); |
| 916 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 345, 123), &button, | 911 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 345, 123), &button, |
| 917 document().view()->layoutView()); | 912 document().view()->layoutView()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 930 " border-bottom: 55px solid;" | 925 " border-bottom: 55px solid;" |
| 931 " border-left: 60px solid;" | 926 " border-left: 60px solid;" |
| 932 " width: 500px;" | 927 " width: 500px;" |
| 933 " height: 400px;" | 928 " height: 400px;" |
| 934 " overflow: scroll;" | 929 " overflow: scroll;" |
| 935 " }" | 930 " }" |
| 936 "</style>" | 931 "</style>" |
| 937 "<div id='div'></div>"); | 932 "<div id='div'></div>"); |
| 938 | 933 |
| 939 LayoutObject& div = *document().getElementById("div")->layoutObject(); | 934 LayoutObject& div = *document().getElementById("div")->layoutObject(); |
| 940 const ObjectPaintProperties* divProperties = div.objectPaintProperties(); | 935 const ObjectPaintProperties* divProperties = div.paintProperties(); |
| 941 // No scroll translation because the document does not scroll (not enough | 936 // No scroll translation because the document does not scroll (not enough |
| 942 // content). | 937 // content). |
| 943 EXPECT_TRUE(!frameScrollTranslation()); | 938 EXPECT_TRUE(!frameScrollTranslation()); |
| 944 EXPECT_EQ(framePreTranslation(), | 939 EXPECT_EQ(framePreTranslation(), |
| 945 divProperties->overflowClip()->localTransformSpace()); | 940 divProperties->overflowClip()->localTransformSpace()); |
| 946 // The overflow clip rect includes only the padding box. | 941 // The overflow clip rect includes only the padding box. |
| 947 // padding box = border box(500+60+50, 400+45+55) - border outset(60+50, | 942 // padding box = border box(500+60+50, 400+45+55) - border outset(60+50, |
| 948 // 45+55) - scrollbars(15, 15) | 943 // 45+55) - scrollbars(15, 15) |
| 949 EXPECT_EQ(FloatRoundedRect(60, 45, 500, 400), | 944 EXPECT_EQ(FloatRoundedRect(60, 45, 500, 400), |
| 950 divProperties->overflowClip()->clipRect()); | 945 divProperties->overflowClip()->clipRect()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 Document& frameDocument = setupChildIframe( | 981 Document& frameDocument = setupChildIframe( |
| 987 "frame", | 982 "frame", |
| 988 "<style>body { margin: 0; }</style><div id='transform' style='transform: " | 983 "<style>body { margin: 0; }</style><div id='transform' style='transform: " |
| 989 "translate3d(4px, 5px, 6px); width: 100px; height: 200px'></div>"); | 984 "translate3d(4px, 5px, 6px); width: 100px; height: 200px'></div>"); |
| 990 FrameView* frameView = document().view(); | 985 FrameView* frameView = document().view(); |
| 991 frameView->updateAllLifecyclePhases(); | 986 frameView->updateAllLifecyclePhases(); |
| 992 | 987 |
| 993 LayoutObject* divWithTransform = | 988 LayoutObject* divWithTransform = |
| 994 document().getElementById("divWithTransform")->layoutObject(); | 989 document().getElementById("divWithTransform")->layoutObject(); |
| 995 const ObjectPaintProperties* divWithTransformProperties = | 990 const ObjectPaintProperties* divWithTransformProperties = |
| 996 divWithTransform->objectPaintProperties(); | 991 divWithTransform->paintProperties(); |
| 997 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), | 992 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), |
| 998 divWithTransformProperties->transform()->matrix()); | 993 divWithTransformProperties->transform()->matrix()); |
| 999 // http://crbug.com/638415 | 994 // http://crbug.com/638415 |
| 1000 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 995 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 1001 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 164), divWithTransform, | 996 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 164), divWithTransform, |
| 1002 frameView->layoutView()); | 997 frameView->layoutView()); |
| 1003 } | 998 } |
| 1004 | 999 |
| 1005 LayoutObject* innerDivWithTransform = | 1000 LayoutObject* innerDivWithTransform = |
| 1006 frameDocument.getElementById("transform")->layoutObject(); | 1001 frameDocument.getElementById("transform")->layoutObject(); |
| 1007 const ObjectPaintProperties* innerDivWithTransformProperties = | 1002 const ObjectPaintProperties* innerDivWithTransformProperties = |
| 1008 innerDivWithTransform->objectPaintProperties(); | 1003 innerDivWithTransform->paintProperties(); |
| 1009 auto* innerDivTransform = innerDivWithTransformProperties->transform(); | 1004 auto* innerDivTransform = innerDivWithTransformProperties->transform(); |
| 1010 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), | 1005 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), |
| 1011 innerDivTransform->matrix()); | 1006 innerDivTransform->matrix()); |
| 1012 CHECK_EXACT_VISUAL_RECT(LayoutRect(12, 14, 100, 145), innerDivWithTransform, | 1007 CHECK_EXACT_VISUAL_RECT(LayoutRect(12, 14, 100, 145), innerDivWithTransform, |
| 1013 frameView->layoutView()); | 1008 frameView->layoutView()); |
| 1014 | 1009 |
| 1015 // Ensure that the inner div's transform is correctly rooted in the root | 1010 // Ensure that the inner div's transform is correctly rooted in the root |
| 1016 // frame's transform tree. | 1011 // frame's transform tree. |
| 1017 // This asserts that we have the following tree structure: | 1012 // This asserts that we have the following tree structure: |
| 1018 // ... | 1013 // ... |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 // PaintOffsetTranslation transform=translation=7.000000,7.000000,0.000000 | 1047 // PaintOffsetTranslation transform=translation=7.000000,7.000000,0.000000 |
| 1053 // Transform transform=translation=4.000000,5.000000,6.000000 | 1048 // Transform transform=translation=4.000000,5.000000,6.000000 |
| 1054 // PreTranslation transform=translation=42.000000,42.000000,0.000000 | 1049 // PreTranslation transform=translation=42.000000,42.000000,0.000000 |
| 1055 // ScrollTranslation transform=translation=0.000000,0.000000,0.00000 | 1050 // ScrollTranslation transform=translation=0.000000,0.000000,0.00000 |
| 1056 // PaintOffsetTranslation transform=translation=31.00,31.00,0.00 | 1051 // PaintOffsetTranslation transform=translation=31.00,31.00,0.00 |
| 1057 // Transform transform=translation=7.000000,8.000000,9.000000 | 1052 // Transform transform=translation=7.000000,8.000000,9.000000 |
| 1058 | 1053 |
| 1059 LayoutObject* innerDivWithTransform = | 1054 LayoutObject* innerDivWithTransform = |
| 1060 frameDocument.getElementById("transform")->layoutObject(); | 1055 frameDocument.getElementById("transform")->layoutObject(); |
| 1061 auto* innerDivTransform = | 1056 auto* innerDivTransform = |
| 1062 innerDivWithTransform->objectPaintProperties()->transform(); | 1057 innerDivWithTransform->paintProperties()->transform(); |
| 1063 EXPECT_EQ(TransformationMatrix().translate3d(7, 8, 9), | 1058 EXPECT_EQ(TransformationMatrix().translate3d(7, 8, 9), |
| 1064 innerDivTransform->matrix()); | 1059 innerDivTransform->matrix()); |
| 1065 CHECK_EXACT_VISUAL_RECT(LayoutRect(92, 95, 100, 111), innerDivWithTransform, | 1060 CHECK_EXACT_VISUAL_RECT(LayoutRect(92, 95, 100, 111), innerDivWithTransform, |
| 1066 frameView->layoutView()); | 1061 frameView->layoutView()); |
| 1067 | 1062 |
| 1068 auto* innerDocumentPaintOffsetTranslation = innerDivTransform->parent(); | 1063 auto* innerDocumentPaintOffsetTranslation = innerDivTransform->parent(); |
| 1069 EXPECT_EQ(TransformationMatrix().translate3d(31, 31, 0), | 1064 EXPECT_EQ(TransformationMatrix().translate3d(31, 31, 0), |
| 1070 innerDocumentPaintOffsetTranslation->matrix()); | 1065 innerDocumentPaintOffsetTranslation->matrix()); |
| 1071 auto* innerDocumentScrollTranslation = | 1066 auto* innerDocumentScrollTranslation = |
| 1072 innerDocumentPaintOffsetTranslation->parent(); | 1067 innerDocumentPaintOffsetTranslation->parent(); |
| 1073 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), | 1068 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), |
| 1074 innerDocumentScrollTranslation->matrix()); | 1069 innerDocumentScrollTranslation->matrix()); |
| 1075 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); | 1070 auto* iframePreTranslation = innerDocumentScrollTranslation->parent(); |
| 1076 EXPECT_EQ(TransformationMatrix().translate3d(42, 42, 0), | 1071 EXPECT_EQ(TransformationMatrix().translate3d(42, 42, 0), |
| 1077 iframePreTranslation->matrix()); | 1072 iframePreTranslation->matrix()); |
| 1078 auto* iframeTransform = iframePreTranslation->parent(); | 1073 auto* iframeTransform = iframePreTranslation->parent(); |
| 1079 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), | 1074 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), |
| 1080 iframeTransform->matrix()); | 1075 iframeTransform->matrix()); |
| 1081 auto* iframePaintOffsetTranslation = iframeTransform->parent(); | 1076 auto* iframePaintOffsetTranslation = iframeTransform->parent(); |
| 1082 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), | 1077 EXPECT_EQ(TransformationMatrix().translate3d(7, 7, 0), |
| 1083 iframePaintOffsetTranslation->matrix()); | 1078 iframePaintOffsetTranslation->matrix()); |
| 1084 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); | 1079 auto* divWithTransformTransform = iframePaintOffsetTranslation->parent(); |
| 1085 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), | 1080 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), |
| 1086 divWithTransformTransform->matrix()); | 1081 divWithTransformTransform->matrix()); |
| 1087 | 1082 |
| 1088 LayoutObject* divWithTransform = | 1083 LayoutObject* divWithTransform = |
| 1089 document().getElementById("divWithTransform")->layoutObject(); | 1084 document().getElementById("divWithTransform")->layoutObject(); |
| 1090 EXPECT_EQ(divWithTransformTransform, | 1085 EXPECT_EQ(divWithTransformTransform, |
| 1091 divWithTransform->objectPaintProperties()->transform()); | 1086 divWithTransform->paintProperties()->transform()); |
| 1092 // http://crbug.com/638415 | 1087 // http://crbug.com/638415 |
| 1093 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 1088 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 1094 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 248), divWithTransform, | 1089 CHECK_EXACT_VISUAL_RECT(LayoutRect(1, 2, 800, 248), divWithTransform, |
| 1095 frameView->layoutView()); | 1090 frameView->layoutView()); |
| 1096 } | 1091 } |
| 1097 } | 1092 } |
| 1098 | 1093 |
| 1099 TEST_P(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) { | 1094 TEST_P(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext) { |
| 1100 // This test verifies the tree builder correctly computes and records the | 1095 // This test verifies the tree builder correctly computes and records the |
| 1101 // property tree context for a (pseudo) stacking context that is scrolled by a | 1096 // property tree context for a (pseudo) stacking context that is scrolled by a |
| 1102 // containing block that is not one of the painting ancestors. | 1097 // containing block that is not one of the painting ancestors. |
| 1103 setBodyInnerHTML( | 1098 setBodyInnerHTML( |
| 1104 "<style>body { margin: 0; }</style>" | 1099 "<style>body { margin: 0; }</style>" |
| 1105 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>" | 1100 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'>" |
| 1106 " <div id='child' style='position:relative; width:100px; height: " | 1101 " <div id='child' style='position:relative; width:100px; height: " |
| 1107 "200px;'></div>" | 1102 "200px;'></div>" |
| 1108 " <div style='height:10000px;'></div>" | 1103 " <div style='height:10000px;'></div>" |
| 1109 "</div>"); | 1104 "</div>"); |
| 1110 FrameView* frameView = document().view(); | 1105 FrameView* frameView = document().view(); |
| 1111 | 1106 |
| 1112 LayoutObject* scroller = | 1107 LayoutObject* scroller = |
| 1113 document().getElementById("scroller")->layoutObject(); | 1108 document().getElementById("scroller")->layoutObject(); |
| 1114 const ObjectPaintProperties* scrollerProperties = | 1109 const ObjectPaintProperties* scrollerProperties = scroller->paintProperties(); |
| 1115 scroller->objectPaintProperties(); | |
| 1116 LayoutObject* child = document().getElementById("child")->layoutObject(); | 1110 LayoutObject* child = document().getElementById("child")->layoutObject(); |
| 1117 const ObjectPaintProperties* childProperties = child->objectPaintProperties(); | 1111 const ObjectPaintProperties* childProperties = child->paintProperties(); |
| 1118 | 1112 |
| 1119 EXPECT_EQ( | 1113 EXPECT_EQ( |
| 1120 scrollerProperties->overflowClip(), | 1114 scrollerProperties->overflowClip(), |
| 1121 childProperties->localBorderBoxProperties()->propertyTreeState.clip()); | 1115 childProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 1122 EXPECT_EQ(scrollerProperties->scrollTranslation(), | 1116 EXPECT_EQ(scrollerProperties->scrollTranslation(), |
| 1123 childProperties->localBorderBoxProperties() | 1117 childProperties->localBorderBoxProperties() |
| 1124 ->propertyTreeState.transform()); | 1118 ->propertyTreeState.transform()); |
| 1125 EXPECT_NE( | 1119 EXPECT_NE( |
| 1126 nullptr, | 1120 nullptr, |
| 1127 childProperties->localBorderBoxProperties()->propertyTreeState.effect()); | 1121 childProperties->localBorderBoxProperties()->propertyTreeState.effect()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1141 setBodyInnerHTML( | 1135 setBodyInnerHTML( |
| 1142 "<style>body { margin: 0; }</style>" | 1136 "<style>body { margin: 0; }</style>" |
| 1143 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" | 1137 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>" |
| 1144 " <div id='child' style='position:absolute; left:0; top:0; width: " | 1138 " <div id='child' style='position:absolute; left:0; top:0; width: " |
| 1145 "100px; height: 200px'></div>" | 1139 "100px; height: 200px'></div>" |
| 1146 " <div style='height:10000px;'></div>" | 1140 " <div style='height:10000px;'></div>" |
| 1147 "</div>"); | 1141 "</div>"); |
| 1148 | 1142 |
| 1149 LayoutObject& scroller = | 1143 LayoutObject& scroller = |
| 1150 *document().getElementById("scroller")->layoutObject(); | 1144 *document().getElementById("scroller")->layoutObject(); |
| 1151 const ObjectPaintProperties* scrollerProperties = | 1145 const ObjectPaintProperties* scrollerProperties = scroller.paintProperties(); |
| 1152 scroller.objectPaintProperties(); | |
| 1153 LayoutObject& child = *document().getElementById("child")->layoutObject(); | 1146 LayoutObject& child = *document().getElementById("child")->layoutObject(); |
| 1154 const ObjectPaintProperties* childProperties = child.objectPaintProperties(); | 1147 const ObjectPaintProperties* childProperties = child.paintProperties(); |
| 1155 | 1148 |
| 1156 EXPECT_EQ( | 1149 EXPECT_EQ( |
| 1157 frameContentClip(), | 1150 frameContentClip(), |
| 1158 childProperties->localBorderBoxProperties()->propertyTreeState.clip()); | 1151 childProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 1159 EXPECT_EQ(frameScrollTranslation(), | 1152 EXPECT_EQ(frameScrollTranslation(), |
| 1160 childProperties->localBorderBoxProperties() | 1153 childProperties->localBorderBoxProperties() |
| 1161 ->propertyTreeState.transform()); | 1154 ->propertyTreeState.transform()); |
| 1162 EXPECT_EQ( | 1155 EXPECT_EQ( |
| 1163 scrollerProperties->effect(), | 1156 scrollerProperties->effect(), |
| 1164 childProperties->localBorderBoxProperties()->propertyTreeState.effect()); | 1157 childProperties->localBorderBoxProperties()->propertyTreeState.effect()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1195 " width: 100px;" | 1188 " width: 100px;" |
| 1196 " height: 100px;" | 1189 " height: 100px;" |
| 1197 " }" | 1190 " }" |
| 1198 "</style>" | 1191 "</style>" |
| 1199 "<table>" | 1192 "<table>" |
| 1200 " <tr><td></td><td></td></tr>" | 1193 " <tr><td></td><td></td></tr>" |
| 1201 " <tr><td></td><td><div id='target'></div></td></tr>" | 1194 " <tr><td></td><td><div id='target'></div></td></tr>" |
| 1202 "</table>"); | 1195 "</table>"); |
| 1203 | 1196 |
| 1204 LayoutObject& target = *document().getElementById("target")->layoutObject(); | 1197 LayoutObject& target = *document().getElementById("target")->layoutObject(); |
| 1205 const ObjectPaintProperties* targetProperties = | 1198 const ObjectPaintProperties* targetProperties = target.paintProperties(); |
| 1206 target.objectPaintProperties(); | |
| 1207 | 1199 |
| 1208 EXPECT_EQ(LayoutPoint(170, 170), | 1200 EXPECT_EQ(LayoutPoint(170, 170), |
| 1209 targetProperties->localBorderBoxProperties()->paintOffset); | 1201 targetProperties->localBorderBoxProperties()->paintOffset); |
| 1210 EXPECT_EQ(framePreTranslation(), targetProperties->localBorderBoxProperties() | 1202 EXPECT_EQ(framePreTranslation(), targetProperties->localBorderBoxProperties() |
| 1211 ->propertyTreeState.transform()); | 1203 ->propertyTreeState.transform()); |
| 1212 CHECK_EXACT_VISUAL_RECT(LayoutRect(170, 170, 100, 100), &target, | 1204 CHECK_EXACT_VISUAL_RECT(LayoutRect(170, 170, 100, 100), &target, |
| 1213 document().view()->layoutView()); | 1205 document().view()->layoutView()); |
| 1214 } | 1206 } |
| 1215 | 1207 |
| 1216 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) { | 1208 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1234 " width: 10px;" | 1226 " width: 10px;" |
| 1235 " height: 20px" | 1227 " height: 20px" |
| 1236 " }" | 1228 " }" |
| 1237 "</style>" | 1229 "</style>" |
| 1238 "<div id='clip'><div id='fixed'></div></div>"); | 1230 "<div id='clip'><div id='fixed'></div></div>"); |
| 1239 LayoutRect localClipRect(40, 10, 40, 60); | 1231 LayoutRect localClipRect(40, 10, 40, 60); |
| 1240 LayoutRect absoluteClipRect = localClipRect; | 1232 LayoutRect absoluteClipRect = localClipRect; |
| 1241 absoluteClipRect.move(123, 456); | 1233 absoluteClipRect.move(123, 456); |
| 1242 | 1234 |
| 1243 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); | 1235 LayoutObject& clip = *document().getElementById("clip")->layoutObject(); |
| 1244 const ObjectPaintProperties* clipProperties = clip.objectPaintProperties(); | 1236 const ObjectPaintProperties* clipProperties = clip.paintProperties(); |
| 1245 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent()); | 1237 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent()); |
| 1246 EXPECT_EQ(framePreTranslation(), | 1238 EXPECT_EQ(framePreTranslation(), |
| 1247 clipProperties->cssClip()->localTransformSpace()); | 1239 clipProperties->cssClip()->localTransformSpace()); |
| 1248 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), | 1240 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), |
| 1249 clipProperties->cssClip()->clipRect()); | 1241 clipProperties->cssClip()->clipRect()); |
| 1250 CHECK_VISUAL_RECT(absoluteClipRect, &clip, document().view()->layoutView(), | 1242 CHECK_VISUAL_RECT(absoluteClipRect, &clip, document().view()->layoutView(), |
| 1251 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() | 1243 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() |
| 1252 // doesn't apply css clip on the object itself. | 1244 // doesn't apply css clip on the object itself. |
| 1253 LayoutUnit::max()); | 1245 LayoutUnit::max()); |
| 1254 | 1246 |
| 1255 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 1247 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 1256 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(); | 1248 const ObjectPaintProperties* fixedProperties = fixed->paintProperties(); |
| 1257 EXPECT_EQ( | 1249 EXPECT_EQ( |
| 1258 clipProperties->cssClip(), | 1250 clipProperties->cssClip(), |
| 1259 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); | 1251 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 1260 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() | 1252 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() |
| 1261 ->propertyTreeState.transform() | 1253 ->propertyTreeState.transform() |
| 1262 ->parent()); | 1254 ->parent()); |
| 1263 EXPECT_EQ(TransformationMatrix().translate(654, 321), | 1255 EXPECT_EQ(TransformationMatrix().translate(654, 321), |
| 1264 fixedProperties->localBorderBoxProperties() | 1256 fixedProperties->localBorderBoxProperties() |
| 1265 ->propertyTreeState.transform() | 1257 ->propertyTreeState.transform() |
| 1266 ->matrix()); | 1258 ->matrix()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1295 " heght: 20px" | 1287 " heght: 20px" |
| 1296 " }" | 1288 " }" |
| 1297 "</style>" | 1289 "</style>" |
| 1298 "<div id='clip'><div id='absolute'></div></div>"); | 1290 "<div id='clip'><div id='absolute'></div></div>"); |
| 1299 | 1291 |
| 1300 LayoutRect localClipRect(40, 10, 40, 60); | 1292 LayoutRect localClipRect(40, 10, 40, 60); |
| 1301 LayoutRect absoluteClipRect = localClipRect; | 1293 LayoutRect absoluteClipRect = localClipRect; |
| 1302 absoluteClipRect.move(123, 456); | 1294 absoluteClipRect.move(123, 456); |
| 1303 | 1295 |
| 1304 LayoutObject* clip = document().getElementById("clip")->layoutObject(); | 1296 LayoutObject* clip = document().getElementById("clip")->layoutObject(); |
| 1305 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); | 1297 const ObjectPaintProperties* clipProperties = clip->paintProperties(); |
| 1306 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent()); | 1298 EXPECT_EQ(frameContentClip(), clipProperties->cssClip()->parent()); |
| 1307 // No scroll translation because the document does not scroll (not enough | 1299 // No scroll translation because the document does not scroll (not enough |
| 1308 // content). | 1300 // content). |
| 1309 EXPECT_TRUE(!frameScrollTranslation()); | 1301 EXPECT_TRUE(!frameScrollTranslation()); |
| 1310 EXPECT_EQ(framePreTranslation(), | 1302 EXPECT_EQ(framePreTranslation(), |
| 1311 clipProperties->cssClip()->localTransformSpace()); | 1303 clipProperties->cssClip()->localTransformSpace()); |
| 1312 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), | 1304 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), |
| 1313 clipProperties->cssClip()->clipRect()); | 1305 clipProperties->cssClip()->clipRect()); |
| 1314 CHECK_VISUAL_RECT(absoluteClipRect, clip, document().view()->layoutView(), | 1306 CHECK_VISUAL_RECT(absoluteClipRect, clip, document().view()->layoutView(), |
| 1315 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() | 1307 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() |
| 1316 // doesn't apply css clip on the object itself. | 1308 // doesn't apply css clip on the object itself. |
| 1317 LayoutUnit::max()); | 1309 LayoutUnit::max()); |
| 1318 | 1310 |
| 1319 LayoutObject* absolute = | 1311 LayoutObject* absolute = |
| 1320 document().getElementById("absolute")->layoutObject(); | 1312 document().getElementById("absolute")->layoutObject(); |
| 1321 const ObjectPaintProperties* absPosProperties = | 1313 const ObjectPaintProperties* absPosProperties = absolute->paintProperties(); |
| 1322 absolute->objectPaintProperties(); | |
| 1323 EXPECT_EQ( | 1314 EXPECT_EQ( |
| 1324 clipProperties->cssClip(), | 1315 clipProperties->cssClip(), |
| 1325 absPosProperties->localBorderBoxProperties()->propertyTreeState.clip()); | 1316 absPosProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 1326 EXPECT_EQ(framePreTranslation(), absPosProperties->localBorderBoxProperties() | 1317 EXPECT_EQ(framePreTranslation(), absPosProperties->localBorderBoxProperties() |
| 1327 ->propertyTreeState.transform()); | 1318 ->propertyTreeState.transform()); |
| 1328 EXPECT_EQ(LayoutPoint(123, 456), | 1319 EXPECT_EQ(LayoutPoint(123, 456), |
| 1329 absPosProperties->localBorderBoxProperties()->paintOffset); | 1320 absPosProperties->localBorderBoxProperties()->paintOffset); |
| 1330 CHECK_VISUAL_RECT(LayoutRect(), absolute, document().view()->layoutView(), | 1321 CHECK_VISUAL_RECT(LayoutRect(), absolute, document().view()->layoutView(), |
| 1331 // TODO(crbug.com/599939): CSS clip of fixed-position | 1322 // TODO(crbug.com/599939): CSS clip of fixed-position |
| 1332 // descendants is broken in | 1323 // descendants is broken in |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1363 " top: 321px;" | 1354 " top: 321px;" |
| 1364 " }" | 1355 " }" |
| 1365 "</style>" | 1356 "</style>" |
| 1366 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>"); | 1357 "<div id='overflow'><div id='clip'><div id='fixed'></div></div></div>"); |
| 1367 LayoutRect localClipRect(40, 10, 40, 60); | 1358 LayoutRect localClipRect(40, 10, 40, 60); |
| 1368 LayoutRect absoluteClipRect = localClipRect; | 1359 LayoutRect absoluteClipRect = localClipRect; |
| 1369 absoluteClipRect.move(123, 456); | 1360 absoluteClipRect.move(123, 456); |
| 1370 | 1361 |
| 1371 LayoutObject& overflow = | 1362 LayoutObject& overflow = |
| 1372 *document().getElementById("overflow")->layoutObject(); | 1363 *document().getElementById("overflow")->layoutObject(); |
| 1373 const ObjectPaintProperties* overflowProperties = | 1364 const ObjectPaintProperties* overflowProperties = overflow.paintProperties(); |
| 1374 overflow.objectPaintProperties(); | |
| 1375 EXPECT_EQ(frameContentClip(), overflowProperties->overflowClip()->parent()); | 1365 EXPECT_EQ(frameContentClip(), overflowProperties->overflowClip()->parent()); |
| 1376 // No scroll translation because the document does not scroll (not enough | 1366 // No scroll translation because the document does not scroll (not enough |
| 1377 // content). | 1367 // content). |
| 1378 EXPECT_TRUE(!frameScrollTranslation()); | 1368 EXPECT_TRUE(!frameScrollTranslation()); |
| 1379 EXPECT_EQ(framePreTranslation(), | 1369 EXPECT_EQ(framePreTranslation(), |
| 1380 overflowProperties->scrollTranslation()->parent()); | 1370 overflowProperties->scrollTranslation()->parent()); |
| 1381 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 50, 50), &overflow, | 1371 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 50, 50), &overflow, |
| 1382 document().view()->layoutView()); | 1372 document().view()->layoutView()); |
| 1383 | 1373 |
| 1384 LayoutObject* clip = document().getElementById("clip")->layoutObject(); | 1374 LayoutObject* clip = document().getElementById("clip")->layoutObject(); |
| 1385 const ObjectPaintProperties* clipProperties = clip->objectPaintProperties(); | 1375 const ObjectPaintProperties* clipProperties = clip->paintProperties(); |
| 1386 EXPECT_EQ(overflowProperties->overflowClip(), | 1376 EXPECT_EQ(overflowProperties->overflowClip(), |
| 1387 clipProperties->cssClip()->parent()); | 1377 clipProperties->cssClip()->parent()); |
| 1388 EXPECT_EQ(overflowProperties->scrollTranslation(), | 1378 EXPECT_EQ(overflowProperties->scrollTranslation(), |
| 1389 clipProperties->cssClip()->localTransformSpace()); | 1379 clipProperties->cssClip()->localTransformSpace()); |
| 1390 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), | 1380 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), |
| 1391 clipProperties->cssClip()->clipRect()); | 1381 clipProperties->cssClip()->clipRect()); |
| 1392 EXPECT_EQ(frameContentClip(), | 1382 EXPECT_EQ(frameContentClip(), |
| 1393 clipProperties->cssClipFixedPosition()->parent()); | 1383 clipProperties->cssClipFixedPosition()->parent()); |
| 1394 EXPECT_EQ(overflowProperties->scrollTranslation(), | 1384 EXPECT_EQ(overflowProperties->scrollTranslation(), |
| 1395 clipProperties->cssClipFixedPosition()->localTransformSpace()); | 1385 clipProperties->cssClipFixedPosition()->localTransformSpace()); |
| 1396 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), | 1386 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), |
| 1397 clipProperties->cssClipFixedPosition()->clipRect()); | 1387 clipProperties->cssClipFixedPosition()->clipRect()); |
| 1398 CHECK_EXACT_VISUAL_RECT(LayoutRect(), clip, document().view()->layoutView()); | 1388 CHECK_EXACT_VISUAL_RECT(LayoutRect(), clip, document().view()->layoutView()); |
| 1399 | 1389 |
| 1400 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 1390 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 1401 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(); | 1391 const ObjectPaintProperties* fixedProperties = fixed->paintProperties(); |
| 1402 EXPECT_EQ( | 1392 EXPECT_EQ( |
| 1403 clipProperties->cssClipFixedPosition(), | 1393 clipProperties->cssClipFixedPosition(), |
| 1404 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); | 1394 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 1405 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() | 1395 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() |
| 1406 ->propertyTreeState.transform() | 1396 ->propertyTreeState.transform() |
| 1407 ->parent()); | 1397 ->parent()); |
| 1408 EXPECT_EQ(TransformationMatrix().translate(654, 321), | 1398 EXPECT_EQ(TransformationMatrix().translate(654, 321), |
| 1409 fixedProperties->localBorderBoxProperties() | 1399 fixedProperties->localBorderBoxProperties() |
| 1410 ->propertyTreeState.transform() | 1400 ->propertyTreeState.transform() |
| 1411 ->matrix()); | 1401 ->matrix()); |
| 1412 EXPECT_EQ(LayoutPoint(), | 1402 EXPECT_EQ(LayoutPoint(), |
| 1413 fixedProperties->localBorderBoxProperties()->paintOffset); | 1403 fixedProperties->localBorderBoxProperties()->paintOffset); |
| 1414 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(), | 1404 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(), |
| 1415 // TODO(crbug.com/599939): CSS clip of fixed-position | 1405 // TODO(crbug.com/599939): CSS clip of fixed-position |
| 1416 // descendants is broken in geometry mapping. | 1406 // descendants is broken in geometry mapping. |
| 1417 LayoutUnit::max()); | 1407 LayoutUnit::max()); |
| 1418 } | 1408 } |
| 1419 | 1409 |
| 1420 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) { | 1410 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) { |
| 1421 setBodyInnerHTML( | 1411 setBodyInnerHTML( |
| 1422 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" | 1412 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" |
| 1423 " <div style='position: relative; top: 100px; left: 100px'>" | 1413 " <div style='position: relative; top: 100px; left: 100px'>" |
| 1424 " <div id='spanner' style='column-span: all; opacity: 0.5; width: " | 1414 " <div id='spanner' style='column-span: all; opacity: 0.5; width: " |
| 1425 "100px; height: 100px;'></div>" | 1415 "100px; height: 100px;'></div>" |
| 1426 " </div>" | 1416 " </div>" |
| 1427 "</div>"); | 1417 "</div>"); |
| 1428 | 1418 |
| 1429 LayoutObject* spanner = getLayoutObjectByElementId("spanner"); | 1419 LayoutObject* spanner = getLayoutObjectByElementId("spanner"); |
| 1430 EXPECT_EQ(LayoutPoint(55, 44), spanner->objectPaintProperties() | 1420 EXPECT_EQ( |
| 1431 ->localBorderBoxProperties() | 1421 LayoutPoint(55, 44), |
| 1432 ->paintOffset); | 1422 spanner->paintProperties()->localBorderBoxProperties()->paintOffset); |
| 1433 CHECK_EXACT_VISUAL_RECT(LayoutRect(55, 44, 100, 100), spanner, | 1423 CHECK_EXACT_VISUAL_RECT(LayoutRect(55, 44, 100, 100), spanner, |
| 1434 document().view()->layoutView()); | 1424 document().view()->layoutView()); |
| 1435 } | 1425 } |
| 1436 | 1426 |
| 1437 TEST_P(PaintPropertyTreeBuilderTest, FractionalPaintOffset) { | 1427 TEST_P(PaintPropertyTreeBuilderTest, FractionalPaintOffset) { |
| 1438 setBodyInnerHTML( | 1428 setBodyInnerHTML( |
| 1439 "<style>" | 1429 "<style>" |
| 1440 " * { margin: 0; }" | 1430 " * { margin: 0; }" |
| 1441 " div { position: absolute; }" | 1431 " div { position: absolute; }" |
| 1442 "</style>" | 1432 "</style>" |
| 1443 "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;'>" | 1433 "<div id='a' style='width: 70px; height: 70px; left: 0.1px; top: 0.3px;'>" |
| 1444 " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: " | 1434 " <div id='b' style='width: 40px; height: 40px; left: 0.5px; top: " |
| 1445 "11.1px;'></div>" | 1435 "11.1px;'></div>" |
| 1446 "</div>"); | 1436 "</div>"); |
| 1447 FrameView* frameView = document().view(); | 1437 FrameView* frameView = document().view(); |
| 1448 | 1438 |
| 1449 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1439 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1450 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1440 const ObjectPaintProperties* aProperties = a->paintProperties(); |
| 1451 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3)); | 1441 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3)); |
| 1452 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset); | 1442 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset); |
| 1453 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.1), LayoutUnit(0.3), | 1443 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.1), LayoutUnit(0.3), |
| 1454 LayoutUnit(70), LayoutUnit(70)), | 1444 LayoutUnit(70), LayoutUnit(70)), |
| 1455 a, frameView->layoutView()); | 1445 a, frameView->layoutView()); |
| 1456 | 1446 |
| 1457 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1447 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1458 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1448 const ObjectPaintProperties* bProperties = b->paintProperties(); |
| 1459 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1)); | 1449 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1)); |
| 1460 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset); | 1450 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset); |
| 1461 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.1), LayoutUnit(0.3), | 1451 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.1), LayoutUnit(0.3), |
| 1462 LayoutUnit(70), LayoutUnit(70)), | 1452 LayoutUnit(70), LayoutUnit(70)), |
| 1463 a, frameView->layoutView()); | 1453 a, frameView->layoutView()); |
| 1464 } | 1454 } |
| 1465 | 1455 |
| 1466 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping) { | 1456 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping) { |
| 1467 setBodyInnerHTML( | 1457 setBodyInnerHTML( |
| 1468 "<style>" | 1458 "<style>" |
| 1469 " * { margin: 0; }" | 1459 " * { margin: 0; }" |
| 1470 " div { position: relative; }" | 1460 " div { position: relative; }" |
| 1471 "</style>" | 1461 "</style>" |
| 1472 "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;'>" | 1462 "<div id='a' style='width: 70px; height: 70px; left: 0.3px; top: 0.3px;'>" |
| 1473 " <div id='b' style='width: 40px; height: 40px; transform: " | 1463 " <div id='b' style='width: 40px; height: 40px; transform: " |
| 1474 "translateZ(0);'>" | 1464 "translateZ(0);'>" |
| 1475 " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: " | 1465 " <div id='c' style='width: 40px; height: 40px; left: 0.1px; top: " |
| 1476 "0.1px;'></div>" | 1466 "0.1px;'></div>" |
| 1477 " </div>" | 1467 " </div>" |
| 1478 "</div>"); | 1468 "</div>"); |
| 1479 FrameView* frameView = document().view(); | 1469 FrameView* frameView = document().view(); |
| 1480 | 1470 |
| 1481 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1471 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1482 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1472 const ObjectPaintProperties* bProperties = b->paintProperties(); |
| 1483 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), | 1473 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), |
| 1484 bProperties->transform()->matrix()); | 1474 bProperties->transform()->matrix()); |
| 1485 // The paint offset transform should be snapped from (0.3,0.3) to (0,0). | 1475 // The paint offset transform should be snapped from (0.3,0.3) to (0,0). |
| 1486 EXPECT_EQ(TransformationMatrix().translate(0, 0), | 1476 EXPECT_EQ(TransformationMatrix().translate(0, 0), |
| 1487 bProperties->transform()->parent()->matrix()); | 1477 bProperties->transform()->parent()->matrix()); |
| 1488 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3). | 1478 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3). |
| 1489 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3)); | 1479 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3)); |
| 1490 EXPECT_EQ(subpixelAccumulation, | 1480 EXPECT_EQ(subpixelAccumulation, |
| 1491 bProperties->localBorderBoxProperties()->paintOffset); | 1481 bProperties->localBorderBoxProperties()->paintOffset); |
| 1492 CHECK_EXACT_VISUAL_RECT(LayoutRect(FloatRect(0.3, 0.3, 40, 40)), b, | 1482 CHECK_EXACT_VISUAL_RECT(LayoutRect(FloatRect(0.3, 0.3, 40, 40)), b, |
| 1493 frameView->layoutView()); | 1483 frameView->layoutView()); |
| 1494 | 1484 |
| 1495 // c should be painted starting at subpixelAccumulation + (0.1,0.1) = | 1485 // c should be painted starting at subpixelAccumulation + (0.1,0.1) = |
| 1496 // (0.4,0.4). | 1486 // (0.4,0.4). |
| 1497 LayoutObject* c = document().getElementById("c")->layoutObject(); | 1487 LayoutObject* c = document().getElementById("c")->layoutObject(); |
| 1498 LayoutPoint cPaintOffset = | 1488 LayoutPoint cPaintOffset = |
| 1499 subpixelAccumulation + LayoutPoint(FloatPoint(0.1, 0.1)); | 1489 subpixelAccumulation + LayoutPoint(FloatPoint(0.1, 0.1)); |
| 1500 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); | 1490 const ObjectPaintProperties* cProperties = c->paintProperties(); |
| 1501 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset); | 1491 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset); |
| 1502 // Visual rects via the non-paint properties system use enclosingIntRect | 1492 // Visual rects via the non-paint properties system use enclosingIntRect |
| 1503 // before applying transforms, because they are computed bottom-up and | 1493 // before applying transforms, because they are computed bottom-up and |
| 1504 // therefore can't apply pixel snapping. Therefore apply a slop of 1px. | 1494 // therefore can't apply pixel snapping. Therefore apply a slop of 1px. |
| 1505 CHECK_VISUAL_RECT(LayoutRect(FloatRect(0.4, 0.4, 40, 40)), c, | 1495 CHECK_VISUAL_RECT(LayoutRect(FloatRect(0.4, 0.4, 40, 40)), c, |
| 1506 frameView->layoutView(), 1); | 1496 frameView->layoutView(), 1); |
| 1507 } | 1497 } |
| 1508 | 1498 |
| 1509 TEST_P(PaintPropertyTreeBuilderTest, | 1499 TEST_P(PaintPropertyTreeBuilderTest, |
| 1510 PaintOffsetWithPixelSnappingThroughTransform) { | 1500 PaintOffsetWithPixelSnappingThroughTransform) { |
| 1511 setBodyInnerHTML( | 1501 setBodyInnerHTML( |
| 1512 "<style>" | 1502 "<style>" |
| 1513 " * { margin: 0; }" | 1503 " * { margin: 0; }" |
| 1514 " div { position: relative; }" | 1504 " div { position: relative; }" |
| 1515 "</style>" | 1505 "</style>" |
| 1516 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'>" | 1506 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; top: 0.7px;'>" |
| 1517 " <div id='b' style='width: 40px; height: 40px; transform: " | 1507 " <div id='b' style='width: 40px; height: 40px; transform: " |
| 1518 "translateZ(0);'>" | 1508 "translateZ(0);'>" |
| 1519 " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: " | 1509 " <div id='c' style='width: 40px; height: 40px; left: 0.7px; top: " |
| 1520 "0.7px;'></div>" | 1510 "0.7px;'></div>" |
| 1521 " </div>" | 1511 " </div>" |
| 1522 "</div>"); | 1512 "</div>"); |
| 1523 FrameView* frameView = document().view(); | 1513 FrameView* frameView = document().view(); |
| 1524 | 1514 |
| 1525 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1515 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1526 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1516 const ObjectPaintProperties* bProperties = b->paintProperties(); |
| 1527 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), | 1517 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), |
| 1528 bProperties->transform()->matrix()); | 1518 bProperties->transform()->matrix()); |
| 1529 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). | 1519 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). |
| 1530 EXPECT_EQ(TransformationMatrix().translate(1, 1), | 1520 EXPECT_EQ(TransformationMatrix().translate(1, 1), |
| 1531 bProperties->transform()->parent()->matrix()); | 1521 bProperties->transform()->parent()->matrix()); |
| 1532 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3). | 1522 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3). |
| 1533 LayoutPoint subpixelAccumulation = | 1523 LayoutPoint subpixelAccumulation = |
| 1534 LayoutPoint(LayoutPoint(FloatPoint(0.7, 0.7)) - LayoutPoint(1, 1)); | 1524 LayoutPoint(LayoutPoint(FloatPoint(0.7, 0.7)) - LayoutPoint(1, 1)); |
| 1535 EXPECT_EQ(subpixelAccumulation, | 1525 EXPECT_EQ(subpixelAccumulation, |
| 1536 bProperties->localBorderBoxProperties()->paintOffset); | 1526 bProperties->localBorderBoxProperties()->paintOffset); |
| 1537 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0.7), | 1527 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0.7), |
| 1538 LayoutUnit(40), LayoutUnit(40)), | 1528 LayoutUnit(40), LayoutUnit(40)), |
| 1539 b, frameView->layoutView()); | 1529 b, frameView->layoutView()); |
| 1540 | 1530 |
| 1541 // c should be painted starting at subpixelAccumulation + (0.7,0.7) = | 1531 // c should be painted starting at subpixelAccumulation + (0.7,0.7) = |
| 1542 // (0.4,0.4). | 1532 // (0.4,0.4). |
| 1543 LayoutObject* c = document().getElementById("c")->layoutObject(); | 1533 LayoutObject* c = document().getElementById("c")->layoutObject(); |
| 1544 LayoutPoint cPaintOffset = | 1534 LayoutPoint cPaintOffset = |
| 1545 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0.7)); | 1535 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0.7)); |
| 1546 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); | 1536 const ObjectPaintProperties* cProperties = c->paintProperties(); |
| 1547 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset); | 1537 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset); |
| 1548 // Visual rects via the non-paint properties system use enclosingIntRect | 1538 // Visual rects via the non-paint properties system use enclosingIntRect |
| 1549 // before applying transforms, because they are computed bottom-up and | 1539 // before applying transforms, because they are computed bottom-up and |
| 1550 // therefore can't apply pixel snapping. Therefore apply a slop of 1px. | 1540 // therefore can't apply pixel snapping. Therefore apply a slop of 1px. |
| 1551 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7), | 1541 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7), |
| 1552 LayoutUnit(0.7) + LayoutUnit(0.7), | 1542 LayoutUnit(0.7) + LayoutUnit(0.7), |
| 1553 LayoutUnit(40), LayoutUnit(40)), | 1543 LayoutUnit(40), LayoutUnit(40)), |
| 1554 c, frameView->layoutView(), 1); | 1544 c, frameView->layoutView(), 1); |
| 1555 } | 1545 } |
| 1556 | 1546 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1567 " <div id='c' style='width: 40px; height: 40px; transform: " | 1557 " <div id='c' style='width: 40px; height: 40px; transform: " |
| 1568 "translate3d(11px, 13px, 0);'>" | 1558 "translate3d(11px, 13px, 0);'>" |
| 1569 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: " | 1559 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; top: " |
| 1570 "0.7px;'></div>" | 1560 "0.7px;'></div>" |
| 1571 " </div>" | 1561 " </div>" |
| 1572 " </div>" | 1562 " </div>" |
| 1573 "</div>"); | 1563 "</div>"); |
| 1574 FrameView* frameView = document().view(); | 1564 FrameView* frameView = document().view(); |
| 1575 | 1565 |
| 1576 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1566 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1577 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1567 const ObjectPaintProperties* bProperties = b->paintProperties(); |
| 1578 EXPECT_EQ(TransformationMatrix().translate3d(5, 7, 0), | 1568 EXPECT_EQ(TransformationMatrix().translate3d(5, 7, 0), |
| 1579 bProperties->transform()->matrix()); | 1569 bProperties->transform()->matrix()); |
| 1580 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). | 1570 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). |
| 1581 EXPECT_EQ(TransformationMatrix().translate(1, 1), | 1571 EXPECT_EQ(TransformationMatrix().translate(1, 1), |
| 1582 bProperties->transform()->parent()->matrix()); | 1572 bProperties->transform()->parent()->matrix()); |
| 1583 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3). | 1573 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3). |
| 1584 LayoutPoint subpixelAccumulation = | 1574 LayoutPoint subpixelAccumulation = |
| 1585 LayoutPoint(LayoutPoint(FloatPoint(0.7, 0.7)) - LayoutPoint(1, 1)); | 1575 LayoutPoint(LayoutPoint(FloatPoint(0.7, 0.7)) - LayoutPoint(1, 1)); |
| 1586 EXPECT_EQ(subpixelAccumulation, | 1576 EXPECT_EQ(subpixelAccumulation, |
| 1587 bProperties->localBorderBoxProperties()->paintOffset); | 1577 bProperties->localBorderBoxProperties()->paintOffset); |
| 1588 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(5.7), LayoutUnit(7.7), | 1578 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(5.7), LayoutUnit(7.7), |
| 1589 LayoutUnit(40), LayoutUnit(40)), | 1579 LayoutUnit(40), LayoutUnit(40)), |
| 1590 b, frameView->layoutView()); | 1580 b, frameView->layoutView()); |
| 1591 | 1581 |
| 1592 LayoutObject* c = document().getElementById("c")->layoutObject(); | 1582 LayoutObject* c = document().getElementById("c")->layoutObject(); |
| 1593 const ObjectPaintProperties* cProperties = c->objectPaintProperties(); | 1583 const ObjectPaintProperties* cProperties = c->paintProperties(); |
| 1594 EXPECT_EQ(TransformationMatrix().translate3d(11, 13, 0), | 1584 EXPECT_EQ(TransformationMatrix().translate3d(11, 13, 0), |
| 1595 cProperties->transform()->matrix()); | 1585 cProperties->transform()->matrix()); |
| 1596 // The paint offset should be (-0.3,-0.3) but the paint offset transform | 1586 // The paint offset should be (-0.3,-0.3) but the paint offset transform |
| 1597 // should still be at (0,0) because it should be snapped. | 1587 // should still be at (0,0) because it should be snapped. |
| 1598 EXPECT_EQ(TransformationMatrix().translate(0, 0), | 1588 EXPECT_EQ(TransformationMatrix().translate(0, 0), |
| 1599 cProperties->transform()->parent()->matrix()); | 1589 cProperties->transform()->parent()->matrix()); |
| 1600 // The residual subpixel adjustment should still be (-0.3,-0.3). | 1590 // The residual subpixel adjustment should still be (-0.3,-0.3). |
| 1601 EXPECT_EQ(subpixelAccumulation, | 1591 EXPECT_EQ(subpixelAccumulation, |
| 1602 cProperties->localBorderBoxProperties()->paintOffset); | 1592 cProperties->localBorderBoxProperties()->paintOffset); |
| 1603 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(16.7), LayoutUnit(20.7), | 1593 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(16.7), LayoutUnit(20.7), |
| 1604 LayoutUnit(40), LayoutUnit(40)), | 1594 LayoutUnit(40), LayoutUnit(40)), |
| 1605 c, frameView->layoutView()); | 1595 c, frameView->layoutView()); |
| 1606 | 1596 |
| 1607 // d should be painted starting at subpixelAccumulation + (0.7,0.7) = | 1597 // d should be painted starting at subpixelAccumulation + (0.7,0.7) = |
| 1608 // (0.4,0.4). | 1598 // (0.4,0.4). |
| 1609 LayoutObject* d = document().getElementById("d")->layoutObject(); | 1599 LayoutObject* d = document().getElementById("d")->layoutObject(); |
| 1610 LayoutPoint dPaintOffset = | 1600 LayoutPoint dPaintOffset = |
| 1611 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0.7)); | 1601 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0.7)); |
| 1612 const ObjectPaintProperties* dProperties = d->objectPaintProperties(); | 1602 const ObjectPaintProperties* dProperties = d->paintProperties(); |
| 1613 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset); | 1603 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset); |
| 1614 // Visual rects via the non-paint properties system use enclosingIntRect | 1604 // Visual rects via the non-paint properties system use enclosingIntRect |
| 1615 // before applying transforms, because they are computed bottom-up and | 1605 // before applying transforms, because they are computed bottom-up and |
| 1616 // therefore can't apply pixel snapping. Therefore apply a slop of 1px. | 1606 // therefore can't apply pixel snapping. Therefore apply a slop of 1px. |
| 1617 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(16.7) + LayoutUnit(0.7), | 1607 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(16.7) + LayoutUnit(0.7), |
| 1618 LayoutUnit(20.7) + LayoutUnit(0.7), | 1608 LayoutUnit(20.7) + LayoutUnit(0.7), |
| 1619 LayoutUnit(40), LayoutUnit(40)), | 1609 LayoutUnit(40), LayoutUnit(40)), |
| 1620 d, frameView->layoutView(), 1); | 1610 d, frameView->layoutView(), 1); |
| 1621 } | 1611 } |
| 1622 | 1612 |
| 1623 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) { | 1613 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) { |
| 1624 setBodyInnerHTML( | 1614 setBodyInnerHTML( |
| 1625 "<style>" | 1615 "<style>" |
| 1626 " * { margin: 0; }" | 1616 " * { margin: 0; }" |
| 1627 "</style>" | 1617 "</style>" |
| 1628 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: " | 1618 "<div id='a' style='width: 70px; height: 70px; left: 0.7px; position: " |
| 1629 "relative;'>" | 1619 "relative;'>" |
| 1630 " <div id='b' style='width: 40px; height: 40px; transform: " | 1620 " <div id='b' style='width: 40px; height: 40px; transform: " |
| 1631 "translateZ(0); position: relative;'>" | 1621 "translateZ(0); position: relative;'>" |
| 1632 " <div id='fixed' style='width: 40px; height: 40px; position: fixed;'>" | 1622 " <div id='fixed' style='width: 40px; height: 40px; position: fixed;'>" |
| 1633 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; " | 1623 " <div id='d' style='width: 40px; height: 40px; left: 0.7px; " |
| 1634 "position: relative;'></div>" | 1624 "position: relative;'></div>" |
| 1635 " </div>" | 1625 " </div>" |
| 1636 " </div>" | 1626 " </div>" |
| 1637 "</div>"); | 1627 "</div>"); |
| 1638 FrameView* frameView = document().view(); | 1628 FrameView* frameView = document().view(); |
| 1639 | 1629 |
| 1640 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1630 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1641 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1631 const ObjectPaintProperties* bProperties = b->paintProperties(); |
| 1642 EXPECT_EQ(TransformationMatrix().translate(0, 0), | 1632 EXPECT_EQ(TransformationMatrix().translate(0, 0), |
| 1643 bProperties->transform()->matrix()); | 1633 bProperties->transform()->matrix()); |
| 1644 // The paint offset transform should be snapped from (0.7,0) to (1,0). | 1634 // The paint offset transform should be snapped from (0.7,0) to (1,0). |
| 1645 EXPECT_EQ(TransformationMatrix().translate(1, 0), | 1635 EXPECT_EQ(TransformationMatrix().translate(1, 0), |
| 1646 bProperties->transform()->parent()->matrix()); | 1636 bProperties->transform()->parent()->matrix()); |
| 1647 // The residual subpixel adjustment should be (0.7,0) - (1,0) = (-0.3,0). | 1637 // The residual subpixel adjustment should be (0.7,0) - (1,0) = (-0.3,0). |
| 1648 LayoutPoint subpixelAccumulation = | 1638 LayoutPoint subpixelAccumulation = |
| 1649 LayoutPoint(LayoutPoint(FloatPoint(0.7, 0)) - LayoutPoint(1, 0)); | 1639 LayoutPoint(LayoutPoint(FloatPoint(0.7, 0)) - LayoutPoint(1, 0)); |
| 1650 EXPECT_EQ(subpixelAccumulation, | 1640 EXPECT_EQ(subpixelAccumulation, |
| 1651 bProperties->localBorderBoxProperties()->paintOffset); | 1641 bProperties->localBorderBoxProperties()->paintOffset); |
| 1652 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0), | 1642 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0), |
| 1653 LayoutUnit(40), LayoutUnit(40)), | 1643 LayoutUnit(40), LayoutUnit(40)), |
| 1654 b, frameView->layoutView()); | 1644 b, frameView->layoutView()); |
| 1655 | 1645 |
| 1656 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); | 1646 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); |
| 1657 const ObjectPaintProperties* fixedProperties = fixed->objectPaintProperties(); | 1647 const ObjectPaintProperties* fixedProperties = fixed->paintProperties(); |
| 1658 // The residual subpixel adjustment should still be (-0.3,0). | 1648 // The residual subpixel adjustment should still be (-0.3,0). |
| 1659 EXPECT_EQ(subpixelAccumulation, | 1649 EXPECT_EQ(subpixelAccumulation, |
| 1660 fixedProperties->localBorderBoxProperties()->paintOffset); | 1650 fixedProperties->localBorderBoxProperties()->paintOffset); |
| 1661 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0), | 1651 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0), |
| 1662 LayoutUnit(40), LayoutUnit(40)), | 1652 LayoutUnit(40), LayoutUnit(40)), |
| 1663 fixed, frameView->layoutView()); | 1653 fixed, frameView->layoutView()); |
| 1664 | 1654 |
| 1665 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0). | 1655 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0). |
| 1666 LayoutObject* d = document().getElementById("d")->layoutObject(); | 1656 LayoutObject* d = document().getElementById("d")->layoutObject(); |
| 1667 LayoutPoint dPaintOffset = | 1657 LayoutPoint dPaintOffset = |
| 1668 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0)); | 1658 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0)); |
| 1669 const ObjectPaintProperties* dProperties = d->objectPaintProperties(); | 1659 const ObjectPaintProperties* dProperties = d->paintProperties(); |
| 1670 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset); | 1660 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset); |
| 1671 // Visual rects via the non-paint properties system use enclosingIntRect | 1661 // Visual rects via the non-paint properties system use enclosingIntRect |
| 1672 // before applying transforms, because they are computed bottom-up and | 1662 // before applying transforms, because they are computed bottom-up and |
| 1673 // therefore can't apply pixel snapping. Therefore apply a slop of 1px. | 1663 // therefore can't apply pixel snapping. Therefore apply a slop of 1px. |
| 1674 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7), LayoutUnit(), | 1664 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7), LayoutUnit(), |
| 1675 LayoutUnit(40), LayoutUnit(40)), | 1665 LayoutUnit(40), LayoutUnit(40)), |
| 1676 d, frameView->layoutView(), 1); | 1666 d, frameView->layoutView(), 1); |
| 1677 } | 1667 } |
| 1678 | 1668 |
| 1679 TEST_P(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) { | 1669 TEST_P(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) { |
| 1680 setBodyInnerHTML( | 1670 setBodyInnerHTML( |
| 1681 "<svg id='svg' style='position: relative; left: 0.1px; transform: " | 1671 "<svg id='svg' style='position: relative; left: 0.1px; transform: " |
| 1682 "matrix(1, 0, 0, 1, 0, 0);'>" | 1672 "matrix(1, 0, 0, 1, 0, 0);'>" |
| 1683 " <rect id='rect' transform='translate(1, 1)'/>" | 1673 " <rect id='rect' transform='translate(1, 1)'/>" |
| 1684 "</svg>"); | 1674 "</svg>"); |
| 1685 | 1675 |
| 1686 LayoutObject& svgWithTransform = | 1676 LayoutObject& svgWithTransform = |
| 1687 *document().getElementById("svg")->layoutObject(); | 1677 *document().getElementById("svg")->layoutObject(); |
| 1688 const ObjectPaintProperties* svgWithTransformProperties = | 1678 const ObjectPaintProperties* svgWithTransformProperties = |
| 1689 svgWithTransform.objectPaintProperties(); | 1679 svgWithTransform.paintProperties(); |
| 1690 EXPECT_EQ(TransformationMatrix(), | 1680 EXPECT_EQ(TransformationMatrix(), |
| 1691 svgWithTransformProperties->transform()->matrix()); | 1681 svgWithTransformProperties->transform()->matrix()); |
| 1692 EXPECT_EQ( | 1682 EXPECT_EQ( |
| 1693 LayoutPoint(FloatPoint(0.1, 0)), | 1683 LayoutPoint(FloatPoint(0.1, 0)), |
| 1694 svgWithTransformProperties->localBorderBoxProperties()->paintOffset); | 1684 svgWithTransformProperties->localBorderBoxProperties()->paintOffset); |
| 1695 EXPECT_EQ(nullptr, | 1685 EXPECT_EQ(nullptr, |
| 1696 svgWithTransformProperties->svgLocalToBorderBoxTransform()); | 1686 svgWithTransformProperties->svgLocalToBorderBoxTransform()); |
| 1697 | 1687 |
| 1698 LayoutObject& rectWithTransform = | 1688 LayoutObject& rectWithTransform = |
| 1699 *document().getElementById("rect")->layoutObject(); | 1689 *document().getElementById("rect")->layoutObject(); |
| 1700 const ObjectPaintProperties* rectWithTransformProperties = | 1690 const ObjectPaintProperties* rectWithTransformProperties = |
| 1701 rectWithTransform.objectPaintProperties(); | 1691 rectWithTransform.paintProperties(); |
| 1702 EXPECT_EQ(TransformationMatrix().translate(1, 1), | 1692 EXPECT_EQ(TransformationMatrix().translate(1, 1), |
| 1703 rectWithTransformProperties->transform()->matrix()); | 1693 rectWithTransformProperties->transform()->matrix()); |
| 1704 | 1694 |
| 1705 // Ensure there is no PaintOffset transform between the rect and the svg's | 1695 // Ensure there is no PaintOffset transform between the rect and the svg's |
| 1706 // transform. | 1696 // transform. |
| 1707 EXPECT_EQ(svgWithTransformProperties->transform(), | 1697 EXPECT_EQ(svgWithTransformProperties->transform(), |
| 1708 rectWithTransformProperties->transform()->parent()); | 1698 rectWithTransformProperties->transform()->parent()); |
| 1709 } | 1699 } |
| 1710 | 1700 |
| 1711 TEST_P(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) { | 1701 TEST_P(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) { |
| 1712 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>"); | 1702 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>"); |
| 1713 | 1703 |
| 1714 const ObjectPaintProperties* properties = | 1704 const ObjectPaintProperties* properties = |
| 1715 document().body()->firstChild()->layoutObject()->objectPaintProperties(); | 1705 document().body()->firstChild()->layoutObject()->paintProperties(); |
| 1716 ASSERT_TRUE(properties->transform()); | 1706 ASSERT_TRUE(properties->transform()); |
| 1717 EXPECT_FALSE(properties->transform()->hasRenderingContext()); | 1707 EXPECT_FALSE(properties->transform()->hasRenderingContext()); |
| 1718 } | 1708 } |
| 1719 | 1709 |
| 1720 TEST_P(PaintPropertyTreeBuilderTest, Preserve3DCreatesSharedRenderingContext) { | 1710 TEST_P(PaintPropertyTreeBuilderTest, Preserve3DCreatesSharedRenderingContext) { |
| 1721 setBodyInnerHTML( | 1711 setBodyInnerHTML( |
| 1722 "<div style='transform-style: preserve-3d'>" | 1712 "<div style='transform-style: preserve-3d'>" |
| 1723 " <div id='a' style='transform: translateZ(0); width: 30px; height: " | 1713 " <div id='a' style='transform: translateZ(0); width: 30px; height: " |
| 1724 "40px'></div>" | 1714 "40px'></div>" |
| 1725 " <div id='b' style='transform: translateZ(0); width: 20px; height: " | 1715 " <div id='b' style='transform: translateZ(0); width: 20px; height: " |
| 1726 "10px'></div>" | 1716 "10px'></div>" |
| 1727 "</div>"); | 1717 "</div>"); |
| 1728 FrameView* frameView = document().view(); | 1718 FrameView* frameView = document().view(); |
| 1729 | 1719 |
| 1730 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1720 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1731 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1721 const ObjectPaintProperties* aProperties = a->paintProperties(); |
| 1732 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1722 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1733 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1723 const ObjectPaintProperties* bProperties = b->paintProperties(); |
| 1734 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); | 1724 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); |
| 1735 EXPECT_NE(aProperties->transform(), bProperties->transform()); | 1725 EXPECT_NE(aProperties->transform(), bProperties->transform()); |
| 1736 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); | 1726 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); |
| 1737 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); | 1727 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); |
| 1738 EXPECT_EQ(aProperties->transform()->renderingContextID(), | 1728 EXPECT_EQ(aProperties->transform()->renderingContextID(), |
| 1739 bProperties->transform()->renderingContextID()); | 1729 bProperties->transform()->renderingContextID()); |
| 1740 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()); | 1730 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()); |
| 1741 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 48, 20, 10), b, | 1731 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 48, 20, 10), b, |
| 1742 frameView->layoutView()); | 1732 frameView->layoutView()); |
| 1743 } | 1733 } |
| 1744 | 1734 |
| 1745 TEST_P(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext) { | 1735 TEST_P(PaintPropertyTreeBuilderTest, FlatTransformStyleEndsRenderingContext) { |
| 1746 setBodyInnerHTML( | 1736 setBodyInnerHTML( |
| 1747 "<div style='transform-style: preserve-3d'>" | 1737 "<div style='transform-style: preserve-3d'>" |
| 1748 " <div id='a' style='transform: translateZ(0); width: 30px; height: " | 1738 " <div id='a' style='transform: translateZ(0); width: 30px; height: " |
| 1749 "40px'>" | 1739 "40px'>" |
| 1750 " <div id='b' style='transform: translateZ(0); width: 10px; height: " | 1740 " <div id='b' style='transform: translateZ(0); width: 10px; height: " |
| 1751 "20px'></div>" | 1741 "20px'></div>" |
| 1752 " </div>" | 1742 " </div>" |
| 1753 "</div>"); | 1743 "</div>"); |
| 1754 FrameView* frameView = document().view(); | 1744 FrameView* frameView = document().view(); |
| 1755 | 1745 |
| 1756 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1746 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1757 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1747 const ObjectPaintProperties* aProperties = a->paintProperties(); |
| 1758 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1748 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1759 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1749 const ObjectPaintProperties* bProperties = b->paintProperties(); |
| 1760 ASSERT_FALSE(a->styleRef().preserves3D()); | 1750 ASSERT_FALSE(a->styleRef().preserves3D()); |
| 1761 | 1751 |
| 1762 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); | 1752 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); |
| 1763 | 1753 |
| 1764 // #a should participate in a rendering context (due to its parent), but its | 1754 // #a should participate in a rendering context (due to its parent), but its |
| 1765 // child #b should not. | 1755 // child #b should not. |
| 1766 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); | 1756 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); |
| 1767 EXPECT_FALSE(bProperties->transform()->hasRenderingContext()); | 1757 EXPECT_FALSE(bProperties->transform()->hasRenderingContext()); |
| 1768 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()); | 1758 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()); |
| 1769 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 20), b, frameView->layoutView()); | 1759 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 20), b, frameView->layoutView()); |
| 1770 } | 1760 } |
| 1771 | 1761 |
| 1772 TEST_P(PaintPropertyTreeBuilderTest, NestedRenderingContexts) { | 1762 TEST_P(PaintPropertyTreeBuilderTest, NestedRenderingContexts) { |
| 1773 setBodyInnerHTML( | 1763 setBodyInnerHTML( |
| 1774 "<div style='transform-style: preserve-3d'>" | 1764 "<div style='transform-style: preserve-3d'>" |
| 1775 " <div id='a' style='transform: translateZ(0); width: 50px; height: " | 1765 " <div id='a' style='transform: translateZ(0); width: 50px; height: " |
| 1776 "60px'>" | 1766 "60px'>" |
| 1777 " <div style='transform-style: preserve-3d; width: 30px; height: " | 1767 " <div style='transform-style: preserve-3d; width: 30px; height: " |
| 1778 "40px'>" | 1768 "40px'>" |
| 1779 " <div id='b' style='transform: translateZ(0); width: 10px; height: " | 1769 " <div id='b' style='transform: translateZ(0); width: 10px; height: " |
| 1780 "20px'>" | 1770 "20px'>" |
| 1781 " </div>" | 1771 " </div>" |
| 1782 " </div>" | 1772 " </div>" |
| 1783 "</div>"); | 1773 "</div>"); |
| 1784 FrameView* frameView = document().view(); | 1774 FrameView* frameView = document().view(); |
| 1785 | 1775 |
| 1786 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1776 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1787 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1777 const ObjectPaintProperties* aProperties = a->paintProperties(); |
| 1788 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1778 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1789 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1779 const ObjectPaintProperties* bProperties = b->paintProperties(); |
| 1790 ASSERT_FALSE(a->styleRef().preserves3D()); | 1780 ASSERT_FALSE(a->styleRef().preserves3D()); |
| 1791 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); | 1781 ASSERT_TRUE(aProperties->transform() && bProperties->transform()); |
| 1792 | 1782 |
| 1793 // #a should participate in a rendering context (due to its parent). Its | 1783 // #a should participate in a rendering context (due to its parent). Its |
| 1794 // child does preserve 3D, but since #a does not, #a's rendering context is | 1784 // child does preserve 3D, but since #a does not, #a's rendering context is |
| 1795 // not passed on to its children. Thus #b ends up in a separate rendering | 1785 // not passed on to its children. Thus #b ends up in a separate rendering |
| 1796 // context rooted at its parent. | 1786 // context rooted at its parent. |
| 1797 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); | 1787 EXPECT_TRUE(aProperties->transform()->hasRenderingContext()); |
| 1798 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); | 1788 EXPECT_TRUE(bProperties->transform()->hasRenderingContext()); |
| 1799 EXPECT_NE(aProperties->transform()->renderingContextID(), | 1789 EXPECT_NE(aProperties->transform()->renderingContextID(), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1830 setBodyInnerHTML( | 1820 setBodyInnerHTML( |
| 1831 "<div id='a' style='transform: translateZ(0); transform-style: flat; " | 1821 "<div id='a' style='transform: translateZ(0); transform-style: flat; " |
| 1832 "width: 30px; height: 40px'>" | 1822 "width: 30px; height: 40px'>" |
| 1833 " <div id='b' style='transform: translateZ(0); width: 10px; height: " | 1823 " <div id='b' style='transform: translateZ(0); width: 10px; height: " |
| 1834 "10px'></div>" | 1824 "10px'></div>" |
| 1835 "</div>"); | 1825 "</div>"); |
| 1836 FrameView* frameView = document().view(); | 1826 FrameView* frameView = document().view(); |
| 1837 | 1827 |
| 1838 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1828 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1839 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1829 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1840 const auto* aTransform = a->objectPaintProperties()->transform(); | 1830 const auto* aTransform = a->paintProperties()->transform(); |
| 1841 ASSERT_TRUE(aTransform); | 1831 ASSERT_TRUE(aTransform); |
| 1842 const auto* bTransform = b->objectPaintProperties()->transform(); | 1832 const auto* bTransform = b->paintProperties()->transform(); |
| 1843 ASSERT_TRUE(bTransform); | 1833 ASSERT_TRUE(bTransform); |
| 1844 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); | 1834 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); |
| 1845 | 1835 |
| 1846 // Some node must flatten the inherited transform from #a before it reaches | 1836 // Some node must flatten the inherited transform from #a before it reaches |
| 1847 // #b's transform. | 1837 // #b's transform. |
| 1848 EXPECT_TRUE(someNodeFlattensTransform(bTransform, aTransform)); | 1838 EXPECT_TRUE(someNodeFlattensTransform(bTransform, aTransform)); |
| 1849 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()); | 1839 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()); |
| 1850 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 10), b, frameView->layoutView()); | 1840 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 10), b, frameView->layoutView()); |
| 1851 } | 1841 } |
| 1852 | 1842 |
| 1853 TEST_P(PaintPropertyTreeBuilderTest, | 1843 TEST_P(PaintPropertyTreeBuilderTest, |
| 1854 Preserve3DTransformStylePropagatesToChildren) { | 1844 Preserve3DTransformStylePropagatesToChildren) { |
| 1855 setBodyInnerHTML( | 1845 setBodyInnerHTML( |
| 1856 "<div id='a' style='transform: translateZ(0); transform-style: " | 1846 "<div id='a' style='transform: translateZ(0); transform-style: " |
| 1857 "preserve-3d; width: 30px; height: 40px'>" | 1847 "preserve-3d; width: 30px; height: 40px'>" |
| 1858 " <div id='b' style='transform: translateZ(0); width: 10px; height: " | 1848 " <div id='b' style='transform: translateZ(0); width: 10px; height: " |
| 1859 "10px'></div>" | 1849 "10px'></div>" |
| 1860 "</div>"); | 1850 "</div>"); |
| 1861 FrameView* frameView = document().view(); | 1851 FrameView* frameView = document().view(); |
| 1862 | 1852 |
| 1863 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1853 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1864 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1854 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1865 const auto* aTransform = a->objectPaintProperties()->transform(); | 1855 const auto* aTransform = a->paintProperties()->transform(); |
| 1866 ASSERT_TRUE(aTransform); | 1856 ASSERT_TRUE(aTransform); |
| 1867 const auto* bTransform = b->objectPaintProperties()->transform(); | 1857 const auto* bTransform = b->paintProperties()->transform(); |
| 1868 ASSERT_TRUE(bTransform); | 1858 ASSERT_TRUE(bTransform); |
| 1869 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); | 1859 ASSERT_TRUE(nodeHasAncestor(bTransform, aTransform)); |
| 1870 | 1860 |
| 1871 // No node may flatten the inherited transform from #a before it reaches | 1861 // No node may flatten the inherited transform from #a before it reaches |
| 1872 // #b's transform. | 1862 // #b's transform. |
| 1873 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aTransform)); | 1863 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aTransform)); |
| 1874 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()); | 1864 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()); |
| 1875 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 10), b, frameView->layoutView()); | 1865 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 10), b, frameView->layoutView()); |
| 1876 } | 1866 } |
| 1877 | 1867 |
| 1878 TEST_P(PaintPropertyTreeBuilderTest, PerspectiveIsNotFlattened) { | 1868 TEST_P(PaintPropertyTreeBuilderTest, PerspectiveIsNotFlattened) { |
| 1879 // It's necessary to make nodes from the one that applies perspective to | 1869 // It's necessary to make nodes from the one that applies perspective to |
| 1880 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't | 1870 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't |
| 1881 // do anything. | 1871 // do anything. |
| 1882 setBodyInnerHTML( | 1872 setBodyInnerHTML( |
| 1883 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" | 1873 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" |
| 1884 " <div id='b' style='transform: translateZ(0); width: 10px; height: " | 1874 " <div id='b' style='transform: translateZ(0); width: 10px; height: " |
| 1885 "20px'></div>" | 1875 "20px'></div>" |
| 1886 "</div>"); | 1876 "</div>"); |
| 1887 FrameView* frameView = document().view(); | 1877 FrameView* frameView = document().view(); |
| 1888 | 1878 |
| 1889 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1879 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1890 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1880 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1891 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1881 const ObjectPaintProperties* aProperties = a->paintProperties(); |
| 1892 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1882 const ObjectPaintProperties* bProperties = b->paintProperties(); |
| 1893 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); | 1883 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); |
| 1894 ASSERT_TRUE(aPerspective); | 1884 ASSERT_TRUE(aPerspective); |
| 1895 const TransformPaintPropertyNode* bTransform = bProperties->transform(); | 1885 const TransformPaintPropertyNode* bTransform = bProperties->transform(); |
| 1896 ASSERT_TRUE(bTransform); | 1886 ASSERT_TRUE(bTransform); |
| 1897 ASSERT_TRUE(nodeHasAncestor(bTransform, aPerspective)); | 1887 ASSERT_TRUE(nodeHasAncestor(bTransform, aPerspective)); |
| 1898 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aPerspective)); | 1888 EXPECT_FALSE(someNodeFlattensTransform(bTransform, aPerspective)); |
| 1899 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()); | 1889 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()); |
| 1900 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 20), b, frameView->layoutView()); | 1890 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 20), b, frameView->layoutView()); |
| 1901 } | 1891 } |
| 1902 | 1892 |
| 1903 TEST_P(PaintPropertyTreeBuilderTest, | 1893 TEST_P(PaintPropertyTreeBuilderTest, |
| 1904 PerspectiveDoesNotEstablishRenderingContext) { | 1894 PerspectiveDoesNotEstablishRenderingContext) { |
| 1905 // It's necessary to make nodes from the one that applies perspective to | 1895 // It's necessary to make nodes from the one that applies perspective to |
| 1906 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't | 1896 // ones that combine with it preserve 3D. Otherwise, the perspective doesn't |
| 1907 // do anything. | 1897 // do anything. |
| 1908 setBodyInnerHTML( | 1898 setBodyInnerHTML( |
| 1909 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" | 1899 "<div id='a' style='perspective: 800px; width: 30px; height: 40px'>" |
| 1910 " <div id='b' style='transform: translateZ(0); width: 10px; height: " | 1900 " <div id='b' style='transform: translateZ(0); width: 10px; height: " |
| 1911 "20px'></div>" | 1901 "20px'></div>" |
| 1912 "</div>"); | 1902 "</div>"); |
| 1913 FrameView* frameView = document().view(); | 1903 FrameView* frameView = document().view(); |
| 1914 | 1904 |
| 1915 LayoutObject* a = document().getElementById("a")->layoutObject(); | 1905 LayoutObject* a = document().getElementById("a")->layoutObject(); |
| 1916 LayoutObject* b = document().getElementById("b")->layoutObject(); | 1906 LayoutObject* b = document().getElementById("b")->layoutObject(); |
| 1917 const ObjectPaintProperties* aProperties = a->objectPaintProperties(); | 1907 const ObjectPaintProperties* aProperties = a->paintProperties(); |
| 1918 const ObjectPaintProperties* bProperties = b->objectPaintProperties(); | 1908 const ObjectPaintProperties* bProperties = b->paintProperties(); |
| 1919 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); | 1909 const TransformPaintPropertyNode* aPerspective = aProperties->perspective(); |
| 1920 ASSERT_TRUE(aPerspective); | 1910 ASSERT_TRUE(aPerspective); |
| 1921 EXPECT_FALSE(aPerspective->hasRenderingContext()); | 1911 EXPECT_FALSE(aPerspective->hasRenderingContext()); |
| 1922 const TransformPaintPropertyNode* bTransform = bProperties->transform(); | 1912 const TransformPaintPropertyNode* bTransform = bProperties->transform(); |
| 1923 ASSERT_TRUE(bTransform); | 1913 ASSERT_TRUE(bTransform); |
| 1924 EXPECT_FALSE(bTransform->hasRenderingContext()); | 1914 EXPECT_FALSE(bTransform->hasRenderingContext()); |
| 1925 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()); | 1915 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 30, 40), a, frameView->layoutView()); |
| 1926 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 20), b, frameView->layoutView()); | 1916 CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 10, 20), b, frameView->layoutView()); |
| 1927 } | 1917 } |
| 1928 | 1918 |
| 1929 TEST_P(PaintPropertyTreeBuilderTest, CachedProperties) { | 1919 TEST_P(PaintPropertyTreeBuilderTest, CachedProperties) { |
| 1930 setBodyInnerHTML( | 1920 setBodyInnerHTML( |
| 1931 "<style>body { margin: 0 }</style>" | 1921 "<style>body { margin: 0 }</style>" |
| 1932 "<div id='a' style='transform: translate(33px, 44px); width: 50px; " | 1922 "<div id='a' style='transform: translate(33px, 44px); width: 50px; " |
| 1933 "height: 60px'>" | 1923 "height: 60px'>" |
| 1934 " <div id='b' style='transform: translate(55px, 66px); width: 30px; " | 1924 " <div id='b' style='transform: translate(55px, 66px); width: 30px; " |
| 1935 "height: 40px'>" | 1925 "height: 40px'>" |
| 1936 " <div id='c' style='transform: translate(77px, 88px); width: 10px; " | 1926 " <div id='c' style='transform: translate(77px, 88px); width: 10px; " |
| 1937 "height: 20px'>C<div>" | 1927 "height: 20px'>C<div>" |
| 1938 " </div>" | 1928 " </div>" |
| 1939 "</div>"); | 1929 "</div>"); |
| 1940 FrameView* frameView = document().view(); | 1930 FrameView* frameView = document().view(); |
| 1941 | 1931 |
| 1942 Element* a = document().getElementById("a"); | 1932 Element* a = document().getElementById("a"); |
| 1943 const ObjectPaintProperties* aProperties = | 1933 const ObjectPaintProperties* aProperties = |
| 1944 a->layoutObject()->objectPaintProperties(); | 1934 a->layoutObject()->paintProperties(); |
| 1945 const TransformPaintPropertyNode* aTransformNode = aProperties->transform(); | 1935 const TransformPaintPropertyNode* aTransformNode = aProperties->transform(); |
| 1946 EXPECT_EQ(TransformationMatrix().translate(33, 44), aTransformNode->matrix()); | 1936 EXPECT_EQ(TransformationMatrix().translate(33, 44), aTransformNode->matrix()); |
| 1947 | 1937 |
| 1948 Element* b = document().getElementById("b"); | 1938 Element* b = document().getElementById("b"); |
| 1949 const ObjectPaintProperties* bProperties = | 1939 const ObjectPaintProperties* bProperties = |
| 1950 b->layoutObject()->objectPaintProperties(); | 1940 b->layoutObject()->paintProperties(); |
| 1951 const TransformPaintPropertyNode* bTransformNode = bProperties->transform(); | 1941 const TransformPaintPropertyNode* bTransformNode = bProperties->transform(); |
| 1952 EXPECT_EQ(TransformationMatrix().translate(55, 66), bTransformNode->matrix()); | 1942 EXPECT_EQ(TransformationMatrix().translate(55, 66), bTransformNode->matrix()); |
| 1953 | 1943 |
| 1954 Element* c = document().getElementById("c"); | 1944 Element* c = document().getElementById("c"); |
| 1955 const ObjectPaintProperties* cProperties = | 1945 const ObjectPaintProperties* cProperties = |
| 1956 c->layoutObject()->objectPaintProperties(); | 1946 c->layoutObject()->paintProperties(); |
| 1957 const TransformPaintPropertyNode* cTransformNode = cProperties->transform(); | 1947 const TransformPaintPropertyNode* cTransformNode = cProperties->transform(); |
| 1958 EXPECT_EQ(TransformationMatrix().translate(77, 88), cTransformNode->matrix()); | 1948 EXPECT_EQ(TransformationMatrix().translate(77, 88), cTransformNode->matrix()); |
| 1959 | 1949 |
| 1960 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), | 1950 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), |
| 1961 frameView->layoutView()); | 1951 frameView->layoutView()); |
| 1962 CHECK_EXACT_VISUAL_RECT(LayoutRect(88, 110, 30, 40), b->layoutObject(), | 1952 CHECK_EXACT_VISUAL_RECT(LayoutRect(88, 110, 30, 40), b->layoutObject(), |
| 1963 frameView->layoutView()); | 1953 frameView->layoutView()); |
| 1964 CHECK_EXACT_VISUAL_RECT(LayoutRect(165, 198, 10, 20), c->layoutObject(), | 1954 CHECK_EXACT_VISUAL_RECT(LayoutRect(165, 198, 10, 20), c->layoutObject(), |
| 1965 frameView->layoutView()); | 1955 frameView->layoutView()); |
| 1966 | 1956 |
| 1967 // Change transform of b. B's transform node should be a new node with the new | 1957 // Change transform of b. B's transform node should be a new node with the new |
| 1968 // value, and a and c's transform nodes should be unchanged (with c's parent | 1958 // value, and a and c's transform nodes should be unchanged (with c's parent |
| 1969 // adjusted). | 1959 // adjusted). |
| 1970 b->setAttribute(HTMLNames::styleAttr, "transform: translate(111px, 222px)"); | 1960 b->setAttribute(HTMLNames::styleAttr, "transform: translate(111px, 222px)"); |
| 1971 document().view()->updateAllLifecyclePhases(); | 1961 document().view()->updateAllLifecyclePhases(); |
| 1972 | 1962 |
| 1973 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); | 1963 EXPECT_EQ(aProperties, a->layoutObject()->paintProperties()); |
| 1974 EXPECT_EQ(aTransformNode, aProperties->transform()); | 1964 EXPECT_EQ(aTransformNode, aProperties->transform()); |
| 1975 | 1965 |
| 1976 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); | 1966 EXPECT_EQ(bProperties, b->layoutObject()->paintProperties()); |
| 1977 bTransformNode = bProperties->transform(); | 1967 bTransformNode = bProperties->transform(); |
| 1978 EXPECT_EQ(TransformationMatrix().translate(111, 222), | 1968 EXPECT_EQ(TransformationMatrix().translate(111, 222), |
| 1979 bTransformNode->matrix()); | 1969 bTransformNode->matrix()); |
| 1980 EXPECT_EQ(aTransformNode, bTransformNode->parent()); | 1970 EXPECT_EQ(aTransformNode, bTransformNode->parent()); |
| 1981 | 1971 |
| 1982 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); | 1972 EXPECT_EQ(cProperties, c->layoutObject()->paintProperties()); |
| 1983 EXPECT_EQ(cTransformNode, cProperties->transform()); | 1973 EXPECT_EQ(cTransformNode, cProperties->transform()); |
| 1984 EXPECT_EQ(bTransformNode, cTransformNode->parent()); | 1974 EXPECT_EQ(bTransformNode, cTransformNode->parent()); |
| 1985 | 1975 |
| 1986 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), | 1976 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), |
| 1987 frameView->layoutView()); | 1977 frameView->layoutView()); |
| 1988 CHECK_EXACT_VISUAL_RECT(LayoutRect(144, 266, 50, 20), b->layoutObject(), | 1978 CHECK_EXACT_VISUAL_RECT(LayoutRect(144, 266, 50, 20), b->layoutObject(), |
| 1989 frameView->layoutView()); | 1979 frameView->layoutView()); |
| 1990 CHECK_EXACT_VISUAL_RECT(LayoutRect(221, 354, 10, 20), c->layoutObject(), | 1980 CHECK_EXACT_VISUAL_RECT(LayoutRect(221, 354, 10, 20), c->layoutObject(), |
| 1991 frameView->layoutView()); | 1981 frameView->layoutView()); |
| 1992 | 1982 |
| 1993 // Remove transform from b. B's transform node should be removed from the | 1983 // Remove transform from b. B's transform node should be removed from the |
| 1994 // tree, and a and c's transform nodes should be unchanged (with c's parent | 1984 // tree, and a and c's transform nodes should be unchanged (with c's parent |
| 1995 // adjusted). | 1985 // adjusted). |
| 1996 b->setAttribute(HTMLNames::styleAttr, ""); | 1986 b->setAttribute(HTMLNames::styleAttr, ""); |
| 1997 document().view()->updateAllLifecyclePhases(); | 1987 document().view()->updateAllLifecyclePhases(); |
| 1998 | 1988 |
| 1999 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); | 1989 EXPECT_EQ(aProperties, a->layoutObject()->paintProperties()); |
| 2000 EXPECT_EQ(aTransformNode, aProperties->transform()); | 1990 EXPECT_EQ(aTransformNode, aProperties->transform()); |
| 2001 | 1991 |
| 2002 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); | 1992 EXPECT_EQ(bProperties, b->layoutObject()->paintProperties()); |
| 2003 EXPECT_EQ(nullptr, bProperties->transform()); | 1993 EXPECT_EQ(nullptr, bProperties->transform()); |
| 2004 | 1994 |
| 2005 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); | 1995 EXPECT_EQ(cProperties, c->layoutObject()->paintProperties()); |
| 2006 EXPECT_EQ(cTransformNode, cProperties->transform()); | 1996 EXPECT_EQ(cTransformNode, cProperties->transform()); |
| 2007 EXPECT_EQ(aTransformNode, cTransformNode->parent()); | 1997 EXPECT_EQ(aTransformNode, cTransformNode->parent()); |
| 2008 | 1998 |
| 2009 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), | 1999 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), |
| 2010 frameView->layoutView()); | 2000 frameView->layoutView()); |
| 2011 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 20), b->layoutObject(), | 2001 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 20), b->layoutObject(), |
| 2012 frameView->layoutView()); | 2002 frameView->layoutView()); |
| 2013 CHECK_EXACT_VISUAL_RECT(LayoutRect(110, 132, 10, 20), c->layoutObject(), | 2003 CHECK_EXACT_VISUAL_RECT(LayoutRect(110, 132, 10, 20), c->layoutObject(), |
| 2014 frameView->layoutView()); | 2004 frameView->layoutView()); |
| 2015 | 2005 |
| 2016 // Re-add transform to b. B's transform node should be inserted into the tree, | 2006 // Re-add transform to b. B's transform node should be inserted into the tree, |
| 2017 // and a and c's transform nodes should be unchanged (with c's parent | 2007 // and a and c's transform nodes should be unchanged (with c's parent |
| 2018 // adjusted). | 2008 // adjusted). |
| 2019 b->setAttribute(HTMLNames::styleAttr, "transform: translate(4px, 5px)"); | 2009 b->setAttribute(HTMLNames::styleAttr, "transform: translate(4px, 5px)"); |
| 2020 document().view()->updateAllLifecyclePhases(); | 2010 document().view()->updateAllLifecyclePhases(); |
| 2021 | 2011 |
| 2022 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties()); | 2012 EXPECT_EQ(aProperties, a->layoutObject()->paintProperties()); |
| 2023 EXPECT_EQ(aTransformNode, aProperties->transform()); | 2013 EXPECT_EQ(aTransformNode, aProperties->transform()); |
| 2024 | 2014 |
| 2025 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties()); | 2015 EXPECT_EQ(bProperties, b->layoutObject()->paintProperties()); |
| 2026 bTransformNode = bProperties->transform(); | 2016 bTransformNode = bProperties->transform(); |
| 2027 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix()); | 2017 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix()); |
| 2028 EXPECT_EQ(aTransformNode, bTransformNode->parent()); | 2018 EXPECT_EQ(aTransformNode, bTransformNode->parent()); |
| 2029 | 2019 |
| 2030 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties()); | 2020 EXPECT_EQ(cProperties, c->layoutObject()->paintProperties()); |
| 2031 EXPECT_EQ(cTransformNode, cProperties->transform()); | 2021 EXPECT_EQ(cTransformNode, cProperties->transform()); |
| 2032 EXPECT_EQ(bTransformNode, cTransformNode->parent()); | 2022 EXPECT_EQ(bTransformNode, cTransformNode->parent()); |
| 2033 | 2023 |
| 2034 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), | 2024 CHECK_EXACT_VISUAL_RECT(LayoutRect(33, 44, 50, 60), a->layoutObject(), |
| 2035 frameView->layoutView()); | 2025 frameView->layoutView()); |
| 2036 CHECK_EXACT_VISUAL_RECT(LayoutRect(37, 49, 50, 20), b->layoutObject(), | 2026 CHECK_EXACT_VISUAL_RECT(LayoutRect(37, 49, 50, 20), b->layoutObject(), |
| 2037 frameView->layoutView()); | 2027 frameView->layoutView()); |
| 2038 CHECK_EXACT_VISUAL_RECT(LayoutRect(114, 137, 10, 20), c->layoutObject(), | 2028 CHECK_EXACT_VISUAL_RECT(LayoutRect(114, 137, 10, 20), c->layoutObject(), |
| 2039 frameView->layoutView()); | 2029 frameView->layoutView()); |
| 2040 } | 2030 } |
| 2041 | 2031 |
| 2042 TEST_P(PaintPropertyTreeBuilderTest, OverflowClipContentsTreeState) { | 2032 TEST_P(PaintPropertyTreeBuilderTest, OverflowClipContentsTreeState) { |
| 2043 // This test verifies the tree builder correctly computes and records the | 2033 // This test verifies the tree builder correctly computes and records the |
| 2044 // property tree context for a (pseudo) stacking context that is scrolled by a | 2034 // property tree context for a (pseudo) stacking context that is scrolled by a |
| 2045 // containing block that is not one of the painting ancestors. | 2035 // containing block that is not one of the painting ancestors. |
| 2046 setBodyInnerHTML( | 2036 setBodyInnerHTML( |
| 2047 "<style>body { margin: 20px 30px; }</style>" | 2037 "<style>body { margin: 20px 30px; }</style>" |
| 2048 "<div id='clipper' style='overflow:hidden; width:400px; height:300px;'>" | 2038 "<div id='clipper' style='overflow:hidden; width:400px; height:300px;'>" |
| 2049 " <div id='child' style='position:relative; width:500px; height: " | 2039 " <div id='child' style='position:relative; width:500px; height: " |
| 2050 "600px;'></div>" | 2040 "600px;'></div>" |
| 2051 "</div>"); | 2041 "</div>"); |
| 2052 | 2042 |
| 2053 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( | 2043 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( |
| 2054 document().getElementById("clipper")->layoutObject()); | 2044 document().getElementById("clipper")->layoutObject()); |
| 2055 const ObjectPaintProperties* clipProperties = | 2045 const ObjectPaintProperties* clipProperties = clipper->paintProperties(); |
| 2056 clipper->objectPaintProperties(); | |
| 2057 LayoutObject* child = document().getElementById("child")->layoutObject(); | 2046 LayoutObject* child = document().getElementById("child")->layoutObject(); |
| 2058 const ObjectPaintProperties* childProperties = child->objectPaintProperties(); | 2047 const ObjectPaintProperties* childProperties = child->paintProperties(); |
| 2059 | 2048 |
| 2060 // No scroll translation because the document does not scroll (not enough | 2049 // No scroll translation because the document does not scroll (not enough |
| 2061 // content). | 2050 // content). |
| 2062 EXPECT_TRUE(!frameScrollTranslation()); | 2051 EXPECT_TRUE(!frameScrollTranslation()); |
| 2063 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() | 2052 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() |
| 2064 ->propertyTreeState.transform()); | 2053 ->propertyTreeState.transform()); |
| 2065 EXPECT_EQ( | 2054 EXPECT_EQ( |
| 2066 frameContentClip(), | 2055 frameContentClip(), |
| 2067 clipProperties->localBorderBoxProperties()->propertyTreeState.clip()); | 2056 clipProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 2068 | 2057 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2088 TEST_P(PaintPropertyTreeBuilderTest, ContainsPaintContentsTreeState) { | 2077 TEST_P(PaintPropertyTreeBuilderTest, ContainsPaintContentsTreeState) { |
| 2089 setBodyInnerHTML( | 2078 setBodyInnerHTML( |
| 2090 "<style>body { margin: 20px 30px; }</style>" | 2079 "<style>body { margin: 20px 30px; }</style>" |
| 2091 "<div id='clipper' style='contain:paint; width:300px; height:200px;'>" | 2080 "<div id='clipper' style='contain:paint; width:300px; height:200px;'>" |
| 2092 " <div id='child' style='position:relative; width:400px; height: " | 2081 " <div id='child' style='position:relative; width:400px; height: " |
| 2093 "500px;'></div>" | 2082 "500px;'></div>" |
| 2094 "</div>"); | 2083 "</div>"); |
| 2095 | 2084 |
| 2096 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( | 2085 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( |
| 2097 document().getElementById("clipper")->layoutObject()); | 2086 document().getElementById("clipper")->layoutObject()); |
| 2098 const ObjectPaintProperties* clipProperties = | 2087 const ObjectPaintProperties* clipProperties = clipper->paintProperties(); |
| 2099 clipper->objectPaintProperties(); | |
| 2100 LayoutObject* child = document().getElementById("child")->layoutObject(); | 2088 LayoutObject* child = document().getElementById("child")->layoutObject(); |
| 2101 const ObjectPaintProperties* childProperties = child->objectPaintProperties(); | 2089 const ObjectPaintProperties* childProperties = child->paintProperties(); |
| 2102 | 2090 |
| 2103 // No scroll translation because the document does not scroll (not enough | 2091 // No scroll translation because the document does not scroll (not enough |
| 2104 // content). | 2092 // content). |
| 2105 EXPECT_TRUE(!frameScrollTranslation()); | 2093 EXPECT_TRUE(!frameScrollTranslation()); |
| 2106 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() | 2094 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() |
| 2107 ->propertyTreeState.transform()); | 2095 ->propertyTreeState.transform()); |
| 2108 EXPECT_EQ( | 2096 EXPECT_EQ( |
| 2109 frameContentClip(), | 2097 frameContentClip(), |
| 2110 clipProperties->localBorderBoxProperties()->propertyTreeState.clip()); | 2098 clipProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 2111 | 2099 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2139 "600px;'></div>" | 2127 "600px;'></div>" |
| 2140 " <div style='width: 200px; height: 10000px'></div>" | 2128 " <div style='width: 200px; height: 10000px'></div>" |
| 2141 "</div>" | 2129 "</div>" |
| 2142 "<div id='forceScroll' style='height: 4000px;'></div>"); | 2130 "<div id='forceScroll' style='height: 4000px;'></div>"); |
| 2143 | 2131 |
| 2144 Element* clipperElement = document().getElementById("clipper"); | 2132 Element* clipperElement = document().getElementById("clipper"); |
| 2145 clipperElement->scrollTo(1, 2); | 2133 clipperElement->scrollTo(1, 2); |
| 2146 | 2134 |
| 2147 LayoutBoxModelObject* clipper = | 2135 LayoutBoxModelObject* clipper = |
| 2148 toLayoutBoxModelObject(clipperElement->layoutObject()); | 2136 toLayoutBoxModelObject(clipperElement->layoutObject()); |
| 2149 const ObjectPaintProperties* clipProperties = | 2137 const ObjectPaintProperties* clipProperties = clipper->paintProperties(); |
| 2150 clipper->objectPaintProperties(); | |
| 2151 LayoutObject* child = document().getElementById("child")->layoutObject(); | 2138 LayoutObject* child = document().getElementById("child")->layoutObject(); |
| 2152 const ObjectPaintProperties* childProperties = child->objectPaintProperties(); | 2139 const ObjectPaintProperties* childProperties = child->paintProperties(); |
| 2153 | 2140 |
| 2154 EXPECT_EQ(frameScrollTranslation(), clipProperties->localBorderBoxProperties() | 2141 EXPECT_EQ(frameScrollTranslation(), clipProperties->localBorderBoxProperties() |
| 2155 ->propertyTreeState.transform()); | 2142 ->propertyTreeState.transform()); |
| 2156 EXPECT_EQ( | 2143 EXPECT_EQ( |
| 2157 frameContentClip(), | 2144 frameContentClip(), |
| 2158 clipProperties->localBorderBoxProperties()->propertyTreeState.clip()); | 2145 clipProperties->localBorderBoxProperties()->propertyTreeState.clip()); |
| 2159 | 2146 |
| 2160 auto contentsProperties = clipProperties->contentsProperties(); | 2147 auto contentsProperties = clipProperties->contentsProperties(); |
| 2161 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset); | 2148 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset); |
| 2162 EXPECT_EQ(clipProperties->scrollTranslation(), | 2149 EXPECT_EQ(clipProperties->scrollTranslation(), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2196 " background-color: orange;" | 2183 " background-color: orange;" |
| 2197 " }" | 2184 " }" |
| 2198 "</style>" | 2185 "</style>" |
| 2199 "<div id='roundedBox'>" | 2186 "<div id='roundedBox'>" |
| 2200 " <div id='roundedBoxChild'></div>" | 2187 " <div id='roundedBoxChild'></div>" |
| 2201 "</div>"); | 2188 "</div>"); |
| 2202 | 2189 |
| 2203 LayoutObject& roundedBox = | 2190 LayoutObject& roundedBox = |
| 2204 *document().getElementById("roundedBox")->layoutObject(); | 2191 *document().getElementById("roundedBox")->layoutObject(); |
| 2205 const ObjectPaintProperties* roundedBoxProperties = | 2192 const ObjectPaintProperties* roundedBoxProperties = |
| 2206 roundedBox.objectPaintProperties(); | 2193 roundedBox.paintProperties(); |
| 2207 EXPECT_EQ( | 2194 EXPECT_EQ( |
| 2208 FloatRoundedRect(FloatRect(50, 50, 200, 200), FloatSize(50, 50), | 2195 FloatRoundedRect(FloatRect(50, 50, 200, 200), FloatSize(50, 50), |
| 2209 FloatSize(50, 50), FloatSize(50, 50), FloatSize(50, 50)), | 2196 FloatSize(50, 50), FloatSize(50, 50), FloatSize(50, 50)), |
| 2210 roundedBoxProperties->innerBorderRadiusClip()->clipRect()); | 2197 roundedBoxProperties->innerBorderRadiusClip()->clipRect()); |
| 2211 | 2198 |
| 2212 // Unlike the inner border radius clip, the overflow clip is inset by the | 2199 // Unlike the inner border radius clip, the overflow clip is inset by the |
| 2213 // scrollbars (13px). | 2200 // scrollbars (13px). |
| 2214 EXPECT_EQ(FloatRoundedRect(50, 50, 187, 187), | 2201 EXPECT_EQ(FloatRoundedRect(50, 50, 187, 187), |
| 2215 roundedBoxProperties->overflowClip()->clipRect()); | 2202 roundedBoxProperties->overflowClip()->clipRect()); |
| 2216 EXPECT_EQ(frameContentClip(), | 2203 EXPECT_EQ(frameContentClip(), |
| 2217 roundedBoxProperties->innerBorderRadiusClip()->parent()); | 2204 roundedBoxProperties->innerBorderRadiusClip()->parent()); |
| 2218 EXPECT_EQ(roundedBoxProperties->innerBorderRadiusClip(), | 2205 EXPECT_EQ(roundedBoxProperties->innerBorderRadiusClip(), |
| 2219 roundedBoxProperties->overflowClip()->parent()); | 2206 roundedBoxProperties->overflowClip()->parent()); |
| 2220 } | 2207 } |
| 2221 | 2208 |
| 2222 TEST_P(PaintPropertyTreeBuilderTest, CssClipContentsTreeState) { | 2209 TEST_P(PaintPropertyTreeBuilderTest, CssClipContentsTreeState) { |
| 2223 // This test verifies the tree builder correctly computes and records the | 2210 // This test verifies the tree builder correctly computes and records the |
| 2224 // property tree context for a (pseudo) stacking context that is scrolled by a | 2211 // property tree context for a (pseudo) stacking context that is scrolled by a |
| 2225 // containing block that is not one of the painting ancestors. | 2212 // containing block that is not one of the painting ancestors. |
| 2226 setBodyInnerHTML( | 2213 setBodyInnerHTML( |
| 2227 "<style>body { margin: 20px 30px; }</style>" | 2214 "<style>body { margin: 20px 30px; }</style>" |
| 2228 "<div id='clipper' style='position: absolute; clip: rect(10px, 80px, " | 2215 "<div id='clipper' style='position: absolute; clip: rect(10px, 80px, " |
| 2229 "70px, 40px); width:300px; height:200px;'>" | 2216 "70px, 40px); width:300px; height:200px;'>" |
| 2230 " <div id='child' style='position:relative; width:400px; height: " | 2217 " <div id='child' style='position:relative; width:400px; height: " |
| 2231 "500px;'></div>" | 2218 "500px;'></div>" |
| 2232 "</div>"); | 2219 "</div>"); |
| 2233 | 2220 |
| 2234 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( | 2221 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( |
| 2235 document().getElementById("clipper")->layoutObject()); | 2222 document().getElementById("clipper")->layoutObject()); |
| 2236 const ObjectPaintProperties* clipProperties = | 2223 const ObjectPaintProperties* clipProperties = clipper->paintProperties(); |
| 2237 clipper->objectPaintProperties(); | |
| 2238 LayoutObject* child = document().getElementById("child")->layoutObject(); | 2224 LayoutObject* child = document().getElementById("child")->layoutObject(); |
| 2239 | 2225 |
| 2240 // No scroll translation because the document does not scroll (not enough | 2226 // No scroll translation because the document does not scroll (not enough |
| 2241 // content). | 2227 // content). |
| 2242 EXPECT_TRUE(!frameScrollTranslation()); | 2228 EXPECT_TRUE(!frameScrollTranslation()); |
| 2243 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() | 2229 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() |
| 2244 ->propertyTreeState.transform()); | 2230 ->propertyTreeState.transform()); |
| 2245 // CSS clip on an element causes it to clip itself, not just descendants. | 2231 // CSS clip on an element causes it to clip itself, not just descendants. |
| 2246 EXPECT_EQ( | 2232 EXPECT_EQ( |
| 2247 clipProperties->cssClip(), | 2233 clipProperties->cssClip(), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2272 " }" | 2258 " }" |
| 2273 "</style>" | 2259 "</style>" |
| 2274 "<svg id='svgWithViewBox' width='100px' height='100px' viewBox='50 50 " | 2260 "<svg id='svgWithViewBox' width='100px' height='100px' viewBox='50 50 " |
| 2275 "100 100'>" | 2261 "100 100'>" |
| 2276 " <rect id='rect' width='100px' height='100px' />" | 2262 " <rect id='rect' width='100px' height='100px' />" |
| 2277 "</svg>"); | 2263 "</svg>"); |
| 2278 | 2264 |
| 2279 LayoutObject& svgWithViewBox = | 2265 LayoutObject& svgWithViewBox = |
| 2280 *document().getElementById("svgWithViewBox")->layoutObject(); | 2266 *document().getElementById("svgWithViewBox")->layoutObject(); |
| 2281 const ObjectPaintProperties* svgWithViewBoxProperties = | 2267 const ObjectPaintProperties* svgWithViewBoxProperties = |
| 2282 svgWithViewBox.objectPaintProperties(); | 2268 svgWithViewBox.paintProperties(); |
| 2283 | 2269 |
| 2284 EXPECT_EQ(framePreTranslation(), | 2270 EXPECT_EQ(framePreTranslation(), |
| 2285 svgWithViewBoxProperties->localBorderBoxProperties() | 2271 svgWithViewBoxProperties->localBorderBoxProperties() |
| 2286 ->propertyTreeState.transform()); | 2272 ->propertyTreeState.transform()); |
| 2287 | 2273 |
| 2288 auto contentsProperties = svgWithViewBoxProperties->contentsProperties(); | 2274 auto contentsProperties = svgWithViewBoxProperties->contentsProperties(); |
| 2289 EXPECT_EQ(LayoutPoint(), contentsProperties.paintOffset); | 2275 EXPECT_EQ(LayoutPoint(), contentsProperties.paintOffset); |
| 2290 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), | 2276 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), |
| 2291 contentsProperties.propertyTreeState.transform()); | 2277 contentsProperties.propertyTreeState.transform()); |
| 2292 } | 2278 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2309 "<div id='overflowHidden'>" | 2295 "<div id='overflowHidden'>" |
| 2310 " <div class='forceScroll'></div>" | 2296 " <div class='forceScroll'></div>" |
| 2311 "</div>"); | 2297 "</div>"); |
| 2312 | 2298 |
| 2313 Element* overflowHidden = document().getElementById("overflowHidden"); | 2299 Element* overflowHidden = document().getElementById("overflowHidden"); |
| 2314 overflowHidden->setScrollTop(37); | 2300 overflowHidden->setScrollTop(37); |
| 2315 | 2301 |
| 2316 document().view()->updateAllLifecyclePhases(); | 2302 document().view()->updateAllLifecyclePhases(); |
| 2317 | 2303 |
| 2318 const ObjectPaintProperties* overflowHiddenScrollProperties = | 2304 const ObjectPaintProperties* overflowHiddenScrollProperties = |
| 2319 overflowHidden->layoutObject()->objectPaintProperties(); | 2305 overflowHidden->layoutObject()->paintProperties(); |
| 2320 // Because the frameView is does not scroll, overflowHidden's scroll should be | 2306 // Because the frameView is does not scroll, overflowHidden's scroll should be |
| 2321 // under the root. | 2307 // under the root. |
| 2322 EXPECT_TRUE(overflowHiddenScrollProperties->scroll()->parent()->isRoot()); | 2308 EXPECT_TRUE(overflowHiddenScrollProperties->scroll()->parent()->isRoot()); |
| 2323 EXPECT_EQ(TransformationMatrix().translate(0, -37), | 2309 EXPECT_EQ(TransformationMatrix().translate(0, -37), |
| 2324 overflowHiddenScrollProperties->scroll() | 2310 overflowHiddenScrollProperties->scroll() |
| 2325 ->scrollOffsetTranslation() | 2311 ->scrollOffsetTranslation() |
| 2326 ->matrix()); | 2312 ->matrix()); |
| 2327 // This should match the overflow's dimensions. | 2313 // This should match the overflow's dimensions. |
| 2328 EXPECT_EQ(IntSize(5, 3), overflowHiddenScrollProperties->scroll()->clip()); | 2314 EXPECT_EQ(IntSize(5, 3), overflowHiddenScrollProperties->scroll()->clip()); |
| 2329 // The scrolling content's bounds should include both the overflow's | 2315 // The scrolling content's bounds should include both the overflow's |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2365 "</div>"); | 2351 "</div>"); |
| 2366 | 2352 |
| 2367 Element* overflowA = document().getElementById("overflowA"); | 2353 Element* overflowA = document().getElementById("overflowA"); |
| 2368 overflowA->setScrollTop(37); | 2354 overflowA->setScrollTop(37); |
| 2369 Element* overflowB = document().getElementById("overflowB"); | 2355 Element* overflowB = document().getElementById("overflowB"); |
| 2370 overflowB->setScrollTop(41); | 2356 overflowB->setScrollTop(41); |
| 2371 | 2357 |
| 2372 document().view()->updateAllLifecyclePhases(); | 2358 document().view()->updateAllLifecyclePhases(); |
| 2373 | 2359 |
| 2374 const ObjectPaintProperties* overflowAScrollProperties = | 2360 const ObjectPaintProperties* overflowAScrollProperties = |
| 2375 overflowA->layoutObject()->objectPaintProperties(); | 2361 overflowA->layoutObject()->paintProperties(); |
| 2376 // Because the frameView is does not scroll, overflowA's scroll should be | 2362 // Because the frameView is does not scroll, overflowA's scroll should be |
| 2377 // under the root. | 2363 // under the root. |
| 2378 EXPECT_TRUE(overflowAScrollProperties->scroll()->parent()->isRoot()); | 2364 EXPECT_TRUE(overflowAScrollProperties->scroll()->parent()->isRoot()); |
| 2379 EXPECT_EQ( | 2365 EXPECT_EQ( |
| 2380 TransformationMatrix().translate(0, -37), | 2366 TransformationMatrix().translate(0, -37), |
| 2381 overflowAScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); | 2367 overflowAScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); |
| 2382 EXPECT_EQ(IntSize(5, 3), overflowAScrollProperties->scroll()->clip()); | 2368 EXPECT_EQ(IntSize(5, 3), overflowAScrollProperties->scroll()->clip()); |
| 2383 // 107 is the forceScroll element plus the height of the overflow scroll child | 2369 // 107 is the forceScroll element plus the height of the overflow scroll child |
| 2384 // (overflowB). | 2370 // (overflowB). |
| 2385 EXPECT_EQ(IntSize(9, 107), overflowAScrollProperties->scroll()->bounds()); | 2371 EXPECT_EQ(IntSize(9, 107), overflowAScrollProperties->scroll()->bounds()); |
| 2386 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableHorizontal()); | 2372 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableHorizontal()); |
| 2387 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableVertical()); | 2373 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableVertical()); |
| 2388 | 2374 |
| 2389 const ObjectPaintProperties* overflowBScrollProperties = | 2375 const ObjectPaintProperties* overflowBScrollProperties = |
| 2390 overflowB->layoutObject()->objectPaintProperties(); | 2376 overflowB->layoutObject()->paintProperties(); |
| 2391 // The overflow child's scroll node should be a child of the parent's | 2377 // The overflow child's scroll node should be a child of the parent's |
| 2392 // (overflowA) scroll node. | 2378 // (overflowA) scroll node. |
| 2393 EXPECT_EQ(overflowAScrollProperties->scroll(), | 2379 EXPECT_EQ(overflowAScrollProperties->scroll(), |
| 2394 overflowBScrollProperties->scroll()->parent()); | 2380 overflowBScrollProperties->scroll()->parent()); |
| 2395 EXPECT_EQ( | 2381 EXPECT_EQ( |
| 2396 TransformationMatrix().translate(0, -41), | 2382 TransformationMatrix().translate(0, -41), |
| 2397 overflowBScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); | 2383 overflowBScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); |
| 2398 EXPECT_EQ(IntSize(9, 7), overflowBScrollProperties->scroll()->clip()); | 2384 EXPECT_EQ(IntSize(9, 7), overflowBScrollProperties->scroll()->clip()); |
| 2399 EXPECT_EQ(IntSize(9, 100), overflowBScrollProperties->scroll()->bounds()); | 2385 EXPECT_EQ(IntSize(9, 100), overflowBScrollProperties->scroll()->bounds()); |
| 2400 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableHorizontal()); | 2386 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableHorizontal()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2449 absposOverflow->setScrollTop(41); | 2435 absposOverflow->setScrollTop(41); |
| 2450 Element* fixedOverflow = document().getElementById("fixedOverflow"); | 2436 Element* fixedOverflow = document().getElementById("fixedOverflow"); |
| 2451 fixedOverflow->setScrollTop(43); | 2437 fixedOverflow->setScrollTop(43); |
| 2452 | 2438 |
| 2453 document().view()->updateAllLifecyclePhases(); | 2439 document().view()->updateAllLifecyclePhases(); |
| 2454 | 2440 |
| 2455 // The frame should scroll due to the "forceScroll" element. | 2441 // The frame should scroll due to the "forceScroll" element. |
| 2456 EXPECT_NE(nullptr, frameScroll()); | 2442 EXPECT_NE(nullptr, frameScroll()); |
| 2457 | 2443 |
| 2458 const ObjectPaintProperties* overflowScrollProperties = | 2444 const ObjectPaintProperties* overflowScrollProperties = |
| 2459 overflow->layoutObject()->objectPaintProperties(); | 2445 overflow->layoutObject()->paintProperties(); |
| 2460 EXPECT_EQ(frameScroll(), overflowScrollProperties->scroll()->parent()); | 2446 EXPECT_EQ(frameScroll(), overflowScrollProperties->scroll()->parent()); |
| 2461 EXPECT_EQ( | 2447 EXPECT_EQ( |
| 2462 TransformationMatrix().translate(0, -37), | 2448 TransformationMatrix().translate(0, -37), |
| 2463 overflowScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); | 2449 overflowScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); |
| 2464 EXPECT_EQ(IntSize(5, 3), overflowScrollProperties->scroll()->clip()); | 2450 EXPECT_EQ(IntSize(5, 3), overflowScrollProperties->scroll()->clip()); |
| 2465 // The height should be 4000px because the (dom-order) overflow children are | 2451 // The height should be 4000px because the (dom-order) overflow children are |
| 2466 // positioned and do not contribute to the height. Only the 4000px | 2452 // positioned and do not contribute to the height. Only the 4000px |
| 2467 // "forceScroll" height is present. | 2453 // "forceScroll" height is present. |
| 2468 EXPECT_EQ(IntSize(5, 4000), overflowScrollProperties->scroll()->bounds()); | 2454 EXPECT_EQ(IntSize(5, 4000), overflowScrollProperties->scroll()->bounds()); |
| 2469 | 2455 |
| 2470 const ObjectPaintProperties* absposOverflowScrollProperties = | 2456 const ObjectPaintProperties* absposOverflowScrollProperties = |
| 2471 absposOverflow->layoutObject()->objectPaintProperties(); | 2457 absposOverflow->layoutObject()->paintProperties(); |
| 2472 // The absolute position overflow scroll node is parented under the frame, not | 2458 // The absolute position overflow scroll node is parented under the frame, not |
| 2473 // the dom-order parent. | 2459 // the dom-order parent. |
| 2474 EXPECT_EQ(frameScroll(), absposOverflowScrollProperties->scroll()->parent()); | 2460 EXPECT_EQ(frameScroll(), absposOverflowScrollProperties->scroll()->parent()); |
| 2475 EXPECT_EQ(TransformationMatrix().translate(0, -41), | 2461 EXPECT_EQ(TransformationMatrix().translate(0, -41), |
| 2476 absposOverflowScrollProperties->scroll() | 2462 absposOverflowScrollProperties->scroll() |
| 2477 ->scrollOffsetTranslation() | 2463 ->scrollOffsetTranslation() |
| 2478 ->matrix()); | 2464 ->matrix()); |
| 2479 EXPECT_EQ(IntSize(9, 7), absposOverflowScrollProperties->scroll()->clip()); | 2465 EXPECT_EQ(IntSize(9, 7), absposOverflowScrollProperties->scroll()->clip()); |
| 2480 EXPECT_EQ(IntSize(9, 4000), | 2466 EXPECT_EQ(IntSize(9, 4000), |
| 2481 absposOverflowScrollProperties->scroll()->bounds()); | 2467 absposOverflowScrollProperties->scroll()->bounds()); |
| 2482 | 2468 |
| 2483 const ObjectPaintProperties* fixedOverflowScrollProperties = | 2469 const ObjectPaintProperties* fixedOverflowScrollProperties = |
| 2484 fixedOverflow->layoutObject()->objectPaintProperties(); | 2470 fixedOverflow->layoutObject()->paintProperties(); |
| 2485 // The fixed position overflow scroll node is parented under the root, not the | 2471 // The fixed position overflow scroll node is parented under the root, not the |
| 2486 // dom-order parent or frame's scroll. | 2472 // dom-order parent or frame's scroll. |
| 2487 EXPECT_TRUE(fixedOverflowScrollProperties->scroll()->parent()->isRoot()); | 2473 EXPECT_TRUE(fixedOverflowScrollProperties->scroll()->parent()->isRoot()); |
| 2488 EXPECT_EQ(TransformationMatrix().translate(0, -43), | 2474 EXPECT_EQ(TransformationMatrix().translate(0, -43), |
| 2489 fixedOverflowScrollProperties->scroll() | 2475 fixedOverflowScrollProperties->scroll() |
| 2490 ->scrollOffsetTranslation() | 2476 ->scrollOffsetTranslation() |
| 2491 ->matrix()); | 2477 ->matrix()); |
| 2492 EXPECT_EQ(IntSize(13, 11), fixedOverflowScrollProperties->scroll()->clip()); | 2478 EXPECT_EQ(IntSize(13, 11), fixedOverflowScrollProperties->scroll()->clip()); |
| 2493 EXPECT_EQ(IntSize(13, 4000), | 2479 EXPECT_EQ(IntSize(13, 4000), |
| 2494 fixedOverflowScrollProperties->scroll()->bounds()); | 2480 fixedOverflowScrollProperties->scroll()->bounds()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2528 "</div>"); | 2514 "</div>"); |
| 2529 | 2515 |
| 2530 Element* overflowA = document().getElementById("overflowA"); | 2516 Element* overflowA = document().getElementById("overflowA"); |
| 2531 overflowA->setScrollTop(37); | 2517 overflowA->setScrollTop(37); |
| 2532 Element* overflowB = document().getElementById("overflowB"); | 2518 Element* overflowB = document().getElementById("overflowB"); |
| 2533 overflowB->setScrollTop(41); | 2519 overflowB->setScrollTop(41); |
| 2534 | 2520 |
| 2535 document().view()->updateAllLifecyclePhases(); | 2521 document().view()->updateAllLifecyclePhases(); |
| 2536 | 2522 |
| 2537 const ObjectPaintProperties* overflowAScrollProperties = | 2523 const ObjectPaintProperties* overflowAScrollProperties = |
| 2538 overflowA->layoutObject()->objectPaintProperties(); | 2524 overflowA->layoutObject()->paintProperties(); |
| 2539 // Because the frameView is does not scroll, overflowA's scroll should be | 2525 // Because the frameView is does not scroll, overflowA's scroll should be |
| 2540 // under the root. | 2526 // under the root. |
| 2541 EXPECT_TRUE(overflowAScrollProperties->scroll()->parent()->isRoot()); | 2527 EXPECT_TRUE(overflowAScrollProperties->scroll()->parent()->isRoot()); |
| 2542 EXPECT_EQ( | 2528 EXPECT_EQ( |
| 2543 TransformationMatrix().translate(0, -37), | 2529 TransformationMatrix().translate(0, -37), |
| 2544 overflowAScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); | 2530 overflowAScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); |
| 2545 EXPECT_EQ(IntSize(20, 20), overflowAScrollProperties->scroll()->clip()); | 2531 EXPECT_EQ(IntSize(20, 20), overflowAScrollProperties->scroll()->clip()); |
| 2546 // 100 is the forceScroll element's height because the overflow child does not | 2532 // 100 is the forceScroll element's height because the overflow child does not |
| 2547 // contribute to the height. | 2533 // contribute to the height. |
| 2548 EXPECT_EQ(IntSize(20, 100), overflowAScrollProperties->scroll()->bounds()); | 2534 EXPECT_EQ(IntSize(20, 100), overflowAScrollProperties->scroll()->bounds()); |
| 2549 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableHorizontal()); | 2535 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableHorizontal()); |
| 2550 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableVertical()); | 2536 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableVertical()); |
| 2551 | 2537 |
| 2552 const ObjectPaintProperties* overflowBScrollProperties = | 2538 const ObjectPaintProperties* overflowBScrollProperties = |
| 2553 overflowB->layoutObject()->objectPaintProperties(); | 2539 overflowB->layoutObject()->paintProperties(); |
| 2554 // The overflow child's scroll node should be a child of the parent's | 2540 // The overflow child's scroll node should be a child of the parent's |
| 2555 // (overflowA) scroll node. | 2541 // (overflowA) scroll node. |
| 2556 EXPECT_EQ(overflowAScrollProperties->scroll(), | 2542 EXPECT_EQ(overflowAScrollProperties->scroll(), |
| 2557 overflowBScrollProperties->scroll()->parent()); | 2543 overflowBScrollProperties->scroll()->parent()); |
| 2558 EXPECT_EQ( | 2544 EXPECT_EQ( |
| 2559 TransformationMatrix().translate(0, -41), | 2545 TransformationMatrix().translate(0, -41), |
| 2560 overflowBScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); | 2546 overflowBScrollProperties->scroll()->scrollOffsetTranslation()->matrix()); |
| 2561 EXPECT_EQ(IntSize(5, 3), overflowBScrollProperties->scroll()->clip()); | 2547 EXPECT_EQ(IntSize(5, 3), overflowBScrollProperties->scroll()->clip()); |
| 2562 EXPECT_EQ(IntSize(5, 100), overflowBScrollProperties->scroll()->bounds()); | 2548 EXPECT_EQ(IntSize(5, 100), overflowBScrollProperties->scroll()->bounds()); |
| 2563 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableHorizontal()); | 2549 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableHorizontal()); |
| 2564 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableVertical()); | 2550 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableVertical()); |
| 2565 } | 2551 } |
| 2566 | 2552 |
| 2567 TEST_P(PaintPropertyTreeBuilderTest, SVGRootClip) { | 2553 TEST_P(PaintPropertyTreeBuilderTest, SVGRootClip) { |
| 2568 setBodyInnerHTML( | 2554 setBodyInnerHTML( |
| 2569 "<svg id='svg' xmlns='http://www.w3.org/2000/svg' width='100px' " | 2555 "<svg id='svg' xmlns='http://www.w3.org/2000/svg' width='100px' " |
| 2570 "height='100px'>" | 2556 "height='100px'>" |
| 2571 " <rect width='200' height='200' fill='red' />" | 2557 " <rect width='200' height='200' fill='red' />" |
| 2572 "</svg>"); | 2558 "</svg>"); |
| 2573 | 2559 |
| 2574 const ClipPaintPropertyNode* clip = getLayoutObjectByElementId("svg") | 2560 const ClipPaintPropertyNode* clip = |
| 2575 ->objectPaintProperties() | 2561 getLayoutObjectByElementId("svg")->paintProperties()->overflowClip(); |
| 2576 ->overflowClip(); | |
| 2577 EXPECT_EQ(frameContentClip(), clip->parent()); | 2562 EXPECT_EQ(frameContentClip(), clip->parent()); |
| 2578 EXPECT_EQ(FloatRoundedRect(8, 8, 100, 100), clip->clipRect()); | 2563 EXPECT_EQ(FloatRoundedRect(8, 8, 100, 100), clip->clipRect()); |
| 2579 } | 2564 } |
| 2580 | 2565 |
| 2581 TEST_P(PaintPropertyTreeBuilderTest, SVGRootNoClip) { | 2566 TEST_P(PaintPropertyTreeBuilderTest, SVGRootNoClip) { |
| 2582 setBodyInnerHTML( | 2567 setBodyInnerHTML( |
| 2583 "<svg id='svg' xmlns='http://www.w3.org/2000/svg' width='100px' " | 2568 "<svg id='svg' xmlns='http://www.w3.org/2000/svg' width='100px' " |
| 2584 "height='100px' style='overflow: visible'>" | 2569 "height='100px' style='overflow: visible'>" |
| 2585 " <rect width='200' height='200' fill='red' />" | 2570 " <rect width='200' height='200' fill='red' />" |
| 2586 "</svg>"); | 2571 "</svg>"); |
| 2587 | 2572 |
| 2588 EXPECT_FALSE(getLayoutObjectByElementId("svg") | 2573 EXPECT_FALSE( |
| 2589 ->objectPaintProperties() | 2574 getLayoutObjectByElementId("svg")->paintProperties()->overflowClip()); |
| 2590 ->overflowClip()); | |
| 2591 } | 2575 } |
| 2592 | 2576 |
| 2593 TEST_P(PaintPropertyTreeBuilderTest, | 2577 TEST_P(PaintPropertyTreeBuilderTest, |
| 2594 ThreadedScrollingDisabledMainThreadScrollReason) { | 2578 ThreadedScrollingDisabledMainThreadScrollReason) { |
| 2595 setBodyInnerHTML( | 2579 setBodyInnerHTML( |
| 2596 "<style>" | 2580 "<style>" |
| 2597 " #overflowA {" | 2581 " #overflowA {" |
| 2598 " position: absolute;" | 2582 " position: absolute;" |
| 2599 " overflow: scroll;" | 2583 " overflow: scroll;" |
| 2600 " width: 20px;" | 2584 " width: 20px;" |
| 2601 " height: 20px;" | 2585 " height: 20px;" |
| 2602 " }" | 2586 " }" |
| 2603 " .forceScroll {" | 2587 " .forceScroll {" |
| 2604 " height: 4000px;" | 2588 " height: 4000px;" |
| 2605 " }" | 2589 " }" |
| 2606 "</style>" | 2590 "</style>" |
| 2607 "<div id='overflowA'>" | 2591 "<div id='overflowA'>" |
| 2608 " <div class='forceScroll'></div>" | 2592 " <div class='forceScroll'></div>" |
| 2609 "</div>" | 2593 "</div>" |
| 2610 "<div class='forceScroll'></div>"); | 2594 "<div class='forceScroll'></div>"); |
| 2611 Element* overflowA = document().getElementById("overflowA"); | 2595 Element* overflowA = document().getElementById("overflowA"); |
| 2612 EXPECT_FALSE(frameScroll()->hasMainThreadScrollingReasons( | 2596 EXPECT_FALSE(frameScroll()->hasMainThreadScrollingReasons( |
| 2613 MainThreadScrollingReason::kThreadedScrollingDisabled)); | 2597 MainThreadScrollingReason::kThreadedScrollingDisabled)); |
| 2614 EXPECT_FALSE(overflowA->layoutObject() | 2598 EXPECT_FALSE(overflowA->layoutObject() |
| 2615 ->objectPaintProperties() | 2599 ->paintProperties() |
| 2616 ->scroll() | 2600 ->scroll() |
| 2617 ->hasMainThreadScrollingReasons( | 2601 ->hasMainThreadScrollingReasons( |
| 2618 MainThreadScrollingReason::kThreadedScrollingDisabled)); | 2602 MainThreadScrollingReason::kThreadedScrollingDisabled)); |
| 2619 | 2603 |
| 2620 document().settings()->setThreadedScrollingEnabled(false); | 2604 document().settings()->setThreadedScrollingEnabled(false); |
| 2621 document().view()->updateAllLifecyclePhases(); | 2605 document().view()->updateAllLifecyclePhases(); |
| 2622 | 2606 |
| 2623 EXPECT_TRUE(frameScroll()->hasMainThreadScrollingReasons( | 2607 EXPECT_TRUE(frameScroll()->hasMainThreadScrollingReasons( |
| 2624 MainThreadScrollingReason::kThreadedScrollingDisabled)); | 2608 MainThreadScrollingReason::kThreadedScrollingDisabled)); |
| 2625 EXPECT_TRUE(overflowA->layoutObject() | 2609 EXPECT_TRUE(overflowA->layoutObject() |
| 2626 ->objectPaintProperties() | 2610 ->paintProperties() |
| 2627 ->scroll() | 2611 ->scroll() |
| 2628 ->hasMainThreadScrollingReasons( | 2612 ->hasMainThreadScrollingReasons( |
| 2629 MainThreadScrollingReason::kThreadedScrollingDisabled)); | 2613 MainThreadScrollingReason::kThreadedScrollingDisabled)); |
| 2630 } | 2614 } |
| 2631 | 2615 |
| 2632 TEST_P(PaintPropertyTreeBuilderTest, | 2616 TEST_P(PaintPropertyTreeBuilderTest, |
| 2633 BackgroundAttachmentFixedMainThreadScrollReasonsWithNestedScrollers) { | 2617 BackgroundAttachmentFixedMainThreadScrollReasonsWithNestedScrollers) { |
| 2634 setBodyInnerHTML( | 2618 setBodyInnerHTML( |
| 2635 "<style>" | 2619 "<style>" |
| 2636 " #overflowA {" | 2620 " #overflowA {" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2660 " <div class='forceScroll'></div>" | 2644 " <div class='forceScroll'></div>" |
| 2661 "</div>" | 2645 "</div>" |
| 2662 "<div class='forceScroll'></div>"); | 2646 "<div class='forceScroll'></div>"); |
| 2663 Element* overflowA = document().getElementById("overflowA"); | 2647 Element* overflowA = document().getElementById("overflowA"); |
| 2664 Element* overflowB = document().getElementById("overflowB"); | 2648 Element* overflowB = document().getElementById("overflowB"); |
| 2665 | 2649 |
| 2666 EXPECT_TRUE(frameScroll()->hasMainThreadScrollingReasons( | 2650 EXPECT_TRUE(frameScroll()->hasMainThreadScrollingReasons( |
| 2667 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2651 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2668 EXPECT_TRUE( | 2652 EXPECT_TRUE( |
| 2669 overflowA->layoutObject() | 2653 overflowA->layoutObject() |
| 2670 ->objectPaintProperties() | 2654 ->paintProperties() |
| 2671 ->scroll() | 2655 ->scroll() |
| 2672 ->hasMainThreadScrollingReasons( | 2656 ->hasMainThreadScrollingReasons( |
| 2673 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2657 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2674 EXPECT_FALSE( | 2658 EXPECT_FALSE( |
| 2675 overflowB->layoutObject() | 2659 overflowB->layoutObject() |
| 2676 ->objectPaintProperties() | 2660 ->paintProperties() |
| 2677 ->scroll() | 2661 ->scroll() |
| 2678 ->hasMainThreadScrollingReasons( | 2662 ->hasMainThreadScrollingReasons( |
| 2679 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2663 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2680 | 2664 |
| 2681 // Removing a main thread scrolling reason should update the entire tree. | 2665 // Removing a main thread scrolling reason should update the entire tree. |
| 2682 overflowB->removeAttribute("class"); | 2666 overflowB->removeAttribute("class"); |
| 2683 document().view()->updateAllLifecyclePhases(); | 2667 document().view()->updateAllLifecyclePhases(); |
| 2684 EXPECT_FALSE(frameScroll()->hasMainThreadScrollingReasons( | 2668 EXPECT_FALSE(frameScroll()->hasMainThreadScrollingReasons( |
| 2685 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2669 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2686 EXPECT_FALSE( | 2670 EXPECT_FALSE( |
| 2687 overflowA->layoutObject() | 2671 overflowA->layoutObject() |
| 2688 ->objectPaintProperties() | 2672 ->paintProperties() |
| 2689 ->scroll() | 2673 ->scroll() |
| 2690 ->hasMainThreadScrollingReasons( | 2674 ->hasMainThreadScrollingReasons( |
| 2691 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2675 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2692 EXPECT_FALSE( | 2676 EXPECT_FALSE( |
| 2693 overflowB->layoutObject() | 2677 overflowB->layoutObject() |
| 2694 ->objectPaintProperties() | 2678 ->paintProperties() |
| 2695 ->scroll() | 2679 ->scroll() |
| 2696 ->hasMainThreadScrollingReasons( | 2680 ->hasMainThreadScrollingReasons( |
| 2697 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2681 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2698 | 2682 |
| 2699 // Adding a main thread scrolling reason should update the entire tree. | 2683 // Adding a main thread scrolling reason should update the entire tree. |
| 2700 overflowB->setAttribute(HTMLNames::classAttr, "backgroundAttachmentFixed"); | 2684 overflowB->setAttribute(HTMLNames::classAttr, "backgroundAttachmentFixed"); |
| 2701 document().view()->updateAllLifecyclePhases(); | 2685 document().view()->updateAllLifecyclePhases(); |
| 2702 EXPECT_TRUE(frameScroll()->hasMainThreadScrollingReasons( | 2686 EXPECT_TRUE(frameScroll()->hasMainThreadScrollingReasons( |
| 2703 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2687 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2704 EXPECT_TRUE( | 2688 EXPECT_TRUE( |
| 2705 overflowA->layoutObject() | 2689 overflowA->layoutObject() |
| 2706 ->objectPaintProperties() | 2690 ->paintProperties() |
| 2707 ->scroll() | 2691 ->scroll() |
| 2708 ->hasMainThreadScrollingReasons( | 2692 ->hasMainThreadScrollingReasons( |
| 2709 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2693 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2710 EXPECT_FALSE( | 2694 EXPECT_FALSE( |
| 2711 overflowB->layoutObject() | 2695 overflowB->layoutObject() |
| 2712 ->objectPaintProperties() | 2696 ->paintProperties() |
| 2713 ->scroll() | 2697 ->scroll() |
| 2714 ->hasMainThreadScrollingReasons( | 2698 ->hasMainThreadScrollingReasons( |
| 2715 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2699 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2716 } | 2700 } |
| 2717 | 2701 |
| 2718 TEST_P(PaintPropertyTreeBuilderTest, | 2702 TEST_P(PaintPropertyTreeBuilderTest, |
| 2719 BackgroundAttachmentFixedMainThreadScrollReasonsWithFixedScroller) { | 2703 BackgroundAttachmentFixedMainThreadScrollReasonsWithFixedScroller) { |
| 2720 setBodyInnerHTML( | 2704 setBodyInnerHTML( |
| 2721 "<style>" | 2705 "<style>" |
| 2722 " #overflowA {" | 2706 " #overflowA {" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2744 " <div class='forceScroll'></div>" | 2728 " <div class='forceScroll'></div>" |
| 2745 " </div>" | 2729 " </div>" |
| 2746 " <div class='forceScroll'></div>" | 2730 " <div class='forceScroll'></div>" |
| 2747 "</div>" | 2731 "</div>" |
| 2748 "<div class='forceScroll'></div>"); | 2732 "<div class='forceScroll'></div>"); |
| 2749 Element* overflowA = document().getElementById("overflowA"); | 2733 Element* overflowA = document().getElementById("overflowA"); |
| 2750 Element* overflowB = document().getElementById("overflowB"); | 2734 Element* overflowB = document().getElementById("overflowB"); |
| 2751 | 2735 |
| 2752 EXPECT_FALSE( | 2736 EXPECT_FALSE( |
| 2753 overflowA->layoutObject() | 2737 overflowA->layoutObject() |
| 2754 ->objectPaintProperties() | 2738 ->paintProperties() |
| 2755 ->scroll() | 2739 ->scroll() |
| 2756 ->hasMainThreadScrollingReasons( | 2740 ->hasMainThreadScrollingReasons( |
| 2757 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2741 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2758 EXPECT_FALSE( | 2742 EXPECT_FALSE( |
| 2759 overflowB->layoutObject() | 2743 overflowB->layoutObject() |
| 2760 ->objectPaintProperties() | 2744 ->paintProperties() |
| 2761 ->scroll() | 2745 ->scroll() |
| 2762 ->hasMainThreadScrollingReasons( | 2746 ->hasMainThreadScrollingReasons( |
| 2763 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2747 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2764 EXPECT_TRUE( | 2748 EXPECT_TRUE( |
| 2765 overflowB->layoutObject() | 2749 overflowB->layoutObject() |
| 2766 ->objectPaintProperties() | 2750 ->paintProperties() |
| 2767 ->scroll() | 2751 ->scroll() |
| 2768 ->parent() | 2752 ->parent() |
| 2769 ->hasMainThreadScrollingReasons( | 2753 ->hasMainThreadScrollingReasons( |
| 2770 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2754 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2771 | 2755 |
| 2772 // Removing a main thread scrolling reason should update the entire tree. | 2756 // Removing a main thread scrolling reason should update the entire tree. |
| 2773 overflowB->removeAttribute("class"); | 2757 overflowB->removeAttribute("class"); |
| 2774 document().view()->updateAllLifecyclePhases(); | 2758 document().view()->updateAllLifecyclePhases(); |
| 2775 EXPECT_FALSE( | 2759 EXPECT_FALSE( |
| 2776 overflowA->layoutObject() | 2760 overflowA->layoutObject() |
| 2777 ->objectPaintProperties() | 2761 ->paintProperties() |
| 2778 ->scroll() | 2762 ->scroll() |
| 2779 ->hasMainThreadScrollingReasons( | 2763 ->hasMainThreadScrollingReasons( |
| 2780 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2764 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2781 EXPECT_FALSE( | 2765 EXPECT_FALSE( |
| 2782 overflowB->layoutObject() | 2766 overflowB->layoutObject() |
| 2783 ->objectPaintProperties() | 2767 ->paintProperties() |
| 2784 ->scroll() | 2768 ->scroll() |
| 2785 ->hasMainThreadScrollingReasons( | 2769 ->hasMainThreadScrollingReasons( |
| 2786 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2770 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2787 EXPECT_FALSE( | 2771 EXPECT_FALSE( |
| 2788 overflowB->layoutObject() | 2772 overflowB->layoutObject() |
| 2789 ->objectPaintProperties() | 2773 ->paintProperties() |
| 2790 ->scroll() | 2774 ->scroll() |
| 2791 ->parent() | 2775 ->parent() |
| 2792 ->hasMainThreadScrollingReasons( | 2776 ->hasMainThreadScrollingReasons( |
| 2793 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); | 2777 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects)); |
| 2794 } | 2778 } |
| 2795 | 2779 |
| 2796 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetsUnderMultiColumn) { | 2780 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetsUnderMultiColumn) { |
| 2797 setBodyInnerHTML( | 2781 setBodyInnerHTML( |
| 2798 "<style>" | 2782 "<style>" |
| 2799 " body { margin: 0; }" | 2783 " body { margin: 0; }" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2870 " <div id=absolute style='position: absolute'>absolute</div>" | 2854 " <div id=absolute style='position: absolute'>absolute</div>" |
| 2871 " </div>" | 2855 " </div>" |
| 2872 " </span>" | 2856 " </span>" |
| 2873 "</div>"); | 2857 "</div>"); |
| 2874 // There should be anonymous block created containing the inline "relative", | 2858 // There should be anonymous block created containing the inline "relative", |
| 2875 // serving as the container of "absolute". | 2859 // serving as the container of "absolute". |
| 2876 EXPECT_TRUE( | 2860 EXPECT_TRUE( |
| 2877 getLayoutObjectByElementId("absolute")->container()->isLayoutBlock()); | 2861 getLayoutObjectByElementId("absolute")->container()->isLayoutBlock()); |
| 2878 } | 2862 } |
| 2879 } // namespace blink | 2863 } // namespace blink |
| OLD | NEW |