Skip to content
Permalink
Browse files
[RenderTreeBuilder] Move RenderElement::removeAndDestroyChild() to Re…
…nderTreeBuilder

https://bugs.webkit.org/show_bug.cgi?id=182915
<rdar://problem/37658123>

Reviewed by Antti Koivisto.

No change in functionality.

* rendering/RenderElement.cpp:
(WebCore::RenderElement::removeAndDestroyChild): Deleted.
* rendering/RenderElement.h:
(WebCore::RenderElement::isChildAllowed const):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::removeFromParentAndDestroy):
* rendering/RenderView.cpp:
(WebCore::RenderView::willBeDestroyed):
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::removeAndDestroyChild):
(WebCore::RenderTreeBuilder::removeFromParentAndDestroyCleaningUpAnonymousWrappers):
* rendering/updating/RenderTreeBuilder.h:
* rendering/updating/RenderTreeBuilderFirstLetter.cpp:
(WebCore::RenderTreeBuilder::FirstLetter::updateStyle):
(WebCore::RenderTreeBuilder::FirstLetter::createRenderers):


Canonical link: https://commits.webkit.org/198674@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Feb 19, 2018
1 parent fbb2800 commit f5411108ef074099d04af66c721f0c8ac8b1359c
@@ -1,3 +1,29 @@
2018-02-19 Zalan Bujtas <zalan@apple.com>

[RenderTreeBuilder] Move RenderElement::removeAndDestroyChild() to RenderTreeBuilder
https://bugs.webkit.org/show_bug.cgi?id=182915
<rdar://problem/37658123>

Reviewed by Antti Koivisto.

No change in functionality.

* rendering/RenderElement.cpp:
(WebCore::RenderElement::removeAndDestroyChild): Deleted.
* rendering/RenderElement.h:
(WebCore::RenderElement::isChildAllowed const):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::removeFromParentAndDestroy):
* rendering/RenderView.cpp:
(WebCore::RenderView::willBeDestroyed):
* rendering/updating/RenderTreeBuilder.cpp:
(WebCore::RenderTreeBuilder::removeAndDestroyChild):
(WebCore::RenderTreeBuilder::removeFromParentAndDestroyCleaningUpAnonymousWrappers):
* rendering/updating/RenderTreeBuilder.h:
* rendering/updating/RenderTreeBuilderFirstLetter.cpp:
(WebCore::RenderTreeBuilder::FirstLetter::updateStyle):
(WebCore::RenderTreeBuilder::FirstLetter::createRenderers):

2018-02-12 Sergio Villar Senin <svillar@igalia.com>

[WebVR][OpenVR] Implement getVRDisplays()
@@ -473,24 +473,6 @@ void RenderElement::didInsertChild(RenderObject& child, RenderObject*)
SVGRenderSupport::childAdded(*this, child);
}

void RenderElement::removeAndDestroyChild(RenderTreeBuilder& builder, RenderObject& oldChild)
{
auto toDestroy = builder.takeChild(*this, oldChild);
// We need to detach the subtree first so that the descendants don't have
// access to previous/next sublings at takeChild().
// FIXME: webkit.org/b/182909.
if (!is<RenderElement>(toDestroy.get()))
return;

auto& child = downcast<RenderElement>(*toDestroy.get());
while (child.firstChild()) {
auto& firstChild = *child.firstChild();
if (auto* node = firstChild.node())
node->setRenderer(nullptr);
child.removeAndDestroyChild(builder, firstChild);
}
}

RenderObject* RenderElement::attachRendererInternal(RenderPtr<RenderObject> child, RenderObject* beforeChild)
{
child->setParent(this);
@@ -87,7 +87,6 @@ class RenderElement : public RenderObject {
bool isRenderInline() const;

virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const { return true; }
void removeAndDestroyChild(RenderTreeBuilder&, RenderObject&);
void didInsertChild(RenderObject& child, RenderObject* beforeChild);

// The following functions are used when the render tree hierarchy changes to make sure layers get
@@ -258,7 +258,7 @@ void RenderObject::setParent(RenderElement* parent)
void RenderObject::removeFromParentAndDestroy(RenderTreeBuilder& builder)
{
ASSERT(m_parent);
m_parent->removeAndDestroyChild(builder, *this);
builder.removeAndDestroyChild(*this);
}

RenderObject* RenderObject::nextInPreOrder() const
@@ -616,7 +616,7 @@ void RenderView::willBeDestroyed(RenderTreeBuilder& builder)
RenderBlockFlow::willBeDestroyed(builder);
// FIXME: This is a workaround for leftover content (see webkit.org/b/182547).
while (firstChild())
removeAndDestroyChild(builder, *firstChild());
builder.removeAndDestroyChild(*firstChild());

ASSERT_WITH_MESSAGE(m_rendererCount == 1, "All other renderers in this render tree should have been destroyed");
}
@@ -139,6 +139,25 @@ RenderTreeBuilder::~RenderTreeBuilder()
s_current = m_previous;
}

void RenderTreeBuilder::removeAndDestroyChild(RenderObject& child)
{
ASSERT(child.parent());
auto toDestroy = takeChild(*child.parent(), child);
// We need to detach the subtree first so that the descendants don't have
// access to previous/next sublings at takeChild().
// FIXME: webkit.org/b/182909.
if (!is<RenderElement>(toDestroy.get()))
return;

auto& childToDestroy = downcast<RenderElement>(*toDestroy.get());
while (childToDestroy.firstChild()) {
auto& firstChild = *childToDestroy.firstChild();
if (auto* node = firstChild.node())
node->setRenderer(nullptr);
removeAndDestroyChild(firstChild);
}
}

void RenderTreeBuilder::insertChild(RenderElement& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
{
auto insertRecursiveIfNeeded = [&](RenderElement& parentCandidate) {
@@ -639,7 +658,7 @@ void RenderTreeBuilder::removeFromParentAndDestroyCleaningUpAnonymousWrappers(Re
tableBuilder().collapseAndDestroyAnonymousSiblingRows(downcast<RenderTableRow>(destroyRoot));

auto& destroyRootParent = *destroyRoot.parent();
destroyRootParent.removeAndDestroyChild(*this, destroyRoot);
removeAndDestroyChild(destroyRoot);
removeAnonymousWrappersForInlineChildrenIfNeeded(destroyRootParent);

// Anonymous parent might have become empty, try to delete it too.
@@ -44,6 +44,7 @@ class RenderTreeBuilder {
void insertChild(RenderTreePosition&, RenderPtr<RenderObject>);
void insertChild(RenderElement& parent, RenderPtr<RenderObject>, RenderObject* beforeChild = nullptr);

void removeAndDestroyChild(RenderObject& child);
RenderPtr<RenderObject> takeChild(RenderElement&, RenderObject&) WARN_UNUSED_RETURN;

// NormalizeAfterInsertion::Yes ensures that the destination subtree is consistent after the insertion (anonymous wrappers etc).
@@ -185,7 +185,7 @@ void RenderTreeBuilder::FirstLetter::updateStyle(RenderBlock& firstLetterBlock,
remainingText->setFirstLetter(*newFirstLetter);
newFirstLetter->setFirstLetterRemainingText(*remainingText);
}
firstLetterContainer->removeAndDestroyChild(m_builder, *firstLetter);
m_builder.removeAndDestroyChild(*firstLetter);
m_builder.insertChild(*firstLetterContainer, WTFMove(newFirstLetter), nextSibling);
return;
}
@@ -241,7 +241,7 @@ void RenderTreeBuilder::FirstLetter::createRenderers(RenderBlock& firstLetterBlo

auto* textNode = currentTextChild.textNode();
auto* beforeChild = currentTextChild.nextSibling();
firstLetterContainer->removeAndDestroyChild(m_builder, currentTextChild);
m_builder.removeAndDestroyChild(currentTextChild);

// Construct a text fragment for the text after the first letter.
// This text fragment might be empty.

0 comments on commit f541110

Please sign in to comment.