Title: [143389] trunk
Revision
143389
Author
[email protected]
Date
2013-02-19 15:04:34 -0800 (Tue, 19 Feb 2013)

Log Message

Fix 'slice' aspect ratio calculation
https://bugs.webkit.org/show_bug.cgi?id=99984

Patch by Branimir Lambov <[email protected]> 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (143388 => 143389)


--- trunk/LayoutTests/ChangeLog	2013-02-19 23:03:15 UTC (rev 143388)
+++ trunk/LayoutTests/ChangeLog	2013-02-19 23:04:34 UTC (rev 143389)
@@ -1,3 +1,22 @@
+2013-02-19  Branimir Lambov  <[email protected]>
+
+        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  <[email protected]>
 
         [Chromium] Test Expectations to reflect flakey calendar tests.

Modified: trunk/LayoutTests/platform/chromium/TestExpectations (143388 => 143389)


--- trunk/LayoutTests/platform/chromium/TestExpectations	2013-02-19 23:03:15 UTC (rev 143388)
+++ trunk/LayoutTests/platform/chromium/TestExpectations	2013-02-19 23:04:34 UTC (rev 143389)
@@ -1383,6 +1383,12 @@
 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 ]

Modified: trunk/LayoutTests/platform/efl/TestExpectations (143388 => 143389)


--- trunk/LayoutTests/platform/efl/TestExpectations	2013-02-19 23:03:15 UTC (rev 143388)
+++ trunk/LayoutTests/platform/efl/TestExpectations	2013-02-19 23:04:34 UTC (rev 143389)
@@ -590,6 +590,12 @@
 # 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 ]

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (143388 => 143389)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2013-02-19 23:03:15 UTC (rev 143388)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2013-02-19 23:04:34 UTC (rev 143389)
@@ -75,6 +75,12 @@
 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 ]
 

Modified: trunk/LayoutTests/platform/mac/TestExpectations (143388 => 143389)


--- trunk/LayoutTests/platform/mac/TestExpectations	2013-02-19 23:03:15 UTC (rev 143388)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2013-02-19 23:04:34 UTC (rev 143389)
@@ -1240,6 +1240,12 @@
 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 ]

Modified: trunk/LayoutTests/platform/qt/TestExpectations (143388 => 143389)


--- trunk/LayoutTests/platform/qt/TestExpectations	2013-02-19 23:03:15 UTC (rev 143388)
+++ trunk/LayoutTests/platform/qt/TestExpectations	2013-02-19 23:04:34 UTC (rev 143389)
@@ -1374,6 +1374,12 @@
 # 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 ]

Added: trunk/LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.txt (0 => 143389)


--- trunk/LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/as-image/image-preserveAspectRatio-all-expected.txt	2013-02-19 23:04:34 UTC (rev 143389)
@@ -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]

Added: trunk/LayoutTests/svg/as-image/image-preserveAspectRatio-all.svg (0 => 143389)


--- trunk/LayoutTests/svg/as-image/image-preserveAspectRatio-all.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/as-image/image-preserveAspectRatio-all.svg	2013-02-19 23:04:34 UTC (rev 143389)
@@ -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="" 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="" 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="" 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="" 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="" 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="" 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="" 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="" 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="" 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="" 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="" 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="" 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="" 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="" 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

Added: trunk/LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.txt (0 => 143389)


--- trunk/LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/filters/feImage-preserveAspectRatio-all-expected.txt	2013-02-19 23:04:34 UTC (rev 143389)
@@ -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]

Added: trunk/LayoutTests/svg/filters/feImage-preserveAspectRatio-all.svg (0 => 143389)


--- trunk/LayoutTests/svg/filters/feImage-preserveAspectRatio-all.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/filters/feImage-preserveAspectRatio-all.svg	2013-02-19 23:04:34 UTC (rev 143389)
@@ -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=""
+           x="0" y="0" width="100%" height="100%"
+           preserveAspectRatio="none"/>
+    </filter>
+    <filter id="slice_mid" primitiveUnits="objectBoundingBox">
+      <feImage xlink:href=""
+         x="0" y="0" width="100%" height="100%"
+         preserveAspectRatio="xMidYMid slice"/>
+    </filter>
+    <filter id="slice_max" primitiveUnits="objectBoundingBox">
+      <feImage xlink:href=""
+         x="0" y="0" width="100%" height="100%"
+         preserveAspectRatio="xMaxYMax slice"/>
+    </filter>
+    <filter id="slice_min" primitiveUnits="objectBoundingBox">
+      <feImage xlink:href=""
+         x="0" y="0" width="100%" height="100%"
+         preserveAspectRatio="xMinYMin slice"/>
+    </filter>
+    <filter id="meet_mid" primitiveUnits="objectBoundingBox">
+      <feImage xlink:href=""
+         x="0" y="0" width="100%" height="100%"
+         preserveAspectRatio="xMidYMid meet"/>
+    </filter>
+    <filter id="meet_max" primitiveUnits="objectBoundingBox">
+      <feImage xlink:href=""
+         x="0" y="0" width="100%" height="100%"
+         preserveAspectRatio="xMaxYMax meet"/>
+    </filter>
+    <filter id="meet_min" primitiveUnits="objectBoundingBox">
+      <feImage xlink:href=""
+         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

Modified: trunk/Source/WebCore/ChangeLog (143388 => 143389)


--- trunk/Source/WebCore/ChangeLog	2013-02-19 23:03:15 UTC (rev 143388)
+++ trunk/Source/WebCore/ChangeLog	2013-02-19 23:04:34 UTC (rev 143389)
@@ -1,3 +1,24 @@
+2013-02-19  Branimir Lambov  <[email protected]>
+
+        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  <[email protected]>
 
         [V8] ScriptRunner::runCompiledScript() should return Handle<Value>() when OOM occurs

Modified: trunk/Source/WebCore/svg/SVGPreserveAspectRatio.cpp (143388 => 143389)


--- trunk/Source/WebCore/svg/SVGPreserveAspectRatio.cpp	2013-02-19 23:03:15 UTC (rev 143388)
+++ trunk/Source/WebCore/svg/SVGPreserveAspectRatio.cpp	2013-02-19 23:04:34 UTC (rev 143389)
@@ -220,12 +220,12 @@
             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 @@
             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;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to