Commit 068dfea7 authored by esprehn@chromium.org's avatar esprehn@chromium.org

Centralize deferred commit conditions.

Instead of having many callbacks that implicitly have conditions for when the
blink frame pipeline should run, have a function on Document that checks them
explicitly and make WebViewImpl call it.

This will allow checking if iframes are ready to begin running their lifecycle
phases when iterating the frame tree in ::beginFrame and ::layout().

BUG=521692

Review URL: https://codereview.chromium.org/1300043003

git-svn-id: svn://svn.chromium.org/blink/trunk@200783 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 40f18375
......@@ -367,6 +367,7 @@ Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC
, TreeScope(*this)
, m_hasNodesWithPlaceholderStyle(false)
, m_evaluateMediaQueriesOnStyleRecalc(false)
, m_shouldProcessFrameLifecycle(false)
, m_pendingSheetLayout(NoLayoutWithPendingSheets)
, m_frame(initializer.frame())
, m_domWindow(m_frame ? m_frame->localDOMWindow() : 0)
......@@ -5086,6 +5087,19 @@ void Document::pluginLoadingTimerFired(Timer<Document>*)
updateLayout();
}
bool Document::shouldProcessFrameLifecycle()
{
if (m_shouldProcessFrameLifecycle)
return true;
if (!isRenderingReady())
return false;
if ((isHTMLDocument() || isXHTMLDocument()) && !body() && parsing())
return false;
// Once the page starts processing the pipeline we should never stop.
m_shouldProcessFrameLifecycle = true;
return true;
}
ScriptedAnimationController& Document::ensureScriptedAnimationController()
{
if (!m_scriptedAnimationController) {
......
......@@ -908,6 +908,8 @@ public:
const DocumentTiming& timing() const { return m_documentTiming; }
bool shouldProcessFrameLifecycle();
int requestAnimationFrame(FrameRequestCallback*);
void cancelAnimationFrame(int id);
void serviceScriptedAnimations(double monotonicAnimationStartTime);
......@@ -1144,6 +1146,7 @@ private:
bool m_hasNodesWithPlaceholderStyle;
bool m_evaluateMediaQueriesOnStyleRecalc;
bool m_shouldProcessFrameLifecycle;
// If we do ignore the pending stylesheet count, then we need to add a boolean
// to track that this happened so that we can do a full repaint when the stylesheets
......
......@@ -3916,43 +3916,28 @@ void WebViewImpl::didCommitLoad(bool isNewNavigation, bool isNavigationWithinPag
void WebViewImpl::willInsertBody(WebLocalFrameImpl* webframe)
{
if (webframe != mainFrameImpl())
return;
if (!m_page->mainFrame()->isLocalFrame())
return;
// If we get to the <body> tag and we have no pending stylesheet and import load, we
// can be fairly confident we'll have something sensible to paint soon and
// can turn off deferred commits.
if (m_page->deprecatedLocalMainFrame()->document()->isRenderingReady())
resumeTreeViewCommits();
resumeTreeViewCommitsIfNeeded(webframe);
}
void WebViewImpl::didFinishDocumentLoad(WebLocalFrameImpl* webframe)
{
if (webframe != mainFrameImpl())
return;
// If we finished parsing and there's no sheets to load start painting.
if (webframe->frame()->document()->isRenderingReady())
resumeTreeViewCommits();
resumeTreeViewCommitsIfNeeded(webframe);
}
void WebViewImpl::didRemoveAllPendingStylesheet(WebLocalFrameImpl* webframe)
{
if (webframe != mainFrameImpl())
return;
// If we have no more stylesheets to load and we're past the body tag,
// we should have something to paint and should start as soon as possible.
if (m_page->deprecatedLocalMainFrame()->document()->body())
resumeTreeViewCommits();
resumeTreeViewCommitsIfNeeded(webframe);
}
void WebViewImpl::resumeTreeViewCommits()
void WebViewImpl::resumeTreeViewCommitsIfNeeded(WebLocalFrameImpl* webframe)
{
if (m_layerTreeView)
m_layerTreeView->setDeferCommits(false);
if (webframe != mainFrameImpl())
return;
if (!webframe->frame()->document()->shouldProcessFrameLifecycle())
return;
if (!m_layerTreeView)
return;
m_layerTreeView->setDeferCommits(false);
}
void WebViewImpl::postLayoutResize(WebLocalFrameImpl* webframe)
......
......@@ -540,7 +540,7 @@ private:
float maximumLegiblePageScale() const;
void refreshPageScaleFactorAfterLayout();
void resetScrollAndScaleState(bool immediately);
void resumeTreeViewCommits();
void resumeTreeViewCommitsIfNeeded(WebLocalFrameImpl*);
IntSize contentsSize() const;
void performResize();
......
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