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:
@@ -137,11 +137,18 @@ void RootWindowViews::Hide() {
|
||||
}
|
||||
}
|
||||
|
||||
void RootWindowViews::SetBounds(int x, int y, size_t width, size_t height) {
|
||||
void RootWindowViews::SetBounds(int x,
|
||||
int y,
|
||||
size_t width,
|
||||
size_t height,
|
||||
bool content_bounds) {
|
||||
// We always expect Window bounds with Views-hosted browsers.
|
||||
DCHECK(!content_bounds);
|
||||
|
||||
if (!CefCurrentlyOn(TID_UI)) {
|
||||
// Execute this method on the UI thread.
|
||||
CefPostTask(TID_UI, base::BindOnce(&RootWindowViews::SetBounds, this, x, y,
|
||||
width, height));
|
||||
width, height, content_bounds));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -151,6 +158,11 @@ void RootWindowViews::SetBounds(int x, int y, size_t width, size_t height) {
|
||||
}
|
||||
}
|
||||
|
||||
bool RootWindowViews::DefaultToContentBounds() const {
|
||||
// Views-hosted browsers always receive CefWindow bounds.
|
||||
return false;
|
||||
}
|
||||
|
||||
void RootWindowViews::Close(bool force) {
|
||||
if (!CefCurrentlyOn(TID_UI)) {
|
||||
// Execute this method on the UI thread.
|
||||
@@ -169,11 +181,11 @@ void RootWindowViews::SetDeviceScaleFactor(float device_scale_factor) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
float RootWindowViews::GetDeviceScaleFactor() const {
|
||||
std::optional<float> RootWindowViews::GetDeviceScaleFactor() const {
|
||||
REQUIRE_MAIN_THREAD();
|
||||
// Windowless rendering is not supported.
|
||||
NOTREACHED();
|
||||
return 0.0;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowser> RootWindowViews::GetBrowser() const {
|
||||
|
Reference in New Issue
Block a user