- Revision
- 108559
- Author
- [email protected]
- Date
- 2012-02-22 15:17:46 -0800 (Wed, 22 Feb 2012)
Log Message
Paddings and borders on root SVG element with viewbox causes child SVG elements to be rendered with the incorrect size
https://bugs.webkit.org/show_bug.cgi?id=78613
Patch by Max Vujovic <[email protected]> on 2012-02-22
Reviewed by Nikolas Zimmermann.
Source/WebCore:
When computing its localToBorderBoxTransform, RenderSVGRoot was using its width and height
as the dimensions of the SVG viewport. However, width and height include CSS borders and
paddings, which are not part of the SVG viewport area. Now, RenderSVGRoot uses its
contentWidth and contentHeight, which correspond to the SVG viewport area.
Tests: svg/custom/svg-root-padding-border-margin-expected.html
svg/custom/svg-root-padding-border-margin.html
* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::buildLocalToBorderBoxTransform):
LayoutTests:
* platform/chromium/test_expectations.txt:
* platform/mac/svg/custom/circle-move-invalidation-expected.png:
* platform/mac/svg/custom/circle-move-invalidation-expected.txt:
This test contains a circle drawn inside a root SVG element with a 1px border. This bug
was causing WebKit to render the circle 1px too large, reflected in the expectations.
The expectations have been updated.
* svg/custom/svg-root-padding-border-margin-expected.html: Added.
* svg/custom/svg-root-padding-border-margin.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (108558 => 108559)
--- trunk/LayoutTests/ChangeLog 2012-02-22 23:15:29 UTC (rev 108558)
+++ trunk/LayoutTests/ChangeLog 2012-02-22 23:17:46 UTC (rev 108559)
@@ -1,3 +1,21 @@
+2012-02-22 Max Vujovic <[email protected]>
+
+ Paddings and borders on root SVG element with viewbox causes child SVG elements to be rendered with the incorrect size
+ https://bugs.webkit.org/show_bug.cgi?id=78613
+
+ Reviewed by Nikolas Zimmermann.
+
+ * platform/chromium/test_expectations.txt:
+ * platform/mac/svg/custom/circle-move-invalidation-expected.png:
+ * platform/mac/svg/custom/circle-move-invalidation-expected.txt:
+
+ This test contains a circle drawn inside a root SVG element with a 1px border. This bug
+ was causing WebKit to render the circle 1px too large, reflected in the expectations.
+ The expectations have been updated.
+
+ * svg/custom/svg-root-padding-border-margin-expected.html: Added.
+ * svg/custom/svg-root-padding-border-margin.html: Added.
+
2012-02-22 Tom Sepez <[email protected]>
XSSAuditor bypass with <svg> tags and html-entities.
Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (108558 => 108559)
--- trunk/LayoutTests/platform/chromium/test_expectations.txt 2012-02-22 23:15:29 UTC (rev 108558)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt 2012-02-22 23:17:46 UTC (rev 108559)
@@ -936,6 +936,9 @@
// New test requires rebaseline
BUGWK77535 : svg/repaint/inner-svg-change-viewPort-relative.svg = IMAGE IMAGE+TEXT
+// Updated test, needs a rebaseline
+BUGWK78613 : svg/custom/circle-move-invalidation.svg = IMAGE IMAGE+TEXT
+
// New test, needs a rebaseline
BUGWK77903 : svg/repaint/inner-svg-change-viewBox-contract.svg = IMAGE IMAGE+TEXT
Modified: trunk/LayoutTests/platform/mac/svg/custom/circle-move-invalidation-expected.png
(Binary files differ)
Modified: trunk/LayoutTests/platform/mac/svg/custom/circle-move-invalidation-expected.txt (108558 => 108559)
--- trunk/LayoutTests/platform/mac/svg/custom/circle-move-invalidation-expected.txt 2012-02-22 23:15:29 UTC (rev 108558)
+++ trunk/LayoutTests/platform/mac/svg/custom/circle-move-invalidation-expected.txt 2012-02-22 23:17:46 UTC (rev 108559)
@@ -4,8 +4,8 @@
RenderBlock {html} at (0,0) size 800x356
RenderBody {body} at (8,8) size 784x340
RenderBlock (anonymous) at (0,0) size 784x306
- RenderSVGRoot {svg} at (196,196) size 79x79
- RenderSVGPath {circle} at (197,197) size 77x77 [fill={[type=SOLID] [color=#FF0000]}] [cx=300.00] [cy=300.00] [r=50.00]
+ RenderSVGRoot {svg} at (195,195) size 78x78
+ RenderSVGPath {circle} at (196,196) size 76x76 [fill={[type=SOLID] [color=#FF0000]}] [cx=300.00] [cy=300.00] [r=50.00]
RenderText {#text} at (302,288) size 4x18
text run at (302,288) width 4: " "
RenderBR {br} at (306,288) size 0x18
Added: trunk/LayoutTests/svg/custom/svg-root-padding-border-margin-expected.html (0 => 108559)
--- trunk/LayoutTests/svg/custom/svg-root-padding-border-margin-expected.html (rev 0)
+++ trunk/LayoutTests/svg/custom/svg-root-padding-border-margin-expected.html 2012-02-22 23:17:46 UTC (rev 108559)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <style>
+ #parentDiv {
+ width: 400px;
+ height: 400px;
+ padding: 15px;
+ border: 10px solid grey;
+ margin: 5px;
+ float: left; /* Do not collapse margins. */
+ background-color: blue;
+ }
+
+ #svgRoot {
+ background-color: blue;
+ }
+ </style>
+ </head>
+ <body>
+ <p>This test checks that SVG elements are rendered with the correct dimensions under an SVG root element with paddings, borders, and margins.</p>
+ <div id="parentDiv">
+ <svg id="svgRoot" width="400" height="400" viewbox="0 0 200 200">
+ <rect id="svgRect" x="0" y="0" width="100" height="100" fill="green"/>
+ </svg>
+ </div>
+ </body>
+</html>
Added: trunk/LayoutTests/svg/custom/svg-root-padding-border-margin.html (0 => 108559)
--- trunk/LayoutTests/svg/custom/svg-root-padding-border-margin.html (rev 0)
+++ trunk/LayoutTests/svg/custom/svg-root-padding-border-margin.html 2012-02-22 23:17:46 UTC (rev 108559)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <style>
+ #svgRoot {
+ padding: 15px;
+ border: 10px solid grey;
+ margin: 5px;
+ background-color: blue;
+ }
+ </style>
+ </head>
+ <body>
+ <p>This test checks that SVG elements are rendered with the correct dimensions under an SVG root element with paddings, borders, and margins.</p>
+ <svg id="svgRoot" width="400" height="400" viewbox="0 0 200 200">
+ <rect id="svgRect" x="0" y="0" width="100" height="100" fill="green"/>
+ </svg>
+ </body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (108558 => 108559)
--- trunk/Source/WebCore/ChangeLog 2012-02-22 23:15:29 UTC (rev 108558)
+++ trunk/Source/WebCore/ChangeLog 2012-02-22 23:17:46 UTC (rev 108559)
@@ -1,3 +1,21 @@
+2012-02-22 Max Vujovic <[email protected]>
+
+ Paddings and borders on root SVG element with viewbox causes child SVG elements to be rendered with the incorrect size
+ https://bugs.webkit.org/show_bug.cgi?id=78613
+
+ Reviewed by Nikolas Zimmermann.
+
+ When computing its localToBorderBoxTransform, RenderSVGRoot was using its width and height
+ as the dimensions of the SVG viewport. However, width and height include CSS borders and
+ paddings, which are not part of the SVG viewport area. Now, RenderSVGRoot uses its
+ contentWidth and contentHeight, which correspond to the SVG viewport area.
+
+ Tests: svg/custom/svg-root-padding-border-margin-expected.html
+ svg/custom/svg-root-padding-border-margin.html
+
+ * rendering/svg/RenderSVGRoot.cpp:
+ (WebCore::RenderSVGRoot::buildLocalToBorderBoxTransform):
+
2012-02-22 Raphael Kubo da Costa <[email protected]>
[EFL] Get rid of GeolocationServiceEfl
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp (108558 => 108559)
--- trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp 2012-02-22 23:15:29 UTC (rev 108558)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp 2012-02-22 23:17:46 UTC (rev 108559)
@@ -306,7 +306,7 @@
float scale = style()->effectiveZoom();
FloatPoint translate = svg->currentTranslate();
LayoutSize borderAndPadding(borderLeft() + paddingLeft(), borderTop() + paddingTop());
- m_localToBorderBoxTransform = svg->viewBoxToViewTransform(width() / scale, height() / scale);
+ m_localToBorderBoxTransform = svg->viewBoxToViewTransform(contentWidth() / scale, contentHeight() / scale);
if (borderAndPadding.isEmpty() && scale == 1 && translate == FloatPoint::zero())
return;
m_localToBorderBoxTransform = AffineTransform(scale, 0, 0, scale, borderAndPadding.width() + translate.x(), borderAndPadding.height() + translate.y()) * m_localToBorderBoxTransform;