Skip to content
Permalink
Browse files
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.

Canonical link: https://commits.webkit.org/140973@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@157509 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Oct 16, 2013
1 parent d4a5d5e commit a5947d9eb9d8786d1ef7d83b983b00660a88b0a6
@@ -1,3 +1,15 @@
2013-10-16 Andreas Kling <akling@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 <pnormand@igalia.com>

[GStreamer] video info unset if upstream doesn't query allocation
@@ -88,7 +88,7 @@ void PseudoElement::didAttachRenderers()

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();
@@ -56,7 +56,7 @@ class RenderElement : public RenderObject {
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*);
@@ -776,9 +776,9 @@ int RenderFrameSet::hitTestSplit(const GridAxis& axis, int position) const
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
@@ -97,7 +97,7 @@ class RenderFrameSet FINAL : public RenderBox {
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;
@@ -111,7 +111,7 @@ RenderFullScreen* RenderFullScreen::wrapRenderer(RenderObject* object, RenderEle
{
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;
}
@@ -476,14 +476,14 @@ const AtomicString& RenderNamedFlowThread::flowThreadName() const
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;

@@ -87,7 +87,7 @@ class RenderNamedFlowThread FINAL : public RenderFlowThread {
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;
@@ -48,9 +48,9 @@ RenderRubyBase::~RenderRubyBase()
{
}

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)
@@ -46,9 +46,8 @@ class RenderRubyBase FINAL : public RenderBlockFlow {

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;

@@ -107,9 +107,9 @@ void RenderRubyRun::updateFirstLetter()
{
}

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)
@@ -56,7 +56,7 @@ class RenderRubyRun FINAL : public RenderBlockFlow {
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);

@@ -46,9 +46,9 @@ RenderRubyText::~RenderRubyText()
{
}

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
@@ -42,7 +42,7 @@ class RenderRubyText FINAL : public RenderBlockFlow {

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"; }
@@ -80,10 +80,10 @@ void RenderTableCol::willBeRemovedFromTree()
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
@@ -80,7 +80,7 @@ class RenderTableCol FINAL : public RenderBox {
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; }

@@ -138,9 +138,9 @@ LayoutUnit RenderView::availableLogicalHeight(AvailableLogicalHeightType) const
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)
@@ -54,7 +54,7 @@ class RenderView FINAL : public RenderBlockFlow {

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;
@@ -55,9 +55,9 @@ RenderMathMLBlock::RenderMathMLBlock(Document& document)
{
}

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)
@@ -44,7 +44,7 @@ class RenderMathMLBlock : public RenderFlexibleBox {
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; }
@@ -80,7 +80,7 @@ RenderMathMLOperator::RenderMathMLOperator(Element& element, UChar operatorChar)
{
}

bool RenderMathMLOperator::isChildAllowed(RenderObject*, RenderStyle*) const
bool RenderMathMLOperator::isChildAllowed(const RenderObject&, const RenderStyle&) const
{
return false;
}
@@ -40,7 +40,7 @@ class RenderMathMLOperator : public RenderMathMLBlock {

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;
@@ -46,7 +46,7 @@ class RenderMathMLSpace : public RenderMathMLBlock {

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;
@@ -75,9 +75,9 @@ SVGTextElement& RenderSVGText::textElement() const
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)
@@ -40,7 +40,7 @@ class RenderSVGText FINAL : public RenderSVGBlock {

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; }
@@ -235,7 +235,7 @@ static void createRendererIfNeeded(Element& element, PassRefPtr<RenderStyle> res
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 @@ static void createTextRendererIfNeeded(Text& textNode)
RenderText* newRenderer = textNode.createTextRenderer(*document.renderArena(), *style);
if (!newRenderer)
return;
if (!parentRenderer->isChildAllowed(newRenderer, style.get())) {
if (!parentRenderer->isChildAllowed(*newRenderer, *style)) {
newRenderer->destroy();
return;
}

0 comments on commit a5947d9

Please sign in to comment.