mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Support JavaScript window.moveTo/By() and resizeTo/By() (fixes #698)
Adds new CefDisplayHandler::OnContentsBoundsChange and CefDisplayHandler::GetRootWindowScreenRect callbacks. cefclient: Implement the above callbacks and call CefBrowserHost::NotifyScreenInfoChanged when the root window bounds change. cefclient: osr: Use real screen bounds by default. Pass `--fake-screen-bounds` for the old default behavior. Load https://tests/window in cefclient for additional implementation details and usage examples.
This commit is contained in:
@@ -20,7 +20,8 @@ namespace client {
|
||||
class BrowserWindow : public ClientHandler::Delegate {
|
||||
public:
|
||||
// This interface is implemented by the owner of the BrowserWindow. The
|
||||
// methods of this class will be called on the main thread.
|
||||
// methods of this class will be called on the main thread unless otherwise
|
||||
// indicated.
|
||||
class Delegate {
|
||||
public:
|
||||
// Returns true if the window should use Alloy style. Safe to call on any
|
||||
@@ -48,6 +49,9 @@ class BrowserWindow : public ClientHandler::Delegate {
|
||||
// Auto-resize contents.
|
||||
virtual void OnAutoResize(const CefSize& new_size) = 0;
|
||||
|
||||
// Set contents bounds.
|
||||
virtual void OnContentsBounds(const CefRect& new_bounds) = 0;
|
||||
|
||||
// Set the loading state.
|
||||
virtual void OnSetLoadingState(bool isLoading,
|
||||
bool canGoBack,
|
||||
@@ -57,6 +61,9 @@ class BrowserWindow : public ClientHandler::Delegate {
|
||||
virtual void OnSetDraggableRegions(
|
||||
const std::vector<CefDraggableRegion>& regions) = 0;
|
||||
|
||||
// Called on the UI thread to retrieve root window bounds.
|
||||
virtual bool GetRootWindowScreenRect(CefRect& rect) { return false; }
|
||||
|
||||
protected:
|
||||
virtual ~Delegate() = default;
|
||||
};
|
||||
@@ -132,13 +139,15 @@ class BrowserWindow : public ClientHandler::Delegate {
|
||||
void OnSetTitle(const std::string& title) override;
|
||||
void OnSetFullscreen(bool fullscreen) override;
|
||||
void OnAutoResize(const CefSize& new_size) override;
|
||||
void OnContentsBounds(const CefRect& new_bounds) override;
|
||||
bool GetRootWindowScreenRect(CefRect& rect) override;
|
||||
void OnSetLoadingState(bool isLoading,
|
||||
bool canGoBack,
|
||||
bool canGoForward) override;
|
||||
void OnSetDraggableRegions(
|
||||
const std::vector<CefDraggableRegion>& regions) override;
|
||||
|
||||
Delegate* delegate_;
|
||||
Delegate* const delegate_;
|
||||
CefRefPtr<CefBrowser> browser_;
|
||||
CefRefPtr<ClientHandler> client_handler_;
|
||||
bool is_closing_ = false;
|
||||
|
Reference in New Issue
Block a user