Title: [106720] trunk/Source/WebCore
- Revision
- 106720
- Author
- [email protected]
- Date
- 2012-02-03 17:33:46 -0800 (Fri, 03 Feb 2012)
Log 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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (106719 => 106720)
--- trunk/Source/WebCore/ChangeLog 2012-02-04 01:32:31 UTC (rev 106719)
+++ trunk/Source/WebCore/ChangeLog 2012-02-04 01:33:46 UTC (rev 106720)
@@ -1,3 +1,33 @@
+2012-02-03 Anders Carlsson <[email protected]>
+
+ 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.
+
2012-02-03 Ryosuke Niwa <[email protected]>
Crash in Node::dispatchSubtreeModifiedEvent
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (106719 => 106720)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2012-02-04 01:32:31 UTC (rev 106719)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp 2012-02-04 01:33:46 UTC (rev 106720)
@@ -28,6 +28,7 @@
#if ENABLE(THREADED_SCROLLING)
+#include "PlatformWheelEvent.h"
#include "ScrollingCoordinator.h"
#include "ScrollingThread.h"
#include "ScrollingTreeNode.h"
@@ -51,6 +52,22 @@
ASSERT(!m_scrollingCoordinator);
}
+bool ScrollingTree::tryToHandleWheelEvent(const PlatformWheelEvent& wheelEvent)
+{
+ // FIXME: Check for wheel event handlers.
+ // FIXME: Check if we're over a subframe or overflow div.
+
+ ScrollingThread::dispatch(bind(&ScrollingTree::handleWheelEvent, this, wheelEvent));
+ return true;
+}
+
+void ScrollingTree::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
+{
+ ASSERT(ScrollingThread::isCurrentThread());
+
+ m_rootNode->handleWheelEvent(wheelEvent);
+}
+
void ScrollingTree::invalidate()
{
// Invalidate is dispatched by the ScrollingCoordinator class on the ScrollingThread
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (106719 => 106720)
--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h 2012-02-04 01:32:31 UTC (rev 106719)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h 2012-02-04 01:33:46 UTC (rev 106720)
@@ -36,6 +36,7 @@
namespace WebCore {
+class PlatformWheelEvent;
class ScrollingCoordinator;
class ScrollingTreeNode;
class ScrollingTreeState;
@@ -49,6 +50,14 @@
static PassRefPtr<ScrollingTree> create(ScrollingCoordinator*);
~ScrollingTree();
+ // Can be called from any thread. Will try to handle the wheel event on the scrolling thread.
+ // Returns true if the wheel event can be handled on the scrolling thread and false if the
+ // event must be sent again to the WebCore event handler.
+ bool tryToHandleWheelEvent(const PlatformWheelEvent&);
+
+ // Must be called from the scrolling thread. Handles the wheel event.
+ void handleWheelEvent(const PlatformWheelEvent&);
+
void invalidate();
void commitNewTreeState(PassOwnPtr<ScrollingTreeState>);
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h (106719 => 106720)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h 2012-02-04 01:32:31 UTC (rev 106719)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h 2012-02-04 01:33:46 UTC (rev 106720)
@@ -33,6 +33,7 @@
namespace WebCore {
+class PlatformWheelEvent;
class ScrollingTree;
class ScrollingTreeState;
@@ -42,6 +43,7 @@
virtual ~ScrollingTreeNode();
virtual void update(ScrollingTreeState*);
+ virtual void handleWheelEvent(const PlatformWheelEvent&) = 0;
protected:
explicit ScrollingTreeNode(ScrollingTree*);
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.h (106719 => 106720)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.h 2012-02-04 01:32:31 UTC (rev 106719)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.h 2012-02-04 01:33:46 UTC (rev 106720)
@@ -41,7 +41,13 @@
private:
virtual void update(ScrollingTreeState*) OVERRIDE;
+ virtual void handleWheelEvent(const PlatformWheelEvent&) OVERRIDE;
+ IntPoint scrollPosition() const;
+ void setScrollPosition(const IntPoint&);
+
+ void scrollBy(const IntSize&);
+
RetainPtr<CALayer> m_scrollLayer;
};
Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm (106719 => 106720)
--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm 2012-02-04 01:32:31 UTC (rev 106719)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm 2012-02-04 01:33:46 UTC (rev 106720)
@@ -28,6 +28,7 @@
#if ENABLE(THREADED_SCROLLING)
+#include "PlatformWheelEvent.h"
#include "ScrollingTreeState.h"
namespace WebCore {
@@ -50,6 +51,30 @@
m_scrollLayer = state->platformScrollLayer();
}
+void ScrollingTreeNodeMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
+{
+ // FXIME: This needs to handle rubberbanding.
+ scrollBy(IntSize(-wheelEvent.deltaX(), -wheelEvent.deltaY()));
+}
+
+IntPoint ScrollingTreeNodeMac::scrollPosition() const
+{
+ CGPoint scrollLayerPosition = m_scrollLayer.get().position;
+ return IntPoint(-scrollLayerPosition.x, -scrollLayerPosition.y);
+}
+
+void ScrollingTreeNodeMac::setScrollPosition(const IntPoint& position)
+{
+ m_scrollLayer.get().position = CGPointMake(-position.x(), -position.y());
+}
+
+void ScrollingTreeNodeMac::scrollBy(const IntSize &offset)
+{
+ setScrollPosition(scrollPosition() + offset);
+
+ // FIXME: Tell the scrolling coordinator that our position changed.
+}
+
} // namespace WebCore
#endif // ENABLE(THREADED_SCROLLING)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes