Skip to content

Commit 6d734ef

Browse files
RenderFlowThread state reset cleanup.
https://bugs.webkit.org/show_bug.cgi?id=164426 Reviewed by Simon Fraser. RenderFlowThread state reset is spread across several functions. This patch groups them together in RenderObject::resetFlowThreadState(). No change in functionality. * rendering/RenderBlock.cpp: (WebCore::RenderBlock::removeLeftoverAnonymousBlock): (WebCore::RenderBlock::dropAnonymousBoxChild): This is now part of resetFlowThreadState() since resetFlowThreadState gets called even when NotifyChildren is false. * rendering/RenderElement.cpp: (WebCore::RenderElement::insertChildInternal): Initialize the thread state before we notify the child. (WebCore::RenderElement::removeChildInternal): Reset the state even when NotifyChildren is false. (WebCore::RenderElement::willBeRemovedFromTree): This code is moved to removeFromRenderFlowThread(). (WebCore::RenderElement::removeFromRenderFlowThread): * rendering/RenderObject.cpp: (WebCore::RenderObject::initializeFlowThreadState): This is in transition for webkit.org/b/164428 (RenderFlowThread state initialization cleanup.) (WebCore::RenderObject::resetFlowThreadState): (WebCore::RenderObject::setParent): This was seemingly a random place to put flow state initialization. (WebCore::RenderObject::willBeRemovedFromTree): resetFlowThreadState() takes care of it now. * rendering/RenderObject.h: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@208414 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 8817e5b commit 6d734ef

File tree

5 files changed

+69
-22
lines changed

5 files changed

+69
-22
lines changed

Source/WebCore/ChangeLog

+28
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
2016-11-04 Zalan Bujtas <[email protected]>
2+
3+
RenderFlowThread state reset cleanup.
4+
https://bugs.webkit.org/show_bug.cgi?id=164426
5+
6+
Reviewed by Simon Fraser.
7+
8+
RenderFlowThread state reset is spread across several functions. This patch groups them
9+
together in RenderObject::resetFlowThreadState().
10+
11+
No change in functionality.
12+
13+
* rendering/RenderBlock.cpp:
14+
(WebCore::RenderBlock::removeLeftoverAnonymousBlock):
15+
(WebCore::RenderBlock::dropAnonymousBoxChild): This is now part of resetFlowThreadState() since resetFlowThreadState
16+
gets called even when NotifyChildren is false.
17+
* rendering/RenderElement.cpp:
18+
(WebCore::RenderElement::insertChildInternal): Initialize the thread state before we notify the child.
19+
(WebCore::RenderElement::removeChildInternal): Reset the state even when NotifyChildren is false.
20+
(WebCore::RenderElement::willBeRemovedFromTree): This code is moved to removeFromRenderFlowThread().
21+
(WebCore::RenderElement::removeFromRenderFlowThread):
22+
* rendering/RenderObject.cpp:
23+
(WebCore::RenderObject::initializeFlowThreadState): This is in transition for webkit.org/b/164428 (RenderFlowThread state initialization cleanup.)
24+
(WebCore::RenderObject::resetFlowThreadState):
25+
(WebCore::RenderObject::setParent): This was seemingly a random place to put flow state initialization.
26+
(WebCore::RenderObject::willBeRemovedFromTree): resetFlowThreadState() takes care of it now.
27+
* rendering/RenderObject.h:
28+
129
2016-11-04 Yusuke Suzuki <[email protected]>
230

331
[DOMJIT] Add DOMJIT::Signature annotation to Document::getElementById

Source/WebCore/rendering/RenderBlock.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ void RenderBlock::removeLeftoverAnonymousBlock(RenderBlock* child)
768768
child->m_next = 0;
769769

770770
// Remove all the information in the flow thread associated with the leftover anonymous block.
771-
child->removeFromRenderFlowThread();
771+
child->resetFlowThreadStateOnRemoval();
772772

773773
child->setParent(0);
774774
child->setPreviousSibling(0);
@@ -812,9 +812,6 @@ void RenderBlock::dropAnonymousBoxChild(RenderBlock& parent, RenderBlock& child)
812812
{
813813
parent.setNeedsLayoutAndPrefWidthsRecalc();
814814
parent.setChildrenInline(child.childrenInline());
815-
if (auto* childFlowThread = child.flowThreadContainingBlock())
816-
childFlowThread->removeFlowChildInfo(&child);
817-
818815
RenderObject* nextSibling = child.nextSibling();
819816
parent.removeChildInternal(child, child.hasLayer() ? NotifyChildren : DontNotifyChildren);
820817
child.moveAllChildrenTo(&parent, nextSibling, child.hasLayer());

Source/WebCore/rendering/RenderElement.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ void RenderElement::insertChildInternal(RenderObject* newChild, RenderObject* be
572572
m_lastChild = newChild;
573573
}
574574

575+
newChild->initializeFlowThreadStateOnInsertion();
575576
if (!documentBeingDestroyed()) {
576577
if (notifyChildren == NotifyChildren)
577578
newChild->insertedIntoTree();
@@ -626,6 +627,8 @@ void RenderElement::removeChildInternal(RenderObject& oldChild, NotifyChildrenTy
626627
if (!documentBeingDestroyed() && notifyChildren == NotifyChildren)
627628
oldChild.willBeRemovedFromTree();
628629

630+
oldChild.resetFlowThreadStateOnRemoval();
631+
629632
// WARNING: There should be no code running between willBeRemovedFromTree and the actual removal below.
630633
// This is needed to avoid race conditions where willBeRemovedFromTree would dirty the tree's structure
631634
// and the code running here would force an untimely rebuilding, leaving |oldChild| dangling.
@@ -1085,11 +1088,6 @@ void RenderElement::willBeRemovedFromTree()
10851088
if (isOutOfFlowPositioned() && parent()->childrenInline())
10861089
parent()->dirtyLinesFromChangedChild(*this);
10871090

1088-
if (auto* containerFlowThread = parent()->renderNamedFlowThreadWrapper())
1089-
containerFlowThread->removeFlowChild(*this);
1090-
1091-
removeFromRenderFlowThread();
1092-
10931091
RenderObject::willBeRemovedFromTree();
10941092
}
10951093

@@ -2208,9 +2206,9 @@ RespectImageOrientationEnum RenderElement::shouldRespectImageOrientation() const
22082206

22092207
void RenderElement::removeFromRenderFlowThread()
22102208
{
2211-
if (flowThreadState() == NotInsideFlowThread)
2212-
return;
2213-
2209+
ASSERT(flowThreadState() != NotInsideFlowThread);
2210+
if (auto* containerFlowThread = parent()->renderNamedFlowThreadWrapper())
2211+
containerFlowThread->removeFlowChild(*this);
22142212
// Sometimes we remove the element from the flow, but it's not destroyed at that time.
22152213
// It's only until later when we actually destroy it and remove all the children from it.
22162214
// Currently, that happens for firstLetter elements and list markers.

Source/WebCore/rendering/RenderObject.cpp

+31-10
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,40 @@ void RenderObject::setFlowThreadStateIncludingDescendants(FlowThreadState state)
177177
}
178178
}
179179

180+
void RenderObject::initializeFlowThreadStateOnInsertion()
181+
{
182+
ASSERT(parent());
183+
184+
if (flowThreadState() == parent()->flowThreadState())
185+
return;
186+
187+
// A RenderFlowThread is always considered to be inside itself, so it never has to change its state in response to parent changes.
188+
if (isRenderFlowThread())
189+
return;
190+
191+
setFlowThreadStateIncludingDescendants(parent()->flowThreadState());
192+
}
193+
194+
void RenderObject::resetFlowThreadStateOnRemoval()
195+
{
196+
if (flowThreadState() == NotInsideFlowThread)
197+
return;
198+
199+
if (!documentBeingDestroyed() && is<RenderElement>(*this)) {
200+
downcast<RenderElement>(*this).removeFromRenderFlowThread();
201+
return;
202+
}
203+
204+
// A RenderFlowThread is always considered to be inside itself, so it never has to change its state in response to parent changes.
205+
if (isRenderFlowThread())
206+
return;
207+
208+
setFlowThreadStateIncludingDescendants(NotInsideFlowThread);
209+
}
210+
180211
void RenderObject::setParent(RenderElement* parent)
181212
{
182213
m_parent = parent;
183-
184-
// Only update if our flow thread state is different from our new parent and if we're not a RenderFlowThread.
185-
// A RenderFlowThread is always considered to be inside itself, so it never has to change its state
186-
// in response to parent changes.
187-
FlowThreadState newState = parent ? parent->flowThreadState() : NotInsideFlowThread;
188-
if (newState != flowThreadState() && !isRenderFlowThread())
189-
setFlowThreadStateIncludingDescendants(newState);
190214
}
191215

192216
void RenderObject::removeFromParent()
@@ -1450,9 +1474,6 @@ void RenderObject::insertedIntoTree()
14501474
void RenderObject::willBeRemovedFromTree()
14511475
{
14521476
// FIXME: We should ASSERT(isRooted()) but we have some out-of-order removals which would need to be fixed first.
1453-
1454-
setFlowThreadState(NotInsideFlowThread);
1455-
14561477
// Update cached boundaries in SVG renderers, if a child is removed.
14571478
parent()->setNeedsBoundariesUpdate();
14581479
}

Source/WebCore/rendering/RenderObject.h

+3
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,9 @@ class RenderObject : public CachedImageClient {
818818
virtual RenderFlowThread* locateFlowThreadContainingBlock() const;
819819
static void calculateBorderStyleColor(const EBorderStyle&, const BoxSide&, Color&);
820820

821+
void initializeFlowThreadStateOnInsertion();
822+
void resetFlowThreadStateOnRemoval();
823+
821824
private:
822825
#ifndef NDEBUG
823826
bool isSetNeedsLayoutForbidden() const { return m_setNeedsLayoutForbidden; }

0 commit comments

Comments
 (0)