Changeset 84034 in webkit
- Timestamp:
- Apr 15, 2011 2:36:13 PM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r84019 r84034 1 2011-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 1 47 2011-04-15 Brian Weinstein <bweinstein@apple.com> 2 48 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
r82780 r84034 176 176 void WKBundlePageUninstallPageOverlay(WKBundlePageRef pageRef, WKBundlePageOverlayRef pageOverlayRef) 177 177 { 178 toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef) );178 toImpl(pageRef)->uninstallPageOverlay(toImpl(pageOverlayRef), false); 179 179 } 180 180 -
trunk/Source/WebKit2/WebProcess/WebPage/FindController.cpp
r82594 r84034 134 134 if (m_findPageOverlay) { 135 135 // Get rid of the overlay. 136 m_webPage->uninstallPageOverlay(m_findPageOverlay );136 m_webPage->uninstallPageOverlay(m_findPageOverlay, false); 137 137 } 138 138 … … 154 154 { 155 155 if (m_findPageOverlay) 156 m_webPage->uninstallPageOverlay(m_findPageOverlay );156 m_webPage->uninstallPageOverlay(m_findPageOverlay, true); 157 157 158 158 hideFindIndicator(); -
trunk/Source/WebKit2/WebProcess/WebPage/PageOverlay.cpp
r77842 r84034 28 28 29 29 #include "WebPage.h" 30 #include "WebProcess.h" 30 31 #include <WebCore/Frame.h> 31 32 #include <WebCore/FrameView.h> … … 38 39 namespace WebKit { 39 40 41 static const double fadeAnimationDuration = 0.2; 42 static const double fadeAnimationFrameRate = 30; 43 40 44 PassRefPtr<PageOverlay> PageOverlay::create(Client* client) 41 45 { … … 46 50 : m_client(client) 47 51 , 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) 48 57 { 49 58 } … … 55 64 IntRect PageOverlay::bounds() const 56 65 { 57 FrameView* frameView = webPage()->corePage()->mainFrame()->view();66 FrameView* frameView = m_webPage->corePage()->mainFrame()->view(); 58 67 59 68 int width = frameView->width(); … … 74 83 m_webPage = webPage; 75 84 m_client->didMoveToWebPage(this, webPage); 85 86 if (m_webPage) 87 setNeedsDisplay(); 88 89 m_fadeAnimationTimer.stop(); 76 90 } 77 91 … … 113 127 } 114 128 129 void PageOverlay::startFadeInAnimation() 130 { 131 m_fractionFadedIn = 0.0; 132 m_fadeAnimationType = FadeInAnimation; 133 134 startFadeAnimation(); 135 } 136 137 void PageOverlay::startFadeOutAnimation() 138 { 139 m_fractionFadedIn = 1.0; 140 m_fadeAnimationType = FadeOutAnimation; 141 142 startFadeAnimation(); 143 } 144 145 void PageOverlay::startFadeAnimation() 146 { 147 m_fadeAnimationStartTime = currentTime(); 148 149 // Start the timer 150 m_fadeAnimationTimer.startRepeating(1 / fadeAnimationFrameRate); 151 } 152 153 void 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 115 179 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/WebPage/PageOverlay.h
r72234 r84034 28 28 29 29 #include "APIObject.h" 30 #include "RunLoop.h" 30 31 #include <wtf/PassRefPtr.h> 31 32 … … 66 67 bool mouseEvent(const WebMouseEvent&); 67 68 69 void startFadeInAnimation(); 70 void startFadeOutAnimation(); 71 72 float fractionFadedIn() const { return m_fractionFadedIn; } 73 68 74 protected: 69 75 explicit PageOverlay(Client*); 70 71 WebPage* webPage() const { return m_webPage; }72 76 73 77 private: … … 77 81 WebCore::IntRect bounds() const; 78 82 83 void startFadeAnimation(); 84 void fadeAnimationTimerFired(); 85 79 86 Client* m_client; 87 WebPage* m_webPage; 80 88 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; 82 101 }; 83 102 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r83842 r84034 730 730 m_pageOverlay = pageOverlay; 731 731 m_pageOverlay->setPage(this); 732 733 732 m_drawingArea->didInstallPageOverlay(); 734 735 m_pageOverlay->setNeedsDisplay(); 736 } 737 738 void WebPage::uninstallPageOverlay(PageOverlay* pageOverlay) 733 } 734 735 void WebPage::uninstallPageOverlay(PageOverlay* pageOverlay, bool fadeOut) 739 736 { 740 737 if (pageOverlay != m_pageOverlay) 741 738 return; 739 740 if (fadeOut) { 741 m_pageOverlay->startFadeOutAnimation(); 742 return; 743 } 742 744 743 745 m_pageOverlay->setPage(0); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r83687 r84034 253 253 bool windowIsFocused() const; 254 254 void installPageOverlay(PassRefPtr<PageOverlay>); 255 void uninstallPageOverlay(PageOverlay* );255 void uninstallPageOverlay(PageOverlay*, bool fadeOut); 256 256 bool hasPageOverlay() const { return m_pageOverlay; } 257 257 WebCore::IntRect windowToScreen(const WebCore::IntRect&);
Note: See TracChangeset
for help on using the changeset viewer.