Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Unified Diff: third_party/WebKit/Source/web/FullscreenController.cpp

Issue 2122013003: Wait until after layout when restoring scroll on exiting fullscreen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests after foolip@'s patch Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/web/FullscreenController.h ('k') | third_party/WebKit/Source/web/WebViewImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/FullscreenController.cpp
diff --git a/third_party/WebKit/Source/web/FullscreenController.cpp b/third_party/WebKit/Source/web/FullscreenController.cpp
index 1bae36ff4b436c30d58968c72729a1267a63e0b4..1d0f0fcc1cfe818faf7921877ab15ccf4eba3ca6 100644
--- a/third_party/WebKit/Source/web/FullscreenController.cpp
+++ b/third_party/WebKit/Source/web/FullscreenController.cpp
@@ -55,6 +55,7 @@ FullscreenController::FullscreenController(WebViewImpl* webViewImpl)
: m_webViewImpl(webViewImpl)
, m_haveEnteredFullscreen(false)
, m_exitFullscreenPageScaleFactor(0)
+ , m_needsScrollAndScaleRestore(false)
, m_isCancelingFullScreen(false)
{
}
@@ -112,12 +113,11 @@ void FullscreenController::didExitFullscreen()
if (isHTMLVideoElement(element) && m_webViewImpl->layerTreeView())
m_webViewImpl->layerTreeView()->setHasTransparentBackground(m_webViewImpl->isTransparent());
- if (m_haveEnteredFullscreen) {
- m_webViewImpl->setPageScaleFactor(m_exitFullscreenPageScaleFactor);
- if (m_webViewImpl->mainFrame()->isWebLocalFrame())
- m_webViewImpl->mainFrame()->setScrollOffset(WebSize(m_exitFullscreenScrollOffset));
- m_webViewImpl->setVisualViewportOffset(m_exitFullscreenVisualViewportOffset);
- }
+ // We need to wait until style and layout are updated in order
+ // to propertly restore scroll offsets since content may not be
+ // overflowing in the same way until they do.
+ if (m_haveEnteredFullscreen)
+ m_needsScrollAndScaleRestore = true;
fullscreen->didExitFullscreen();
}
@@ -152,8 +152,10 @@ void FullscreenController::enterFullScreenForElement(Element* element)
// We need to store these values here rather than didEnterFullscreen since
// by the time the latter is called, a Resize has already occured, clamping
- // the scroll offset.
- if (!m_haveEnteredFullscreen) {
+ // the scroll offset. Don't save values if we're still waiting to restore
+ // a previous set. This can happen if we exit and quickly reenter fullscreen
+ // without performing a layout.
+ if (!m_haveEnteredFullscreen && !m_needsScrollAndScaleRestore) {
m_exitFullscreenPageScaleFactor = m_webViewImpl->pageScaleFactor();
m_exitFullscreenScrollOffset = m_webViewImpl->mainFrame()->isWebLocalFrame() ? m_webViewImpl->mainFrame()->scrollOffset() : WebSize();
m_exitFullscreenVisualViewportOffset = m_webViewImpl->visualViewportOffset();
@@ -200,6 +202,23 @@ void FullscreenController::updateSize()
Fullscreen::from(fullscreenElement->document()).didUpdateSize(*fullscreenElement);
}
+void FullscreenController::didUpdateLayout()
+{
+ if (!m_needsScrollAndScaleRestore)
+ return;
+
+ // If we re-entered fullscreen before we could restore the scroll and scale
+ // don't try restoring them yet.
+ if (isFullscreen())
+ return;
+
+ m_webViewImpl->setPageScaleFactor(m_exitFullscreenPageScaleFactor);
+ if (m_webViewImpl->mainFrame()->isWebLocalFrame())
+ m_webViewImpl->mainFrame()->setScrollOffset(WebSize(m_exitFullscreenScrollOffset));
+ m_webViewImpl->setVisualViewportOffset(m_exitFullscreenVisualViewportOffset);
+ m_needsScrollAndScaleRestore = false;
+}
+
void FullscreenController::updatePageScaleConstraints(bool removeConstraints)
{
PageScaleConstraints fullscreenConstraints;
« no previous file with comments | « third_party/WebKit/Source/web/FullscreenController.h ('k') | third_party/WebKit/Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698