[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

krit at webkit.org krit at webkit.org
Thu Apr 8 00:55:54 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit aaef148ba6bee8dd028e439ed1749132fc3b6709
Author: krit at webkit.org <krit at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jan 6 21:10:35 2010 +0000

    2010-01-06  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            SVG feImage support
            https://bugs.webkit.org/show_bug.cgi?id=31905
    
            This implements the SVG Filter effect feImage with support of fragment urls.
            It also includes a bug fix for feComposite. feComposite didn't cover values
            bigger than 255 correctly on composite oeprator arithmetic.
    
            Tests: There are already many feImage tests in trunk. They just needed updated
                   pixel test results.
                   The feComposite bug is covered by svg/W3C-SVG-1.1/filters-composite-02-b.svg
                   and depends on feImage.
    
            * platform/graphics/filters/FEComposite.cpp:
            (WebCore::arithmetic):
            * rendering/RenderSVGImage.cpp:
            (WebCore::RenderSVGImage::paint):
            * rendering/RenderSVGImage.h:
            * svg/SVGFEImageElement.cpp:
            (WebCore::SVGFEImageElement::requestImageResource):
            (WebCore::SVGFEImageElement::parseMappedAttribute):
            (WebCore::SVGFEImageElement::notifyFinished):
            (WebCore::SVGFEImageElement::build):
            * svg/SVGFEImageElement.h:
            * svg/SVGFEImageElement.idl:
            * svg/SVGPreserveAspectRatio.cpp:
            (WebCore::SVGPreserveAspectRatio::transformRect):
            * svg/SVGPreserveAspectRatio.h:
            * svg/graphics/filters/SVGFEImage.cpp:
            (WebCore::FEImage::FEImage):
            (WebCore::FEImage::create):
            (WebCore::FEImage::apply):
            * svg/graphics/filters/SVGFEImage.h:
    
    2010-01-06  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            SVG feImage support
            https://bugs.webkit.org/show_bug.cgi?id=31905
    
            The implementation of feImage requires pixel test result updates of the already
            available tests.
    
            There is also an update for svg/filters/feComposite.svg, since the patch also
            fixed a bug in feComposite.
    
            * platform/mac/svg/W3C-SVG-1.1/filters-composite-02-b-expected.checksum:
            * platform/mac/svg/W3C-SVG-1.1/filters-composite-02-b-expected.png:
            * platform/mac/svg/W3C-SVG-1.1/filters-displace-01-f-expected.checksum:
            * platform/mac/svg/W3C-SVG-1.1/filters-displace-01-f-expected.png:
            * platform/mac/svg/W3C-SVG-1.1/filters-image-01-b-expected.checksum:
            * platform/mac/svg/W3C-SVG-1.1/filters-image-01-b-expected.png:
            * platform/mac/svg/custom/feDisplacementMap-01-expected.checksum:
            * platform/mac/svg/custom/feDisplacementMap-01-expected.png:
            * platform/mac/svg/filters/feComposite-expected.checksum:
            * platform/mac/svg/filters/feComposite-expected.png:
            * platform/mac/svg/webarchive/svg-feimage-subresources-expected.checksum:
            * platform/mac/svg/webarchive/svg-feimage-subresources-expected.png:
    
    2010-01-06  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            SVG feImage support
            https://bugs.webkit.org/show_bug.cgi?id=31905
    
            Update SVG status page. We support feDisplacementMap and feImage now.
    
            * projects/svg/status.xml:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52865 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 872b208..799c8b7 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,29 @@
+2010-01-06  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVG feImage support
+        https://bugs.webkit.org/show_bug.cgi?id=31905
+
+        The implementation of feImage requires pixel test result updates of the already
+        available tests.
+
+        There is also an update for svg/filters/feComposite.svg, since the patch also
+        fixed a bug in feComposite.
+
+        * platform/mac/svg/W3C-SVG-1.1/filters-composite-02-b-expected.checksum:
+        * platform/mac/svg/W3C-SVG-1.1/filters-composite-02-b-expected.png:
+        * platform/mac/svg/W3C-SVG-1.1/filters-displace-01-f-expected.checksum:
+        * platform/mac/svg/W3C-SVG-1.1/filters-displace-01-f-expected.png:
+        * platform/mac/svg/W3C-SVG-1.1/filters-image-01-b-expected.checksum:
+        * platform/mac/svg/W3C-SVG-1.1/filters-image-01-b-expected.png:
+        * platform/mac/svg/custom/feDisplacementMap-01-expected.checksum:
+        * platform/mac/svg/custom/feDisplacementMap-01-expected.png:
+        * platform/mac/svg/filters/feComposite-expected.checksum:
+        * platform/mac/svg/filters/feComposite-expected.png:
+        * platform/mac/svg/webarchive/svg-feimage-subresources-expected.checksum:
+        * platform/mac/svg/webarchive/svg-feimage-subresources-expected.png:
+
 2010-01-06  Darin Adler  <darin at apple.com>
 
         Added file James Robinson provided to go with his fix for
diff --git a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-composite-02-b-expected.checksum b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-composite-02-b-expected.checksum
index 21dc41e..cd5736f 100644
--- a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-composite-02-b-expected.checksum
+++ b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-composite-02-b-expected.checksum
@@ -1 +1 @@
-595cf6946aa045acc21ed50e49871010
\ No newline at end of file
+4e2d58b2588a2a7b8d42e789a80f789f
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-composite-02-b-expected.png b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-composite-02-b-expected.png
index 933992d..48ea539 100644
Binary files a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-composite-02-b-expected.png and b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-composite-02-b-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-displace-01-f-expected.checksum b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-displace-01-f-expected.checksum
index 2659881..e989b2d 100644
--- a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-displace-01-f-expected.checksum
+++ b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-displace-01-f-expected.checksum
@@ -1 +1 @@
-a5b60846615b1ff8ccd1bbb5062c6fe5
\ No newline at end of file
+b6c63dd5fe1fda01e3ff9b0dfd771915
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-displace-01-f-expected.png b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-displace-01-f-expected.png
index 76c61e1..48f480b 100644
Binary files a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-displace-01-f-expected.png and b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-displace-01-f-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-image-01-b-expected.checksum b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-image-01-b-expected.checksum
index 2a78edf..9c32e1c 100644
--- a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-image-01-b-expected.checksum
+++ b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-image-01-b-expected.checksum
@@ -1 +1 @@
-5a1e5687cc46137b116c062c175d83d5
\ No newline at end of file
+cfb233bae17cc624073e47952c53e490
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-image-01-b-expected.png b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-image-01-b-expected.png
index 2d2f7da..e5c1324 100644
Binary files a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-image-01-b-expected.png and b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-image-01-b-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/feDisplacementMap-01-expected.checksum b/LayoutTests/platform/mac/svg/custom/feDisplacementMap-01-expected.checksum
index 4923a44..ef24172 100644
--- a/LayoutTests/platform/mac/svg/custom/feDisplacementMap-01-expected.checksum
+++ b/LayoutTests/platform/mac/svg/custom/feDisplacementMap-01-expected.checksum
@@ -1 +1 @@
-37725a2315328ea128fc2cfe3549a4f9
\ No newline at end of file
+c13733cd61a1b84ab863558aa67ee47b
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/feDisplacementMap-01-expected.png b/LayoutTests/platform/mac/svg/custom/feDisplacementMap-01-expected.png
index 3191a79..2f87bbd 100644
Binary files a/LayoutTests/platform/mac/svg/custom/feDisplacementMap-01-expected.png and b/LayoutTests/platform/mac/svg/custom/feDisplacementMap-01-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/filters/feComposite-expected.checksum b/LayoutTests/platform/mac/svg/filters/feComposite-expected.checksum
index c2024b2..0b417c0 100644
--- a/LayoutTests/platform/mac/svg/filters/feComposite-expected.checksum
+++ b/LayoutTests/platform/mac/svg/filters/feComposite-expected.checksum
@@ -1 +1 @@
-2393c34443caa35be741e4cc3e05edd2
\ No newline at end of file
+d0fabba10fec772a87a338fa3bf1b627
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/filters/feComposite-expected.png b/LayoutTests/platform/mac/svg/filters/feComposite-expected.png
index 2bf98cb..0649586 100644
Binary files a/LayoutTests/platform/mac/svg/filters/feComposite-expected.png and b/LayoutTests/platform/mac/svg/filters/feComposite-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/webarchive/svg-feimage-subresources-expected.checksum b/LayoutTests/platform/mac/svg/webarchive/svg-feimage-subresources-expected.checksum
index d69a371..d364eb1 100644
--- a/LayoutTests/platform/mac/svg/webarchive/svg-feimage-subresources-expected.checksum
+++ b/LayoutTests/platform/mac/svg/webarchive/svg-feimage-subresources-expected.checksum
@@ -1 +1 @@
-853de00567d121bea0b7bece66a5d61c
\ No newline at end of file
+c6ab9fc121db160df3116601d024db23
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/webarchive/svg-feimage-subresources-expected.png b/LayoutTests/platform/mac/svg/webarchive/svg-feimage-subresources-expected.png
index 12fde95..d99dbe8 100644
Binary files a/LayoutTests/platform/mac/svg/webarchive/svg-feimage-subresources-expected.png and b/LayoutTests/platform/mac/svg/webarchive/svg-feimage-subresources-expected.png differ
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index a7d30a1..fc58f34 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,40 @@
+2010-01-06  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVG feImage support
+        https://bugs.webkit.org/show_bug.cgi?id=31905
+
+        This implements the SVG Filter effect feImage with support of fragment urls.
+        It also includes a bug fix for feComposite. feComposite didn't cover values
+        bigger than 255 correctly on composite oeprator arithmetic.
+
+        Tests: There are already many feImage tests in trunk. They just needed updated
+               pixel test results.
+               The feComposite bug is covered by svg/W3C-SVG-1.1/filters-composite-02-b.svg
+               and depends on feImage.
+
+        * platform/graphics/filters/FEComposite.cpp:
+        (WebCore::arithmetic):
+        * rendering/RenderSVGImage.cpp:
+        (WebCore::RenderSVGImage::paint):
+        * rendering/RenderSVGImage.h:
+        * svg/SVGFEImageElement.cpp:
+        (WebCore::SVGFEImageElement::requestImageResource):
+        (WebCore::SVGFEImageElement::parseMappedAttribute):
+        (WebCore::SVGFEImageElement::notifyFinished):
+        (WebCore::SVGFEImageElement::build):
+        * svg/SVGFEImageElement.h:
+        * svg/SVGFEImageElement.idl:
+        * svg/SVGPreserveAspectRatio.cpp:
+        (WebCore::SVGPreserveAspectRatio::transformRect):
+        * svg/SVGPreserveAspectRatio.h:
+        * svg/graphics/filters/SVGFEImage.cpp:
+        (WebCore::FEImage::FEImage):
+        (WebCore::FEImage::create):
+        (WebCore::FEImage::apply):
+        * svg/graphics/filters/SVGFEImage.h:
+
 2010-01-06  Yong Li  <yoli at rim.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/platform/graphics/filters/FEComposite.cpp b/WebCore/platform/graphics/filters/FEComposite.cpp
index c540cb7..67d3d27 100644
--- a/WebCore/platform/graphics/filters/FEComposite.cpp
+++ b/WebCore/platform/graphics/filters/FEComposite.cpp
@@ -111,9 +111,7 @@ inline void arithmetic(const RefPtr<CanvasPixelArray>& srcPixelArrayA, CanvasPix
             unsigned char i1 = srcPixelArrayA->get(pixelOffset + channel);
             unsigned char i2 = srcPixelArrayB->get(pixelOffset + channel);
 
-            unsigned char result = scaledK1 * i1 * i2 + k2 * i1 + k3 * i2 + scaledK4;
-            if (channel == 3 && i1 == 0 && i2 == 0)
-                result = 0;
+            double result = scaledK1 * i1 * i2 + k2 * i1 + k3 * i2 + scaledK4;
             srcPixelArrayB->set(pixelOffset + channel, result);
         }
     }
diff --git a/WebCore/rendering/RenderSVGImage.cpp b/WebCore/rendering/RenderSVGImage.cpp
index 246b1bb..27d1a40 100644
--- a/WebCore/rendering/RenderSVGImage.cpp
+++ b/WebCore/rendering/RenderSVGImage.cpp
@@ -48,81 +48,6 @@ RenderSVGImage::RenderSVGImage(SVGImageElement* impl)
 {
 }
 
-void RenderSVGImage::adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, const SVGPreserveAspectRatio& aspectRatio)
-{
-    float origDestWidth = destRect.width();
-    float origDestHeight = destRect.height();
-    if (aspectRatio.meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET) {
-        float widthToHeightMultiplier = srcRect.height() / srcRect.width();
-        if (origDestHeight > (origDestWidth * widthToHeightMultiplier)) {
-            destRect.setHeight(origDestWidth * widthToHeightMultiplier);
-            switch (aspectRatio.align()) {
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
-                    destRect.setY(destRect.y() + origDestHeight / 2.0f - destRect.height() / 2.0f);
-                    break;
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMAX:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
-                    destRect.setY(destRect.y() + origDestHeight - destRect.height());
-                    break;
-            }
-        }
-        if (origDestWidth > (origDestHeight / widthToHeightMultiplier)) {
-            destRect.setWidth(origDestHeight / widthToHeightMultiplier);
-            switch (aspectRatio.align()) {
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
-                    destRect.setX(destRect.x() + origDestWidth / 2.0f - destRect.width() / 2.0f);
-                    break;
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMIN:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
-                    destRect.setX(destRect.x() + origDestWidth - destRect.width());
-                    break;
-            }
-        }
-    } else if (aspectRatio.meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE) {
-        float widthToHeightMultiplier = srcRect.height() / srcRect.width();
-        // if the destination height is less than the height of the image we'll be drawing
-        if (origDestHeight < (origDestWidth * widthToHeightMultiplier)) {
-            float destToSrcMultiplier = srcRect.width() / destRect.width();
-            srcRect.setHeight(destRect.height() * destToSrcMultiplier);
-            switch (aspectRatio.align()) {
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
-                    srcRect.setY(destRect.y() + image()->height() / 2.0f - srcRect.height() / 2.0f);
-                    break;
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMAX:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
-                    srcRect.setY(destRect.y() + image()->height() - srcRect.height());
-                    break;
-            }
-        }
-        // if the destination width is less than the width of the image we'll be drawing
-        if (origDestWidth < (origDestHeight / widthToHeightMultiplier)) {
-            float destToSrcMultiplier = srcRect.height() / destRect.height();
-            srcRect.setWidth(destRect.width() * destToSrcMultiplier);
-            switch (aspectRatio.align()) {
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
-                    srcRect.setX(destRect.x() + image()->width() / 2.0f - srcRect.width() / 2.0f);
-                    break;
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMIN:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
-                case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
-                    srcRect.setX(destRect.x() + image()->width() - srcRect.width());
-                    break;
-            }
-        }
-    }
-}
-
 void RenderSVGImage::layout()
 {
     ASSERT(needsLayout());
@@ -165,7 +90,7 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, int, int)
 
             SVGImageElement* imageElt = static_cast<SVGImageElement*>(node());
             if (imageElt->preserveAspectRatio().align() != SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_NONE)
-                adjustRectsForAspectRatio(destRect, srcRect, imageElt->preserveAspectRatio());
+                imageElt->preserveAspectRatio().transformRect(destRect, srcRect);
 
             paintInfo.context->drawImage(image(), DeviceColorSpace, destRect, srcRect);
         }
diff --git a/WebCore/rendering/RenderSVGImage.h b/WebCore/rendering/RenderSVGImage.h
index 044d63b..7791613 100644
--- a/WebCore/rendering/RenderSVGImage.h
+++ b/WebCore/rendering/RenderSVGImage.h
@@ -59,7 +59,6 @@ namespace WebCore {
         virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
 
         virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
-        void adjustRectsForAspectRatio(FloatRect& destRect, FloatRect& srcRect, const SVGPreserveAspectRatio&);
         
         virtual void layout();
         virtual void paint(PaintInfo&, int parentX, int parentY);
diff --git a/WebCore/svg/SVGFEImageElement.cpp b/WebCore/svg/SVGFEImageElement.cpp
index d9e13e9..04c98ea 100644
--- a/WebCore/svg/SVGFEImageElement.cpp
+++ b/WebCore/svg/SVGFEImageElement.cpp
@@ -1,6 +1,7 @@
 /*
     Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann at kde.org>
                   2004, 2005 Rob Buis <buis at kde.org>
+                  2010 Dirk Schulze <krit at webkit.org>
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public
@@ -31,6 +32,7 @@
 #include "SVGLength.h"
 #include "SVGNames.h"
 #include "SVGPreserveAspectRatio.h"
+#include "SVGRenderSupport.h"
 #include "SVGResourceFilter.h"
 
 namespace WebCore {
@@ -52,6 +54,23 @@ SVGFEImageElement::~SVGFEImageElement()
         m_cachedImage->removeClient(this);
 }
 
+void SVGFEImageElement::requestImageResource()
+{
+    if (m_cachedImage) {
+        m_cachedImage->removeClient(this);
+        m_cachedImage = 0;
+    }
+
+    Element* hrefElement = document()->getElementById(SVGURIReference::getTarget(href()));
+    if (hrefElement && hrefElement->isSVGElement() && hrefElement->renderer())
+        return;
+
+    m_cachedImage = ownerDocument()->docLoader()->requestImage(href());
+
+    if (m_cachedImage)
+        m_cachedImage->addClient(this);
+}
+
 void SVGFEImageElement::parseMappedAttribute(MappedAttribute* attr)
 {
     const String& value = attr->value();
@@ -59,14 +78,7 @@ void SVGFEImageElement::parseMappedAttribute(MappedAttribute* attr)
         SVGPreserveAspectRatio::parsePreserveAspectRatio(this, value);
     else {
         if (SVGURIReference::parseMappedAttribute(attr)) {
-            if (!href().startsWith("#")) {
-                // FIXME: this code needs to special-case url fragments and later look them up using getElementById instead of loading them here
-                if (m_cachedImage)
-                    m_cachedImage->removeClient(this);
-                m_cachedImage = ownerDocument()->docLoader()->requestImage(href());
-                if (m_cachedImage)
-                    m_cachedImage->addClient(this);
-            }
+            requestImageResource();
             return;
         }
         if (SVGLangSpace::parseMappedAttribute(attr))
@@ -80,14 +92,27 @@ void SVGFEImageElement::parseMappedAttribute(MappedAttribute* attr)
 
 void SVGFEImageElement::notifyFinished(CachedResource*)
 {
+    SVGStyledElement::invalidateResourcesInAncestorChain();
 }
 
 bool SVGFEImageElement::build(SVGResourceFilter* filterResource)
 {
-    if (!m_cachedImage)
-        return false;
+    if (!m_cachedImage && !m_targetImage) {
+        Element* hrefElement = document()->getElementById(SVGURIReference::getTarget(href()));
+        if (!hrefElement || !hrefElement->isSVGElement())
+            return false;
+
+        RenderObject* renderer = hrefElement->renderer();
+        if (!renderer)
+            return false;
+
+        IntRect targetRect = enclosingIntRect(renderer->objectBoundingBox());
+        m_targetImage = ImageBuffer::create(targetRect.size(), LinearRGB);
+
+        renderSubtreeToImage(m_targetImage.get(), renderer);
+    }
 
-    RefPtr<FilterEffect> effect = FEImage::create(m_cachedImage.get());
+    RefPtr<FilterEffect> effect = FEImage::create(m_targetImage ? m_targetImage->image() : m_cachedImage->image(), preserveAspectRatio());
     filterResource->addFilterEffect(this, effect.release());
 
     return true;
diff --git a/WebCore/svg/SVGFEImageElement.h b/WebCore/svg/SVGFEImageElement.h
index 7c6d89b..8446e09 100644
--- a/WebCore/svg/SVGFEImageElement.h
+++ b/WebCore/svg/SVGFEImageElement.h
@@ -23,12 +23,13 @@
 
 #if ENABLE(SVG) && ENABLE(FILTERS)
 #include "CachedResourceHandle.h"
-#include "SVGFilterPrimitiveStandardAttributes.h"
-#include "SVGURIReference.h"
-#include "SVGLangSpace.h"
+#include "ImageBuffer.h"
 #include "SVGExternalResourcesRequired.h"
 #include "SVGFEImage.h"
+#include "SVGFilterPrimitiveStandardAttributes.h"
+#include "SVGLangSpace.h"
 #include "SVGPreserveAspectRatio.h"
+#include "SVGURIReference.h"
 
 namespace WebCore {
 
@@ -48,6 +49,8 @@ namespace WebCore {
         virtual bool build(SVGResourceFilter*);
 
     private:
+        void requestImageResource();
+
         ANIMATED_PROPERTY_DECLARATIONS(SVGFEImageElement, SVGNames::feImageTagString, SVGNames::preserveAspectRatioAttrString, SVGPreserveAspectRatio, PreserveAspectRatio, preserveAspectRatio)
 
         // SVGURIReference
@@ -59,6 +62,7 @@ namespace WebCore {
                                        ExternalResourcesRequired, externalResourcesRequired)
 
         CachedResourceHandle<CachedImage> m_cachedImage;
+        OwnPtr<ImageBuffer> m_targetImage;
     };
 
 } // namespace WebCore
diff --git a/WebCore/svg/SVGFEImageElement.idl b/WebCore/svg/SVGFEImageElement.idl
index 23b9c86..0ebe53e 100644
--- a/WebCore/svg/SVGFEImageElement.idl
+++ b/WebCore/svg/SVGFEImageElement.idl
@@ -26,10 +26,11 @@
 module svg {
 
     interface [Conditional=SVG&FILTERS] SVGFEImageElement : SVGElement,
-                                                    SVGURIReference,
-                                                    SVGLangSpace,
-                                                    SVGExternalResourcesRequired,
-                                                    SVGFilterPrimitiveStandardAttributes {
+                                                            SVGURIReference,
+                                                            SVGLangSpace,
+                                                            SVGExternalResourcesRequired,
+                                                            SVGFilterPrimitiveStandardAttributes {
+        readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio;
     };
 
 }
diff --git a/WebCore/svg/SVGPreserveAspectRatio.cpp b/WebCore/svg/SVGPreserveAspectRatio.cpp
index 4fd1281..be07a26 100644
--- a/WebCore/svg/SVGPreserveAspectRatio.cpp
+++ b/WebCore/svg/SVGPreserveAspectRatio.cpp
@@ -1,6 +1,7 @@
 /*
     Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann at kde.org>
                   2004, 2005, 2006, 2007 Rob Buis <buis at kde.org>
+                  2010 Dirk Schulze <krit at webkit.org>
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public
@@ -158,6 +159,82 @@ bail_out:
     return aspectRatio;
 }
 
+void SVGPreserveAspectRatio::transformRect(FloatRect& destRect, FloatRect& srcRect)
+{
+    FloatSize imageSize = srcRect.size();
+    float origDestWidth = destRect.width();
+    float origDestHeight = destRect.height();
+    if (meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_MEET) {
+        float widthToHeightMultiplier = srcRect.height() / srcRect.width();
+        if (origDestHeight > (origDestWidth * widthToHeightMultiplier)) {
+            destRect.setHeight(origDestWidth * widthToHeightMultiplier);
+            switch (align()) {
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
+                destRect.setY(destRect.y() + origDestHeight / 2.0f - destRect.height() / 2.0f);
+                break;
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMAX:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
+                destRect.setY(destRect.y() + origDestHeight - destRect.height());
+                break;
+            }
+        }
+        if (origDestWidth > (origDestHeight / widthToHeightMultiplier)) {
+            destRect.setWidth(origDestHeight / widthToHeightMultiplier);
+            switch (align()) {
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
+                destRect.setX(destRect.x() + origDestWidth / 2.0f - destRect.width() / 2.0f);
+                break;
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMIN:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
+                destRect.setX(destRect.x() + origDestWidth - destRect.width());
+                break;
+            }
+        }
+    } else if (meetOrSlice() == SVGPreserveAspectRatio::SVG_MEETORSLICE_SLICE) {
+        float widthToHeightMultiplier = srcRect.height() / srcRect.width();
+        // if the destination height is less than the height of the image we'll be drawing
+        if (origDestHeight < (origDestWidth * widthToHeightMultiplier)) {
+            float destToSrcMultiplier = srcRect.width() / destRect.width();
+            srcRect.setHeight(destRect.height() * destToSrcMultiplier);
+            switch (align()) {
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMID:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
+                srcRect.setY(destRect.y() + imageSize.height() / 2.0f - srcRect.height() / 2.0f);
+                break;
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMINYMAX:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
+                srcRect.setY(destRect.y() + imageSize.height() - srcRect.height());
+                break;
+            }
+        }
+        // if the destination width is less than the width of the image we'll be drawing
+        if (origDestWidth < (origDestHeight / widthToHeightMultiplier)) {
+            float destToSrcMultiplier = srcRect.height() / destRect.height();
+            srcRect.setWidth(destRect.width() * destToSrcMultiplier);
+            switch (align()) {
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMIN:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMID:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMIDYMAX:
+                srcRect.setX(destRect.x() + imageSize.width() / 2.0f - srcRect.width() / 2.0f);
+                break;
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMIN:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMID:
+            case SVGPreserveAspectRatio::SVG_PRESERVEASPECTRATIO_XMAXYMAX:
+                srcRect.setX(destRect.x() + imageSize.width() - srcRect.width());
+                break;
+            }
+        }
+    }
+}
+
 TransformationMatrix SVGPreserveAspectRatio::getCTM(double logicX, double logicY,
                                                double logicWidth, double logicHeight,
                                                double /*physX*/, double /*physY*/,
diff --git a/WebCore/svg/SVGPreserveAspectRatio.h b/WebCore/svg/SVGPreserveAspectRatio.h
index 17db42d..bbd9256 100644
--- a/WebCore/svg/SVGPreserveAspectRatio.h
+++ b/WebCore/svg/SVGPreserveAspectRatio.h
@@ -22,6 +22,7 @@
 #define SVGPreserveAspectRatio_h
 
 #if ENABLE(SVG)
+#include "FloatRect.h"
 #include "PlatformString.h"
 #include "SVGNames.h"
 
@@ -60,6 +61,8 @@ namespace WebCore {
 
         void setMeetOrSlice(unsigned short);
         unsigned short meetOrSlice() const;
+
+        void transformRect(FloatRect& destRect, FloatRect& srcRect);
         
         TransformationMatrix getCTM(double logicX, double logicY,
                                double logicWidth, double logicHeight,
diff --git a/WebCore/svg/graphics/filters/SVGFEImage.cpp b/WebCore/svg/graphics/filters/SVGFEImage.cpp
index e82328a..331de4f 100644
--- a/WebCore/svg/graphics/filters/SVGFEImage.cpp
+++ b/WebCore/svg/graphics/filters/SVGFEImage.cpp
@@ -2,6 +2,7 @@
     Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann at kde.org>
                   2004, 2005 Rob Buis <buis at kde.org>
                   2005 Eric Seidel <eric at webkit.org>
+                  2010 Dirk Schulze <krit at webkit.org>
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public
@@ -23,50 +24,42 @@
 
 #if ENABLE(SVG) && ENABLE(FILTERS)
 #include "SVGFEImage.h"
-#include "SVGRenderTreeAsText.h"
+
 #include "Filter.h"
+#include "GraphicsContext.h"
+#include "SVGPreserveAspectRatio.h"
+#include "SVGRenderTreeAsText.h"
+#include "TransformationMatrix.h"
 
 namespace WebCore {
 
-FEImage::FEImage(CachedImage* cachedImage)
+FEImage::FEImage(RefPtr<Image> image, SVGPreserveAspectRatio preserveAspectRatio)
     : FilterEffect()
-    , m_cachedImage(cachedImage)
+    , m_image(image)
+    , m_preserveAspectRatio(preserveAspectRatio)
 {
-    m_cachedImage->addClient(this);
 }
 
-PassRefPtr<FEImage> FEImage::create(CachedImage* cachedImage)
+PassRefPtr<FEImage> FEImage::create(RefPtr<Image> image, SVGPreserveAspectRatio preserveAspectRatio)
 {
-    return adoptRef(new FEImage(cachedImage));
+    return adoptRef(new FEImage(image, preserveAspectRatio));
 }
 
-FEImage::~FEImage()
-{
-    if (m_cachedImage)
-        m_cachedImage->removeClient(this);
-}
-
-CachedImage* FEImage::cachedImage() const
+void FEImage::apply(Filter*)
 {
-    return m_cachedImage.get();
-}
+    if (!m_image.get())
+        return;
 
-void FEImage::setCachedImage(CachedImage* image)
-{
-    if (m_cachedImage == image)
+    GraphicsContext* filterContext = getEffectContext();
+    if (!filterContext)
         return;
-    
-    if (m_cachedImage)
-        m_cachedImage->removeClient(this);
 
-    m_cachedImage = image;
+    FloatRect srcRect(FloatPoint(), m_image->size());
+    FloatRect destRect(FloatPoint(), subRegion().size());
 
-    if (m_cachedImage)
-        m_cachedImage->addClient(this);
-}
+    m_preserveAspectRatio.transformRect(destRect, srcRect);
 
-void FEImage::apply(Filter*)
-{
+    filterContext->drawImage(m_image.get(), DeviceColorSpace, destRect, srcRect);
 }
 
 void FEImage::dump()
diff --git a/WebCore/svg/graphics/filters/SVGFEImage.h b/WebCore/svg/graphics/filters/SVGFEImage.h
index f29d266..0883aad 100644
--- a/WebCore/svg/graphics/filters/SVGFEImage.h
+++ b/WebCore/svg/graphics/filters/SVGFEImage.h
@@ -2,6 +2,7 @@
     Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann at kde.org>
                   2004, 2005 Rob Buis <buis at kde.org>
                   2005 Eric Seidel <eric at webkit.org>
+                  2010 Dirk Schulze <krit at webkit.org>
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public
@@ -23,33 +24,26 @@
 #define SVGFEImage_h
 
 #if ENABLE(SVG) && ENABLE(FILTERS)
-#include "CachedImage.h"
-#include "CachedResourceClient.h"
-#include "CachedResourceHandle.h"
+#include "Image.h"
 #include "FilterEffect.h"
 #include "Filter.h"
+#include "SVGPreserveAspectRatio.h"
 
 namespace WebCore {
 
-    class FEImage : public FilterEffect
-                     , public CachedResourceClient {
+    class FEImage : public FilterEffect {
     public:
-        static PassRefPtr<FEImage> create(CachedImage*);
-        virtual ~FEImage();
-
-        // FIXME: We need to support <svg> (RenderObject*) as well as image data.
-
-        CachedImage* cachedImage() const;
-        void setCachedImage(CachedImage*);
+        static PassRefPtr<FEImage> create(RefPtr<Image>, SVGPreserveAspectRatio);
 
         void apply(Filter*);
         void dump();
         TextStream& externalRepresentation(TextStream& ts) const;
         
     private:
-        FEImage(CachedImage*);
+        FEImage(RefPtr<Image>, SVGPreserveAspectRatio);
 
-        CachedResourceHandle<CachedImage> m_cachedImage;
+        RefPtr<Image> m_image;
+        SVGPreserveAspectRatio m_preserveAspectRatio;
     };
 
 } // namespace WebCore
diff --git a/WebKitSite/ChangeLog b/WebKitSite/ChangeLog
index 5b1c638..d8f2d52 100644
--- a/WebKitSite/ChangeLog
+++ b/WebKitSite/ChangeLog
@@ -1,3 +1,14 @@
+2010-01-06  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVG feImage support
+        https://bugs.webkit.org/show_bug.cgi?id=31905
+
+        Update SVG status page. We support feDisplacementMap and feImage now.
+
+        * projects/svg/status.xml:
+
 2009-12-20  Chris Jerdonek  <chris.jerdonek at gmail.com>
 
         Reviewed by Darin Adler.
diff --git a/WebKitSite/projects/svg/status.xml b/WebKitSite/projects/svg/status.xml
index 6c2974b..20e636d 100644
--- a/WebKitSite/projects/svg/status.xml
+++ b/WebKitSite/projects/svg/status.xml
@@ -6,7 +6,7 @@
     This is a seldom-updated summary document showing the current implementation status of SVG in WebKit.
     </p>
     <p>
-    Last update: Nov 5th, 2009.
+    Last update: Jan 5th, 2010.
     </p>
     <p>
     Note: this is not a full list of all SVG bugs, please see the <a href="https://bugs.webkit.org/buglist.cgi?query_format=advanced&amp;product=WebKit&amp;component=SVG&amp;bug_status=UNCONFIRMED&amp;bug_status=NEW&amp;bug_status=ASSIGNED&amp;bug_status=REOPENED">SVG bug list</a>.
@@ -293,13 +293,11 @@
                 <issues>
                     <issue>Tracking Bug <bug>26389</bug>.</issue>
                     <issue>Filters look grainy when scaled <bug>5526</bug></issue>
-                    <issue>Filters don't support filterRes <bug>6021</bug></issue>
                     <issue>Need support sources other than SourceGraphic <bug>6022</bug></issue>
                     <issue>Support 'color-interpolation-filters' and draw in correct colorspace <bug>6033</bug></issue>
                     <issue>Positional light problems <bug>10115</bug></issue>
                     <issue>Handle missing filter elements correctly <bug>12569</bug></issue>
                     <issue>Filter Effects being cleared and reloaded multiple times <bug>19388</bug></issue>
-                    <issue>Big filterRegions <bug>26380</bug></issue>
                 </issues>
             </element>
             <element>
@@ -338,7 +336,7 @@
             <element>
                 <name>feDisplacementMap</name>
                 <url>http://www.w3.org/TR/SVG11/filters.html#feDisplacementMapElement</url>
-                <status>Unimplemented</status>
+                <status>Implemented</status>
             </element>
             <element>
                 <name>feFlood</name>
@@ -353,10 +351,7 @@
             <element>
                 <name>feImage</name>
                 <url>http://www.w3.org/TR/SVG11/filters.html#feImageElement</url>
-                <status>Unimplemented</status>
-                <issues>
-                    <issue>Does not support SVG fragment URLs <bug>12027</bug></issue>
-                </issues>
+                <status>Implemented</status>
             </element>
             <element>
                 <name>feMerge</name>

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list