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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1488653002: Fix scroll restoration when exiting fullscreen mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Accidentally made will_cause_resize always false in previous cleanup. Fixed Created 4 years, 11 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
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 2612caf128a20ba5c78dab342b5d4ee3c009a40f..d5714dd1342944796d30481b5339ff70366778f1 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1685,11 +1685,13 @@ void WebContentsImpl::EnterFullscreenMode(const GURL& origin) {
delegate_->EnterFullscreenModeForTab(this, origin);
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
- DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab(
- GetRenderViewHost()->GetWidget())));
+ DidToggleFullscreenModeForTab(
+ IsFullscreenForCurrentTab(
+ GetRenderViewHost()->GetWidget()),
+ false));
}
-void WebContentsImpl::ExitFullscreenMode() {
+void WebContentsImpl::ExitFullscreenMode(bool will_cause_resize) {
// This method is being called to leave renderer-initiated fullscreen mode.
// Make sure any existing fullscreen widget is shut down first.
RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView();
@@ -1707,20 +1709,26 @@ void WebContentsImpl::ExitFullscreenMode() {
if (delegate_)
delegate_->ExitFullscreenModeForTab(this);
- // Ensure web contents exit fullscreen state by sending a resize message,
- // which includes the fullscreen state. This is required for the situation
- // of the browser moving the view into a fullscreen state "browser fullscreen"
- // and then the contents entering "tab fullscreen". Exiting the contents
- // "tab fullscreen" then won't have the side effect of the view resizing,
- // hence the explicit call here is required.
- if (RenderWidgetHostView* rwh_view = GetRenderWidgetHostView()) {
- if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost())
- render_widget_host->WasResized();
+ // The fullscreen state is communicated to the renderer through a resize
+ // message. If the change in fullscreen state doesn't cause a view resize
+ // then we must ensure web contents exit the fullscreen state by explicitly
+ // sending a resize message. This is required for the situation of the browser
+ // moving the view into a "browser fullscreen" state and then the contents
+ // entering "tab fullscreen". Exiting the contents "tab fullscreen" then won't
+ // have the side effect of the view resizing, hence the explicit call here is
+ // required.
+ if (!will_cause_resize) {
+ if (RenderWidgetHostView* rwhv = GetRenderWidgetHostView()) {
+ if (RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost())
+ render_widget_host->WasResized();
+ }
}
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
- DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab(
- GetRenderViewHost()->GetWidget())));
+ DidToggleFullscreenModeForTab(
+ IsFullscreenForCurrentTab(
+ GetRenderViewHost()->GetWidget()),
+ will_cause_resize));
}
bool WebContentsImpl::IsFullscreenForCurrentTab(
@@ -2885,10 +2893,10 @@ void WebContentsImpl::HasManifest(const HasManifestCallback& callback) {
manifest_manager_host_->HasManifest(GetMainFrame(), callback);
}
-void WebContentsImpl::ExitFullscreen() {
+void WebContentsImpl::ExitFullscreen(bool will_cause_resize) {
// Clean up related state and initiate the fullscreen exit.
GetRenderViewHost()->GetWidget()->RejectMouseLockOrUnlockIfNecessary();
- ExitFullscreenMode();
+ ExitFullscreenMode(will_cause_resize);
}
void WebContentsImpl::ResumeLoadingCreatedWebContents() {
@@ -3071,7 +3079,7 @@ void WebContentsImpl::DidNavigateMainFramePreCommit(
return;
}
if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget()))
- ExitFullscreen();
+ ExitFullscreen(false);
DCHECK(!IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget()));
}
@@ -3943,7 +3951,7 @@ void WebContentsImpl::RenderViewTerminated(RenderViewHost* rvh,
// Ensure fullscreen mode is exited in the |delegate_| since a crashed
// renderer may not have made a clean exit.
if (IsFullscreenForCurrentTab(GetRenderViewHost()->GetWidget()))
- ExitFullscreenMode();
+ ExitFullscreenMode(false);
// Cancel any visible dialogs so they are not left dangling over the sad tab.
CancelActiveAndPendingDialogs();
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/screen_orientation_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698