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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 ->layer(); | 137 ->layer(); |
138 PaintLayer* fixed = | 138 PaintLayer* fixed = |
139 toLayoutBoxModelObject(getLayoutObjectByElementId("fixed"))->layer(); | 139 toLayoutBoxModelObject(getLayoutObjectByElementId("fixed"))->layer(); |
140 | 140 |
141 EXPECT_EQ(LayoutRect(0, 0, 100, 100), | 141 EXPECT_EQ(LayoutRect(0, 0, 100, 100), |
142 transformed->clipper().localClipRect(transformed)); | 142 transformed->clipper().localClipRect(transformed)); |
143 EXPECT_EQ(LayoutRect(0, 50, 100, 100), | 143 EXPECT_EQ(LayoutRect(0, 50, 100, 100), |
144 fixed->clipper().localClipRect(transformed)); | 144 fixed->clipper().localClipRect(transformed)); |
145 } | 145 } |
146 | 146 |
| 147 TEST_F(PaintLayerClipperTest, ClearClipRectsRecursive) { |
| 148 setBodyInnerHTML( |
| 149 "<style>" |
| 150 "div { " |
| 151 " width: 5px; height: 5px; background: blue;" |
| 152 " position: relative;" |
| 153 "}" |
| 154 "</style>" |
| 155 "<div id='parent'>" |
| 156 " <div id='child'>" |
| 157 " <div id='grandchild'></div>" |
| 158 " </div>" |
| 159 "</div>"); |
| 160 |
| 161 PaintLayer* parent = |
| 162 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); |
| 163 PaintLayer* child = |
| 164 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); |
| 165 |
| 166 EXPECT_TRUE(parent->clipRectsCache()); |
| 167 EXPECT_TRUE(child->clipRectsCache()); |
| 168 |
| 169 parent->clipper().clearClipRectsIncludingDescendants(); |
| 170 |
| 171 EXPECT_FALSE(parent->clipRectsCache()); |
| 172 EXPECT_FALSE(child->clipRectsCache()); |
| 173 } |
| 174 |
| 175 TEST_F(PaintLayerClipperTest, ClearClipRectsRecursiveChild) { |
| 176 setBodyInnerHTML( |
| 177 "<style>" |
| 178 "div { " |
| 179 " width: 5px; height: 5px; background: blue;" |
| 180 " position: relative;" |
| 181 "}" |
| 182 "</style>" |
| 183 "<div id='parent'>" |
| 184 " <div id='child'>" |
| 185 " <div id='grandchild'></div>" |
| 186 " </div>" |
| 187 "</div>"); |
| 188 |
| 189 PaintLayer* parent = |
| 190 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); |
| 191 PaintLayer* child = |
| 192 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); |
| 193 |
| 194 EXPECT_TRUE(parent->clipRectsCache()); |
| 195 EXPECT_TRUE(child->clipRectsCache()); |
| 196 |
| 197 child->clipper().clearClipRectsIncludingDescendants(); |
| 198 |
| 199 EXPECT_TRUE(parent->clipRectsCache()); |
| 200 EXPECT_FALSE(child->clipRectsCache()); |
| 201 } |
| 202 |
| 203 TEST_F(PaintLayerClipperTest, ClearClipRectsRecursiveOneType) { |
| 204 setBodyInnerHTML( |
| 205 "<style>" |
| 206 "div { " |
| 207 " width: 5px; height: 5px; background: blue;" |
| 208 " position: relative;" |
| 209 "}" |
| 210 "</style>" |
| 211 "<div id='parent'>" |
| 212 " <div id='child'>" |
| 213 " <div id='grandchild'></div>" |
| 214 " </div>" |
| 215 "</div>"); |
| 216 |
| 217 PaintLayer* parent = |
| 218 toLayoutBoxModelObject(getLayoutObjectByElementId("parent"))->layer(); |
| 219 PaintLayer* child = |
| 220 toLayoutBoxModelObject(getLayoutObjectByElementId("child"))->layer(); |
| 221 |
| 222 EXPECT_TRUE(parent->clipRectsCache()); |
| 223 EXPECT_TRUE(child->clipRectsCache()); |
| 224 EXPECT_TRUE(parent->clipRectsCache()->get(AbsoluteClipRects).root); |
| 225 EXPECT_TRUE(child->clipRectsCache()->get(AbsoluteClipRects).root); |
| 226 |
| 227 parent->clipper().clearClipRectsIncludingDescendants(AbsoluteClipRects); |
| 228 |
| 229 EXPECT_TRUE(parent->clipRectsCache()); |
| 230 EXPECT_TRUE(child->clipRectsCache()); |
| 231 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root); |
| 232 EXPECT_FALSE(parent->clipRectsCache()->get(AbsoluteClipRects).root); |
| 233 } |
| 234 |
147 } // namespace blink | 235 } // namespace blink |
OLD | NEW |