Core Implementation Details:
This is the basic principle:
- A new class called “cc::ScrollbarController” manages the state and behavior related to translating Mouse events into GestureScrolls.
- When a kMouseDown arrives at InputHandlerProxy::RouteToTypeSpecificHandler, it gets passed to the ScrollbarController to determine if this event will cause scrollbar manipulation.
- The ScrollbarController returns enough data to the InputHandlerProxy to inject gesture events to the CompositorThreadEventQueue (CTEQ). For example, in the case of a mouse down, a GestureScrollBegin(GSB) and a GestureScrollUpdate(GSU) are added to the CTEQ.
- Depending on the action, there can be more synthetic GSUs that get added to the CTEQ. (For eg: thumb drags).
- The WebInputEvent::kMouseUp is responsible for cleaning up the scroll state.
- GestureScrollBegin gets dispatched first. This sets up the scroll_node and other state necessary to begin scrolling in LayerTreeHostImpl::ScrollBegin. This is as usual for all gesture based scrolls.
- GestureScrollUpdate(s) get handled next. Scroll deltas get applied to the node that was set up during GestureScrollBegin. Depending on the type of scroll, this may lead to an animated scroll (eg: LayerTreeHostImpl::ScrollAnimated for autoscroll/mouse clicks) or a regular scroll. (eg: LayerTreeHostImpl::ScrollBy for thumb drags)
- Finally, the GestureScrollEnd is dispatched and it clears the scrolling state (like the CurrentlyScrollingNode) and calls SetNeedsCommitOnImplThread().