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

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

Issue 1852183002: Don't apply svg viewport clip when mapping a LayoutSVGRoot's own rect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CORE_EXPORT LayoutSVGRoot Created 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/layout/svg/LayoutSVGRoot.h"
6
7 #include "core/layout/LayoutTestHelper.h"
8 #include "core/layout/svg/LayoutSVGShape.h"
9 #include "core/layout/svg/SVGLayoutSupport.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace blink {
13
14 using LayoutSVGRootTest = RenderingTest;
15
16 TEST_F(LayoutSVGRootTest, OverflowRectMappingWithoutViewportClipWithBorder)
17 {
18 setBodyInnerHTML(
19 "<svg id='root' style='border: 10px solid red; width: 200px; height: 100 px; overflow: visible' viewBox='0 0 200 100'>"
20 " <rect id='rect' x='80' y='80' width='100' height='100'/>"
21 "</svg>");
22
23 const LayoutSVGRoot* root = toLayoutSVGRoot(getLayoutObjectByElementId("root "));
24 const LayoutSVGShape* svgRect = toLayoutSVGShape(getLayoutObjectByElementId( "rect"));
25
26 LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation( *svgRect, *root);
27 // (80, 80, 100, 100) added by root's content rect offset from border rect, not clipped.
28 EXPECT_EQ(LayoutRect(90, 90, 100, 100), rect);
29
30 LayoutRect rootOverflowRect = static_cast<const LayoutObject*>(root)->localO verflowRectForPaintInvalidation();
31 // SVG root's overflow includes overflow from descendants.
32 EXPECT_EQ(LayoutRect(0, 0, 220, 190), rootOverflowRect);
33
34 rect = rootOverflowRect;
35 EXPECT_TRUE(root->mapToVisualRectInAncestorSpace(root, rect));
36 EXPECT_EQ(LayoutRect(0, 0, 220, 190), rect);
37 }
38
39 TEST_F(LayoutSVGRootTest, OverflowRectMappingWithViewportClipAndBorder)
40 {
41 setBodyInnerHTML(
42 "<svg id='root' style='border: 10px solid red; width: 200px; height: 100 px; overflow: hidden' viewBox='0 0 200 100'>"
43 " <rect id='rect' x='80' y='80' width='100' height='100'/>"
44 "</svg>");
45
46 const LayoutSVGRoot* root = toLayoutSVGRoot(getLayoutObjectByElementId("root "));
47 const LayoutSVGShape* svgRect = toLayoutSVGShape(getLayoutObjectByElementId( "rect"));
48
49 LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation( *svgRect, *root);
50 // (80, 80, 100, 100) added by root's content rect offset from border rect, clipped by (10, 10, 200, 100).
51 EXPECT_EQ(LayoutRect(90, 90, 100, 30), rect);
52
53 LayoutRect rootOverflowRect = static_cast<const LayoutObject*>(root)->localO verflowRectForPaintInvalidation();
54 // SVG root with overflow:hidden doesn't include overflow from children, jus t border box rect.
55 EXPECT_EQ(LayoutRect(0, 0, 220, 120), rootOverflowRect);
56
57 rect = rootOverflowRect;
58 EXPECT_TRUE(root->mapToVisualRectInAncestorSpace(root, rect));
59 // LayoutSVGRoot should not apply overflow clip on its own rect.
60 EXPECT_EQ(LayoutRect(0, 0, 220, 120), rect);
61 }
62
63 TEST_F(LayoutSVGRootTest, OverflowRectMappingWithViewportClipWithoutBorder)
64 {
65 setBodyInnerHTML(
66 "<svg id='root' style='width: 200px; height: 100px; overflow: hidden' vi ewBox='0 0 200 100'>"
67 " <rect id='rect' x='80' y='80' width='100' height='100'/>"
68 "</svg>");
69
70 const LayoutSVGRoot* root = toLayoutSVGRoot(getLayoutObjectByElementId("root "));
71 const LayoutSVGShape* svgRect = toLayoutSVGShape(getLayoutObjectByElementId( "rect"));
72
73 LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation( *svgRect, *root);
74 // (80, 80, 100, 100) clipped by (0, 0, 200, 100).
75 EXPECT_EQ(LayoutRect(80, 80, 100, 20), rect);
76
77 LayoutRect rootOverflowRect = static_cast<const LayoutObject*>(root)->localO verflowRectForPaintInvalidation();
78 // SVG root doesn't have box decoration background, so just use clipped over flow of children.
79 EXPECT_EQ(LayoutRect(80, 80, 100, 20), rootOverflowRect);
80
81 rect = rootOverflowRect;
82 EXPECT_TRUE(root->mapToVisualRectInAncestorSpace(root, rect));
83 EXPECT_EQ(LayoutRect(80, 80, 100, 20), rect);
84 }
85
86 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698