Fix 'slice' aspect ratio calculation
authorpdr@google.com <pdr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Feb 2013 23:04:34 +0000 (23:04 +0000)
committerpdr@google.com <pdr@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Feb 2013 23:04:34 +0000 (23:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=99984

Patch by Branimir Lambov <blambov@google.com> on 2013-02-19
Reviewed by Dirk Schulze.

Source/WebCore:

Previously the calculation for the 'slice' aspect ratio would incorrectly calculate the
source rect location based on the destination rect offset. This caused our source rect to be
incorrect, and sometimes render outside the visible area completely. After this patch
our implementation matches the implementation of both Gecko and Presto.

The relevant spec section:
http://www.w3.org/TR/SVG/single-page.html#coords-PreserveAspectRatioAttribute

Tests: svg/as-image/image-preserveAspectRatio-all.svg
       svg/filters/feImage-preserveAspectRatio-all.svg

* svg/SVGPreserveAspectRatio.cpp:
(WebCore::SVGPreserveAspectRatio::transformRect):

LayoutTests:

* platform/chromium/TestExpectations:
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt/TestExpectations:
* svg/as-image/image-preserveAspectRatio-all-expected.png: Added.
* svg/as-image/image-preserveAspectRatio-all-expected.txt: Added.
* svg/as-image/image-preserveAspectRatio-all.svg: Added.
* svg/filters/feImage-preserveAspectRatio-all-expected.png: Added.
* svg/filters/feImage-preserveAspectRatio-all-expected.txt: Added.
* svg/filters/feImage-preserveAspectRatio-all.svg: Added.

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

14 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium/TestExpectations
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/qt/TestExpectations
LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.png [new file with mode: 0644]
LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.txt [new file with mode: 0644]
LayoutTests/svg/as-image/image-preserveAspectRatio-all.svg [new file with mode: 0644]
LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.png [new file with mode: 0644]
LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.txt [new file with mode: 0644]
LayoutTests/svg/filters/feImage-preserveAspectRatio-all.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/svg/SVGPreserveAspectRatio.cpp

index 003494b..0e61598 100644 (file)
@@ -1,3 +1,22 @@
+2013-02-19  Branimir Lambov  <blambov@google.com>
+
+        Fix 'slice' aspect ratio calculation
+        https://bugs.webkit.org/show_bug.cgi?id=99984
+
+        Reviewed by Dirk Schulze.
+
+        * platform/chromium/TestExpectations:
+        * platform/efl/TestExpectations:
+        * platform/gtk/TestExpectations:
+        * platform/mac/TestExpectations:
+        * platform/qt/TestExpectations:
+        * svg/as-image/image-preserveAspectRatio-all-expected.png: Added.
+        * svg/as-image/image-preserveAspectRatio-all-expected.txt: Added.
+        * svg/as-image/image-preserveAspectRatio-all.svg: Added.
+        * svg/filters/feImage-preserveAspectRatio-all-expected.png: Added.
+        * svg/filters/feImage-preserveAspectRatio-all-expected.txt: Added.
+        * svg/filters/feImage-preserveAspectRatio-all.svg: Added.
+
 2013-02-19  Stephen Chenney  <schenney@chromium.org>
 
         [Chromium] Test Expectations to reflect flakey calendar tests.
index 8794585..6efad50 100644 (file)
@@ -1383,6 +1383,12 @@ webkit.org/b/101396 svg/custom/simple-text-double-shadow.svg
 webkit.org/b/101396 svg/css/clippath-with-shadow.svg
 webkit.org/b/101396 svg/css/arrow-with-shadow.svg
 
+# These tests need to be rebaselined after https://bugs.webkit.org/show_bug.cgi?id=99984
+webkit.org/b/99984 svg/as-image/image-preserveAspectRatio-all.svg [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/filters/feImage-preserveAspectRatio-all.svg [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/dynamic-updates/SVGFEImageElement-dom-preserveAspectRatio-attr.html [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/dynamic-updates/SVGFEImageElement-svgdom-preserveAspectRatio-prop.html [ ImageOnlyFailure Pass ]
+
 # Need rebaseline after https://bugs.webkit.org/show_bug.cgi?id=109775
 webkit.org/b/109775 [ Win Mac ] media/audio-controls-rendering.html [ Failure ]
 webkit.org/b/109775 [ Lion MountainLion Win7 ] media/controls-after-reload.html [ Failure ]
index cfe7df6..01d8141 100644 (file)
@@ -590,6 +590,12 @@ webkit.org/b/98895 perf/accessibility-title-ui-element.html [ Skip ]
 # not SKIP, just WONTFIX.
 webkit.org/b/66218 fast/harness/sample-fail-mismatch-reftest.html [ WontFix ImageOnlyFailure ]
 
+# These tests need to be rebaselined after https://bugs.webkit.org/show_bug.cgi?id=99984
+webkit.org/b/99984 svg/as-image/image-preserveAspectRatio-all.svg [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/filters/feImage-preserveAspectRatio-all.svg [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/dynamic-updates/SVGFEImageElement-dom-preserveAspectRatio-attr.html [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/dynamic-updates/SVGFEImageElement-svgdom-preserveAspectRatio-prop.html [ ImageOnlyFailure Pass ]
+
 # Need rebaseline after https://bugs.webkit.org/show_bug.cgi?id=105437
 webkit.org/b/105437 svg/W3C-SVG-1.1-SE/filters-image-03-f.svg [ ImageOnlyFailure Pass ]
 webkit.org/b/105437 svg/W3C-SVG-1.1-SE/filters-image-05-f.svg [ ImageOnlyFailure Pass ]
index 0586730..d1895b3 100644 (file)
@@ -75,6 +75,12 @@ webkit.org/b/107567 tables/mozilla/bugs/bug1188.html [ Failure ]
 webkit.org/b/107567 editing/selection/extend-by-sentence-001.html [ Failure ] 
 webkit.org/b/107567 svg/carto.net/combobox.svg [ Failure ] 
 
+# These tests need to be rebaselined after https://bugs.webkit.org/show_bug.cgi?id=99984
+webkit.org/b/99984 svg/as-image/image-preserveAspectRatio-all.svg [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/filters/feImage-preserveAspectRatio-all.svg [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/dynamic-updates/SVGFEImageElement-dom-preserveAspectRatio-attr.html [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/dynamic-updates/SVGFEImageElement-svgdom-preserveAspectRatio-prop.html [ ImageOnlyFailure Pass ]
+
 # Rebaseline required after https://webkit.org/b/95772
 webkit.org/b/109209 fast/text/international/bidi-ignored-for-first-child-inline.html [ Failure ]
 
index 1b04530..4b932c1 100644 (file)
@@ -1240,6 +1240,12 @@ webkit.org/b/90951 fast/text/shaping
 webkit.org/b/101177 svg/dynamic-updates/SVGUseElement-dom-requiredFeatures.html [ ImageOnlyFailure Pass ]
 webkit.org/b/101177 svg/repaint/inner-svg-change-viewBox.svg [ ImageOnlyFailure Pass ]
 
+# These tests need to be rebaselined after https://bugs.webkit.org/show_bug.cgi?id=99984
+webkit.org/b/99984 svg/as-image/image-preserveAspectRatio-all.svg [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/filters/feImage-preserveAspectRatio-all.svg [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/dynamic-updates/SVGFEImageElement-dom-preserveAspectRatio-attr.html [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/dynamic-updates/SVGFEImageElement-svgdom-preserveAspectRatio-prop.html [ ImageOnlyFailure Pass ]
+
 # Needs rebaseline after bug https://bugs.webkit.org/show_bug.cgi?id=104462
 webkit.org/b/98687 fast/css-generated-content/table-row-group-to-inline.html [ Failure ]
 webkit.org/b/104595 fast/css/empty-generated-content.html [ Failure ]
index ef333b3..ac32d2b 100644 (file)
@@ -1374,6 +1374,12 @@ fast/regions/autoheight-singleregion-breakbeforealways-minheight.html
 # https://bugs.webkit.org/show_bug.cgi?id=92734
 svg/css/text-gradient-shadow.svg
 
+# These tests need to be rebaselined after https://bugs.webkit.org/show_bug.cgi?id=99984
+webkit.org/b/99984 svg/as-image/image-preserveAspectRatio-all.svg [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/filters/feImage-preserveAspectRatio-all.svg [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/dynamic-updates/SVGFEImageElement-dom-preserveAspectRatio-attr.html [ ImageOnlyFailure Pass ]
+webkit.org/b/99984 svg/dynamic-updates/SVGFEImageElement-svgdom-preserveAspectRatio-prop.html [ ImageOnlyFailure Pass ]
+
 # Need rebaseline after https://bugs.webkit.org/show_bug.cgi?id=105437
 webkit.org/b/105437 svg/W3C-SVG-1.1-SE/filters-image-03-f.svg [ ImageOnlyFailure Pass ]
 webkit.org/b/105437 svg/W3C-SVG-1.1-SE/filters-image-05-f.svg [ ImageOnlyFailure Pass ]
diff --git a/LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.png b/LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.png
new file mode 100644 (file)
index 0000000..0f85421
Binary files /dev/null and b/LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.png differ
diff --git a/LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.txt b/LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.txt
new file mode 100644 (file)
index 0000000..695edc7
--- /dev/null
@@ -0,0 +1,34 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x400
+  RenderSVGRoot {svg} at (0,0) size 800x333
+    RenderSVGRect {rect} at (0,0) size 800x333 [stroke={[type=SOLID] [color=#0000FF]}] [x=1.00] [y=1.00] [width=1198.00] [height=498.00]
+    RenderSVGContainer {g} at (33,16) size 734x285
+      RenderSVGImage {image} at (33,16) size 67x134
+      RenderSVGRect {rect} at (33,16) size 68x135 [stroke={[type=SOLID] [color=#008000]}] [x=50.00] [y=25.00] [width=100.00] [height=200.00]
+      RenderSVGImage {image} at (33,216) size 134x68
+      RenderSVGRect {rect} at (33,216) size 134x68 [stroke={[type=SOLID] [color=#008000]}] [x=50.00] [y=325.00] [width=200.00] [height=100.00]
+      RenderSVGImage {image} at (200,16) size 67x134
+      RenderSVGRect {rect} at (199,16) size 68x135 [stroke={[type=SOLID] [color=#008000]}] [x=300.00] [y=25.00] [width=100.00] [height=200.00]
+      RenderSVGImage {image} at (280,16) size 67x134
+      RenderSVGRect {rect} at (279,16) size 68x135 [stroke={[type=SOLID] [color=#008000]}] [x=420.00] [y=25.00] [width=100.00] [height=200.00]
+      RenderSVGImage {image} at (360,16) size 67x134
+      RenderSVGRect {rect} at (359,16) size 68x135 [stroke={[type=SOLID] [color=#008000]}] [x=540.00] [y=25.00] [width=100.00] [height=200.00]
+      RenderSVGImage {image} at (466,16) size 134x68
+      RenderSVGRect {rect} at (466,16) size 135x68 [stroke={[type=SOLID] [color=#008000]}] [x=700.00] [y=25.00] [width=200.00] [height=100.00]
+      RenderSVGImage {image} at (466,96) size 134x68
+      RenderSVGRect {rect} at (466,96) size 135x68 [stroke={[type=SOLID] [color=#008000]}] [x=700.00] [y=145.00] [width=200.00] [height=100.00]
+      RenderSVGImage {image} at (466,176) size 134x68
+      RenderSVGRect {rect} at (466,176) size 135x68 [stroke={[type=SOLID] [color=#008000]}] [x=700.00] [y=265.00] [width=200.00] [height=100.00]
+      RenderSVGImage {image} at (200,166) size 67x134
+      RenderSVGRect {rect} at (199,166) size 68x135 [stroke={[type=SOLID] [color=#008000]}] [x=300.00] [y=250.00] [width=100.00] [height=200.00]
+      RenderSVGImage {image} at (280,166) size 67x134
+      RenderSVGRect {rect} at (279,166) size 68x135 [stroke={[type=SOLID] [color=#008000]}] [x=420.00] [y=250.00] [width=100.00] [height=200.00]
+      RenderSVGImage {image} at (360,166) size 67x134
+      RenderSVGRect {rect} at (359,166) size 68x135 [stroke={[type=SOLID] [color=#008000]}] [x=540.00] [y=250.00] [width=100.00] [height=200.00]
+      RenderSVGImage {image} at (633,16) size 134x68
+      RenderSVGRect {rect} at (633,16) size 134x68 [stroke={[type=SOLID] [color=#008000]}] [x=950.00] [y=25.00] [width=200.00] [height=100.00]
+      RenderSVGImage {image} at (633,96) size 134x68
+      RenderSVGRect {rect} at (633,96) size 134x68 [stroke={[type=SOLID] [color=#008000]}] [x=950.00] [y=145.00] [width=200.00] [height=100.00]
+      RenderSVGImage {image} at (633,176) size 134x68
+      RenderSVGRect {rect} at (633,176) size 134x68 [stroke={[type=SOLID] [color=#008000]}] [x=950.00] [y=265.00] [width=200.00] [height=100.00]
diff --git a/LayoutTests/svg/as-image/image-preserveAspectRatio-all.svg b/LayoutTests/svg/as-image/image-preserveAspectRatio-all.svg
new file mode 100644 (file)
index 0000000..0027b76
--- /dev/null
@@ -0,0 +1,42 @@
+<svg width="800" height="400" viewBox="0 0 1200 600"
+     xmlns="http://www.w3.org/2000/svg"
+     xmlns:xlink="http://www.w3.org/1999/xlink">
+  <title>Example feImage - Examples of feImage use</title>
+  <desc>Testing all preserveAspectRatio options for feImage.
+        See bug 99984.</desc>
+  <rect fill="none" stroke="blue" x="1" y="1" width="1198" height="498"/>
+  <g>
+    <image xlink:href="../W3C-SVG-1.1/resources/smiley.png" x="50"  y="25" width="100" height="200" preserveAspectRatio="none"/>
+    <rect x="50"  y="25" width="100" height="200" fill="none" stroke="green"/>
+    <image xlink:href="../W3C-SVG-1.1/resources/smiley.png" x="50"  y="325" width="200" height="100" preserveAspectRatio="none"/>
+    <rect x="50"  y="325" width="200" height="100" fill="none" stroke="green"/>
+
+    <image xlink:href="../W3C-SVG-1.1/resources/smiley.png" x="300" y="25" width="100" height="200" preserveAspectRatio="xMinYMin meet"/>
+    <rect x="300" y="25" width="100" height="200" fill="none" stroke="green"/>
+    <image xlink:href="../W3C-SVG-1.1/resources/smiley.png" x="420" y="25" width="100" height="200" preserveAspectRatio="xMidYMid meet"/>
+    <rect x="420" y="25" width="100" height="200" fill="none" stroke="green"/>
+    <image xlink:href="../W3C-SVG-1.1/resources/smiley.png" x="540" y="25" width="100" height="200" preserveAspectRatio="xMaxYMax meet"/>
+    <rect x="540" y="25" width="100" height="200" fill="none" stroke="green"/>
+
+    <image xlink:href="../W3C-SVG-1.1/resources/smiley.png" x="700" y="25" width="200" height="100" preserveAspectRatio="xMinYMin meet"/>
+    <rect x="700" y="25" width="200" height="100" fill="none" stroke="green"/>
+    <image xlink:href="../W3C-SVG-1.1/resources/smiley.png" x="700" y="145" width="200" height="100" preserveAspectRatio="xMidYMid meet"/>
+    <rect x="700" y="145" width="200" height="100" fill="none" stroke="green"/>
+    <image xlink:href="../W3C-SVG-1.1/resources/smiley.png" x="700" y="265" width="200" height="100" preserveAspectRatio="xMaxYMax meet"/>
+    <rect x="700" y="265" width="200" height="100" fill="none" stroke="green"/>
+    
+    <image xlink:href="../W3C-SVG-1.1/resources/smiley.png" x="300" y="250" width="100" height="200" preserveAspectRatio="xMinYMin slice"/>
+    <rect x="300" y="250" width="100" height="200" fill="none" stroke="green"/>
+    <image xlink:href="../W3C-SVG-1.1/resources/smiley.png" x="420" y="250" width="100" height="200" preserveAspectRatio="xMidYMid slice"/>
+    <rect x="420" y="250" width="100" height="200" fill="none" stroke="green"/>
+    <image xlink:href="../W3C-SVG-1.1/resources/smiley.png" x="540" y="250" width="100" height="200" preserveAspectRatio="xMaxYMax slice"/>
+    <rect x="540" y="250" width="100" height="200" fill="none" stroke="green"/>
+
+    <image xlink:href="../W3C-SVG-1.1/resources/smiley.png" x="950" y="25" width="200" height="100" preserveAspectRatio="xMinYMin slice"/>
+    <rect x="950" y="25" width="200" height="100" fill="none" stroke="green"/>
+    <image xlink:href="../W3C-SVG-1.1/resources/smiley.png" x="950" y="145" width="200" height="100" preserveAspectRatio="xMidYMid slice"/>
+    <rect x="950" y="145" width="200" height="100" fill="none" stroke="green"/>
+    <image xlink:href="../W3C-SVG-1.1/resources/smiley.png" x="950" y="265" width="200" height="100" preserveAspectRatio="xMaxYMax slice"/>
+    <rect x="950" y="265" width="200" height="100" fill="none" stroke="green"/>
+  </g>
+</svg>
\ No newline at end of file
diff --git a/LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.png b/LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.png
new file mode 100644 (file)
index 0000000..0f85421
Binary files /dev/null and b/LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.png differ
diff --git a/LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.txt b/LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.txt
new file mode 100644 (file)
index 0000000..6731d5c
--- /dev/null
@@ -0,0 +1,63 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x400
+  RenderSVGRoot {svg} at (0,0) size 800x333
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceFilter {filter} [id="none"] [filterUnits=objectBoundingBox] [primitiveUnits=objectBoundingBox]
+        [feImage image-size="100x100"]
+      RenderSVGResourceFilter {filter} [id="slice_mid"] [filterUnits=objectBoundingBox] [primitiveUnits=objectBoundingBox]
+        [feImage image-size="100x100"]
+      RenderSVGResourceFilter {filter} [id="slice_max"] [filterUnits=objectBoundingBox] [primitiveUnits=objectBoundingBox]
+        [feImage image-size="100x100"]
+      RenderSVGResourceFilter {filter} [id="slice_min"] [filterUnits=objectBoundingBox] [primitiveUnits=objectBoundingBox]
+        [feImage image-size="100x100"]
+      RenderSVGResourceFilter {filter} [id="meet_mid"] [filterUnits=objectBoundingBox] [primitiveUnits=objectBoundingBox]
+        [feImage image-size="100x100"]
+      RenderSVGResourceFilter {filter} [id="meet_max"] [filterUnits=objectBoundingBox] [primitiveUnits=objectBoundingBox]
+        [feImage image-size="100x100"]
+      RenderSVGResourceFilter {filter} [id="meet_min"] [filterUnits=objectBoundingBox] [primitiveUnits=objectBoundingBox]
+        [feImage image-size="100x100"]
+    RenderSVGRect {rect} at (0,0) size 800x333 [stroke={[type=SOLID] [color=#0000FF]}] [x=1.00] [y=1.00] [width=1198.00] [height=498.00]
+    RenderSVGContainer {g} at (20,3) size 760x311
+      RenderSVGRect {rect} at (26,3) size 81x161 [fill={[type=SOLID] [color=#000000]}] [x=50.00] [y=25.00] [width=100.00] [height=200.00]
+        [filter="none"] RenderSVGResourceFilter {filter} at (40,5) size 120x240
+      RenderSVGRect {rect} at (33,16) size 68x135 [stroke={[type=SOLID] [color=#008000]}] [x=50.00] [y=25.00] [width=100.00] [height=200.00]
+      RenderSVGRect {rect} at (20,210) size 160x80 [fill={[type=SOLID] [color=#000000]}] [x=50.00] [y=325.00] [width=200.00] [height=100.00]
+        [filter="none"] RenderSVGResourceFilter {filter} at (30,315) size 240x120
+      RenderSVGRect {rect} at (33,216) size 134x68 [stroke={[type=SOLID] [color=#008000]}] [x=50.00] [y=325.00] [width=200.00] [height=100.00]
+      RenderSVGRect {rect} at (193,3) size 81x161 [fill={[type=SOLID] [color=#000000]}] [x=300.00] [y=25.00] [width=100.00] [height=200.00]
+        [filter="meet_min"] RenderSVGResourceFilter {filter} at (290,5) size 120x240
+      RenderSVGRect {rect} at (199,16) size 68x135 [stroke={[type=SOLID] [color=#008000]}] [x=300.00] [y=25.00] [width=100.00] [height=200.00]
+      RenderSVGRect {rect} at (273,3) size 81x161 [fill={[type=SOLID] [color=#000000]}] [x=420.00] [y=25.00] [width=100.00] [height=200.00]
+        [filter="meet_mid"] RenderSVGResourceFilter {filter} at (410,5) size 120x240
+      RenderSVGRect {rect} at (279,16) size 68x135 [stroke={[type=SOLID] [color=#008000]}] [x=420.00] [y=25.00] [width=100.00] [height=200.00]
+      RenderSVGRect {rect} at (353,3) size 81x161 [fill={[type=SOLID] [color=#000000]}] [x=540.00] [y=25.00] [width=100.00] [height=200.00]
+        [filter="meet_max"] RenderSVGResourceFilter {filter} at (530,5) size 120x240
+      RenderSVGRect {rect} at (359,16) size 68x135 [stroke={[type=SOLID] [color=#008000]}] [x=540.00] [y=25.00] [width=100.00] [height=200.00]
+      RenderSVGRect {rect} at (453,10) size 161x80 [fill={[type=SOLID] [color=#000000]}] [x=700.00] [y=25.00] [width=200.00] [height=100.00]
+        [filter="meet_min"] RenderSVGResourceFilter {filter} at (680,15) size 240x120
+      RenderSVGRect {rect} at (466,16) size 135x68 [stroke={[type=SOLID] [color=#008000]}] [x=700.00] [y=25.00] [width=200.00] [height=100.00]
+      RenderSVGRect {rect} at (453,90) size 161x80 [fill={[type=SOLID] [color=#000000]}] [x=700.00] [y=145.00] [width=200.00] [height=100.00]
+        [filter="meet_mid"] RenderSVGResourceFilter {filter} at (680,135) size 240x120
+      RenderSVGRect {rect} at (466,96) size 135x68 [stroke={[type=SOLID] [color=#008000]}] [x=700.00] [y=145.00] [width=200.00] [height=100.00]
+      RenderSVGRect {rect} at (453,170) size 161x80 [fill={[type=SOLID] [color=#000000]}] [x=700.00] [y=265.00] [width=200.00] [height=100.00]
+        [filter="meet_max"] RenderSVGResourceFilter {filter} at (680,255) size 240x120
+      RenderSVGRect {rect} at (466,176) size 135x68 [stroke={[type=SOLID] [color=#008000]}] [x=700.00] [y=265.00] [width=200.00] [height=100.00]
+      RenderSVGRect {rect} at (193,153) size 81x161 [fill={[type=SOLID] [color=#000000]}] [x=300.00] [y=250.00] [width=100.00] [height=200.00]
+        [filter="slice_min"] RenderSVGResourceFilter {filter} at (290,230) size 120x240
+      RenderSVGRect {rect} at (199,166) size 68x135 [stroke={[type=SOLID] [color=#008000]}] [x=300.00] [y=250.00] [width=100.00] [height=200.00]
+      RenderSVGRect {rect} at (273,153) size 81x161 [fill={[type=SOLID] [color=#000000]}] [x=420.00] [y=250.00] [width=100.00] [height=200.00]
+        [filter="slice_mid"] RenderSVGResourceFilter {filter} at (410,230) size 120x240
+      RenderSVGRect {rect} at (279,166) size 68x135 [stroke={[type=SOLID] [color=#008000]}] [x=420.00] [y=250.00] [width=100.00] [height=200.00]
+      RenderSVGRect {rect} at (353,153) size 81x161 [fill={[type=SOLID] [color=#000000]}] [x=540.00] [y=250.00] [width=100.00] [height=200.00]
+        [filter="slice_max"] RenderSVGResourceFilter {filter} at (530,230) size 120x240
+      RenderSVGRect {rect} at (359,166) size 68x135 [stroke={[type=SOLID] [color=#008000]}] [x=540.00] [y=250.00] [width=100.00] [height=200.00]
+      RenderSVGRect {rect} at (620,10) size 160x80 [fill={[type=SOLID] [color=#000000]}] [x=950.00] [y=25.00] [width=200.00] [height=100.00]
+        [filter="slice_min"] RenderSVGResourceFilter {filter} at (930,15) size 240x120
+      RenderSVGRect {rect} at (633,16) size 134x68 [stroke={[type=SOLID] [color=#008000]}] [x=950.00] [y=25.00] [width=200.00] [height=100.00]
+      RenderSVGRect {rect} at (620,90) size 160x80 [fill={[type=SOLID] [color=#000000]}] [x=950.00] [y=145.00] [width=200.00] [height=100.00]
+        [filter="slice_mid"] RenderSVGResourceFilter {filter} at (930,135) size 240x120
+      RenderSVGRect {rect} at (633,96) size 134x68 [stroke={[type=SOLID] [color=#008000]}] [x=950.00] [y=145.00] [width=200.00] [height=100.00]
+      RenderSVGRect {rect} at (620,170) size 160x80 [fill={[type=SOLID] [color=#000000]}] [x=950.00] [y=265.00] [width=200.00] [height=100.00]
+        [filter="slice_max"] RenderSVGResourceFilter {filter} at (930,255) size 240x120
+      RenderSVGRect {rect} at (633,176) size 134x68 [stroke={[type=SOLID] [color=#008000]}] [x=950.00] [y=265.00] [width=200.00] [height=100.00]
diff --git a/LayoutTests/svg/filters/feImage-preserveAspectRatio-all.svg b/LayoutTests/svg/filters/feImage-preserveAspectRatio-all.svg
new file mode 100644 (file)
index 0000000..224855c
--- /dev/null
@@ -0,0 +1,80 @@
+<svg width="800" height="400" viewBox="0 0 1200 600"
+     xmlns="http://www.w3.org/2000/svg"
+     xmlns:xlink="http://www.w3.org/1999/xlink">
+  <title>Example feImage - Examples of feImage use</title>
+  <desc>Testing all preserveAspectRatio options for feImage.
+        See bug 99984.</desc>
+  <defs>
+    <filter id="none" primitiveUnits="objectBoundingBox">
+      <feImage xlink:href="../W3C-SVG-1.1/resources/smiley.png"
+           x="0" y="0" width="100%" height="100%"
+           preserveAspectRatio="none"/>
+    </filter>
+    <filter id="slice_mid" primitiveUnits="objectBoundingBox">
+      <feImage xlink:href="../W3C-SVG-1.1/resources/smiley.png"
+         x="0" y="0" width="100%" height="100%"
+         preserveAspectRatio="xMidYMid slice"/>
+    </filter>
+    <filter id="slice_max" primitiveUnits="objectBoundingBox">
+      <feImage xlink:href="../W3C-SVG-1.1/resources/smiley.png"
+         x="0" y="0" width="100%" height="100%"
+         preserveAspectRatio="xMaxYMax slice"/>
+    </filter>
+    <filter id="slice_min" primitiveUnits="objectBoundingBox">
+      <feImage xlink:href="../W3C-SVG-1.1/resources/smiley.png"
+         x="0" y="0" width="100%" height="100%"
+         preserveAspectRatio="xMinYMin slice"/>
+    </filter>
+    <filter id="meet_mid" primitiveUnits="objectBoundingBox">
+      <feImage xlink:href="../W3C-SVG-1.1/resources/smiley.png"
+         x="0" y="0" width="100%" height="100%"
+         preserveAspectRatio="xMidYMid meet"/>
+    </filter>
+    <filter id="meet_max" primitiveUnits="objectBoundingBox">
+      <feImage xlink:href="../W3C-SVG-1.1/resources/smiley.png"
+         x="0" y="0" width="100%" height="100%"
+         preserveAspectRatio="xMaxYMax meet"/>
+    </filter>
+    <filter id="meet_min" primitiveUnits="objectBoundingBox">
+      <feImage xlink:href="../W3C-SVG-1.1/resources/smiley.png"
+         x="0" y="0" width="100%" height="100%"
+         preserveAspectRatio="xMinYMin meet"/>
+    </filter>
+  </defs>
+  <rect fill="none" stroke="blue"  
+        x="1" y="1" width="1198" height="498"/>
+  <g>
+    <rect x="50"  y="25" width="100" height="200" filter="url(#none)"/>
+    <rect x="50"  y="25" width="100" height="200" fill="none" stroke="green"/>
+    <rect x="50"  y="325" width="200" height="100" filter="url(#none)"/>
+    <rect x="50"  y="325" width="200" height="100" fill="none" stroke="green"/>
+
+    <rect x="300" y="25" width="100" height="200" filter="url(#meet_min)"/>
+    <rect x="300" y="25" width="100" height="200" fill="none" stroke="green"/>
+    <rect x="420" y="25" width="100" height="200" filter="url(#meet_mid)"/>
+    <rect x="420" y="25" width="100" height="200" fill="none" stroke="green"/>
+    <rect x="540" y="25" width="100" height="200" filter="url(#meet_max)"/>
+    <rect x="540" y="25" width="100" height="200" fill="none" stroke="green"/>
+
+    <rect x="700" y="25" width="200" height="100" filter="url(#meet_min)"/>
+    <rect x="700" y="25" width="200" height="100" fill="none" stroke="green"/>
+    <rect x="700" y="145" width="200" height="100" filter="url(#meet_mid)"/>
+    <rect x="700" y="145" width="200" height="100" fill="none" stroke="green"/>
+    <rect x="700" y="265" width="200" height="100" filter="url(#meet_max)"/>
+    <rect x="700" y="265" width="200" height="100" fill="none" stroke="green"/>
+    
+    <rect x="300" y="250" width="100" height="200" filter="url(#slice_min)"/>
+    <rect x="300" y="250" width="100" height="200" fill="none" stroke="green"/>
+    <rect x="420" y="250" width="100" height="200" filter="url(#slice_mid)"/>
+    <rect x="420" y="250" width="100" height="200" fill="none" stroke="green"/>
+    <rect x="540" y="250" width="100" height="200" filter="url(#slice_max)"/>
+    <rect x="540" y="250" width="100" height="200" fill="none" stroke="green"/>
+
+    <rect x="950" y="25" width="200" height="100" filter="url(#slice_min)"/>
+    <rect x="950" y="25" width="200" height="100" fill="none" stroke="green"/>
+    <rect x="950" y="145" width="200" height="100" filter="url(#slice_mid)"/>
+    <rect x="950" y="145" width="200" height="100" fill="none" stroke="green"/>
+    <rect x="950" y="265" width="200" height="100" filter="url(#slice_max)"/>
+    <rect x="950" y="265" width="200" height="100" fill="none" stroke="green"/>
+  </g>
+</svg>
\ No newline at end of file
index ad1ed33..09a61c3 100644 (file)
@@ -1,3 +1,24 @@
+2013-02-19  Branimir Lambov  <blambov@google.com>
+
+        Fix 'slice' aspect ratio calculation
+        https://bugs.webkit.org/show_bug.cgi?id=99984
+
+        Reviewed by Dirk Schulze.
+
+        Previously the calculation for the 'slice' aspect ratio would incorrectly calculate the
+        source rect location based on the destination rect offset. This caused our source rect to be
+        incorrect, and sometimes render outside the visible area completely. After this patch
+        our implementation matches the implementation of both Gecko and Presto.
+
+        The relevant spec section:
+        http://www.w3.org/TR/SVG/single-page.html#coords-PreserveAspectRatioAttribute
+
+        Tests: svg/as-image/image-preserveAspectRatio-all.svg
+               svg/filters/feImage-preserveAspectRatio-all.svg
+
+        * svg/SVGPreserveAspectRatio.cpp:
+        (WebCore::SVGPreserveAspectRatio::transformRect):
+
 2013-02-19  Kentaro Hara  <haraken@google.com>
 
         [V8] ScriptRunner::runCompiledScript() should return Handle<Value>() when OOM occurs
index 6a1cd14..afeef35 100644 (file)
@@ -220,12 +220,12 @@ void SVGPreserveAspectRatio::transformRect(FloatRect& destRect, FloatRect& srcRe
             case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID:
             case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
             case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
-                srcRect.setY(destRect.y() + imageSize.height() / 2 - srcRect.height() / 2);
+                srcRect.setY(srcRect.y() + imageSize.height() / 2 - srcRect.height() / 2);
                 break;
             case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMAX:
             case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
             case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
-                srcRect.setY(destRect.y() + imageSize.height() - srcRect.height());
+                srcRect.setY(srcRect.y() + imageSize.height() - srcRect.height());
                 break;
             default:
                 break;
@@ -239,12 +239,12 @@ void SVGPreserveAspectRatio::transformRect(FloatRect& destRect, FloatRect& srcRe
             case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN:
             case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
             case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
-                srcRect.setX(destRect.x() + imageSize.width() / 2 - srcRect.width() / 2);
+                srcRect.setX(srcRect.x() + imageSize.width() / 2 - srcRect.width() / 2);
                 break;
             case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMIN:
             case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
             case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
-                srcRect.setX(destRect.x() + imageSize.width() - srcRect.width());
+                srcRect.setX(srcRect.x() + imageSize.width() - srcRect.width());
                 break;
             default:
                 break;