| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 PaintLayer::GeometryMapperOption option = PaintLayer::kDoNotUseGeometryMapper; | 60 PaintLayer::GeometryMapperOption option = PaintLayer::kDoNotUseGeometryMapper; |
| 61 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) | 61 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) |
| 62 option = PaintLayer::kUseGeometryMapper; | 62 option = PaintLayer::kUseGeometryMapper; |
| 63 target_paint_layer->Clipper(option).CalculateRects( | 63 target_paint_layer->Clipper(option).CalculateRects( |
| 64 context, LayoutRect(LayoutRect::InfiniteIntRect()), layer_bounds, | 64 context, LayoutRect(LayoutRect::InfiniteIntRect()), layer_bounds, |
| 65 background_rect, foreground_rect); | 65 background_rect, foreground_rect); |
| 66 | 66 |
| 67 EXPECT_EQ(LayoutRect(FloatRect(8.25, 8.35, 200, 300)), | 67 EXPECT_EQ(LayoutRect(FloatRect(8.25, 8.35, 200, 300)), |
| 68 background_rect.Rect()); | 68 background_rect.Rect()); |
| 69 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) { | 69 EXPECT_EQ(LayoutRect(FloatRect(8.25, 8.35, 200, 300)), |
| 70 EXPECT_EQ(LayoutRect(FloatRect(8.25, 8.35, 199.75, 299.66)), | 70 foreground_rect.Rect()); |
| 71 foreground_rect.Rect()); | |
| 72 } else { | |
| 73 // TODO(chrishtr): this is off by 0.25px because | |
| 74 // LayoutSVGRoot::OverflowClipRect incorrectly does pixel-snapping. | |
| 75 EXPECT_EQ(LayoutRect(FloatRect(8, 8, 200, 300)), foreground_rect.Rect()); | |
| 76 } | |
| 77 EXPECT_EQ(LayoutRect(FloatRect(8.25, 8.35, 200, 300)), layer_bounds); | 71 EXPECT_EQ(LayoutRect(FloatRect(8.25, 8.35, 200, 300)), layer_bounds); |
| 78 } | 72 } |
| 79 | 73 |
| 80 TEST_P(PaintLayerClipperTest, ControlClip) { | 74 TEST_P(PaintLayerClipperTest, ControlClip) { |
| 81 SetBodyInnerHTML( | 75 SetBodyInnerHTML( |
| 82 "<!DOCTYPE html>" | 76 "<!DOCTYPE html>" |
| 83 "<input id=target style='position:absolute; width: 200px; height: 300px'" | 77 "<input id=target style='position:absolute; width: 200px; height: 300px'" |
| 84 " type=button>"); | 78 " type=button>"); |
| 85 Element* target = GetDocument().GetElementById("target"); | 79 Element* target = GetDocument().GetElementById("target"); |
| 86 PaintLayer* target_paint_layer = | 80 PaintLayer* target_paint_layer = |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 ClipRect background_rect(infinite_rect); | 506 ClipRect background_rect(infinite_rect); |
| 513 ClipRect foreground_rect(infinite_rect); | 507 ClipRect foreground_rect(infinite_rect); |
| 514 target->Clipper(option).CalculateRects(context, infinite_rect, layer_bounds, | 508 target->Clipper(option).CalculateRects(context, infinite_rect, layer_bounds, |
| 515 background_rect, foreground_rect); | 509 background_rect, foreground_rect); |
| 516 | 510 |
| 517 EXPECT_EQ(LayoutRect(-12, -9, 124, 224), background_rect.Rect()); | 511 EXPECT_EQ(LayoutRect(-12, -9, 124, 224), background_rect.Rect()); |
| 518 EXPECT_EQ(LayoutRect(0, 0, 100, 200), foreground_rect.Rect()); | 512 EXPECT_EQ(LayoutRect(0, 0, 100, 200), foreground_rect.Rect()); |
| 519 } | 513 } |
| 520 | 514 |
| 521 } // namespace blink | 515 } // namespace blink |
| OLD | NEW |