[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andersca at apple.com andersca at apple.com
Wed Dec 22 14:41:22 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit d89f6a90bf7408c9573249e871dc51f6332f217f
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 15 23:33:03 2010 +0000

    Make the find indicator window fade out when requested
    https://bugs.webkit.org/show_bug.cgi?id=47747
    
    Reviewed by Sam Weinig.
    
    * UIProcess/API/mac/FindIndicatorWindow.h:
    * UIProcess/API/mac/FindIndicatorWindow.mm:
    Add WebFindIndicatorWindowAnimation - an NSAnimation subclass that takes two
    C++ member function pointers and invokes them the animation progress changes and
    when the animation stops.
    
    (-[WebFindIndicatorWindowAnimation setCurrentProgress:]):
    Call the _animationProgressCallback.
    
    (-[WebFindIndicatorWindowAnimation animationDidEnd:]):
    Call the _animationDidEndCallback.
    
    (WebKit::FindIndicatorWindow::FindIndicatorWindow):
    Initialize the fade out start timer.
    
    (WebKit::FindIndicatorWindow::setFindIndicator):
    When asked to fade out, we start the fade out timer.
    
    (WebKit::FindIndicatorWindow::closeWindow):
    Stop the fade out timer and the fade out animation.
    
    (WebKit::FindIndicatorWindow::startFadeOutTimerFired):
    Create a fade out animation.
    
    (WebKit::FindIndicatorWindow::fadeOutAnimationCallback):
    Update the window alpha.
    
    (WebKit::FindIndicatorWindow::fadeOutAnimationDidEnd):
    Close the window.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69895 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 2fc8462..05f5cea 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -23,6 +23,43 @@
 
         Reviewed by Sam Weinig.
 
+        Make the find indicator window fade out when requested
+        https://bugs.webkit.org/show_bug.cgi?id=47747
+
+        * UIProcess/API/mac/FindIndicatorWindow.h:
+        * UIProcess/API/mac/FindIndicatorWindow.mm:
+        Add WebFindIndicatorWindowAnimation - an NSAnimation subclass that takes two
+        C++ member function pointers and invokes them the animation progress changes and
+        when the animation stops.
+
+        (-[WebFindIndicatorWindowAnimation setCurrentProgress:]):
+        Call the _animationProgressCallback.
+
+        (-[WebFindIndicatorWindowAnimation animationDidEnd:]):
+        Call the _animationDidEndCallback.
+
+        (WebKit::FindIndicatorWindow::FindIndicatorWindow):
+        Initialize the fade out start timer.
+
+        (WebKit::FindIndicatorWindow::setFindIndicator):
+        When asked to fade out, we start the fade out timer.
+
+        (WebKit::FindIndicatorWindow::closeWindow):
+        Stop the fade out timer and the fade out animation.
+
+        (WebKit::FindIndicatorWindow::startFadeOutTimerFired):
+        Create a fade out animation.
+
+        (WebKit::FindIndicatorWindow::fadeOutAnimationCallback):
+        Update the window alpha.
+
+        (WebKit::FindIndicatorWindow::fadeOutAnimationDidEnd):
+        Close the window.
+
+2010-10-15  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Sam Weinig.
+
         Move find indicator window logic to WKView
         https://bugs.webkit.org/show_bug.cgi?id=47739
 
diff --git a/WebKit2/UIProcess/API/mac/FindIndicatorWindow.h b/WebKit2/UIProcess/API/mac/FindIndicatorWindow.h
index 45acdc7..4ffcf79 100644
--- a/WebKit2/UIProcess/API/mac/FindIndicatorWindow.h
+++ b/WebKit2/UIProcess/API/mac/FindIndicatorWindow.h
@@ -30,8 +30,10 @@
 #import <wtf/PassOwnPtr.h>
 #import <wtf/RefPtr.h>
 #import <wtf/RetainPtr.h>
+#import "RunLoop.h"
 
 @class WKView;
+ at class WebFindIndicatorWindowAnimation;
 
 namespace WebKit {
 
@@ -50,9 +52,17 @@ private:
     explicit FindIndicatorWindow(WKView *);
     void closeWindow();
 
+    void startFadeOutTimerFired();
+
+    void fadeOutAnimationCallback(double);
+    void fadeOutAnimationDidEnd();
+
     WKView* m_wkView;
     RefPtr<FindIndicator> m_findIndicator;
     RetainPtr<NSWindow> m_findIndicatorWindow;
+
+    RunLoop::Timer<FindIndicatorWindow> m_startFadeOutTimer;
+    RetainPtr<WebFindIndicatorWindowAnimation> m_fadeOutAnimation;
 };
 
 } // namespace WebKit
diff --git a/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm b/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm
index b8bad78..b18d7dc 100644
--- a/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm
+++ b/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm
@@ -28,6 +28,10 @@
 #include "FindIndicator.h"
 #include <WebCore/GraphicsContext.h>
 
+static const double pulseAnimationDuration = 0.12;
+static const double timeBeforeFadeStarts = pulseAnimationDuration + 0.2;
+static const double fadeOutAnimationDuration = 0.3;
+
 using namespace WebCore;
 
 @interface WebFindIndicatorView : NSView {
@@ -61,6 +65,47 @@ using namespace WebCore;
 
 @end
 
+ at interface WebFindIndicatorWindowAnimation : NSAnimation<NSAnimationDelegate> {
+    WebKit::FindIndicatorWindow* _findIndicatorWindow;
+    void (WebKit::FindIndicatorWindow::*_animationProgressCallback)(double progress);
+    void (WebKit::FindIndicatorWindow::*_animationDidEndCallback)();
+}
+
+- (id)_initWithFindIndicatorWindow:(WebKit::FindIndicatorWindow *)findIndicatorWindow 
+                 animationProgressCallback:(void (WebKit::FindIndicatorWindow::*)(double progress))animationProgressCallback
+                   animationDidEndCallback:(void (WebKit::FindIndicatorWindow::*)())animationDidEndCallback;
+ at end
+
+ at implementation WebFindIndicatorWindowAnimation
+
+- (id)_initWithFindIndicatorWindow:(WebKit::FindIndicatorWindow *)findIndicatorWindow 
+         animationProgressCallback:(void (WebKit::FindIndicatorWindow::*)(double progress))animationProgressCallback
+           animationDidEndCallback:(void (WebKit::FindIndicatorWindow::*)())animationDidEndCallback;
+{
+    if ((self = [super initWithDuration:fadeOutAnimationDuration animationCurve:NSAnimationEaseInOut])) {
+        _findIndicatorWindow = findIndicatorWindow;
+        _animationCallback = animationCallback;
+        _animationDidEndCallback = animationDidEndCallback;
+        [self setDelegate:self];
+        [self setAnimationBlockingMode:NSAnimationNonblocking];
+    }
+    return self;
+}
+
+- (void)setCurrentProgress:(NSAnimationProgress)progress
+{
+    (_findIndicatorWindow->*_animationCallback)(progress);
+}
+
+- (void)animationDidEnd:(NSAnimation *)animation
+{
+    ASSERT(animation == self);
+
+    (_findIndicatorWindow->*_animationDidEndCallback)();
+}
+
+ at end
+
 namespace WebKit {
 
 PassOwnPtr<FindIndicatorWindow> FindIndicatorWindow::create(WKView *wkView)
@@ -70,6 +115,7 @@ PassOwnPtr<FindIndicatorWindow> FindIndicatorWindow::create(WKView *wkView)
 
 FindIndicatorWindow::FindIndicatorWindow(WKView *wkView)
     : m_wkView(wkView)
+    , m_startFadeOutTimer(RunLoop::main(), this, &FindIndicatorWindow::startFadeOutTimerFired)
 {
 }
 
@@ -113,6 +159,9 @@ void FindIndicatorWindow::setFindIndicator(PassRefPtr<FindIndicator> findIndicat
 
     [[m_wkView window] addChildWindow:m_findIndicatorWindow.get() ordered:NSWindowAbove];
     [m_findIndicatorWindow.get() setReleasedWhenClosed:NO];
+
+    if (fadeOut)
+        m_startFadeOutTimer.startOneShot(timeBeforeFadeStarts);
 }
 
 void FindIndicatorWindow::closeWindow()
@@ -120,10 +169,41 @@ void FindIndicatorWindow::closeWindow()
     if (!m_findIndicatorWindow)
         return;
 
+    m_startFadeOutTimer.stop();
+
+    if (m_fadeOutAnimation) {
+        [m_fadeOutAnimation.get() stopAnimation];
+        m_fadeOutAnimation = 0;
+    }
+
     [[m_findIndicatorWindow.get() parentWindow] removeChildWindow:m_findIndicatorWindow.get()];
     [m_findIndicatorWindow.get() close];
-    m_findIndicatorWindow.clear();
+    m_findIndicatorWindow = 0;
+}
+
+void FindIndicatorWindow::startFadeOutTimerFired()
+{
+    ASSERT(!m_fadeOutAnimation);
     
+    m_fadeOutAnimation.adoptNS([[WebFindIndicatorWindowAnimation alloc] _initWithFindIndicatorWindow:this 
+                                                                           animationProgressCallback:&FindIndicatorWindow::fadeOutAnimationCallback
+                                                                             animationDidEndCallback:&FindIndicatorWindow::fadeOutAnimationDidEnd]);
+    [m_fadeOutAnimation.get() startAnimation];
+}
+                        
+void FindIndicatorWindow::fadeOutAnimationCallback(double progress)
+{
+    ASSERT(m_fadeOutAnimation);
+
+    [m_findIndicatorWindow.get() setAlphaValue:1.0 - progress];
+}
+
+void FindIndicatorWindow::fadeOutAnimationDidEnd()
+{
+    ASSERT(m_fadeOutAnimation);
+    ASSERT(m_findIndicatorWindow);
+
+    closeWindow();
 }
 
 } // namespace WebKit

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list