Implement and adopt two new TextIndicator presentation animations
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Dec 2014 03:02:41 +0000 (03:02 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Dec 2014 03:02:41 +0000 (03:02 +0000)
commit5bfd706acd2ff7e8e89f4e448db7ae108f9736a5
treea332dcaf18b2c3ae3d3d66c1e5d93fcc028e27da
parentb1fefa627b96038e0b1229f5d032df950797d4ab
Implement and adopt two new TextIndicator presentation animations
https://bugs.webkit.org/show_bug.cgi?id=139715
<rdar://problem/19237945>

Reviewed by Anders Carlsson.

* WebCore.exp.in:
Adjust one symbol and export another.

* page/TextIndicator.cpp:
(WebCore::TextIndicator::createWithSelectionInFrame):
Take a blue-highlight snapshot if we're doing a crossfade without a bounce.

* page/TextIndicator.h:
(WebCore::TextIndicator::presentationTransition):
Add FadeIn and Crossfade transition types.

* page/mac/TextIndicatorWindow.h:
* page/mac/TextIndicatorWindow.mm:
(-[WebTextIndicatorView initWithFrame:textIndicator:margin:]):
(createBounceAnimation):
(createContentCrossfadeAnimation):
(createShadowFadeAnimation):
(createFadeInAnimation):
(-[WebTextIndicatorView _textIndicatorWantsBounce]):
(-[WebTextIndicatorView _textIndicatorWantsContentCrossfade]):
(-[WebTextIndicatorView _textIndicatorWantsFadeIn]):
Factor out the animation construction.

(-[WebTextIndicatorView _animationDuration]):
Factor out the duration computation.

(-[WebTextIndicatorView present]):
(-[WebTextIndicatorView setAnimationProgress:]):
Implement FadeIn and Crossfade transitions.
They can be driven externally and then continue from where they
left off when the progress reaches 100%.
FadeIn changes the opacity of the whole bubble, Crossfade
crossfades the content (from blue to yellow).

(WebCore::TextIndicatorWindow::TextIndicatorWindow):
(WebCore::TextIndicatorWindow::~TextIndicatorWindow):
Don't immediately destroy the window if it is crossfades or fades in.
Fade it out, instead.

(WebCore::TextIndicatorWindow::setAnimationProgress):
Drive the paused animation manually. If progress hits 100%,
start running it automatically from where it last left off.

(WebCore::TextIndicatorWindow::setTextIndicator):
(WebCore::TextIndicatorWindow::startFadeOut):
(-[WebTextIndicatorView presentWithCompletionHandler:]): Deleted.
(WebCore::TextIndicatorWindow::startFadeOutTimerFired): Deleted.
Remove the completion block from -present.

* platform/spi/mac/NSImmediateActionGestureRecognizerSPI.h:
Add some SPI.

* WebView/WebActionMenuController.mm:
(-[WebActionMenuController _showTextIndicator]):
* WebView/WebHTMLView.mm:
(-[WebHTMLView quickLookWithEvent:]):
Remove the completionHandler from text indicator presentation.

* WebView/WebImmediateActionController.mm:
(-[WebImmediateActionController immediateActionRecognizerWillPrepare:]):
(-[WebImmediateActionController immediateActionRecognizerDidUpdateAnimation:]):
(-[WebImmediateActionController immediateActionRecognizerDidCancelAnimation:]):
(-[WebImmediateActionController immediateActionRecognizerDidCompleteAnimation:]):
(-[WebImmediateActionController _menuItemForDataDetectedText]):
(-[WebImmediateActionController _animationControllerForText]):
(-[WebImmediateActionController _showTextIndicator]):
Forward immediate action gesture recognizer animation progress
to TextIndicator. Force us to keep the selection when immediate
action popovers steal first responder status from the WebView.
If the Lookup range is equal to the selection range, use a Crossfade
animation; otherwise, use a FadeIn animation.

* WebView/WebView.mm:
(-[WebView _setMaintainsInactiveSelection:]):
(-[WebView maintainsInactiveSelection]):
(-[WebView _animationControllerForDictionaryLookupPopupInfo:]):
(-[WebView _setTextIndicator:fadeOut:]):
(-[WebView _clearTextIndicator]):
(-[WebView _setTextIndicatorAnimationProgress:]):
(-[WebView _showDictionaryLookupPopup:]):
(-[WebView _dictionaryLookupPopoverWillClose:]):
(-[WebView _setTextIndicator:fadeOut:animationCompletionHandler:]):
Remove the completionHandler from text indicator presentation.
Add a _setMaintainsInactiveSelection, which allows WebKit internals
to change the return value of -maintainsInactiveSelection, allowing
us to keep the selection alive when the WebView loses first responder status.

* WebView/WebViewData.h:
* WebView/WebViewInternal.h:

* UIProcess/API/mac/WKView.mm:
(-[WKView _setTextIndicator:fadeOut:]):
(-[WKView _setTextIndicatorAnimationProgress:]):
(-[WKView _setTextIndicator:fadeOut:animationCompletionHandler:]): Deleted.
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::setTextIndicatorAnimationProgress):
(WebKit::WebPageProxy::performActionMenuHitTestAtLocation):
* UIProcess/WebPageProxy.h:
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::setTextIndicatorAnimationProgress):
(WebKit::PageClientImpl::didPerformDictionaryLookup):
Remove the completion handler block argument from TextIndicator
installation.
Plumb animation progress through PageClient to TextIndicatorWindow.

* UIProcess/mac/WKActionMenuController.mm:
(-[WKActionMenuController prepareForMenu:withEvent:]):
(-[WKActionMenuController _defaultMenuItemsForDataDetectedText]):
* UIProcess/mac/WKImmediateActionController.mm:
(-[WKImmediateActionController _clearImmediateActionState]):
(-[WKImmediateActionController immediateActionRecognizerWillPrepare:]):
(-[WKImmediateActionController immediateActionRecognizerDidUpdateAnimation:]):
(-[WKImmediateActionController immediateActionRecognizerDidCancelAnimation:]):
(-[WKImmediateActionController immediateActionRecognizerDidCompleteAnimation:]):
(-[WKImmediateActionController _menuItemForDataDetectedText]):
(-[WKImmediateActionController _animationControllerForText]):
Forward immediate action gesture recognizer animation progress
to TextIndicator. Force us to keep the selection when immediate
action popovers steal first responder status from the WebView.

* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::textIndicatorTransitionForActionMenu):
(WebKit::WebPage::performActionMenuHitTestAtLocation):
Factor out the presentation animation decision code.
For immediate actions, of the Lookup range is equal to the
selection range, use a Crossfade animation; otherwise, use a FadeIn
animation.
Push whether the actionMenuHitTest is for an immediate action
or a menu to the Web process, to make the presentation animation
decision code live entirely in the Web process.
Avoid extracting encoded image data if we know we're doing
an immediate action and will never need it.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177427 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/page/TextIndicator.cpp
Source/WebCore/page/TextIndicator.h
Source/WebCore/page/mac/TextIndicatorWindow.h
Source/WebCore/page/mac/TextIndicatorWindow.mm
Source/WebCore/platform/spi/mac/NSImmediateActionGestureRecognizerSPI.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebActionMenuController.mm
Source/WebKit/mac/WebView/WebHTMLView.mm
Source/WebKit/mac/WebView/WebImmediateActionController.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/mac/WebView/WebViewData.h
Source/WebKit/mac/WebView/WebViewInternal.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/mac/PageClientImpl.h
Source/WebKit2/UIProcess/mac/PageClientImpl.mm
Source/WebKit2/UIProcess/mac/WKActionMenuController.mm
Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm