mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-09 08:38:41 +01:00
mac: Update CSS on fullscreen window exit (fixes #3597)
This commit is contained in:
parent
38848f1780
commit
9d1cdd020f
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=db4fce1215cb4f69346ef2d048974ba34187b2b1$
|
// $hash=13ba2d807f2c1ac3adfc65f2bdb269baecba57ec$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_CAPI_H_
|
||||||
@ -932,6 +932,29 @@ typedef struct _cef_browser_host_t {
|
|||||||
/// be called on the UI thread.
|
/// be called on the UI thread.
|
||||||
///
|
///
|
||||||
int(CEF_CALLBACK* is_audio_muted)(struct _cef_browser_host_t* self);
|
int(CEF_CALLBACK* is_audio_muted)(struct _cef_browser_host_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns true (1) if the renderer is currently in browser fullscreen. This
|
||||||
|
/// differs from window fullscreen in that browser fullscreen is entered using
|
||||||
|
/// the JavaScript Fullscreen API and modifies CSS attributes such as the
|
||||||
|
/// ::backdrop pseudo-element and :fullscreen pseudo-structure. This function
|
||||||
|
/// can only be called on the UI thread.
|
||||||
|
///
|
||||||
|
int(CEF_CALLBACK* is_fullscreen)(struct _cef_browser_host_t* self);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Requests the renderer to exit browser fullscreen. In most cases exiting
|
||||||
|
/// window fullscreen should also exit browser fullscreen. With the Alloy
|
||||||
|
/// runtime this function should be called in response to a user action such
|
||||||
|
/// as clicking the green traffic light button on MacOS
|
||||||
|
/// (cef_window_delegate_t::OnWindowFullscreenTransition callback) or pressing
|
||||||
|
/// the "ESC" key (cef_keyboard_handler_t::OnPreKeyEvent callback). With the
|
||||||
|
/// Chrome runtime these standard exit actions are handled internally but
|
||||||
|
/// new/additional user actions can use this function. Set |will_cause_resize|
|
||||||
|
/// to true (1) if exiting browser fullscreen will cause a view resize.
|
||||||
|
///
|
||||||
|
void(CEF_CALLBACK* exit_fullscreen)(struct _cef_browser_host_t* self,
|
||||||
|
int will_cause_resize);
|
||||||
} cef_browser_host_t;
|
} cef_browser_host_t;
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -42,13 +42,13 @@
|
|||||||
// way that may cause binary incompatibility with other builds. The universal
|
// way that may cause binary incompatibility with other builds. The universal
|
||||||
// hash value will change if any platform is affected whereas the platform hash
|
// hash value will change if any platform is affected whereas the platform hash
|
||||||
// values will change only if that particular platform is affected.
|
// values will change only if that particular platform is affected.
|
||||||
#define CEF_API_HASH_UNIVERSAL "4acea2e5c7a3e281d9652802ae1d24b25eef299b"
|
#define CEF_API_HASH_UNIVERSAL "87db318fb26ee0debfcb686433bd334ea7b9923d"
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#define CEF_API_HASH_PLATFORM "3a181fdfaa42d2214c77cd83f76886b0657b0b53"
|
#define CEF_API_HASH_PLATFORM "aee3b3f687dce72a3370f98309bb43f722596b83"
|
||||||
#elif defined(OS_MAC)
|
#elif defined(OS_MAC)
|
||||||
#define CEF_API_HASH_PLATFORM "06bfe874ee215bde0a415bac7ac37ecf4969d4ca"
|
#define CEF_API_HASH_PLATFORM "1cc534c1000bf82e8db52b8635272bb18daec4c2"
|
||||||
#elif defined(OS_LINUX)
|
#elif defined(OS_LINUX)
|
||||||
#define CEF_API_HASH_PLATFORM "1615f7e7079d89e2e81f683d4a8480455b5f2a60"
|
#define CEF_API_HASH_PLATFORM "47f4af678148110cb790fb48a957fb522446ecf2"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -964,6 +964,30 @@ class CefBrowserHost : public virtual CefBaseRefCounted {
|
|||||||
///
|
///
|
||||||
/*--cef()--*/
|
/*--cef()--*/
|
||||||
virtual bool IsAudioMuted() = 0;
|
virtual bool IsAudioMuted() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns true if the renderer is currently in browser fullscreen. This
|
||||||
|
/// differs from window fullscreen in that browser fullscreen is entered using
|
||||||
|
/// the JavaScript Fullscreen API and modifies CSS attributes such as the
|
||||||
|
/// ::backdrop pseudo-element and :fullscreen pseudo-class. This method can
|
||||||
|
/// only be called on the UI thread.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual bool IsFullscreen() = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Requests the renderer to exit browser fullscreen. In most cases exiting
|
||||||
|
/// window fullscreen should also exit browser fullscreen. With the Alloy
|
||||||
|
/// runtime this method should be called in response to a user action such as
|
||||||
|
/// clicking the green traffic light button on MacOS
|
||||||
|
/// (CefWindowDelegate::OnWindowFullscreenTransition callback) or pressing the
|
||||||
|
/// "ESC" key (CefKeyboardHandler::OnPreKeyEvent callback). With the Chrome
|
||||||
|
/// runtime these standard exit actions are handled internally but
|
||||||
|
/// new/additional user actions can use this method. Set |will_cause_resize|
|
||||||
|
/// to true if exiting browser fullscreen will cause a view resize.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void ExitFullscreen(bool will_cause_resize) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CEF_BROWSER_H_
|
#endif // CEF_INCLUDE_CEF_BROWSER_H_
|
||||||
|
@ -633,6 +633,31 @@ void CefBrowserHostBase::NotifyMoveOrResizeStarted() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CefBrowserHostBase::IsFullscreen() {
|
||||||
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
DCHECK(false) << "called on invalid thread";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto web_contents = GetWebContents()) {
|
||||||
|
return web_contents->IsFullscreen();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserHostBase::ExitFullscreen(bool will_cause_resize) {
|
||||||
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostBase::ExitFullscreen,
|
||||||
|
this, will_cause_resize));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto web_contents = GetWebContents();
|
||||||
|
if (web_contents && web_contents->IsFullscreen()) {
|
||||||
|
web_contents->ExitFullscreen(will_cause_resize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserHostBase::ReplaceMisspelling(const CefString& word) {
|
void CefBrowserHostBase::ReplaceMisspelling(const CefString& word) {
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
CEF_POST_TASK(
|
CEF_POST_TASK(
|
||||||
|
@ -212,6 +212,8 @@ class CefBrowserHostBase : public CefBrowserHost,
|
|||||||
bool current_only) override;
|
bool current_only) override;
|
||||||
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
|
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
|
||||||
void NotifyMoveOrResizeStarted() override;
|
void NotifyMoveOrResizeStarted() override;
|
||||||
|
bool IsFullscreen() override;
|
||||||
|
void ExitFullscreen(bool will_cause_resize) override;
|
||||||
|
|
||||||
// CefBrowser methods:
|
// CefBrowser methods:
|
||||||
bool IsValid() override;
|
bool IsValid() override;
|
||||||
|
@ -121,12 +121,18 @@ void CefNativeWidgetMac::OnWindowFullscreenTransitionStart() {
|
|||||||
views::NativeWidgetMac::OnWindowFullscreenTransitionStart();
|
views::NativeWidgetMac::OnWindowFullscreenTransitionStart();
|
||||||
if (IsCefWindowInitialized()) {
|
if (IsCefWindowInitialized()) {
|
||||||
window_delegate_->OnWindowFullscreenTransition(window_, false);
|
window_delegate_->OnWindowFullscreenTransition(window_, false);
|
||||||
|
if (browser_view_) {
|
||||||
|
browser_view_->FullscreenStateChanging();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefNativeWidgetMac::OnWindowFullscreenTransitionComplete() {
|
void CefNativeWidgetMac::OnWindowFullscreenTransitionComplete() {
|
||||||
views::NativeWidgetMac::OnWindowFullscreenTransitionComplete();
|
views::NativeWidgetMac::OnWindowFullscreenTransitionComplete();
|
||||||
if (IsCefWindowInitialized()) {
|
if (IsCefWindowInitialized()) {
|
||||||
|
if (browser_view_) {
|
||||||
|
browser_view_->FullscreenStateChanged();
|
||||||
|
}
|
||||||
window_delegate_->OnWindowFullscreenTransition(window_, true);
|
window_delegate_->OnWindowFullscreenTransition(window_, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=497607653318fe0245cbe18c8911e39867e16249$
|
// $hash=5358aa617ebb6d7d074e2d346599fbd6777f1770$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/cpptoc/browser_host_cpptoc.h"
|
#include "libcef_dll/cpptoc/browser_host_cpptoc.h"
|
||||||
@ -1435,6 +1435,39 @@ int CEF_CALLBACK browser_host_is_audio_muted(struct _cef_browser_host_t* self) {
|
|||||||
return _retval;
|
return _retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK browser_host_is_fullscreen(struct _cef_browser_host_t* self) {
|
||||||
|
shutdown_checker::AssertNotShutdown();
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
bool _retval = CefBrowserHostCppToC::Get(self)->IsFullscreen();
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK browser_host_exit_fullscreen(struct _cef_browser_host_t* self,
|
||||||
|
int will_cause_resize) {
|
||||||
|
shutdown_checker::AssertNotShutdown();
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefBrowserHostCppToC::Get(self)->ExitFullscreen(will_cause_resize ? true
|
||||||
|
: false);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// CONSTRUCTOR - Do not edit by hand.
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
@ -1512,6 +1545,8 @@ CefBrowserHostCppToC::CefBrowserHostCppToC() {
|
|||||||
GetStruct()->is_background_host = browser_host_is_background_host;
|
GetStruct()->is_background_host = browser_host_is_background_host;
|
||||||
GetStruct()->set_audio_muted = browser_host_set_audio_muted;
|
GetStruct()->set_audio_muted = browser_host_set_audio_muted;
|
||||||
GetStruct()->is_audio_muted = browser_host_is_audio_muted;
|
GetStruct()->is_audio_muted = browser_host_is_audio_muted;
|
||||||
|
GetStruct()->is_fullscreen = browser_host_is_fullscreen;
|
||||||
|
GetStruct()->exit_fullscreen = browser_host_exit_fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DESTRUCTOR - Do not edit by hand.
|
// DESTRUCTOR - Do not edit by hand.
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=cd4e4aa1670f0c887090e23f5e7e3a01e5de9d13$
|
// $hash=4d51bbece0dd5773f9c97163008d6b2f4bf1ccbf$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/ctocpp/browser_host_ctocpp.h"
|
#include "libcef_dll/ctocpp/browser_host_ctocpp.h"
|
||||||
@ -1229,6 +1229,38 @@ NO_SANITIZE("cfi-icall") bool CefBrowserHostCToCpp::IsAudioMuted() {
|
|||||||
return _retval ? true : false;
|
return _retval ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NO_SANITIZE("cfi-icall") bool CefBrowserHostCToCpp::IsFullscreen() {
|
||||||
|
shutdown_checker::AssertNotShutdown();
|
||||||
|
|
||||||
|
cef_browser_host_t* _struct = GetStruct();
|
||||||
|
if (CEF_MEMBER_MISSING(_struct, is_fullscreen)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = _struct->is_fullscreen(_struct);
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
NO_SANITIZE("cfi-icall")
|
||||||
|
void CefBrowserHostCToCpp::ExitFullscreen(bool will_cause_resize) {
|
||||||
|
shutdown_checker::AssertNotShutdown();
|
||||||
|
|
||||||
|
cef_browser_host_t* _struct = GetStruct();
|
||||||
|
if (CEF_MEMBER_MISSING(_struct, exit_fullscreen)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
_struct->exit_fullscreen(_struct, will_cause_resize);
|
||||||
|
}
|
||||||
|
|
||||||
// CONSTRUCTOR - Do not edit by hand.
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
CefBrowserHostCToCpp::CefBrowserHostCToCpp() {}
|
CefBrowserHostCToCpp::CefBrowserHostCToCpp() {}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=b4e11c91197cd5d6ccbe3a0d96aaae3792a6e05c$
|
// $hash=5c1df6572bffebd983970394be27397837db0b25$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_
|
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_
|
||||||
@ -134,6 +134,8 @@ class CefBrowserHostCToCpp : public CefCToCppRefCounted<CefBrowserHostCToCpp,
|
|||||||
bool IsBackgroundHost() override;
|
bool IsBackgroundHost() override;
|
||||||
void SetAudioMuted(bool mute) override;
|
void SetAudioMuted(bool mute) override;
|
||||||
bool IsAudioMuted() override;
|
bool IsAudioMuted() override;
|
||||||
|
bool IsFullscreen() override;
|
||||||
|
void ExitFullscreen(bool will_cause_resize) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_
|
#endif // CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_
|
||||||
|
@ -651,6 +651,18 @@ void ViewsWindow::OnWindowFullscreenTransition(CefRefPtr<CefWindow> window,
|
|||||||
if (should_change && with_controls_) {
|
if (should_change && with_controls_) {
|
||||||
ShowTopControls(!window->IsFullscreen());
|
ShowTopControls(!window->IsFullscreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// With Alloy runtime we need to explicitly exit browser fullscreen when
|
||||||
|
// exiting window fullscreen. Chrome runtime handles this internally.
|
||||||
|
if (!MainContext::Get()->UseChromeRuntime() && should_change &&
|
||||||
|
!window->IsFullscreen()) {
|
||||||
|
CefRefPtr<CefBrowser> browser = browser_view_->GetBrowser();
|
||||||
|
if (browser && browser->GetHost()->IsFullscreen()) {
|
||||||
|
// Will not cause a resize because the fullscreen transition has already
|
||||||
|
// begun.
|
||||||
|
browser->GetHost()->ExitFullscreen(/*will_cause_resize=*/false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewsWindow::OnWindowCreated(CefRefPtr<CefWindow> window) {
|
void ViewsWindow::OnWindowCreated(CefRefPtr<CefWindow> window) {
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
<html lang="en-US">
|
<html lang="en-US">
|
||||||
<head>
|
<head>
|
||||||
<title>Window Test</title>
|
<title>Window Test</title>
|
||||||
|
<style>
|
||||||
|
/* Background becomes pink in fullscreen mode. */
|
||||||
|
:fullscreen {
|
||||||
|
background: pink;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<script>
|
<script>
|
||||||
function setup() {
|
function setup() {
|
||||||
if (location.hostname == 'tests' || location.hostname == 'localhost')
|
if (location.hostname == 'tests' || location.hostname == 'localhost')
|
||||||
@ -38,10 +44,18 @@ function restore() {
|
|||||||
setTimeout(function() { send_message('Restore'); }, 1000);
|
setTimeout(function() { send_message('Restore'); }, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fullscreen() {
|
function fullscreenWindow() {
|
||||||
send_message('Fullscreen');
|
send_message('Fullscreen');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fullscreenBrowser() {
|
||||||
|
if (document.fullscreenElement) {
|
||||||
|
document.exitFullscreen();
|
||||||
|
} else {
|
||||||
|
document.getElementById('form').requestFullscreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function position() {
|
function position() {
|
||||||
var x = parseInt(document.getElementById('x').value);
|
var x = parseInt(document.getElementById('x').value);
|
||||||
var y = parseInt(document.getElementById('y').value);
|
var y = parseInt(document.getElementById('y').value);
|
||||||
@ -68,7 +82,8 @@ Click a button to perform the associated window action.
|
|||||||
<br/><input type="button" onclick="minimize();" value="Minimize">
|
<br/><input type="button" onclick="minimize();" value="Minimize">
|
||||||
<br/><input type="button" onclick="maximize();" value="Maximize">
|
<br/><input type="button" onclick="maximize();" value="Maximize">
|
||||||
<br/><input type="button" onclick="restore();" value="Restore"> (minimizes and then restores the window as topmost)
|
<br/><input type="button" onclick="restore();" value="Restore"> (minimizes and then restores the window as topmost)
|
||||||
<br/><input type="button" onclick="fullscreen();" value="Toggle Fullscreen"> (works with Views)
|
<br/><input type="button" onclick="fullscreenWindow();" value="Toggle Window Fullscreen"> (works with Views)
|
||||||
|
<br/><input type="button" onclick="fullscreenBrowser();" value="Toggle Browser Fullscreen"> (uses <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API" target="_new">Fullscreen API</a>; background turns pink)
|
||||||
<br/><input type="button" onclick="position();" value="Set Position">
|
<br/><input type="button" onclick="position();" value="Set Position">
|
||||||
X: <input type="text" size="4" id="x" value="200">
|
X: <input type="text" size="4" id="x" value="200">
|
||||||
Y: <input type="text" size="4" id="y" value="100">
|
Y: <input type="text" size="4" id="y" value="100">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user