[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

krit at webkit.org krit at webkit.org
Wed Dec 22 14:40:56 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7e4b67577a7ef5ce0d2dc1ba86168c00adbce4ba
Author: krit at webkit.org <krit at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 15 20:02:34 2010 +0000

    2010-10-15  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            carto.net Dock example redraws *way* too often
            https://bugs.webkit.org/show_bug.cgi?id=16090
    
            Setting the attributes x, y, width or height shouldn't cause a repaint if the image boundaries don't change.
            Added updateFromElement() to RenderSVGImage that checks if the old boundaries match the new boundaries after
            setting one of the attributes of above. Mark renderer for layout (and therefore repaint) if the boundaries
            differ, do nothing if not.
            Also added caching of the repaint rect to avoid multiple calculations.
    
            Test: svg/custom/repaint-on-constant-size-change.svg
    
            * rendering/RenderSVGImage.cpp:
            (WebCore::RenderSVGImage::RenderSVGImage):
            (WebCore::RenderSVGImage::layout): Update repaint rect on layout.
            (WebCore::RenderSVGImage::updateFromElement): Check SVGImageElement for boundaries update.
            * rendering/RenderSVGImage.h:
            (WebCore::RenderSVGImage::repaintRectInLocalCoordinates): Return the cached repaint rect.
            * svg/SVGImageElement.cpp:
            (WebCore::SVGImageElement::svgAttributeChanged): Call updateFromElement() on changes to x, y, width or height.
    2010-10-15  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            carto.net Dock example redraws *way* too often
            https://bugs.webkit.org/show_bug.cgi?id=16090
    
            Added a repaint example to make sure that setting the attributes x, y, width or height
            doens't cause a repaint if the boundaries don't change.
    
            * platform/mac/svg/custom/repaint-on-constant-size-change-expected.checksum: Added.
            * platform/mac/svg/custom/repaint-on-constant-size-change-expected.png: Added.
            * platform/mac/svg/custom/repaint-on-constant-size-change-expected.txt: Added.
            * svg/custom/repaint-on-constant-size-change.svg: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69874 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 650664c..3cea8a3 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,5 +1,20 @@
 2010-10-15  Dirk Schulze  <krit at webkit.org>
 
+        Reviewed by Nikolas Zimmermann.
+
+        carto.net Dock example redraws *way* too often
+        https://bugs.webkit.org/show_bug.cgi?id=16090
+
+        Added a repaint example to make sure that setting the attributes x, y, width or height
+        doens't cause a repaint if the boundaries don't change.
+
+        * platform/mac/svg/custom/repaint-on-constant-size-change-expected.checksum: Added.
+        * platform/mac/svg/custom/repaint-on-constant-size-change-expected.png: Added.
+        * platform/mac/svg/custom/repaint-on-constant-size-change-expected.txt: Added.
+        * svg/custom/repaint-on-constant-size-change.svg: Added.
+
+2010-10-15  Dirk Schulze  <krit at webkit.org>
+
         Unreviewed rebaseline of Snow Leopard.
 
         Moved current results for SVGFEConvolveMatrixElement to mac-leopard.
diff --git a/LayoutTests/platform/mac/svg/custom/repaint-on-constant-size-change-expected.checksum b/LayoutTests/platform/mac/svg/custom/repaint-on-constant-size-change-expected.checksum
new file mode 100644
index 0000000..ee50194
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/repaint-on-constant-size-change-expected.checksum
@@ -0,0 +1 @@
+8b74d2b70652f673e2adc2045f484369
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/custom/repaint-on-constant-size-change-expected.png b/LayoutTests/platform/mac/svg/custom/repaint-on-constant-size-change-expected.png
new file mode 100644
index 0000000..034c7e0
Binary files /dev/null and b/LayoutTests/platform/mac/svg/custom/repaint-on-constant-size-change-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/repaint-on-constant-size-change-expected.txt b/LayoutTests/platform/mac/svg/custom/repaint-on-constant-size-change-expected.txt
new file mode 100644
index 0000000..4165feb
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/custom/repaint-on-constant-size-change-expected.txt
@@ -0,0 +1,5 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 200x100
+    RenderSVGImage {image} at (0,0) size 200x100
diff --git a/LayoutTests/svg/custom/repaint-on-constant-size-change.svg b/LayoutTests/svg/custom/repaint-on-constant-size-change.svg
new file mode 100644
index 0000000..9ea2cd7
--- /dev/null
+++ b/LayoutTests/svg/custom/repaint-on-constant-size-change.svg
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 480 360">
+    <image externalResourcesRequired="true" onload="loadEventFired()" xlink:href="../../css2.1/support/swatch-green.png" x="0" y="0" width="200" height="100" />
+
+    <script>
+    function loadEventFired() {
+        var image = document.getElementsByTagName('image')[0];
+        image.onclick = function() {
+            window.setTimeout(function() {
+                // Show differences, makes it easier to spot the repaint rect changes
+                if (window.layoutTestController)
+                    layoutTestController.display();
+
+                image.setAttribute("x", 0);
+                image.setAttribute("y", 0);
+                image.setAttribute("width", 200);
+                image.setAttribute("height", 100);
+
+
+                if (window.layoutTestController)
+                    layoutTestController.notifyDone();
+            }, 0);
+        }
+
+        if (window.layoutTestController)
+            layoutTestController.waitUntilDone();
+
+        if (window.eventSender) {
+            eventSender.mouseMoveTo(100, 25);
+            eventSender.mouseDown();
+            eventSender.mouseUp();
+        }
+    }
+    </script>
+</svg>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 5fa574f..14cefd8 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,27 @@
+2010-10-15  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        carto.net Dock example redraws *way* too often
+        https://bugs.webkit.org/show_bug.cgi?id=16090
+
+        Setting the attributes x, y, width or height shouldn't cause a repaint if the image boundaries don't change.
+        Added updateFromElement() to RenderSVGImage that checks if the old boundaries match the new boundaries after
+        setting one of the attributes of above. Mark renderer for layout (and therefore repaint) if the boundaries
+        differ, do nothing if not.
+        Also added caching of the repaint rect to avoid multiple calculations.
+
+        Test: svg/custom/repaint-on-constant-size-change.svg
+
+        * rendering/RenderSVGImage.cpp:
+        (WebCore::RenderSVGImage::RenderSVGImage):
+        (WebCore::RenderSVGImage::layout): Update repaint rect on layout.
+        (WebCore::RenderSVGImage::updateFromElement): Check SVGImageElement for boundaries update.
+        * rendering/RenderSVGImage.h:
+        (WebCore::RenderSVGImage::repaintRectInLocalCoordinates): Return the cached repaint rect.
+        * svg/SVGImageElement.cpp:
+        (WebCore::SVGImageElement::svgAttributeChanged): Call updateFromElement() on changes to x, y, width or height.
+
 2010-10-15  Martin Robinson  <mrobinson at igalia.com>
 
         Build fix for GTK+.
diff --git a/WebCore/rendering/RenderSVGImage.cpp b/WebCore/rendering/RenderSVGImage.cpp
index a89a738..85eb3fa 100644
--- a/WebCore/rendering/RenderSVGImage.cpp
+++ b/WebCore/rendering/RenderSVGImage.cpp
@@ -47,6 +47,7 @@ namespace WebCore {
 
 RenderSVGImage::RenderSVGImage(SVGImageElement* impl)
     : RenderSVGModelObject(impl)
+    , m_updateCachedRepaintRect(true)
     , m_needsTransformUpdate(true)
     , m_imageResource(RenderImageResource::create())
 {
@@ -62,36 +63,45 @@ void RenderSVGImage::layout()
 {
     ASSERT(needsLayout());
 
-    LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
+    LayoutRepainter repainter(*this, checkForRepaintDuringLayout() && selfNeedsLayout());
     SVGImageElement* image = static_cast<SVGImageElement*>(node());
 
-    bool updateCachedBoundariesInParents = false;
+    bool transformOrBoundariesUpdate = m_needsTransformUpdate || m_updateCachedRepaintRect;
     if (m_needsTransformUpdate) {
         m_localTransform = image->animatedLocalTransform();
         m_needsTransformUpdate = false;
-        updateCachedBoundariesInParents = true;
     }
 
-    // FIXME: Optimize caching the repaint rects.
-    FloatRect oldBoundaries = m_localBounds;
-    m_localBounds = FloatRect(image->x().value(image), image->y().value(image), image->width().value(image), image->height().value(image));
-    m_cachedLocalRepaintRect = FloatRect();
-
-    if (!updateCachedBoundariesInParents)
-        updateCachedBoundariesInParents = oldBoundaries != m_localBounds;
+    if (m_updateCachedRepaintRect) {
+        m_repaintBoundingBox = m_objectBoundingBox;
+        SVGRenderSupport::intersectRepaintRectWithResources(this, m_repaintBoundingBox);
+        m_updateCachedRepaintRect = false;
+    }
 
     // Invalidate all resources of this client if our layout changed.
     if (m_everHadLayout && selfNeedsLayout())
         SVGResourcesCache::clientLayoutChanged(this);
 
     // If our bounds changed, notify the parents.
-    if (updateCachedBoundariesInParents)
+    if (transformOrBoundariesUpdate)
         RenderSVGModelObject::setNeedsBoundariesUpdate();
 
     repainter.repaintAfterLayout();
     setNeedsLayout(false);
 }
 
+void RenderSVGImage::updateFromElement()
+{
+    SVGImageElement* image = static_cast<SVGImageElement*>(node());
+
+    FloatRect oldBoundaries = m_objectBoundingBox;
+    m_objectBoundingBox = FloatRect(image->x().value(image), image->y().value(image), image->width().value(image), image->height().value(image));
+    if (m_objectBoundingBox != oldBoundaries) {
+        m_updateCachedRepaintRect = true;
+        setNeedsLayout(true);
+    }
+}
+
 void RenderSVGImage::paint(PaintInfo& paintInfo, int, int)
 {
     if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN || !m_imageResource->hasImage())
@@ -112,7 +122,7 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, int, int)
 
             if (SVGRenderSupport::prepareToRenderSVGContent(this, childPaintInfo)) {
                 Image* image = m_imageResource->image();
-                FloatRect destRect = m_localBounds;
+                FloatRect destRect = m_objectBoundingBox;
                 FloatRect srcRect(0, 0, image->width(), image->height());
 
                 SVGImageElement* imageElement = static_cast<SVGImageElement*>(node());
@@ -148,7 +158,7 @@ bool RenderSVGImage::nodeAtFloatPoint(const HitTestRequest& request, HitTestResu
             return false;
 
         if (hitRules.canHitFill) {
-            if (m_localBounds.contains(localPoint)) {
+            if (m_objectBoundingBox.contains(localPoint)) {
                 updateHitTestResult(result, roundedIntPoint(localPoint));
                 return true;
             }
@@ -158,18 +168,6 @@ bool RenderSVGImage::nodeAtFloatPoint(const HitTestRequest& request, HitTestResu
     return false;
 }
 
-FloatRect RenderSVGImage::repaintRectInLocalCoordinates() const
-{
-    // If we already have a cached repaint rect, return that
-    if (!m_cachedLocalRepaintRect.isEmpty())
-        return m_cachedLocalRepaintRect;
-
-    m_cachedLocalRepaintRect = m_localBounds;
-    SVGRenderSupport::intersectRepaintRectWithResources(this, m_cachedLocalRepaintRect);
-
-    return m_cachedLocalRepaintRect;
-}
-
 void RenderSVGImage::imageChanged(WrappedImagePtr, const IntRect*)
 {
     // The image resource defaults to nullImage until the resource arrives.
diff --git a/WebCore/rendering/RenderSVGImage.h b/WebCore/rendering/RenderSVGImage.h
index da94568..485d6ab 100644
--- a/WebCore/rendering/RenderSVGImage.h
+++ b/WebCore/rendering/RenderSVGImage.h
@@ -42,6 +42,7 @@ public:
     virtual ~RenderSVGImage();
 
     virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; }
+    virtual void updateFromElement();
 
     RenderImageResource* imageResource() { return m_imageResource.get(); }
     const RenderImageResource* imageResource() const { return m_imageResource.get(); }
@@ -52,9 +53,9 @@ private:
 
     virtual const AffineTransform& localToParentTransform() const { return m_localTransform; }
 
-    virtual FloatRect objectBoundingBox() const { return m_localBounds; }
-    virtual FloatRect strokeBoundingBox() const { return m_localBounds; }
-    virtual FloatRect repaintRectInLocalCoordinates() const;
+    virtual FloatRect objectBoundingBox() const { return m_objectBoundingBox; }
+    virtual FloatRect strokeBoundingBox() const { return m_objectBoundingBox; }
+    virtual FloatRect repaintRectInLocalCoordinates() const { return m_repaintBoundingBox; }
 
     virtual void addFocusRingRects(Vector<IntRect>&, int tx, int ty);
 
@@ -69,10 +70,11 @@ private:
 
     virtual AffineTransform localTransform() const { return m_localTransform; }
 
+    bool m_updateCachedRepaintRect : 1;
     bool m_needsTransformUpdate : 1;
     AffineTransform m_localTransform;
-    FloatRect m_localBounds;
-    mutable FloatRect m_cachedLocalRepaintRect;
+    FloatRect m_objectBoundingBox;
+    FloatRect m_repaintBoundingBox;
     OwnPtr<RenderImageResource> m_imageResource;
 };
 
diff --git a/WebCore/svg/SVGImageElement.cpp b/WebCore/svg/SVGImageElement.cpp
index f6fa013..fcfa54f 100644
--- a/WebCore/svg/SVGImageElement.cpp
+++ b/WebCore/svg/SVGImageElement.cpp
@@ -108,8 +108,13 @@ void SVGImageElement::svgAttributeChanged(const QualifiedName& attrName)
         return;
     }
 
-    if (isLengthAttribute
-        || attrName == SVGNames::preserveAspectRatioAttr
+    if (isLengthAttribute) {
+        renderer->updateFromElement();
+        RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer, false);
+        return;
+    }
+
+    if (attrName == SVGNames::preserveAspectRatioAttr
         || SVGTests::isKnownAttribute(attrName)
         || SVGLangSpace::isKnownAttribute(attrName)
         || SVGExternalResourcesRequired::isKnownAttribute(attrName))

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list