Bug 21413
Summary: | DOMWindow.cpp DOMWindow::moveTo offsets moves by 22 (menu bar height) | ||
---|---|---|---|
Product: | WebKit | Reporter: | Eric Simenel <esimenel> |
Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
Status: | UNCONFIRMED | ||
Severity: | Normal | CC: | ahmad.saleem792, ap, bfulgham, esimenel, rniwa, yevseytsev |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | Mac | ||
OS: | OS X 10.5 | ||
See Also: | https://bugs.webkit.org/show_bug.cgi?id=250800 |
Eric Simenel
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
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
Please ignore the second part of my previous comment, Firefox uses WebKit only on iOS
yevseytsev
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
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
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.