Skip to content
Permalink
Browse files
[RenderTreeBuilder] Move RenderSVG*::takeChild() to RenderTreeBuilder
https://bugs.webkit.org/show_bug.cgi?id=182736
<rdar://problem/37503107>

Reviewed by Antti Koivisto.

No change in functionality.

* rendering/svg/RenderSVGContainer.cpp:
(WebCore::RenderSVGContainer::takeChild): Deleted.
* rendering/svg/RenderSVGContainer.h:
* rendering/svg/RenderSVGInline.cpp:
(WebCore::RenderSVGInline::takeChild): Deleted.
* rendering/svg/RenderSVGInline.h:
* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::takeChild): Deleted.
* rendering/svg/RenderSVGRoot.h:
* rendering/svg/RenderSVGText.cpp:
(WebCore::RenderSVGText::takeChild): Deleted.
* rendering/svg/RenderSVGText.h:
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::takeChild):
* rendering/updating/RenderTreeBuilderSVG.cpp:
(WebCore::RenderTreeBuilder::SVG::takeChild):
* rendering/updating/RenderTreeBuilderSVG.h:


Canonical link: https://commits.webkit.org/198525@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228429 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Feb 13, 2018
1 parent 82fe381 commit 7384ae383fabf431ae90883a28c7b04fc2aa9eee
@@ -1,3 +1,31 @@
2018-02-13 Zalan Bujtas <zalan@apple.com>

[RenderTreeBuilder] Move RenderSVG*::takeChild() to RenderTreeBuilder
https://bugs.webkit.org/show_bug.cgi?id=182736
<rdar://problem/37503107>

Reviewed by Antti Koivisto.

No change in functionality.

* rendering/svg/RenderSVGContainer.cpp:
(WebCore::RenderSVGContainer::takeChild): Deleted.
* rendering/svg/RenderSVGContainer.h:
* rendering/svg/RenderSVGInline.cpp:
(WebCore::RenderSVGInline::takeChild): Deleted.
* rendering/svg/RenderSVGInline.h:
* rendering/svg/RenderSVGRoot.cpp:
(WebCore::RenderSVGRoot::takeChild): Deleted.
* rendering/svg/RenderSVGRoot.h:
* rendering/svg/RenderSVGText.cpp:
(WebCore::RenderSVGText::takeChild): Deleted.
* rendering/svg/RenderSVGText.h:
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::takeChild):
* rendering/updating/RenderTreeBuilderSVG.cpp:
(WebCore::RenderTreeBuilder::SVG::takeChild):
* rendering/updating/RenderTreeBuilderSVG.h:

2018-02-13 Zalan Bujtas <zalan@apple.com>

[RenderTreeBuilder] Move RenderGrid::takeChild() to RenderTreeBuilder
@@ -95,12 +95,6 @@ void RenderSVGContainer::addChild(RenderTreeBuilder& builder, RenderPtr<RenderOb
builder.insertChildToSVGContainer(*this, WTFMove(newChild), beforeChild);
}

RenderPtr<RenderObject> RenderSVGContainer::takeChild(RenderTreeBuilder& builder, RenderObject& child)
{
SVGResourcesCache::clientWillBeRemovedFromTree(child);
return RenderSVGModelObject::takeChild(builder, child);
}

bool RenderSVGContainer::selfWillPaint()
{
auto* resources = SVGResourcesCache::cachedResourcesForRenderer(*this);
@@ -49,7 +49,6 @@ class RenderSVGContainer : public RenderSVGModelObject {
void layout() override;

void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) final;
RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) final;
void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) final;

FloatRect objectBoundingBox() const final { return m_objectBoundingBox; }
@@ -128,19 +128,4 @@ void RenderSVGInline::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObjec
builder.insertChildToSVGInline(*this, WTFMove(newChild), beforeChild);
}

RenderPtr<RenderObject> RenderSVGInline::takeChild(RenderTreeBuilder& builder, RenderObject& child)
{
SVGResourcesCache::clientWillBeRemovedFromTree(child);

auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this);
if (!textAncestor)
return RenderInline::takeChild(builder, child);

Vector<SVGTextLayoutAttributes*, 2> affectedAttributes;
textAncestor->subtreeChildWillBeRemoved(&child, affectedAttributes);
auto takenChild = RenderInline::takeChild(builder, child);
textAncestor->subtreeChildWasRemoved(affectedAttributes);
return takenChild;
}

}
@@ -62,7 +62,6 @@ class RenderSVGInline : public RenderInline {
void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final;

void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr) final;
RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) final;
};

} // namespace WebCore
@@ -308,12 +308,6 @@ void RenderSVGRoot::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject>
builder.insertChildToSVGRoot(*this, WTFMove(newChild), beforeChild);
}

RenderPtr<RenderObject> RenderSVGRoot::takeChild(RenderTreeBuilder& builder, RenderObject& child)
{
SVGResourcesCache::clientWillBeRemovedFromTree(child);
return RenderReplaced::takeChild(builder, child);
}

// RenderBox methods will expect coordinates w/o any transforms in coordinates
// relative to our borderBox origin. This method gives us exactly that.
void RenderSVGRoot::buildLocalToBorderBoxTransform()
@@ -83,7 +83,6 @@ class RenderSVGRoot final : public RenderReplaced {

void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = 0) override;
RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) override;

const AffineTransform& localToParentTransform() const override;

@@ -525,17 +525,6 @@ void RenderSVGText::addChild(RenderTreeBuilder& builder, RenderPtr<RenderObject>
builder.insertChildToSVGText(*this, WTFMove(newChild), beforeChild);
}

RenderPtr<RenderObject> RenderSVGText::takeChild(RenderTreeBuilder& builder, RenderObject& child)
{
SVGResourcesCache::clientWillBeRemovedFromTree(child);

Vector<SVGTextLayoutAttributes*, 2> affectedAttributes;
subtreeChildWillBeRemoved(&child, affectedAttributes);
auto takenChild = RenderSVGBlock::takeChild(builder, child);
subtreeChildWasRemoved(affectedAttributes);
return takenChild;
}

// Fix for <rdar://problem/8048875>. We should not render :first-line CSS Style
// in a SVG text element context.
RenderBlock* RenderSVGText::firstLineBlock() const
@@ -84,7 +84,6 @@ class RenderSVGText final : public RenderSVGBlock {
void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags, bool* wasFixed) const override;
const RenderObject* pushMappingToContainer(const RenderLayerModelObject* ancestorToStopAt, RenderGeometryMap&) const override;
void addChild(RenderTreeBuilder&, RenderPtr<RenderObject> child, RenderObject* beforeChild = nullptr) override;
RenderPtr<RenderObject> takeChild(RenderTreeBuilder&, RenderObject&) override;
void willBeDestroyed(RenderTreeBuilder&) override;

const AffineTransform& localToParentTransform() const override { return m_localTransform; }
@@ -33,6 +33,9 @@
#include "RenderRuby.h"
#include "RenderRubyBase.h"
#include "RenderRubyRun.h"
#include "RenderSVGContainer.h"
#include "RenderSVGInline.h"
#include "RenderSVGRoot.h"
#include "RenderTable.h"
#include "RenderTableRow.h"
#include "RenderTableSection.h"
@@ -209,6 +212,18 @@ RenderPtr<RenderObject> RenderTreeBuilder::takeChild(RenderElement& parent, Rend
if (is<RenderGrid>(parent))
return takeChildFromRenderGrid(downcast<RenderGrid>(parent), child);

if (is<RenderSVGText>(parent))
return svgBuilder().takeChild(downcast<RenderSVGText>(parent), child);

if (is<RenderSVGInline>(parent))
return svgBuilder().takeChild(downcast<RenderSVGInline>(parent), child);

if (is<RenderSVGContainer>(parent))
return svgBuilder().takeChild(downcast<RenderSVGContainer>(parent), child);

if (is<RenderSVGRoot>(parent))
return svgBuilder().takeChild(downcast<RenderSVGRoot>(parent), child);

return parent.takeChild(*this, child);
}

@@ -72,4 +72,42 @@ void RenderTreeBuilder::SVG::insertChild(RenderSVGText& parent, RenderPtr<Render
parent.subtreeChildWasAdded(&childToAdd);
}

RenderPtr<RenderObject> RenderTreeBuilder::SVG::takeChild(RenderSVGText& parent, RenderObject& child)
{
SVGResourcesCache::clientWillBeRemovedFromTree(child);

Vector<SVGTextLayoutAttributes*, 2> affectedAttributes;
parent.subtreeChildWillBeRemoved(&child, affectedAttributes);
auto takenChild = parent.RenderBlockFlow::takeChild(m_builder, child);
parent.subtreeChildWasRemoved(affectedAttributes);
return takenChild;
}

RenderPtr<RenderObject> RenderTreeBuilder::SVG::takeChild(RenderSVGInline& parent, RenderObject& child)
{
SVGResourcesCache::clientWillBeRemovedFromTree(child);

auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(parent);
if (!textAncestor)
return parent.RenderElement::takeChild(m_builder, child);

Vector<SVGTextLayoutAttributes*, 2> affectedAttributes;
textAncestor->subtreeChildWillBeRemoved(&child, affectedAttributes);
auto takenChild = parent.RenderElement::takeChild(m_builder, child);
textAncestor->subtreeChildWasRemoved(affectedAttributes);
return takenChild;
}

RenderPtr<RenderObject> RenderTreeBuilder::SVG::takeChild(RenderSVGContainer& parent, RenderObject& child)
{
SVGResourcesCache::clientWillBeRemovedFromTree(child);
return parent.RenderElement::takeChild(m_builder, child);
}

RenderPtr<RenderObject> RenderTreeBuilder::SVG::takeChild(RenderSVGRoot& parent, RenderObject& child)
{
SVGResourcesCache::clientWillBeRemovedFromTree(child);
return parent.RenderElement::takeChild(m_builder, child);
}

}
@@ -43,6 +43,11 @@ class RenderTreeBuilder::SVG {
void insertChild(RenderSVGRoot& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
void insertChild(RenderSVGText& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);

RenderPtr<RenderObject> takeChild(RenderSVGText& parent, RenderObject& child);
RenderPtr<RenderObject> takeChild(RenderSVGInline& parent, RenderObject& child);
RenderPtr<RenderObject> takeChild(RenderSVGContainer& parent, RenderObject& child);
RenderPtr<RenderObject> takeChild(RenderSVGRoot& parent, RenderObject& child);

private:
RenderTreeBuilder& m_builder;
};

0 comments on commit 7384ae3

Please sign in to comment.