2011-06-04 Sam Weinig <sam@webkit.org>
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Jun 2011 19:20:00 +0000 (19:20 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Jun 2011 19:20:00 +0000 (19:20 +0000)
        Reviewed by Anders Carlsson.

        WebKit2 needs to know when a scroll is happening due to the ScrollAnimator
        https://bugs.webkit.org/show_bug.cgi?id=62093

        Add additional ChromeClient functions to indicate the beginning and end of
        the various ScrollAnimator animations. Change existing notification that a
        rubber-band has completed for the main frame to be triggered for all frames.

        * page/ChromeClient.h:
        (WebCore::ChromeClient::didStartRubberBandForFrame):
        (WebCore::ChromeClient::didCompleteRubberBandForFrame):
        (WebCore::ChromeClient::didStartAnimatedScroll):
        (WebCore::ChromeClient::didCompleteAnimatedScroll):
        * page/FrameView.cpp:
        (WebCore::FrameView::didStartRubberBand):
        (WebCore::FrameView::didCompleteRubberBand):
        (WebCore::FrameView::didStartAnimatedScroll):
        (WebCore::FrameView::didCompleteAnimatedScroll):
        * page/FrameView.h:
        * platform/ScrollableArea.h:
        (WebCore::ScrollableArea::didStartRubberBand):
        (WebCore::ScrollableArea::didStartAnimatedScroll):
        (WebCore::ScrollableArea::didCompleteAnimatedScroll):
        * platform/mac/ScrollAnimatorMac.h:
        * platform/mac/ScrollAnimatorMac.mm:
        (-[ScrollAnimationHelperDelegate _immediateScrollToPoint:]):
        (WebCore::ScrollAnimatorMac::scroll):
        (WebCore::ScrollAnimatorMac::immediateScrollToPointForScrollAnimation):
        (WebCore::ScrollAnimatorMac::snapRubberBandTimerFired):
2011-06-04  Sam Weinig  <sam@webkit.org>

        Reviewed by Anders Carlsson.

        WebKit2 needs to know when a scroll is happening due to the ScrollAnimator
        https://bugs.webkit.org/show_bug.cgi?id=62093

        Stub out new ChromeClient functions regarding the start and end of ScrollAnimator
        animated scrolls, and update logic for rubber-band ending to check for main frame
        now that it is called for all frames.

        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
        (WebKit::WebChromeClient::didStartRubberBandForFrame):
        (WebKit::WebChromeClient::didCompleteRubberBandForFrame):
        (WebKit::WebChromeClient::didStartAnimatedScroll):
        (WebKit::WebChromeClient::didCompleteAnimatedScroll):
        * WebProcess/WebCoreSupport/WebChromeClient.h:

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

Source/WebCore/ChangeLog
Source/WebCore/page/ChromeClient.h
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/platform/ScrollableArea.h
Source/WebCore/platform/mac/ScrollAnimatorMac.h
Source/WebCore/platform/mac/ScrollAnimatorMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

index 690c41f..624a8fa 100644 (file)
@@ -1,3 +1,36 @@
+2011-06-04  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        WebKit2 needs to know when a scroll is happening due to the ScrollAnimator
+        https://bugs.webkit.org/show_bug.cgi?id=62093
+
+        Add additional ChromeClient functions to indicate the beginning and end of
+        the various ScrollAnimator animations. Change existing notification that a
+        rubber-band has completed for the main frame to be triggered for all frames.
+
+        * page/ChromeClient.h:
+        (WebCore::ChromeClient::didStartRubberBandForFrame):
+        (WebCore::ChromeClient::didCompleteRubberBandForFrame):
+        (WebCore::ChromeClient::didStartAnimatedScroll):
+        (WebCore::ChromeClient::didCompleteAnimatedScroll):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::didStartRubberBand):
+        (WebCore::FrameView::didCompleteRubberBand):
+        (WebCore::FrameView::didStartAnimatedScroll):
+        (WebCore::FrameView::didCompleteAnimatedScroll):
+        * page/FrameView.h:
+        * platform/ScrollableArea.h:
+        (WebCore::ScrollableArea::didStartRubberBand):
+        (WebCore::ScrollableArea::didStartAnimatedScroll):
+        (WebCore::ScrollableArea::didCompleteAnimatedScroll):
+        * platform/mac/ScrollAnimatorMac.h:
+        * platform/mac/ScrollAnimatorMac.mm:
+        (-[ScrollAnimationHelperDelegate _immediateScrollToPoint:]):
+        (WebCore::ScrollAnimatorMac::scroll):
+        (WebCore::ScrollAnimatorMac::immediateScrollToPointForScrollAnimation):
+        (WebCore::ScrollAnimatorMac::snapRubberBandTimerFired):
+
 2011-06-04  Martin Robinson  <mrobinson@igalia.com>
 
         Touch a file to try to fix the GTK+ build on the 32-bit bot.
index 1e4396b..3e1bf26 100644 (file)
@@ -311,7 +311,11 @@ namespace WebCore {
 
         virtual void postAccessibilityNotification(AccessibilityObject*, AXObjectCache::AXNotification) { }
 
-        virtual void didCompleteRubberBandForMainFrame(const IntSize&) const { }
+        virtual void didStartRubberBandForFrame(Frame*, const IntSize&) const { }
+        virtual void didCompleteRubberBandForFrame(Frame*, const IntSize&) const { }
+        virtual void didStartAnimatedScroll() const { }
+        virtual void didCompleteAnimatedScroll() const { }
+        
         virtual void notifyScrollerThumbIsVisibleInRect(const IntRect&) { }
 
         enum DialogType {
index daefd41..c06fb82 100644 (file)
@@ -2180,14 +2180,36 @@ IntRect FrameView::windowResizerRect() const
     return page->chrome()->windowResizerRect();
 }
 
+void FrameView::didStartRubberBand(const IntSize& initialOverhang) const
+{
+    Page* page = m_frame->page();
+    if (!page)
+        return;
+    return page->chrome()->client()->didCompleteRubberBandForFrame(m_frame.get(), initialOverhang);
+}
+
 void FrameView::didCompleteRubberBand(const IntSize& initialOverhang) const
 {
     Page* page = m_frame->page();
     if (!page)
         return;
-    if (page->mainFrame() != m_frame)
+    return page->chrome()->client()->didCompleteRubberBandForFrame(m_frame.get(), initialOverhang);
+}
+
+void FrameView::didStartAnimatedScroll() const
+{
+    Page* page = m_frame->page();
+    if (!page)
+        return;
+    return page->chrome()->client()->didStartAnimatedScroll();
+}
+
+void FrameView::didCompleteAnimatedScroll() const
+{
+    Page* page = m_frame->page();
+    if (!page)
         return;
-    return page->chrome()->client()->didCompleteRubberBandForMainFrame(initialOverhang);
+    return page->chrome()->client()->didCompleteAnimatedScroll();
 }
 
 void FrameView::scrollbarStyleChanged()
index 5b73950..2bad526 100644 (file)
@@ -323,7 +323,10 @@ private:
     virtual bool isActive() const;
     virtual void getTickmarks(Vector<IntRect>&) const;
     virtual void scrollTo(const IntSize&);
+    virtual void didStartRubberBand(const IntSize&) const;
     virtual void didCompleteRubberBand(const IntSize&) const;
+    virtual void didStartAnimatedScroll() const;
+    virtual void didCompleteAnimatedScroll() const;
     virtual void scrollbarStyleChanged();
     virtual void setVisibleScrollerThumbRect(const IntRect&);
 #if USE(ACCELERATED_COMPOSITING)
index 7b0f5ba..e919cee 100644 (file)
@@ -127,7 +127,12 @@ public:
     virtual IntSize contentsSize() const { ASSERT_NOT_REACHED(); return IntSize(); }
     virtual IntSize overhangAmount() const { ASSERT_NOT_REACHED(); return IntSize(); }
     virtual IntPoint currentMousePosition() const { return IntPoint(); }
+
+    virtual void didStartRubberBand(const IntSize&) const { ASSERT_NOT_REACHED(); }
     virtual void didCompleteRubberBand(const IntSize&) const { ASSERT_NOT_REACHED(); }
+    virtual void didStartAnimatedScroll() const { }
+    virtual void didCompleteAnimatedScroll() const { }
+    
     virtual bool shouldSuspendScrollAnimations() const { return true; }
     virtual void scrollbarStyleChanged() { }
     virtual void setVisibleScrollerThumbRect(const IntRect&) { }
index ff05e25..09fd333 100644 (file)
@@ -76,6 +76,8 @@ public:
     void immediateScrollByDeltaX(float deltaX);
     void immediateScrollByDeltaY(float deltaY);
 
+    void immediateScrollToPointForScrollAnimation(const FloatPoint& newPosition);
+
     void setIsDrawingIntoLayer(bool b) { m_drawingIntoLayer = b; }
     bool isDrawingIntoLayer() const { return m_drawingIntoLayer; }
 
index 605baf7..b822f28 100644 (file)
@@ -48,6 +48,7 @@ using namespace std;
 - (void)_stopRun;
 - (BOOL)_isAnimating;
 - (NSPoint)targetOrigin;
+- (CGFloat)_progress;
 @end
 
 @interface ScrollAnimationHelperDelegate : NSObject
@@ -97,7 +98,7 @@ static NSSize abs(NSSize size)
 {
     if (!_animator)
         return;
-    _animator->immediateScrollToPoint(newPosition);
+    _animator->immediateScrollToPointForScrollAnimation(newPosition);
 }
 
 - (NSPoint)_pixelAlignProposedScrollPosition:(NSPoint)newOrigin
@@ -506,8 +507,10 @@ bool ScrollAnimatorMac::scroll(ScrollbarOrientation orientation, ScrollGranulari
     if ([m_scrollAnimationHelper.get() _isAnimating]) {
         NSPoint targetOrigin = [m_scrollAnimationHelper.get() targetOrigin];
         newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, targetOrigin.y) : NSMakePoint(targetOrigin.x, newPos);
-    } else
+    } else {
         newPoint = orientation == HorizontalScrollbar ? NSMakePoint(newPos, m_currentPosY) : NSMakePoint(m_currentPosX, newPos);
+        m_scrollableArea->didStartAnimatedScroll();
+    }
 
     [m_scrollAnimationHelper.get() scrollToPoint:newPoint];
     return true;
@@ -580,6 +583,17 @@ void ScrollAnimatorMac::immediateScrollByDeltaY(float deltaY)
     notityPositionChanged();
 }
 
+void ScrollAnimatorMac::immediateScrollToPointForScrollAnimation(const FloatPoint& newPosition)
+{
+    ASSERT(m_scrollAnimationHelper);
+    CGFloat progress = [m_scrollAnimationHelper.get() _progress];
+    
+    immediateScrollToPoint(newPosition);
+
+    if (progress >= 1.0)
+        m_scrollableArea->didCompleteAnimatedScroll();
+}
+
 void ScrollAnimatorMac::notityPositionChanged()
 {
 #if USE(WK_SCROLLBAR_PAINTER)
@@ -1148,6 +1162,8 @@ void ScrollAnimatorMac::snapRubberBandTimerFired(Timer<ScrollAnimatorMac>*)
                 return;
             }
 
+            m_scrollableArea->didStartRubberBand(roundedIntSize(m_startStretch));
+            
             m_origOrigin = (m_scrollableArea->visibleContentRect().location() + m_scrollableArea->scrollOrigin()) - m_startStretch;
             m_origVelocity = m_momentumVelocity;
 
index ff8195a..f73203c 100644 (file)
@@ -1,3 +1,21 @@
+2011-06-04  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Anders Carlsson.
+
+        WebKit2 needs to know when a scroll is happening due to the ScrollAnimator
+        https://bugs.webkit.org/show_bug.cgi?id=62093
+
+        Stub out new ChromeClient functions regarding the start and end of ScrollAnimator
+        animated scrolls, and update logic for rubber-band ending to check for main frame
+        now that it is called for all frames.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::didStartRubberBandForFrame):
+        (WebKit::WebChromeClient::didCompleteRubberBandForFrame):
+        (WebKit::WebChromeClient::didStartAnimatedScroll):
+        (WebKit::WebChromeClient::didCompleteAnimatedScroll):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+
 2011-06-03  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Steve Falkenburg.
index 11d80c4..0d7ddff 100644 (file)
@@ -768,11 +768,25 @@ void WebChromeClient::dispatchViewportDataDidChange(const ViewportArguments& arg
     m_page->send(Messages::WebPageProxy::DidChangeViewportData(args));
 }
 
-void WebChromeClient::didCompleteRubberBandForMainFrame(const IntSize& initialOverhang) const
+void WebChromeClient::didStartRubberBandForFrame(Frame*, const IntSize&) const
 {
+}
+
+void WebChromeClient::didCompleteRubberBandForFrame(Frame* frame, const IntSize& initialOverhang) const
+{
+    if (frame != frame->page()->mainFrame())
+        return;
     m_page->send(Messages::WebPageProxy::DidCompleteRubberBandForMainFrame(initialOverhang));
 }
 
+void WebChromeClient::didStartAnimatedScroll() const
+{
+}
+
+void WebChromeClient::didCompleteAnimatedScroll() const
+{
+}
+    
 void WebChromeClient::notifyScrollerThumbIsVisibleInRect(const IntRect& scrollerThumb)
 {
     m_page->send(Messages::WebPageProxy::NotifyScrollerThumbIsVisibleInRect(scrollerThumb));
index 2079c44..2b67f74 100644 (file)
@@ -220,7 +220,11 @@ private:
     
     virtual void dispatchViewportDataDidChange(const WebCore::ViewportArguments&) const;
 
-    virtual void didCompleteRubberBandForMainFrame(const WebCore::IntSize&) const;
+    virtual void didStartRubberBandForFrame(WebCore::Frame*, const WebCore::IntSize&) const;
+    virtual void didCompleteRubberBandForFrame(WebCore::Frame*, const WebCore::IntSize&) const;
+    virtual void didStartAnimatedScroll() const;
+    virtual void didCompleteAnimatedScroll() const;
+
     virtual void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&);
     virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const;