Closed Bug 1446832 Opened 8 years ago Closed 8 years ago

Hover state still set on element during mouseleave event.

Categories

(Core :: DOM: Events, defect)

59 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox61 --- fixed

People

(Reporter: gfiore, Assigned: emilio)

References

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36 Steps to reproduce: I can reproduce the error consistently by following these steps: 1) Create an HTML element and give it an id (let's say it's id is 'elem1'). 2) Create a Javascript "mouseleave" event listener on that HTML element and corresponding function to be executed. In that function check which element(s) in the DOM has the :hover property (using any of the many ways to select elements with :hover). Also check which element(s) the cursor is currently over using document.elementFromPoint(event.clientX, event.clientY). Actual results: When the event is triggered and the above corresponding function is executed, the :hover selector returns that 'elem1' (and only 'elem1') is currently the element hovered over. However, document.elementFromPoint() returns that the element currently under the cursor is NOT 'elem1' - it is whatever element is next to (or behind) 'elem1'. Expected results: When a 'mouseleave' event is triggered for an element (in this case 'elem1') the cursor is no longer over that element and thus the element should no longer be selectable with :hover. Instead, the element that the cursor is currently over should be selectable with :hover. This is the behavior demonstrated by Chrome, Safari, Opera, etc.
Could you attach a test-case, using the "Attach file" link in bugzilla? It'd be much easier to see and debug. Thanks!
Flags: needinfo?(gfiore)
(I suspect we're just updating the hover state after dispatching the element or something like that...)
Attached file test-case.
Well, I just got curious myself, though it's late in Europe... :P Should never print "element", but it does.
Flags: needinfo?(gfiore)
Summary: Hover property still set on element after cursor has already left. → Hover state still set on element during mouseleave event.
Status: UNCONFIRMED → NEW
Component: DOM: CSS Object Model → DOM: Events
Ever confirmed: true
Attached file test.html
This is the simple test case I used.
The test case I used shows effectively the same behavior as yours it looks like. Thanks for recategorizing - wasn't sure if this should land in CSS Object or Events.
So, the relevant code is here: https://searchfox.org/mozilla-central/rev/3abf6fa7e2a6d9a7bfb88796141b0f012e68c2db/dom/events/EventStateManager.cpp#4351 Note how we NotifyMouseOut (which triggers the mouseleave event), _then_ set the hover state on the new node (unsetting it later), _then_ dispatch mouseenter on the new one. It may just be a matter of reordering those...
Are you interested in fixing this by any chance? Happy to mentor if so, though probably someone more familiar with the events code may be a more suitable reviewer :). It may be a matter of writing that patch as suggested in comment 6 and write an automated test (which can be a bit harder, you need to synthesize events). You could probably use: https://searchfox.org/mozilla-central/rev/3abf6fa7e2a6d9a7bfb88796141b0f012e68c2db/layout/style/test/test_hover_quirk.html#71 as a guide. Otherwise I can try to fix it myself I guess :)
Flags: needinfo?(gfiore)
I would be interested in fixing it, but I'm extremely busy right now and won't be able to look at it for another few days. If you (or anyone else) want to fix it in the meantime please feel free to.
Flags: needinfo?(gfiore)
(In reply to Gawan Fiore from comment #9) > I would be interested in fixing it, but I'm extremely busy right now and > won't be able to look at it for another few days. If you (or anyone else) > want to fix it in the meantime please feel free to. Ok, will do, thanks! If you want any other bug to fix or something once you have more time feel free to reach out to me either over email or IRC :)
Assignee: nobody → emilio
Attachment #8960163 - Flags: review?(bugs)
Comment on attachment 8960163 [details] Bug 1446832: Update hover state before firing mouseleave, to match other browsers. r=smaug Olli Pettay [:smaug] has approved the revision. https://phabricator.services.mozilla.com/D772
Attachment #8960163 - Flags: review+
Pushed by ecoal95@gmail.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/62fbfdc5ac11 Update hover state before firing mouseleave, to match other browsers. r=smaug
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
See Also: → 2062197
Duplicate of this bug: 1360335
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: