Commit abec5eed authored by eric@webkit.org's avatar eric@webkit.org

Reviewed by Simon Fraser.

        Move more code into SVGRenderBase
        https://bugs.webkit.org/show_bug.cgi?id=25532

        clippedOverflowRectForRepaint, computeRectForRepaint and mapLocalToContainer
        are now all shared via SVGRenderBase.

        RenderForeignObject should also be sharing this code, but I've left it
        alone for now, as changing that would likely cause test changes.

        No test changes.  It's possible that transformed <svg:image> elements will
        now show up with better metrics in the inspector.

        * rendering/RenderSVGImage.cpp:
        (WebCore::RenderSVGImage::clippedOverflowRectForRepaint):
        (WebCore::RenderSVGImage::computeRectForRepaint):
        (WebCore::RenderSVGImage::mapLocalToContainer):
        * rendering/RenderSVGImage.h:
        * rendering/RenderSVGModelObject.cpp:
        (WebCore::RenderSVGModelObject::clippedOverflowRectForRepaint):
        (WebCore::RenderSVGModelObject::computeRectForRepaint):
        (WebCore::RenderSVGModelObject::mapLocalToContainer):
        * rendering/RenderSVGText.cpp:
        (WebCore::RenderSVGText::clippedOverflowRectForRepaint):
        (WebCore::RenderSVGText::computeRectForRepaint):
        (WebCore::RenderSVGText::mapLocalToContainer):
        * rendering/SVGRenderSupport.cpp:
        (WebCore::SVGRenderBase::clippedOverflowRectForRepaint):
        (WebCore::SVGRenderBase::computeRectForRepaint):
        (WebCore::SVGRenderBase::mapLocalToContainer):
        * rendering/SVGRenderSupport.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@43210 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f5ef91cf
2009-05-03 Eric Seidel <eric@webkit.org>
Reviewed by Simon Fraser.
Move more code into SVGRenderBase
https://bugs.webkit.org/show_bug.cgi?id=25532
clippedOverflowRectForRepaint, computeRectForRepaint and mapLocalToContainer
are now all shared via SVGRenderBase.
RenderForeignObject should also be sharing this code, but I've left it
alone for now, as changing that would likely cause test changes.
No test changes. It's possible that transformed <svg:image> elements will
now show up with better metrics in the inspector.
* rendering/RenderSVGImage.cpp:
(WebCore::RenderSVGImage::clippedOverflowRectForRepaint):
(WebCore::RenderSVGImage::computeRectForRepaint):
(WebCore::RenderSVGImage::mapLocalToContainer):
* rendering/RenderSVGImage.h:
* rendering/RenderSVGModelObject.cpp:
(WebCore::RenderSVGModelObject::clippedOverflowRectForRepaint):
(WebCore::RenderSVGModelObject::computeRectForRepaint):
(WebCore::RenderSVGModelObject::mapLocalToContainer):
* rendering/RenderSVGText.cpp:
(WebCore::RenderSVGText::clippedOverflowRectForRepaint):
(WebCore::RenderSVGText::computeRectForRepaint):
(WebCore::RenderSVGText::mapLocalToContainer):
* rendering/SVGRenderSupport.cpp:
(WebCore::SVGRenderBase::clippedOverflowRectForRepaint):
(WebCore::SVGRenderBase::computeRectForRepaint):
(WebCore::SVGRenderBase::mapLocalToContainer):
* rendering/SVGRenderSupport.h:
2009-05-03 Eric Seidel <eric@webkit.org>
Reviewed by Simon Fraser.
......@@ -239,22 +239,17 @@ void RenderSVGImage::imageChanged(WrappedImagePtr image, const IntRect* rect)
IntRect RenderSVGImage::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer)
{
// Return early for any cases where we don't actually paint
if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent())
return IntRect();
// Pass our local paint rect to computeRectForRepaint() which will
// map to parent coords and recurse up the parent chain.
IntRect repaintRect = enclosingIntRect(repaintRectInLocalCoordinates());
computeRectForRepaint(repaintContainer, repaintRect);
return repaintRect;
return SVGRenderBase::clippedOverflowRectForRepaint(this, repaintContainer);
}
void RenderSVGImage::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed)
{
// Translate to coords in our parent renderer, and then call computeRectForRepaint on our parent
repaintRect = localToParentTransform().mapRect(repaintRect);
parent()->computeRectForRepaint(repaintContainer, repaintRect, fixed);
SVGRenderBase::computeRectForRepaint(this, repaintContainer, repaintRect, fixed);
}
void RenderSVGImage::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed , bool useTransforms, TransformState& transformState) const
{
SVGRenderBase::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState);
}
void RenderSVGImage::addFocusRingRects(GraphicsContext* graphicsContext, int, int)
......
......@@ -50,7 +50,9 @@ namespace WebCore {
virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false);
virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&) const;
virtual void absoluteRects(Vector<IntRect>&, int tx, int ty);
virtual void absoluteQuads(Vector<FloatQuad>&);
virtual void addFocusRingRects(GraphicsContext*, int tx, int ty);
......
......@@ -37,7 +37,6 @@
#include "RenderLayer.h"
#include "RenderView.h"
#include "SVGStyledElement.h"
#include "TransformState.h"
#if ENABLE(SVG_FILTERS)
#include "SVGResourceFilter.h"
......@@ -52,38 +51,22 @@ RenderSVGModelObject::RenderSVGModelObject(SVGStyledElement* node)
IntRect RenderSVGModelObject::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer)
{
// Return early for any cases where we don't actually paint
if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent())
return IntRect();
// Pass our local paint rect to computeRectForRepaint() which will
// map to parent coords and recurse up the parent chain.
IntRect repaintRect = enclosingIntRect(repaintRectInLocalCoordinates());
computeRectForRepaint(repaintContainer, repaintRect);
return repaintRect;
return SVGRenderBase::clippedOverflowRectForRepaint(this, repaintContainer);
}
void RenderSVGModelObject::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed)
{
// Translate to coords in our parent renderer, and then call computeRectForRepaint on our parent
repaintRect = localToParentTransform().mapRect(repaintRect);
parent()->computeRectForRepaint(repaintContainer, repaintRect, fixed);
SVGRenderBase::computeRectForRepaint(this, repaintContainer, repaintRect, fixed);
}
void RenderSVGModelObject::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed , bool useTransforms, TransformState& transformState) const
{
ASSERT(!fixed); // We should have no fixed content in the SVG rendering tree.
// FIXME: If we don't respect useTransforms we break SVG text rendering.
// Seems RenderSVGInlineText has some own broken translation hacks which depend useTransforms=false
// This should instead be ASSERT(useTransforms) once we fix RenderSVGInlineText
if (useTransforms)
transformState.applyTransform(localToParentTransform());
parent()->mapLocalToContainer(repaintContainer, fixed, useTransforms, transformState);
SVGRenderBase::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState);
}
// Copied from RenderBox, this method likely requires further refactoring to work easily for both SVG and CSS Box Model content.
// FIXME: This may also need to move into SVGRenderBase as the RenderBox version depends
// on borderBoundingBox() which SVG RenderBox subclases (like SVGRenderBlock) do not implement.
IntRect RenderSVGModelObject::outlineBoundsForRepaint(RenderBoxModelObject* repaintContainer) const
{
IntRect box = enclosingIntRect(repaintRectInLocalCoordinates());
......
......@@ -43,7 +43,6 @@
#include "SVGTransformList.h"
#include "SVGURIReference.h"
#include "SimpleFontData.h"
#include "TransformState.h"
namespace WebCore {
......@@ -54,35 +53,17 @@ RenderSVGText::RenderSVGText(SVGTextElement* node)
IntRect RenderSVGText::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer)
{
// Return early for any cases where we don't actually paint
if (style()->visibility() != VISIBLE && !enclosingLayer()->hasVisibleContent())
return IntRect();
// Pass our local paint rect to computeRectForRepaint() which will
// map to parent coords and recurse up the parent chain.
IntRect repaintRect = enclosingIntRect(repaintRectInLocalCoordinates());
computeRectForRepaint(repaintContainer, repaintRect);
return repaintRect;
return SVGRenderBase::clippedOverflowRectForRepaint(this, repaintContainer);
}
void RenderSVGText::computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed)
{
// Translate to coords in our parent renderer, and then call computeRectForRepaint on our parent
repaintRect = localToParentTransform().mapRect(repaintRect);
parent()->computeRectForRepaint(repaintContainer, repaintRect, fixed);
SVGRenderBase::computeRectForRepaint(this, repaintContainer, repaintRect, fixed);
}
void RenderSVGText::mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool fixed , bool useTransforms, TransformState& transformState) const
{
ASSERT(!fixed); // We should have no fixed content in the SVG rendering tree.
// FIXME: If we don't respect useTransforms we break SVG text rendering.
// Seems RenderSVGInlineText has some own broken translation hacks which depend useTransforms=false
// This should instead be ASSERT(useTransforms) once we fix RenderSVGInlineText
if (useTransforms)
transformState.applyTransform(localToParentTransform());
parent()->mapLocalToContainer(repaintContainer, fixed, useTransforms, transformState);
SVGRenderBase::mapLocalToContainer(this, repaintContainer, fixed, useTransforms, transformState);
}
bool RenderSVGText::calculateLocalTransform()
......
......@@ -26,7 +26,6 @@
#if ENABLE(SVG)
#include "SVGRenderSupport.h"
#include "TransformationMatrix.h"
#include "ImageBuffer.h"
#include "RenderObject.h"
#include "RenderSVGContainer.h"
......@@ -36,10 +35,45 @@
#include "SVGResourceMasker.h"
#include "SVGStyledElement.h"
#include "SVGURIReference.h"
#include "TransformState.h"
#include "TransformationMatrix.h"
#include <wtf/UnusedParam.h>
namespace WebCore {
IntRect SVGRenderBase::clippedOverflowRectForRepaint(RenderObject* object, RenderBoxModelObject* repaintContainer)
{
// Return early for any cases where we don't actually paint
if (object->style()->visibility() != VISIBLE && !object->enclosingLayer()->hasVisibleContent())
return IntRect();
// Pass our local paint rect to computeRectForRepaint() which will
// map to parent coords and recurse up the parent chain.
IntRect repaintRect = enclosingIntRect(object->repaintRectInLocalCoordinates());
object->computeRectForRepaint(repaintContainer, repaintRect);
return repaintRect;
}
void SVGRenderBase::computeRectForRepaint(RenderObject* object, RenderBoxModelObject* repaintContainer, IntRect& repaintRect, bool fixed)
{
// Translate to coords in our parent renderer, and then call computeRectForRepaint on our parent
repaintRect = object->localToParentTransform().mapRect(repaintRect);
object->parent()->computeRectForRepaint(repaintContainer, repaintRect, fixed);
}
void SVGRenderBase::mapLocalToContainer(const RenderObject* object, RenderBoxModelObject* repaintContainer, bool fixed , bool useTransforms, TransformState& transformState)
{
ASSERT(!fixed); // We should have no fixed content in the SVG rendering tree.
// FIXME: If we don't respect useTransforms we break SVG text rendering.
// Seems RenderSVGInlineText has some own broken translation hacks which depend useTransforms=false
// This should instead be ASSERT(useTransforms) once we fix RenderSVGInlineText
if (useTransforms)
transformState.applyTransform(object->localToParentTransform());
object->parent()->mapLocalToContainer(repaintContainer, fixed, useTransforms, transformState);
}
void SVGRenderBase::prepareToRenderSVGContent(RenderObject* object, RenderObject::PaintInfo& paintInfo, const FloatRect& boundingBox, SVGResourceFilter*& filter, SVGResourceFilter* rootFilter)
{
#if !ENABLE(SVG_FILTERS)
......
......@@ -45,6 +45,11 @@ namespace WebCore {
static void finishRenderSVGContent(RenderObject*, RenderObject::PaintInfo&, const FloatRect& boundingBox, SVGResourceFilter*&, GraphicsContext* savedContext);
protected:
static IntRect clippedOverflowRectForRepaint(RenderObject*, RenderBoxModelObject* repaintContainer);
static void computeRectForRepaint(RenderObject*, RenderBoxModelObject* repaintContainer, IntRect&, bool fixed);
static void mapLocalToContainer(const RenderObject*, RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&);
// Used to share the "walk all the children" logic between objectBoundingBox
// and repaintRectInLocalCoordinates in RenderSVGRoot and RenderSVGContainer
static FloatRect computeContainerBoundingBox(const RenderObject* container, bool includeAllPaintedContent);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment