Gecko:Mouse Wheel Scrolling: Difference between revisions

Line 48: Line 48:
= DOM mouse wheel events and Default action =
= DOM mouse wheel events and Default action =


The specification of DOM Level 3 Events defines "wheel" event. We're working on this in [https://bugzilla.mozilla.org/show_bug.cgi?id=719320 bug 719320]. All web developers should handle only this event after it's fixed.
Starting Mozilla 17 (Firefox 17), Gecko supports DOM Level 3 Events "wheel". All web developers should handle only this event. You can see [https://developer.mozilla.org/en-US/docs/DOM/DOM_event_reference/wheel the detail of "wheel" event] and [https://developer.mozilla.org/en-US/docs/DOM/WheelEvent WheelEvent interface] in MDN.


And also, there are two legacy mouse wheel events which are non-standard. One is DOMMouseScroll event. This is typically fired when mouse wheel is turned one or more lines or pages. The other is MozMousePixelScroll. This event tells web applications how much pixels should be scrolled. It's typically fired after a DOMMouseScroll event, however, it may be fired before DOMMouseScroll event when native mouse wheel event causes less than one line or page on Windows.
And also, there are two legacy mouse wheel events which are non-standard. One is DOMMouseScroll event. This is typically fired when mouse wheel is turned one or more lines or pages. The other is MozMousePixelScroll. This event tells web applications how much pixels should be scrolled. It's always fired after a DOMMouseScroll event, however, it may be fired without DOMMouseScroll event when native mouse wheel event causes less than one line or page.


On Mac, native events tell Gecko how much lines should be scrolled first. After that, one or more native pixel scroll events may be fired for smooth scroll. Therefore, DOMMouseScroll event is fired first on Mac.
On Mac, native events tell Gecko how much lines should be scrolled first. After that, one or more native pixel scroll events may be fired for smooth scroll. widget/cocoa dispatches widget::WheelEvent with nsIDOMWheelEvent::DOM_DELTA_PIXEL if the mouse (or touchpad) tells Gecko how much pixels should be scrolled.  Otherwise, i.e., it tells Gecko only how much lines should be scrolled, it dispatches the event with nsIDOMWheelEvent::DOM_DELTA_LINE.


On Windows, native events tell Gecko how much lines or pages should be scrolled. If the scroll amount is not integer, Gecko dispatches a MozMousePixelScroll event first and stores the amount. When accumulated scroll amount becomes one or more, it dispatches DOMMouseScroll.
On Windows, native events tell Gecko how much lines or pages should be scrolled. So, widget/windows dispatches widget::WheelEvent with nsIDOMWheelEvent::DOM_DELTA_LINE or nsIDOMWheelEvent::DOM_DELTA_PAGE. And either the deltaX or deltaY values may be non-integer value.


On the other platforms, widget only dispatches DOMMouseScroll event and nsEventStateManager automatically dispatches MozMousePixelScroll event.
On the other platforms, widget dispatches widget::WheelEvent with nsIDOMWheelEvent::DOM_DELTA_LINE.


If neither DOMMouseScroll nor MozMousePixelScroll is consumed by peventDefault(), nsEventStateManager performs a default action. There are four default actions: scroll, going back or forward history, zoom in or out, and doing nothing.
If neither wheel, DOMMouseScroll nor MozMousePixelScroll is consumed by peventDefault(), nsEventStateManager performs a default action. There are four default actions: scroll, going back or forward history, zoom in or out, and doing nothing.


So, the contents can prevent scrolling. Then, mouse wheel transaction isn't updated.
So, the contents can prevent scrolling. Then, mouse wheel transaction isn't updated.
87

edits