Skip to content

Commit

Permalink
[FrameView::layout cleanup] Move post layout task scheduling logic to…
Browse files Browse the repository at this point in the history
… a separate function

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

Reviewed by Simon Fraser.

Move and reorganize post layout task scheduling code.

Covered by existing tests.

* page/FrameView.cpp:
(WebCore::FrameView::layout):
(WebCore::FrameView::runOrSchedulePostLayoutTasks):
* page/FrameView.h:


Canonical link: https://commits.webkit.org/194732@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223717 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbaradlay committed Oct 19, 2017
1 parent c75463b commit 737cc5b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
17 changes: 17 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,20 @@
2017-10-19 Zalan Bujtas <zalan@apple.com>

[FrameView::layout cleanup] Move post layout task scheduling logic to a separate function
https://bugs.webkit.org/show_bug.cgi?id=178538
<rdar://problem/35080743>

Reviewed by Simon Fraser.

Move and reorganize post layout task scheduling code.

Covered by existing tests.

* page/FrameView.cpp:
(WebCore::FrameView::layout):
(WebCore::FrameView::runOrSchedulePostLayoutTasks):
* page/FrameView.h:

2017-10-19 Zalan Bujtas <zalan@apple.com>

[FrameView::layout cleanup] Move scrollbars setup logic to a separate function
Expand Down
48 changes: 30 additions & 18 deletions Source/WebCore/page/FrameView.cpp
Expand Up @@ -1548,28 +1548,40 @@ void FrameView::layout(bool allowSubtreeLayout)

frame().document()->markers().invalidateRectsForAllMarkers();

if (!m_postLayoutTasksTimer.isActive()) {
if (!m_inPerformPostLayoutTasks) {
if (isInChildFrameWithFrameFlattening())
updateWidgetPositions();
else
performPostLayoutTasks(); // Calls resumeScheduledEvents().
}

if (!m_postLayoutTasksTimer.isActive() && (needsLayout() || m_inPerformPostLayoutTasks || isInChildFrameWithFrameFlattening())) {
// If we need layout or are already in a synchronous call to postLayoutTasks(),
// defer widget updates and event dispatch until after we return. postLayoutTasks()
// can make us need to update again, and we can get stuck in a nasty cycle unless
// we call it through the timer here.
m_postLayoutTasksTimer.startOneShot(0_s);
}
if (needsLayout())
layout();
}
runOrSchedulePostLayoutTasks();

InspectorInstrumentation::didLayout(cookie, *layoutRoot);
DebugPageOverlays::didLayout(frame());
}

void FrameView::runOrSchedulePostLayoutTasks()
{
if (m_postLayoutTasksTimer.isActive())
return;

if (isInChildFrameWithFrameFlattening()) {
// While flattening frames, we defer post layout tasks to avoid getting stuck in a cycle,
// except updateWidgetPositions() which is required to kick off subframe layout in certain cases.
if (!m_inPerformPostLayoutTasks)
updateWidgetPositions();
m_postLayoutTasksTimer.startOneShot(0_s);
return;
}

// If we are already in performPostLayoutTasks(), defer post layout tasks until after we return
// to avoid re-entrancy.
if (m_inPerformPostLayoutTasks) {
m_postLayoutTasksTimer.startOneShot(0_s);
return;
}

performPostLayoutTasks();
if (needsLayout()) {
// If performPostLayoutTasks() made us layout again, let's defer the tasks until after we return.
m_postLayoutTasksTimer.startOneShot(0_s);
layout();
}
}

bool FrameView::shouldDeferScrollUpdateAfterContentSizeChange()
{
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/page/FrameView.h
Expand Up @@ -688,6 +688,7 @@ class FrameView final : public ScrollView {

void forceLayoutParentViewIfNeeded();
void flushPostLayoutTasksQueue();
void runOrSchedulePostLayoutTasks();
void performPostLayoutTasks();
void autoSizeIfEnabled();

Expand Down

0 comments on commit 737cc5b

Please sign in to comment.