Title: [157509] trunk/Source/WebCore
Revision
157509
Author
akl...@apple.com
Date
2013-10-16 02:34:35 -0700 (Wed, 16 Oct 2013)

Log Message

RenderElement::isChildAllowed() should take const references.
<https://webkit.org/b/122870>

Reviewed by Anders Carlsson.

The isChildAllowed() functions expect non-null values to be passed,
so enforce this at compile-time.

Reordered some checks to do bit tests before virtual calls.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (157508 => 157509)


--- trunk/Source/WebCore/ChangeLog	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/ChangeLog	2013-10-16 09:34:35 UTC (rev 157509)
@@ -1,3 +1,15 @@
+2013-10-16  Andreas Kling  <akl...@apple.com>
+
+        RenderElement::isChildAllowed() should take const references.
+        <https://webkit.org/b/122870>
+
+        Reviewed by Anders Carlsson.
+
+        The isChildAllowed() functions expect non-null values to be passed,
+        so enforce this at compile-time.
+
+        Reordered some checks to do bit tests before virtual calls.
+
 2013-10-15  Philippe Normand  <pnorm...@igalia.com>
 
         [GStreamer] video info unset if upstream doesn't query allocation

Modified: trunk/Source/WebCore/dom/PseudoElement.cpp (157508 => 157509)


--- trunk/Source/WebCore/dom/PseudoElement.cpp	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/dom/PseudoElement.cpp	2013-10-16 09:34:35 UTC (rev 157509)
@@ -88,7 +88,7 @@
 
     for (const ContentData* content = style->contentData(); content; content = content->next()) {
         RenderObject* child = content->createRenderer(document(), *style);
-        if (renderer->isChildAllowed(child, style)) {
+        if (renderer->isChildAllowed(*child, *style)) {
             renderer->addChild(child);
             if (child->isQuote())
                 toRenderQuote(child)->attachQuote();

Modified: trunk/Source/WebCore/rendering/RenderElement.h (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderElement.h	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderElement.h	2013-10-16 09:34:35 UTC (rev 157509)
@@ -56,7 +56,7 @@
     bool isRenderReplaced() const;
     bool isRenderInline() const;
 
-    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const { return true; }
+    virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const { return true; }
     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
     virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0) { return addChild(newChild, beforeChild); }
     virtual void removeChild(RenderObject*);

Modified: trunk/Source/WebCore/rendering/RenderFrameSet.cpp (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderFrameSet.cpp	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderFrameSet.cpp	2013-10-16 09:34:35 UTC (rev 157509)
@@ -776,9 +776,9 @@
     return noSplit;
 }
 
-bool RenderFrameSet::isChildAllowed(RenderObject* child, RenderStyle*) const
+bool RenderFrameSet::isChildAllowed(const RenderObject& child, const RenderStyle&) const
 {
-    return child->isFrame() || child->isFrameSet();
+    return child.isFrame() || child.isFrameSet();
 }
 
 CursorDirective RenderFrameSet::getCursor(const LayoutPoint& point, Cursor& cursor) const

Modified: trunk/Source/WebCore/rendering/RenderFrameSet.h (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderFrameSet.h	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderFrameSet.h	2013-10-16 09:34:35 UTC (rev 157509)
@@ -97,7 +97,7 @@
     virtual void layout() OVERRIDE;
     virtual void paint(PaintInfo&, const LayoutPoint&) OVERRIDE;
     virtual bool canHaveChildren() const OVERRIDE { return true; }
-    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE;
+    virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const OVERRIDE;
     virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const OVERRIDE;
 
     bool flattenFrameSet() const;

Modified: trunk/Source/WebCore/rendering/RenderFullScreen.cpp (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderFullScreen.cpp	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderFullScreen.cpp	2013-10-16 09:34:35 UTC (rev 157509)
@@ -111,7 +111,7 @@
 {
     RenderFullScreen* fullscreenRenderer = new (*document.renderArena()) RenderFullScreen(document);
     fullscreenRenderer->setStyle(createFullScreenStyle());
-    if (parent && !parent->isChildAllowed(fullscreenRenderer, fullscreenRenderer->style())) {
+    if (parent && !parent->isChildAllowed(*fullscreenRenderer, *fullscreenRenderer->style())) {
         fullscreenRenderer->destroy();
         return 0;
     }

Modified: trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderNamedFlowThread.cpp	2013-10-16 09:34:35 UTC (rev 157509)
@@ -476,14 +476,14 @@
     return m_namedFlow->name();
 }
 
-bool RenderNamedFlowThread::isChildAllowed(RenderObject* child, RenderStyle* style) const
+bool RenderNamedFlowThread::isChildAllowed(const RenderObject& child, const RenderStyle& style) const
 {
-    if (!child->node())
+    if (!child.node())
         return true;
 
-    ASSERT(child->node()->isElementNode());
+    ASSERT(child.node()->isElementNode());
 
-    Node* originalParent = NodeRenderingTraversal::parent(child->node());
+    Node* originalParent = NodeRenderingTraversal::parent(child.node());
     if (!originalParent || !originalParent->isElementNode() || !originalParent->renderer())
         return true;
 

Modified: trunk/Source/WebCore/rendering/RenderNamedFlowThread.h (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderNamedFlowThread.h	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderNamedFlowThread.h	2013-10-16 09:34:35 UTC (rev 157509)
@@ -87,7 +87,7 @@
 private:
     virtual const char* renderName() const OVERRIDE;
     virtual bool isRenderNamedFlowThread() const OVERRIDE { return true; }
-    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE;
+    virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const OVERRIDE;
 
     virtual void dispatchRegionLayoutUpdateEvent() OVERRIDE;
     virtual void dispatchRegionOversetChangeEvent() OVERRIDE;

Modified: trunk/Source/WebCore/rendering/RenderRubyBase.cpp (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderRubyBase.cpp	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderRubyBase.cpp	2013-10-16 09:34:35 UTC (rev 157509)
@@ -48,9 +48,9 @@
 {
 }
 
-bool RenderRubyBase::isChildAllowed(RenderObject* child, RenderStyle*) const
+bool RenderRubyBase::isChildAllowed(const RenderObject& child, const RenderStyle&) const
 {
-    return child->isInline();
+    return child.isInline();
 }
 
 void RenderRubyBase::moveChildren(RenderRubyBase* toBase, RenderObject* beforeChild)

Modified: trunk/Source/WebCore/rendering/RenderRubyBase.h (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderRubyBase.h	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderRubyBase.h	2013-10-16 09:34:35 UTC (rev 157509)
@@ -46,9 +46,8 @@
 
     virtual bool isRubyBase() const { return true; }
 
-    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const;
-
 private:
+    virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const;
     virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const;
     virtual void adjustInlineDirectionLineBounds(int expansionOpportunityCount, float& logicalLeft, float& logicalWidth) const;
 

Modified: trunk/Source/WebCore/rendering/RenderRubyRun.cpp (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderRubyRun.cpp	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderRubyRun.cpp	2013-10-16 09:34:35 UTC (rev 157509)
@@ -107,9 +107,9 @@
 {
 }
 
-bool RenderRubyRun::isChildAllowed(RenderObject* child, RenderStyle*) const
+bool RenderRubyRun::isChildAllowed(const RenderObject& child, const RenderStyle&) const
 {
-    return child->isRubyText() || child->isInline();
+    return child.isInline() || child.isRubyText();
 }
 
 void RenderRubyRun::addChild(RenderObject* child, RenderObject* beforeChild)

Modified: trunk/Source/WebCore/rendering/RenderRubyRun.h (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderRubyRun.h	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderRubyRun.h	2013-10-16 09:34:35 UTC (rev 157509)
@@ -56,7 +56,7 @@
     virtual RenderObject* layoutSpecialExcludedChild(bool relayoutChildren);
     virtual void layout();
 
-    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const;
+    virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const;
     virtual void addChild(RenderObject* child, RenderObject* beforeChild = 0);
     virtual void removeChild(RenderObject* child);
 

Modified: trunk/Source/WebCore/rendering/RenderRubyText.cpp (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderRubyText.cpp	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderRubyText.cpp	2013-10-16 09:34:35 UTC (rev 157509)
@@ -46,9 +46,9 @@
 {
 }
 
-bool RenderRubyText::isChildAllowed(RenderObject* child, RenderStyle*) const
+bool RenderRubyText::isChildAllowed(const RenderObject& child, const RenderStyle&) const
 {
-    return child->isInline();
+    return child.isInline();
 }
 
 ETextAlign RenderRubyText::textAlignmentForLine(bool endsWithSoftBreak) const

Modified: trunk/Source/WebCore/rendering/RenderRubyText.h (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderRubyText.h	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderRubyText.h	2013-10-16 09:34:35 UTC (rev 157509)
@@ -42,7 +42,7 @@
 
     Element& element() const { return toElement(nodeForNonAnonymous()); }
 
-    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE;
+    virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const OVERRIDE;
 
 private:
     virtual const char* renderName() const OVERRIDE { return "RenderRubyText"; }

Modified: trunk/Source/WebCore/rendering/RenderTableCol.cpp (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderTableCol.cpp	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderTableCol.cpp	2013-10-16 09:34:35 UTC (rev 157509)
@@ -80,10 +80,10 @@
     table()->removeColumn(this);
 }
 
-bool RenderTableCol::isChildAllowed(RenderObject* child, RenderStyle* style) const
+bool RenderTableCol::isChildAllowed(const RenderObject& child, const RenderStyle& style) const
 {
     // We cannot use isTableColumn here as style() may return 0.
-    return child->isRenderTableCol() && style->display() == TABLE_COLUMN;
+    return style.display() == TABLE_COLUMN && child.isRenderTableCol();
 }
 
 bool RenderTableCol::canHaveChildren() const

Modified: trunk/Source/WebCore/rendering/RenderTableCol.h (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderTableCol.h	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderTableCol.h	2013-10-16 09:34:35 UTC (rev 157509)
@@ -80,7 +80,7 @@
     virtual void insertedIntoTree() OVERRIDE;
     virtual void willBeRemovedFromTree() OVERRIDE;
 
-    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE;
+    virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const OVERRIDE;
     virtual bool canHaveChildren() const OVERRIDE;
     virtual bool requiresLayer() const OVERRIDE { return false; }
 

Modified: trunk/Source/WebCore/rendering/RenderView.cpp (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderView.cpp	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderView.cpp	2013-10-16 09:34:35 UTC (rev 157509)
@@ -138,9 +138,9 @@
     return isHorizontalWritingMode() ? frameView().visibleHeight() : frameView().visibleWidth();
 }
 
-bool RenderView::isChildAllowed(RenderObject* child, RenderStyle*) const
+bool RenderView::isChildAllowed(const RenderObject& child, const RenderStyle&) const
 {
-    return child->isBox();
+    return child.isBox();
 }
 
 void RenderView::layoutContent(const LayoutState& state)

Modified: trunk/Source/WebCore/rendering/RenderView.h (157508 => 157509)


--- trunk/Source/WebCore/rendering/RenderView.h	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/RenderView.h	2013-10-16 09:34:35 UTC (rev 157509)
@@ -54,7 +54,7 @@
 
     virtual bool requiresLayer() const OVERRIDE { return true; }
 
-    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE;
+    virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const OVERRIDE;
 
     virtual void layout() OVERRIDE;
     virtual void updateLogicalWidth() OVERRIDE;

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp (157508 => 157509)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp	2013-10-16 09:34:35 UTC (rev 157509)
@@ -55,9 +55,9 @@
 {
 }
 
-bool RenderMathMLBlock::isChildAllowed(RenderObject* child, RenderStyle*) const
+bool RenderMathMLBlock::isChildAllowed(const RenderObject& child, const RenderStyle&) const
 {
-    return child->node() && child->node()->nodeType() == Node::ELEMENT_NODE;
+    return child.node() && isElement(*child.node());
 }
 
 RenderMathMLBlock* RenderMathMLBlock::createAnonymousMathMLBlock(EDisplay display)

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h (157508 => 157509)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.h	2013-10-16 09:34:35 UTC (rev 157509)
@@ -44,7 +44,7 @@
     explicit RenderMathMLBlock(Element&);
     explicit RenderMathMLBlock(Document&);
 
-    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE;
+    virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const OVERRIDE;
     
     virtual bool isRenderMathMLBlock() const OVERRIDE { return true; }
     virtual bool isRenderMathMLOperator() const { return false; }

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp (157508 => 157509)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp	2013-10-16 09:34:35 UTC (rev 157509)
@@ -80,7 +80,7 @@
 {
 }
 
-bool RenderMathMLOperator::isChildAllowed(RenderObject*, RenderStyle*) const
+bool RenderMathMLOperator::isChildAllowed(const RenderObject&, const RenderStyle&) const
 {
     return false;
 }

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h (157508 => 157509)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h	2013-10-16 09:34:35 UTC (rev 157509)
@@ -40,7 +40,7 @@
 
     virtual bool isRenderMathMLOperator() const OVERRIDE { return true; }
     
-    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE;
+    virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const OVERRIDE;
     virtual void updateFromElement() OVERRIDE;
     virtual void computePreferredLogicalWidths() OVERRIDE;
     virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const OVERRIDE;

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.h (157508 => 157509)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.h	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.h	2013-10-16 09:34:35 UTC (rev 157509)
@@ -46,7 +46,7 @@
 
     virtual bool isRenderMathMLSpace() const OVERRIDE { return true; }
 
-    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const OVERRIDE { return false; } 
+    virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const OVERRIDE { return false; }
     virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const OVERRIDE;
 
     virtual void updateFromElement() OVERRIDE;

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp (157508 => 157509)


--- trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp	2013-10-16 09:34:35 UTC (rev 157509)
@@ -75,9 +75,9 @@
     return toSVGTextElement(RenderSVGBlock::graphicsElement());
 }
 
-bool RenderSVGText::isChildAllowed(RenderObject* child, RenderStyle*) const
+bool RenderSVGText::isChildAllowed(const RenderObject& child, const RenderStyle&) const
 {
-    return child->isInline();
+    return child.isInline();
 }
 
 RenderSVGText* RenderSVGText::locateRenderSVGTextAncestor(RenderObject* start)

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGText.h (157508 => 157509)


--- trunk/Source/WebCore/rendering/svg/RenderSVGText.h	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGText.h	2013-10-16 09:34:35 UTC (rev 157509)
@@ -40,7 +40,7 @@
 
     SVGTextElement& textElement() const;
 
-    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const;
+    virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const;
 
     void setNeedsPositioningValuesUpdate() { m_needsPositioningValuesUpdate = true; }
     virtual void setNeedsTransformUpdate() { m_needsTransformUpdate = true; }

Modified: trunk/Source/WebCore/style/StyleResolveTree.cpp (157508 => 157509)


--- trunk/Source/WebCore/style/StyleResolveTree.cpp	2013-10-16 09:24:28 UTC (rev 157508)
+++ trunk/Source/WebCore/style/StyleResolveTree.cpp	2013-10-16 09:34:35 UTC (rev 157509)
@@ -235,7 +235,7 @@
     RenderElement* newRenderer = element.createRenderer(*document.renderArena(), *style);
     if (!newRenderer)
         return;
-    if (!parentRenderer->isChildAllowed(newRenderer, style.get())) {
+    if (!parentRenderer->isChildAllowed(*newRenderer, *style)) {
         newRenderer->destroy();
         return;
     }
@@ -374,7 +374,7 @@
     RenderText* newRenderer = textNode.createTextRenderer(*document.renderArena(), *style);
     if (!newRenderer)
         return;
-    if (!parentRenderer->isChildAllowed(newRenderer, style.get())) {
+    if (!parentRenderer->isChildAllowed(*newRenderer, *style)) {
         newRenderer->destroy();
         return;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to