Move paint() to RenderElement
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 6 Oct 2013 22:55:54 +0000 (22:55 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 6 Oct 2013 22:55:54 +0000 (22:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=122371

Reviewed by Darin Adler.

RenderText does not paint itself (text is painted by line boxes). We can move paint() down
to RenderElement.

This also requires some type tightening elsewhere in the code.

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

34 files changed:
Source/WebCore/ChangeLog
Source/WebCore/rendering/InlineBox.cpp
Source/WebCore/rendering/InlineBox.h
Source/WebCore/rendering/InlineFlowBox.cpp
Source/WebCore/rendering/InlineTextBox.cpp
Source/WebCore/rendering/PaintInfo.h
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/RenderFieldset.cpp
Source/WebCore/rendering/RenderFrameSet.cpp
Source/WebCore/rendering/RenderLineBreak.h
Source/WebCore/rendering/RenderObject.cpp
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/RenderReplaced.cpp
Source/WebCore/rendering/RenderTable.cpp
Source/WebCore/rendering/RenderTableCell.cpp
Source/WebCore/rendering/RenderTableCol.h
Source/WebCore/rendering/RenderText.h
Source/WebCore/rendering/RenderView.cpp
Source/WebCore/rendering/RootInlineBox.cpp
Source/WebCore/rendering/svg/RenderSVGContainer.cpp
Source/WebCore/rendering/svg/RenderSVGGradientStop.h
Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp
Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp
Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp
Source/WebCore/rendering/svg/RenderSVGRoot.cpp
Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
Source/WebCore/rendering/svg/SVGRenderingContext.cpp
Source/WebCore/rendering/svg/SVGRenderingContext.h
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/svg/SVGUseElement.h
Source/WebCore/svg/graphics/filters/SVGFEImage.cpp

index a3668db..07dfe0b 100644 (file)
@@ -1,5 +1,17 @@
 2013-10-06  Antti Koivisto  <antti@apple.com>
 
+        Move paint() to RenderElement
+        https://bugs.webkit.org/show_bug.cgi?id=122371
+
+        Reviewed by Darin Adler.
+
+        RenderText does not paint itself (text is painted by line boxes). We can move paint() down
+        to RenderElement.
+        
+        This also requires some type tightening elsewhere in the code.
+
+2013-10-06  Antti Koivisto  <antti@apple.com>
+
         Don't try to dispatch resize events for SVG images
         https://bugs.webkit.org/show_bug.cgi?id=122410
 
index c5ff027..15df7e7 100644 (file)
@@ -226,12 +226,13 @@ void InlineBox::adjustPosition(float dx, float dy)
 
 void InlineBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit /* lineTop */, LayoutUnit /*lineBottom*/)
 {
-    if (!paintInfo.shouldPaintWithinRoot(&renderer()) || (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection))
+    RenderElement& renderer = toRenderElement(this->renderer());
+    if (!paintInfo.shouldPaintWithinRoot(renderer) || (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection))
         return;
 
     LayoutPoint childPoint = paintOffset;
-    if (parent()->renderer().style()->isFlippedBlocksWritingMode() && renderer().isBox()) // Faster than calling containingBlock().
-        childPoint = m_renderer.containingBlock()->flipForWritingModeForChild(&toRenderBox(renderer()), childPoint);
+    if (parent()->renderer().style()->isFlippedBlocksWritingMode() && renderer.isBox()) // Faster than calling containingBlock().
+        childPoint = m_renderer.containingBlock()->flipForWritingModeForChild(&toRenderBox(renderer), childPoint);
     
     // Paint all phases of replaced elements atomically, as though the replaced element established its
     // own stacking context.  (See Appendix E.2, section 6.4 on inline block/table elements in the CSS2.1
@@ -239,16 +240,16 @@ void InlineBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, Layo
     bool preservePhase = paintInfo.phase == PaintPhaseSelection || paintInfo.phase == PaintPhaseTextClip;
     PaintInfo info(paintInfo);
     info.phase = preservePhase ? paintInfo.phase : PaintPhaseBlockBackground;
-    m_renderer.paint(info, childPoint);
+    renderer.paint(info, childPoint);
     if (!preservePhase) {
         info.phase = PaintPhaseChildBlockBackgrounds;
-        m_renderer.paint(info, childPoint);
+        renderer.paint(info, childPoint);
         info.phase = PaintPhaseFloat;
-        m_renderer.paint(info, childPoint);
+        renderer.paint(info, childPoint);
         info.phase = PaintPhaseForeground;
-        m_renderer.paint(info, childPoint);
+        renderer.paint(info, childPoint);
         info.phase = PaintPhaseOutline;
-        m_renderer.paint(info, childPoint);
+        renderer.paint(info, childPoint);
     }
 }
 
index 63fc68b..f9d36b1 100644 (file)
@@ -181,6 +181,7 @@ public:
     InlineBox* nextLeafChildIgnoringLineBreak() const;
     InlineBox* prevLeafChildIgnoringLineBreak() const;
 
+    // FIXME: There should be a subclass that returns RenderElement. Plain InlineBox shouldn't be instantiated.
     RenderObject& renderer() const { return m_renderer; }
 
     InlineFlowBox* parent() const
index e0a5f10..4911f50 100644 (file)
@@ -1298,7 +1298,7 @@ static LayoutRect clipRectForNinePieceImageStrip(InlineFlowBox* box, const NineP
 
 void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
-    if (!paintInfo.shouldPaintWithinRoot(&renderer()) || renderer().style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground)
+    if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer().style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground)
         return;
 
     // Pixel snap background/border painting.
@@ -1372,7 +1372,7 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&
 
 void InlineFlowBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
-    if (!paintInfo.shouldPaintWithinRoot(&renderer()) || renderer().style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
+    if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer().style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
         return;
 
     // Pixel snap mask painting.
index ddcf6b6..cb52a9f 100644 (file)
@@ -518,8 +518,8 @@ static inline AffineTransform rotation(const FloatRect& boxRect, RotationDirecti
 
 void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit /*lineTop*/, LayoutUnit /*lineBottom*/)
 {
-    if (isLineBreak() || !paintInfo.shouldPaintWithinRoot(&renderer()) || renderer().style()->visibility() != VISIBLE ||
-        m_truncation == cFullTruncation || paintInfo.phase == PaintPhaseOutline || !m_len)
+    if (isLineBreak() || !paintInfo.shouldPaintWithinRoot(renderer()) || renderer().style()->visibility() != VISIBLE
+        || m_truncation == cFullTruncation || paintInfo.phase == PaintPhaseOutline || !m_len)
         return;
 
     ASSERT(paintInfo.phase != PaintPhaseSelfOutline && paintInfo.phase != PaintPhaseChildOutlines);
index 8224749..0aeb889 100644 (file)
@@ -80,9 +80,9 @@ struct PaintInfo {
         }
     }
 
-    bool shouldPaintWithinRoot(const RenderObject* renderer) const
+    bool shouldPaintWithinRoot(const RenderObject& renderer) const
     {
-        return !subtreePaintRoot || subtreePaintRoot == renderer;
+        return !subtreePaintRoot || subtreePaintRoot == &renderer;
     }
 
     bool forceBlackText() const { return paintBehavior & PaintBehaviorForceBlackText; }
index 62b78b0..f854f84 100644 (file)
@@ -2235,7 +2235,7 @@ void RenderBlock::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     // Our scrollbar widgets paint exactly when we tell them to, so that they work properly with
     // z-index.  We paint after we painted the background/border, so that the scrollbars will
     // sit above the background/border.
-    if (hasOverflowClip() && style()->visibility() == VISIBLE && (phase == PaintPhaseBlockBackground || phase == PaintPhaseChildBlockBackground) && paintInfo.shouldPaintWithinRoot(this) && !paintInfo.paintRootBackgroundOnly())
+    if (hasOverflowClip() && style()->visibility() == VISIBLE && (phase == PaintPhaseBlockBackground || phase == PaintPhaseChildBlockBackground) && paintInfo.shouldPaintWithinRoot(*this) && !paintInfo.paintRootBackgroundOnly())
         layer()->paintOverflowControls(paintInfo.context, roundedIntPoint(adjustedPaintOffset), paintInfo.rect);
 }
 
index 68bdfcf..6681d34 100644 (file)
@@ -1094,16 +1094,6 @@ bool RenderBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result
 
 // --------------------- painting stuff -------------------------------
 
-void RenderBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
-{
-    LayoutPoint adjustedPaintOffset = paintOffset + location();
-    // default implementation. Just pass paint through to the children
-    PaintInfo childInfo(paintInfo);
-    childInfo.updateSubtreePaintRootForChildren(this);
-    for (RenderObject* child = firstChild(); child; child = child->nextSibling())
-        child->paint(childInfo, adjustedPaintOffset);
-}
-
 void RenderBox::paintRootBoxFillLayers(const PaintInfo& paintInfo)
 {
     if (paintInfo.skipRootBackground())
@@ -1154,7 +1144,7 @@ BackgroundBleedAvoidance RenderBox::determineBackgroundBleedAvoidance(GraphicsCo
 
 void RenderBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
-    if (!paintInfo.shouldPaintWithinRoot(this))
+    if (!paintInfo.shouldPaintWithinRoot(*this))
         return;
 
     LayoutRect paintRect = borderBoxRectInRegion(paintInfo.renderRegion);
@@ -1375,7 +1365,7 @@ bool RenderBox::backgroundHasOpaqueTopLayer() const
 
 void RenderBox::paintMask(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
-    if (!paintInfo.shouldPaintWithinRoot(this) || style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask || paintInfo.context->paintingDisabled())
+    if (!paintInfo.shouldPaintWithinRoot(*this) || style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask || paintInfo.context->paintingDisabled())
         return;
 
     LayoutRect paintRect = LayoutRect(paintOffset, size());
index f0fb20e..bacb309 100644 (file)
@@ -297,7 +297,6 @@ public:
     LayoutRect reflectedRect(const LayoutRect&) const;
 
     virtual void layout();
-    virtual void paint(PaintInfo&, const LayoutPoint&);
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
 
     virtual LayoutUnit minPreferredLogicalWidth() const;
index 1fc58b0..f6f1ed4 100644 (file)
@@ -87,6 +87,8 @@ public:
     void setNeedsPositionedMovementLayout(const RenderStyle* oldStyle);
     void setNeedsSimplifiedNormalFlowLayout();
 
+    virtual void paint(PaintInfo&, const LayoutPoint&) = 0;
+
     // Return the renderer whose background style is used to paint the root background. Should only be called on the renderer for which isRoot() is true.
     RenderElement* rendererForRootBackground();
 
index 950a3c0..d0fa939 100644 (file)
@@ -138,7 +138,7 @@ RenderBox* RenderFieldset::findLegend(FindLegendOption option) const
 
 void RenderFieldset::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
-    if (!paintInfo.shouldPaintWithinRoot(this))
+    if (!paintInfo.shouldPaintWithinRoot(*this))
         return;
 
     LayoutRect paintRect(paintOffset, size());
index a34068e..c398f03 100644 (file)
@@ -140,7 +140,7 @@ void RenderFrameSet::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     for (size_t r = 0; r < rows; r++) {
         LayoutUnit xPos = 0;
         for (size_t c = 0; c < cols; c++) {
-            child->paint(paintInfo, adjustedPaintOffset);
+            toRenderElement(child)->paint(paintInfo, adjustedPaintOffset);
             xPos += m_cols.m_sizes[c];
             if (borderThickness && m_cols.m_allowBorder[c + 1]) {
                 paintColumnBorder(paintInfo, pixelSnappedIntRect(LayoutRect(adjustedPaintOffset.x() + xPos, adjustedPaintOffset.y() + yPos, borderThickness, height())));
index dfc9c64..5b7f9ba 100644 (file)
@@ -55,6 +55,7 @@ private:
     void node() const WTF_DELETED_FUNCTION;
 
     virtual bool canHaveChildren() const OVERRIDE { return false; }
+    virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE FINAL { }
 
     virtual VisiblePosition positionForPoint(const LayoutPoint&) OVERRIDE;
     virtual int caretMinOffset() const OVERRIDE;
index fd38427..f6119f0 100644 (file)
@@ -1238,10 +1238,6 @@ LayoutRect RenderObject::paintingRootRect(LayoutRect& topLevelRect)
     return result;
 }
 
-void RenderObject::paint(PaintInfo&, const LayoutPoint&)
-{
-}
-
 RenderLayerModelObject* RenderObject::containerForRepaint() const
 {
     RenderLayerModelObject* repaintContainer = 0;
index c5d7d3f..69b044f 100644 (file)
@@ -653,8 +653,6 @@ public:
     void setHasTransform(bool b = true) { m_bitfields.setHasTransform(b); }
     void setHasReflection(bool b = true) { m_bitfields.setHasReflection(b); }
 
-    virtual void paint(PaintInfo&, const LayoutPoint&);
-
     // Recursive function that computes the size and position of this object and all its descendants.
     virtual void layout();
 
index c85b5cf..2b8dbf5 100644 (file)
@@ -129,7 +129,7 @@ void RenderReplaced::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection && !canHaveChildren())
         return;
     
-    if (!paintInfo.shouldPaintWithinRoot(this))
+    if (!paintInfo.shouldPaintWithinRoot(*this))
         return;
     
     bool drawSelectionTint = selectionState() != SelectionNone && !document().printing();
@@ -176,7 +176,7 @@ bool RenderReplaced::shouldPaint(PaintInfo& paintInfo, const LayoutPoint& paintO
             && paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseMask)
         return false;
 
-    if (!paintInfo.shouldPaintWithinRoot(this))
+    if (!paintInfo.shouldPaintWithinRoot(*this))
         return false;
         
     // if we're invisible or haven't received a layout yet, then just bail.
index 440b6f2..a75ce42 100644 (file)
@@ -651,9 +651,12 @@ void RenderTable::paintObject(PaintInfo& paintInfo, const LayoutPoint& paintOffs
     info.updateSubtreePaintRootForChildren(this);
 
     for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
-        if (child->isBox() && !toRenderBox(child)->hasSelfPaintingLayer() && (child->isTableSection() || child->isTableCaption())) {
-            LayoutPoint childPoint = flipForWritingModeForChild(toRenderBox(child), paintOffset);
-            child->paint(info, childPoint);
+        if (!child->isBox())
+            continue;
+        RenderBox& box = toRenderBox(*child);
+        if (!box.hasSelfPaintingLayer() && (box.isTableSection() || box.isTableCaption())) {
+            LayoutPoint childPoint = flipForWritingModeForChild(&box, paintOffset);
+            box.paint(info, childPoint);
         }
     }
     
@@ -697,7 +700,7 @@ void RenderTable::subtractCaptionRect(LayoutRect& rect) const
 
 void RenderTable::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
-    if (!paintInfo.shouldPaintWithinRoot(this))
+    if (!paintInfo.shouldPaintWithinRoot(*this))
         return;
 
     LayoutRect rect(paintOffset, size());
index ee2530f..f6e5b4b 100644 (file)
@@ -1156,7 +1156,7 @@ void RenderTableCell::paintCollapsedBorders(PaintInfo& paintInfo, const LayoutPo
 {
     ASSERT(paintInfo.phase == PaintPhaseCollapsedTableBorders);
 
-    if (!paintInfo.shouldPaintWithinRoot(this) || style()->visibility() != VISIBLE)
+    if (!paintInfo.shouldPaintWithinRoot(*this) || style()->visibility() != VISIBLE)
         return;
 
     LayoutRect localRepaintRect = paintInfo.rect;
@@ -1266,7 +1266,7 @@ void RenderTableCell::paintCollapsedBorders(PaintInfo& paintInfo, const LayoutPo
 
 void RenderTableCell::paintBackgroundsBehindCell(PaintInfo& paintInfo, const LayoutPoint& paintOffset, RenderElement* backgroundObject)
 {
-    if (!paintInfo.shouldPaintWithinRoot(this))
+    if (!paintInfo.shouldPaintWithinRoot(*this))
         return;
 
     if (!backgroundObject)
@@ -1302,7 +1302,7 @@ void RenderTableCell::paintBackgroundsBehindCell(PaintInfo& paintInfo, const Lay
 
 void RenderTableCell::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
-    if (!paintInfo.shouldPaintWithinRoot(this))
+    if (!paintInfo.shouldPaintWithinRoot(*this))
         return;
 
     RenderTable* tableElt = table();
index e810090..2832575 100644 (file)
@@ -88,6 +88,7 @@ private:
     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) OVERRIDE;
 
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
+    virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE { }
 
     RenderTable* table() const;
 
index bc93c16..497478f 100644 (file)
@@ -171,7 +171,6 @@ private:
     // callers with a RenderObject* can continue to use length().
     virtual unsigned length() const OVERRIDE FINAL { return textLength(); }
 
-    virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE FINAL { ASSERT_NOT_REACHED(); }
     virtual void layout() OVERRIDE FINAL { ASSERT_NOT_REACHED(); }
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint&, HitTestAction) OVERRIDE FINAL { ASSERT_NOT_REACHED(); return false; }
 
index 5ceacb1..a620a09 100644 (file)
@@ -438,7 +438,7 @@ void RenderView::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
     ASSERT(LayoutPoint(IntPoint(paintOffset.x(), paintOffset.y())) == paintOffset);
 
     // This avoids painting garbage between columns if there is a column gap.
-    if (frameView().pagination().mode != Pagination::Unpaginated && paintInfo.shouldPaintWithinRoot(this))
+    if (frameView().pagination().mode != Pagination::Unpaginated && paintInfo.shouldPaintWithinRoot(*this))
         paintInfo.context->fillRect(paintInfo.rect, frameView().baseBackgroundColor(), ColorSpaceDeviceRGB);
 
     paintObject(paintInfo, paintOffset);
@@ -472,7 +472,7 @@ static inline bool rendererObscuresBackground(RenderElement* rootObject)
 
 void RenderView::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&)
 {
-    if (!paintInfo.shouldPaintWithinRoot(this))
+    if (!paintInfo.shouldPaintWithinRoot(*this))
         return;
 
     // Check to see if we are enclosed by a layer that requires complex painting rules.  If so, we cannot blit
index 8ab58b7..ab253d2 100644 (file)
@@ -169,7 +169,7 @@ float RootInlineBox::placeEllipsisBox(bool ltr, float blockLeftEdge, float block
 
 void RootInlineBox::paintEllipsisBox(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom) const
 {
-    if (hasEllipsisBox() && paintInfo.shouldPaintWithinRoot(&renderer()) && renderer().style()->visibility() == VISIBLE
+    if (hasEllipsisBox() && paintInfo.shouldPaintWithinRoot(renderer()) && renderer().style()->visibility() == VISIBLE
             && paintInfo.phase == PaintPhaseForeground)
         ellipsisBox()->paint(paintInfo, paintOffset, lineTop, lineBottom);
 }
@@ -190,7 +190,7 @@ void RootInlineBox::addHighlightOverflow()
 
 void RootInlineBox::paintCustomHighlight(PaintInfo& paintInfo, const LayoutPoint& paintOffset, const AtomicString& highlightType)
 {
-    if (!paintInfo.shouldPaintWithinRoot(&renderer()) || renderer().style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground)
+    if (!paintInfo.shouldPaintWithinRoot(renderer()) || renderer().style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseForeground)
         return;
 
     Page* page = renderer().frame().page();
index 96cbed6..5b659db 100644 (file)
@@ -139,8 +139,11 @@ void RenderSVGContainer::paint(PaintInfo& paintInfo, const LayoutPoint&)
 
         if (continueRendering) {
             childPaintInfo.updateSubtreePaintRootForChildren(this);
-            for (RenderObject* child = firstChild(); child; child = child->nextSibling())
-                child->paint(childPaintInfo, IntPoint());
+            for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
+                if (!child->isRenderElement())
+                    continue;
+                toRenderElement(child)->paint(childPaintInfo, IntPoint());
+            }
         }
     }
     
index 57d336c..a56bad9 100644 (file)
@@ -54,6 +54,7 @@ protected:
 
 private:
     virtual bool canHaveChildren() const OVERRIDE { return false; }
+    virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE FINAL { }
 
     SVGGradientElement* gradientElement() const;
 };
index 010be08..3def190 100644 (file)
@@ -26,6 +26,7 @@
 #include "RenderSVGResourceClipper.h"
 
 #include "AffineTransform.h"
+#include "ElementIterator.h"
 #include "FloatRect.h"
 #include "Frame.h"
 #include "FrameView.h"
@@ -220,9 +221,11 @@ bool RenderSVGResourceClipper::drawContentIntoMaskImage(ClipperData* clipperData
     view().frameView().setPaintBehavior(oldBehavior | PaintBehaviorRenderingSVGMask);
 
     // Draw all clipPath children into a global mask.
-    for (Node* childNode = clipPathElement().firstChild(); childNode; childNode = childNode->nextSibling()) {
-        RenderObject* renderer = childNode->renderer();
-        if (!childNode->isSVGElement() || !renderer)
+    auto children = childrenOfType<SVGElement>(&clipPathElement());
+    for (auto it = children.begin(), end = children.end(); it != end; ++it) {
+        SVGElement& child = *it;
+        auto renderer = child.renderer();
+        if (!renderer)
             continue;
         if (renderer->needsLayout()) {
             view().frameView().setPaintBehavior(oldBehavior);
@@ -233,13 +236,13 @@ bool RenderSVGResourceClipper::drawContentIntoMaskImage(ClipperData* clipperData
             continue;
 
         WindRule newClipRule = style->svgStyle()->clipRule();
-        bool isUseElement = childNode->hasTagName(SVGNames::useTag);
+        bool isUseElement = child.hasTagName(SVGNames::useTag);
         if (isUseElement) {
-            SVGUseElement* useElement = toSVGUseElement(childNode);
-            renderer = useElement->rendererClipChild();
+            SVGUseElement& useElement = toSVGUseElement(child);
+            renderer = useElement.rendererClipChild();
             if (!renderer)
                 continue;
-            if (!useElement->hasAttribute(SVGNames::clip_ruleAttr))
+            if (!useElement.hasAttribute(SVGNames::clip_ruleAttr))
                 newClipRule = renderer->style()->svgStyle()->clipRule();
         }
 
@@ -252,7 +255,7 @@ bool RenderSVGResourceClipper::drawContentIntoMaskImage(ClipperData* clipperData
         // In the case of a <use> element, we obtained its renderere above, to retrieve its clipRule.
         // We have to pass the <use> renderer itself to renderSubtreeToImageBuffer() to apply it's x/y/transform/etc. values when rendering.
         // So if isUseElement is true, refetch the childNode->renderer(), as renderer got overriden above.
-        SVGRenderingContext::renderSubtreeToImageBuffer(clipperData->clipMaskImage.get(), isUseElement ? childNode->renderer() : renderer, maskContentTransformation);
+        SVGRenderingContext::renderSubtreeToImageBuffer(clipperData->clipMaskImage.get(), isUseElement ? *child.renderer() : *renderer, maskContentTransformation);
     }
 
     view().frameView().setPaintBehavior(oldBehavior);
index 3b65421..d928ac4 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "AffineTransform.h"
 #include "Element.h"
+#include "ElementIterator.h"
 #include "FloatPoint.h"
 #include "FloatRect.h"
 #include "GraphicsContext.h"
@@ -118,16 +119,18 @@ bool RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, C
     }
 
     // Draw the content into the ImageBuffer.
-    for (Node* node = maskElement().firstChild(); node; node = node->nextSibling()) {
-        RenderObject* renderer = node->renderer();
-        if (!node->isSVGElement() || !renderer)
+    auto children = childrenOfType<SVGElement>(&maskElement());
+    for (auto it = children.begin(), end = children.end(); it != end; ++it) {
+        SVGElement& child = *it;
+        auto renderer = child.renderer();
+        if (!renderer)
             continue;
         if (renderer->needsLayout())
             return false;
         RenderStyle* style = renderer->style();
         if (!style || style->display() == NONE || style->visibility() != VISIBLE)
             continue;
-        SVGRenderingContext::renderSubtreeToImageBuffer(maskerData->maskImage.get(), renderer, maskContentTransformation);
+        SVGRenderingContext::renderSubtreeToImageBuffer(maskerData->maskImage.get(), *renderer, maskContentTransformation);
     }
 
 #if !USE(CG)
index 5f287cb..eee8951 100644 (file)
@@ -279,7 +279,7 @@ PassOwnPtr<ImageBuffer> RenderSVGResourcePattern::createTileImage(const PatternA
             continue;
         if (child.renderer()->needsLayout())
             return nullptr;
-        SVGRenderingContext::renderSubtreeToImageBuffer(tileImage.get(), child.renderer(), contentTransformation);
+        SVGRenderingContext::renderSubtreeToImageBuffer(tileImage.get(), *child.renderer(), contentTransformation);
     }
 
     return tileImage.release();
index 61fdcb2..4a7fab6 100644 (file)
@@ -291,8 +291,15 @@ void RenderSVGRoot::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paint
             continueRendering = renderingContext.isRenderingPrepared();
         }
 
-        if (continueRendering)
-            RenderBox::paint(childPaintInfo, LayoutPoint());
+        if (continueRendering) {
+            childPaintInfo.updateSubtreePaintRootForChildren(this);
+            for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
+                // FIXME: Can this ever have RenderText children?
+                if (!child->isRenderElement())
+                    continue;
+                toRenderElement(child)->paint(childPaintInfo, location());
+            }
+        }
     }
 
     childPaintInfo.context->restore();
index 1b0bc46..d84c141 100644 (file)
@@ -177,7 +177,7 @@ static inline bool textShouldBePainted(const RenderSVGInlineText& textRenderer)
 
 void SVGInlineTextBox::paintSelectionBackground(PaintInfo& paintInfo)
 {
-    ASSERT(paintInfo.shouldPaintWithinRoot(&renderer()));
+    ASSERT(paintInfo.shouldPaintWithinRoot(renderer()));
     ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
     ASSERT(truncation() == cNoTruncation);
 
@@ -242,7 +242,7 @@ void SVGInlineTextBox::paintSelectionBackground(PaintInfo& paintInfo)
 
 void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint&, LayoutUnit, LayoutUnit)
 {
-    ASSERT(paintInfo.shouldPaintWithinRoot(&renderer()));
+    ASSERT(paintInfo.shouldPaintWithinRoot(renderer()));
     ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
     ASSERT(truncation() == cNoTruncation);
 
index be1693d..96adf47 100644 (file)
@@ -274,9 +274,8 @@ bool SVGRenderingContext::createImageBufferForPattern(const FloatRect& absoluteT
     return true;
 }
 
-void SVGRenderingContext::renderSubtreeToImageBuffer(ImageBuffer* image, RenderObject* item, const AffineTransform& subtreeContentTransformation)
+void SVGRenderingContext::renderSubtreeToImageBuffer(ImageBuffer* image, RenderElement& item, const AffineTransform& subtreeContentTransformation)
 {
-    ASSERT(item);
     ASSERT(image);
     ASSERT(image->context());
 
@@ -286,8 +285,8 @@ void SVGRenderingContext::renderSubtreeToImageBuffer(ImageBuffer* image, RenderO
     AffineTransform savedContentTransformation = contentTransformation;
     contentTransformation = subtreeContentTransformation * contentTransformation;
 
-    ASSERT(!item->needsLayout());
-    item->paint(info, IntPoint());
+    ASSERT(!item.needsLayout());
+    item.paint(info, IntPoint());
 
     contentTransformation = savedContentTransformation;
 }
index 1fc3f1a..a5b538d 100644 (file)
@@ -32,6 +32,7 @@
 namespace WebCore {
 
 class AffineTransform;
+class RenderElement;
 class RenderObject;
 class FloatRect;
 class RenderSVGResourceFilter;
@@ -79,7 +80,7 @@ public:
     // Patterns need a different float-to-integer coordinate mapping.
     static bool createImageBufferForPattern(const FloatRect& absoluteTargetRect, const FloatRect& clampedAbsoluteTargetRect, OwnPtr<ImageBuffer>&, ColorSpace, RenderingMode);
 
-    static void renderSubtreeToImageBuffer(ImageBuffer*, RenderObject*, const AffineTransform&);
+    static void renderSubtreeToImageBuffer(ImageBuffer*, RenderElement&, const AffineTransform&);
     static void clipToImageBuffer(GraphicsContext*, const AffineTransform& absoluteTransform, const FloatRect& targetRect, OwnPtr<ImageBuffer>&, bool safeToClear);
 
     static float calculateScreenFontSizeScalingFactor(const RenderObject*);
index cccae8b..a2700a8 100644 (file)
@@ -570,7 +570,7 @@ void SVGUseElement::toClipPath(Path& path)
     }
 }
 
-RenderObject* SVGUseElement::rendererClipChild() const
+RenderElement* SVGUseElement::rendererClipChild() const
 {
     Node* n = m_targetElementInstance ? m_targetElementInstance->shadowTreeElement() : 0;
     if (!n)
index f2fbfb0..6992168 100644 (file)
@@ -51,7 +51,7 @@ public:
     void invalidateShadowTree();
     void invalidateDependentShadowTrees();
 
-    RenderObject* rendererClipChild() const;
+    RenderElement* rendererClipChild() const;
 
 private:
     SVGUseElement(const QualifiedName&, Document&, bool wasInsertedByParser);
index 6e0dfa0..409bce3 100644 (file)
@@ -96,7 +96,7 @@ RenderElement* FEImage::referencedRenderer() const
 
 void FEImage::platformApplySoftware()
 {
-    RenderObject* renderer = referencedRenderer();
+    RenderElement* renderer = referencedRenderer();
     if (!m_image && !renderer)
         return;
 
@@ -125,7 +125,7 @@ void FEImage::platformApplySoftware()
         const AffineTransform& absoluteTransform = svgFilter->absoluteTransform();
         resultImage->context()->concatCTM(absoluteTransform);
 
-        SVGElement* contextNode = toSVGElement(renderer->node());
+        SVGElement* contextNode = toSVGElement(renderer->element());
         if (contextNode->hasRelativeLengths()) {
             SVGLengthContext lengthContext(contextNode);
             float width = 0;
@@ -138,7 +138,7 @@ void FEImage::platformApplySoftware()
         }
 
         AffineTransform contentTransformation;
-        SVGRenderingContext::renderSubtreeToImageBuffer(resultImage, renderer, contentTransformation);
+        SVGRenderingContext::renderSubtreeToImageBuffer(resultImage, *renderer, contentTransformation);
         return;
     }