WebCore:
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2007 06:31:28 +0000 (06:31 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2007 06:31:28 +0000 (06:31 +0000)
        Reviewed by Oliver.

        Fix for <rdar://problem/5616052> SVGs with width or height of 100%
        hang when used as a background-image (16164)

        * platform/graphics/svg/SVGImage.cpp:
        (WebCore::SVGImage::size): Use valueAsPercentage() for percents
        instead of valueInSpecifiedUnits(). valueInSpecifiedUnits()
        returns, for example, 50 for 50%, so multiplying percentages by the
        default size of 300 x 150 led to ridiculously huge dimensions for
        SVG images, and the subsequent hang.

LayoutTests:

        Reviewed by Oliver.

        Test for <rdar://problem/5616052> SVGs with width or height of 100%
        hang when used as a background-image (16164)

        * fast/images/resources/width-100-percent.svg: Added.
        * fast/images/svg-width-100p-as-background.html: Added.
        * platform/mac/fast/images/svg-width-100p-as-background-expected.checksum: Added.
        * platform/mac/fast/images/svg-width-100p-as-background-expected.png: Added.
        * platform/mac/fast/images/svg-width-100p-as-background-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28102 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/images/resources/width-100-percent.svg [new file with mode: 0644]
LayoutTests/fast/images/svg-width-100p-as-background.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/images/svg-width-100p-as-background-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/images/svg-width-100p-as-background-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/images/svg-width-100p-as-background-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/platform/graphics/svg/SVGImage.cpp

index 5e1e1f4826931e082d8fb93892018c5fe6e8b06b..7400730483caa279d9b9aabd9fdf97540d17fd40 100644 (file)
@@ -1,3 +1,16 @@
+2007-11-27  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Oliver.
+
+        Test for <rdar://problem/5616052> SVGs with width or height of 100% 
+        hang when used as a background-image (16164)
+
+        * fast/images/resources/width-100-percent.svg: Added.
+        * fast/images/svg-width-100p-as-background.html: Added.
+        * platform/mac/fast/images/svg-width-100p-as-background-expected.checksum: Added.
+        * platform/mac/fast/images/svg-width-100p-as-background-expected.png: Added.
+        * platform/mac/fast/images/svg-width-100p-as-background-expected.txt: Added.
+
 2007-11-27  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Kevin McCullough.
diff --git a/LayoutTests/fast/images/resources/width-100-percent.svg b/LayoutTests/fast/images/resources/width-100-percent.svg
new file mode 100644 (file)
index 0000000..7acf359
--- /dev/null
@@ -0,0 +1,4 @@
+<svg width="100%" height="100%"
+       xmlns="http://www.w3.org/2000/svg"
+     xmlns:xlink="http://www.w3.org/1999/xlink">
+</svg>
diff --git a/LayoutTests/fast/images/svg-width-100p-as-background.html b/LayoutTests/fast/images/svg-width-100p-as-background.html
new file mode 100644 (file)
index 0000000..a19e620
--- /dev/null
@@ -0,0 +1,16 @@
+<html>
+<head>
+<style>
+div {
+  background: red;
+  background-repeat: no-repeat;
+  background-image: url(resources/width-100-percent.svg);
+  height: 600px;
+  width: 800px;
+}
+</style>
+</head>
+<body style='margin: 0px'>
+<div>&nbsp;</div>
+</body>
+</html>
diff --git a/LayoutTests/platform/mac/fast/images/svg-width-100p-as-background-expected.checksum b/LayoutTests/platform/mac/fast/images/svg-width-100p-as-background-expected.checksum
new file mode 100644 (file)
index 0000000..9920a44
--- /dev/null
@@ -0,0 +1 @@
+483a463f69d2fd454249a4813d925c6c
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/images/svg-width-100p-as-background-expected.png b/LayoutTests/platform/mac/fast/images/svg-width-100p-as-background-expected.png
new file mode 100644 (file)
index 0000000..5eaa72b
Binary files /dev/null and b/LayoutTests/platform/mac/fast/images/svg-width-100p-as-background-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/images/svg-width-100p-as-background-expected.txt b/LayoutTests/platform/mac/fast/images/svg-width-100p-as-background-expected.txt
new file mode 100644 (file)
index 0000000..cb5e2a8
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (0,0) size 800x600
+      RenderBlock {DIV} at (0,0) size 800x600 [bgcolor=#FF0000]
+        RenderText {#text} at (0,0) size 4x18
+          text run at (0,0) width 4: " "
index b6a6835b0cea1e794c129b03855c53447c37fb84..ea1ffc052d65cef842e667a83b92e225d7424990 100644 (file)
@@ -1,3 +1,17 @@
+2007-11-27  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Oliver.
+
+        Fix for <rdar://problem/5616052> SVGs with width or height of 100% 
+        hang when used as a background-image (16164)
+
+        * platform/graphics/svg/SVGImage.cpp:
+        (WebCore::SVGImage::size): Use valueAsPercentage() for percents 
+        instead of valueInSpecifiedUnits(). valueInSpecifiedUnits() 
+        returns, for example, 50 for 50%, so multiplying percentages by the 
+        default size of 300 x 150 led to ridiculously huge dimensions for 
+        SVG images, and the subsequent hang. 
+
 2007-11-27  Jon Honeycutt  <jhoneycutt@apple.com>
 
         Reviewed by Adam.
index 03528d6d62b1a782a90ef5fe31ac097e774ed113..39425fc60909e53c74001474ad8ca977437d5801 100644 (file)
@@ -81,11 +81,11 @@ IntSize SVGImage::size() const
     
     IntSize svgSize;
     if (width.unitType() == LengthTypePercentage)
-        svgSize.setWidth(static_cast<int>(width.valueInSpecifiedUnits() * destSize.width()));
+        svgSize.setWidth(static_cast<int>(width.valueAsPercentage() * destSize.width()));
     else
         svgSize.setWidth(static_cast<int>(width.value()));
     if (height.unitType() == LengthTypePercentage)
-        svgSize.setHeight(static_cast<int>(height.valueInSpecifiedUnits() * destSize.height()));
+        svgSize.setHeight(static_cast<int>(height.valueAsPercentage() * destSize.height()));
     else
         svgSize.setHeight(static_cast<int>(height.value()));