Commit be814f83 authored by akling@apple.com's avatar akling@apple.com

Simplify subtree relayout scheduling a bit.

<https://webkit.org/b/120684>

Reviewed by Antti Koivisto.

Subtree relayout scheduling should only happen while there's a render tree up,
the code can freely assume that there's a RenderView present.

Added an assertion that the render tree isn't being torn down. This should catch
renderers doing unnecessary work during document detach and could be a source
of "performance freebies."

I also un-nested scheduleRelayoutOfSubtree() with early-return style to make
the code more human-readable.

* page/FrameView.h:
* page/FrameView.cpp:
(WebCore::FrameView::scheduleRelayoutOfSubtree):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::scheduleRelayout):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155046 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bccd03d6
2013-09-04 Andreas Kling <akling@apple.com>
Simplify subtree relayout scheduling a bit.
<https://webkit.org/b/120684>
Reviewed by Antti Koivisto.
Subtree relayout scheduling should only happen while there's a render tree up,
the code can freely assume that there's a RenderView present.
Added an assertion that the render tree isn't being torn down. This should catch
renderers doing unnecessary work during document detach and could be a source
of "performance freebies."
I also un-nested scheduleRelayoutOfSubtree() with early-return style to make
the code more human-readable.
* page/FrameView.h:
* page/FrameView.cpp:
(WebCore::FrameView::scheduleRelayoutOfSubtree):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::scheduleRelayout):
2013-09-04 Jae Hyun Park <jae.park@company100.net>
[Coordinated Graphics] Remove unused method in CoordinatedGraphicsLayer
......@@ -2417,46 +2417,61 @@ static bool isObjectAncestorContainerOf(RenderObject* ancestor, RenderObject* de
return false;
}
void FrameView::scheduleRelayoutOfSubtree(RenderObject* relayoutRoot)
void FrameView::scheduleRelayoutOfSubtree(RenderObject& newRelayoutRoot)
{
ASSERT(renderView());
RenderView& renderView = *this->renderView();
// Try to catch unnecessary work during render tree teardown.
ASSERT(!renderView.documentBeingDestroyed());
ASSERT(frame().view() == this);
RenderView* renderView = this->renderView();
if (renderView && renderView->needsLayout()) {
if (relayoutRoot)
relayoutRoot->markContainingBlocksForLayout(false);
if (renderView.needsLayout()) {
newRelayoutRoot.markContainingBlocksForLayout(false);
return;
}
if (layoutPending() || !m_layoutSchedulingEnabled) {
if (m_layoutRoot != relayoutRoot) {
if (isObjectAncestorContainerOf(m_layoutRoot, relayoutRoot)) {
// Keep the current root
relayoutRoot->markContainingBlocksForLayout(false, m_layoutRoot);
ASSERT(!m_layoutRoot->container() || !m_layoutRoot->container()->needsLayout());
} else if (m_layoutRoot && isObjectAncestorContainerOf(relayoutRoot, m_layoutRoot)) {
// Re-root at relayoutRoot
m_layoutRoot->markContainingBlocksForLayout(false, relayoutRoot);
m_layoutRoot = relayoutRoot;
ASSERT(!m_layoutRoot->container() || !m_layoutRoot->container()->needsLayout());
InspectorInstrumentation::didInvalidateLayout(&frame());
} else {
// Just do a full relayout
if (m_layoutRoot)
m_layoutRoot->markContainingBlocksForLayout(false);
m_layoutRoot = 0;
relayoutRoot->markContainingBlocksForLayout(false);
InspectorInstrumentation::didInvalidateLayout(&frame());
}
}
} else if (m_layoutSchedulingEnabled) {
int delay = frame().document()->minimumLayoutDelay();
m_layoutRoot = relayoutRoot;
ASSERT(!m_layoutRoot->container() || !m_layoutRoot->container()->needsLayout());
if (!layoutPending() && m_layoutSchedulingEnabled) {
int delay = renderView.document().minimumLayoutDelay();
ASSERT(!newRelayoutRoot.container() || !newRelayoutRoot.container()->needsLayout());
m_layoutRoot = &newRelayoutRoot;
InspectorInstrumentation::didInvalidateLayout(&frame());
m_delayedLayout = delay != 0;
m_layoutTimer.startOneShot(delay * 0.001);
return;
}
if (m_layoutRoot == &newRelayoutRoot)
return;
if (!m_layoutRoot) {
// Just relayout the subtree.
newRelayoutRoot.markContainingBlocksForLayout(false);
InspectorInstrumentation::didInvalidateLayout(&frame());
return;
}
if (isObjectAncestorContainerOf(m_layoutRoot, &newRelayoutRoot)) {
// Keep the current root.
newRelayoutRoot.markContainingBlocksForLayout(false, m_layoutRoot);
ASSERT(!m_layoutRoot->container() || !m_layoutRoot->container()->needsLayout());
return;
}
if (isObjectAncestorContainerOf(&newRelayoutRoot, m_layoutRoot)) {
// Re-root at newRelayoutRoot.
m_layoutRoot->markContainingBlocksForLayout(false, &newRelayoutRoot);
m_layoutRoot = &newRelayoutRoot;
ASSERT(!m_layoutRoot->container() || !m_layoutRoot->container()->needsLayout());
InspectorInstrumentation::didInvalidateLayout(&frame());
return;
}
// Just do a full relayout.
m_layoutRoot->markContainingBlocksForLayout(false);
m_layoutRoot = 0;
newRelayoutRoot.markContainingBlocksForLayout(false);
InspectorInstrumentation::didInvalidateLayout(&frame());
}
bool FrameView::layoutPending() const
......
......@@ -101,7 +101,7 @@ public:
bool didFirstLayout() const;
void layoutTimerFired(Timer<FrameView>*);
void scheduleRelayout();
void scheduleRelayoutOfSubtree(RenderObject*);
void scheduleRelayoutOfSubtree(RenderObject&);
void unscheduleRelayout();
bool layoutPending() const;
bool isInLayout() const { return m_inLayout; }
......
......@@ -2768,7 +2768,7 @@ void RenderObject::scheduleRelayout()
toRenderView(*this).frameView().scheduleRelayout();
else {
if (isRooted())
view().frameView().scheduleRelayoutOfSubtree(this);
view().frameView().scheduleRelayoutOfSubtree(*this);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment