Commit c392fc40 authored by esprehn@chromium.org's avatar esprehn@chromium.org

Move dispatchDidFirstVisuallyNonEmptyLayout into WebViewImpl.

This removes the last user of didLayoutWithPendingStylesheets() and instead moves
the call to dispatchDidFirstVisuallyNonEmptyLayout into WebViewImpl so the
notification to the embedder is tied to the pumping of frames. This changes the
behavior of this notification to only dispatch for the top level frame,
but Chromium already has a check for that:

https://chromium.googlesource.com/chromium/src/+/976d4d9a2735bdc11e5a641c84b6382566d48f1d/content/renderer/render_frame_impl.cc#3472

RenderFrameImpl::didFirstVisuallyNonEmptyLayout's first check is

if (frame->parent())
    return;

so we already ignore all frames that are not the main frame. Future patches will
clean up this interface so it's obvious this really only happens for the main
frame.

BUG=521692
R=dglazkov@chromium.org

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

git-svn-id: svn://svn.chromium.org/blink/trunk@200664 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 57b5bc17
......@@ -213,7 +213,6 @@ void FrameView::reset()
m_visuallyNonEmptyCharacterCount = 0;
m_visuallyNonEmptyPixelCount = 0;
m_isVisuallyNonEmpty = false;
m_firstVisuallyNonEmptyLayoutCallbackPending = true;
clearScrollAnchor();
m_viewportConstrainedObjects.clear();
m_layoutSubtreeRootList.clear();
......@@ -1067,6 +1066,11 @@ void FrameView::layout()
layoutView()->assertSubtreeIsLaidOut();
#endif
// Ensure that we become visually non-empty eventually.
// TODO(esprehn): This should check isRenderingReady() instead.
if (!frame().document()->parsing() && frame().loader().stateMachine()->committedFirstRealDocumentLoad())
m_isVisuallyNonEmpty = true;
// FIXME: It should be not possible to remove the FrameView from the frame/page during layout
// however m_inPerformLayout is not set for most of this function, so none of our RELEASE_ASSERTS
// in LocalFrame/Page will fire. One of the post-layout tasks is disconnecting the LocalFrame from
......@@ -1970,19 +1974,6 @@ void FrameView::performPostLayoutTasks()
m_frame->selection().updateAppearance();
ASSERT(m_frame->document());
if (m_nestedLayoutCount <= 1) {
// Ensure that we always send this eventually.
if (!m_frame->document()->parsing() && m_frame->loader().stateMachine()->committedFirstRealDocumentLoad())
m_isVisuallyNonEmpty = true;
// If the layout was done with pending sheets, we are not in fact visually non-empty yet.
if (m_isVisuallyNonEmpty && !m_frame->document()->didLayoutWithPendingStylesheets() && m_firstVisuallyNonEmptyLayoutCallbackPending) {
m_firstVisuallyNonEmptyLayoutCallbackPending = false;
// FIXME: This callback is probably not needed, but is currently used
// by android for setting the background color.
m_frame->loader().client()->dispatchDidFirstVisuallyNonEmptyLayout();
}
}
FontFaceSet::didLayout(*m_frame->document());
// Cursor update scheduling is done by the local root, which is the main frame if there
......
......@@ -233,6 +233,7 @@ public:
void incrementVisuallyNonEmptyCharacterCount(unsigned);
void incrementVisuallyNonEmptyPixelCount(const IntSize&);
bool isVisuallyNonEmpty() const { return m_isVisuallyNonEmpty; }
void setIsVisuallyNonEmpty() { m_isVisuallyNonEmpty = true; }
void enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSize);
void disableAutoSizeMode();
......@@ -777,7 +778,6 @@ private:
unsigned m_visuallyNonEmptyCharacterCount;
unsigned m_visuallyNonEmptyPixelCount;
bool m_isVisuallyNonEmpty;
bool m_firstVisuallyNonEmptyLayoutCallbackPending;
RefPtrWillBeMember<Node> m_scrollAnchor;
......
......@@ -76,6 +76,7 @@
#include "core/loader/DocumentLoader.h"
#include "core/loader/FrameLoadRequest.h"
#include "core/loader/FrameLoader.h"
#include "core/loader/FrameLoaderClient.h"
#include "core/page/ContextMenuController.h"
#include "core/page/ContextMenuProvider.h"
#include "core/page/DragController.h"
......@@ -456,6 +457,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
, m_backgroundColorOverride(Color::transparent)
, m_zoomFactorOverride(0)
, m_userGestureObserved(false)
, m_shouldDispatchFirstVisuallyNonEmptyLayout(false)
, m_displayMode(WebDisplayModeBrowser)
, m_elasticOverscroll(FloatSize())
{
......@@ -1926,6 +1928,15 @@ void WebViewImpl::layout()
m_inspectorOverlay->layout();
for (size_t i = 0; i < m_linkHighlights.size(); ++i)
m_linkHighlights[i]->updateGeometry();
if (FrameView* view = mainFrameImpl()->frameView()) {
if (m_shouldDispatchFirstVisuallyNonEmptyLayout && view->isVisuallyNonEmpty()) {
m_shouldDispatchFirstVisuallyNonEmptyLayout = false;
// TODO(esprehn): Move users of this callback to something
// better, the heuristic for "visually non-empty" is bad.
mainFrameImpl()->frame()->loader().client()->dispatchDidFirstVisuallyNonEmptyLayout();
}
}
}
void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect)
......@@ -4191,6 +4202,7 @@ void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer)
// attempt to paint too early in the next page load.
m_layerTreeView->setDeferCommits(true);
m_layerTreeView->clearRootLayer();
m_shouldDispatchFirstVisuallyNonEmptyLayout = true;
page()->frameHost().visualViewport().clearLayersForTreeView(m_layerTreeView);
}
......
......@@ -758,6 +758,7 @@ private:
float m_zoomFactorOverride;
bool m_userGestureObserved;
bool m_shouldDispatchFirstVisuallyNonEmptyLayout;
WebDisplayMode m_displayMode;
FloatSize m_elasticOverscroll;
......
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