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

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

Issue 2400063002: Don't clip contain:paint when requested to ignore clip (Closed)
Patch Set: Rebase Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 LayoutRect layerBounds; 54 LayoutRect layerBounds;
55 ClipRect backgroundRect, foregroundRect; 55 ClipRect backgroundRect, foregroundRect;
56 targetPaintLayer->clipper().calculateRects( 56 targetPaintLayer->clipper().calculateRects(
57 context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds, 57 context, LayoutRect(LayoutRect::infiniteIntRect()), layerBounds,
58 backgroundRect, foregroundRect); 58 backgroundRect, foregroundRect);
59 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect()); 59 EXPECT_EQ(LayoutRect(8, 8, 200, 300), backgroundRect.rect());
60 EXPECT_EQ(LayoutRect(8, 8, 200, 300), foregroundRect.rect()); 60 EXPECT_EQ(LayoutRect(8, 8, 200, 300), foregroundRect.rect());
61 EXPECT_EQ(LayoutRect(8, 8, 400, 0), layerBounds); 61 EXPECT_EQ(LayoutRect(8, 8, 400, 0), layerBounds);
62 } 62 }
63 63
64 TEST_F(PaintLayerClipperTest, ContainPaintClip) {
65 setBodyInnerHTML(
66 "<div id='target'"
67 " style='contain: paint; width: 200px; height: 200px; overflow: auto'>"
68 " <div style='height: 400px'></div>"
69 "</div>");
70
71 LayoutRect infiniteRect(LayoutRect::infiniteIntRect());
72 PaintLayer* layer =
73 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer();
74 ClipRectsContext context(layer, PaintingClipRectsIgnoringOverflowClip);
75 LayoutRect layerBounds;
76 ClipRect backgroundRect, foregroundRect;
77 layer->clipper().calculateRects(context, infiniteRect, layerBounds,
78 backgroundRect, foregroundRect);
79 EXPECT_EQ(infiniteRect, backgroundRect.rect());
80 EXPECT_EQ(infiniteRect, foregroundRect.rect());
81 EXPECT_EQ(LayoutRect(0, 0, 200, 200), layerBounds);
82
83 ClipRectsContext contextClip(layer, PaintingClipRects);
84 layer->clipper().calculateRects(contextClip, infiniteRect, layerBounds,
85 backgroundRect, foregroundRect);
86 EXPECT_EQ(LayoutRect(0, 0, 200, 200), backgroundRect.rect());
87 EXPECT_EQ(LayoutRect(0, 0, 200, 200), foregroundRect.rect());
88 EXPECT_EQ(LayoutRect(0, 0, 200, 200), layerBounds);
89 }
90
91 TEST_F(PaintLayerClipperTest, NestedContainPaintClip) {
92 setBodyInnerHTML(
93 "<div style='contain: paint; width: 200px; height: 200px; overflow: "
94 "auto'>"
95 " <div id='target' style='contain: paint; height: 400px'>"
96 " </div>"
97 "</div>");
98
99 LayoutRect infiniteRect(LayoutRect::infiniteIntRect());
100 PaintLayer* layer =
101 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer();
102 ClipRectsContext context(layer->parent(),
103 PaintingClipRectsIgnoringOverflowClip);
104 LayoutRect layerBounds;
105 ClipRect backgroundRect, foregroundRect;
106 layer->clipper().calculateRects(context, infiniteRect, layerBounds,
107 backgroundRect, foregroundRect);
108 EXPECT_EQ(LayoutRect(0, 0, 200, 400), backgroundRect.rect());
109 EXPECT_EQ(LayoutRect(0, 0, 200, 400), foregroundRect.rect());
110 EXPECT_EQ(LayoutRect(0, 0, 200, 400), layerBounds);
111
112 ClipRectsContext contextClip(layer->parent(), PaintingClipRects);
113 layer->clipper().calculateRects(contextClip, infiniteRect, layerBounds,
114 backgroundRect, foregroundRect);
115 EXPECT_EQ(LayoutRect(0, 0, 200, 200), backgroundRect.rect());
116 EXPECT_EQ(LayoutRect(0, 0, 200, 200), foregroundRect.rect());
117 EXPECT_EQ(LayoutRect(0, 0, 200, 400), layerBounds);
118 }
119
64 } // namespace blink 120 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698