+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.
#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;
}
- (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;
FindIndicatorWindow::FindIndicatorWindow(WKView *wkView)
: m_wkView(wkView)
+ , m_bounceAnimationContext(0)
, m_startFadeOutTimer(RunLoop::main(), this, &FindIndicatorWindow::startFadeOutTimerFired)
{
}
[[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);
}
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;
{
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];
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