https://bugs.webkit.org/show_bug.cgi?id=79868
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Feb 2012 19:51:54 +0000 (19:51 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Feb 2012 19:51:54 +0000 (19:51 +0000)
Overlay scrollbars should respond to AppKit's NSEventPhaseMayBegin
-and corresponding-
<rdar://problem/10688637>

Reviewed by Anders Carlsson.

Scrollbars are currently drawn on the main thread even when scrolling happens
on the scrolling thread, so we have to call back to the main thread for the
time being to make the right drawing calls for NSEventPhaseMayBegin.
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::handleWheelEventPhase):
(WebCore):
* page/scrolling/ScrollingCoordinator.h:
(ScrollingCoordinator):
* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::handleWheelEventPhase):
(WebCore):
* page/scrolling/ScrollingTree.h:
* page/scrolling/mac/ScrollingTreeNodeMac.mm:
(WebCore::ScrollingTreeNodeMac::handleWheelEvent):
* platform/ScrollAnimator.h:
(WebCore::ScrollAnimator::handleWheelEventPhase):
(ScrollAnimator):

Call into AppKit on NSEventPhaseMayBegin.
* platform/mac/ScrollAnimatorMac.h:
(ScrollAnimatorMac):
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::mayBeginScrollGesture):
(WebCore):
(WebCore::ScrollAnimatorMac::handleWheelEventPhase):
(WebCore::ScrollAnimatorMac::handleWheelEvent):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@109237 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/ScrollingCoordinator.cpp
Source/WebCore/page/scrolling/ScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingTree.cpp
Source/WebCore/page/scrolling/ScrollingTree.h
Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm
Source/WebCore/platform/ScrollAnimator.h
Source/WebCore/platform/mac/ScrollAnimatorMac.h
Source/WebCore/platform/mac/ScrollAnimatorMac.mm

index ad778f9..c341535 100644 (file)
@@ -1,3 +1,39 @@
+2012-02-28  Beth Dakin  <bdakin@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=79868
+        Overlay scrollbars should respond to AppKit's NSEventPhaseMayBegin
+        -and corresponding-
+        <rdar://problem/10688637>
+
+        Reviewed by Anders Carlsson.
+
+        Scrollbars are currently drawn on the main thread even when scrolling happens 
+        on the scrolling thread, so we have to call back to the main thread for the 
+        time being to make the right drawing calls for NSEventPhaseMayBegin.
+        * page/scrolling/ScrollingCoordinator.cpp:
+        (WebCore::ScrollingCoordinator::handleWheelEventPhase):
+        (WebCore):
+        * page/scrolling/ScrollingCoordinator.h:
+        (ScrollingCoordinator):
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::handleWheelEventPhase):
+        (WebCore):
+        * page/scrolling/ScrollingTree.h:
+        * page/scrolling/mac/ScrollingTreeNodeMac.mm:
+        (WebCore::ScrollingTreeNodeMac::handleWheelEvent):
+        * platform/ScrollAnimator.h:
+        (WebCore::ScrollAnimator::handleWheelEventPhase):
+        (ScrollAnimator):
+
+        Call into AppKit on NSEventPhaseMayBegin.
+        * platform/mac/ScrollAnimatorMac.h:
+        (ScrollAnimatorMac):
+        * platform/mac/ScrollAnimatorMac.mm:
+        (WebCore::ScrollAnimatorMac::mayBeginScrollGesture):
+        (WebCore):
+        (WebCore::ScrollAnimatorMac::handleWheelEventPhase):
+        (WebCore::ScrollAnimatorMac::handleWheelEvent):
+
 2012-02-28  Jer Noble  <jer.noble@apple.com>
 
         Full screen video volume slider has "progress bar"
index 5c14d99..6e07241 100644 (file)
@@ -279,6 +279,22 @@ void ScrollingCoordinator::updateMainFrameScrollPositionAndScrollLayerPosition(c
 #endif
 }
 
+#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
+void ScrollingCoordinator::handleWheelEventPhase(PlatformWheelEventPhase phase)
+{
+    ASSERT(isMainThread());
+
+    if (!m_page)
+        return;
+
+    FrameView* frameView = m_page->mainFrame()->view();
+    if (!frameView)
+        return;
+
+    frameView->scrollAnimator()->handleWheelEventPhase(phase);
+}
+#endif
+
 void ScrollingCoordinator::recomputeWheelEventHandlerCount()
 {
     unsigned wheelEventHandlerCount = 0;
index 00b289f..a2bd796 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "GraphicsLayer.h"
 #include "IntRect.h"
+#include "PlatformWheelEvent.h"
 #include "ScrollTypes.h"
 #include "Timer.h"
 #include <wtf/Forward.h>
@@ -46,7 +47,6 @@ namespace WebCore {
 class FrameView;
 class GraphicsLayer;
 class Page;
-class PlatformWheelEvent;
 class Region;
 class ScrollingCoordinatorPrivate;
 class ScrollingTreeState;
@@ -107,6 +107,11 @@ public:
     // Dispatched by the scrolling tree whenever the main frame scroll position changes and the scroll layer position needs to be updated as well.
     void updateMainFrameScrollPositionAndScrollLayerPosition(const IntPoint&);
 
+#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
+    // Dispatched by the scrolling tree during handleWheelEvent. This is required as long as scrollbars are painted on the main thread.
+    void handleWheelEventPhase(PlatformWheelEventPhase);
+#endif
+
 private:
     explicit ScrollingCoordinator(Page*);
 
index d58c62b..9d63fae 100644 (file)
@@ -174,6 +174,16 @@ void ScrollingTree::updateMainFrameScrollPositionAndScrollLayerPosition(const In
     callOnMainThread(bind(&ScrollingCoordinator::updateMainFrameScrollPositionAndScrollLayerPosition, m_scrollingCoordinator.get(), scrollPosition));
 }
 
+#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
+void ScrollingTree::handleWheelEventPhase(PlatformWheelEventPhase phase)
+{
+    if (!m_scrollingCoordinator)
+        return;
+
+    callOnMainThread(bind(&ScrollingCoordinator::handleWheelEventPhase, m_scrollingCoordinator.get(), phase));
+}
+#endif
+
 bool ScrollingTree::canGoBack()
 {
     MutexLocker lock(m_swipeStateMutex);
index 00d2584..65e2ad9 100644 (file)
@@ -28,6 +28,7 @@
 
 #if ENABLE(THREADED_SCROLLING)
 
+#include "PlatformWheelEvent.h"
 #include "Region.h"
 #include <wtf/Functional.h>
 #include <wtf/OwnPtr.h>
@@ -39,7 +40,6 @@
 namespace WebCore {
 
 class IntPoint;
-class PlatformWheelEvent;
 class ScrollingCoordinator;
 class ScrollingTreeNode;
 class ScrollingTreeState;
@@ -80,6 +80,10 @@ public:
     void updateMainFrameScrollPosition(const IntPoint& scrollPosition);
     void updateMainFrameScrollPositionAndScrollLayerPosition(const IntPoint& scrollPosition);
 
+#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
+    void handleWheelEventPhase(PlatformWheelEventPhase);
+#endif
+
     bool canGoBack();
     bool canGoForward();
 
index 966b2e1..016179e 100644 (file)
@@ -65,6 +65,7 @@ void ScrollingTreeNodeMac::update(ScrollingTreeState* state)
 void ScrollingTreeNodeMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
 {
     m_scrollElasticityController.handleWheelEvent(wheelEvent);
+    scrollingTree()->handleWheelEventPhase(wheelEvent.phase());
 }
 
 void ScrollingTreeNodeMac::setScrollPosition(const IntPoint& scrollPosition)
index 2b38944..91413e8 100644 (file)
 #ifndef ScrollAnimator_h
 #define ScrollAnimator_h
 
+#include "PlatformWheelEvent.h"
 #include "ScrollTypes.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
 
 class FloatPoint;
-class PlatformWheelEvent;
 class ScrollableArea;
 class Scrollbar;
 
@@ -65,6 +65,10 @@ public:
 
     virtual bool handleWheelEvent(const PlatformWheelEvent&);
 
+#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
+    virtual void handleWheelEventPhase(PlatformWheelEventPhase) { }
+#endif
+
     void setCurrentPosition(const FloatPoint&);
     FloatPoint currentPosition() const;
 
index 3720feb..4ea6904 100644 (file)
@@ -86,6 +86,8 @@ private:
     virtual bool handleWheelEvent(const PlatformWheelEvent&) OVERRIDE;
 #endif
 
+    virtual void handleWheelEventPhase(PlatformWheelEventPhase) OVERRIDE;
+
     virtual void cancelAnimations();
     virtual void setIsActive();
     
@@ -103,6 +105,7 @@ private:
     virtual void contentAreaDidHide() const;
     void didBeginScrollGesture() const;
     void didEndScrollGesture() const;
+    void mayBeginScrollGesture() const;
 
     virtual void didAddVerticalScrollbar(Scrollbar*);
     virtual void willRemoveVerticalScrollbar(Scrollbar*);
index 5bcc775..78b71b0 100644 (file)
@@ -779,6 +779,17 @@ void ScrollAnimatorMac::didEndScrollGesture() const
         [m_scrollbarPainterController.get() endScrollGesture];
 }
 
+void ScrollAnimatorMac::mayBeginScrollGesture() const
+{
+    if (!scrollableArea()->isOnActivePage())
+        return;
+    if (!isScrollbarOverlayAPIAvailable())
+        return;
+
+    [m_scrollbarPainterController.get() beginScrollGesture];
+    [m_scrollbarPainterController.get() contentAreaScrolled];
+}
+
 void ScrollAnimatorMac::didAddVerticalScrollbar(Scrollbar* scrollbar)
 {
     if (!isScrollbarOverlayAPIAvailable())
@@ -889,6 +900,16 @@ void ScrollAnimatorMac::cancelAnimations()
     }
 }
 
+void ScrollAnimatorMac::handleWheelEventPhase(PlatformWheelEventPhase phase)
+{
+    if (phase == PlatformWheelEventPhaseBegan)
+        didBeginScrollGesture();
+    else if (phase == PlatformWheelEventPhaseEnded || phase == PlatformWheelEventPhaseCancelled)
+        didEndScrollGesture();
+    else if (phase == PlatformWheelEventPhaseMayBegin)
+        mayBeginScrollGesture();
+}
+
 #if ENABLE(RUBBER_BANDING)
 bool ScrollAnimatorMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
 {
@@ -911,12 +932,8 @@ bool ScrollAnimatorMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
 
     bool didHandleEvent = m_scrollElasticityController.handleWheelEvent(wheelEvent);
 
-    if (didHandleEvent) {
-        if (wheelEvent.phase() == PlatformWheelEventPhaseBegan)
-            didBeginScrollGesture();
-        else if (wheelEvent.phase() == PlatformWheelEventPhaseEnded)
-            didEndScrollGesture();
-    }
+    if (didHandleEvent)
+        handleWheelEventPhase(wheelEvent.phase());
 
     return didHandleEvent;
 }