Reviewed by David Hyatt.

        Split out objectBoundingBox and repaintRectInLocalCoordinates from relativeBBox
        in preparation for simplifying (and fixing) repaint logic in the SVG rendering tree.
        https://bugs.webkit.org/show_bug.cgi?id=25224

        objectBoundingBox() matches the SVG 1.1 concept of a "bounding box"

        repaintRectInLocalCoordinates() should return the a rect covering all painted content.
        However, repaintRectInLocalCoordinates() still only returns the "stroke bounding box"
        in this patch.  In a future patch, repaintRectInLocalCoordinates will be fixed to return
        a rect covering all painted content.  In order to avoid changing several hundred layout test results, I've left
        the behavior as-is for now.  The returned rect is used by various repaintRectInLocalCoordinates
        implementations and sometimes adjusted to include all painted content, but not always, and
        the places where the adjustments are made are sometimes wrong.  Again, will be fixed in
        an upcoming patch.

        This patch discovered a bug in Font::drawTextUsingSVGFont, which is probably causing
        bounding-box relative gradients on SVGFont glyphs to not paint correctly.
        I chose not to try and fix the bug in this patch and instead left a FIXME.

        This patch also discovered that at least tspan.getBBox() is broken.  This
        along with the foreignObject.getBBox() change will be tested (and fixed) in a
        later patch.  https://bugs.webkit.org/show_bug.cgi?id=25225

        No change in behavior (besides the above mentioned foreignObject.getBBox()), thus no tests.

        * rendering/RenderForeignObject.cpp:
        (WebCore::RenderForeignObject::objectBoundingBox): this is a behavior improvement for getBBox() test case coming in a later patch
        (WebCore::RenderForeignObject::repaintRectInLocalCoordinates): only really used for layout test results, might some day be used for repaint.
        * rendering/RenderForeignObject.h:
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::objectBoundingBox): new methods, ASSERT if used but not implemented.
        (WebCore::RenderObject::repaintRectInLocalCoordinates):
        * rendering/RenderObject.h:
        * rendering/RenderPath.cpp:
        (WebCore::RenderPath::objectBoundingBox):
        (WebCore::RenderPath::repaintRectInLocalCoordinates):
        (WebCore::RenderPath::clippedOverflowRectForRepaint):
        (WebCore::RenderPath::lineHeight):
        (WebCore::RenderPath::baselinePosition):
        (WebCore::RenderPath::paint):
        (WebCore::RenderPath::addFocusRingRects):
        * rendering/RenderPath.h:
        * rendering/RenderSVGContainer.cpp:
        (WebCore::RenderSVGContainer::paint):
        (WebCore::RenderSVGContainer::objectBoundingBox):
        (WebCore::RenderSVGContainer::repaintRectInLocalCoordinates):
        * rendering/RenderSVGContainer.h:
        * rendering/RenderSVGGradientStop.h:
        (WebCore::RenderSVGGradientStop::objectBoundingBox):
        (WebCore::RenderSVGGradientStop::repaintRectInLocalCoordinates):
        * rendering/RenderSVGHiddenContainer.cpp:
        (WebCore::RenderSVGHiddenContainer::objectBoundingBox):
        (WebCore::RenderSVGHiddenContainer::repaintRectInLocalCoordinates):
        * rendering/RenderSVGHiddenContainer.h:
        * rendering/RenderSVGImage.cpp:
        (WebCore::RenderSVGImage::objectBoundingBox):
        (WebCore::RenderSVGImage::repaintRectInLocalCoordinates):
        (WebCore::RenderSVGImage::calculateAbsoluteBounds):
        (WebCore::RenderSVGImage::addFocusRingRects):
        * rendering/RenderSVGImage.h:
        * rendering/RenderSVGRoot.cpp:
        (WebCore::RenderSVGRoot::paint):
        (WebCore::RenderSVGRoot::objectBoundingBox):
        (WebCore::RenderSVGRoot::repaintRectInLocalCoordinates):
        * rendering/RenderSVGRoot.h:
        * rendering/RenderSVGTSpan.h:
        (WebCore::RenderSVGTSpan::objectBoundingBox):
        (WebCore::RenderSVGTSpan::repaintRectInLocalCoordinates):
        * rendering/RenderSVGText.cpp:
        (WebCore::RenderSVGText::clippedOverflowRectForRepaint):
        (WebCore::RenderSVGText::absoluteRects):
        (WebCore::RenderSVGText::absoluteQuads):
        (WebCore::RenderSVGText::objectBoundingBox):
        (WebCore::RenderSVGText::repaintRectInLocalCoordinates):
        * rendering/RenderSVGText.h:
        * rendering/RenderSVGViewportContainer.cpp:
        (WebCore::RenderSVGViewportContainer::viewportTransform):
        * rendering/SVGRenderSupport.cpp:
        (WebCore::computeContainerBoundingBox):
        * rendering/SVGRenderSupport.h:
        * rendering/SVGRenderTreeAsText.cpp:
        (WebCore::operator<<):
        * svg/SVGFont.cpp:
        (WebCore::Font::drawTextUsingSVGFont):
        * svg/SVGLocatable.cpp:
        (WebCore::SVGLocatable::getBBox):
        * svg/SVGPatternElement.cpp:
        (WebCore::SVGPatternElement::buildPattern):
        * svg/graphics/SVGPaintServerGradient.cpp:
        (WebCore::createMaskAndSwapContextForTextGradient):
        (WebCore::clipToTextMask):
        (WebCore::SVGPaintServerGradient::setup):
        * svg/graphics/SVGPaintServerPattern.cpp:
        (WebCore::SVGPaintServerPattern::setup):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@42578 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/rendering/SVGRenderSupport.cpp b/WebCore/rendering/SVGRenderSupport.cpp
index dd154c7..d73e456 100644
--- a/WebCore/rendering/SVGRenderSupport.cpp
+++ b/WebCore/rendering/SVGRenderSupport.cpp
@@ -2,6 +2,7 @@
  * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org>
  *           (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
  *           (C) 2007 Eric Seidel <eric@webkit.org>
+ * Copyright (C) 2009 Google, Inc.  All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -174,6 +175,25 @@
         size.setHeight(viewHeight);
 }
 
+FloatRect computeContainerBoundingBox(const RenderObject* container, bool includeAllPaintedContent)
+{
+    FloatRect boundingBox;
+
+    RenderObject* current = container->firstChild();
+    for (; current != 0; current = current->nextSibling()) {
+        FloatRect childBBox = includeAllPaintedContent ? current->repaintRectInLocalCoordinates() : current->objectBoundingBox();
+        FloatRect childBBoxInLocalCoords = current->localTransform().mapRect(childBBox);
+
+        // <svg> elements may a viewBox transform as well
+        if (current->isSVGContainer())
+            childBBoxInLocalCoords = static_cast<RenderSVGContainer*>(current)->viewportTransform().mapRect(childBBoxInLocalCoords);
+
+        boundingBox.unite(childBBoxInLocalCoords);
+    }
+
+    return boundingBox;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SVG)