Gecko:Mouse Wheel Scrolling: Difference between revisions
(Creating new document) |
|||
| Line 21: | Line 21: | ||
= Mouse wheel transaction = | = Mouse wheel transaction = | ||
By above rules, users can scroll one scrollable frame smoothly. However, when two or more scrollable frames are nested, we need additional rules. | |||
For example, there is a page body which is scrollable and has a scrollable sub frame (e.g., listbox of select element with multiple attribute, div element with overflow property, iframe element). When an user is scrolling down the sub frame, it will be reached to the end of its content. However, some mouse wheel events which were fired after that will scroll the body unexpectedly. | |||
And there is another example, when the user is scrolling the page body, the sub frame may come under mouse cursor. Then, the sub frame intercepts the mouse wheel events unexpectedly. | |||
We can fix these problems by a simple idea. That is, all users may want to scroll only one scrollable frame at one time. So, we can assume that two or more mouse wheel events which are fired between short term should scroll only one scrollable frame. The frame must be the frame under cursor at the first mouse wheel event. | |||
Gecko manages this transaction by nsMouseWheelTransaction which is in [http://mxr.mozilla.org/mozilla-central/source/content/events/src/nsEventStateManager.cpp nsEventStateManager.cpp]. | |||
= DOM event vs. Scrolling = | = DOM event vs. Scrolling = | ||
= Issues = | = Issues = | ||
Revision as of 08:33, 26 January 2010
Overview
Gecko can have many scrollable frames at one time. This documents the detail of mouse wheel scrolling processing in Gecko.
Gecko honors mouse cursor position
Basically, turning mouse wheel scrolls a scrollable view under mouse cursor. This behavior was designed in bug 97283.
Note that on Windows, most mouse drivers honors keyboard focus rather than mouse cursor position. However, Internet Explorer and other web browsers honor the cursor position too. So, it's not a problem, probably.
Deciding a scrolling target from cursor position
There can be two or more scrollable frames at a point (i.e., under mouse cursor). Gecko decides one scrolling target by following rules:
- Finds a frame under mouse cursor.
- Checks whether the frame is scrollable to the direction by user operation.
- If the frame is scrollable, Gecko scrolls the frame.
- Otherwise, repeats the steps with its ancestor frames.
There is a special case. If gecko finds a drop down frame of a select element, it stops going up the frame hierarchy.
Mouse wheel transaction
By above rules, users can scroll one scrollable frame smoothly. However, when two or more scrollable frames are nested, we need additional rules.
For example, there is a page body which is scrollable and has a scrollable sub frame (e.g., listbox of select element with multiple attribute, div element with overflow property, iframe element). When an user is scrolling down the sub frame, it will be reached to the end of its content. However, some mouse wheel events which were fired after that will scroll the body unexpectedly.
And there is another example, when the user is scrolling the page body, the sub frame may come under mouse cursor. Then, the sub frame intercepts the mouse wheel events unexpectedly.
We can fix these problems by a simple idea. That is, all users may want to scroll only one scrollable frame at one time. So, we can assume that two or more mouse wheel events which are fired between short term should scroll only one scrollable frame. The frame must be the frame under cursor at the first mouse wheel event.
Gecko manages this transaction by nsMouseWheelTransaction which is in nsEventStateManager.cpp.