| 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" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 #else | 94 #else |
| 95 // If the PaintLayer clips overflow, the background rect is intersected with | 95 // If the PaintLayer clips overflow, the background rect is intersected with |
| 96 // the PaintLayer bounds... | 96 // the PaintLayer bounds... |
| 97 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect()); | 97 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect()); |
| 98 // and the foreground rect is intersected with the control clip in this case. | 98 // and the foreground rect is intersected with the control clip in this case. |
| 99 EXPECT_EQ(LayoutRect(10, 10, 196, 296), foregroundRect.rect()); | 99 EXPECT_EQ(LayoutRect(10, 10, 196, 296), foregroundRect.rect()); |
| 100 EXPECT_EQ(LayoutRect(8, 8, 200, 300), layerBounds); | 100 EXPECT_EQ(LayoutRect(8, 8, 200, 300), layerBounds); |
| 101 #endif | 101 #endif |
| 102 } | 102 } |
| 103 | 103 |
| 104 TEST_P(PaintLayerClipperTest, ControlClipSelect) { |
| 105 setBodyInnerHTML( |
| 106 "<select id='target' style='position: relative; width: 100px; " |
| 107 " background: none; border: none; padding: 0px 15px 0px 5px;'>" |
| 108 " <option>" |
| 109 " Test long texttttttttttttttttttttttttttttttt" |
| 110 " </option>" |
| 111 "</select>"); |
| 112 Element* target = document().getElementById("target"); |
| 113 PaintLayer* targetPaintLayer = |
| 114 toLayoutBoxModelObject(target->layoutObject())->layer(); |
| 115 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects); |
| 116 // When RLS is enabled, the LayoutView will have a composited scrolling layer, |
| 117 // so don't apply an overflow clip. |
| 118 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
| 119 context.setIgnoreOverflowClip(); |
| 120 LayoutRect layerBounds; |
| 121 ClipRect backgroundRect, foregroundRect; |
| 122 targetPaintLayer->clipper().calculateRects( |
| 123 context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds, |
| 124 backgroundRect, foregroundRect); |
| 125 // The control clip for a select excludes the area for the down arrow. |
| 126 #if OS(MACOSX) |
| 127 EXPECT_EQ(LayoutRect(16, 9, 79, 13), foregroundRect.rect()); |
| 128 #elif OS(WIN) |
| 129 EXPECT_EQ(LayoutRect(17, 9, 60, 16), foregroundRect.rect()); |
| 130 #else |
| 131 EXPECT_EQ(LayoutRect(17, 9, 60, 15), foregroundRect.rect()); |
| 132 #endif |
| 133 } |
| 134 |
| 104 TEST_P(PaintLayerClipperTest, LayoutSVGRootChild) { | 135 TEST_P(PaintLayerClipperTest, LayoutSVGRootChild) { |
| 105 setBodyInnerHTML( | 136 setBodyInnerHTML( |
| 106 "<svg width=200 height=300 style='position: relative'>" | 137 "<svg width=200 height=300 style='position: relative'>" |
| 107 " <foreignObject width=400 height=500>" | 138 " <foreignObject width=400 height=500>" |
| 108 " <div id=target xmlns='http://www.w3.org/1999/xhtml' " | 139 " <div id=target xmlns='http://www.w3.org/1999/xhtml' " |
| 109 "style='position: relative'></div>" | 140 "style='position: relative'></div>" |
| 110 " </foreignObject>" | 141 " </foreignObject>" |
| 111 "</svg>"); | 142 "</svg>"); |
| 112 | 143 |
| 113 Element* target = document().getElementById("target"); | 144 Element* target = document().getElementById("target"); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 333 |
| 303 parent->clipper().clearClipRectsIncludingDescendants(AbsoluteClipRects); | 334 parent->clipper().clearClipRectsIncludingDescendants(AbsoluteClipRects); |
| 304 | 335 |
| 305 EXPECT_TRUE(parent->clipRectsCache()); | 336 EXPECT_TRUE(parent->clipRectsCache()); |
| 306 EXPECT_TRUE(child->clipRectsCache()); | 337 EXPECT_TRUE(child->clipRectsCache()); |
| 307 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root); | 338 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root); |
| 308 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root); | 339 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root); |
| 309 } | 340 } |
| 310 | 341 |
| 311 } // namespace blink | 342 } // namespace blink |
| OLD | NEW |