Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp

Issue 2678263002: Plumb border radius through when computing clip visual rects. (Closed)
Patch Set: none Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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, RoundedClip) {
105 setBodyInnerHTML(
106 "<!DOCTYPE html>"
107 "<div id='target' style='position:absolute; width: 200px; height: 300px;"
108 " overflow: hidden; border-radius: 1px'>"
109 "</div>");
110
111 Element* target = document().getElementById("target");
112 PaintLayer* targetPaintLayer =
113 toLayoutBoxModelObject(target->layoutObject())->layer();
114 ClipRectsContext context(document().layoutView()->layer(), UncachedClipRects);
115 // When RLS is enabled, the LayoutView will have a composited scrolling layer,
116 // so don't apply an overflow clip.
117 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
118 context.setIgnoreOverflowClip();
119
120 LayoutRect layerBounds;
121 ClipRect backgroundRect, foregroundRect;
122 targetPaintLayer->clipper().calculateRects(
123 context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds,
124 backgroundRect, foregroundRect);
125
126 // Only the foreground rect gets hasRadius set for overflow clipping
127 // of descendants.
128 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect());
129 EXPECT_FALSE(backgroundRect.hasRadius());
130 EXPECT_EQ(LayoutRect(8, 8, 200, 300), foregroundRect.rect());
131 EXPECT_TRUE(foregroundRect.hasRadius());
132 EXPECT_EQ(LayoutRect(8, 8, 200, 300), layerBounds);
133 }
134
135 TEST_P(PaintLayerClipperTest, RoundedClipNested) {
136 setBodyInnerHTML(
137 "<!DOCTYPE html>"
138 "<div id='parent' style='position:absolute; width: 200px; height: 300px;"
139 " overflow: hidden; border-radius: 1px'>"
140 " <div id='child' style='position: relative; width: 500px; "
141 " height: 500px'>"
142 " </div>"
143 "</div>");
144
145 Element* parent = document().getElementById("parent");
146 PaintLayer* parentPaintLayer =
147 toLayoutBoxModelObject(parent->layoutObject())->layer();
148
149 Element* child = document().getElementById("child");
150 PaintLayer* childPaintLayer =
151 toLayoutBoxModelObject(child->layoutObject())->layer();
152
153 ClipRectsContext context(parentPaintLayer, UncachedClipRects);
154
155 LayoutRect layerBounds;
156 ClipRect backgroundRect, foregroundRect;
157 childPaintLayer->clipper().calculateRects(
158 context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds,
159 backgroundRect, foregroundRect);
160
161 EXPECT_EQ(LayoutRect(0, 0, 200, 300), backgroundRect.rect());
162 EXPECT_TRUE(backgroundRect.hasRadius());
163 EXPECT_EQ(LayoutRect(0, 0, 200, 300), foregroundRect.rect());
164 EXPECT_TRUE(foregroundRect.hasRadius());
165 EXPECT_EQ(LayoutRect(0, 0, 500, 500), layerBounds);
166 }
167
104 TEST_P(PaintLayerClipperTest, ControlClipSelect) { 168 TEST_P(PaintLayerClipperTest, ControlClipSelect) {
105 setBodyInnerHTML( 169 setBodyInnerHTML(
106 "<select id='target' style='position: relative; width: 100px; " 170 "<select id='target' style='position: relative; width: 100px; "
107 " background: none; border: none; padding: 0px 15px 0px 5px;'>" 171 " background: none; border: none; padding: 0px 15px 0px 5px;'>"
108 " <option>" 172 " <option>"
109 " Test long texttttttttttttttttttttttttttttttt" 173 " Test long texttttttttttttttttttttttttttttttt"
110 " </option>" 174 " </option>"
111 "</select>"); 175 "</select>");
112 Element* target = document().getElementById("target"); 176 Element* target = document().getElementById("target");
113 PaintLayer* targetPaintLayer = 177 PaintLayer* targetPaintLayer =
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 397
334 parent->clipper().clearClipRectsIncludingDescendants(AbsoluteClipRects); 398 parent->clipper().clearClipRectsIncludingDescendants(AbsoluteClipRects);
335 399
336 EXPECT_TRUE(parent->clipRectsCache()); 400 EXPECT_TRUE(parent->clipRectsCache());
337 EXPECT_TRUE(child->clipRectsCache()); 401 EXPECT_TRUE(child->clipRectsCache());
338 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root); 402 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root);
339 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root); 403 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root);
340 } 404 }
341 405
342 } // namespace blink 406 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698