Find indicators do not bounce
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Oct 2010 01:44:58 +0000 (01:44 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Oct 2010 01:44:58 +0000 (01:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=48490
<rdar://problem/8564276>

Reviewed by Sam Weinig.

WebKit2:

* UIProcess/API/mac/FindIndicatorWindow.h:
* UIProcess/API/mac/FindIndicatorWindow.mm:
(-[WebFindIndicatorWindowAnimation _initWithFindIndicatorWindow:WebKit::animationDuration:animationProgressCallback:WebKit::FindIndicatorWindow::animationDidEndCallback:WebKit::FindIndicatorWindow::]):
Add an animationDuration parameter.

(WebKit::FindIndicatorWindow::FindIndicatorWindow):
Initialize m_bounceAnimationContext.

(WebKit::FindIndicatorWindow::setFindIndicator):
Create a bounce animation and start it.

(WebKit::FindIndicatorWindow::closeWindow):
Stop the bounce animation and destroy the bounce animation context.

(WebKit::FindIndicatorWindow::startFadeOutTimerFired):
pass the fade out duration.

(WebKit::FindIndicatorWindow::bounceAnimationCallback):
Set the bounce animation progress.

(WebKit::FindIndicatorWindow::bounceAnimationDidEnd):
Destroy the bounce animation context.

WebKitLibraries:

Add bounce animation context functions.

* WebKitSystemInterface.h:
* libWebKitSystemInterfaceLeopard.a:
* libWebKitSystemInterfaceSnowLeopard.a:

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

WebKit2/ChangeLog
WebKit2/UIProcess/API/mac/FindIndicatorWindow.h
WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm
WebKitLibraries/ChangeLog
WebKitLibraries/WebKitSystemInterface.h
WebKitLibraries/libWebKitSystemInterfaceLeopard.a
WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a

index 89d3008..00f72e0 100644 (file)
@@ -1,3 +1,34 @@
+2010-10-27  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Find indicators do not bounce
+        https://bugs.webkit.org/show_bug.cgi?id=48490
+        <rdar://problem/8564276>
+
+        * UIProcess/API/mac/FindIndicatorWindow.h:
+        * UIProcess/API/mac/FindIndicatorWindow.mm:
+        (-[WebFindIndicatorWindowAnimation _initWithFindIndicatorWindow:WebKit::animationDuration:animationProgressCallback:WebKit::FindIndicatorWindow::animationDidEndCallback:WebKit::FindIndicatorWindow::]):
+        Add an animationDuration parameter.
+        
+        (WebKit::FindIndicatorWindow::FindIndicatorWindow):
+        Initialize m_bounceAnimationContext.
+
+        (WebKit::FindIndicatorWindow::setFindIndicator):
+        Create a bounce animation and start it.
+
+        (WebKit::FindIndicatorWindow::closeWindow):
+        Stop the bounce animation and destroy the bounce animation context.
+
+        (WebKit::FindIndicatorWindow::startFadeOutTimerFired):
+        pass the fade out duration.
+
+        (WebKit::FindIndicatorWindow::bounceAnimationCallback):
+        Set the bounce animation progress.
+
+        (WebKit::FindIndicatorWindow::bounceAnimationDidEnd):
+        Destroy the bounce animation context.
+
 2010-10-27  Kenneth Rohde Christiansen  <kenneth@webkit.org>
 
         Reviewed by Andreas Kling.
index 4ffcf79..e8889b6 100644 (file)
@@ -31,6 +31,7 @@
 #import <wtf/RefPtr.h>
 #import <wtf/RetainPtr.h>
 #import "RunLoop.h"
+#import "WebKitSystemInterface.h"
 
 @class WKView;
 @class WebFindIndicatorWindowAnimation;
@@ -57,10 +58,16 @@ private:
     void fadeOutAnimationCallback(double);
     void fadeOutAnimationDidEnd();
 
+    void bounceAnimationCallback(double);
+    void bounceAnimationDidEnd();
+
     WKView* m_wkView;
     RefPtr<FindIndicator> m_findIndicator;
     RetainPtr<NSWindow> m_findIndicatorWindow;
 
+    WKWindowBounceAnimationContextRef m_bounceAnimationContext;
+    RetainPtr<WebFindIndicatorWindowAnimation> m_bounceAnimation;
+
     RunLoop::Timer<FindIndicatorWindow> m_startFadeOutTimer;
     RetainPtr<WebFindIndicatorWindowAnimation> m_fadeOutAnimation;
 };
index 85fe9ed..5b93a9e 100644 (file)
@@ -28,8 +28,8 @@
 #include "FindIndicator.h"
 #include <WebCore/GraphicsContext.h>
 
-static const double pulseAnimationDuration = 0.12;
-static const double timeBeforeFadeStarts = pulseAnimationDuration + 0.2;
+static const double bounceAnimationDuration = 0.12;
+static const double timeBeforeFadeStarts = bounceAnimationDuration + 0.2;
 static const double fadeOutAnimationDuration = 0.3;
 
 using namespace WebCore;
@@ -72,17 +72,19 @@ using namespace WebCore;
 }
 
 - (id)_initWithFindIndicatorWindow:(WebKit::FindIndicatorWindow *)findIndicatorWindow 
-                 animationProgressCallback:(void (WebKit::FindIndicatorWindow::*)(double progress))animationProgressCallback
-                   animationDidEndCallback:(void (WebKit::FindIndicatorWindow::*)())animationDidEndCallback;
+                 animationDuration:(CFTimeInterval)duration
+         animationProgressCallback:(void (WebKit::FindIndicatorWindow::*)(double progress))animationProgressCallback
+           animationDidEndCallback:(void (WebKit::FindIndicatorWindow::*)())animationDidEndCallback;
 @end
 
 @implementation WebFindIndicatorWindowAnimation
 
 - (id)_initWithFindIndicatorWindow:(WebKit::FindIndicatorWindow *)findIndicatorWindow 
+                 animationDuration:(CFTimeInterval)animationDuration
          animationProgressCallback:(void (WebKit::FindIndicatorWindow::*)(double progress))animationProgressCallback
            animationDidEndCallback:(void (WebKit::FindIndicatorWindow::*)())animationDidEndCallback
 {
-    if ((self = [super initWithDuration:fadeOutAnimationDuration animationCurve:NSAnimationEaseInOut])) {
+    if ((self = [super initWithDuration:animationDuration animationCurve:NSAnimationEaseInOut])) {
         _findIndicatorWindow = findIndicatorWindow;
         _animationProgressCallback = animationProgressCallback;
         _animationDidEndCallback = animationDidEndCallback;
@@ -115,6 +117,7 @@ PassOwnPtr<FindIndicatorWindow> FindIndicatorWindow::create(WKView *wkView)
 
 FindIndicatorWindow::FindIndicatorWindow(WKView *wkView)
     : m_wkView(wkView)
+    , m_bounceAnimationContext(0)
     , m_startFadeOutTimer(RunLoop::main(), this, &FindIndicatorWindow::startFadeOutTimerFired)
 {
 }
@@ -158,6 +161,14 @@ void FindIndicatorWindow::setFindIndicator(PassRefPtr<FindIndicator> findIndicat
     [[m_wkView window] addChildWindow:m_findIndicatorWindow.get() ordered:NSWindowAbove];
     [m_findIndicatorWindow.get() setReleasedWhenClosed:NO];
 
+    // Start the bounce animation.
+    m_bounceAnimationContext = WKWindowBounceAnimationContextCreate(m_findIndicatorWindow.get());
+    m_bounceAnimation.adoptNS([[WebFindIndicatorWindowAnimation alloc] _initWithFindIndicatorWindow:this
+                                                                                  animationDuration:bounceAnimationDuration
+                                                                          animationProgressCallback:&FindIndicatorWindow::bounceAnimationCallback
+                                                                            animationDidEndCallback:&FindIndicatorWindow::bounceAnimationDidEnd]);
+    [m_bounceAnimation.get() startAnimation];
+
     if (fadeOut)
         m_startFadeOutTimer.startOneShot(timeBeforeFadeStarts);
 }
@@ -174,6 +185,14 @@ void FindIndicatorWindow::closeWindow()
         m_fadeOutAnimation = nullptr;
     }
 
+    if (m_bounceAnimation) {
+        [m_bounceAnimation.get() stopAnimation];
+        m_bounceAnimation = nullptr;
+    }
+
+    if (m_bounceAnimationContext)
+        WKWindowBounceAnimationContextDestroy(m_bounceAnimationContext);
+    
     [[m_findIndicatorWindow.get() parentWindow] removeChildWindow:m_findIndicatorWindow.get()];
     [m_findIndicatorWindow.get() close];
     m_findIndicatorWindow = nullptr;
@@ -183,7 +202,8 @@ void FindIndicatorWindow::startFadeOutTimerFired()
 {
     ASSERT(!m_fadeOutAnimation);
     
-    m_fadeOutAnimation.adoptNS([[WebFindIndicatorWindowAnimation alloc] _initWithFindIndicatorWindow:this 
+    m_fadeOutAnimation.adoptNS([[WebFindIndicatorWindowAnimation alloc] _initWithFindIndicatorWindow:this
+                                                                                   animationDuration:fadeOutAnimationDuration
                                                                            animationProgressCallback:&FindIndicatorWindow::fadeOutAnimationCallback
                                                                              animationDidEndCallback:&FindIndicatorWindow::fadeOutAnimationDidEnd]);
     [m_fadeOutAnimation.get() startAnimation];
@@ -204,4 +224,22 @@ void FindIndicatorWindow::fadeOutAnimationDidEnd()
     closeWindow();
 }
 
+void FindIndicatorWindow::bounceAnimationCallback(double progress)
+{
+    ASSERT(m_bounceAnimation);
+    ASSERT(m_bounceAnimationContext);
+
+    WKWindowBounceAnimationSetAnimationProgress(m_bounceAnimationContext, progress);
+}
+
+void FindIndicatorWindow::bounceAnimationDidEnd()
+{
+    ASSERT(m_bounceAnimation);
+    ASSERT(m_bounceAnimationContext);
+    ASSERT(m_findIndicatorWindow);
+
+    WKWindowBounceAnimationContextDestroy(m_bounceAnimationContext);
+    m_bounceAnimationContext = 0;
+}
+
 } // namespace WebKit
index 23029f5..96a8be2 100644 (file)
@@ -1,3 +1,17 @@
+2010-10-27  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Find indicators do not bounce
+        https://bugs.webkit.org/show_bug.cgi?id=48490
+        <rdar://problem/8564276>
+
+        Add bounce animation context functions.
+
+        * WebKitSystemInterface.h:
+        * libWebKitSystemInterfaceLeopard.a:
+        * libWebKitSystemInterfaceSnowLeopard.a:
+
 2010-10-26  Adam Roben  <aroben@apple.com>
 
         Fix duplicate vsprops name
index 79e816f..3e94071 100644 (file)
@@ -290,6 +290,12 @@ uint32_t WKCARemoteLayerClientGetClientId(WKCARemoteLayerClientRef);
 void WKCARemoteLayerClientSetLayer(WKCARemoteLayerClientRef, CALayer *);
 CALayer *WKCARemoteLayerClientGetLayer(WKCARemoteLayerClientRef);
 
+typedef struct __WKWindowBounceAnimationContext *WKWindowBounceAnimationContextRef;
+
+WKWindowBounceAnimationContextRef WKWindowBounceAnimationContextCreate(NSWindow *window);
+void WKWindowBounceAnimationContextDestroy(WKWindowBounceAnimationContextRef context);
+void WKWindowBounceAnimationSetAnimationProgress(WKWindowBounceAnimationContextRef context, double animationProgress);
+
 #if defined(__x86_64__)
 #import <mach/mig.h>
 
index 0de4a0b..b3fec5e 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceLeopard.a differ
index 2a5ca23..53f60b4 100644 (file)
Binary files a/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a and b/WebKitLibraries/libWebKitSystemInterfaceSnowLeopard.a differ