Changeset 106720 in webkit


Ignore:
Timestamp:
Feb 3, 2012 5:33:46 PM (12 years ago)
Author:
andersca@apple.com
Message:

The scrolling tree should be able to handle wheel events
https://bugs.webkit.org/show_bug.cgi?id=77794

Reviewed by Andreas Kling.

  • page/scrolling/ScrollingTree.cpp:

(WebCore::ScrollingTree::tryToHandleWheelEvent):
New function. Currently this always returns that it was able to handle the wheel event,
but this will change in the future.

(WebCore::ScrollingTree::handleWheelEvent):
Ask the root node to handle the wheel event.

  • page/scrolling/ScrollingTreeNode.h:

Add a handleWheelEvent pure virtual member function.

  • page/scrolling/mac/ScrollingTreeNodeMac.mm:

(WebCore::ScrollingTreeNodeMac::handleWheelEvent):
Call scrollBy for now. Eventually this should use a scroll elasticity controller to handle
things like rubber-banding.

(WebCore::ScrollingTreeNodeMac::scrollPosition):
(WebCore::ScrollingTreeNodeMac::setScrollPosition):
Add getters and setters for the scroll position.

(WebCore::ScrollingTreeNodeMac::scrollBy):
Update the scroll position given the offset.

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r106715 r106720  
     12012-02-03  Anders Carlsson  <andersca@apple.com>
     2
     3        The scrolling tree should be able to handle wheel events
     4        https://bugs.webkit.org/show_bug.cgi?id=77794
     5
     6        Reviewed by Andreas Kling.
     7
     8        * page/scrolling/ScrollingTree.cpp:
     9        (WebCore::ScrollingTree::tryToHandleWheelEvent):
     10        New function. Currently this always returns that it was able to handle the wheel event,
     11        but this will change in the future.
     12
     13        (WebCore::ScrollingTree::handleWheelEvent):
     14        Ask the root node to handle the wheel event.
     15
     16        * page/scrolling/ScrollingTreeNode.h:
     17        Add a handleWheelEvent pure virtual member function.
     18
     19        * page/scrolling/mac/ScrollingTreeNodeMac.mm:
     20        (WebCore::ScrollingTreeNodeMac::handleWheelEvent):
     21        Call scrollBy for now. Eventually this should use a scroll elasticity controller to handle
     22        things like rubber-banding.
     23
     24        (WebCore::ScrollingTreeNodeMac::scrollPosition):
     25        (WebCore::ScrollingTreeNodeMac::setScrollPosition):
     26        Add getters and setters for the scroll position.
     27
     28        (WebCore::ScrollingTreeNodeMac::scrollBy):
     29        Update the scroll position given the offset.
     30
    1312012-02-03  Ryosuke Niwa  <rniwa@webkit.org>
    232
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp

    r106696 r106720  
    2929#if ENABLE(THREADED_SCROLLING)
    3030
     31#include "PlatformWheelEvent.h"
    3132#include "ScrollingCoordinator.h"
    3233#include "ScrollingThread.h"
     
    5253}
    5354
     55bool ScrollingTree::tryToHandleWheelEvent(const PlatformWheelEvent& wheelEvent)
     56{
     57    // FIXME: Check for wheel event handlers.
     58    // FIXME: Check if we're over a subframe or overflow div.
     59
     60    ScrollingThread::dispatch(bind(&ScrollingTree::handleWheelEvent, this, wheelEvent));
     61    return true;
     62}
     63
     64void ScrollingTree::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
     65{
     66    ASSERT(ScrollingThread::isCurrentThread());
     67
     68    m_rootNode->handleWheelEvent(wheelEvent);
     69}
     70
    5471void ScrollingTree::invalidate()
    5572{
  • trunk/Source/WebCore/page/scrolling/ScrollingTree.h

    r106696 r106720  
    3737namespace WebCore {
    3838
     39class PlatformWheelEvent;
    3940class ScrollingCoordinator;
    4041class ScrollingTreeNode;
     
    4950    static PassRefPtr<ScrollingTree> create(ScrollingCoordinator*);
    5051    ~ScrollingTree();
     52
     53    // Can be called from any thread. Will try to handle the wheel event on the scrolling thread.
     54    // Returns true if the wheel event can be handled on the scrolling thread and false if the
     55    // event must be sent again to the WebCore event handler.
     56    bool tryToHandleWheelEvent(const PlatformWheelEvent&);
     57
     58    // Must be called from the scrolling thread. Handles the wheel event.
     59    void handleWheelEvent(const PlatformWheelEvent&);
    5160
    5261    void invalidate();
  • trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h

    r106711 r106720  
    3434namespace WebCore {
    3535
     36class PlatformWheelEvent;
    3637class ScrollingTree;
    3738class ScrollingTreeState;
     
    4344
    4445    virtual void update(ScrollingTreeState*);
     46    virtual void handleWheelEvent(const PlatformWheelEvent&) = 0;
    4547
    4648protected:
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.h

    r106711 r106720  
    4242private:
    4343    virtual void update(ScrollingTreeState*) OVERRIDE;
     44    virtual void handleWheelEvent(const PlatformWheelEvent&) OVERRIDE;
     45
     46    IntPoint scrollPosition() const;
     47    void setScrollPosition(const IntPoint&);
     48
     49    void scrollBy(const IntSize&);
    4450
    4551    RetainPtr<CALayer> m_scrollLayer;
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm

    r106711 r106720  
    2929#if ENABLE(THREADED_SCROLLING)
    3030
     31#include "PlatformWheelEvent.h"
    3132#include "ScrollingTreeState.h"
    3233
     
    5152}
    5253
     54void ScrollingTreeNodeMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
     55{
     56    // FXIME: This needs to handle rubberbanding.
     57    scrollBy(IntSize(-wheelEvent.deltaX(), -wheelEvent.deltaY()));
     58}
     59
     60IntPoint ScrollingTreeNodeMac::scrollPosition() const
     61{
     62    CGPoint scrollLayerPosition = m_scrollLayer.get().position;
     63    return IntPoint(-scrollLayerPosition.x, -scrollLayerPosition.y);
     64}
     65
     66void ScrollingTreeNodeMac::setScrollPosition(const IntPoint& position)
     67{
     68    m_scrollLayer.get().position = CGPointMake(-position.x(), -position.y());
     69}
     70
     71void ScrollingTreeNodeMac::scrollBy(const IntSize &offset)
     72{
     73    setScrollPosition(scrollPosition() + offset);
     74
     75    // FIXME: Tell the scrolling coordinator that our position changed.
     76}
     77
    5378} // namespace WebCore
    5479
Note: See TracChangeset for help on using the changeset viewer.