SVGRenderingContext should wrap a RenderElement.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Oct 2013 19:36:55 +0000 (19:36 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Oct 2013 19:36:55 +0000 (19:36 +0000)
<https://webkit.org/b/123283>

The SVG rendering context class is never used with text renderers
so we can have it wrap a RenderElement for tighter code.

Also renamed SVGRenderingContext::m_object to m_renderer.

Reviewed by Antti Koivisto.

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGContainer.cpp
Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp
Source/WebCore/rendering/svg/RenderSVGImage.cpp
Source/WebCore/rendering/svg/RenderSVGRoot.cpp
Source/WebCore/rendering/svg/RenderSVGShape.cpp
Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp
Source/WebCore/rendering/svg/SVGRenderingContext.cpp
Source/WebCore/rendering/svg/SVGRenderingContext.h
Source/WebCore/rendering/svg/SVGRootInlineBox.cpp

index 3282fbf..b4b8b6c 100644 (file)
@@ -1,3 +1,15 @@
+2013-10-24  Andreas Kling  <akling@apple.com>
+
+        SVGRenderingContext should wrap a RenderElement.
+        <https://webkit.org/b/123283>
+
+        The SVG rendering context class is never used with text renderers
+        so we can have it wrap a RenderElement for tighter code.
+
+        Also renamed SVGRenderingContext::m_object to m_renderer.
+
+        Reviewed by Antti Koivisto.
+
 2013-10-24  Santosh Mahto  <santosh.ma@samsung.com>
 
         [contenteditable] Content after non-editable element disappears when merging lines using backspace
index 0580005..595c2aa 100644 (file)
@@ -133,7 +133,7 @@ void RenderSVGContainer::paint(PaintInfo& paintInfo, const LayoutPoint&)
         SVGRenderingContext renderingContext;
         bool continueRendering = true;
         if (childPaintInfo.phase == PaintPhaseForeground) {
-            renderingContext.prepareToRenderSVGContent(this, childPaintInfo);
+            renderingContext.prepareToRenderSVGContent(*this, childPaintInfo);
             continueRendering = renderingContext.isRenderingPrepared();
         }
 
index e5d8bc3..f27e7cd 100644 (file)
@@ -70,7 +70,7 @@ void RenderSVGForeignObject::paint(PaintInfo& paintInfo, const LayoutPoint&)
     SVGRenderingContext renderingContext;
     bool continueRendering = true;
     if (paintInfo.phase == PaintPhaseForeground) {
-        renderingContext.prepareToRenderSVGContent(this, childPaintInfo);
+        renderingContext.prepareToRenderSVGContent(*this, childPaintInfo);
         continueRendering = renderingContext.isRenderingPrepared();
     }
 
index 147fdef..cdf9daa 100644 (file)
@@ -134,7 +134,7 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, const LayoutPoint&)
         childPaintInfo.applyTransform(m_localTransform);
 
         if (childPaintInfo.phase == PaintPhaseForeground) {
-            SVGRenderingContext renderingContext(this, childPaintInfo);
+            SVGRenderingContext renderingContext(*this, childPaintInfo);
 
             if (renderingContext.isRenderingPrepared()) {
                 if (style()->svgStyle()->bufferedRendering() == BR_STATIC  && renderingContext.bufferForeground(m_bufferedForeground))
index 73bbe00..8be3a07 100644 (file)
@@ -287,7 +287,7 @@ void RenderSVGRoot::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paint
         SVGRenderingContext renderingContext;
         bool continueRendering = true;
         if (childPaintInfo.phase == PaintPhaseForeground) {
-            renderingContext.prepareToRenderSVGContent(this, childPaintInfo);
+            renderingContext.prepareToRenderSVGContent(*this, childPaintInfo);
             continueRendering = renderingContext.isRenderingPrepared();
         }
 
index f633e02..0f936b0 100644 (file)
@@ -280,7 +280,7 @@ void RenderSVGShape::paint(PaintInfo& paintInfo, const LayoutPoint&)
         childPaintInfo.applyTransform(m_localTransform);
 
         if (childPaintInfo.phase == PaintPhaseForeground) {
-            SVGRenderingContext renderingContext(this, childPaintInfo);
+            SVGRenderingContext renderingContext(*this, childPaintInfo);
 
             if (renderingContext.isRenderingPrepared()) {
                 const SVGRenderStyle* svgStyle = style()->svgStyle();
index 8d7101b..f29d0d7 100644 (file)
@@ -54,7 +54,7 @@ void SVGInlineFlowBox::paint(PaintInfo& paintInfo, const LayoutPoint&, LayoutUni
     ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
     ASSERT(!paintInfo.context->paintingDisabled());
 
-    SVGRenderingContext renderingContext(&renderer(), paintInfo, SVGRenderingContext::SaveGraphicsContext);
+    SVGRenderingContext renderingContext(renderer(), paintInfo, SVGRenderingContext::SaveGraphicsContext);
     if (renderingContext.isRenderingPrepared()) {
         for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
             if (child->isSVGInlineTextBox())
index be5b76e..85b4333 100644 (file)
@@ -56,12 +56,12 @@ SVGRenderingContext::~SVGRenderingContext()
     if (!(m_renderingFlags & ActionsNeeded))
         return;
 
-    ASSERT(m_object && m_paintInfo);
+    ASSERT(m_renderer && m_paintInfo);
 
 #if ENABLE(FILTERS)
     if (m_renderingFlags & EndFilterLayer) {
         ASSERT(m_filter);
-        m_filter->postApplyResource(m_object, m_paintInfo->context, ApplyToDefaultMode, 0, 0);
+        m_filter->postApplyResource(m_renderer, m_paintInfo->context, ApplyToDefaultMode, 0, 0);
         m_paintInfo->context = m_savedContext;
         m_paintInfo->rect = m_savedPaintRect;
     }
@@ -77,17 +77,15 @@ SVGRenderingContext::~SVGRenderingContext()
         m_paintInfo->context->restore();
 }
 
-void SVGRenderingContext::prepareToRenderSVGContent(RenderObject* object, PaintInfo& paintInfo, NeedsGraphicsContextSave needsGraphicsContextSave)
+void SVGRenderingContext::prepareToRenderSVGContent(RenderElement& renderer, PaintInfo& paintInfo, NeedsGraphicsContextSave needsGraphicsContextSave)
 {
-    ASSERT(object);
-
 #ifndef NDEBUG
     // This function must not be called twice!
     ASSERT(!(m_renderingFlags & PrepareToRenderSVGContentWasCalled));
     m_renderingFlags |= PrepareToRenderSVGContentWasCalled;
 #endif
 
-    m_object = object;
+    m_renderer = &renderer;
     m_paintInfo = &paintInfo;
 #if ENABLE(FILTERS)
     m_filter = 0;
@@ -99,18 +97,18 @@ void SVGRenderingContext::prepareToRenderSVGContent(RenderObject* object, PaintI
         m_renderingFlags |= RestoreGraphicsContext;
     }
 
-    RenderStyle* style = m_object->style();
+    RenderStyle* style = m_renderer->style();
     ASSERT(style);
 
     const SVGRenderStyle* svgStyle = style->svgStyle();
     ASSERT(svgStyle);
 
     // Setup transparency layers before setting up SVG resources!
-    bool isRenderingMask = isRenderingMaskImage(*m_object);
+    bool isRenderingMask = isRenderingMaskImage(*m_renderer);
     float opacity = isRenderingMask ? 1 : style->opacity();
     const ShadowData* shadow = svgStyle->shadow();
     if (opacity < 1 || shadow) {
-        FloatRect repaintRect = m_object->repaintRectInLocalCoordinates();
+        FloatRect repaintRect = m_renderer->repaintRectInLocalCoordinates();
 
         if (opacity < 1) {
             m_paintInfo->context->clip(repaintRect);
@@ -129,10 +127,10 @@ void SVGRenderingContext::prepareToRenderSVGContent(RenderObject* object, PaintI
     ClipPathOperation* clipPathOperation = style->clipPath();
     if (clipPathOperation && clipPathOperation->type() == ClipPathOperation::SHAPE) {
         ShapeClipPathOperation* clipPath = static_cast<ShapeClipPathOperation*>(clipPathOperation);
-        m_paintInfo->context->clipPath(clipPath->path(object->objectBoundingBox()), clipPath->windRule());
+        m_paintInfo->context->clipPath(clipPath->path(renderer.objectBoundingBox()), clipPath->windRule());
     }
 
-    SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(m_object);
+    SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(m_renderer);
     if (!resources) {
 #if ENABLE(FILTERS)
         if (svgStyle->hasFilter())
@@ -144,14 +142,14 @@ void SVGRenderingContext::prepareToRenderSVGContent(RenderObject* object, PaintI
 
     if (!isRenderingMask) {
         if (RenderSVGResourceMasker* masker = resources->masker()) {
-            if (!masker->applyResource(m_object, style, m_paintInfo->context, ApplyToDefaultMode))
+            if (!masker->applyResource(m_renderer, style, m_paintInfo->context, ApplyToDefaultMode))
                 return;
         }
     }
 
     RenderSVGResourceClipper* clipper = resources->clipper();
     if (!clipPathOperation && clipper) {
-        if (!clipper->applyResource(m_object, style, m_paintInfo->context, ApplyToDefaultMode))
+        if (!clipper->applyResource(m_renderer, style, m_paintInfo->context, ApplyToDefaultMode))
             return;
     }
 
@@ -164,14 +162,14 @@ void SVGRenderingContext::prepareToRenderSVGContent(RenderObject* object, PaintI
             // Return with false here may mean that we don't need to draw the content
             // (because it was either drawn before or empty) but we still need to apply the filter.
             m_renderingFlags |= EndFilterLayer;
-            if (!m_filter->applyResource(m_object, style, m_paintInfo->context, ApplyToDefaultMode))
+            if (!m_filter->applyResource(m_renderer, style, m_paintInfo->context, ApplyToDefaultMode))
                 return;
 
             // Since we're caching the resulting bitmap and do not invalidate it on repaint rect
             // changes, we need to paint the whole filter region. Otherwise, elements not visible
             // at the time of the initial paint (due to scrolling, window size, etc.) will never
             // be drawn.
-            m_paintInfo->rect = IntRect(m_filter->drawingRegion(m_object));
+            m_paintInfo->rect = IntRect(m_filter->drawingRegion(m_renderer));
         }
     }
 #endif
@@ -333,8 +331,8 @@ void SVGRenderingContext::clear2DRotation(AffineTransform& transform)
 bool SVGRenderingContext::bufferForeground(OwnPtr<ImageBuffer>& imageBuffer)
 {
     ASSERT(m_paintInfo);
-    ASSERT(m_object->isSVGImage());
-    FloatRect boundingBox = m_object->objectBoundingBox();
+    ASSERT(m_renderer->isSVGImage());
+    FloatRect boundingBox = m_renderer->objectBoundingBox();
 
     // Invalidate an existing buffer if the scale is not correct.
     if (imageBuffer) {
@@ -352,7 +350,7 @@ bool SVGRenderingContext::bufferForeground(OwnPtr<ImageBuffer>& imageBuffer)
             bufferedRenderingContext->translate(-boundingBox.x(), -boundingBox.y());
             PaintInfo bufferedInfo(*m_paintInfo);
             bufferedInfo.context = bufferedRenderingContext;
-            toRenderSVGImage(m_object)->paintForeground(bufferedInfo);
+            toRenderSVGImage(m_renderer)->paintForeground(bufferedInfo);
         } else
             return false;
     }
index a5b538d..2da70cd 100644 (file)
@@ -48,22 +48,22 @@ public:
     // Does not start rendering.
     SVGRenderingContext()
         : m_renderingFlags(0)
-        , m_object(0)
-        , m_paintInfo(0)
-        , m_savedContext(0)
+        , m_renderer(nullptr)
+        , m_paintInfo(nullptr)
+        , m_savedContext(nullptr)
 #if ENABLE(FILTERS)
-        , m_filter(0)
+        , m_filter(nullptr)
 #endif
     {
     }
 
-    SVGRenderingContext(RenderObject* object, PaintInfo& paintinfo, NeedsGraphicsContextSave needsGraphicsContextSave = DontSaveGraphicsContext)
+    SVGRenderingContext(RenderElement& object, PaintInfo& paintinfo, NeedsGraphicsContextSave needsGraphicsContextSave = DontSaveGraphicsContext)
         : m_renderingFlags(0)
-        , m_object(0)
-        , m_paintInfo(0)
-        , m_savedContext(0)
+        , m_renderer(nullptr)
+        , m_paintInfo(nullptr)
+        , m_savedContext(nullptr)
 #if ENABLE(FILTERS)
-        , m_filter(0)
+        , m_filter(nullptr)
 #endif
     {
         prepareToRenderSVGContent(object, paintinfo, needsGraphicsContextSave);
@@ -73,7 +73,7 @@ public:
     ~SVGRenderingContext();
 
     // Used by all SVG renderers who apply clip/filter/etc. resources to the renderer content.
-    void prepareToRenderSVGContent(RenderObject*, PaintInfo&, NeedsGraphicsContextSave = DontSaveGraphicsContext);
+    void prepareToRenderSVGContent(RenderElement&, PaintInfo&, NeedsGraphicsContextSave = DontSaveGraphicsContext);
     bool isRenderingPrepared() const { return m_renderingFlags & RenderingPrepared; }
 
     static bool createImageBuffer(const FloatRect& paintRect, const AffineTransform& absoluteTransform, OwnPtr<ImageBuffer>&, ColorSpace, RenderingMode);
@@ -112,7 +112,7 @@ private:
     const static int ActionsNeeded = RestoreGraphicsContext | EndOpacityLayer | EndShadowLayer | EndFilterLayer;
 
     int m_renderingFlags;
-    RenderObject* m_object;
+    RenderElement* m_renderer;
     PaintInfo* m_paintInfo;
     GraphicsContext* m_savedContext;
     IntRect m_savedPaintRect;
index 4d796ca..039f229 100644 (file)
@@ -65,7 +65,7 @@ void SVGRootInlineBox::paint(PaintInfo& paintInfo, const LayoutPoint&, LayoutUni
         }
     }
 
-    SVGRenderingContext renderingContext(&renderSVGText(), paintInfo, SVGRenderingContext::SaveGraphicsContext);
+    SVGRenderingContext renderingContext(renderSVGText(), paintInfo, SVGRenderingContext::SaveGraphicsContext);
     if (renderingContext.isRenderingPrepared()) {
         for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
             if (child->isSVGInlineTextBox())