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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/svg/LayoutSVGRootTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGRootTest.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGRootTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ae076ae899e7270515f5694955de6502371cf8dc
--- /dev/null
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGRootTest.cpp
@@ -0,0 +1,86 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/layout/svg/LayoutSVGRoot.h"
+
+#include "core/layout/LayoutTestHelper.h"
+#include "core/layout/svg/LayoutSVGShape.h"
+#include "core/layout/svg/SVGLayoutSupport.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+using LayoutSVGRootTest = RenderingTest;
+
+TEST_F(LayoutSVGRootTest, OverflowRectMappingWithoutViewportClipWithBorder)
+{
+ setBodyInnerHTML(
+ "<svg id='root' style='border: 10px solid red; width: 200px; height: 100px; overflow: visible' viewBox='0 0 200 100'>"
+ " <rect id='rect' x='80' y='80' width='100' height='100'/>"
+ "</svg>");
+
+ const LayoutSVGRoot* root = toLayoutSVGRoot(getLayoutObjectByElementId("root"));
+ const LayoutSVGShape* svgRect = toLayoutSVGShape(getLayoutObjectByElementId("rect"));
+
+ LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(*svgRect, *root);
+ // (80, 80, 100, 100) added by root's content rect offset from border rect, not clipped.
+ EXPECT_EQ(LayoutRect(90, 90, 100, 100), rect);
+
+ LayoutRect rootOverflowRect = static_cast<const LayoutObject*>(root)->localOverflowRectForPaintInvalidation();
+ // SVG root's overflow includes overflow from descendants.
+ EXPECT_EQ(LayoutRect(0, 0, 220, 190), rootOverflowRect);
+
+ rect = rootOverflowRect;
+ EXPECT_TRUE(root->mapToVisualRectInAncestorSpace(root, rect));
+ EXPECT_EQ(LayoutRect(0, 0, 220, 190), rect);
+}
+
+TEST_F(LayoutSVGRootTest, OverflowRectMappingWithViewportClipAndBorder)
+{
+ setBodyInnerHTML(
+ "<svg id='root' style='border: 10px solid red; width: 200px; height: 100px; overflow: hidden' viewBox='0 0 200 100'>"
+ " <rect id='rect' x='80' y='80' width='100' height='100'/>"
+ "</svg>");
+
+ const LayoutSVGRoot* root = toLayoutSVGRoot(getLayoutObjectByElementId("root"));
+ const LayoutSVGShape* svgRect = toLayoutSVGShape(getLayoutObjectByElementId("rect"));
+
+ LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(*svgRect, *root);
+ // (80, 80, 100, 100) added by root's content rect offset from border rect, clipped by (10, 10, 200, 100).
+ EXPECT_EQ(LayoutRect(90, 90, 100, 30), rect);
+
+ LayoutRect rootOverflowRect = static_cast<const LayoutObject*>(root)->localOverflowRectForPaintInvalidation();
+ // SVG root with overflow:hidden doesn't include overflow from children, just border box rect.
+ EXPECT_EQ(LayoutRect(0, 0, 220, 120), rootOverflowRect);
+
+ rect = rootOverflowRect;
+ EXPECT_TRUE(root->mapToVisualRectInAncestorSpace(root, rect));
+ // LayoutSVGRoot should not apply overflow clip on its own rect.
+ EXPECT_EQ(LayoutRect(0, 0, 220, 120), rect);
+}
+
+TEST_F(LayoutSVGRootTest, OverflowRectMappingWithViewportClipWithoutBorder)
+{
+ setBodyInnerHTML(
+ "<svg id='root' style='width: 200px; height: 100px; overflow: hidden' viewBox='0 0 200 100'>"
+ " <rect id='rect' x='80' y='80' width='100' height='100'/>"
+ "</svg>");
+
+ const LayoutSVGRoot* root = toLayoutSVGRoot(getLayoutObjectByElementId("root"));
+ const LayoutSVGShape* svgRect = toLayoutSVGShape(getLayoutObjectByElementId("rect"));
+
+ LayoutRect rect = SVGLayoutSupport::clippedOverflowRectForPaintInvalidation(*svgRect, *root);
+ // (80, 80, 100, 100) clipped by (0, 0, 200, 100).
+ EXPECT_EQ(LayoutRect(80, 80, 100, 20), rect);
+
+ LayoutRect rootOverflowRect = static_cast<const LayoutObject*>(root)->localOverflowRectForPaintInvalidation();
+ // SVG root doesn't have box decoration background, so just use clipped overflow of children.
+ EXPECT_EQ(LayoutRect(80, 80, 100, 20), rootOverflowRect);
+
+ rect = rootOverflowRect;
+ EXPECT_TRUE(root->mapToVisualRectInAncestorSpace(root, rect));
+ EXPECT_EQ(LayoutRect(80, 80, 100, 20), rect);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698