layerX/layerY wrong when mouse is over scrollbar

Bug #136985 reported by Klaus Reimer
2
Affects Status Importance Assigned to Milestone
Mozilla Firefox
New
Unknown
firefox (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Binary package hint: firefox

When you have a DIV with scrollbars (overflow:scroll or overflow:auto) and connect a mouse handler like "onmousemove" to the div then event.layerX must contain the X mouse position relative to the upper left corner of the DIV. But this doesn't work in Firefox when the mouse is over the scrollbar. Firefox "wraps" the mouse position so it begins with X=0 at the left edge of the scrollbar. This is bad because in this way Javascript cannot determine if the mouse is over the scrollbar or if the mouse is on the left side of the DIV. Here is a demo:

http://www.ailis.de/~k/permdata/20070903/scrollbar.html

Move the mouse over the div and then move it to the right over the scrollbar and watch the displayed X coordinate wrapping from 186 to 1. Other browsers behave correctly. Tested it in IE, Safari, Konqueror and Opera. In my opinion the mouse events should not fire at all when the mouse pointer is over the scrollbar but my opinion is not important. So I think this should be fixed so Firefox behaves like all other browsers and don't "wrap" the mouse position.

I also tested the current Firefox Nightly Build and the problem is still present there.

ProblemType: Bug
Architecture: i386
Date: Mon Sep 3 13:26:05 2007
DistroRelease: Ubuntu 7.04
Package: firefox 2.0.0.6+1-0ubuntu1
PackageArchitecture: i386
SourcePackage: firefox
Uname: Linux vincent 2.6.20-16-generic #2 SMP Fri Aug 31 00:55:27 UTC 2007 i686 GNU/Linux

Revision history for this message
Klaus Reimer (kay) wrote :
Revision history for this message
In , Klaus Reimer (kay) wrote :

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a9pre) Gecko/2007092404 Minefield/3.0a9pre
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a9pre) Gecko/2007092404 Minefield/3.0a9pre

When you have a DIV with scrollbars (overflow:scroll or overflow:auto) and connect a mouse handler like "onmousemove" to the div then event.layerX must contain the X mouse position relative to the upper left corner of the DIV. But this doesn't work in Firefox when the mouse is over the scrollbar. Firefox "wraps" the mouse position so it begins with X=0 at the left edge of the scrollbar. This is bad because in this way Javascript cannot determine if the mouse is over the scrollbar or if the mouse is on the left side of the DIV. Here is a demo:

http://www.ailis.de/~k/permdata/20070903/scrollbar.html

Move the mouse over the div and then move it to the right over the scrollbar and watch the displayed X coordinate wrapping from 186 to 1. Other browsers behave correctly. Tested it in IE, Safari, Konqueror and Opera. In my opinion the mouse events should not fire at all when the mouse pointer is over the scrollbar but my opinion is not important. So I think this should be fixed so Firefox behaves like all other browsers and don't "wrap" the mouse position.

This problem occurs in current nightly build and current stable version on Linux and Windows.

Reproducible: Always

Steps to Reproduce:
1. Open
http://www.ailis.de/~k/permdata/20070903/scrollbar.html
2. Move mouse cursor over scrollbar
3. Notice the wrong mouse position
Actual Results:
Mouse position which can be retrieved with layerX/layerY is wrong. X and Y should be somewhere between 180 and 200 but they are between 0 and 20.

Expected Results:
X and Y position between 180 and 200 when mouse cursor is over scrollbar

Revision history for this message
John Vivirito (gnomefreak) wrote :

Thank you for your bug report. Can you please file this bug on Mozilla's upstream bug tracker and drop the link in the bug please.

Changed in firefox:
assignee: nobody → mozilla-bugs
status: New → Incomplete
Changed in firefox:
status: Unknown → New
Revision history for this message
Alexander Sack (asac) wrote :

can someone else confirm this issue?

Revision history for this message
In , Klaus Reimer (kay) wrote :

By the way: This bug is still present in Firefox 3 Beta. Maybe this is a good time to finally fix it?

Revision history for this message
John Vivirito (gnomefreak) wrote :

Thank you for taking the time to file this bug report with us. Closing due to age. If this is still a problem in 3.0.7 please reopen this bug.
Also please reopen with all new information on how to reproduce this bug by giving us step by step instructions.
We also need what happens what is expected to happen.
To reopen the bug report you can click on the current status, under the Status column, and change the Status back to "New". Thanks again!

No upstream confirmation

Changed in firefox (Ubuntu):
assignee: mozilla-bugs → nobody
status: Incomplete → Invalid
Revision history for this message
In , Tyler Downer (tyler-downer) wrote :

Does this still happen in firefox 3.6.6 or later in a fresh profile?

Revision history for this message
In , Klaus Reimer (kay) wrote :

Yes, still happens in Firefox 3.6.6 with a fresh profile. The bug demo page is still online so everyone can try it out easily. Just click the link and move the mouse cursor over the scrollbars of the DIV and see the mouse position which is then not relative to the top/left corner of the DIV but instead relative to the top/left corner of the scrollbar.

I tried it now in Chrome, too: Works perfectly. Just to clarify: I don't know if there is any spec how a browser should work in this situation. So I don't know if this can be called a "bug". But the fact is that ALL browsers EXCEPT Firefox works the same. The mouse-position is always relative to the top/left corner, doesn't matter if mouse cursor is over the div, the scrollbars or the small square between the scrollbars. Firefox is the only browser which has a different opinion how mouse coordinates should be calculated.

Changed in firefox:
importance: Unknown → Medium
Revision history for this message
In , agamemnus (agamemnus) wrote :

This bug persists, lol. :\

Revision history for this message
In , Nic-t (nic-t) wrote :

This bug is still present in Firefox 20, and
http://www.ailis.de/~k/permdata/20070903/scrollbar.html
If you change the boder width, and put the mouse cursor on border-left and padding-left, the x will both be 0.

Changed in firefox:
status: New → Unknown
Changed in firefox:
status: Unknown → New
Changed in firefox:
importance: Medium → Unknown
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.