Bug 21413 - DOMWindow.cpp DOMWindow::moveTo offsets moves by 22 (menu bar height)
Summary: DOMWindow.cpp DOMWindow::moveTo offsets moves by 22 (menu bar height)
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Macintosh OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-06 15:09 PDT by Eric Simenel
Modified: 2019-02-22 10:48 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Simenel 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.
Comment 1 yevseytsev 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.
Comment 2 yevseytsev 2019-02-15 13:40:23 PST
 Please ignore the second part of my previous comment, Firefox uses WebKit only on iOS
Comment 3 yevseytsev 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));
}