https://bugs.webkit.org/show_bug.cgi?id=66584
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Nov 2011 00:06:02 +0000 (00:06 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Nov 2011 00:06:02 +0000 (00:06 +0000)
WebKit2's find bouncy looks blurry after dragging window onto >1.0 scale factor
display
-and corresponding-
<rdar://problem/9987559>

Reviewed by Anders Carlsson.

The setFindIndicator message and various functions of the same name must all take
an additional parameter indicating whether or not setting the find indicator
should result in a bounce animation. This is because when the device scale factor
changes, if there is currently a find indicator, it must be re-set to a higher or
lower resolution version, but we don't want the bounce animation to happen again.
* UIProcess/API/mac/FindIndicatorWindow.h:
* UIProcess/API/mac/FindIndicatorWindow.mm:
(WebKit::FindIndicatorWindow::setFindIndicator):
* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::setFindIndicator):
* UIProcess/API/mac/WKView.mm:
(-[WKView _setFindIndicator:fadeOut:animate:]):
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setFindIndicator):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:

New function FindController::isShowingOverlay() is used to determine if
FindController::deviceScaleFactorDidChange() needs to be called.
* WebProcess/WebPage/FindController.h:
(WebKit::FindController::isShowingOverlay):

FindController::deviceScaleFactorDidChange() calls updateFindIndicator to re-
generate the bitmap at the appropriate scale factor, but tells it not to animate
this time.
(WebKit::FindController::deviceScaleFactorDidChange):

updateFindIndicator() takes a new parameter indicating whether or not the
FindIndicator should animate. It defaults to true since the deviceScaleFactor
changing is the only case currently where we do not want it to animate.
* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::updateFindIndicator):
(WebKit::FindController::hideFindIndicator):

Calls into FindController::deviceScaleFactorDidChange() when the scale factor has
changed and the find overlay is showing.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setDeviceScaleFactor):

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

14 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.h
Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm
Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
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/WebPageProxy.messages.in
Source/WebKit2/WebProcess/WebPage/FindController.cpp
Source/WebKit2/WebProcess/WebPage/FindController.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 570a33c..e7e739d 100644 (file)
@@ -1,3 +1,55 @@
+2011-11-10  Beth Dakin  <bdakin@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=66584
+        WebKit2's find bouncy looks blurry after dragging window onto >1.0 scale factor 
+        display
+        -and corresponding-
+        <rdar://problem/9987559>
+
+        Reviewed by Anders Carlsson.
+
+        The setFindIndicator message and various functions of the same name must all take 
+        an additional parameter indicating whether or not setting the find indicator 
+        should result in a bounce animation. This is because when the device scale factor 
+        changes, if there is currently a find indicator, it must be re-set to a higher or 
+        lower resolution version, but we don't want the bounce animation to happen again.
+        * UIProcess/API/mac/FindIndicatorWindow.h:
+        * UIProcess/API/mac/FindIndicatorWindow.mm:
+        (WebKit::FindIndicatorWindow::setFindIndicator):
+        * UIProcess/API/mac/PageClientImpl.h:
+        * UIProcess/API/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::setFindIndicator):
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _setFindIndicator:fadeOut:animate:]):
+        * UIProcess/API/mac/WKViewInternal.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setFindIndicator):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+
+        New function FindController::isShowingOverlay() is used to determine if 
+        FindController::deviceScaleFactorDidChange() needs to be called.
+        * WebProcess/WebPage/FindController.h:
+        (WebKit::FindController::isShowingOverlay): 
+
+        FindController::deviceScaleFactorDidChange() calls updateFindIndicator to re-
+        generate the bitmap at the appropriate scale factor, but tells it not to animate 
+        this time.
+        (WebKit::FindController::deviceScaleFactorDidChange):
+
+        updateFindIndicator() takes a new parameter indicating whether or not the 
+        FindIndicator should animate. It defaults to true since the deviceScaleFactor 
+        changing is the only case currently where we do not want it to animate.
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::FindController::updateFindIndicator):
+        (WebKit::FindController::hideFindIndicator):
+
+        Calls into FindController::deviceScaleFactorDidChange() when the scale factor has 
+        changed and the find overlay is showing.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setDeviceScaleFactor):
+
 2011-11-10  Timothy Hatcher  <timothy@apple.com>
 
         Make WKViews in NSPopovers render as they would in active windows.
index eb1b4c2..7836a54 100644 (file)
@@ -47,7 +47,7 @@ public:
     static PassOwnPtr<FindIndicatorWindow> create(WKView *);
     ~FindIndicatorWindow();
 
-    void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut);
+    void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate);
 
 private:
     explicit FindIndicatorWindow(WKView *);
index 4056e1e..0e6a6f1 100644 (file)
@@ -129,7 +129,7 @@ FindIndicatorWindow::~FindIndicatorWindow()
     closeWindow();
 }
 
-void FindIndicatorWindow::setFindIndicator(PassRefPtr<FindIndicator> findIndicator, bool fadeOut)
+void FindIndicatorWindow::setFindIndicator(PassRefPtr<FindIndicator> findIndicator, bool fadeOut, bool animate)
 {
     if (m_findIndicator == findIndicator)
         return;
@@ -163,13 +163,15 @@ 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([[WKFindIndicatorWindowAnimation alloc] _initWithFindIndicatorWindow:this
-                                                                                  animationDuration:bounceAnimationDuration
-                                                                          animationProgressCallback:&FindIndicatorWindow::bounceAnimationCallback
-                                                                            animationDidEndCallback:&FindIndicatorWindow::bounceAnimationDidEnd]);
-    [m_bounceAnimation.get() startAnimation];
+    if (animate) {
+        // Start the bounce animation.
+        m_bounceAnimationContext = WKWindowBounceAnimationContextCreate(m_findIndicatorWindow.get());
+        m_bounceAnimation.adoptNS([[WKFindIndicatorWindowAnimation alloc] _initWithFindIndicatorWindow:this
+                                                                                    animationDuration:bounceAnimationDuration
+                                                                            animationProgressCallback:&FindIndicatorWindow::bounceAnimationCallback
+                                                                              animationDidEndCallback:&FindIndicatorWindow::bounceAnimationDidEnd]);
+        [m_bounceAnimation.get() startAnimation];
+    }
 
     if (fadeOut)
         m_startFadeOutTimer.startOneShot(timeBeforeFadeStarts);
index cb1575d..ed30cce 100644 (file)
@@ -88,7 +88,7 @@ private:
     virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
     virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
 
-    void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut);
+    void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate);
 
     virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
     virtual void exitAcceleratedCompositingMode();
index 0ba4beb..16b5007 100644 (file)
@@ -313,9 +313,9 @@ PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPagePr
     return WebContextMenuProxyMac::create(m_wkView, page);
 }
 
-void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator> findIndicator, bool fadeOut)
+void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator> findIndicator, bool fadeOut, bool animate)
 {
-    [m_wkView _setFindIndicator:findIndicator fadeOut:fadeOut];
+    [m_wkView _setFindIndicator:findIndicator fadeOut:fadeOut animate:animate];
 }
 
 void PageClientImpl::accessibilityWebProcessTokenReceived(const CoreIPC::DataReference& data)
index 03ff9cf..a845501 100644 (file)
@@ -2337,7 +2337,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
     }
 }
 
-- (void)_setFindIndicator:(PassRefPtr<FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut
+- (void)_setFindIndicator:(PassRefPtr<FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate
 {
     if (!findIndicator) {
         _data->_findIndicatorWindow = nullptr;
@@ -2347,7 +2347,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
     if (!_data->_findIndicatorWindow)
         _data->_findIndicatorWindow = FindIndicatorWindow::create(self);
 
-    _data->_findIndicatorWindow->setFindIndicator(findIndicator, fadeOut);
+    _data->_findIndicatorWindow->setFindIndicator(findIndicator, fadeOut, animate);
 }
 
 - (void)_enterAcceleratedCompositingMode:(const LayerTreeContext&)layerTreeContext
index c746136..fd3e152 100644 (file)
@@ -60,7 +60,7 @@ namespace WebKit {
 - (bool)_executeSavedCommandBySelector:(SEL)selector;
 - (NSRect)_convertToDeviceSpace:(NSRect)rect;
 - (NSRect)_convertToUserSpace:(NSRect)rect;
-- (void)_setFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut;
+- (void)_setFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate;
 
 - (void)_enterAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext;
 - (void)_exitAcceleratedCompositingMode;
index 3ffa2bf..98727a3 100644 (file)
@@ -151,7 +151,7 @@ public:
     virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*) = 0;
     virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*) = 0;
 
-    virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut) = 0;
+    virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate) = 0;
 #if PLATFORM(WIN)
     virtual void didInstallOrUninstallPageOverlay(bool) = 0;
 #endif
index 6ab439a..feb452a 100644 (file)
@@ -2402,10 +2402,10 @@ void WebPageProxy::didCountStringMatches(const String& string, uint32_t matchCou
     m_findClient.didCountStringMatches(this, string, matchCount);
 }
 
-void WebPageProxy::setFindIndicator(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut)
+void WebPageProxy::setFindIndicator(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut, bool animate)
 {
     RefPtr<FindIndicator> findIndicator = FindIndicator::create(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImageScaleFactor, contentImageHandle);
-    m_pageClient->setFindIndicator(findIndicator.release(), fadeOut);
+    m_pageClient->setFindIndicator(findIndicator.release(), fadeOut, animate);
 }
 
 void WebPageProxy::didFindString(const String& string, uint32_t matchCount)
index 9031bb6..6787ed1 100644 (file)
@@ -431,7 +431,7 @@ public:
     void hideFindUI();
     void countStringMatches(const String&, FindOptions, unsigned maxMatchCount);
     void didCountStringMatches(const String&, uint32_t matchCount);
-    void setFindIndicator(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut);
+    void setFindIndicator(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut, bool animate);
     void didFindString(const String&, uint32_t matchCount);
     void didFailToFindString(const String&);
 #if PLATFORM(WIN)
index d196550..e4031d3 100644 (file)
@@ -165,7 +165,7 @@ messages -> WebPageProxy {
 
     # Find messages
     DidCountStringMatches(WTF::String string, uint32_t matchCount)
-    SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, float contentImageScaleFactor, WebKit::ShareableBitmap::Handle contentImageHandle, bool fadeOut)
+    SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, float contentImageScaleFactor, WebKit::ShareableBitmap::Handle contentImageHandle, bool fadeOut, bool animate)
     DidFindString(WTF::String string, uint32_t matchCount)
     DidFailToFindString(WTF::String string)
 #if PLATFORM(WIN)
index 49e2f65..9bdd80b 100644 (file)
@@ -159,7 +159,7 @@ void FindController::hideFindUI()
     hideFindIndicator();
 }
 
-bool FindController::updateFindIndicator(Frame* selectedFrame, bool isShowingOverlay)
+bool FindController::updateFindIndicator(Frame* selectedFrame, bool isShowingOverlay, bool shouldAnimate)
 {
     if (!selectedFrame)
         return false;
@@ -211,8 +211,8 @@ bool FindController::updateFindIndicator(Frame* selectedFrame, bool isShowingOve
 
         textRectsInSelectionRectCoordinates.append(textRectInSelectionRectCoordinates);
     }            
-    
-    m_webPage->send(Messages::WebPageProxy::SetFindIndicator(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, m_webPage->corePage()->deviceScaleFactor(), handle, !isShowingOverlay));
+
+    m_webPage->send(Messages::WebPageProxy::SetFindIndicator(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, m_webPage->corePage()->deviceScaleFactor(), handle, !isShowingOverlay, shouldAnimate));
     m_isShowingFindIndicator = true;
 
     return true;
@@ -224,7 +224,7 @@ void FindController::hideFindIndicator()
         return;
 
     ShareableBitmap::Handle handle;
-    m_webPage->send(Messages::WebPageProxy::SetFindIndicator(FloatRect(), Vector<FloatRect>(), m_webPage->corePage()->deviceScaleFactor(), handle, false));
+    m_webPage->send(Messages::WebPageProxy::SetFindIndicator(FloatRect(), Vector<FloatRect>(), m_webPage->corePage()->deviceScaleFactor(), handle, false, true));
     m_isShowingFindIndicator = false;
 }
 
@@ -237,6 +237,17 @@ void FindController::showFindIndicatorInSelection()
     updateFindIndicator(selectedFrame, false);
 }
 
+void FindController::deviceScaleFactorDidChange()
+{
+    ASSERT(isShowingOverlay());
+
+    Frame* selectedFrame = frameWithSelection(m_webPage->corePage());
+    if (!selectedFrame)
+        return;
+
+    updateFindIndicator(selectedFrame, true, false);
+}
+
 Vector<IntRect> FindController::rectsForTextMatches()
 {
     Vector<IntRect> rects;
index 19f6e9e..da03b79 100644 (file)
@@ -55,6 +55,10 @@ public:
     void hideFindIndicator();
     void showFindIndicatorInSelection();
 
+    bool isShowingOverlay() const { return m_isShowingFindIndicator && m_findPageOverlay; }
+
+    void deviceScaleFactorDidChange();
+
 private:
     // PageOverlay::Client.
     virtual void pageOverlayDestroyed(PageOverlay*);
@@ -64,7 +68,7 @@ private:
     virtual void drawRect(PageOverlay*, WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
 
     Vector<WebCore::IntRect> rectsForTextMatches();
-    bool updateFindIndicator(WebCore::Frame* selectedFrame, bool isShowingOverlay);
+    bool updateFindIndicator(WebCore::Frame* selectedFrame, bool isShowingOverlay, bool shouldAnimate = true);
 
 private:
     WebPage* m_webPage;
index 584d6aa..49b5fc4 100644 (file)
@@ -874,6 +874,12 @@ void WebPage::setDeviceScaleFactor(float scaleFactor)
     for (HashSet<PluginView*>::const_iterator it = m_pluginViews.begin(), end = m_pluginViews.end(); it != end; ++it)
         (*it)->setDeviceScaleFactor(scaleFactor);
 #endif
+
+    if (m_findController.isShowingOverlay()) {
+        // We must have updated layout to get the selection rects right.
+        layoutIfNeeded();
+        m_findController.deviceScaleFactorDidChange();
+    }
 }
 
 float WebPage::deviceScaleFactor() const