2010-01-15 Oliver Hunt <oliver@apple.com>
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jan 2010 12:25:29 +0000 (12:25 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jan 2010 12:25:29 +0000 (12:25 +0000)
        Reviewed by Nikolas Zimmermann.

        Bad DOM performance in large SVG files
        https://bugs.webkit.org/show_bug.cgi?id=30055

        Add an early return when we go to paint a RenderPath that
        isn't in the current clip.

        * rendering/RenderPath.cpp:
        (WebCore::RenderPath::paint):

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

WebCore/ChangeLog
WebCore/rendering/RenderPath.cpp

index d75031f..f4b41d4 100644 (file)
@@ -1,3 +1,16 @@
+2010-01-15  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Nikolas Zimmermann.
+
+        Bad DOM performance in large SVG files
+        https://bugs.webkit.org/show_bug.cgi?id=30055
+
+        Add an early return when we go to paint a RenderPath that
+        isn't in the current clip.
+
+        * rendering/RenderPath.cpp:
+        (WebCore::RenderPath::paint):
+
 2010-01-15  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
 
         Reviewed by Antti Koivisto.
index 86d280b..81cddfa 100644 (file)
@@ -215,32 +215,40 @@ void RenderPath::paint(PaintInfo& paintInfo, int, int)
 {
     if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN || m_path.isEmpty())
         return;
-            
-    paintInfo.context->save();
-    paintInfo.context->concatCTM(localToParentTransform());
+
+    PaintInfo childPaintInfo(paintInfo);
+    childPaintInfo.context->save();
+    applyTransformToPaintInfo(childPaintInfo, m_localTransform);
+    FloatRect boundingBox = repaintRectInLocalCoordinates();
+    // FIXME: The empty rect check is to deal with incorrect initial clip in renderSubtreeToImage
+    // unfortunately fixing that problem is fairly complex unless we were willing to just futz the
+    // rect to something "close enough"
+    if (!boundingBox.intersects(childPaintInfo.rect) && !childPaintInfo.rect.isEmpty()) {
+        childPaintInfo.context->restore();
+        return;
+    }
 
     SVGResourceFilter* filter = 0;
 
-    FloatRect boundingBox = repaintRectInLocalCoordinates();
-    if (paintInfo.phase == PaintPhaseForeground) {
-        PaintInfo savedInfo(paintInfo);
+    if (childPaintInfo.phase == PaintPhaseForeground) {
+        PaintInfo savedInfo(childPaintInfo);
 
-        if (prepareToRenderSVGContent(this, paintInfo, boundingBox, filter)) {
+        if (prepareToRenderSVGContent(this, childPaintInfo, boundingBox, filter)) {
             if (style()->svgStyle()->shapeRendering() == SR_CRISPEDGES)
-                paintInfo.context->setShouldAntialias(false);
-            fillAndStrokePath(m_path, paintInfo.context, style(), this);
+                childPaintInfo.context->setShouldAntialias(false);
+            fillAndStrokePath(m_path, childPaintInfo.context, style(), this);
 
             if (static_cast<SVGStyledElement*>(node())->supportsMarkers())
-                m_markerLayoutInfo.drawMarkers(paintInfo);
+                m_markerLayoutInfo.drawMarkers(childPaintInfo);
         }
-        finishRenderSVGContent(this, paintInfo, filter, savedInfo.context);
+        finishRenderSVGContent(this, childPaintInfo, filter, savedInfo.context);
     }
 
-    if ((paintInfo.phase == PaintPhaseOutline || paintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth())
-        paintOutline(paintInfo.context, static_cast<int>(boundingBox.x()), static_cast<int>(boundingBox.y()),
+    if ((childPaintInfo.phase == PaintPhaseOutline || childPaintInfo.phase == PaintPhaseSelfOutline) && style()->outlineWidth())
+        paintOutline(childPaintInfo.context, static_cast<int>(boundingBox.x()), static_cast<int>(boundingBox.y()),
             static_cast<int>(boundingBox.width()), static_cast<int>(boundingBox.height()), style());
     
-    paintInfo.context->restore();
+    childPaintInfo.context->restore();
 }
 
 // This method is called from inside paintOutline() since we call paintOutline()