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