Title: [102284] branches/safari-534.53-branch/Source

Diff

Modified: branches/safari-534.53-branch/Source/WebCore/ChangeLog (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebCore/ChangeLog	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebCore/ChangeLog	2011-12-08 00:35:12 UTC (rev 102284)
@@ -1,5 +1,87 @@
 2011-12-07  Lucas Forschler  <lforsch...@apple.com>
 
+    Merge 99493
+
+    2011-11-07  Beth Dakin  <bda...@apple.com>
+
+            https://bugs.webkit.org/show_bug.cgi?id=71490
+            Support uiStateTransitionProgress for scrollbars
+            -and corresponding-
+            <rdar://problem/9849612>
+
+            Reviewed by Sam Weinig.
+
+            Step 1 of supporting uiStateTransitionProgress is knowing when the mouse has 
+            entered or exited a scrollbar. These changes to Scrollbar pass that information 
+            on to the ScrollAnimator. Also, Scrollbar::mouseUp() now takes a 
+            PlatformMouseEvent as a parameter. This is necessary because m_hoveredNode is not 
+            always up to date on a mouseUp, so mouseUp must hitTest the scrollbar to see if 
+            the mouse has exited the scrollbar.
+            * platform/Scrollbar.cpp:
+            (WebCore::Scrollbar::mouseMoved):
+            (WebCore::Scrollbar::mouseExited):
+            (WebCore::Scrollbar::mouseUp):
+            * platform/Scrollbar.h:
+
+            These changes are required now that Scrollbar::mouseUp() takes a parameter.
+            * WebCore.exp.in:
+            * page/EventHandler.cpp:
+            (WebCore::EventHandler::handleMouseDoubleClickEvent):
+            (WebCore::EventHandler::handleMouseReleaseEvent):
+            * platform/chromium/PopupListBox.cpp:
+            (WebCore::PopupListBox::handleMouseReleaseEvent):
+            * platform/win/PopupMenuWin.cpp:
+            (WebCore::PopupMenuWin::wndProc):
+
+            ScrollAnimator passes the information on to AppKit.
+            * platform/ScrollAnimator.h:
+            (WebCore::ScrollAnimator::mouseEnteredScrollbar):
+            (WebCore::ScrollAnimator::mouseExitedScrollbar):
+            * platform/mac/ScrollAnimatorMac.h:
+            (WebCore::ScrollAnimatorMac::mouseEnteredScrollbar):
+            (WebCore::ScrollAnimatorMac::mouseExitedScrollbar):
+
+            There are several new pieces of AppKit api we must call into.
+            * platform/mac/NSScrollerImpDetails.h:
+
+            This is a temporary function that is needed for the time being since there is new 
+            AppKit api required for this to work.
+            * platform/mac/ScrollAnimatorMac.mm:
+            (supportsUIStateTransitionProgress):
+
+            I refactored WebScrollbarPartAnimation so that it can handle the 
+            uiStateTransitionProgress animation as well as the alpha animations it already 
+            handled. This mostly involved re-naming things and making use of a new enum called 
+            FeatureToAnimate which keeps track of what the instance of 
+            WebScrollbarPartAnimation is animating.
+            (-[WebScrollbarPartAnimation initWithScrollbarPainter:animate:scrollAnimator:animateFrom:animateTo:duration:]):
+            (-[WebScrollbarPartAnimation setScrollbarPainter:]):
+            (-[WebScrollbarPartAnimation setStartValue:]):
+            (-[WebScrollbarPartAnimation setEndValue:]):
+            (-[WebScrollbarPartAnimation setCurrentProgress:]):
+
+            WebScrollbarPainterDelegate has two new animations, 
+            _verticalUIStateTransitionAnimation, and _horizontalUIStateTransitionAnimation. It 
+            also responds to a few new delegate calls.
+            (-[WebScrollbarPainterDelegate cancelAnimations]):
+
+            This is a new delegate call needed for uiStateTransitionProgress.
+            (-[WebScrollbarPainterDelegate mouseLocationInScrollerForScrollerImp:]):
+
+            I re-named setUpAnimation to setUpAlphaAnimation since it does a lot of things 
+            that are specific to the alpha animation and I chose not to re-use it for 
+            uiStateTransition.
+            (-[WebScrollbarPainterDelegate setUpAlphaAnimation:scrollerPainter:part:WebCore::animateAlphaTo:duration:]):
+            (-[WebScrollbarPainterDelegate scrollerImp:animateKnobAlphaTo:duration:]):
+            (-[WebScrollbarPainterDelegate scrollerImp:animateTrackAlphaTo:duration:]):
+
+            New delegate call for the uiStateTransition animation that sets up that animation 
+            and kicks it off.
+            (-[WebScrollbarPainterDelegate scrollerImp:animateUIStateTransitionWithDuration:]):
+            (-[WebScrollbarPainterDelegate scrollAnimatorDestroyed]):
+
+2011-12-07  Lucas Forschler  <lforsch...@apple.com>
+
     Merge 98892
 
     2011-10-31  Anders Carlsson  <ander...@apple.com>

Modified: branches/safari-534.53-branch/Source/WebCore/WebCore.exp.in (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebCore/WebCore.exp.in	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebCore/WebCore.exp.in	2011-12-08 00:35:12 UTC (rev 102284)
@@ -1038,11 +1038,11 @@
 __ZN7WebCore9PageGroup26setShouldTrackVisitedLinksEb
 __ZN7WebCore9PageGroup29removeUserStyleSheetFromWorldEPNS_15DOMWrapperWorldERKNS_4KURLE
 __ZN7WebCore9PageGroup30removeUserStyleSheetsFromWorldEPNS_15DOMWrapperWorldE
-__ZN7WebCore9Scrollbar7mouseUpEv
 __ZN7WebCore9PageGroup9pageGroupERKN3WTF6StringE
 __ZN7WebCore9Scrollbar13setProportionEii
 __ZN7WebCore9Scrollbar21createNativeScrollbarEPNS_14ScrollableAreaENS_20ScrollbarOrientationENS_20ScrollbarControlSizeE
 __ZN7WebCore9Scrollbar22maxOverlapBetweenPagesEv
+__ZN7WebCore9Scrollbar7mouseUpERKNS_18PlatformMouseEventE
 __ZN7WebCore9Scrollbar8setStepsEiii
 __ZN7WebCore9Scrollbar9mouseDownERKNS_18PlatformMouseEventE
 __ZN7WebCore9TimerBase4stopEv

Modified: branches/safari-534.53-branch/Source/WebCore/page/EventHandler.cpp (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebCore/page/EventHandler.cpp	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebCore/page/EventHandler.cpp	2011-12-08 00:35:12 UTC (rev 102284)
@@ -1501,7 +1501,7 @@
     bool swallowClickEvent = mouseEvent.button() != RightButton && targetNode(mev) == m_clickNode && dispatchMouseEvent(eventNames().clickEvent, targetNode(mev), true, m_clickCount, mouseEvent, true);
 
     if (m_lastScrollbarUnderMouse)
-        swallowMouseUpEvent = m_lastScrollbarUnderMouse->mouseUp();
+        swallowMouseUpEvent = m_lastScrollbarUnderMouse->mouseUp(mouseEvent);
 
     bool swallowMouseReleaseEvent = !swallowMouseUpEvent && handleMouseReleaseEvent(mev);
 
@@ -1700,7 +1700,7 @@
 
     if (m_lastScrollbarUnderMouse) {
         invalidateClick();
-        return m_lastScrollbarUnderMouse->mouseUp();
+        return m_lastScrollbarUnderMouse->mouseUp(mouseEvent);
     }
 
     HitTestRequest request(HitTestRequest::MouseUp);

Modified: branches/safari-534.53-branch/Source/WebCore/platform/ScrollAnimator.h (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebCore/platform/ScrollAnimator.h	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebCore/platform/ScrollAnimator.h	2011-12-08 00:35:12 UTC (rev 102284)
@@ -76,6 +76,8 @@
     virtual void mouseEnteredContentArea() const { }
     virtual void mouseExitedContentArea() const { }
     virtual void mouseMovedInContentArea() const { }
+    virtual void mouseEnteredScrollbar(Scrollbar*) const { }
+    virtual void mouseExitedScrollbar(Scrollbar*) const { }
     virtual void willStartLiveResize() { }
     virtual void contentsResized() const { }
     virtual void willEndLiveResize() { }

Modified: branches/safari-534.53-branch/Source/WebCore/platform/Scrollbar.cpp (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebCore/platform/Scrollbar.cpp	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebCore/platform/Scrollbar.cpp	2011-12-08 00:35:12 UTC (rev 102284)
@@ -343,7 +343,12 @@
     if (m_pressedPart != NoPart)
         m_pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y());
 
-    ScrollbarPart part = theme()->hitTest(this, evt);    
+    if (m_hoveredPart == NoPart) {
+        if (m_scrollableArea)
+            m_scrollableArea->scrollAnimator()->mouseEnteredScrollbar(this);
+    }
+
+    ScrollbarPart part = theme()->hitTest(this, evt);
     if (part != m_hoveredPart) {
         if (m_pressedPart != NoPart) {
             if (part == m_pressedPart) {
@@ -367,17 +372,27 @@
 
 bool Scrollbar::mouseExited()
 {
+    if (m_scrollableArea)
+        m_scrollableArea->scrollAnimator()->mouseExitedScrollbar(this);
     setHoveredPart(NoPart);
     return true;
 }
 
-bool Scrollbar::mouseUp()
+bool Scrollbar::mouseUp(const PlatformMouseEvent& mouseEvent)
 {
     setPressedPart(NoPart);
     m_pressedPos = 0;
     m_draggingDocument = false;
     stopTimerIfNeeded();
 
+    if (m_scrollableArea) {
+        // m_hoveredPart won't be updated until the next mouseMoved or mouseDown, so we have to hit test
+        // to really know if the mouse has exited the scrollbar on a mouseUp.
+        ScrollbarPart part = theme()->hitTest(this, mouseEvent);
+        if (part == NoPart)
+            m_scrollableArea->scrollAnimator()->mouseExitedScrollbar(this);
+    }
+
     if (parent() && parent()->isFrameView())
         static_cast<FrameView*>(parent())->frame()->eventHandler()->setMousePressed(false);
 

Modified: branches/safari-534.53-branch/Source/WebCore/platform/Scrollbar.h (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebCore/platform/Scrollbar.h	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebCore/platform/Scrollbar.h	2011-12-08 00:35:12 UTC (rev 102284)
@@ -97,7 +97,7 @@
     bool mouseExited();
     
     // Used by some platform scrollbars to know when they've been released from capture.
-    bool mouseUp();
+    bool mouseUp(const PlatformMouseEvent&);
 
     bool mouseDown(const PlatformMouseEvent&);
 

Modified: branches/safari-534.53-branch/Source/WebCore/platform/mac/NSScrollerImpDetails.h (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebCore/platform/mac/NSScrollerImpDetails.h	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebCore/platform/mac/NSScrollerImpDetails.h	2011-12-08 00:35:12 UTC (rev 102284)
@@ -41,6 +41,7 @@
 - (void)setKnobProportion:(CGFloat)proportion;
 - (void)setKnobStyle:(NSScrollerKnobStyle)knobStyle;
 - (void)setDelegate:(id)delegate;
+- (void)setUiStateTransitionProgress:(CGFloat)uiStateTransitionProgress;
 - (BOOL)isHorizontal;
 - (CGFloat)trackWidth;
 - (CGFloat)trackBoxWidth;
@@ -49,9 +50,12 @@
 - (CGFloat)knobOverlapEndInset;
 - (CGFloat)trackEndInset;
 - (CGFloat)knobEndInset;
+- (CGFloat)uiStateTransitionProgress;
 - (NSRect)rectForPart:(NSScrollerPart)partCode;
 - (void)drawKnobSlotInRect:(NSRect)slotRect highlight:(BOOL)flag alpha:(CGFloat)alpha;
 - (void)drawKnob;
+- (void)mouseEnteredScroller;
+- (void)mouseExitedScroller;
 @end
 
 @interface NSObject (ScrollbarPainterController)

Modified: branches/safari-534.53-branch/Source/WebCore/platform/mac/ScrollAnimatorMac.h (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebCore/platform/mac/ScrollAnimatorMac.h	2011-12-08 00:35:12 UTC (rev 102284)
@@ -113,6 +113,8 @@
     virtual void mouseEnteredContentArea() const;
     virtual void mouseExitedContentArea() const;
     virtual void mouseMovedInContentArea() const;
+    virtual void mouseEnteredScrollbar(Scrollbar*) const;
+    virtual void mouseExitedScrollbar(Scrollbar*) const;
     virtual void willStartLiveResize();
     virtual void contentsResized() const;
     virtual void willEndLiveResize();

Modified: branches/safari-534.53-branch/Source/WebCore/platform/mac/ScrollAnimatorMac.mm (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebCore/platform/mac/ScrollAnimatorMac.mm	2011-12-08 00:35:12 UTC (rev 102284)
@@ -45,6 +45,15 @@
 using namespace WebCore;
 using namespace std;
 
+#if USE(SCROLLBAR_PAINTER)
+static bool supportsUIStateTransitionProgress()
+{
+    // FIXME: This is temporary until all platforms that support ScrollbarPainter support this part of the API.
+    static bool globalSupportsUIStateTransitionProgress = [NSClassFromString(@"NSScrollerImp") instancesRespondToSelector:@selector(mouseEnteredScroller)];
+    return globalSupportsUIStateTransitionProgress;
+}
+#endif
+
 @interface NSObject (ScrollAnimationHelperDetails)
 - (id)initWithDelegate:(id)delegate;
 - (void)_stopRun;
@@ -243,34 +252,55 @@
 
 @end
 
+enum FeatureToAnimate {
+    ThumbAlpha,
+    TrackAlpha,
+    UIStateTransition
+};
+
 @interface ScrollbarPartAnimation : NSAnimation
 {
     RetainPtr<ScrollbarPainter> _scrollerPainter;
-    WebCore::ScrollbarPart _part;
-    WebCore::ScrollAnimatorMac* _animator;
-    CGFloat _initialAlpha;
-    CGFloat _newAlpha;
+    FeatureToAnimate _featureToAnimate;
+    ScrollAnimatorMac* _animator;
+    CGFloat _startValue;
+    CGFloat _endValue;
 }
-- (id)initWithScrollbarPainter:(ScrollbarPainter)scrollerPainter part:(WebCore::ScrollbarPart)part scrollAnimator:(WebCore::ScrollAnimatorMac*)scrollAnimator animateAlphaTo:(CGFloat)newAlpha duration:(NSTimeInterval)duration;
+- (id)initWithScrollbarPainter:(ScrollbarPainter)scrollerPainter animate:(FeatureToAnimate)featureToAnimate scrollAnimator:(ScrollAnimatorMac*)scrollAnimator animateFrom:(CGFloat)startValue animateTo:(CGFloat)endValue duration:(NSTimeInterval)duration;
 @end
 
 @implementation ScrollbarPartAnimation
 
-- (id)initWithScrollbarPainter:(ScrollbarPainter)scrollerPainter part:(WebCore::ScrollbarPart)part scrollAnimator:(WebCore::ScrollAnimatorMac*)scrollAnimator animateAlphaTo:(CGFloat)newAlpha duration:(NSTimeInterval)duration
+- (id)initWithScrollbarPainter:(ScrollbarPainter)scrollerPainter animate:(FeatureToAnimate)featureToAnimate scrollAnimator:(ScrollAnimatorMac*)scrollAnimator animateFrom:(CGFloat)startValue animateTo:(CGFloat)endValue duration:(NSTimeInterval)duration
 {
     self = [super initWithDuration:duration animationCurve:NSAnimationEaseInOut];
     if (!self)
         return nil;
     
     _scrollerPainter = scrollerPainter;
-    _part = part;
+    _featureToAnimate = featureToAnimate;
     _animator = scrollAnimator;
-    _initialAlpha = _part == WebCore::ThumbPart ? [_scrollerPainter.get() knobAlpha] : [_scrollerPainter.get() trackAlpha];
-    _newAlpha = newAlpha;
+    _startValue = startValue;
+    _endValue = endValue;
     
     return self;    
 }
 
+- (void)setScrollbarPainter:(ScrollbarPainter)scrollerPainter
+{
+    _scrollerPainter = scrollerPainter;
+}
+
+- (void)setStartValue:(CGFloat)startValue
+{
+    _startValue = startValue;
+}
+
+- (void)setEndValue:(CGFloat)endValue
+{
+    _endValue = endValue;
+}
+
 - (void)setCurrentProgress:(NSAnimationProgress)progress
 {
     [super setCurrentProgress:progress];
@@ -278,22 +308,29 @@
     if (!_animator)
         return;
 
-    CGFloat currentAlpha;
-    if (_initialAlpha > _newAlpha)
-        currentAlpha = 1 - progress;
+    CGFloat currentValue;
+    if (_startValue > _endValue)
+        currentValue = 1 - progress;
     else
-        currentAlpha = progress;
-    
-    if (_part == WebCore::ThumbPart)
-        [_scrollerPainter.get() setKnobAlpha:currentAlpha];
-    else
-        [_scrollerPainter.get() setTrackAlpha:currentAlpha];
+        currentValue = progress;
 
+    switch (_featureToAnimate) {
+    case ThumbAlpha:
+        [_scrollerPainter.get() setKnobAlpha:currentValue];
+        break;
+    case TrackAlpha:
+        [_scrollerPainter.get() setTrackAlpha:currentValue];
+        break;
+    case UIStateTransition:
+        [_scrollerPainter.get() setUiStateTransitionProgress:currentValue];
+        break;
+    }
+
     // Invalidate the scrollbars so that they paint the animation
-    if (WebCore::Scrollbar* verticalScrollbar = _animator->scrollableArea()->verticalScrollbar())
-        verticalScrollbar->invalidateRect(WebCore::IntRect(0, 0, verticalScrollbar->width(), verticalScrollbar->height()));
-    if (WebCore::Scrollbar* horizontalScrollbar = _animator->scrollableArea()->horizontalScrollbar())
-        horizontalScrollbar->invalidateRect(WebCore::IntRect(0, 0, horizontalScrollbar->width(), horizontalScrollbar->height()));
+    if (Scrollbar* verticalScrollbar = _animator->scrollableArea()->verticalScrollbar())
+        verticalScrollbar->invalidate();
+    if (Scrollbar* horizontalScrollbar = _animator->scrollableArea()->horizontalScrollbar())
+        horizontalScrollbar->invalidate();
 }
 
 - (void)scrollAnimatorDestroyed
@@ -315,6 +352,9 @@
 
     RetainPtr<ScrollbarPartAnimation> _verticalTrackAnimation;
     RetainPtr<ScrollbarPartAnimation> _horizontalTrackAnimation;
+
+    RetainPtr<ScrollbarPartAnimation> _verticalUIStateTransitionAnimation;
+    RetainPtr<ScrollbarPartAnimation> _horizontalUIStateTransitionAnimation;
 }
 - (id)initWithScrollAnimator:(WebCore::ScrollAnimatorMac*)scrollAnimator;
 - (void)cancelAnimations;
@@ -339,6 +379,8 @@
     [_horizontalKnobAnimation.get() stopAnimation];
     [_verticalTrackAnimation.get() stopAnimation];
     [_horizontalTrackAnimation.get() stopAnimation];
+    [_verticalUIStateTransitionAnimation.get() stopAnimation];
+    [_horizontalUIStateTransitionAnimation.get() stopAnimation];
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
@@ -364,8 +406,26 @@
     return dummyLayer;
 }
 
-- (void)setUpAnimation:(RetainPtr<ScrollbarPartAnimation>&)scrollbarPartAnimation scrollerPainter:(ScrollbarPainter)scrollerPainter part:(WebCore::ScrollbarPart)part animateAlphaTo:(CGFloat)newAlpha duration:(NSTimeInterval)duration
+- (NSPoint)mouseLocationInScrollerForScrollerImp:(id)scrollerImp
 {
+    if (!_animator)
+        return NSZeroPoint;
+
+    ScrollbarPainter scrollerPainter = (ScrollbarPainter)scrollerImp;
+    Scrollbar* scrollbar;
+    if ([scrollerPainter isHorizontal])
+        scrollbar = _animator->scrollableArea()->horizontalScrollbar();
+    else 
+        scrollbar = _animator->scrollableArea()->verticalScrollbar();
+
+    if (!scrollbar)
+        return NSZeroPoint;
+
+    return scrollbar->convertFromContainingView(_animator->scrollableArea()->currentMousePosition());
+}
+
+- (void)setUpAlphaAnimation:(RetainPtr<ScrollbarPartAnimation>&)scrollbarPartAnimation scrollerPainter:(ScrollbarPainter)scrollerPainter part:(WebCore::ScrollbarPart)part animateAlphaTo:(CGFloat)newAlpha duration:(NSTimeInterval)duration
+{
     // If the user has scrolled the page, then the scrollbars must be animated here. 
     // This overrides the early returns.
     bool mustAnimate = _animator->haveScrolledSincePageLoad();
@@ -398,9 +458,10 @@
     [NSAnimationContext beginGrouping];
     [[NSAnimationContext currentContext] setDuration:duration];
     scrollbarPartAnimation.adoptNS([[ScrollbarPartAnimation alloc] initWithScrollbarPainter:scrollerPainter 
-                                                                    part:part
-                                                                    scrollAnimator:_animator 
-                                                                    animateAlphaTo:newAlpha 
+                                                                    animate:part == ThumbPart ? ThumbAlpha : TrackAlpha
+                                                                    scrollAnimator:_animator
+                                                                    animateFrom:part == ThumbPart ? [scrollerPainter knobAlpha] : [scrollerPainter trackAlpha]
+                                                                    animateTo:newAlpha 
                                                                     duration:duration]);
     [scrollbarPartAnimation.get() setAnimationBlockingMode:NSAnimationNonblocking];
     [scrollbarPartAnimation.get() startAnimation];
@@ -414,9 +475,9 @@
 
     ScrollbarPainter scrollerPainter = (ScrollbarPainter)scrollerImp;
     if ([scrollerImp isHorizontal])
-        [self setUpAnimation:_horizontalKnobAnimation scrollerPainter:scrollerPainter part:WebCore::ThumbPart animateAlphaTo:newKnobAlpha duration:duration];
+        [self setUpAlphaAnimation:_horizontalKnobAnimation scrollerPainter:scrollerPainter part:WebCore::ThumbPart animateAlphaTo:newKnobAlpha duration:duration];
     else
-        [self setUpAnimation:_verticalKnobAnimation scrollerPainter:scrollerPainter part:WebCore::ThumbPart animateAlphaTo:newKnobAlpha duration:duration];
+        [self setUpAlphaAnimation:_verticalKnobAnimation scrollerPainter:scrollerPainter part:WebCore::ThumbPart animateAlphaTo:newKnobAlpha duration:duration];
 }
 
 - (void)scrollerImp:(id)scrollerImp animateTrackAlphaTo:(CGFloat)newTrackAlpha duration:(NSTimeInterval)duration
@@ -426,11 +487,46 @@
 
     ScrollbarPainter scrollerPainter = (ScrollbarPainter)scrollerImp;
     if ([scrollerImp isHorizontal])
-        [self setUpAnimation:_horizontalTrackAnimation scrollerPainter:scrollerPainter part:WebCore::BackTrackPart animateAlphaTo:newTrackAlpha duration:duration];
+        [self setUpAlphaAnimation:_horizontalTrackAnimation scrollerPainter:scrollerPainter part:WebCore::BackTrackPart animateAlphaTo:newTrackAlpha duration:duration];
     else
-        [self setUpAnimation:_verticalTrackAnimation scrollerPainter:scrollerPainter part:WebCore::BackTrackPart animateAlphaTo:newTrackAlpha duration:duration];
+        [self setUpAlphaAnimation:_verticalTrackAnimation scrollerPainter:scrollerPainter part:WebCore::BackTrackPart animateAlphaTo:newTrackAlpha duration:duration];
 }
 
+- (void)scrollerImp:(id)scrollerImp animateUIStateTransitionWithDuration:(NSTimeInterval)duration
+{
+    if (!_animator)
+        return;
+
+    if (!supportsUIStateTransitionProgress())
+        return;
+
+    ScrollbarPainter scrollerPainter = (ScrollbarPainter)scrollerImp;
+    RetainPtr<ScrollbarPartAnimation> scrollbarPartAnimation = [scrollerPainter isHorizontal] ? _horizontalUIStateTransitionAnimation : _verticalUIStateTransitionAnimation;
+
+    // UIStateTransition always animates to 1. In case an animation is in progress this avoids a hard transition.
+    [scrollerPainter setUiStateTransitionProgress:1 - [scrollerPainter uiStateTransitionProgress]];
+
+    [NSAnimationContext beginGrouping];
+    [[NSAnimationContext currentContext] setDuration:duration];
+    if (!scrollbarPartAnimation) {
+        scrollbarPartAnimation.adoptNS([[ScrollbarPartAnimation alloc] initWithScrollbarPainter:scrollerPainter 
+                                                                    animate:UIStateTransition
+                                                                    scrollAnimator:_animator
+                                                                    animateFrom:[scrollerPainter uiStateTransitionProgress]
+                                                                    animateTo:1.0 
+                                                                    duration:duration]);
+        [scrollbarPartAnimation.get() setAnimationBlockingMode:NSAnimationNonblocking];
+    } else {
+        // If we don't need to initialize the animation, just reset the values in case they have changed.
+        [scrollbarPartAnimation.get() setScrollbarPainter:scrollerPainter];
+        [scrollbarPartAnimation.get() setStartValue:[scrollerPainter uiStateTransitionProgress]];
+        [scrollbarPartAnimation.get() setEndValue:1.0];
+        [scrollbarPartAnimation.get() setDuration:duration];
+    }
+    [scrollbarPartAnimation.get() startAnimation];
+    [NSAnimationContext endGrouping];
+}
+
 - (void)scrollerImp:(id)scrollerImp overlayScrollerStateChangedTo:(NSUInteger)newOverlayScrollerState
 {
     UNUSED_PARAM(scrollerImp);
@@ -445,6 +541,8 @@
     [_horizontalKnobAnimation.get() scrollAnimatorDestroyed];
     [_verticalTrackAnimation.get() scrollAnimatorDestroyed];
     [_horizontalTrackAnimation.get() scrollAnimatorDestroyed];
+    [_verticalUIStateTransitionAnimation.get() scrollAnimatorDestroyed];
+    [_horizontalUIStateTransitionAnimation.get() scrollAnimatorDestroyed];
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
@@ -655,6 +753,38 @@
 #endif
 }
 
+void ScrollAnimatorMac::mouseEnteredScrollbar(Scrollbar* scrollbar) const
+{
+    if (!scrollableArea()->isOnActivePage())
+        return;
+#if USE(SCROLLBAR_PAINTER)
+    if (!supportsUIStateTransitionProgress())
+        return;
+    if (ScrollbarThemeMac* theme = static_cast<WebCore::ScrollbarThemeMac*>(WebCore::ScrollbarTheme::nativeTheme())) {
+        ScrollbarPainter painter = theme->painterForScrollbar(scrollbar);
+        [painter mouseEnteredScroller];
+    }
+#else
+    UNUSED_PARAM(scrollbar);
+#endif
+}
+
+void ScrollAnimatorMac::mouseExitedScrollbar(Scrollbar* scrollbar) const
+{
+    if (!scrollableArea()->isOnActivePage())
+        return;
+#if USE(SCROLLBAR_PAINTER)
+    if (!supportsUIStateTransitionProgress())
+        return;
+    if (ScrollbarThemeMac* theme = static_cast<WebCore::ScrollbarThemeMac*>(WebCore::ScrollbarTheme::nativeTheme())) {
+        ScrollbarPainter painter = theme->painterForScrollbar(scrollbar);
+        [painter mouseExitedScroller];
+    }
+#else
+    UNUSED_PARAM(scrollbar);
+#endif
+}
+
 void ScrollAnimatorMac::willStartLiveResize()
 {
     if (!scrollableArea()->isOnActivePage()) 

Modified: branches/safari-534.53-branch/Source/WebCore/platform/win/PopupMenuWin.cpp (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebCore/platform/win/PopupMenuWin.cpp	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebCore/platform/win/PopupMenuWin.cpp	2011-12-08 00:35:12 UTC (rev 102284)
@@ -963,7 +963,7 @@
                     // Put the point into coordinates relative to the scroll bar
                     mousePoint.move(-scrollBarRect.x(), -scrollBarRect.y());
                     PlatformMouseEvent event(hWnd, message, wParam, MAKELPARAM(mousePoint.x(), mousePoint.y()));
-                    scrollbar()->mouseUp();
+                    scrollbar()->mouseUp(event);
                     // FIXME: This is a hack to work around Scrollbar not invalidating correctly when it doesn't have a parent widget
                     RECT r = scrollBarRect;
                     ::InvalidateRect(popupHandle(), &r, TRUE);

Modified: branches/safari-534.53-branch/Source/WebKit/chromium/ChangeLog (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebKit/chromium/ChangeLog	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebKit/chromium/ChangeLog	2011-12-08 00:35:12 UTC (rev 102284)
@@ -1,3 +1,20 @@
+2011-12-07  Lucas Forschler  <lforsch...@apple.com>
+
+    Merge 99493
+
+    2011-11-07  Beth Dakin  <bda...@apple.com>
+
+            https://bugs.webkit.org/show_bug.cgi?id=71490
+            Support uiStateTransitionProgress for scrollbars
+            -and corresponding-
+            <rdar://problem/9849612>
+
+            Reviewed by Sam Weinig.
+
+            Scrollbar::mouseUp() now takes a PlatformMouseEvent as a parameter.
+            * src/WebScrollbarImpl.cpp:
+            (WebKit::WebScrollbarImpl::onMouseUp):
+
 2011-11-16  Lucas Forschler  <lforsch...@apple.com>
 
     Merge 93303 

Modified: branches/safari-534.53-branch/Source/WebKit/chromium/src/WebScrollbarImpl.cpp (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebKit/chromium/src/WebScrollbarImpl.cpp	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebKit/chromium/src/WebScrollbarImpl.cpp	2011-12-08 00:35:12 UTC (rev 102284)
@@ -166,10 +166,11 @@
 
 bool WebScrollbarImpl::onMouseUp(const WebInputEvent& event)
 {
+    WebMouseEvent mouseup = *static_cast<const WebMouseEvent*>(&event);
     if (m_scrollbar->pressedPart() == NoPart)
         return false;
 
-    return m_scrollbar->mouseUp();
+    return m_scrollbar->mouseUp(PlatformMouseEventBuilder(m_scrollbar.get(), mouseup));
 }
 
 bool WebScrollbarImpl::onMouseMove(const WebInputEvent& event)

Modified: branches/safari-534.53-branch/Source/WebKit/win/ChangeLog (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebKit/win/ChangeLog	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebKit/win/ChangeLog	2011-12-08 00:35:12 UTC (rev 102284)
@@ -1,3 +1,20 @@
+2011-12-07  Lucas Forschler  <lforsch...@apple.com>
+
+    Merge 99493
+
+    2011-11-07  Beth Dakin  <bda...@apple.com>
+
+            https://bugs.webkit.org/show_bug.cgi?id=71490
+            Support uiStateTransitionProgress for scrollbars
+            -and corresponding-
+            <rdar://problem/9849612>
+
+            Reviewed by Sam Weinig.
+
+            Scrollbar::mouseUp() now takes a PlatformMouseEvent as a parameter.
+            * WebScrollBar.cpp:
+            (WebScrollBar::handleMouseEvent):
+
 2011-11-16  Lucas Forschler  <lforsch...@apple.com>
 
     Merge 93303

Modified: branches/safari-534.53-branch/Source/WebKit/win/WebScrollBar.cpp (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebKit/win/WebScrollBar.cpp	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebKit/win/WebScrollBar.cpp	2011-12-08 00:35:12 UTC (rev 102284)
@@ -230,7 +230,7 @@
             m_scrollBar->mouseDown(mouseEvent);
             break;
         case WM_LBUTTONUP:
-            m_scrollBar->mouseUp();
+            m_scrollBar->mouseUp(mouseEvent);
             break;
         case WM_MOUSEMOVE:
             m_scrollBar->mouseMoved(mouseEvent);

Modified: branches/safari-534.53-branch/Source/WebKit2/ChangeLog (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebKit2/ChangeLog	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebKit2/ChangeLog	2011-12-08 00:35:12 UTC (rev 102284)
@@ -1,5 +1,24 @@
 2011-12-07  Lucas Forschler  <lforsch...@apple.com>
 
+    Merge 99493
+
+    2011-11-07  Beth Dakin  <bda...@apple.com>
+
+            https://bugs.webkit.org/show_bug.cgi?id=71490
+            Support uiStateTransitionProgress for scrollbars
+            -and corresponding-
+            <rdar://problem/9849612>
+
+            Reviewed by Sam Weinig.
+
+            Scrollbar::mouseUp() now takes a PlatformMouseEvent as a parameter.
+            * UIProcess/win/WebPopupMenuProxyWin.cpp:
+            (WebKit::WebPopupMenuProxyWin::onLButtonUp):
+            * WebProcess/Plugins/PDF/BuiltInPDFView.cpp:
+            (WebKit::BuiltInPDFView::handleMouseEvent):
+
+2011-12-07  Lucas Forschler  <lforsch...@apple.com>
+
     Merge 99090
 
     2011-11-02  Anders Carlsson  <ander...@apple.com>

Modified: branches/safari-534.53-branch/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp	2011-12-08 00:35:12 UTC (rev 102284)
@@ -705,7 +705,7 @@
             // Put the point into coordinates relative to the scroll bar
             mousePoint.move(-scrollBarRect.x(), -scrollBarRect.y());
             PlatformMouseEvent event(hWnd, message, wParam, MAKELPARAM(mousePoint.x(), mousePoint.y()));
-            scrollbar()->mouseUp();
+            scrollbar()->mouseUp(event);
             // FIXME: This is a hack to work around Scrollbar not invalidating correctly when it doesn't have a parent widget
             RECT r = scrollBarRect;
             ::InvalidateRect(m_popup, &r, TRUE);

Modified: branches/safari-534.53-branch/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp (102283 => 102284)


--- branches/safari-534.53-branch/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp	2011-12-08 00:32:51 UTC (rev 102283)
+++ branches/safari-534.53-branch/Source/WebKit2/WebProcess/Plugins/PDF/BuiltInPDFView.cpp	2011-12-08 00:35:12 UTC (rev 102284)
@@ -479,12 +479,14 @@
         // When support for PDF forms is added, we'll need to actually focus the plug-in when clicking in a form.
         break;
     }
-    case WebEvent::MouseUp:
+    case WebEvent::MouseUp: {
+        PlatformMouseEvent platformEvent = platform(event);
         if (m_horizontalScrollbar)
-            m_horizontalScrollbar->mouseUp();
+            m_horizontalScrollbar->mouseUp(platformEvent);
         if (m_verticalScrollbar)
-            m_verticalScrollbar->mouseUp();
+            m_verticalScrollbar->mouseUp(platformEvent);
         break;
+    }
     default:
         break;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to