Title: [113181] trunk/Source/WebKit2
Revision
113181
Author
[email protected]
Date
2012-04-04 06:10:28 -0700 (Wed, 04 Apr 2012)

Log Message

[WK2] Add Page Visibility API support
https://bugs.webkit.org/show_bug.cgi?id=81154

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

Use WebPageProxy::viewStateDidChange to correctly define the page's
visibilityState and then set it to the WebProcess. The WebKit2's based
ports just need to implement the related PageClient functions in order
to get this API enabled and working properly.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::initializeWebPage):
(WebKit::WebPageProxy::viewStateDidChange):
* WebProcess/WebPage/WebPage.cpp:
(WebKit):
(WebKit::WebPage::setVisibilityState):
* WebProcess/WebPage/WebPage.h:
(WebPage):
* WebProcess/WebPage/WebPage.messages.in:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (113180 => 113181)


--- trunk/Source/WebKit2/ChangeLog	2012-04-04 13:04:39 UTC (rev 113180)
+++ trunk/Source/WebKit2/ChangeLog	2012-04-04 13:10:28 UTC (rev 113181)
@@ -1,3 +1,26 @@
+2012-04-04  Jesus Sanchez-Palencia  <[email protected]>
+
+        [WK2] Add Page Visibility API support
+        https://bugs.webkit.org/show_bug.cgi?id=81154
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Use WebPageProxy::viewStateDidChange to correctly define the page's
+        visibilityState and then set it to the WebProcess. The WebKit2's based
+        ports just need to implement the related PageClient functions in order
+        to get this API enabled and working properly.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::initializeWebPage):
+        (WebKit::WebPageProxy::viewStateDidChange):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit):
+        (WebKit::WebPage::setVisibilityState):
+        * WebProcess/WebPage/WebPage.h:
+        (WebPage):
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2012-04-04  Kenneth Rohde Christiansen  <[email protected]>
 
         [Qt] Further improvements of the tap gesture recognizer

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (113180 => 113181)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-04-04 13:04:39 UTC (rev 113180)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-04-04 13:10:28 UTC (rev 113181)
@@ -204,6 +204,9 @@
     , m_renderTreeSize(0)
     , m_shouldSendEventsSynchronously(false)
     , m_mediaVolume(1)
+#if ENABLE(PAGE_VISIBILITY_API)
+    , m_visibilityState(PageVisibilityStateVisible)
+#endif
 {
 #ifndef NDEBUG
     webPageProxyCounter.increment();
@@ -345,6 +348,10 @@
 #endif
 
     process()->send(Messages::WebProcess::CreateWebPage(m_pageID, creationParameters()), 0);
+
+#if ENABLE(PAGE_VISIBILITY_API)
+    process()->send(Messages::WebPage::SetVisibilityState(m_visibilityState, /* isInitialState */ true), m_pageID);
+#endif
 }
 
 void WebPageProxy::close()
@@ -792,6 +799,18 @@
         }
     }
 
+#if ENABLE(PAGE_VISIBILITY_API)
+    PageVisibilityState visibilityState = PageVisibilityStateHidden;
+
+    if (m_pageClient->isViewVisible())
+        visibilityState = PageVisibilityStateVisible;
+
+    if (visibilityState != m_visibilityState) {
+        m_visibilityState = visibilityState;
+        process()->send(Messages::WebPage::SetVisibilityState(visibilityState, false), m_pageID);
+    }
+#endif
+
     updateBackingStoreDiscardableState();
 }
 

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (113180 => 113181)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2012-04-04 13:04:39 UTC (rev 113180)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2012-04-04 13:10:28 UTC (rev 113181)
@@ -1056,6 +1056,10 @@
 #if PLATFORM(QT)
     WTF::HashSet<RefPtr<QtRefCountedNetworkRequestData> > m_applicationSchemeRequests;
 #endif
+
+#if ENABLE(PAGE_VISIBILITY_API)
+    WebCore::PageVisibilityState m_visibilityState;
+#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (113180 => 113181)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-04-04 13:04:39 UTC (rev 113180)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2012-04-04 13:10:28 UTC (rev 113181)
@@ -3157,4 +3157,13 @@
     return 0;
 }
 
+#if ENABLE(PAGE_VISIBILITY_API)
+void WebPage::setVisibilityState(int visibilityState, bool isInitialState)
+{
+    if (!m_page)
+        return;
+    m_page->setVisibilityState(static_cast<WebCore::PageVisibilityState>(visibilityState), isInitialState);
+}
+#endif
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (113180 => 113181)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2012-04-04 13:04:39 UTC (rev 113180)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2012-04-04 13:10:28 UTC (rev 113181)
@@ -512,7 +512,11 @@
     void recomputeShortCircuitHorizontalWheelEventsState();
 
     bool willGoToBackForwardItemCallbackEnabled() const { return m_willGoToBackForwardItemCallbackEnabled; }
-    
+
+#if ENABLE(PAGE_VISIBILITY_API)
+    void setVisibilityState(int visibilityState, bool isInitialState);
+#endif
+
 private:
     WebPage(uint64_t pageID, const WebPageCreationParameters&);
 

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (113180 => 113181)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2012-04-04 13:04:39 UTC (rev 113180)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2012-04-04 13:10:28 UTC (rev 113181)
@@ -260,4 +260,8 @@
 #if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
     HandleAlternativeTextUIResult(String result)
 #endif
+
+#if ENABLE(PAGE_VISIBILITY_API)
+    SetVisibilityState(int visibilityState, bool isInitialState);
+#endif
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to