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:
@@ -22,48 +22,7 @@ NSWindow* GetWindow(CefRefPtr<CefBrowser> browser) {
|
||||
|
||||
} // namespace
|
||||
|
||||
WindowTestRunnerMac::WindowTestRunnerMac() {}
|
||||
|
||||
void WindowTestRunnerMac::SetPos(CefRefPtr<CefBrowser> browser,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
REQUIRE_MAIN_THREAD();
|
||||
|
||||
NSWindow* window = GetWindow(browser);
|
||||
|
||||
// Make sure the window isn't minimized or maximized.
|
||||
if ([window isMiniaturized]) {
|
||||
[window deminiaturize:nil];
|
||||
} else if ([window isZoomed]) {
|
||||
[window performZoom:nil];
|
||||
}
|
||||
|
||||
// Retrieve information for the display that contains the window.
|
||||
NSScreen* screen = [window screen];
|
||||
if (screen == nil) {
|
||||
screen = [NSScreen mainScreen];
|
||||
}
|
||||
NSRect frame = [screen frame];
|
||||
NSRect visibleFrame = [screen visibleFrame];
|
||||
|
||||
// Make sure the window is inside the display.
|
||||
CefRect display_rect(
|
||||
visibleFrame.origin.x,
|
||||
frame.size.height - visibleFrame.size.height - visibleFrame.origin.y,
|
||||
visibleFrame.size.width, visibleFrame.size.height);
|
||||
CefRect window_rect(x, y, width, height);
|
||||
ModifyBounds(display_rect, window_rect);
|
||||
|
||||
NSRect newRect;
|
||||
newRect.origin.x = window_rect.x;
|
||||
newRect.origin.y = frame.size.height - window_rect.height - window_rect.y;
|
||||
newRect.size.width = window_rect.width;
|
||||
newRect.size.height = window_rect.height;
|
||||
[window setFrame:newRect display:YES];
|
||||
}
|
||||
WindowTestRunnerMac::WindowTestRunnerMac() = default;
|
||||
|
||||
void WindowTestRunnerMac::Minimize(CefRefPtr<CefBrowser> browser) {
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
Reference in New Issue
Block a user