Title: [116422] trunk/Source/WebKit2
Revision
116422
Author
[email protected]
Date
2012-05-08 07:59:58 -0700 (Tue, 08 May 2012)

Log Message

[WK2] Integrate Page Visibility state change and WK2 Suspend/Resume API
https://bugs.webkit.org/show_bug.cgi?id=85650

Patch by Jesus Sanchez-Palencia <[email protected]> on 2012-05-08
Reviewed by Kenneth Rohde Christiansen.

This patch uses state changes of the Page Visibility API to trigger the
automatic suspension/resume of animations on the WebPage and its main frame,
in the same fashion of what is used by the Suspend/Resume API of WebKit2.
By telling the WebPage it will move off/on the screen and the FrameView to
hide/show, this patch is suspending/resuming animations (animated painting)
but not timers and other active DOM objects.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setVisibilityState):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (116421 => 116422)


--- trunk/Source/WebKit2/ChangeLog	2012-05-08 14:42:48 UTC (rev 116421)
+++ trunk/Source/WebKit2/ChangeLog	2012-05-08 14:59:58 UTC (rev 116422)
@@ -1,3 +1,20 @@
+2012-05-08  Jesus Sanchez-Palencia  <[email protected]>
+
+        [WK2] Integrate Page Visibility state change and WK2 Suspend/Resume API
+        https://bugs.webkit.org/show_bug.cgi?id=85650
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        This patch uses state changes of the Page Visibility API to trigger the
+        automatic suspension/resume of animations on the WebPage and its main frame,
+        in the same fashion of what is used by the Suspend/Resume API of WebKit2.
+        By telling the WebPage it will move off/on the screen and the FrameView to
+        hide/show, this patch is suspending/resuming animations (animated painting)
+        but not timers and other active DOM objects.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::setVisibilityState):
+
 2012-05-08  Kenneth Rohde Christiansen  <[email protected]>
 
         [Qt] Add QML/WK2 evaluateJavaScript experimental API

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (116421 => 116422)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-05-08 14:42:48 UTC (rev 116421)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-05-08 14:59:58 UTC (rev 116422)
@@ -224,6 +224,9 @@
 #if PLATFORM(WIN)
     , m_gestureReachedScrollingLimit(false)
 #endif
+#if ENABLE(PAGE_VISIBILITY_API)
+    , m_visibilityState(WebCore::PageVisibilityStateVisible)
+#endif
 {
     ASSERT(m_pageID);
     // FIXME: This is a non-ideal location for this Setting and
@@ -3157,7 +3160,28 @@
 {
     if (!m_page)
         return;
-    m_page->setVisibilityState(static_cast<WebCore::PageVisibilityState>(visibilityState), isInitialState);
+
+    WebCore::PageVisibilityState state = static_cast<WebCore::PageVisibilityState>(visibilityState);
+
+    if (m_visibilityState == state)
+        return;
+
+    FrameView* view = m_page->mainFrame() ? m_page->mainFrame()->view() : 0;
+
+    if (state == WebCore::PageVisibilityStateVisible) {
+        m_page->didMoveOnscreen();
+        if (view)
+            view->show();
+    }
+
+    m_page->setVisibilityState(state, isInitialState);
+    m_visibilityState = state;
+
+    if (state == WebCore::PageVisibilityStateHidden) {
+        m_page->willMoveOffscreen();
+        if (view)
+            view->hide();
+    }
 }
 #endif
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (116421 => 116422)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2012-05-08 14:42:48 UTC (rev 116421)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2012-05-08 14:59:58 UTC (rev 116422)
@@ -52,6 +52,9 @@
 #include <WebCore/Editor.h>
 #include <WebCore/FrameLoaderTypes.h>
 #include <WebCore/IntRect.h>
+#if ENABLE(PAGE_VISIBILITY_API)
+#include <WebCore/PageVisibilityState.h>
+#endif
 #include <WebCore/PlatformScreen.h>
 #include <WebCore/ScrollTypes.h>
 #include <WebCore/WebCoreKeyboardUIMode.h>
@@ -828,6 +831,9 @@
 #if PLATFORM(QT)
     HashMap<String, QtNetworkReply*> m_applicationSchemeReplies;
 #endif
+#if ENABLE(PAGE_VISIBILITY_API)
+    WebCore::PageVisibilityState m_visibilityState;
+#endif
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to