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

Side by Side Diff: third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp

Issue 2802443002: Compute rounded-ness of visual rects (Closed)
Patch Set: none Created 3 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/layout/LayoutTestHelper.h" 5 #include "core/layout/LayoutTestHelper.h"
6 #include "core/layout/LayoutView.h" 6 #include "core/layout/LayoutView.h"
7 #include "core/layout/PaintInvalidationState.h" 7 #include "core/layout/PaintInvalidationState.h"
8 #include "core/paint/PaintLayer.h" 8 #include "core/paint/PaintLayer.h"
9 #include "core/paint/PaintPropertyTreePrinter.h" 9 #include "core/paint/PaintPropertyTreePrinter.h"
10 #include "platform/graphics/paint/GeometryMapper.h" 10 #include "platform/graphics/paint/GeometryMapper.h"
(...skipping 23 matching lines...) Expand all
34 void checkVisualRect(const LayoutObject& object, 34 void checkVisualRect(const LayoutObject& object,
35 const LayoutBoxModelObject& ancestor, 35 const LayoutBoxModelObject& ancestor,
36 const LayoutRect& localRect, 36 const LayoutRect& localRect,
37 const LayoutRect& expectedVisualRect, 37 const LayoutRect& expectedVisualRect,
38 bool adjustForBacking = false) { 38 bool adjustForBacking = false) {
39 LayoutRect slowMapRect = localRect; 39 LayoutRect slowMapRect = localRect;
40 object.mapToVisualRectInAncestorSpace(&ancestor, slowMapRect); 40 object.mapToVisualRectInAncestorSpace(&ancestor, slowMapRect);
41 if (slowMapRect.isEmpty() && object.visualRect().isEmpty()) 41 if (slowMapRect.isEmpty() && object.visualRect().isEmpty())
42 return; 42 return;
43 43
44 FloatRect geometryMapperRect(localRect); 44 FloatClipRect geometryMapperRect((FloatRect(localRect)));
45 if (object.paintProperties() || object.localBorderBoxProperties()) { 45 if (object.paintProperties() || object.localBorderBoxProperties()) {
46 geometryMapperRect.moveBy(FloatPoint(object.paintOffset())); 46 geometryMapperRect.moveBy(FloatPoint(object.paintOffset()));
47 GeometryMapper::sourceToDestinationVisualRect( 47 GeometryMapper::sourceToDestinationVisualRect(
48 *object.localBorderBoxProperties(), *ancestor.contentsProperties(), 48 *object.localBorderBoxProperties(), *ancestor.contentsProperties(),
49 geometryMapperRect); 49 geometryMapperRect);
50 geometryMapperRect.moveBy(-FloatPoint(ancestor.paintOffset())); 50 geometryMapperRect.moveBy(-FloatPoint(ancestor.paintOffset()));
51 } 51 }
52 52
53 // The following condition can be false if paintInvalidationContainer is 53 // The following condition can be false if paintInvalidationContainer is
54 // a LayoutView and compositing is not enabled. 54 // a LayoutView and compositing is not enabled.
55 if (adjustForBacking && ancestor.isPaintInvalidationContainer()) { 55 if (adjustForBacking && ancestor.isPaintInvalidationContainer()) {
56 PaintLayer::mapRectInPaintInvalidationContainerToBacking(ancestor, 56 PaintLayer::mapRectInPaintInvalidationContainerToBacking(ancestor,
57 slowMapRect); 57 slowMapRect);
58 LayoutRect temp(geometryMapperRect); 58 LayoutRect temp(geometryMapperRect.rect());
59 PaintLayer::mapRectInPaintInvalidationContainerToBacking(ancestor, temp); 59 PaintLayer::mapRectInPaintInvalidationContainerToBacking(ancestor, temp);
60 geometryMapperRect = FloatRect(temp); 60 geometryMapperRect.setRect(FloatRect(temp));
61 } 61 }
62 EXPECT_TRUE(enclosingIntRect(slowMapRect) 62 EXPECT_TRUE(enclosingIntRect(slowMapRect)
63 .contains(enclosingIntRect(expectedVisualRect))); 63 .contains(enclosingIntRect(expectedVisualRect)));
64 64
65 if (object.paintProperties()) { 65 if (object.paintProperties()) {
66 EXPECT_TRUE(enclosingIntRect(geometryMapperRect) 66 EXPECT_TRUE(enclosingIntRect(geometryMapperRect.rect())
67 .contains(enclosingIntRect(expectedVisualRect))); 67 .contains(enclosingIntRect(expectedVisualRect)));
68 } 68 }
69 } 69 }
70 }; 70 };
71 71
72 TEST_F(VisualRectMappingTest, LayoutText) { 72 TEST_F(VisualRectMappingTest, LayoutText) {
73 setBodyInnerHTML( 73 setBodyInnerHTML(
74 "<style>body { margin: 0; }</style>" 74 "<style>body { margin: 0; }</style>"
75 "<div id='container' style='overflow: scroll; width: 50px; height: 50px'>" 75 "<div id='container' style='overflow: scroll; width: 50px; height: 50px'>"
76 " <span><img style='width: 20px; height: 100px'></span>" 76 " <span><img style='width: 20px; height: 100px'></span>"
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 // getTransformfromContainter includes transform and perspective matrix 824 // getTransformfromContainter includes transform and perspective matrix
825 // of the container. 825 // of the container.
826 target->getTransformFromContainer(container, LayoutSize(), targetMatrix); 826 target->getTransformFromContainer(container, LayoutSize(), targetMatrix);
827 matrix *= targetMatrix; 827 matrix *= targetMatrix;
828 LayoutRect output(matrix.mapRect(FloatRect(originalRect))); 828 LayoutRect output(matrix.mapRect(FloatRect(originalRect)));
829 829
830 checkVisualRect(*target, *target->view(), originalRect, output); 830 checkVisualRect(*target, *target->view(), originalRect, output);
831 } 831 }
832 832
833 } // namespace blink 833 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698