mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	chrome: Standardize fullscreen transition behavor/callbacks (fixes #3571)
Use the same code path for all fullscreen transitions so that Chrome UI updates correctly. All user-initiated fullscreen transitions now result in CefWindowDelegate::OnWindowFullscreenTransition callbacks.
This commit is contained in:
		| @@ -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=1de3354bd0a042cc28199f1f56753b1df9e279a2$ | // $hash=5374127458a7cac3ee9b4d2b4ad8a6f5ca81ec52$ | ||||||
| // | // | ||||||
|  |  | ||||||
| #ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_ | #ifndef CEF_INCLUDE_CAPI_CEF_DISPLAY_HANDLER_CAPI_H_ | ||||||
| @@ -84,8 +84,13 @@ typedef struct _cef_display_handler_t { | |||||||
|   /// Called when web content in the page has toggled fullscreen mode. If |   /// Called when web content in the page has toggled fullscreen mode. If | ||||||
|   /// |fullscreen| is true (1) the content will automatically be sized to fill |   /// |fullscreen| is true (1) the content will automatically be sized to fill | ||||||
|   /// the browser content area. If |fullscreen| is false (0) the content will |   /// the browser content area. If |fullscreen| is false (0) the content will | ||||||
|   /// automatically return to its original size and position. The client is |   /// automatically return to its original size and position. With the Alloy | ||||||
|   /// responsible for resizing the browser if desired. |   /// runtime the client is responsible for triggering the fullscreen transition | ||||||
|  |   /// (for example, by calling cef_window_t::SetFullscreen when using Views). | ||||||
|  |   /// With the Chrome runtime the fullscreen transition will be triggered | ||||||
|  |   /// automatically. The cef_window_delegate_t::OnWindowFullscreenTransition | ||||||
|  |   /// function will be called during the fullscreen transition for notification | ||||||
|  |   /// purposes. | ||||||
|   /// |   /// | ||||||
|   void(CEF_CALLBACK* on_fullscreen_mode_change)( |   void(CEF_CALLBACK* on_fullscreen_mode_change)( | ||||||
|       struct _cef_display_handler_t* self, |       struct _cef_display_handler_t* self, | ||||||
|   | |||||||
| @@ -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=d53c4a0a7e731a56a0edcb9d705c76b0a2770155$ | // $hash=4b43fe0b493d860e8b28d7a6d892db49d1135b34$ | ||||||
| // | // | ||||||
|  |  | ||||||
| #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_ | #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_CAPI_H_ | ||||||
| @@ -155,7 +155,9 @@ typedef struct _cef_window_t { | |||||||
|   void(CEF_CALLBACK* restore)(struct _cef_window_t* self); |   void(CEF_CALLBACK* restore)(struct _cef_window_t* self); | ||||||
|  |  | ||||||
|   /// |   /// | ||||||
|   /// Set fullscreen Window state. |   /// Set fullscreen Window state. The | ||||||
|  |   /// cef_window_delegate_t::OnWindowFullscreenTransition function will be | ||||||
|  |   /// called during the fullscreen transition for notification purposes. | ||||||
|   /// |   /// | ||||||
|   void(CEF_CALLBACK* set_fullscreen)(struct _cef_window_t* self, |   void(CEF_CALLBACK* set_fullscreen)(struct _cef_window_t* self, | ||||||
|                                      int fullscreen); |                                      int fullscreen); | ||||||
|   | |||||||
| @@ -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=61099a1ba8b16a5e46f5a80d326d1f9bfc99317d$ | // $hash=456f00f7afbac910cf36feecd38399a2fb16960d$ | ||||||
| // | // | ||||||
|  |  | ||||||
| #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_ | #ifndef CEF_INCLUDE_CAPI_VIEWS_CEF_WINDOW_DELEGATE_CAPI_H_ | ||||||
| @@ -96,6 +96,20 @@ typedef struct _cef_window_delegate_t { | |||||||
|       struct _cef_window_t* window, |       struct _cef_window_t* window, | ||||||
|       const cef_rect_t* new_bounds); |       const cef_rect_t* new_bounds); | ||||||
|  |  | ||||||
|  |   /// | ||||||
|  |   /// Called when |window| is transitioning to or from fullscreen mode. On MacOS | ||||||
|  |   /// the transition occurs asynchronously with |is_competed| set to false (0) | ||||||
|  |   /// when the transition starts and true (1) after the transition completes. On | ||||||
|  |   /// other platforms the transition occurs synchronously with |is_completed| | ||||||
|  |   /// set to true (1) after the transition completes. With the Alloy runtime you | ||||||
|  |   /// must also implement cef_display_handler_t::OnFullscreenModeChange to | ||||||
|  |   /// handle fullscreen transitions initiated by browser content. | ||||||
|  |   /// | ||||||
|  |   void(CEF_CALLBACK* on_window_fullscreen_transition)( | ||||||
|  |       struct _cef_window_delegate_t* self, | ||||||
|  |       struct _cef_window_t* window, | ||||||
|  |       int is_completed); | ||||||
|  |  | ||||||
|   /// |   /// | ||||||
|   /// Return the parent for |window| or NULL if the |window| does not have a |   /// Return the parent for |window| or NULL if the |window| does not have a | ||||||
|   /// parent. Windows with parents will not get a taskbar button. Set |is_menu| |   /// parent. Windows with parents will not get a taskbar button. Set |is_menu| | ||||||
| @@ -210,17 +224,6 @@ typedef struct _cef_window_delegate_t { | |||||||
|   int(CEF_CALLBACK* on_key_event)(struct _cef_window_delegate_t* self, |   int(CEF_CALLBACK* on_key_event)(struct _cef_window_delegate_t* self, | ||||||
|                                   struct _cef_window_t* window, |                                   struct _cef_window_t* window, | ||||||
|                                   const cef_key_event_t* event); |                                   const cef_key_event_t* event); | ||||||
|  |  | ||||||
|   /// |  | ||||||
|   /// Called when the |window| is transitioning to or from fullscreen mode. The |  | ||||||
|   /// transition occurs in two stages, with |is_competed| set to false (0) when |  | ||||||
|   /// the transition starts and true (1) when the transition completes. This |  | ||||||
|   /// function is only supported on macOS. |  | ||||||
|   /// |  | ||||||
|   void(CEF_CALLBACK* on_window_fullscreen_transition)( |  | ||||||
|       struct _cef_window_delegate_t* self, |  | ||||||
|       struct _cef_window_t* window, |  | ||||||
|       int is_completed); |  | ||||||
| } cef_window_delegate_t; | } cef_window_delegate_t; | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|   | |||||||
| @@ -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 "8aa786740cdcadf7b4f6dd3554343abae09ffdfd" | #define CEF_API_HASH_UNIVERSAL "c684c3da478cb88b042bf13c88ab7797e33c29bc" | ||||||
| #if defined(OS_WIN) | #if defined(OS_WIN) | ||||||
| #define CEF_API_HASH_PLATFORM "f241d73d66f3b7f99aae58a0cc99be36beda4f4f" | #define CEF_API_HASH_PLATFORM "bcc26a8181330fd0dc07e9d2475c048919d4f55f" | ||||||
| #elif defined(OS_MAC) | #elif defined(OS_MAC) | ||||||
| #define CEF_API_HASH_PLATFORM "3708f34f956e6306d09989a88ff1dee9c8f7a2b5" | #define CEF_API_HASH_PLATFORM "2abec7e306f2c474c8a66b585b9c6a0bdcd45276" | ||||||
| #elif defined(OS_LINUX) | #elif defined(OS_LINUX) | ||||||
| #define CEF_API_HASH_PLATFORM "cf413edb4edeb80d7d5c1173e342231b26808fce" | #define CEF_API_HASH_PLATFORM "b93f84208be4af554a5b60315a63251263a71e57" | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
|   | |||||||
| @@ -75,8 +75,12 @@ class CefDisplayHandler : public virtual CefBaseRefCounted { | |||||||
|   /// Called when web content in the page has toggled fullscreen mode. If |   /// Called when web content in the page has toggled fullscreen mode. If | ||||||
|   /// |fullscreen| is true the content will automatically be sized to fill the |   /// |fullscreen| is true the content will automatically be sized to fill the | ||||||
|   /// browser content area. If |fullscreen| is false the content will |   /// browser content area. If |fullscreen| is false the content will | ||||||
|   /// automatically return to its original size and position. The client is |   /// automatically return to its original size and position. With the Alloy | ||||||
|   /// responsible for resizing the browser if desired. |   /// runtime the client is responsible for triggering the fullscreen transition | ||||||
|  |   /// (for example, by calling CefWindow::SetFullscreen when using Views). With | ||||||
|  |   /// the Chrome runtime the fullscreen transition will be triggered | ||||||
|  |   /// automatically. The CefWindowDelegate::OnWindowFullscreenTransition method | ||||||
|  |   /// will be called during the fullscreen transition for notification purposes. | ||||||
|   /// |   /// | ||||||
|   /*--cef()--*/ |   /*--cef()--*/ | ||||||
|   virtual void OnFullscreenModeChange(CefRefPtr<CefBrowser> browser, |   virtual void OnFullscreenModeChange(CefRefPtr<CefBrowser> browser, | ||||||
|   | |||||||
| @@ -165,7 +165,9 @@ class CefWindow : public CefPanel { | |||||||
|   virtual void Restore() = 0; |   virtual void Restore() = 0; | ||||||
|  |  | ||||||
|   /// |   /// | ||||||
|   /// Set fullscreen Window state. |   /// Set fullscreen Window state. The | ||||||
|  |   /// CefWindowDelegate::OnWindowFullscreenTransition method will be called | ||||||
|  |   /// during the fullscreen transition for notification purposes. | ||||||
|   /// |   /// | ||||||
|   /*--cef()--*/ |   /*--cef()--*/ | ||||||
|   virtual void SetFullscreen(bool fullscreen) = 0; |   virtual void SetFullscreen(bool fullscreen) = 0; | ||||||
|   | |||||||
| @@ -84,6 +84,19 @@ class CefWindowDelegate : public CefPanelDelegate { | |||||||
|   virtual void OnWindowBoundsChanged(CefRefPtr<CefWindow> window, |   virtual void OnWindowBoundsChanged(CefRefPtr<CefWindow> window, | ||||||
|                                      const CefRect& new_bounds) {} |                                      const CefRect& new_bounds) {} | ||||||
|  |  | ||||||
|  |   /// | ||||||
|  |   /// Called when |window| is transitioning to or from fullscreen mode. On MacOS | ||||||
|  |   /// the transition occurs asynchronously with |is_competed| set to false when | ||||||
|  |   /// the transition starts and true after the transition completes. On other | ||||||
|  |   /// platforms the transition occurs synchronously with |is_completed| set to | ||||||
|  |   /// true after the transition completes. With the Alloy runtime you must also | ||||||
|  |   /// implement CefDisplayHandler::OnFullscreenModeChange to handle fullscreen | ||||||
|  |   /// transitions initiated by browser content. | ||||||
|  |   /// | ||||||
|  |   /*--cef()--*/ | ||||||
|  |   virtual void OnWindowFullscreenTransition(CefRefPtr<CefWindow> window, | ||||||
|  |                                             bool is_completed) {} | ||||||
|  |  | ||||||
|   /// |   /// | ||||||
|   /// Return the parent for |window| or NULL if the |window| does not have a |   /// Return the parent for |window| or NULL if the |window| does not have a | ||||||
|   /// parent. Windows with parents will not get a taskbar button. Set |is_menu| |   /// parent. Windows with parents will not get a taskbar button. Set |is_menu| | ||||||
| @@ -209,16 +222,6 @@ class CefWindowDelegate : public CefPanelDelegate { | |||||||
|                           const CefKeyEvent& event) { |                           const CefKeyEvent& event) { | ||||||
|     return false; |     return false; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   /// |  | ||||||
|   /// Called when the |window| is transitioning to or from fullscreen mode. The |  | ||||||
|   /// transition occurs in two stages, with |is_competed| set to false when the |  | ||||||
|   /// transition starts and true when the transition completes. |  | ||||||
|   /// This method is only supported on macOS. |  | ||||||
|   /// |  | ||||||
|   /*--cef()--*/ |  | ||||||
|   virtual void OnWindowFullscreenTransition(CefRefPtr<CefWindow> window, |  | ||||||
|                                             bool is_completed) {} |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #endif  // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_ | #endif  // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_ | ||||||
|   | |||||||
| @@ -126,6 +126,9 @@ class BrowserDelegate : public content::WebContentsDelegate { | |||||||
|   // Set the draggable region relative to web contents. |   // Set the draggable region relative to web contents. | ||||||
|   // Called from DraggableRegionsHostImpl::UpdateDraggableRegions. |   // Called from DraggableRegionsHostImpl::UpdateDraggableRegions. | ||||||
|   virtual void UpdateDraggableRegion(const SkRegion& region) {} |   virtual void UpdateDraggableRegion(const SkRegion& region) {} | ||||||
|  |  | ||||||
|  |   // Called at the end of a fullscreen transition. | ||||||
|  |   virtual void WindowFullscreenStateChanged() {} | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }  // namespace cef | }  // namespace cef | ||||||
|   | |||||||
| @@ -15,6 +15,7 @@ | |||||||
| #include "libcef/browser/media_access_query.h" | #include "libcef/browser/media_access_query.h" | ||||||
| #include "libcef/browser/request_context_impl.h" | #include "libcef/browser/request_context_impl.h" | ||||||
| #include "libcef/browser/views/browser_view_impl.h" | #include "libcef/browser/views/browser_view_impl.h" | ||||||
|  | #include "libcef/browser/views/window_impl.h" | ||||||
| #include "libcef/common/app_manager.h" | #include "libcef/common/app_manager.h" | ||||||
| #include "libcef/common/frame_util.h" | #include "libcef/common/frame_util.h" | ||||||
|  |  | ||||||
| @@ -257,6 +258,23 @@ void ChromeBrowserDelegate::UpdateDraggableRegion(const SkRegion& region) { | |||||||
|   draggable_region_ = region; |   draggable_region_ = region; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void ChromeBrowserDelegate::WindowFullscreenStateChanged() { | ||||||
|  |   // Use a synchronous callback for notification on Windows/Linux. MacOS gets | ||||||
|  |   // notified asynchronously via CefNativeWidgetMac callbacks. | ||||||
|  | #if !BUILDFLAG(IS_MAC) | ||||||
|  |   if (auto browser = ChromeBrowserHostImpl::GetBrowserForBrowser(browser_)) { | ||||||
|  |     if (auto chrome_browser_view = browser->chrome_browser_view()) { | ||||||
|  |       auto* cef_window = chrome_browser_view->cef_browser_view()->cef_window(); | ||||||
|  |       if (auto* delegate = cef_window->delegate()) { | ||||||
|  |         // Give the CefWindowDelegate a chance to handle the event. | ||||||
|  |         delegate->OnWindowFullscreenTransition(cef_window, | ||||||
|  |                                                /*is_completed=*/true); | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  |  | ||||||
| void ChromeBrowserDelegate::WebContentsCreated( | void ChromeBrowserDelegate::WebContentsCreated( | ||||||
|     content::WebContents* source_contents, |     content::WebContents* source_contents, | ||||||
|     int opener_render_process_id, |     int opener_render_process_id, | ||||||
|   | |||||||
| @@ -70,6 +70,7 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate { | |||||||
|   bool SupportsDraggableRegion() const override; |   bool SupportsDraggableRegion() const override; | ||||||
|   const absl::optional<SkRegion> GetDraggableRegion() const override; |   const absl::optional<SkRegion> GetDraggableRegion() const override; | ||||||
|   void UpdateDraggableRegion(const SkRegion& region) override; |   void UpdateDraggableRegion(const SkRegion& region) override; | ||||||
|  |   void WindowFullscreenStateChanged() override; | ||||||
|  |  | ||||||
|   // WebContentsDelegate methods: |   // WebContentsDelegate methods: | ||||||
|   void WebContentsCreated(content::WebContents* source_contents, |   void WebContentsCreated(content::WebContents* source_contents, | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ | |||||||
|  |  | ||||||
| #include "chrome/browser/themes/theme_service.h" | #include "chrome/browser/themes/theme_service.h" | ||||||
| #include "chrome/browser/ui/browser.h" | #include "chrome/browser/ui/browser.h" | ||||||
|  | #include "chrome/browser/ui/browser_commands.h" | ||||||
| #include "chrome/browser/ui/views/frame/browser_view.h" | #include "chrome/browser/ui/views/frame/browser_view.h" | ||||||
|  |  | ||||||
| #if BUILDFLAG(IS_MAC) | #if BUILDFLAG(IS_MAC) | ||||||
| @@ -17,10 +18,10 @@ | |||||||
| void ChromeBrowserFrame::Init(BrowserView* browser_view, | void ChromeBrowserFrame::Init(BrowserView* browser_view, | ||||||
|                               std::unique_ptr<Browser> browser) { |                               std::unique_ptr<Browser> browser) { | ||||||
|   DCHECK(browser_view); |   DCHECK(browser_view); | ||||||
|  |   DCHECK(browser); | ||||||
|  |  | ||||||
|   DCHECK(!browser_); |   DCHECK(!browser_view_); | ||||||
|   browser_ = browser.get(); |   browser_view_ = browser_view; | ||||||
|   DCHECK(browser_); |  | ||||||
|  |  | ||||||
|   // Initialize BrowserFrame state. |   // Initialize BrowserFrame state. | ||||||
|   InitBrowserView(browser_view); |   InitBrowserView(browser_view); | ||||||
| @@ -42,6 +43,10 @@ void ChromeBrowserFrame::Init(BrowserView* browser_view, | |||||||
| #endif  // BUILDFLAG(IS_MAC) | #endif  // BUILDFLAG(IS_MAC) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void ChromeBrowserFrame::ToggleFullscreenMode() { | ||||||
|  |   chrome::ToggleFullscreenMode(browser_view_->browser()); | ||||||
|  | } | ||||||
|  |  | ||||||
| views::internal::RootView* ChromeBrowserFrame::CreateRootView() { | views::internal::RootView* ChromeBrowserFrame::CreateRootView() { | ||||||
|   // Bypass the BrowserFrame implementation. |   // Bypass the BrowserFrame implementation. | ||||||
|   return views::Widget::CreateRootView(); |   return views::Widget::CreateRootView(); | ||||||
|   | |||||||
| @@ -97,13 +97,17 @@ class ChromeBrowserFrame : public BrowserFrame { | |||||||
|  |  | ||||||
|   void Init(BrowserView* browser_view, std::unique_ptr<Browser> browser); |   void Init(BrowserView* browser_view, std::unique_ptr<Browser> browser); | ||||||
|  |  | ||||||
|  |   void ToggleFullscreenMode(); | ||||||
|  |  | ||||||
|   // views::Widget methods: |   // views::Widget methods: | ||||||
|   views::internal::RootView* CreateRootView() override; |   views::internal::RootView* CreateRootView() override; | ||||||
|   std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView() |   std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView() | ||||||
|       override; |       override; | ||||||
|  |  | ||||||
|  |   BrowserView* browser_view() const { return browser_view_; } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   Browser* browser_ = nullptr; |   BrowserView* browser_view_ = nullptr; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #endif  // CEF_LIBCEF_BROWSER_CHROME_VIEWS_CHROME_BROWSER_FRAME_H_ | #endif  // CEF_LIBCEF_BROWSER_CHROME_VIEWS_CHROME_BROWSER_FRAME_H_ | ||||||
|   | |||||||
| @@ -141,10 +141,7 @@ bool CefBrowserViewImpl::HandleKeyboardEvent( | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Give the CefWindowDelegate a chance to handle the event. |   // Give the CefWindowDelegate a chance to handle the event. | ||||||
|   CefRefPtr<CefWindow> window = |   if (auto* window_impl = cef_window()) { | ||||||
|       view_util::GetWindowFor(root_view()->GetWidget()); |  | ||||||
|   CefWindowImpl* window_impl = static_cast<CefWindowImpl*>(window.get()); |  | ||||||
|   if (window_impl) { |  | ||||||
|     CefKeyEvent cef_event; |     CefKeyEvent cef_event; | ||||||
|     if (browser_util::GetCefKeyEvent(event, cef_event) && |     if (browser_util::GetCefKeyEvent(event, cef_event) && | ||||||
|         window_impl->OnKeyEvent(cef_event)) { |         window_impl->OnKeyEvent(cef_event)) { | ||||||
| @@ -319,6 +316,12 @@ ChromeBrowserView* CefBrowserViewImpl::chrome_browser_view() const { | |||||||
|   return static_cast<ChromeBrowserView*>(root_view()); |   return static_cast<ChromeBrowserView*>(root_view()); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | CefWindowImpl* CefBrowserViewImpl::cef_window() const { | ||||||
|  |   CefRefPtr<CefWindow> window = | ||||||
|  |       view_util::GetWindowFor(root_view()->GetWidget()); | ||||||
|  |   return static_cast<CefWindowImpl*>(window.get()); | ||||||
|  | } | ||||||
|  |  | ||||||
| bool CefBrowserViewImpl::HandleAccelerator( | bool CefBrowserViewImpl::HandleAccelerator( | ||||||
|     const content::NativeWebKeyboardEvent& event, |     const content::NativeWebKeyboardEvent& event, | ||||||
|     views::FocusManager* focus_manager) { |     views::FocusManager* focus_manager) { | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
| #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" | #include "ui/views/controls/webview/unhandled_keyboard_event_handler.h" | ||||||
|  |  | ||||||
| class CefBrowserHostBase; | class CefBrowserHostBase; | ||||||
|  | class CefWindowImpl; | ||||||
| class ChromeBrowserView; | class ChromeBrowserView; | ||||||
|  |  | ||||||
| class CefBrowserViewImpl | class CefBrowserViewImpl | ||||||
| @@ -83,6 +84,9 @@ class CefBrowserViewImpl | |||||||
|   // Return the CEF specialization of BrowserView. |   // Return the CEF specialization of BrowserView. | ||||||
|   ChromeBrowserView* chrome_browser_view() const; |   ChromeBrowserView* chrome_browser_view() const; | ||||||
|  |  | ||||||
|  |   // Return the CefWindowImpl hosting this object. | ||||||
|  |   CefWindowImpl* cef_window() const; | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   // Create a new implementation object. |   // Create a new implementation object. | ||||||
|   // Always call Initialize() after creation. |   // Always call Initialize() after creation. | ||||||
|   | |||||||
| @@ -48,6 +48,9 @@ class CefNativeWidgetMac : public views::NativeWidgetMac { | |||||||
|   const CefRefPtr<CefWindow> window_; |   const CefRefPtr<CefWindow> window_; | ||||||
|   CefWindowDelegate* const window_delegate_; |   CefWindowDelegate* const window_delegate_; | ||||||
|  |  | ||||||
|  |   // Returns true if the CefWindow is fully initialized. | ||||||
|  |   bool IsCefWindowInitialized() const; | ||||||
|  |  | ||||||
|   BrowserView* browser_view_ = nullptr; |   BrowserView* browser_view_ = nullptr; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ | |||||||
| #include "include/views/cef_window.h" | #include "include/views/cef_window.h" | ||||||
| #include "include/views/cef_window_delegate.h" | #include "include/views/cef_window_delegate.h" | ||||||
| #include "libcef/browser/views/ns_window.h" | #include "libcef/browser/views/ns_window.h" | ||||||
|  | #include "libcef/browser/views/window_impl.h" | ||||||
|  |  | ||||||
| #include "chrome/browser/apps/app_shim/app_shim_host_mac.h" | #include "chrome/browser/apps/app_shim/app_shim_host_mac.h" | ||||||
| #include "chrome/browser/apps/app_shim/app_shim_manager_mac.h" | #include "chrome/browser/apps/app_shim/app_shim_manager_mac.h" | ||||||
| @@ -118,12 +119,16 @@ void CefNativeWidgetMac::GetWindowFrameTitlebarHeight( | |||||||
|  |  | ||||||
| void CefNativeWidgetMac::OnWindowFullscreenTransitionStart() { | void CefNativeWidgetMac::OnWindowFullscreenTransitionStart() { | ||||||
|   views::NativeWidgetMac::OnWindowFullscreenTransitionStart(); |   views::NativeWidgetMac::OnWindowFullscreenTransitionStart(); | ||||||
|   window_delegate_->OnWindowFullscreenTransition(window_, false); |   if (IsCefWindowInitialized()) { | ||||||
|  |     window_delegate_->OnWindowFullscreenTransition(window_, false); | ||||||
|  |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| void CefNativeWidgetMac::OnWindowFullscreenTransitionComplete() { | void CefNativeWidgetMac::OnWindowFullscreenTransitionComplete() { | ||||||
|   views::NativeWidgetMac::OnWindowFullscreenTransitionComplete(); |   views::NativeWidgetMac::OnWindowFullscreenTransitionComplete(); | ||||||
|   window_delegate_->OnWindowFullscreenTransition(window_, true); |   if (IsCefWindowInitialized()) { | ||||||
|  |     window_delegate_->OnWindowFullscreenTransition(window_, true); | ||||||
|  |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| void CefNativeWidgetMac::OnWindowInitialized() { | void CefNativeWidgetMac::OnWindowInitialized() { | ||||||
| @@ -142,3 +147,7 @@ void CefNativeWidgetMac::OnWindowInitialized() { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | bool CefNativeWidgetMac::IsCefWindowInitialized() const { | ||||||
|  |   return static_cast<CefWindowImpl*>(window_.get())->initialized(); | ||||||
|  | } | ||||||
|   | |||||||
| @@ -5,6 +5,7 @@ | |||||||
| #include "libcef/browser/views/window_impl.h" | #include "libcef/browser/views/window_impl.h" | ||||||
|  |  | ||||||
| #include "libcef/browser/browser_util.h" | #include "libcef/browser/browser_util.h" | ||||||
|  | #include "libcef/browser/chrome/views/chrome_browser_frame.h" | ||||||
| #include "libcef/browser/thread_util.h" | #include "libcef/browser/thread_util.h" | ||||||
| #include "libcef/browser/views/browser_view_impl.h" | #include "libcef/browser/views/browser_view_impl.h" | ||||||
| #include "libcef/browser/views/display_impl.h" | #include "libcef/browser/views/display_impl.h" | ||||||
| @@ -12,6 +13,7 @@ | |||||||
| #include "libcef/browser/views/layout_util.h" | #include "libcef/browser/views/layout_util.h" | ||||||
| #include "libcef/browser/views/view_util.h" | #include "libcef/browser/views/view_util.h" | ||||||
| #include "libcef/browser/views/window_view.h" | #include "libcef/browser/views/window_view.h" | ||||||
|  | #include "libcef/features/runtime.h" | ||||||
|  |  | ||||||
| #include "base/i18n/rtl.h" | #include "base/i18n/rtl.h" | ||||||
| #include "components/constrained_window/constrained_window_views.h" | #include "components/constrained_window/constrained_window_views.h" | ||||||
| @@ -116,9 +118,6 @@ CefRefPtr<CefWindowImpl> CefWindowImpl::Create( | |||||||
|   CefRefPtr<CefWindowImpl> window = new CefWindowImpl(delegate); |   CefRefPtr<CefWindowImpl> window = new CefWindowImpl(delegate); | ||||||
|   window->Initialize(); |   window->Initialize(); | ||||||
|   window->CreateWidget(parent_widget); |   window->CreateWidget(parent_widget); | ||||||
|   if (delegate) { |  | ||||||
|     delegate->OnWindowCreated(window.get()); |  | ||||||
|   } |  | ||||||
|   return window; |   return window; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -253,7 +252,29 @@ void CefWindowImpl::Restore() { | |||||||
| void CefWindowImpl::SetFullscreen(bool fullscreen) { | void CefWindowImpl::SetFullscreen(bool fullscreen) { | ||||||
|   CEF_REQUIRE_VALID_RETURN_VOID(); |   CEF_REQUIRE_VALID_RETURN_VOID(); | ||||||
|   if (widget_ && fullscreen != widget_->IsFullscreen()) { |   if (widget_ && fullscreen != widget_->IsFullscreen()) { | ||||||
|  |     if (cef::IsChromeRuntimeEnabled()) { | ||||||
|  |       // If a BrowserView exists, toggle fullscreen mode via the Chrome command | ||||||
|  |       // for consistent behavior. | ||||||
|  |       auto* browser_frame = static_cast<ChromeBrowserFrame*>(widget_); | ||||||
|  |       if (browser_frame->browser_view()) { | ||||||
|  |         browser_frame->ToggleFullscreenMode(); | ||||||
|  |         return; | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // Call the Widget method directly with Alloy runtime, or Chrome runtime | ||||||
|  |     // when no BrowserView exists. | ||||||
|     widget_->SetFullscreen(fullscreen); |     widget_->SetFullscreen(fullscreen); | ||||||
|  |  | ||||||
|  |     // Use a synchronous callback notification on Windows/Linux. Chrome runtime | ||||||
|  |     // on Windows/Linux gets notified synchronously via ChromeBrowserDelegate | ||||||
|  |     // callbacks when a BrowserView exists. MacOS (both runtimes) gets notified | ||||||
|  |     // asynchronously via CefNativeWidgetMac callbacks. | ||||||
|  | #if !BUILDFLAG(IS_MAC) | ||||||
|  |     if (delegate()) { | ||||||
|  |       delegate()->OnWindowFullscreenTransition(this, /*is_completed=*/true); | ||||||
|  |     } | ||||||
|  | #endif | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -714,7 +735,7 @@ void CefWindowImpl::RemoveAllAccelerators() { | |||||||
| } | } | ||||||
|  |  | ||||||
| CefWindowImpl::CefWindowImpl(CefRefPtr<CefWindowDelegate> delegate) | CefWindowImpl::CefWindowImpl(CefRefPtr<CefWindowDelegate> delegate) | ||||||
|     : ParentClass(delegate), widget_(nullptr), destroyed_(false) {} |     : ParentClass(delegate) {} | ||||||
|  |  | ||||||
| CefWindowView* CefWindowImpl::CreateRootView() { | CefWindowView* CefWindowImpl::CreateRootView() { | ||||||
|   return new CefWindowView(delegate(), this); |   return new CefWindowView(delegate(), this); | ||||||
| @@ -740,4 +761,10 @@ void CefWindowImpl::CreateWidget(gfx::AcceleratedWidget parent_widget) { | |||||||
|   // keep an owned reference. |   // keep an owned reference. | ||||||
|   std::unique_ptr<views::View> view_ptr = view_util::PassOwnership(this); |   std::unique_ptr<views::View> view_ptr = view_util::PassOwnership(this); | ||||||
|   [[maybe_unused]] views::View* view = view_ptr.release(); |   [[maybe_unused]] views::View* view = view_ptr.release(); | ||||||
|  |  | ||||||
|  |   initialized_ = true; | ||||||
|  |  | ||||||
|  |   if (delegate()) { | ||||||
|  |     delegate()->OnWindowCreated(this); | ||||||
|  |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -132,6 +132,7 @@ class CefWindowImpl | |||||||
|   void MenuClosed(); |   void MenuClosed(); | ||||||
|  |  | ||||||
|   views::Widget* widget() const { return widget_; } |   views::Widget* widget() const { return widget_; } | ||||||
|  |   bool initialized() const { return initialized_; } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   // Create a new implementation object. |   // Create a new implementation object. | ||||||
| @@ -146,10 +147,13 @@ class CefWindowImpl | |||||||
|   // Initialize the Widget. |   // Initialize the Widget. | ||||||
|   void CreateWidget(gfx::AcceleratedWidget parent_widget); |   void CreateWidget(gfx::AcceleratedWidget parent_widget); | ||||||
|  |  | ||||||
|   views::Widget* widget_; |   views::Widget* widget_ = nullptr; | ||||||
|  |  | ||||||
|  |   // True if the window has been initialized. | ||||||
|  |   bool initialized_ = false; | ||||||
|  |  | ||||||
|   // True if the window has been destroyed. |   // True if the window has been destroyed. | ||||||
|   bool destroyed_; |   bool destroyed_ = false; | ||||||
|  |  | ||||||
|   // The currently active menu model and runner. |   // The currently active menu model and runner. | ||||||
|   CefRefPtr<CefMenuModelImpl> menu_model_; |   CefRefPtr<CefMenuModelImpl> menu_model_; | ||||||
|   | |||||||
| @@ -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=10ec416d3aeba7215b08604b1a329adc1c9aaf6f$ | // $hash=61afa22f2b3401bab08c3faeb872e3de7a99ca5b$ | ||||||
| // | // | ||||||
|  |  | ||||||
| #include "libcef_dll/cpptoc/views/window_delegate_cpptoc.h" | #include "libcef_dll/cpptoc/views/window_delegate_cpptoc.h" | ||||||
| @@ -141,6 +141,29 @@ window_delegate_on_window_bounds_changed(struct _cef_window_delegate_t* self, | |||||||
|       CefWindowCToCpp::Wrap(window), new_boundsVal); |       CefWindowCToCpp::Wrap(window), new_boundsVal); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void CEF_CALLBACK window_delegate_on_window_fullscreen_transition( | ||||||
|  |     struct _cef_window_delegate_t* self, | ||||||
|  |     cef_window_t* window, | ||||||
|  |     int is_completed) { | ||||||
|  |   shutdown_checker::AssertNotShutdown(); | ||||||
|  |  | ||||||
|  |   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||||
|  |  | ||||||
|  |   DCHECK(self); | ||||||
|  |   if (!self) { | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  |   // Verify param: window; type: refptr_diff | ||||||
|  |   DCHECK(window); | ||||||
|  |   if (!window) { | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   // Execute | ||||||
|  |   CefWindowDelegateCppToC::Get(self)->OnWindowFullscreenTransition( | ||||||
|  |       CefWindowCToCpp::Wrap(window), is_completed ? true : false); | ||||||
|  | } | ||||||
|  |  | ||||||
| cef_window_t* CEF_CALLBACK | cef_window_t* CEF_CALLBACK | ||||||
| window_delegate_get_parent_window(struct _cef_window_delegate_t* self, | window_delegate_get_parent_window(struct _cef_window_delegate_t* self, | ||||||
|                                   cef_window_t* window, |                                   cef_window_t* window, | ||||||
| @@ -509,29 +532,6 @@ window_delegate_on_key_event(struct _cef_window_delegate_t* self, | |||||||
|   return _retval; |   return _retval; | ||||||
| } | } | ||||||
|  |  | ||||||
| void CEF_CALLBACK window_delegate_on_window_fullscreen_transition( |  | ||||||
|     struct _cef_window_delegate_t* self, |  | ||||||
|     cef_window_t* window, |  | ||||||
|     int is_completed) { |  | ||||||
|   shutdown_checker::AssertNotShutdown(); |  | ||||||
|  |  | ||||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING |  | ||||||
|  |  | ||||||
|   DCHECK(self); |  | ||||||
|   if (!self) { |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
|   // Verify param: window; type: refptr_diff |  | ||||||
|   DCHECK(window); |  | ||||||
|   if (!window) { |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // Execute |  | ||||||
|   CefWindowDelegateCppToC::Get(self)->OnWindowFullscreenTransition( |  | ||||||
|       CefWindowCToCpp::Wrap(window), is_completed ? true : false); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| cef_size_t CEF_CALLBACK | cef_size_t CEF_CALLBACK | ||||||
| window_delegate_get_preferred_size(struct _cef_view_delegate_t* self, | window_delegate_get_preferred_size(struct _cef_view_delegate_t* self, | ||||||
|                                    cef_view_t* view) { |                                    cef_view_t* view) { | ||||||
| @@ -805,6 +805,8 @@ CefWindowDelegateCppToC::CefWindowDelegateCppToC() { | |||||||
|       window_delegate_on_window_activation_changed; |       window_delegate_on_window_activation_changed; | ||||||
|   GetStruct()->on_window_bounds_changed = |   GetStruct()->on_window_bounds_changed = | ||||||
|       window_delegate_on_window_bounds_changed; |       window_delegate_on_window_bounds_changed; | ||||||
|  |   GetStruct()->on_window_fullscreen_transition = | ||||||
|  |       window_delegate_on_window_fullscreen_transition; | ||||||
|   GetStruct()->get_parent_window = window_delegate_get_parent_window; |   GetStruct()->get_parent_window = window_delegate_get_parent_window; | ||||||
|   GetStruct()->is_window_modal_dialog = window_delegate_is_window_modal_dialog; |   GetStruct()->is_window_modal_dialog = window_delegate_is_window_modal_dialog; | ||||||
|   GetStruct()->get_initial_bounds = window_delegate_get_initial_bounds; |   GetStruct()->get_initial_bounds = window_delegate_get_initial_bounds; | ||||||
| @@ -819,8 +821,6 @@ CefWindowDelegateCppToC::CefWindowDelegateCppToC() { | |||||||
|   GetStruct()->can_close = window_delegate_can_close; |   GetStruct()->can_close = window_delegate_can_close; | ||||||
|   GetStruct()->on_accelerator = window_delegate_on_accelerator; |   GetStruct()->on_accelerator = window_delegate_on_accelerator; | ||||||
|   GetStruct()->on_key_event = window_delegate_on_key_event; |   GetStruct()->on_key_event = window_delegate_on_key_event; | ||||||
|   GetStruct()->on_window_fullscreen_transition = |  | ||||||
|       window_delegate_on_window_fullscreen_transition; |  | ||||||
|   GetStruct()->base.base.get_preferred_size = |   GetStruct()->base.base.get_preferred_size = | ||||||
|       window_delegate_get_preferred_size; |       window_delegate_get_preferred_size; | ||||||
|   GetStruct()->base.base.get_minimum_size = window_delegate_get_minimum_size; |   GetStruct()->base.base.get_minimum_size = window_delegate_get_minimum_size; | ||||||
|   | |||||||
| @@ -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=12bd03a8fb7d680a4e2b1a6818313c29bf14f011$ | // $hash=bb69763a25cd013a50504d762a81c0a4454ce8eb$ | ||||||
| // | // | ||||||
|  |  | ||||||
| #include "libcef_dll/ctocpp/views/window_delegate_ctocpp.h" | #include "libcef_dll/ctocpp/views/window_delegate_ctocpp.h" | ||||||
| @@ -129,6 +129,30 @@ void CefWindowDelegateCToCpp::OnWindowBoundsChanged(CefRefPtr<CefWindow> window, | |||||||
|                                     &new_bounds); |                                     &new_bounds); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | NO_SANITIZE("cfi-icall") | ||||||
|  | void CefWindowDelegateCToCpp::OnWindowFullscreenTransition( | ||||||
|  |     CefRefPtr<CefWindow> window, | ||||||
|  |     bool is_completed) { | ||||||
|  |   shutdown_checker::AssertNotShutdown(); | ||||||
|  |  | ||||||
|  |   cef_window_delegate_t* _struct = GetStruct(); | ||||||
|  |   if (CEF_MEMBER_MISSING(_struct, on_window_fullscreen_transition)) { | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||||
|  |  | ||||||
|  |   // Verify param: window; type: refptr_diff | ||||||
|  |   DCHECK(window.get()); | ||||||
|  |   if (!window.get()) { | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   // Execute | ||||||
|  |   _struct->on_window_fullscreen_transition( | ||||||
|  |       _struct, CefWindowCppToC::Wrap(window), is_completed); | ||||||
|  | } | ||||||
|  |  | ||||||
| NO_SANITIZE("cfi-icall") | NO_SANITIZE("cfi-icall") | ||||||
| CefRefPtr<CefWindow> CefWindowDelegateCToCpp::GetParentWindow( | CefRefPtr<CefWindow> CefWindowDelegateCToCpp::GetParentWindow( | ||||||
|     CefRefPtr<CefWindow> window, |     CefRefPtr<CefWindow> window, | ||||||
| @@ -487,30 +511,6 @@ bool CefWindowDelegateCToCpp::OnKeyEvent(CefRefPtr<CefWindow> window, | |||||||
|   return _retval ? true : false; |   return _retval ? true : false; | ||||||
| } | } | ||||||
|  |  | ||||||
| NO_SANITIZE("cfi-icall") |  | ||||||
| void CefWindowDelegateCToCpp::OnWindowFullscreenTransition( |  | ||||||
|     CefRefPtr<CefWindow> window, |  | ||||||
|     bool is_completed) { |  | ||||||
|   shutdown_checker::AssertNotShutdown(); |  | ||||||
|  |  | ||||||
|   cef_window_delegate_t* _struct = GetStruct(); |  | ||||||
|   if (CEF_MEMBER_MISSING(_struct, on_window_fullscreen_transition)) { |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING |  | ||||||
|  |  | ||||||
|   // Verify param: window; type: refptr_diff |  | ||||||
|   DCHECK(window.get()); |  | ||||||
|   if (!window.get()) { |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // Execute |  | ||||||
|   _struct->on_window_fullscreen_transition( |  | ||||||
|       _struct, CefWindowCppToC::Wrap(window), is_completed); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| NO_SANITIZE("cfi-icall") | NO_SANITIZE("cfi-icall") | ||||||
| CefSize CefWindowDelegateCToCpp::GetPreferredSize(CefRefPtr<CefView> view) { | CefSize CefWindowDelegateCToCpp::GetPreferredSize(CefRefPtr<CefView> view) { | ||||||
|   shutdown_checker::AssertNotShutdown(); |   shutdown_checker::AssertNotShutdown(); | ||||||
|   | |||||||
| @@ -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=25487f4d82069d1e4c0c7b27c1c1fcbcebbbacea$ | // $hash=e1ed42bb378f9f140e006ec582c0e908f711e7fa$ | ||||||
| // | // | ||||||
|  |  | ||||||
| #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_DELEGATE_CTOCPP_H_ | #ifndef CEF_LIBCEF_DLL_CTOCPP_VIEWS_WINDOW_DELEGATE_CTOCPP_H_ | ||||||
| @@ -44,6 +44,8 @@ class CefWindowDelegateCToCpp | |||||||
|                                  bool active) override; |                                  bool active) override; | ||||||
|   void OnWindowBoundsChanged(CefRefPtr<CefWindow> window, |   void OnWindowBoundsChanged(CefRefPtr<CefWindow> window, | ||||||
|                              const CefRect& new_bounds) override; |                              const CefRect& new_bounds) override; | ||||||
|  |   void OnWindowFullscreenTransition(CefRefPtr<CefWindow> window, | ||||||
|  |                                     bool is_completed) override; | ||||||
|   CefRefPtr<CefWindow> GetParentWindow(CefRefPtr<CefWindow> window, |   CefRefPtr<CefWindow> GetParentWindow(CefRefPtr<CefWindow> window, | ||||||
|                                        bool* is_menu, |                                        bool* is_menu, | ||||||
|                                        bool* can_activate_menu) override; |                                        bool* can_activate_menu) override; | ||||||
| @@ -61,8 +63,6 @@ class CefWindowDelegateCToCpp | |||||||
|   bool OnAccelerator(CefRefPtr<CefWindow> window, int command_id) override; |   bool OnAccelerator(CefRefPtr<CefWindow> window, int command_id) override; | ||||||
|   bool OnKeyEvent(CefRefPtr<CefWindow> window, |   bool OnKeyEvent(CefRefPtr<CefWindow> window, | ||||||
|                   const CefKeyEvent& event) override; |                   const CefKeyEvent& event) override; | ||||||
|   void OnWindowFullscreenTransition(CefRefPtr<CefWindow> window, |  | ||||||
|                                     bool is_completed) override; |  | ||||||
|  |  | ||||||
|   // CefPanelDelegate methods. |   // CefPanelDelegate methods. | ||||||
|  |  | ||||||
|   | |||||||
| @@ -70,7 +70,7 @@ index a521886e9eb44..4ba68bf125c94 100644 | |||||||
|      ] |      ] | ||||||
|    } |    } | ||||||
| diff --git chrome/browser/ui/browser.cc chrome/browser/ui/browser.cc | diff --git chrome/browser/ui/browser.cc chrome/browser/ui/browser.cc | ||||||
| index fdb96dee05067..7719f86fd4e0e 100644 | index fdb96dee05067..a188b6442b1ca 100644 | ||||||
| --- chrome/browser/ui/browser.cc | --- chrome/browser/ui/browser.cc | ||||||
| +++ chrome/browser/ui/browser.cc | +++ chrome/browser/ui/browser.cc | ||||||
| @@ -265,6 +265,25 @@ | @@ -265,6 +265,25 @@ | ||||||
| @@ -123,7 +123,16 @@ index fdb96dee05067..7719f86fd4e0e 100644 | |||||||
|  } |  } | ||||||
|   |   | ||||||
|  /////////////////////////////////////////////////////////////////////////////// |  /////////////////////////////////////////////////////////////////////////////// | ||||||
| @@ -1394,6 +1423,14 @@ content::KeyboardEventProcessingResult Browser::PreHandleKeyboardEvent( | @@ -1055,6 +1084,8 @@ void Browser::WindowFullscreenStateChanged() { | ||||||
|  |        ->WindowFullscreenStateChanged(); | ||||||
|  |    command_controller_->FullscreenStateChanged(); | ||||||
|  |    UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN); | ||||||
|  | + | ||||||
|  | +  CALL_CEF_DELEGATE(WindowFullscreenStateChanged); | ||||||
|  |  } | ||||||
|  |   | ||||||
|  |  void Browser::FullscreenTopUIStateChanged() { | ||||||
|  | @@ -1394,6 +1425,14 @@ content::KeyboardEventProcessingResult Browser::PreHandleKeyboardEvent( | ||||||
|    if (exclusive_access_manager_->HandleUserKeyEvent(event)) |    if (exclusive_access_manager_->HandleUserKeyEvent(event)) | ||||||
|      return content::KeyboardEventProcessingResult::HANDLED; |      return content::KeyboardEventProcessingResult::HANDLED; | ||||||
|   |   | ||||||
| @@ -138,7 +147,7 @@ index fdb96dee05067..7719f86fd4e0e 100644 | |||||||
|    return window()->PreHandleKeyboardEvent(event); |    return window()->PreHandleKeyboardEvent(event); | ||||||
|  } |  } | ||||||
|   |   | ||||||
| @@ -1401,8 +1438,18 @@ bool Browser::HandleKeyboardEvent(content::WebContents* source, | @@ -1401,8 +1440,18 @@ bool Browser::HandleKeyboardEvent(content::WebContents* source, | ||||||
|                                    const NativeWebKeyboardEvent& event) { |                                    const NativeWebKeyboardEvent& event) { | ||||||
|    DevToolsWindow* devtools_window = |    DevToolsWindow* devtools_window = | ||||||
|        DevToolsWindow::GetInstanceForInspectedWebContents(source); |        DevToolsWindow::GetInstanceForInspectedWebContents(source); | ||||||
| @@ -159,7 +168,7 @@ index fdb96dee05067..7719f86fd4e0e 100644 | |||||||
|  } |  } | ||||||
|   |   | ||||||
|  bool Browser::TabsNeedBeforeUnloadFired() { |  bool Browser::TabsNeedBeforeUnloadFired() { | ||||||
| @@ -1613,6 +1660,14 @@ WebContents* Browser::OpenURLFromTab(WebContents* source, | @@ -1613,6 +1662,14 @@ WebContents* Browser::OpenURLFromTab(WebContents* source, | ||||||
|    } |    } | ||||||
|  #endif  // BUILDFLAG(IS_CHROMEOS_ASH) |  #endif  // BUILDFLAG(IS_CHROMEOS_ASH) | ||||||
|   |   | ||||||
| @@ -174,7 +183,7 @@ index fdb96dee05067..7719f86fd4e0e 100644 | |||||||
|    NavigateParams nav_params(this, params.url, params.transition); |    NavigateParams nav_params(this, params.url, params.transition); | ||||||
|    nav_params.FillNavigateParamsFromOpenURLParams(params); |    nav_params.FillNavigateParamsFromOpenURLParams(params); | ||||||
|    nav_params.source_contents = source; |    nav_params.source_contents = source; | ||||||
| @@ -1770,6 +1825,8 @@ void Browser::LoadingStateChanged(WebContents* source, | @@ -1770,6 +1827,8 @@ void Browser::LoadingStateChanged(WebContents* source, | ||||||
|                                    bool should_show_loading_ui) { |                                    bool should_show_loading_ui) { | ||||||
|    ScheduleUIUpdate(source, content::INVALIDATE_TYPE_LOAD); |    ScheduleUIUpdate(source, content::INVALIDATE_TYPE_LOAD); | ||||||
|    UpdateWindowForLoadingStateChanged(source, should_show_loading_ui); |    UpdateWindowForLoadingStateChanged(source, should_show_loading_ui); | ||||||
| @@ -183,7 +192,7 @@ index fdb96dee05067..7719f86fd4e0e 100644 | |||||||
|  } |  } | ||||||
|   |   | ||||||
|  void Browser::CloseContents(WebContents* source) { |  void Browser::CloseContents(WebContents* source) { | ||||||
| @@ -1798,6 +1855,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) { | @@ -1798,6 +1857,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) { | ||||||
|  } |  } | ||||||
|   |   | ||||||
|  void Browser::UpdateTargetURL(WebContents* source, const GURL& url) { |  void Browser::UpdateTargetURL(WebContents* source, const GURL& url) { | ||||||
| @@ -192,7 +201,7 @@ index fdb96dee05067..7719f86fd4e0e 100644 | |||||||
|    if (!GetStatusBubble()) |    if (!GetStatusBubble()) | ||||||
|      return; |      return; | ||||||
|   |   | ||||||
| @@ -1805,6 +1864,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) { | @@ -1805,6 +1866,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) { | ||||||
|      GetStatusBubble()->SetURL(url); |      GetStatusBubble()->SetURL(url); | ||||||
|  } |  } | ||||||
|   |   | ||||||
| @@ -210,7 +219,7 @@ index fdb96dee05067..7719f86fd4e0e 100644 | |||||||
|  void Browser::ContentsMouseEvent(WebContents* source, |  void Browser::ContentsMouseEvent(WebContents* source, | ||||||
|                                   bool motion, |                                   bool motion, | ||||||
|                                   bool exited) { |                                   bool exited) { | ||||||
| @@ -1829,6 +1899,19 @@ bool Browser::TakeFocus(content::WebContents* source, bool reverse) { | @@ -1829,6 +1901,19 @@ bool Browser::TakeFocus(content::WebContents* source, bool reverse) { | ||||||
|    return false; |    return false; | ||||||
|  } |  } | ||||||
|   |   | ||||||
| @@ -230,7 +239,7 @@ index fdb96dee05067..7719f86fd4e0e 100644 | |||||||
|  void Browser::BeforeUnloadFired(WebContents* web_contents, |  void Browser::BeforeUnloadFired(WebContents* web_contents, | ||||||
|                                  bool proceed, |                                  bool proceed, | ||||||
|                                  bool* proceed_to_fire_unload) { |                                  bool* proceed_to_fire_unload) { | ||||||
| @@ -1921,6 +2004,10 @@ void Browser::WebContentsCreated(WebContents* source_contents, | @@ -1921,6 +2006,10 @@ void Browser::WebContentsCreated(WebContents* source_contents, | ||||||
|   |   | ||||||
|    // Make the tab show up in the task manager. |    // Make the tab show up in the task manager. | ||||||
|    task_manager::WebContentsTags::CreateForTabContents(new_contents); |    task_manager::WebContentsTags::CreateForTabContents(new_contents); | ||||||
| @@ -241,7 +250,7 @@ index fdb96dee05067..7719f86fd4e0e 100644 | |||||||
|  } |  } | ||||||
|   |   | ||||||
|  void Browser::PortalWebContentsCreated(WebContents* portal_web_contents) { |  void Browser::PortalWebContentsCreated(WebContents* portal_web_contents) { | ||||||
| @@ -2038,11 +2125,15 @@ void Browser::EnterFullscreenModeForTab( | @@ -2038,11 +2127,15 @@ void Browser::EnterFullscreenModeForTab( | ||||||
|      const blink::mojom::FullscreenOptions& options) { |      const blink::mojom::FullscreenOptions& options) { | ||||||
|    exclusive_access_manager_->fullscreen_controller()->EnterFullscreenModeForTab( |    exclusive_access_manager_->fullscreen_controller()->EnterFullscreenModeForTab( | ||||||
|        requesting_frame, options.display_id); |        requesting_frame, options.display_id); | ||||||
| @@ -257,7 +266,7 @@ index fdb96dee05067..7719f86fd4e0e 100644 | |||||||
|  } |  } | ||||||
|   |   | ||||||
|  bool Browser::IsFullscreenForTabOrPending(const WebContents* web_contents) { |  bool Browser::IsFullscreenForTabOrPending(const WebContents* web_contents) { | ||||||
| @@ -2232,6 +2323,15 @@ void Browser::RequestMediaAccessPermission( | @@ -2232,6 +2325,15 @@ void Browser::RequestMediaAccessPermission( | ||||||
|      content::WebContents* web_contents, |      content::WebContents* web_contents, | ||||||
|      const content::MediaStreamRequest& request, |      const content::MediaStreamRequest& request, | ||||||
|      content::MediaResponseCallback callback) { |      content::MediaResponseCallback callback) { | ||||||
| @@ -273,7 +282,7 @@ index fdb96dee05067..7719f86fd4e0e 100644 | |||||||
|    const extensions::Extension* extension = |    const extensions::Extension* extension = | ||||||
|        GetExtensionForOrigin(profile_, request.security_origin); |        GetExtensionForOrigin(profile_, request.security_origin); | ||||||
|    MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest( |    MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest( | ||||||
| @@ -2783,13 +2883,20 @@ void Browser::RemoveScheduledUpdatesFor(WebContents* contents) { | @@ -2783,13 +2885,20 @@ void Browser::RemoveScheduledUpdatesFor(WebContents* contents) { | ||||||
|  // Browser, Getters for UI (private): |  // Browser, Getters for UI (private): | ||||||
|   |   | ||||||
|  StatusBubble* Browser::GetStatusBubble() { |  StatusBubble* Browser::GetStatusBubble() { | ||||||
| @@ -295,7 +304,7 @@ index fdb96dee05067..7719f86fd4e0e 100644 | |||||||
|    return window_ ? window_->GetStatusBubble() : nullptr; |    return window_ ? window_->GetStatusBubble() : nullptr; | ||||||
|  } |  } | ||||||
|   |   | ||||||
| @@ -2923,6 +3030,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) { | @@ -2923,6 +3032,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) { | ||||||
|      BookmarkTabHelper::FromWebContents(web_contents)->RemoveObserver(this); |      BookmarkTabHelper::FromWebContents(web_contents)->RemoveObserver(this); | ||||||
|      web_contents_collection_.StopObserving(web_contents); |      web_contents_collection_.StopObserving(web_contents); | ||||||
|    } |    } | ||||||
| @@ -304,7 +313,7 @@ index fdb96dee05067..7719f86fd4e0e 100644 | |||||||
|  } |  } | ||||||
|   |   | ||||||
|  void Browser::TabDetachedAtImpl(content::WebContents* contents, |  void Browser::TabDetachedAtImpl(content::WebContents* contents, | ||||||
| @@ -3077,6 +3186,14 @@ bool Browser::PictureInPictureBrowserSupportsWindowFeature( | @@ -3077,6 +3188,14 @@ bool Browser::PictureInPictureBrowserSupportsWindowFeature( | ||||||
|   |   | ||||||
|  bool Browser::SupportsWindowFeatureImpl(WindowFeature feature, |  bool Browser::SupportsWindowFeatureImpl(WindowFeature feature, | ||||||
|                                          bool check_can_support) const { |                                          bool check_can_support) const { | ||||||
|   | |||||||
| @@ -277,12 +277,18 @@ void ViewsWindow::SetFavicon(CefRefPtr<CefImage> image) { | |||||||
|  |  | ||||||
| void ViewsWindow::SetFullscreen(bool fullscreen) { | void ViewsWindow::SetFullscreen(bool fullscreen) { | ||||||
|   CEF_REQUIRE_UI_THREAD(); |   CEF_REQUIRE_UI_THREAD(); | ||||||
|   if (window_) { |  | ||||||
|     // Hide the top controls while in full-screen mode. |  | ||||||
|     if (with_controls_) { |  | ||||||
|       ShowTopControls(!fullscreen); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |   // For Chrome runtime we ignore this notification from | ||||||
|  |   // ClientHandler::OnFullscreenModeChange(). Chrome runtime will trigger | ||||||
|  |   // the fullscreen change internally and then call | ||||||
|  |   // OnWindowFullscreenTransition(). | ||||||
|  |   if (MainContext::Get()->UseChromeRuntime()) { | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   // For Alloy runtime we need to explicitly trigger the fullscreen change. | ||||||
|  |   if (window_) { | ||||||
|  |     // Results in a call to OnWindowFullscreenTransition(). | ||||||
|     window_->SetFullscreen(fullscreen); |     window_->SetFullscreen(fullscreen); | ||||||
|   } |   } | ||||||
| } | } | ||||||
| @@ -404,10 +410,12 @@ bool ViewsWindow::GetWindowRestorePreferences( | |||||||
|   show_state = CEF_SHOW_STATE_NORMAL; |   show_state = CEF_SHOW_STATE_NORMAL; | ||||||
|   if (window_->IsMinimized()) { |   if (window_->IsMinimized()) { | ||||||
|     show_state = CEF_SHOW_STATE_MINIMIZED; |     show_state = CEF_SHOW_STATE_MINIMIZED; | ||||||
|  |   } else if (window_->IsFullscreen()) { | ||||||
|  |     // On MacOS, IsMaximized() will also return true for fullscreen, so check | ||||||
|  |     // IsFullscreen() first. | ||||||
|  |     show_state = CEF_SHOW_STATE_FULLSCREEN; | ||||||
|   } else if (window_->IsMaximized()) { |   } else if (window_->IsMaximized()) { | ||||||
|     show_state = CEF_SHOW_STATE_MAXIMIZED; |     show_state = CEF_SHOW_STATE_MAXIMIZED; | ||||||
|   } else if (window_->IsFullscreen()) { |  | ||||||
|     show_state = CEF_SHOW_STATE_FULLSCREEN; |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   if (show_state == CEF_SHOW_STATE_NORMAL) { |   if (show_state == CEF_SHOW_STATE_NORMAL) { | ||||||
| @@ -626,6 +634,25 @@ bool ViewsWindow::OnKeyEvent(CefRefPtr<CefTextfield> textfield, | |||||||
|   return false; |   return false; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void ViewsWindow::OnWindowFullscreenTransition(CefRefPtr<CefWindow> window, | ||||||
|  |                                                bool is_completed) { | ||||||
|  | #if defined(OS_MAC) | ||||||
|  |   // On MacOS we get two asynchronous callbacks, and we want to change the UI on | ||||||
|  |   // |is_completed=false| (e.g. when the fullscreen transition begins). | ||||||
|  |   const bool should_change = !is_completed; | ||||||
|  | #else | ||||||
|  |   // On other platforms we only get a single synchronous callback with | ||||||
|  |   // |is_completed=true|. | ||||||
|  |   DCHECK(is_completed); | ||||||
|  |   const bool should_change = true; | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  |   // Hide the top controls while in fullscreen mode. | ||||||
|  |   if (should_change && with_controls_) { | ||||||
|  |     ShowTopControls(!window->IsFullscreen()); | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
| void ViewsWindow::OnWindowCreated(CefRefPtr<CefWindow> window) { | void ViewsWindow::OnWindowCreated(CefRefPtr<CefWindow> window) { | ||||||
|   CEF_REQUIRE_UI_THREAD(); |   CEF_REQUIRE_UI_THREAD(); | ||||||
|   DCHECK(browser_view_); |   DCHECK(browser_view_); | ||||||
|   | |||||||
| @@ -188,6 +188,8 @@ class ViewsWindow : public CefBrowserViewDelegate, | |||||||
|   bool OnAccelerator(CefRefPtr<CefWindow> window, int command_id) override; |   bool OnAccelerator(CefRefPtr<CefWindow> window, int command_id) override; | ||||||
|   bool OnKeyEvent(CefRefPtr<CefWindow> window, |   bool OnKeyEvent(CefRefPtr<CefWindow> window, | ||||||
|                   const CefKeyEvent& event) override; |                   const CefKeyEvent& event) override; | ||||||
|  |   void OnWindowFullscreenTransition(CefRefPtr<CefWindow> window, | ||||||
|  |                                     bool is_completed) override; | ||||||
|  |  | ||||||
|   // CefViewDelegate methods: |   // CefViewDelegate methods: | ||||||
|   CefSize GetPreferredSize(CefRefPtr<CefView> view) override; |   CefSize GetPreferredSize(CefRefPtr<CefView> view) override; | ||||||
|   | |||||||
| @@ -35,6 +35,7 @@ const char kMessagePositionName[] = "WindowTest.Position"; | |||||||
| const char kMessageMinimizeName[] = "WindowTest.Minimize"; | const char kMessageMinimizeName[] = "WindowTest.Minimize"; | ||||||
| const char kMessageMaximizeName[] = "WindowTest.Maximize"; | const char kMessageMaximizeName[] = "WindowTest.Maximize"; | ||||||
| const char kMessageRestoreName[] = "WindowTest.Restore"; | const char kMessageRestoreName[] = "WindowTest.Restore"; | ||||||
|  | const char kMessageFullscreenName[] = "WindowTest.Fullscreen"; | ||||||
| const char kMessageTitlebarHeightName[] = "WindowTest.TitlebarHeight"; | const char kMessageTitlebarHeightName[] = "WindowTest.TitlebarHeight"; | ||||||
|  |  | ||||||
| // Create the appropriate platform test runner object. | // Create the appropriate platform test runner object. | ||||||
| @@ -109,6 +110,8 @@ class Handler : public CefMessageRouterBrowserSide::Handler { | |||||||
|       runner_->Maximize(browser); |       runner_->Maximize(browser); | ||||||
|     } else if (message_name == kMessageRestoreName) { |     } else if (message_name == kMessageRestoreName) { | ||||||
|       runner_->Restore(browser); |       runner_->Restore(browser); | ||||||
|  |     } else if (message_name == kMessageFullscreenName) { | ||||||
|  |       runner_->Fullscreen(browser); | ||||||
|     } else if (message_name.find(kMessageTitlebarHeightName) == 0) { |     } else if (message_name.find(kMessageTitlebarHeightName) == 0) { | ||||||
|       const auto height = ParseHeight(message_name); |       const auto height = ParseHeight(message_name); | ||||||
|       runner_->SetTitleBarHeight(browser, height); |       runner_->SetTitleBarHeight(browser, height); | ||||||
|   | |||||||
| @@ -36,6 +36,10 @@ void WindowTestRunner::ModifyBounds(const CefRect& display, CefRect& window) { | |||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void WindowTestRunner::Fullscreen(CefRefPtr<CefBrowser> browser) { | ||||||
|  |   NOTIMPLEMENTED(); | ||||||
|  | } | ||||||
|  |  | ||||||
| void WindowTestRunner::SetTitleBarHeight(CefRefPtr<CefBrowser> browser, | void WindowTestRunner::SetTitleBarHeight(CefRefPtr<CefBrowser> browser, | ||||||
|                                          const std::optional<float>& height) { |                                          const std::optional<float>& height) { | ||||||
|   NOTIMPLEMENTED(); |   NOTIMPLEMENTED(); | ||||||
|   | |||||||
| @@ -27,6 +27,7 @@ class WindowTestRunner { | |||||||
|   virtual void Minimize(CefRefPtr<CefBrowser> browser) = 0; |   virtual void Minimize(CefRefPtr<CefBrowser> browser) = 0; | ||||||
|   virtual void Maximize(CefRefPtr<CefBrowser> browser) = 0; |   virtual void Maximize(CefRefPtr<CefBrowser> browser) = 0; | ||||||
|   virtual void Restore(CefRefPtr<CefBrowser> browser) = 0; |   virtual void Restore(CefRefPtr<CefBrowser> browser) = 0; | ||||||
|  |   virtual void Fullscreen(CefRefPtr<CefBrowser> browser); | ||||||
|  |  | ||||||
|   // Fit |window| inside |display|. Coordinates are relative to the upper-left |   // Fit |window| inside |display|. Coordinates are relative to the upper-left | ||||||
|   // corner of the display. |   // corner of the display. | ||||||
|   | |||||||
| @@ -69,6 +69,17 @@ void WindowTestRunnerViews::Restore(CefRefPtr<CefBrowser> browser) { | |||||||
|   GetWindow(browser)->Restore(); |   GetWindow(browser)->Restore(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void WindowTestRunnerViews::Fullscreen(CefRefPtr<CefBrowser> browser) { | ||||||
|  |   auto window = GetWindow(browser); | ||||||
|  |  | ||||||
|  |   // Results in a call to ViewsWindow::OnWindowFullscreenTransition(). | ||||||
|  |   if (window->IsFullscreen()) { | ||||||
|  |     window->SetFullscreen(false); | ||||||
|  |   } else { | ||||||
|  |     window->SetFullscreen(true); | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
| void WindowTestRunnerViews::SetTitleBarHeight( | void WindowTestRunnerViews::SetTitleBarHeight( | ||||||
|     CefRefPtr<CefBrowser> browser, |     CefRefPtr<CefBrowser> browser, | ||||||
|     const std::optional<float>& height) { |     const std::optional<float>& height) { | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ class WindowTestRunnerViews : public WindowTestRunner { | |||||||
|   void Minimize(CefRefPtr<CefBrowser> browser) override; |   void Minimize(CefRefPtr<CefBrowser> browser) override; | ||||||
|   void Maximize(CefRefPtr<CefBrowser> browser) override; |   void Maximize(CefRefPtr<CefBrowser> browser) override; | ||||||
|   void Restore(CefRefPtr<CefBrowser> browser) override; |   void Restore(CefRefPtr<CefBrowser> browser) override; | ||||||
|  |   void Fullscreen(CefRefPtr<CefBrowser> browser) override; | ||||||
|   void SetTitleBarHeight(CefRefPtr<CefBrowser> browser, |   void SetTitleBarHeight(CefRefPtr<CefBrowser> browser, | ||||||
|                          const std::optional<float>& height) override; |                          const std::optional<float>& height) override; | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -38,6 +38,10 @@ function restore() { | |||||||
|   setTimeout(function() { send_message('Restore'); }, 1000); |   setTimeout(function() { send_message('Restore'); }, 1000); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | function fullscreen() { | ||||||
|  |   send_message('Fullscreen'); | ||||||
|  | } | ||||||
|  |  | ||||||
| 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); | ||||||
| @@ -64,6 +68,7 @@ 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="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"> | ||||||
|   | |||||||
| @@ -23,6 +23,11 @@ namespace { | |||||||
| // Test timeout in MS. | // Test timeout in MS. | ||||||
| const int kTestTimeout = 5000; | const int kTestTimeout = 5000; | ||||||
|  |  | ||||||
|  | #if defined(OS_MAC) | ||||||
|  | // Match the value in view_util_mac.mm. | ||||||
|  | constexpr float kDefaultTitleBarHeight = 30; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| }  // namespace | }  // namespace | ||||||
|  |  | ||||||
| // static | // static | ||||||
| @@ -33,8 +38,8 @@ void TestWindowDelegate::RunTest(CefRefPtr<CefWaitableEvent> event, | |||||||
|                                  std::unique_ptr<Config> config) { |                                  std::unique_ptr<Config> config) { | ||||||
|   CefSize window_size{config->window_size, config->window_size}; |   CefSize window_size{config->window_size, config->window_size}; | ||||||
|  |  | ||||||
| #if defined(OS_WIN) |  | ||||||
|   if (!config->frameless) { |   if (!config->frameless) { | ||||||
|  | #if defined(OS_WIN) | ||||||
|     // Expand the client area size to full window size based on the default |     // Expand the client area size to full window size based on the default | ||||||
|     // frame window style. AdjustWindowRect expects pixel coordinates, so |     // frame window style. AdjustWindowRect expects pixel coordinates, so | ||||||
|     // perform the necessary conversions. |     // perform the necessary conversions. | ||||||
| @@ -53,8 +58,11 @@ void TestWindowDelegate::RunTest(CefRefPtr<CefWaitableEvent> event, | |||||||
|         {rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top}, |         {rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top}, | ||||||
|         scale_factor); |         scale_factor); | ||||||
|     window_size = {scaled_rect.width, scaled_rect.height}; |     window_size = {scaled_rect.width, scaled_rect.height}; | ||||||
|  | #elif defined(OS_MAC) | ||||||
|  |     // Expand client area size to include the default titlebar height. | ||||||
|  |     window_size.height += kDefaultTitleBarHeight; | ||||||
|  | #endif | ||||||
|   } |   } | ||||||
| #endif  // defined(OS_WIN) |  | ||||||
|  |  | ||||||
|   CefWindow::CreateTopLevelWindow( |   CefWindow::CreateTopLevelWindow( | ||||||
|       new TestWindowDelegate(event, std::move(config), window_size)); |       new TestWindowDelegate(event, std::move(config), window_size)); | ||||||
| @@ -67,14 +75,8 @@ void TestWindowDelegate::OnWindowCreated(CefRefPtr<CefWindow> window) { | |||||||
|   EXPECT_TRUE(window->IsValid()); |   EXPECT_TRUE(window->IsValid()); | ||||||
|   EXPECT_FALSE(window->IsClosed()); |   EXPECT_FALSE(window->IsClosed()); | ||||||
|  |  | ||||||
|   EXPECT_FALSE(window->IsVisible()); |  | ||||||
|   EXPECT_FALSE(window->IsDrawn()); |  | ||||||
|  |  | ||||||
|   EXPECT_FALSE(window->IsActive()); |   EXPECT_FALSE(window->IsActive()); | ||||||
|   EXPECT_FALSE(window->IsAlwaysOnTop()); |   EXPECT_FALSE(window->IsAlwaysOnTop()); | ||||||
|   EXPECT_FALSE(window->IsMaximized()); |  | ||||||
|   EXPECT_FALSE(window->IsMinimized()); |  | ||||||
|   EXPECT_FALSE(window->IsFullscreen()); |  | ||||||
|  |  | ||||||
|   const char* title = "ViewsTest"; |   const char* title = "ViewsTest"; | ||||||
|   window->SetTitle(title); |   window->SetTitle(title); | ||||||
| @@ -95,26 +97,36 @@ void TestWindowDelegate::OnWindowCreated(CefRefPtr<CefWindow> window) { | |||||||
|     EXPECT_FALSE(got_get_preferred_size_); |     EXPECT_FALSE(got_get_preferred_size_); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   CefRect client_bounds = window->GetBounds(); |   // Expectations for the default |initial_show_state| value. | ||||||
|   if (!config_->window_origin.IsEmpty()) { |   if (config_->initial_show_state == CEF_SHOW_STATE_NORMAL) { | ||||||
|     EXPECT_EQ(config_->window_origin.x, client_bounds.x); |     EXPECT_FALSE(window->IsVisible()); | ||||||
|     EXPECT_EQ(config_->window_origin.y, client_bounds.y); |     EXPECT_FALSE(window->IsDrawn()); | ||||||
|   } else { |  | ||||||
|     // Default origin is the upper-left corner of the display's work area. |  | ||||||
|     auto work_area = display->GetWorkArea(); |  | ||||||
|     EXPECT_NEAR(work_area.x, client_bounds.x, 1); |  | ||||||
|     EXPECT_NEAR(work_area.y, client_bounds.y, 1); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   if (config_->frameless) { |     EXPECT_FALSE(window->IsMaximized()); | ||||||
|     EXPECT_NEAR(config_->window_size, client_bounds.width, 2); |     EXPECT_FALSE(window->IsMinimized()); | ||||||
|     EXPECT_NEAR(config_->window_size, client_bounds.height, 2); |     EXPECT_FALSE(window->IsFullscreen()); | ||||||
|   } else { |  | ||||||
|     // Client area bounds calculation might have off-by-one errors on Windows |     CefRect client_bounds = window->GetBounds(); | ||||||
|     // due to non-client frame size being calculated internally in pixels and |     if (!config_->window_origin.IsEmpty()) { | ||||||
|     // then converted to DIPs. See https://crbug.com/602692. |       EXPECT_EQ(config_->window_origin.x, client_bounds.x); | ||||||
|     EXPECT_NEAR(client_bounds.width, window_size_.width, 2); |       EXPECT_EQ(config_->window_origin.y, client_bounds.y); | ||||||
|     EXPECT_NEAR(client_bounds.height, window_size_.height, 2); |     } else { | ||||||
|  |       // Default origin is the upper-left corner of the display's work area. | ||||||
|  |       auto work_area = display->GetWorkArea(); | ||||||
|  |       EXPECT_NEAR(work_area.x, client_bounds.x, 1); | ||||||
|  |       EXPECT_NEAR(work_area.y, client_bounds.y, 1); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     if (config_->frameless) { | ||||||
|  |       EXPECT_NEAR(config_->window_size, client_bounds.width, 2); | ||||||
|  |       EXPECT_NEAR(config_->window_size, client_bounds.height, 2); | ||||||
|  |     } else { | ||||||
|  |       // Client area bounds calculation might have off-by-one errors on Windows | ||||||
|  |       // due to non-client frame size being calculated internally in pixels and | ||||||
|  |       // then converted to DIPs. See https://crbug.com/602692. | ||||||
|  |       EXPECT_NEAR(client_bounds.width, window_size_.width, 2); | ||||||
|  |       EXPECT_NEAR(client_bounds.height, window_size_.height, 2); | ||||||
|  |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Run the callback. |   // Run the callback. | ||||||
| @@ -158,6 +170,41 @@ void TestWindowDelegate::OnWindowDestroyed(CefRefPtr<CefWindow> window) { | |||||||
|   weak_ptr_factory_.InvalidateWeakPtrs(); |   weak_ptr_factory_.InvalidateWeakPtrs(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void TestWindowDelegate::OnWindowFullscreenTransition( | ||||||
|  |     CefRefPtr<CefWindow> window, | ||||||
|  |     bool is_completed) { | ||||||
|  |   EXPECT_TRUE(window->IsSame(window_)); | ||||||
|  |  | ||||||
|  |   EXPECT_TRUE(window->IsValid()); | ||||||
|  |   EXPECT_FALSE(window->IsClosed()); | ||||||
|  |   EXPECT_TRUE(window->IsVisible()); | ||||||
|  |   EXPECT_TRUE(window->IsDrawn()); | ||||||
|  |  | ||||||
|  |   fullscreen_transition_callback_count_++; | ||||||
|  |  | ||||||
|  | #if defined(OS_MAC) | ||||||
|  |   // Two callbacks on MacOS. | ||||||
|  |   EXPECT_EQ(is_completed ? 2U : 1U, fullscreen_transition_callback_count_); | ||||||
|  | #else | ||||||
|  |   // Single callback on other platforms. | ||||||
|  |   EXPECT_TRUE(is_completed); | ||||||
|  |   EXPECT_EQ(1U, fullscreen_transition_callback_count_); | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  |   if (is_completed) { | ||||||
|  |     fullscreen_transition_complete_count_++; | ||||||
|  |  | ||||||
|  |     // Reset intermediate state. | ||||||
|  |     fullscreen_transition_callback_count_ = 0; | ||||||
|  |  | ||||||
|  |     // Run the callback. | ||||||
|  |     if (!config_->on_window_fullscreen_transition_complete.is_null()) { | ||||||
|  |       config_->on_window_fullscreen_transition_complete.Run( | ||||||
|  |           window, fullscreen_transition_complete_count_); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
| bool TestWindowDelegate::IsFrameless(CefRefPtr<CefWindow> window) { | bool TestWindowDelegate::IsFrameless(CefRefPtr<CefWindow> window) { | ||||||
|   return config_->frameless; |   return config_->frameless; | ||||||
| } | } | ||||||
| @@ -173,6 +220,11 @@ CefRect TestWindowDelegate::GetInitialBounds(CefRefPtr<CefWindow> window) { | |||||||
|   return CefRect(); |   return CefRect(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | cef_show_state_t TestWindowDelegate::GetInitialShowState( | ||||||
|  |     CefRefPtr<CefWindow> window) { | ||||||
|  |   return config_->initial_show_state; | ||||||
|  | } | ||||||
|  |  | ||||||
| CefSize TestWindowDelegate::GetPreferredSize(CefRefPtr<CefView> view) { | CefSize TestWindowDelegate::GetPreferredSize(CefRefPtr<CefView> view) { | ||||||
|   got_get_preferred_size_ = true; |   got_get_preferred_size_ = true; | ||||||
|   return window_size_; |   return window_size_; | ||||||
|   | |||||||
| @@ -20,6 +20,8 @@ class TestWindowDelegate : public CefWindowDelegate { | |||||||
|       base::OnceCallback<void(CefRefPtr<CefWindow>)>; |       base::OnceCallback<void(CefRefPtr<CefWindow>)>; | ||||||
|   using OnWindowDestroyedCallback = |   using OnWindowDestroyedCallback = | ||||||
|       base::OnceCallback<void(CefRefPtr<CefWindow>)>; |       base::OnceCallback<void(CefRefPtr<CefWindow>)>; | ||||||
|  |   using OnWindowFullscreenTransitionCompleteCallback = | ||||||
|  |       base::RepeatingCallback<void(CefRefPtr<CefWindow>, size_t /*count*/)>; | ||||||
|   using OnAcceleratorCallback = |   using OnAcceleratorCallback = | ||||||
|       base::RepeatingCallback<bool(CefRefPtr<CefWindow>, int)>; |       base::RepeatingCallback<bool(CefRefPtr<CefWindow>, int)>; | ||||||
|   using OnKeyEventCallback = |   using OnKeyEventCallback = | ||||||
| @@ -28,12 +30,15 @@ class TestWindowDelegate : public CefWindowDelegate { | |||||||
|   struct Config { |   struct Config { | ||||||
|     OnWindowCreatedCallback on_window_created; |     OnWindowCreatedCallback on_window_created; | ||||||
|     OnWindowDestroyedCallback on_window_destroyed; |     OnWindowDestroyedCallback on_window_destroyed; | ||||||
|  |     OnWindowFullscreenTransitionCompleteCallback | ||||||
|  |         on_window_fullscreen_transition_complete; | ||||||
|     OnAcceleratorCallback on_accelerator; |     OnAcceleratorCallback on_accelerator; | ||||||
|     OnKeyEventCallback on_key_event; |     OnKeyEventCallback on_key_event; | ||||||
|     bool frameless = false; |     bool frameless = false; | ||||||
|     bool close_window = true; |     bool close_window = true; | ||||||
|     int window_size = kWSize; |     int window_size = kWSize; | ||||||
|     CefPoint window_origin = {}; |     CefPoint window_origin = {}; | ||||||
|  |     cef_show_state_t initial_show_state = CEF_SHOW_STATE_NORMAL; | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   // Creates a Window with a new TestWindowDelegate instance and executes |   // Creates a Window with a new TestWindowDelegate instance and executes | ||||||
| @@ -48,8 +53,11 @@ class TestWindowDelegate : public CefWindowDelegate { | |||||||
|   // CefWindowDelegate methods: |   // CefWindowDelegate methods: | ||||||
|   void OnWindowCreated(CefRefPtr<CefWindow> window) override; |   void OnWindowCreated(CefRefPtr<CefWindow> window) override; | ||||||
|   void OnWindowDestroyed(CefRefPtr<CefWindow> window) override; |   void OnWindowDestroyed(CefRefPtr<CefWindow> window) override; | ||||||
|  |   void OnWindowFullscreenTransition(CefRefPtr<CefWindow> window, | ||||||
|  |                                     bool is_completed) override; | ||||||
|   bool IsFrameless(CefRefPtr<CefWindow> window) override; |   bool IsFrameless(CefRefPtr<CefWindow> window) override; | ||||||
|   CefRect GetInitialBounds(CefRefPtr<CefWindow> window) override; |   CefRect GetInitialBounds(CefRefPtr<CefWindow> window) override; | ||||||
|  |   cef_show_state_t GetInitialShowState(CefRefPtr<CefWindow> window) override; | ||||||
|   CefSize GetPreferredSize(CefRefPtr<CefView> view) override; |   CefSize GetPreferredSize(CefRefPtr<CefView> view) override; | ||||||
|   bool OnAccelerator(CefRefPtr<CefWindow> window, int command_id) override; |   bool OnAccelerator(CefRefPtr<CefWindow> window, int command_id) override; | ||||||
|   bool OnKeyEvent(CefRefPtr<CefWindow> window, |   bool OnKeyEvent(CefRefPtr<CefWindow> window, | ||||||
| @@ -73,6 +81,9 @@ class TestWindowDelegate : public CefWindowDelegate { | |||||||
|   bool got_get_initial_bounds_ = false; |   bool got_get_initial_bounds_ = false; | ||||||
|   bool got_get_preferred_size_ = false; |   bool got_get_preferred_size_ = false; | ||||||
|  |  | ||||||
|  |   size_t fullscreen_transition_callback_count_ = 0; | ||||||
|  |   size_t fullscreen_transition_complete_count_ = 0; | ||||||
|  |  | ||||||
|   // Must be the last member. |   // Must be the last member. | ||||||
|   base::WeakPtrFactory<TestWindowDelegate> weak_ptr_factory_; |   base::WeakPtrFactory<TestWindowDelegate> weak_ptr_factory_; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -36,6 +36,13 @@ void ExpectCloseRects(const CefRect& expected, | |||||||
|   EXPECT_LE(abs(expected.height - actual.height), allowed_deviance); |   EXPECT_LE(abs(expected.height - actual.height), allowed_deviance); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void ExpectClosePoints(const CefPoint& expected, | ||||||
|  |                        const CefPoint& actual, | ||||||
|  |                        int allowed_deviance) { | ||||||
|  |   EXPECT_LE(abs(expected.x - actual.x), allowed_deviance); | ||||||
|  |   EXPECT_LE(abs(expected.y - actual.y), allowed_deviance); | ||||||
|  | } | ||||||
|  |  | ||||||
| void WindowCreateImpl(CefRefPtr<CefWaitableEvent> event) { | void WindowCreateImpl(CefRefPtr<CefWaitableEvent> event) { | ||||||
|   auto config = std::make_unique<TestWindowDelegate::Config>(); |   auto config = std::make_unique<TestWindowDelegate::Config>(); | ||||||
|   TestWindowDelegate::RunTest(event, std::move(config)); |   TestWindowDelegate::RunTest(event, std::move(config)); | ||||||
| @@ -47,23 +54,106 @@ void WindowCreateFramelessImpl(CefRefPtr<CefWaitableEvent> event) { | |||||||
|   TestWindowDelegate::RunTest(event, std::move(config)); |   TestWindowDelegate::RunTest(event, std::move(config)); | ||||||
| } | } | ||||||
|  |  | ||||||
| void RunWindowShow(CefRefPtr<CefWindow> window) { | void RunWindowShow(cef_show_state_t initial_show_state, | ||||||
|   EXPECT_FALSE(window->IsVisible()); |                    CefRefPtr<CefWindow> window) { | ||||||
|   EXPECT_FALSE(window->IsDrawn()); | #if defined(OS_MAC) | ||||||
|   window->Show(); |   if (initial_show_state == CEF_SHOW_STATE_FULLSCREEN) { | ||||||
|   EXPECT_TRUE(window->IsVisible()); |     // On MacOS, starting in fullscreen mode also shows the window on creation. | ||||||
|   EXPECT_TRUE(window->IsDrawn()); |     EXPECT_TRUE(window->IsVisible()); | ||||||
|  |     EXPECT_TRUE(window->IsDrawn()); | ||||||
|  |   } else | ||||||
|  | #endif | ||||||
|  |   { | ||||||
|  |     EXPECT_FALSE(window->IsVisible()); | ||||||
|  |     EXPECT_FALSE(window->IsDrawn()); | ||||||
|  |     window->Show(); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   if (initial_show_state == CEF_SHOW_STATE_MINIMIZED) { | ||||||
|  | #if !defined(OS_MAC) | ||||||
|  |     // This result is a bit unexpected, but I guess the platform considers a | ||||||
|  |     // window to be visible even when it's minimized. | ||||||
|  |     EXPECT_TRUE(window->IsVisible()); | ||||||
|  |     EXPECT_TRUE(window->IsDrawn()); | ||||||
|  | #else | ||||||
|  |     EXPECT_FALSE(window->IsVisible()); | ||||||
|  |     EXPECT_FALSE(window->IsDrawn()); | ||||||
|  | #endif | ||||||
|  |   } else { | ||||||
|  |     EXPECT_TRUE(window->IsVisible()); | ||||||
|  |     EXPECT_TRUE(window->IsDrawn()); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   switch (initial_show_state) { | ||||||
|  |     case CEF_SHOW_STATE_NORMAL: | ||||||
|  |       EXPECT_FALSE(window->IsMaximized()); | ||||||
|  |       EXPECT_FALSE(window->IsMinimized()); | ||||||
|  |       EXPECT_FALSE(window->IsFullscreen()); | ||||||
|  |       break; | ||||||
|  |     case CEF_SHOW_STATE_MINIMIZED: | ||||||
|  |       EXPECT_FALSE(window->IsMaximized()); | ||||||
|  | #if defined(OS_WIN) | ||||||
|  |       // On MacOS, IsMinimized() state isn't reliable in this callback due to a | ||||||
|  |       // timing issue between NativeWidgetMac::Minimize requesting the minimize | ||||||
|  |       // state change (before this callback) and | ||||||
|  |       // NativeWidgetMacNSWindowHost::OnWindowMiniaturizedChanged indicating the | ||||||
|  |       // completed state change (after this callback). | ||||||
|  |       // On Linux, there's likely a similar timing issue. | ||||||
|  |       EXPECT_TRUE(window->IsMinimized()); | ||||||
|  | #endif | ||||||
|  |       EXPECT_FALSE(window->IsFullscreen()); | ||||||
|  |       break; | ||||||
|  |     case CEF_SHOW_STATE_MAXIMIZED: | ||||||
|  | #if !defined(OS_LINUX) | ||||||
|  |       // On Linux, there's likely a similar timing issue. | ||||||
|  |       EXPECT_TRUE(window->IsMaximized()); | ||||||
|  | #endif | ||||||
|  |       EXPECT_FALSE(window->IsMinimized()); | ||||||
|  |       EXPECT_FALSE(window->IsFullscreen()); | ||||||
|  |       break; | ||||||
|  |     case CEF_SHOW_STATE_FULLSCREEN: | ||||||
|  |       EXPECT_FALSE(window->IsMaximized()); | ||||||
|  |       EXPECT_FALSE(window->IsMinimized()); | ||||||
|  |       EXPECT_TRUE(window->IsFullscreen()); | ||||||
|  |       break; | ||||||
|  |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| void WindowCreateWithOriginImpl(CefRefPtr<CefWaitableEvent> event) { | void WindowCreateWithOriginImpl(CefRefPtr<CefWaitableEvent> event) { | ||||||
|   auto config = std::make_unique<TestWindowDelegate::Config>(); |   auto config = std::make_unique<TestWindowDelegate::Config>(); | ||||||
|   config->window_origin = {100, 200}; |   config->window_origin = {100, 200}; | ||||||
|   config->on_window_created = base::BindOnce(RunWindowShow); |   config->on_window_created = | ||||||
|  |       base::BindOnce(RunWindowShow, config->initial_show_state); | ||||||
|   TestWindowDelegate::RunTest(event, std::move(config)); |   TestWindowDelegate::RunTest(event, std::move(config)); | ||||||
| } | } | ||||||
|  |  | ||||||
| void RunWindowShowHide(CefRefPtr<CefWindow> window) { | void WindowCreateMinimizedImpl(CefRefPtr<CefWaitableEvent> event) { | ||||||
|   RunWindowShow(window); |   auto config = std::make_unique<TestWindowDelegate::Config>(); | ||||||
|  |   config->initial_show_state = CEF_SHOW_STATE_MINIMIZED; | ||||||
|  |   config->on_window_created = | ||||||
|  |       base::BindOnce(RunWindowShow, config->initial_show_state); | ||||||
|  |   TestWindowDelegate::RunTest(event, std::move(config)); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void WindowCreateMaximizedImpl(CefRefPtr<CefWaitableEvent> event) { | ||||||
|  |   auto config = std::make_unique<TestWindowDelegate::Config>(); | ||||||
|  |   config->initial_show_state = CEF_SHOW_STATE_MAXIMIZED; | ||||||
|  |   config->on_window_created = | ||||||
|  |       base::BindOnce(RunWindowShow, config->initial_show_state); | ||||||
|  |   TestWindowDelegate::RunTest(event, std::move(config)); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void WindowCreateFullscreenImpl(CefRefPtr<CefWaitableEvent> event) { | ||||||
|  |   auto config = std::make_unique<TestWindowDelegate::Config>(); | ||||||
|  |   config->initial_show_state = CEF_SHOW_STATE_FULLSCREEN; | ||||||
|  |   config->on_window_created = | ||||||
|  |       base::BindOnce(RunWindowShow, config->initial_show_state); | ||||||
|  |   TestWindowDelegate::RunTest(event, std::move(config)); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void RunWindowShowHide(cef_show_state_t initial_show_state, | ||||||
|  |                        CefRefPtr<CefWindow> window) { | ||||||
|  |   RunWindowShow(initial_show_state, window); | ||||||
|   window->Hide(); |   window->Hide(); | ||||||
|   EXPECT_FALSE(window->IsVisible()); |   EXPECT_FALSE(window->IsVisible()); | ||||||
|   EXPECT_FALSE(window->IsDrawn()); |   EXPECT_FALSE(window->IsDrawn()); | ||||||
| @@ -71,13 +161,15 @@ void RunWindowShowHide(CefRefPtr<CefWindow> window) { | |||||||
|  |  | ||||||
| void WindowShowHideImpl(CefRefPtr<CefWaitableEvent> event) { | void WindowShowHideImpl(CefRefPtr<CefWaitableEvent> event) { | ||||||
|   auto config = std::make_unique<TestWindowDelegate::Config>(); |   auto config = std::make_unique<TestWindowDelegate::Config>(); | ||||||
|   config->on_window_created = base::BindOnce(RunWindowShowHide); |   config->on_window_created = | ||||||
|  |       base::BindOnce(RunWindowShowHide, config->initial_show_state); | ||||||
|   TestWindowDelegate::RunTest(event, std::move(config)); |   TestWindowDelegate::RunTest(event, std::move(config)); | ||||||
| } | } | ||||||
|  |  | ||||||
| void WindowShowHideFramelessImpl(CefRefPtr<CefWaitableEvent> event) { | void WindowShowHideFramelessImpl(CefRefPtr<CefWaitableEvent> event) { | ||||||
|   auto config = std::make_unique<TestWindowDelegate::Config>(); |   auto config = std::make_unique<TestWindowDelegate::Config>(); | ||||||
|   config->on_window_created = base::BindOnce(RunWindowShowHide); |   config->on_window_created = | ||||||
|  |       base::BindOnce(RunWindowShowHide, config->initial_show_state); | ||||||
|   config->frameless = true; |   config->frameless = true; | ||||||
|   TestWindowDelegate::RunTest(event, std::move(config)); |   TestWindowDelegate::RunTest(event, std::move(config)); | ||||||
| } | } | ||||||
| @@ -146,9 +238,9 @@ void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) { | |||||||
|             point); |             point); | ||||||
|   point = CefPoint(0, 0); |   point = CefPoint(0, 0); | ||||||
|   EXPECT_TRUE(view2->ConvertPointToScreen(point)); |   EXPECT_TRUE(view2->ConvertPointToScreen(point)); | ||||||
|   EXPECT_EQ(CefPoint(client_bounds_in_screen.x, |   ExpectClosePoints(CefPoint(client_bounds_in_screen.x, | ||||||
|                      client_bounds_in_screen.y + kWSize / 2), |                              client_bounds_in_screen.y + kWSize / 2), | ||||||
|             point); |                     point, 1); | ||||||
|  |  | ||||||
|   // Test view from screen coordinate conversions. |   // Test view from screen coordinate conversions. | ||||||
|   point = CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y); |   point = CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y); | ||||||
| @@ -157,7 +249,7 @@ void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) { | |||||||
|   point = CefPoint(client_bounds_in_screen.x, |   point = CefPoint(client_bounds_in_screen.x, | ||||||
|                    client_bounds_in_screen.y + kWSize / 2); |                    client_bounds_in_screen.y + kWSize / 2); | ||||||
|   EXPECT_TRUE(view2->ConvertPointFromScreen(point)); |   EXPECT_TRUE(view2->ConvertPointFromScreen(point)); | ||||||
|   EXPECT_EQ(CefPoint(0, 0), point); |   ExpectClosePoints(CefPoint(0, 0), point, 1); | ||||||
|  |  | ||||||
|   // Test view to window coordinate conversions. |   // Test view to window coordinate conversions. | ||||||
|   point = CefPoint(0, 0); |   point = CefPoint(0, 0); | ||||||
| @@ -165,7 +257,7 @@ void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) { | |||||||
|   EXPECT_EQ(CefPoint(0, 0), point); |   EXPECT_EQ(CefPoint(0, 0), point); | ||||||
|   point = CefPoint(0, 0); |   point = CefPoint(0, 0); | ||||||
|   EXPECT_TRUE(view2->ConvertPointToWindow(point)); |   EXPECT_TRUE(view2->ConvertPointToWindow(point)); | ||||||
|   EXPECT_EQ(CefPoint(0, kWSize / 2), point); |   ExpectClosePoints(CefPoint(0, kWSize / 2), point, 1); | ||||||
|  |  | ||||||
|   // Test view from window coordinate conversions. |   // Test view from window coordinate conversions. | ||||||
|   point = CefPoint(0, 0); |   point = CefPoint(0, 0); | ||||||
| @@ -173,23 +265,23 @@ void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) { | |||||||
|   EXPECT_EQ(CefPoint(0, 0), point); |   EXPECT_EQ(CefPoint(0, 0), point); | ||||||
|   point = CefPoint(0, kWSize / 2); |   point = CefPoint(0, kWSize / 2); | ||||||
|   EXPECT_TRUE(view2->ConvertPointFromWindow(point)); |   EXPECT_TRUE(view2->ConvertPointFromWindow(point)); | ||||||
|   EXPECT_EQ(CefPoint(0, 0), point); |   ExpectClosePoints(CefPoint(0, 0), point, 1); | ||||||
|  |  | ||||||
|   // Test view to view coordinate conversions. |   // Test view to view coordinate conversions. | ||||||
|   point = CefPoint(0, 0); |   point = CefPoint(0, 0); | ||||||
|   EXPECT_TRUE(view1->ConvertPointToView(view2, point)); |   EXPECT_TRUE(view1->ConvertPointToView(view2, point)); | ||||||
|   EXPECT_EQ(CefPoint(0, -kWSize / 2), point); |   ExpectClosePoints(CefPoint(0, -kWSize / 2), point, 1); | ||||||
|   point = CefPoint(0, 0); |   point = CefPoint(0, 0); | ||||||
|   EXPECT_TRUE(view2->ConvertPointToView(view1, point)); |   EXPECT_TRUE(view2->ConvertPointToView(view1, point)); | ||||||
|   EXPECT_EQ(CefPoint(0, kWSize / 2), point); |   ExpectClosePoints(CefPoint(0, kWSize / 2), point, 1); | ||||||
|  |  | ||||||
|   // Test view from view coordinate conversions. |   // Test view from view coordinate conversions. | ||||||
|   point = CefPoint(0, -kWSize / 2); |   point = CefPoint(0, -kWSize / 2); | ||||||
|   EXPECT_TRUE(view1->ConvertPointFromView(view2, point)); |   EXPECT_TRUE(view1->ConvertPointFromView(view2, point)); | ||||||
|   EXPECT_EQ(CefPoint(0, 0), point); |   ExpectClosePoints(CefPoint(0, 0), point, 1); | ||||||
|   point = CefPoint(0, kWSize / 2); |   point = CefPoint(0, kWSize / 2); | ||||||
|   EXPECT_TRUE(view2->ConvertPointFromView(view1, point)); |   EXPECT_TRUE(view2->ConvertPointFromView(view1, point)); | ||||||
|   EXPECT_EQ(CefPoint(0, 0), point); |   ExpectClosePoints(CefPoint(0, 0), point, 1); | ||||||
|  |  | ||||||
|   CefRefPtr<CefDisplay> display = window->GetDisplay(); |   CefRefPtr<CefDisplay> display = window->GetDisplay(); | ||||||
|   EXPECT_TRUE(display.get()); |   EXPECT_TRUE(display.get()); | ||||||
| @@ -198,8 +290,8 @@ void RunWindowLayoutAndCoords(CefRefPtr<CefWindow> window) { | |||||||
|   point = CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y); |   point = CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y); | ||||||
|   display->ConvertPointToPixels(point); |   display->ConvertPointToPixels(point); | ||||||
|   display->ConvertPointFromPixels(point); |   display->ConvertPointFromPixels(point); | ||||||
|   EXPECT_EQ(CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y), |   ExpectClosePoints( | ||||||
|             point); |       CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y), point, 1); | ||||||
|  |  | ||||||
|   // We don't know what the pixel values will be, but they should be reversable. |   // We don't know what the pixel values will be, but they should be reversable. | ||||||
|   point = CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y); |   point = CefPoint(client_bounds_in_screen.x, client_bounds_in_screen.y); | ||||||
| @@ -278,10 +370,15 @@ void VerifyMinimize(CefRefPtr<CefWindow> window) { | |||||||
|   EXPECT_FALSE(window->IsMaximized()); |   EXPECT_FALSE(window->IsMaximized()); | ||||||
|   EXPECT_FALSE(window->IsFullscreen()); |   EXPECT_FALSE(window->IsFullscreen()); | ||||||
|  |  | ||||||
|  | #if defined(OS_WIN) | ||||||
|   // This result is a bit unexpected, but I guess the platform considers a |   // This result is a bit unexpected, but I guess the platform considers a | ||||||
|   // window to be visible even when it's minimized. |   // window to be visible even when it's minimized. | ||||||
|   EXPECT_TRUE(window->IsVisible()); |   EXPECT_TRUE(window->IsVisible()); | ||||||
|   EXPECT_TRUE(window->IsDrawn()); |   EXPECT_TRUE(window->IsDrawn()); | ||||||
|  | #else | ||||||
|  |   EXPECT_FALSE(window->IsVisible()); | ||||||
|  |   EXPECT_FALSE(window->IsDrawn()); | ||||||
|  | #endif | ||||||
|  |  | ||||||
|   window->Restore(); |   window->Restore(); | ||||||
|   CefPostDelayedTask(TID_UI, base::BindOnce(VerifyRestore, window), |   CefPostDelayedTask(TID_UI, base::BindOnce(VerifyRestore, window), | ||||||
| @@ -316,28 +413,26 @@ void WindowMinimizeFramelessImpl(CefRefPtr<CefWaitableEvent> event) { | |||||||
|   config->close_window = false; |   config->close_window = false; | ||||||
|   TestWindowDelegate::RunTest(event, std::move(config)); |   TestWindowDelegate::RunTest(event, std::move(config)); | ||||||
| } | } | ||||||
|  | void WindowFullscreenTransitionComplete(CefRefPtr<CefWindow> window, | ||||||
| void VerifyFullscreenExit(CefRefPtr<CefWindow> window) { |                                         size_t count) { | ||||||
|   EXPECT_FALSE(window->IsMinimized()); |   EXPECT_FALSE(window->IsMinimized()); | ||||||
|  |  | ||||||
|  | #if defined(OS_MAC) | ||||||
|  |   // On MacOS, IsMaximized() returns true when IsFullscreen() returns true. | ||||||
|  |   EXPECT_EQ(window->IsFullscreen(), window->IsMaximized()); | ||||||
|  | #else | ||||||
|   EXPECT_FALSE(window->IsMaximized()); |   EXPECT_FALSE(window->IsMaximized()); | ||||||
|   EXPECT_FALSE(window->IsFullscreen()); | #endif | ||||||
|   EXPECT_TRUE(window->IsVisible()); |  | ||||||
|   EXPECT_TRUE(window->IsDrawn()); |  | ||||||
|  |  | ||||||
|   // End the test by closing the Window. |   if (window->IsFullscreen()) { | ||||||
|   window->Close(); |     EXPECT_EQ(1U, count); | ||||||
| } |     window->SetFullscreen(false); | ||||||
|  |   } else { | ||||||
|  |     EXPECT_EQ(2U, count); | ||||||
|  |  | ||||||
| void VerifyFullscreen(CefRefPtr<CefWindow> window) { |     // End the test by closing the Window. | ||||||
|   EXPECT_FALSE(window->IsMinimized()); |     window->Close(); | ||||||
|   EXPECT_FALSE(window->IsMaximized()); |   } | ||||||
|   EXPECT_TRUE(window->IsFullscreen()); |  | ||||||
|   EXPECT_TRUE(window->IsVisible()); |  | ||||||
|   EXPECT_TRUE(window->IsDrawn()); |  | ||||||
|  |  | ||||||
|   window->SetFullscreen(false); |  | ||||||
|   CefPostDelayedTask(TID_UI, base::BindOnce(VerifyFullscreenExit, window), |  | ||||||
|                      kStateDelayMS); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void RunWindowFullscreen(CefRefPtr<CefWindow> window) { | void RunWindowFullscreen(CefRefPtr<CefWindow> window) { | ||||||
| @@ -350,13 +445,13 @@ void RunWindowFullscreen(CefRefPtr<CefWindow> window) { | |||||||
|   EXPECT_TRUE(window->IsDrawn()); |   EXPECT_TRUE(window->IsDrawn()); | ||||||
|  |  | ||||||
|   window->SetFullscreen(true); |   window->SetFullscreen(true); | ||||||
|   CefPostDelayedTask(TID_UI, base::BindOnce(VerifyFullscreen, window), |  | ||||||
|                      kStateDelayMS); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void WindowFullscreenImpl(CefRefPtr<CefWaitableEvent> event) { | void WindowFullscreenImpl(CefRefPtr<CefWaitableEvent> event) { | ||||||
|   auto config = std::make_unique<TestWindowDelegate::Config>(); |   auto config = std::make_unique<TestWindowDelegate::Config>(); | ||||||
|   config->on_window_created = base::BindOnce(RunWindowFullscreen); |   config->on_window_created = base::BindOnce(RunWindowFullscreen); | ||||||
|  |   config->on_window_fullscreen_transition_complete = | ||||||
|  |       base::BindRepeating(WindowFullscreenTransitionComplete); | ||||||
|   config->close_window = false; |   config->close_window = false; | ||||||
|   TestWindowDelegate::RunTest(event, std::move(config)); |   TestWindowDelegate::RunTest(event, std::move(config)); | ||||||
| } | } | ||||||
| @@ -364,6 +459,8 @@ void WindowFullscreenImpl(CefRefPtr<CefWaitableEvent> event) { | |||||||
| void WindowFullscreenFramelessImpl(CefRefPtr<CefWaitableEvent> event) { | void WindowFullscreenFramelessImpl(CefRefPtr<CefWaitableEvent> event) { | ||||||
|   auto config = std::make_unique<TestWindowDelegate::Config>(); |   auto config = std::make_unique<TestWindowDelegate::Config>(); | ||||||
|   config->on_window_created = base::BindOnce(RunWindowFullscreen); |   config->on_window_created = base::BindOnce(RunWindowFullscreen); | ||||||
|  |   config->on_window_fullscreen_transition_complete = | ||||||
|  |       base::BindRepeating(WindowFullscreenTransitionComplete); | ||||||
|   config->frameless = true; |   config->frameless = true; | ||||||
|   config->close_window = false; |   config->close_window = false; | ||||||
|   TestWindowDelegate::RunTest(event, std::move(config)); |   TestWindowDelegate::RunTest(event, std::move(config)); | ||||||
| @@ -505,6 +602,9 @@ void WindowAcceleratorImpl(CefRefPtr<CefWaitableEvent> event) { | |||||||
| WINDOW_TEST_ASYNC(WindowCreate) | WINDOW_TEST_ASYNC(WindowCreate) | ||||||
| WINDOW_TEST_ASYNC(WindowCreateFrameless) | WINDOW_TEST_ASYNC(WindowCreateFrameless) | ||||||
| WINDOW_TEST_ASYNC(WindowCreateWithOrigin) | WINDOW_TEST_ASYNC(WindowCreateWithOrigin) | ||||||
|  | WINDOW_TEST_ASYNC(WindowCreateMinimized) | ||||||
|  | WINDOW_TEST_ASYNC(WindowCreateMaximized) | ||||||
|  | WINDOW_TEST_ASYNC(WindowCreateFullscreen) | ||||||
| WINDOW_TEST_ASYNC(WindowShowHide) | WINDOW_TEST_ASYNC(WindowShowHide) | ||||||
| WINDOW_TEST_ASYNC(WindowShowHideFrameless) | WINDOW_TEST_ASYNC(WindowShowHideFrameless) | ||||||
| WINDOW_TEST_ASYNC(WindowLayoutAndCoords) | WINDOW_TEST_ASYNC(WindowLayoutAndCoords) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user