Title: [97640] trunk/Source
Revision
97640
Author
[email protected]
Date
2011-10-17 13:15:01 -0700 (Mon, 17 Oct 2011)

Log Message

Throttle rate of requestAnimationFrame when page is not visible
https://bugs.webkit.org/show_bug.cgi?id=67873

Reviewed by Anders Carlsson.

Source/WebCore:

Add logic to suspend and resume scripted animations when page is hidden,
minimized or the tab is not visible. The hide/minimize notification comes
in from WebKit/WebKit2 to a new set of functions.

* WebCore.exp.in:
* page/Page.cpp:
(WebCore::Page::didMoveOnscreen):
(WebCore::Page::willMoveOffscreen):
(WebCore::Page::suspendScriptedAnimations):
(WebCore::Page::resumeScriptedAnimations):
* page/Page.h:

Source/WebKit/mac:

Plumb through notification when the window is hidden/shown or
minimized/unminimized

* WebView/WebView.mm:
(-[WebView _windowWillOrderOnScreen:]):
(-[WebView _windowWillOrderOffScreen:]):

Source/WebKit2:

Plumb through notification when the window is hidden/shown or
minimized/unminimized

* WebProcess/WebPage/DrawingAreaImpl.cpp:
(WebKit::DrawingAreaImpl::suspendPainting):
(WebKit::DrawingAreaImpl::resumePainting):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (97639 => 97640)


--- trunk/Source/WebCore/ChangeLog	2011-10-17 20:03:57 UTC (rev 97639)
+++ trunk/Source/WebCore/ChangeLog	2011-10-17 20:15:01 UTC (rev 97640)
@@ -1,3 +1,22 @@
+2011-10-14  Chris Marrin  <[email protected]>
+
+        Throttle rate of requestAnimationFrame when page is not visible
+        https://bugs.webkit.org/show_bug.cgi?id=67873
+
+        Reviewed by Anders Carlsson.
+
+        Add logic to suspend and resume scripted animations when page is hidden,
+        minimized or the tab is not visible. The hide/minimize notification comes
+        in from WebKit/WebKit2 to a new set of functions.
+
+        * WebCore.exp.in:
+        * page/Page.cpp:
+        (WebCore::Page::didMoveOnscreen):
+        (WebCore::Page::willMoveOffscreen):
+        (WebCore::Page::suspendScriptedAnimations):
+        (WebCore::Page::resumeScriptedAnimations):
+        * page/Page.h:
+
 2011-10-17  Antti Koivisto  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=69966

Modified: trunk/Source/WebCore/WebCore.exp.in (97639 => 97640)


--- trunk/Source/WebCore/WebCore.exp.in	2011-10-17 20:03:57 UTC (rev 97639)
+++ trunk/Source/WebCore/WebCore.exp.in	2011-10-17 20:15:01 UTC (rev 97640)
@@ -744,6 +744,8 @@
 __ZN7WebCore4Page21windowScreenDidChangeEj
 __ZN7WebCore4Page22allVisitedStateChangedEPNS_9PageGroupE
 __ZN7WebCore4Page23clearUndoRedoOperationsEv
+__ZN7WebCore4Page24resumeScriptedAnimationsEv
+__ZN7WebCore4Page25suspendScriptedAnimationsEv
 __ZN7WebCore4Page27setJavaScriptURLsAreAllowedEb
 __ZN7WebCore4Page31setCustomHTMLTokenizerChunkSizeEi
 __ZN7WebCore4Page31setCustomHTMLTokenizerTimeDelayEd

Modified: trunk/Source/WebCore/page/Page.cpp (97639 => 97640)


--- trunk/Source/WebCore/page/Page.cpp	2011-10-17 20:03:57 UTC (rev 97639)
+++ trunk/Source/WebCore/page/Page.cpp	2011-10-17 20:15:01 UTC (rev 97640)
@@ -668,6 +668,8 @@
         if (frame->view())
             frame->view()->didMoveOnscreen();
     }
+    
+    resumeScriptedAnimations();
 }
 
 void Page::willMoveOffscreen()
@@ -676,6 +678,8 @@
         if (frame->view())
             frame->view()->willMoveOffscreen();
     }
+    
+    suspendScriptedAnimations();
 }
 
 void Page::windowScreenDidChange(PlatformDisplayID displayID)
@@ -688,6 +692,22 @@
     }
 }
 
+void Page::suspendScriptedAnimations()
+{
+    for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+        if (frame->document())
+            frame->document()->suspendScriptedAnimationControllerCallbacks();
+    }
+}
+
+void Page::resumeScriptedAnimations()
+{
+    for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) {
+        if (frame->document())
+            frame->document()->resumeScriptedAnimationControllerCallbacks();
+    }
+}
+
 void Page::userStyleSheetLocationChanged()
 {
     // FIXME: Eventually we will move to a model of just being handed the sheet

Modified: trunk/Source/WebCore/page/Page.h (97639 => 97640)


--- trunk/Source/WebCore/page/Page.h	2011-10-17 20:03:57 UTC (rev 97639)
+++ trunk/Source/WebCore/page/Page.h	2011-10-17 20:15:01 UTC (rev 97640)
@@ -257,6 +257,9 @@
 
         void windowScreenDidChange(PlatformDisplayID);
         
+        void suspendScriptedAnimations();
+        void resumeScriptedAnimations();
+        
         void userStyleSheetLocationChanged();
         const String& userStyleSheet() const;
 

Modified: trunk/Source/WebKit/mac/ChangeLog (97639 => 97640)


--- trunk/Source/WebKit/mac/ChangeLog	2011-10-17 20:03:57 UTC (rev 97639)
+++ trunk/Source/WebKit/mac/ChangeLog	2011-10-17 20:15:01 UTC (rev 97640)
@@ -1,3 +1,17 @@
+2011-10-14  Chris Marrin  <[email protected]>
+
+        Throttle rate of requestAnimationFrame when page is not visible
+        https://bugs.webkit.org/show_bug.cgi?id=67873
+
+        Reviewed by Anders Carlsson.
+
+        Plumb through notification when the window is hidden/shown or
+        minimized/unminimized
+
+        * WebView/WebView.mm:
+        (-[WebView _windowWillOrderOnScreen:]):
+        (-[WebView _windowWillOrderOffScreen:]):
+
 2011-10-16  Adam Barth  <[email protected]>
 
         Always enable ENABLE(DOM_STORAGE)

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (97639 => 97640)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2011-10-17 20:03:57 UTC (rev 97639)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2011-10-17 20:15:01 UTC (rev 97640)
@@ -3326,6 +3326,9 @@
 
     // Send a change screen to make sure the initial displayID is set
     [self doWindowDidChangeScreen];
+
+    if (_private && _private->page)
+        _private->page->resumeScriptedAnimations();    
 }
 
 - (void)_windowDidChangeScreen:(NSNotification *)notification
@@ -3339,6 +3342,9 @@
     // This is needed because the normal NSWindowDidResignKeyNotification is not fired
     // for NSPopover windows since they share key with their parent window.
     [self _updateActiveState];
+    
+    if (_private && _private->page)
+        _private->page->suspendScriptedAnimations();    
 }
 
 - (void)_windowWillClose:(NSNotification *)notification

Modified: trunk/Source/WebKit2/ChangeLog (97639 => 97640)


--- trunk/Source/WebKit2/ChangeLog	2011-10-17 20:03:57 UTC (rev 97639)
+++ trunk/Source/WebKit2/ChangeLog	2011-10-17 20:15:01 UTC (rev 97640)
@@ -1,3 +1,17 @@
+2011-10-14  Chris Marrin  <[email protected]>
+
+        Throttle rate of requestAnimationFrame when page is not visible
+        https://bugs.webkit.org/show_bug.cgi?id=67873
+
+        Reviewed by Anders Carlsson.
+
+        Plumb through notification when the window is hidden/shown or
+        minimized/unminimized
+
+        * WebProcess/WebPage/DrawingAreaImpl.cpp:
+        (WebKit::DrawingAreaImpl::suspendPainting):
+        (WebKit::DrawingAreaImpl::resumePainting):
+
 2011-10-17  No'am Rosenthal  <[email protected]>
 
         [Qt][WK2] Synchronize tiling with accelerated compositing

Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp (97639 => 97640)


--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp	2011-10-17 20:03:57 UTC (rev 97639)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingAreaImpl.cpp	2011-10-17 20:15:01 UTC (rev 97640)
@@ -406,6 +406,8 @@
 
     m_isPaintingSuspended = true;
     m_displayTimer.stop();
+
+    m_webPage->corePage()->suspendScriptedAnimations();
 }
 
 void DrawingAreaImpl::resumePainting()
@@ -423,6 +425,8 @@
 
     // FIXME: We shouldn't always repaint everything here.
     setNeedsDisplay(m_webPage->bounds());
+
+    m_webPage->corePage()->resumeScriptedAnimations();
 }
 
 void DrawingAreaImpl::enterAcceleratedCompositingMode(GraphicsLayer* graphicsLayer)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to