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

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

Issue 2400783002: Reformat comments in core/layout/svg (Closed)
Patch Set: 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
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/layout/svg/LayoutSVGRoot.h" 5 #include "core/layout/svg/LayoutSVGRoot.h"
6 6
7 #include "core/layout/LayoutTestHelper.h" 7 #include "core/layout/LayoutTestHelper.h"
8 #include "core/layout/svg/LayoutSVGShape.h" 8 #include "core/layout/svg/LayoutSVGShape.h"
9 #include "core/layout/svg/SVGLayoutSupport.h" 9 #include "core/layout/svg/SVGLayoutSupport.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 using LayoutSVGRootTest = RenderingTest; 14 using LayoutSVGRootTest = RenderingTest;
15 15
16 TEST_F(LayoutSVGRootTest, OverflowRectMappingWithoutViewportClipWithBorder) { 16 TEST_F(LayoutSVGRootTest, OverflowRectMappingWithoutViewportClipWithBorder) {
17 setBodyInnerHTML( 17 setBodyInnerHTML(
18 "<svg id='root' style='border: 10px solid red; width: 200px; height: " 18 "<svg id='root' style='border: 10px solid red; width: 200px; height: "
19 "100px; overflow: visible' viewBox='0 0 200 100'>" 19 "100px; overflow: visible' viewBox='0 0 200 100'>"
20 " <rect id='rect' x='80' y='80' width='100' height='100'/>" 20 " <rect id='rect' x='80' y='80' width='100' height='100'/>"
21 "</svg>"); 21 "</svg>");
22 22
23 const LayoutSVGRoot* root = 23 const LayoutSVGRoot* root =
24 toLayoutSVGRoot(getLayoutObjectByElementId("root")); 24 toLayoutSVGRoot(getLayoutObjectByElementId("root"));
25 const LayoutSVGShape* svgRect = 25 const LayoutSVGShape* svgRect =
26 toLayoutSVGShape(getLayoutObjectByElementId("rect")); 26 toLayoutSVGShape(getLayoutObjectByElementId("rect"));
27 27
28 LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation( 28 LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(
29 *svgRect, *root); 29 *svgRect, *root);
30 // (80, 80, 100, 100) added by root's content rect offset from border rect, no t clipped. 30 // (80, 80, 100, 100) added by root's content rect offset from border rect,
31 // not clipped.
31 EXPECT_EQ(LayoutRect(90, 90, 100, 100), rect); 32 EXPECT_EQ(LayoutRect(90, 90, 100, 100), rect);
32 33
33 LayoutRect rootOverflowRect = static_cast<const LayoutObject*>(root) 34 LayoutRect rootOverflowRect = static_cast<const LayoutObject*>(root)
34 ->localOverflowRectForPaintInvalidation(); 35 ->localOverflowRectForPaintInvalidation();
35 // SVG root's overflow includes overflow from descendants. 36 // SVG root's overflow includes overflow from descendants.
36 EXPECT_EQ(LayoutRect(0, 0, 220, 190), rootOverflowRect); 37 EXPECT_EQ(LayoutRect(0, 0, 220, 190), rootOverflowRect);
37 38
38 rect = rootOverflowRect; 39 rect = rootOverflowRect;
39 EXPECT_TRUE(root->mapToVisualRectInAncestorSpace(root, rect)); 40 EXPECT_TRUE(root->mapToVisualRectInAncestorSpace(root, rect));
40 EXPECT_EQ(LayoutRect(0, 0, 220, 190), rect); 41 EXPECT_EQ(LayoutRect(0, 0, 220, 190), rect);
41 } 42 }
42 43
43 TEST_F(LayoutSVGRootTest, OverflowRectMappingWithViewportClipAndBorder) { 44 TEST_F(LayoutSVGRootTest, OverflowRectMappingWithViewportClipAndBorder) {
44 setBodyInnerHTML( 45 setBodyInnerHTML(
45 "<svg id='root' style='border: 10px solid red; width: 200px; height: " 46 "<svg id='root' style='border: 10px solid red; width: 200px; height: "
46 "100px; overflow: hidden' viewBox='0 0 200 100'>" 47 "100px; overflow: hidden' viewBox='0 0 200 100'>"
47 " <rect id='rect' x='80' y='80' width='100' height='100'/>" 48 " <rect id='rect' x='80' y='80' width='100' height='100'/>"
48 "</svg>"); 49 "</svg>");
49 50
50 const LayoutSVGRoot* root = 51 const LayoutSVGRoot* root =
51 toLayoutSVGRoot(getLayoutObjectByElementId("root")); 52 toLayoutSVGRoot(getLayoutObjectByElementId("root"));
52 const LayoutSVGShape* svgRect = 53 const LayoutSVGShape* svgRect =
53 toLayoutSVGShape(getLayoutObjectByElementId("rect")); 54 toLayoutSVGShape(getLayoutObjectByElementId("rect"));
54 55
55 LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation( 56 LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(
56 *svgRect, *root); 57 *svgRect, *root);
57 // (80, 80, 100, 100) added by root's content rect offset from border rect, cl ipped by (10, 10, 200, 100). 58 // (80, 80, 100, 100) added by root's content rect offset from border rect,
59 // clipped by (10, 10, 200, 100).
58 EXPECT_EQ(LayoutRect(90, 90, 100, 20), rect); 60 EXPECT_EQ(LayoutRect(90, 90, 100, 20), rect);
59 61
60 LayoutRect rootOverflowRect = static_cast<const LayoutObject*>(root) 62 LayoutRect rootOverflowRect = static_cast<const LayoutObject*>(root)
61 ->localOverflowRectForPaintInvalidation(); 63 ->localOverflowRectForPaintInvalidation();
62 // SVG root with overflow:hidden doesn't include overflow from children, just border box rect. 64 // SVG root with overflow:hidden doesn't include overflow from children, just
65 // border box rect.
63 EXPECT_EQ(LayoutRect(0, 0, 220, 120), rootOverflowRect); 66 EXPECT_EQ(LayoutRect(0, 0, 220, 120), rootOverflowRect);
64 67
65 rect = rootOverflowRect; 68 rect = rootOverflowRect;
66 EXPECT_TRUE(root->mapToVisualRectInAncestorSpace(root, rect)); 69 EXPECT_TRUE(root->mapToVisualRectInAncestorSpace(root, rect));
67 // LayoutSVGRoot should not apply overflow clip on its own rect. 70 // LayoutSVGRoot should not apply overflow clip on its own rect.
68 EXPECT_EQ(LayoutRect(0, 0, 220, 120), rect); 71 EXPECT_EQ(LayoutRect(0, 0, 220, 120), rect);
69 } 72 }
70 73
71 TEST_F(LayoutSVGRootTest, OverflowRectMappingWithViewportClipWithoutBorder) { 74 TEST_F(LayoutSVGRootTest, OverflowRectMappingWithViewportClipWithoutBorder) {
72 setBodyInnerHTML( 75 setBodyInnerHTML(
73 "<svg id='root' style='width: 200px; height: 100px; overflow: hidden' " 76 "<svg id='root' style='width: 200px; height: 100px; overflow: hidden' "
74 "viewBox='0 0 200 100'>" 77 "viewBox='0 0 200 100'>"
75 " <rect id='rect' x='80' y='80' width='100' height='100'/>" 78 " <rect id='rect' x='80' y='80' width='100' height='100'/>"
76 "</svg>"); 79 "</svg>");
77 80
78 const LayoutSVGRoot* root = 81 const LayoutSVGRoot* root =
79 toLayoutSVGRoot(getLayoutObjectByElementId("root")); 82 toLayoutSVGRoot(getLayoutObjectByElementId("root"));
80 const LayoutSVGShape* svgRect = 83 const LayoutSVGShape* svgRect =
81 toLayoutSVGShape(getLayoutObjectByElementId("rect")); 84 toLayoutSVGShape(getLayoutObjectByElementId("rect"));
82 85
83 LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation( 86 LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(
84 *svgRect, *root); 87 *svgRect, *root);
85 // (80, 80, 100, 100) clipped by (0, 0, 200, 100). 88 // (80, 80, 100, 100) clipped by (0, 0, 200, 100).
86 EXPECT_EQ(LayoutRect(80, 80, 100, 20), rect); 89 EXPECT_EQ(LayoutRect(80, 80, 100, 20), rect);
87 90
88 LayoutRect rootOverflowRect = static_cast<const LayoutObject*>(root) 91 LayoutRect rootOverflowRect = static_cast<const LayoutObject*>(root)
89 ->localOverflowRectForPaintInvalidation(); 92 ->localOverflowRectForPaintInvalidation();
90 // SVG root doesn't have box decoration background, so just use clipped overfl ow of children. 93 // SVG root doesn't have box decoration background, so just use clipped
94 // overflow of children.
91 EXPECT_EQ(LayoutRect(80, 80, 100, 20), rootOverflowRect); 95 EXPECT_EQ(LayoutRect(80, 80, 100, 20), rootOverflowRect);
92 96
93 rect = rootOverflowRect; 97 rect = rootOverflowRect;
94 EXPECT_TRUE(root->mapToVisualRectInAncestorSpace(root, rect)); 98 EXPECT_TRUE(root->mapToVisualRectInAncestorSpace(root, rect));
95 EXPECT_EQ(LayoutRect(80, 80, 100, 20), rect); 99 EXPECT_EQ(LayoutRect(80, 80, 100, 20), rect);
96 } 100 }
97 101
98 } // namespace blink 102 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698