diff options
Diffstat (limited to 'chromium/content')
4 files changed, 27 insertions, 32 deletions
diff --git a/chromium/content/browser/frame_host/render_frame_host_impl.cc b/chromium/content/browser/frame_host/render_frame_host_impl.cc index 5f651966422..f9a8ff26e87 100644 --- a/chromium/content/browser/frame_host/render_frame_host_impl.cc +++ b/chromium/content/browser/frame_host/render_frame_host_impl.cc @@ -2587,17 +2587,7 @@ void RenderFrameHostImpl::OnToggleFullscreen(bool enter_fullscreen) { if (enter_fullscreen) delegate_->EnterFullscreenMode(last_committed_url().GetOrigin()); else - delegate_->ExitFullscreenMode(/* will_cause_resize */ true); - - // The previous call might change the fullscreen state. We need to make sure - // the renderer is aware of that, which is done via the resize message. - // Typically, this will be sent as part of the call on the |delegate_| above - // when resizing the native windows, but sometimes fullscreen can be entered - // without causing a resize, so we need to ensure that the resize message is - // sent in that case. We always send this to the main frame's widget, and if - // there are any OOPIF widgets, this will also trigger them to resize via - // frameRectsChanged. - render_view_host_->GetWidget()->WasResized(); + delegate_->ExitFullscreenMode(/* will_cause_resize */ false); } void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) { diff --git a/chromium/content/browser/web_contents/web_contents_impl.cc b/chromium/content/browser/web_contents/web_contents_impl.cc index ee26efdd9cb..3ae6216917a 100644 --- a/chromium/content/browser/web_contents/web_contents_impl.cc +++ b/chromium/content/browser/web_contents/web_contents_impl.cc @@ -2036,6 +2036,26 @@ RenderWidgetHostInputEventRouter* WebContentsImpl::GetInputEventRouter() { return rwh_input_event_router_.get(); } +void WebContentsImpl::NotifyFullscreenChanged(bool will_cause_resize) { + // 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* rwh_view = GetRenderWidgetHostView()) { + if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) + render_widget_host->WasResized(); + } + } + + for (auto& observer : observers_) + observer.DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab(), will_cause_resize); +} + void WebContentsImpl::ReplicatePageFocus(bool is_focused) { // Focus loss may occur while this WebContents is being destroyed. Don't // send the message in this case, as the main frame's RenderFrameHost and @@ -2118,8 +2138,8 @@ void WebContentsImpl::EnterFullscreenMode(const GURL& origin) { if (delegate_) delegate_->EnterFullscreenModeForTab(this, origin); - for (auto& observer : observers_) - observer.DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab(), false); + if (IsFullscreenForCurrentTab()) + NotifyFullscreenChanged(false); } void WebContentsImpl::ExitFullscreenMode(bool will_cause_resize) { @@ -2140,25 +2160,8 @@ void WebContentsImpl::ExitFullscreenMode(bool will_cause_resize) { if (delegate_) delegate_->ExitFullscreenModeForTab(this); - // 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 (auto& observer : observers_) { - observer.DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab(), - will_cause_resize); - } + if (!IsFullscreenForCurrentTab()) + NotifyFullscreenChanged(will_cause_resize); } bool WebContentsImpl::IsFullscreenForCurrentTab() const { diff --git a/chromium/content/browser/web_contents/web_contents_impl.h b/chromium/content/browser/web_contents/web_contents_impl.h index afd40fc8389..be4efae1457 100644 --- a/chromium/content/browser/web_contents/web_contents_impl.h +++ b/chromium/content/browser/web_contents/web_contents_impl.h @@ -453,6 +453,7 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents, void GetManifest(const GetManifestCallback& callback) override; bool IsFullscreenForCurrentTab() const override; void ExitFullscreen(bool will_cause_resize) override; + void NotifyFullscreenChanged(bool will_cause_resize) override; void ResumeLoadingCreatedWebContents() override; void OnPasswordInputShownOnHttp() override; void OnAllPasswordInputsHiddenOnHttp() override; diff --git a/chromium/content/public/browser/web_contents.h b/chromium/content/public/browser/web_contents.h index 453942537f6..4a31e7bdbf0 100644 --- a/chromium/content/public/browser/web_contents.h +++ b/chromium/content/public/browser/web_contents.h @@ -758,6 +758,7 @@ class WebContents : public PageNavigator, // view resize. e.g. This will be false when going from tab fullscreen to // browser fullscreen. virtual void ExitFullscreen(bool will_cause_resize) = 0; + virtual void NotifyFullscreenChanged(bool will_cause_resize) = 0; // Unblocks requests from renderer for a newly created window. This is // used in showCreatedWindow() or sometimes later in cases where |