WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
UNCONFIRMED
21413
DOMWindow.cpp DOMWindow::moveTo offsets moves by 22 (menu bar height)
https://bugs.webkit.org/show_bug.cgi?id=21413
Summary
DOMWindow.cpp DOMWindow::moveTo offsets moves by 22 (menu bar height)
Eric Simenel
Reported
2008-10-06 15:09:08 PDT
Easy to reproduce: Using the following HTML code: <html> <script> function M(dx, dy) { window.moveTo(window.screenX+dx, window.screenY+dy); } </script> <body> <input type="button" value="move me" onclick="M(0, -50)"> </body> </html> Safari/Webkit windows move up 28 pixels, Firefox windows move up 50 pixels. Tentative fix: Instead of: FloatRect fr = page->chrome()->windowRect(); FloatRect sr = screenAvailableRect(page->mainFrame()->view()); fr.setLocation(sr.location()); FloatRect update = fr; update.move(x, y); We should have: FloatRect fr = page->chrome()->windowRect(); FloatRect sr = screenAvailableRect(page->mainFrame()->view()); x -= fr.x(); y -= fr.y(); FloatRect update = fr; update.move(x, y); That change seems to fix the problem.
Attachments
Add attachment
proposed patch, testcase, etc.
yevseytsev
Comment 1
2019-02-15 11:24:53 PST
Tried to reproduce a bug in Safari and Firefox using the code provided, but windows are not moving at all. As well Firefox is no longer uses WebKit, so I am not sure it is a bug nowadays.
yevseytsev
Comment 2
2019-02-15 13:40:23 PST
Please ignore the second part of my previous comment, Firefox uses WebKit only on iOS
yevseytsev
Comment 3
2019-02-22 10:48:24 PST
in webkit/Source/WebCore/page/DOMWindow.cpp file there is a code that prevents window geometry to be changed void DOMWindow::moveTo(float x, float y) const { if (!allowedToChangeWindowGeometry()) return; Page* page = m_frame->page(); FloatRect fr = page->chrome().windowRect(); FloatRect sr = screenAvailableRect(page->mainFrame().view()); fr.setLocation(sr.location()); FloatRect update = fr; update.move(x, y); page->chrome().setWindowRect(adjustWindowRect(*page, update)); }
Ahmad Saleem
Comment 4
2022-08-19 09:33:08 PDT
I am not able to reproduce anything from the test case in
Comment 0
and all browsers (Safari 15.6, Safari Technology Preview 151, Chrome Canary 106, Firefox Nightly 105) ignore the "Move Me" input and also don't show anything in console. Link -
https://jsfiddle.net/3gowr4c5/
The referencee code in
Comment 03
, is still present in slightly changed / refactor format:
https://github.com/WebKit/WebKit/blob/64f843f962fd4b62b95fb3c3c53127b6f526fbcd/Source/WebCore/page/DOMWindow.cpp#L1758
rniwa@webkit.org
- Is something still needed? Thanks!
Alexey Proskuryakov
Comment 5
2022-08-19 10:31:37 PDT
As documented in <
https://developer.mozilla.org/en-US/docs/Web/API/Window/moveTo
>, Firefox only performs a moveTo if the window was created by window.open(). Looking at allowedToChangeWindowGeometry(), WebKit appears to have a different policy, it blocks moveTo if invoked from a mouse event handler. It also needs to be the main frame, not a subframe. The test needs to be adjusted accordingly to verify if this is still an issue.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug