Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/paint/PaintLayerClipper.h" | 5 #include "core/paint/PaintLayerClipper.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutBoxModelObject.h" | 7 #include "core/layout/LayoutBoxModelObject.h" |
| 8 #include "core/layout/LayoutTestHelper.h" | 8 #include "core/layout/LayoutTestHelper.h" |
| 9 #include "core/layout/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
| 10 #include "core/paint/PaintLayer.h" | 10 #include "core/paint/PaintLayer.h" |
| 11 #include "platform/LayoutTestSupport.h" | |
| 11 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 12 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| 12 #include "platform/testing/UnitTestHelpers.h" | 13 #include "platform/testing/UnitTestHelpers.h" |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 class PaintLayerClipperTest : public ::testing::WithParamInterface<bool>, | 17 class PaintLayerClipperTest : public ::testing::WithParamInterface<bool>, |
| 17 private ScopedSlimmingPaintV2ForTest, | 18 private ScopedSlimmingPaintV2ForTest, |
| 18 public RenderingTest { | 19 public RenderingTest { |
| 19 public: | 20 public: |
| 20 PaintLayerClipperTest() | 21 PaintLayerClipperTest() |
| 21 : ScopedSlimmingPaintV2ForTest(GetParam()), | 22 : ScopedSlimmingPaintV2ForTest(GetParam()), |
| 22 RenderingTest(EmptyFrameLoaderClient::create()) {} | 23 RenderingTest(EmptyFrameLoaderClient::create()) {} |
| 23 | 24 |
| 25 void SetUp() override { | |
| 26 LayoutTestSupport::setMockThemeEnabledForTest(true); | |
| 27 RenderingTest::SetUp(); | |
| 28 } | |
| 29 | |
| 30 void TearDown() override { | |
| 31 LayoutTestSupport::setMockThemeEnabledForTest(false); | |
| 32 RenderingTest::TearDown(); | |
| 33 } | |
| 34 | |
| 24 bool geometryMapperCacheEmpty(const PaintLayerClipper& clipper) { | 35 bool geometryMapperCacheEmpty(const PaintLayerClipper& clipper) { |
| 25 return clipper.m_geometryMapper->m_data.isEmpty(); | 36 return clipper.m_geometryMapper->m_data.isEmpty(); |
| 26 } | 37 } |
| 27 }; | 38 }; |
| 28 | 39 |
| 29 INSTANTIATE_TEST_CASE_P(All, | 40 INSTANTIATE_TEST_CASE_P(All, |
| 30 PaintLayerClipperTest, | 41 PaintLayerClipperTest, |
| 31 ::testing::ValuesIn({false, true})); | 42 ::testing::ValuesIn({false, true})); |
| 32 | 43 |
| 33 TEST_P(PaintLayerClipperTest, LayoutSVGRoot) { | 44 TEST_P(PaintLayerClipperTest, LayoutSVGRoot) { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 48 LayoutRect layerBounds; | 59 LayoutRect layerBounds; |
| 49 ClipRect backgroundRect, foregroundRect; | 60 ClipRect backgroundRect, foregroundRect; |
| 50 targetPaintLayer->clipper().calculateRects( | 61 targetPaintLayer->clipper().calculateRects( |
| 51 context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds, | 62 context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds, |
| 52 backgroundRect, foregroundRect); | 63 backgroundRect, foregroundRect); |
| 53 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect()); | 64 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect()); |
| 54 EXPECT_EQ(LayoutRect(8, 8, 200, 300), foregroundRect.rect()); | 65 EXPECT_EQ(LayoutRect(8, 8, 200, 300), foregroundRect.rect()); |
| 55 EXPECT_EQ(LayoutRect(8, 8, 200, 300), layerBounds); | 66 EXPECT_EQ(LayoutRect(8, 8, 200, 300), layerBounds); |
| 56 } | 67 } |
| 57 | 68 |
| 69 TEST_P(PaintLayerClipperTest, ControlClip) { | |
| 70 setBodyInnerHTML( | |
| 71 "<!DOCTYPE html>" | |
| 72 "<input id=target style='position:absolute; width: 200px; height: 300px'" | |
| 73 " type=button>"); | |
| 74 Element* target = document().getElementById("target"); | |
| 75 PaintLayer* targetPaintLayer = | |
| 76 toLayoutBoxModelObject(target->layoutObject())->layer(); | |
| 77 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects); | |
| 78 // When RLS is enabled, the LayoutView will have a composited scrolling layer, | |
| 79 // so don't apply an overflow clip. | |
| 80 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | |
| 81 context.setIgnoreOverflowClip(); | |
| 82 LayoutRect layerBounds; | |
| 83 ClipRect backgroundRect, foregroundRect; | |
| 84 targetPaintLayer->clipper().calculateRects( | |
| 85 context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds, | |
| 86 backgroundRect, foregroundRect); | |
| 87 #if OS(MACOSX) | |
|
chrishtr
2017/01/18 21:12:30
Added OSX-specific expectations. I tried to make m
| |
| 88 // If the PaintLayer clips overflow, the background rect is intersected with | |
| 89 // the PaintLayer bounds... | |
| 90 EXPECT_EQ(LayoutRect(3, 4, 210, 28), backgroundRect.rect()); | |
|
chrishtr
2017/01/18 21:12:30
On Mac, input elements are forced into not being m
| |
| 91 // and the foreground rect is intersected with the control clip in this case. | |
| 92 EXPECT_EQ(LayoutRect(8, 8, 200, 18), foregroundRect.rect()); | |
| 93 EXPECT_EQ(LayoutRect(8, 8, 200, 18), layerBounds); | |
| 94 #else | |
| 95 // If the PaintLayer clips overflow, the background rect is intersected with | |
| 96 // the PaintLayer bounds... | |
| 97 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect()); | |
| 98 // and the foreground rect is intersected with the control clip in this case. | |
| 99 EXPECT_EQ(LayoutRect(10, 10, 196, 296), foregroundRect.rect()); | |
| 100 EXPECT_EQ(LayoutRect(8, 8, 200, 300), layerBounds); | |
| 101 #endif | |
| 102 } | |
| 103 | |
| 58 TEST_P(PaintLayerClipperTest, LayoutSVGRootChild) { | 104 TEST_P(PaintLayerClipperTest, LayoutSVGRootChild) { |
| 59 setBodyInnerHTML( | 105 setBodyInnerHTML( |
| 60 "<svg width=200 height=300 style='position: relative'>" | 106 "<svg width=200 height=300 style='position: relative'>" |
| 61 " <foreignObject width=400 height=500>" | 107 " <foreignObject width=400 height=500>" |
| 62 " <div id=target xmlns='http://www.w3.org/1999/xhtml' " | 108 " <div id=target xmlns='http://www.w3.org/1999/xhtml' " |
| 63 "style='position: relative'></div>" | 109 "style='position: relative'></div>" |
| 64 " </foreignObject>" | 110 " </foreignObject>" |
| 65 "</svg>"); | 111 "</svg>"); |
| 66 | 112 |
| 67 Element* target = document().getElementById("target"); | 113 Element* target = document().getElementById("target"); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 | 302 |
| 257 parent->clipper().clearClipRectsIncludingDescendants(AbsoluteClipRects); | 303 parent->clipper().clearClipRectsIncludingDescendants(AbsoluteClipRects); |
| 258 | 304 |
| 259 EXPECT_TRUE(parent->clipRectsCache()); | 305 EXPECT_TRUE(parent->clipRectsCache()); |
| 260 EXPECT_TRUE(child->clipRectsCache()); | 306 EXPECT_TRUE(child->clipRectsCache()); |
| 261 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root); | 307 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root); |
| 262 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root); | 308 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root); |
| 263 } | 309 } |
| 264 | 310 |
| 265 } // namespace blink | 311 } // namespace blink |
| OLD | NEW |