Changeset 84034 in webkit


Ignore:
Timestamp:
Apr 15, 2011 2:36:13 PM (13 years ago)
Author:
andersca@apple.com
Message:

2011-04-15 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.

Add the ability for PageOverlays to fade in and out
https://bugs.webkit.org/show_bug.cgi?id=58694

  • WebProcess/InjectedBundle/API/c/WKBundlePage.cpp: (WKBundlePageUninstallPageOverlay): WebPage::uninstallPageOverlay now takes a boolean. Default to false for now.
  • WebProcess/WebPage/FindController.cpp: (WebKit::FindController::findString): Pass false to uninstallPageOverlay.

(WebKit::FindController::hideFindUI):
Pass true to uninstallPageOverlay.


  • WebProcess/WebPage/PageOverlay.cpp: (WebKit::PageOverlay::PageOverlay): Initialize new member variables.

(WebKit::PageOverlay::bounds):
Get rid of an unnecessary webPage() getter.

(WebKit::PageOverlay::setPage):
Stop the animation timer.

(WebKit::PageOverlay::startFadeInAnimation):
Update m_fractionFadedIn and call startFadeAnimation.

(WebKit::PageOverlay::startFadeOutAnimation):
Ditto.


(WebKit::PageOverlay::startFadeAnimation):
Initialize m_fadeAnimationStartTime and start the fade animation timer.

(WebKit::PageOverlay::fadeAnimationTimerFired):
Update m_fractionFadedIn and call setNeedsDisplay().

  • WebProcess/WebPage/PageOverlay.h:
  • WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::uninstallPageOverlay): If fadeOut is true, tell the page overlay to start the fade out animation. When the fade animation is complete, the page overlay will uninstall itself.
Location:
trunk/Source/WebKit2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r84019 r84034  
     12011-04-15  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Add the ability for PageOverlays to fade in and out
     6        https://bugs.webkit.org/show_bug.cgi?id=58694
     7
     8        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
     9        (WKBundlePageUninstallPageOverlay):
     10        WebPage::uninstallPageOverlay now takes a boolean. Default to false for now.
     11
     12        * WebProcess/WebPage/FindController.cpp:
     13        (WebKit::FindController::findString):
     14        Pass false to uninstallPageOverlay.
     15
     16        (WebKit::FindController::hideFindUI):
     17        Pass true to uninstallPageOverlay.
     18       
     19        * WebProcess/WebPage/PageOverlay.cpp:
     20        (WebKit::PageOverlay::PageOverlay):
     21        Initialize new member variables.
     22
     23        (WebKit::PageOverlay::bounds):
     24        Get rid of an unnecessary webPage() getter.
     25
     26        (WebKit::PageOverlay::setPage):
     27        Stop the animation timer.
     28
     29        (WebKit::PageOverlay::startFadeInAnimation):
     30        Update m_fractionFadedIn and call startFadeAnimation.
     31
     32        (WebKit::PageOverlay::startFadeOutAnimation):
     33        Ditto.
     34       
     35        (WebKit::PageOverlay::startFadeAnimation):
     36        Initialize m_fadeAnimationStartTime and start the fade animation timer.
     37
     38        (WebKit::PageOverlay::fadeAnimationTimerFired):
     39        Update m_fractionFadedIn and call setNeedsDisplay().
     40
     41        * WebProcess/WebPage/PageOverlay.h:
     42        * WebProcess/WebPage/WebPage.cpp:
     43        (WebKit::WebPage::uninstallPageOverlay):
     44        If fadeOut is true, tell the page overlay to start the fade out animation.
     45        When the fade animation is complete, the page overlay will uninstall itself.
     46
    1472011-04-15  Brian Weinstein  <bweinstein@apple.com>
    248
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp

    r82780 r84034  
    176176void WKBundlePageUninstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef)
    177177{
    178     toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef));
     178    toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef), false);
    179179}
    180180
  • trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp

    r82594 r84034  
    134134        if (m_findPageOverlay) {
    135135            // Get rid of the overlay.
    136             m_webPage->uninstallPageOverlay(m_findPageOverlay);
     136            m_webPage->uninstallPageOverlay(m_findPageOverlay, false);
    137137        }
    138138       
     
    154154{
    155155    if (m_findPageOverlay)
    156         m_webPage->uninstallPageOverlay(m_findPageOverlay);
     156        m_webPage->uninstallPageOverlay(m_findPageOverlay, true);
    157157
    158158    hideFindIndicator();
  • trunk/Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp

    r77842 r84034  
    2828
    2929#include "WebPage.h"
     30#include "WebProcess.h"
    3031#include <WebCore/Frame.h>
    3132#include <WebCore/FrameView.h>
     
    3839namespace WebKit {
    3940
     41static const double fadeAnimationDuration = 0.2;
     42static const double fadeAnimationFrameRate = 30;
     43
    4044PassRefPtr<PageOverlay> PageOverlay::create(Client* client)
    4145{
     
    4650    : m_client(client)
    4751    , m_webPage(0)
     52    , m_fadeAnimationTimer(WebProcess::shared().runLoop(), this, &PageOverlay::fadeAnimationTimerFired)
     53    , m_fadeAnimationStartTime(0.0)
     54    , m_fadeAnimationDuration(fadeAnimationDuration)
     55    , m_fadeAnimationType(NoAnimation)
     56    , m_fractionFadedIn(1.0)
    4857{
    4958}
     
    5564IntRect PageOverlay::bounds() const
    5665{
    57     FrameView* frameView = webPage()->corePage()->mainFrame()->view();
     66    FrameView* frameView = m_webPage->corePage()->mainFrame()->view();
    5867
    5968    int width = frameView->width();
     
    7483    m_webPage = webPage;
    7584    m_client->didMoveToWebPage(this, webPage);
     85
     86    if (m_webPage)
     87        setNeedsDisplay();
     88
     89    m_fadeAnimationTimer.stop();
    7690}
    7791
     
    113127}
    114128
     129void PageOverlay::startFadeInAnimation()
     130{
     131    m_fractionFadedIn = 0.0;
     132    m_fadeAnimationType = FadeInAnimation;
     133
     134    startFadeAnimation();
     135}
     136
     137void PageOverlay::startFadeOutAnimation()
     138{
     139    m_fractionFadedIn = 1.0;
     140    m_fadeAnimationType = FadeOutAnimation;
     141
     142    startFadeAnimation();
     143}
     144
     145void PageOverlay::startFadeAnimation()
     146{
     147    m_fadeAnimationStartTime = currentTime();
     148   
     149    // Start the timer
     150    m_fadeAnimationTimer.startRepeating(1 / fadeAnimationFrameRate);
     151}
     152
     153void PageOverlay::fadeAnimationTimerFired()
     154{
     155    float animationProgress = (currentTime() - m_fadeAnimationStartTime) / m_fadeAnimationDuration;
     156
     157    if (animationProgress >= 1.0)
     158        animationProgress = 1.0;
     159
     160    double sine = sin(M_PI_2 * animationProgress);
     161    float fadeAnimationValue = sine * sine;
     162
     163    m_fractionFadedIn = (m_fadeAnimationType == FadeInAnimation) ? fadeAnimationValue : 1 - fadeAnimationValue;
     164    setNeedsDisplay();
     165
     166    if (animationProgress == 1.0) {
     167        m_fadeAnimationTimer.stop();
     168
     169        bool wasFadingOut = m_fadeAnimationType == FadeOutAnimation;
     170        m_fadeAnimationType = NoAnimation;
     171
     172        if (wasFadingOut) {
     173            // If this was a fade out, go ahead and uninstall the page overlay.
     174            m_webPage->uninstallPageOverlay(this, false);
     175        }
     176    }
     177}
     178
    115179} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebPage/PageOverlay.h

    r72234 r84034  
    2828
    2929#include "APIObject.h"
     30#include "RunLoop.h"
    3031#include <wtf/PassRefPtr.h>
    3132
     
    6667    bool mouseEvent(const WebMouseEvent&);
    6768
     69    void startFadeInAnimation();
     70    void startFadeOutAnimation();
     71
     72    float fractionFadedIn() const { return m_fractionFadedIn; }
     73
    6874protected:
    6975    explicit PageOverlay(Client*);
    70 
    71     WebPage* webPage() const { return m_webPage; }
    7276
    7377private:
     
    7781    WebCore::IntRect bounds() const;
    7882
     83    void startFadeAnimation();
     84    void fadeAnimationTimerFired();
     85
    7986    Client* m_client;
     87    WebPage* m_webPage;
    8088
    81     WebPage* m_webPage;
     89    RunLoop::Timer<PageOverlay> m_fadeAnimationTimer;
     90    double m_fadeAnimationStartTime;
     91    double m_fadeAnimationDuration;
     92
     93    enum FadeAnimationType {
     94        NoAnimation,
     95        FadeInAnimation,
     96        FadeOutAnimation,
     97    };
     98
     99    FadeAnimationType m_fadeAnimationType;
     100    float m_fractionFadedIn;
    82101};
    83102
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r83842 r84034  
    730730    m_pageOverlay = pageOverlay;
    731731    m_pageOverlay->setPage(this);
    732 
    733732    m_drawingArea->didInstallPageOverlay();
    734 
    735     m_pageOverlay->setNeedsDisplay();
    736 }
    737 
    738 void WebPage::uninstallPageOverlay(PageOverlay* pageOverlay)
     733}
     734
     735void WebPage::uninstallPageOverlay(PageOverlay* pageOverlay, bool fadeOut)
    739736{
    740737    if (pageOverlay != m_pageOverlay)
    741738        return;
     739
     740    if (fadeOut) {
     741        m_pageOverlay->startFadeOutAnimation();
     742        return;
     743    }
    742744
    743745    m_pageOverlay->setPage(0);
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r83687 r84034  
    253253    bool windowIsFocused() const;
    254254    void installPageOverlay(PassRefPtr<PageOverlay>);
    255     void uninstallPageOverlay(PageOverlay*);
     255    void uninstallPageOverlay(PageOverlay*, bool fadeOut);
    256256    bool hasPageOverlay() const { return m_pageOverlay; }
    257257    WebCore::IntRect windowToScreen(const WebCore::IntRect&);
Note: See TracChangeset for help on using the changeset viewer.