WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
page_visibility_api.patch (text/plain), 56.15 KB, created by
Shishir Agrawal
on 2011-05-04 18:46:37 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Shishir Agrawal
Created:
2011-05-04 18:46:37 PDT
Size:
56.15 KB
patch
obsolete
>diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 8c2b32c..8a74e09 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,25 @@ >+2011-05-04 Shishir Agrawal <shishir@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement Page Visibility API. >+ https://bugs.webkit.org/show_bug.cgi?id=54181 >+ >+ * fast/events/page-visibility-iframe-delete-test-expected.txt: Added. >+ * fast/events/page-visibility-iframe-delete-test.html: Added. >+ * fast/events/page-visibility-iframe-move-test-expected.txt: Added. >+ * fast/events/page-visibility-iframe-move-test.html: Added. >+ * fast/events/page-visibility-iframe-propagation-test-expected.txt: Added. >+ * fast/events/page-visibility-iframe-propagation-test.html: Added. >+ * fast/events/page-visibility-transition-test-expected.txt: Added. >+ * fast/events/page-visibility-transition-test.html: Added. >+ * fast/events/resources/page-visibility-iframe-delete-test-frame.html: Added. >+ * fast/events/resources/page-visibility-iframe-move-new-page.html: Added. >+ * platform/gtk/Skipped: >+ * platform/mac/Skipped: >+ * platform/qt/Skipped: >+ * platform/win/Skipped: >+ > 2011-05-03 Jer Noble <jer.noble@apple.com> > > Reviewed by Antti Koivisto. >diff --git a/LayoutTests/fast/events/page-visibility-iframe-delete-test-expected.txt b/LayoutTests/fast/events/page-visibility-iframe-delete-test-expected.txt >new file mode 100644 >index 0000000..1d20a39 >--- /dev/null >+++ b/LayoutTests/fast/events/page-visibility-iframe-delete-test-expected.txt >@@ -0,0 +1,12 @@ >+This test checks that the page visibility event proagation does not crash the browser when frames are added / deleted. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+Loaded all frames. >+Visibility of main document changed. >+Visibility of sub frame 2 changed. >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/events/page-visibility-iframe-delete-test.html b/LayoutTests/fast/events/page-visibility-iframe-delete-test.html >new file mode 100644 >index 0000000..d705f4f >--- /dev/null >+++ b/LayoutTests/fast/events/page-visibility-iframe-delete-test.html >@@ -0,0 +1,110 @@ >+<html> >+<body onload="startTest()"> >+ >+<p id="description"></p> >+<div id="console"></div> >+ >+<script src="../js/resources/js-test-pre.js"></script> >+ >+<script> >+ >+description("This test checks that the page visibility event proagation does not crash the browser when frames are added / deleted."); >+ >+window.jsTestIsAsync = true; >+window.successfullyParsed = false; >+ >+var numVisibilityChanges = 0; >+var frame1, frame2, frame3, frame4, frame5, subframe1, subFrame2, subFrame3; >+ >+var docsLoaded = 0; >+var mainPageVisibilityChangeDone = false; >+var frame2VisiblityChangeDone = false; >+ >+function startTest() { >+ ++docsLoaded; >+ if (docsLoaded < 8) { >+ return; >+ } >+ >+ debug("Loaded all frames."); >+ >+ frame1 = document.getElementById("topFrame1"); >+ frame2 = document.getElementById("topFrame2"); >+ frame3 = document.getElementById("topFrame3"); >+ frame4 = document.getElementById("topFrame4"); >+ subFrame1 = frame3.contentDocument.getElementById("subIframe1"); >+ subFrame2 = frame3.contentDocument.getElementById("subIframe2"); >+ >+ document.addEventListener( >+ "webkitvisibilitystatechange", onMainPageVisibilityChange, false); >+ frame2.contentDocument.addEventListener( >+ "webkitvisibilitystatechange", onFrame2VisibilityChange, false); >+ // Change the visibility of the current page to invisible. >+ if (window.layoutTestController) { >+ numVisibilityChanges++; >+ layoutTestController.setPageVisibility("hidden"); >+ } >+} >+ >+function finishTest() { >+ if (window.layoutTestController) >+ layoutTestController.resetPageVisibility(); >+ window.successfullyParsed = true; >+ finishJSTest(); >+} >+ >+function onMainPageVisibilityChange() { >+ if (mainPageVisibilityChangeDone && frame2VisiblityChangeDone) { >+ finishTest(); >+ } else if (!mainPageVisibilityChangeDone) { >+ debug("Visibility of main document changed."); >+ // Delete frame 4. >+ document.body.removeChild(frame4); >+ >+ // Delete subframe 2. >+ frame3.contentDocument.body.removeChild(subFrame2); >+ >+ // Add a new frame to top level. >+ frame5 = document.createElement("iframe"); >+ frame5.src = ''; >+ document.body.appendChild(frame5); >+ >+ // Add a new frame to frame2. >+ subFrame3 = frame2.contentDocument.createElement("iframe"); >+ subFrame3.src = ''; >+ frame2.contentDocument.body.appendChild(subFrame3); >+ >+ mainPageVisibilityChangeDone = true; >+ } >+ >+ if (mainPageVisibilityChangeDone && frame2VisiblityChangeDone) { >+ finishTest(); >+ } >+} >+ >+function onFrame2VisibilityChange() { >+ if (mainPageVisibilityChangeDone && frame2VisiblityChangeDone) { >+ finishTest(); >+ } else if (!frame2VisiblityChangeDone) { >+ debug("Visibility of sub frame 2 changed."); >+ >+ // Delete frame 1. >+ document.body.removeChild(frame1); >+ >+ frame2VisiblityChangeDone = true; >+ } >+ >+ if (mainPageVisibilityChangeDone && frame2VisiblityChangeDone) { >+ finishTest(); >+ } >+} >+</script> >+ >+<script src="../js/resources/js-test-post.js"></script> >+ >+<iframe id="topFrame1" onload="startTest()" ></iframe> >+<iframe id="topFrame2" onload="startTest()" ></iframe> >+<iframe id="topFrame3" onload="startTest()" src="resources/page-visibility-iframe-delete-test-frame.html"></iframe> >+<iframe id="topFrame4" onload="startTest()" ></iframe> >+</body> >+</html> >diff --git a/LayoutTests/fast/events/page-visibility-iframe-move-test-expected.txt b/LayoutTests/fast/events/page-visibility-iframe-move-test-expected.txt >new file mode 100644 >index 0000000..79440cf >--- /dev/null >+++ b/LayoutTests/fast/events/page-visibility-iframe-move-test-expected.txt >@@ -0,0 +1,21 @@ >+This test checks that an iframe that moves between pages with different visibility will have the correct visibility value. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+Window 1 Loaded >+Window 2 Loaded >+PASS window.document.webkitIsVisible is true >+PASS window2.document.webkitIsVisible is true >+PASS iframe.contentDocument.webkitIsVisible is true >+PASS window.document.webkitIsVisible is false >+PASS window2.document.webkitIsVisible is true >+PASS iframe.contentDocument.webkitIsVisible is true >+Adopted iframe to Window 1 >+PASS window.document.webkitIsVisible is false >+PASS window2.document.webkitIsVisible is true >+PASS iframe.contentDocument.webkitIsVisible is false >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/events/page-visibility-iframe-move-test.html b/LayoutTests/fast/events/page-visibility-iframe-move-test.html >new file mode 100644 >index 0000000..5abea87 >--- /dev/null >+++ b/LayoutTests/fast/events/page-visibility-iframe-move-test.html >@@ -0,0 +1,80 @@ >+<html> >+<body onload="startTest()"> >+ >+<p id="description"></p> >+<div id="console"></div> >+ >+<script src="../js/resources/js-test-pre.js"></script> >+ >+<script> >+ >+description("This test checks that an iframe that moves between pages with different visibility will have the correct visibility value."); >+ >+window.jsTestIsAsync = true; >+window.successfullyParsed = false; >+ >+var window2, iframe; >+var numVisibilityChanges = 0; >+ >+function window2Loaded() { >+ debug("Window 2 Loaded"); >+ >+ iframe = window2.document.getElementById("iframe"); >+ >+ shouldBeTrue("window.document.webkitIsVisible"); >+ shouldBeTrue("window2.document.webkitIsVisible"); >+ shouldBeTrue("iframe.contentDocument.webkitIsVisible"); >+ >+ // Change the visibility of the current page to invisible. >+ if (window.layoutTestController) { >+ numVisibilityChanges++; >+ window.layoutTestController.setPageVisibility("hidden"); >+ } >+} >+ >+function onVisibilityChange() { >+ shouldBeFalse("window.document.webkitIsVisible"); >+ shouldBeTrue("window2.document.webkitIsVisible"); >+ shouldBeTrue("iframe.contentDocument.webkitIsVisible"); >+ >+ window.document.adoptNode(iframe); >+ window.document.body.appendChild(iframe); >+ debug("Adopted iframe to Window 1"); >+ >+ shouldBeFalse("window.document.webkitIsVisible"); >+ shouldBeTrue("window2.document.webkitIsVisible"); >+ shouldBeFalse("iframe.contentDocument.webkitIsVisible"); >+ >+ window2.close(); >+ >+ window.successfullyParsed = true; >+ finishTest(); >+} >+ >+function startTest() { >+ if (window.layoutTestController) { >+ layoutTestController.waitUntilDone(); >+ layoutTestController.setCanOpenWindows(); >+ } >+ >+ debug("Window 1 Loaded"); >+ document.addEventListener("webkitvisibilitystatechange", >+ onVisibilityChange, false); >+ >+ window2 = window.open("resources/page-visibility-iframe-move-new-page.html"); >+ window2.addEventListener("load", window2Loaded, false); >+} >+ >+function finishTest() { >+ if (window.layoutTestController) { >+ layoutTestController.resetPageVisibility(); >+ } >+ finishJSTest(); >+} >+ >+</script> >+ >+<script src="../js/resources/js-test-post.js"></script> >+ >+</body> >+</html> >diff --git a/LayoutTests/fast/events/page-visibility-iframe-propagation-test-expected.txt b/LayoutTests/fast/events/page-visibility-iframe-propagation-test-expected.txt >new file mode 100644 >index 0000000..95b79ba >--- /dev/null >+++ b/LayoutTests/fast/events/page-visibility-iframe-propagation-test-expected.txt >@@ -0,0 +1,27 @@ >+This test checks that Page Visibility state events are propagated to child frames. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+Main Page: >+PASS document.webkitVisibilityState is "visible" >+PASS document.webkitIsVisible is true >+Child Frame: >+PASS childFrame.contentDocument.webkitVisibilityState is "visible" >+PASS childFrame.contentDocument.webkitIsVisible is true >+Main Page: >+PASS document.webkitVisibilityState is "hidden" >+PASS document.webkitIsVisible is false >+Child Frame: >+PASS childFrame.contentDocument.webkitVisibilityState is "hidden" >+PASS childFrame.contentDocument.webkitIsVisible is false >+Main Page: >+PASS document.webkitVisibilityState is "visible" >+PASS document.webkitIsVisible is true >+Child Frame: >+PASS childFrame.contentDocument.webkitVisibilityState is "visible" >+PASS childFrame.contentDocument.webkitIsVisible is true >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/events/page-visibility-iframe-propagation-test.html b/LayoutTests/fast/events/page-visibility-iframe-propagation-test.html >new file mode 100644 >index 0000000..2a8c5d0 >--- /dev/null >+++ b/LayoutTests/fast/events/page-visibility-iframe-propagation-test.html >@@ -0,0 +1,124 @@ >+<html> >+<body> >+ >+<p id="description"></p> >+<div id="console"></div> >+ >+<script src="../js/resources/js-test-pre.js"></script> >+ >+<script> >+ >+description("This test checks that Page Visibility state events are propagated to child frames."); >+ >+window.jsTestIsAsync = true; >+window.successfullyParsed = false; >+ >+function makePageVisible() { >+ if (window.layoutTestController) >+ layoutTestController.setPageVisibility("visible"); >+} >+ >+function makePageHidden() { >+ if (window.layoutTestController) >+ layoutTestController.setPageVisibility("hidden"); >+} >+ >+function checkIsPageVisible() { >+ debug("Main Page:"); >+ shouldBeEqualToString("document.webkitVisibilityState", "visible"); >+ shouldBeTrue("document.webkitIsVisible"); >+} >+ >+function checkIsPageHidden() { >+ debug("Main Page:"); >+ shouldBeEqualToString("document.webkitVisibilityState", "hidden"); >+ shouldBeFalse("document.webkitIsVisible"); >+} >+ >+function checkIsChildFrameVisible() { >+ debug("Child Frame:"); >+ shouldBeEqualToString("childFrame.contentDocument.webkitVisibilityState", >+ "visible"); >+ shouldBeTrue("childFrame.contentDocument.webkitIsVisible"); >+} >+ >+function checkIsChildFrameHidden() { >+ debug("Child Frame:"); >+ shouldBeEqualToString("childFrame.contentDocument.webkitVisibilityState", >+ "hidden"); >+ shouldBeFalse("childFrame.contentDocument.webkitIsVisible"); >+} >+ >+// We will try to change the visibility states as: >+// 0 - visible. (Initial - i.e. on load). >+// 1 - hidden >+// 2 - visible >+var numVisibilityChanges = 0; >+ >+var childFrame; >+ >+function startTest() { >+ childFrame = document.getElementById("childFrame"); >+ childFrame.contentDocument.addEventListener( >+ "webkitvisibilitystatechange", onChildFrameVisibilityChange, false); >+ document.addEventListener("webkitvisibilitystatechange", >+ onVisibilityChange, false); >+ >+ checkIsPageVisible(); >+ checkIsChildFrameVisible(); >+ >+ numVisibilityChanges++; >+ makePageHidden(); >+} >+ >+var numFinishes = 0; >+function finishTest() { >+ numFinishes++; >+ if (numFinishes < 2) { >+ return; >+ } >+ >+ if (window.layoutTestController) { >+ layoutTestController.resetPageVisibility(); >+ } >+ finishJSTest(); >+} >+ >+function onVisibilityChange() { >+ if (numVisibilityChanges == 1) { >+ checkIsPageHidden(); >+ return; >+ } else if (numVisibilityChanges == 2) { >+ checkIsPageVisible(); >+ window.successfullyParsed = true; >+ finishTest(); >+ return; >+ } else { >+ testFailed("Too many visibility transitions"); >+ finishTest(); >+ return; >+ } >+} >+ >+function onChildFrameVisibilityChange() { >+ if (numVisibilityChanges == 1) { >+ checkIsChildFrameHidden(); >+ numVisibilityChanges++; >+ makePageVisible(); >+ return; >+ } else if (numVisibilityChanges == 2) { >+ checkIsChildFrameVisible(); >+ finishTest(); >+ return; >+ } else { >+ testFailed("Child Frame: Too many visibility transitions"); >+ finishTest(); >+ } >+} >+</script> >+ >+<script src="../js/resources/js-test-post.js"></script> >+ >+<iframe id="childFrame" onload="startTest()"></iframe> >+</body> >+</html> >diff --git a/LayoutTests/fast/events/page-visibility-transition-test-expected.txt b/LayoutTests/fast/events/page-visibility-transition-test-expected.txt >new file mode 100644 >index 0000000..25a9b5e >--- /dev/null >+++ b/LayoutTests/fast/events/page-visibility-transition-test-expected.txt >@@ -0,0 +1,17 @@ >+This test checks that Page Visibility state values are correct and the event changes are fired correctly. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS document.webkitVisibilityState is "visible" >+PASS document.webkitIsVisible is true >+PASS document.webkitVisibilityState is "hidden" >+PASS document.webkitIsVisible is false >+PASS document.webkitVisibilityState is "hidden" >+PASS document.webkitIsVisible is false >+PASS document.webkitVisibilityState is "visible" >+PASS document.webkitIsVisible is true >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/events/page-visibility-transition-test.html b/LayoutTests/fast/events/page-visibility-transition-test.html >new file mode 100644 >index 0000000..814508e >--- /dev/null >+++ b/LayoutTests/fast/events/page-visibility-transition-test.html >@@ -0,0 +1,88 @@ >+<html> >+<body onload='startTest()'> >+ >+<p id="description"></p> >+<div id="console"></div> >+ >+<script src="../js/resources/js-test-pre.js"></script> >+ >+<script> >+ >+description("This test checks that Page Visibility state values are correct and the event changes are fired correctly."); >+ >+window.jsTestIsAsync = true; >+window.successfullyParsed = false; >+ >+function makePageVisible() { >+ if (window.layoutTestController) >+ layoutTestController.setPageVisibility("visible"); >+} >+ >+function makePageHidden() { >+ if (window.layoutTestController) >+ layoutTestController.setPageVisibility("hidden"); >+} >+ >+function checkIsPageVisible() { >+ shouldBeEqualToString("document.webkitVisibilityState", "visible"); >+ shouldBeTrue("document.webkitIsVisible"); >+} >+ >+function checkIsPageHidden() { >+ shouldBeEqualToString("document.webkitVisibilityState", "hidden"); >+ shouldBeFalse("document.webkitIsVisible"); >+} >+ >+// We will try to change the visibility states as: >+// 0 - visible. (Initial - i.e. on load). >+// 1 - hidden (should fire event). >+// 2 - hidden (no event). >+// 3 - visible (should fire event). >+var numVisibilityChanges = 0; >+ >+function startTest() { >+ document.addEventListener( >+ "webkitvisibilitystatechange", onVisibilityChange, false); >+ checkIsPageVisible(); >+ numVisibilityChanges++; >+ makePageHidden(); >+} >+ >+function finishTest() { >+ if (window.layoutTestController) { >+ layoutTestController.resetPageVisibility(); >+ } >+ finishJSTest(); >+} >+ >+function onVisibilityChange() { >+ if (numVisibilityChanges == 1) { >+ checkIsPageHidden(); >+ numVisibilityChanges++; >+ makePageHidden(); >+ checkIsPageHidden(); >+ numVisibilityChanges++; >+ makePageVisible(); >+ return; >+ } else if (numVisibilityChanges == 2) { >+ testFailed("Invalid event fired on same state change."); >+ finishTest(); >+ return; >+ } else if (numVisibilityChanges == 3) { >+ checkIsPageVisible(); >+ numVisibilityChanges++; >+ window.successfullyParsed = true; >+ finishTest(); >+ return; >+ } else { >+ testFailed("Too many visibility transitions"); >+ finishTest(); >+ return; >+ } >+} >+</script> >+ >+<script src="../js/resources/js-test-post.js"></script> >+ >+</body> >+</html> >diff --git a/LayoutTests/fast/events/resources/page-visibility-iframe-delete-test-frame.html b/LayoutTests/fast/events/resources/page-visibility-iframe-delete-test-frame.html >new file mode 100644 >index 0000000..febb954 >--- /dev/null >+++ b/LayoutTests/fast/events/resources/page-visibility-iframe-delete-test-frame.html >@@ -0,0 +1,6 @@ >+<html> >+<body onload="parent.startTest()"> >+<iframe id="subIframe1" onload="parent.parent.startTest()"></iframe> >+<iframe id="subIframe2" onload="parent.parent.startTest()"></iframe> >+</body> >+</html> >diff --git a/LayoutTests/fast/events/resources/page-visibility-iframe-move-new-page.html b/LayoutTests/fast/events/resources/page-visibility-iframe-move-new-page.html >new file mode 100644 >index 0000000..6d28ccc >--- /dev/null >+++ b/LayoutTests/fast/events/resources/page-visibility-iframe-move-new-page.html >@@ -0,0 +1,5 @@ >+<html> >+<body> >+<iframe id="iframe"></iframe> >+</body> >+</html> >diff --git a/LayoutTests/platform/gtk/Skipped b/LayoutTests/platform/gtk/Skipped >index aa21a74..683b540 100644 >--- a/LayoutTests/platform/gtk/Skipped >+++ b/LayoutTests/platform/gtk/Skipped >@@ -1412,3 +1412,7 @@ tables/mozilla_expected_failures/bugs/bug85016.html > # HTTP 204 (No Content) should be ignored > # https://bugs.webkit.org/show_bug.cgi?id=60206 > http/tests/navigation/response204.html >+ >+# This platform does not support the Page Visibility API. >+fast/events/page-visibility-iframe-test.html >+fast/events/page-visibility-transition-test.html >diff --git a/LayoutTests/platform/mac/Skipped b/LayoutTests/platform/mac/Skipped >index 4f4c217..3686cb4 100644 >--- a/LayoutTests/platform/mac/Skipped >+++ b/LayoutTests/platform/mac/Skipped >@@ -351,3 +351,7 @@ animations/animation-api-1.html > # HTTP 204 (No Content) should be ignored > # https://bugs.webkit.org/show_bug.cgi?id=60206 > http/tests/navigation/response204.html >+ >+# This platform does not support the Page Visibility API. >+fast/events/page-visibility-iframe-test.html >+fast/events/page-visibility-transition-test.html >diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped >index e5d2c27..7c10ed2 100644 >--- a/LayoutTests/platform/qt/Skipped >+++ b/LayoutTests/platform/qt/Skipped >@@ -2696,3 +2696,7 @@ http/tests/security/contentSecurityPolicy/media-src-blocked.html > > # Animation API is disabled by default > animations/animation-api-1.html >+ >+# This platform does not support the Page Visibility API. >+fast/events/page-visibility-iframe-test.html >+fast/events/page-visibility-transition-test.html >diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped >index 9076f0a..ec5e104 100644 >--- a/LayoutTests/platform/win/Skipped >+++ b/LayoutTests/platform/win/Skipped >@@ -1282,3 +1282,7 @@ animations/animation-api-1.html > # HTTP 204 (No Content) should be ignored > # https://bugs.webkit.org/show_bug.cgi?id=60206 > http/tests/navigation/response204.html >+ >+# This platform does not support the Page Visibility API. >+fast/events/page-visibility-iframe-test.html >+fast/events/page-visibility-transition-test.html >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index d1afd65..92d09b9 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -1011,6 +1011,7 @@ SET(WebCore_SOURCES > page/PageGroup.cpp > page/PageGroupLoadDeferrer.cpp > page/PageSerializer.cpp >+ page/PageVisibilityState.cpp > page/Performance.cpp > page/PerformanceNavigation.cpp > page/PerformanceTiming.cpp >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index ebc6e64..f146e73 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,41 @@ >+2011-05-04 Shishir Agrawal <shishir@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement Page Visibility API. >+ https://bugs.webkit.org/show_bug.cgi?id=54181 >+ >+ Tests: fast/events/page-visibility-iframe-delete-test.html >+ fast/events/page-visibility-iframe-move-test.html >+ fast/events/page-visibility-iframe-propagation-test.html >+ fast/events/page-visibility-transition-test.html >+ >+ * CMakeLists.txt: >+ * GNUmakefile.list.am: >+ * WebCore.gypi: >+ * WebCore.pro: >+ * WebCore.vcproj/WebCore.vcproj: >+ * WebCore.xcodeproj/project.pbxproj: >+ * dom/Document.cpp: >+ (WebCore::Document::visibilityState): >+ (WebCore::Document::webkitVisibilityState): >+ (WebCore::Document::webkitIsVisible): >+ (WebCore::Document::dispatchVisibilityStateChangeEvent): >+ * dom/Document.h: >+ * dom/Document.idl: >+ * dom/EventNames.h: >+ * page/Frame.cpp: >+ (WebCore::Frame::dispatchVisibilityStateChangeEvent): >+ * page/Frame.h: >+ * page/Page.cpp: >+ (WebCore::Page::Page): >+ (WebCore::Page::setVisibilityState): >+ (WebCore::Page::visibilityState): >+ * page/Page.h: >+ * page/PageVisibilityState.cpp: Added. >+ (WebCore::GetPageVisibilityStateString): >+ * page/PageVisibilityState.h: Added. >+ > 2011-05-03 Jer Noble <jer.noble@apple.com> > > Reviewed by Antti Koivisto. >diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am >index 825de4d..92ea113 100644 >--- a/Source/WebCore/GNUmakefile.list.am >+++ b/Source/WebCore/GNUmakefile.list.am >@@ -2220,6 +2220,8 @@ webcore_sources += \ > Source/WebCore/page/PageGroupLoadDeferrer.h \ > Source/WebCore/page/PageSerializer.cpp \ > Source/WebCore/page/PageSerializer.h \ >+ Source/WebCore/page/PageVisibilityState.cpp \ >+ Source/WebCore/page/PageVisibilityState.h \ > Source/WebCore/page/Performance.cpp \ > Source/WebCore/page/Performance.h \ > Source/WebCore/page/PerformanceNavigation.cpp \ >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index bb4a3fa..fe7a01e 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -711,6 +711,7 @@ > 'page/Page.h', > 'page/PageGroup.h', > 'page/PageSerializer.h', >+ 'page/PageVisibilityState.h', > 'page/PluginHalterClient.h', > 'page/PositionCallback.h', > 'page/PositionError.h', >@@ -3434,6 +3435,7 @@ > 'page/PageGroupLoadDeferrer.cpp', > 'page/PageGroupLoadDeferrer.h', > 'page/PageSerializer.cpp', >+ 'page/PageVisibilityState.cpp', > 'page/Performance.cpp', > 'page/Performance.h', > 'page/PerformanceNavigation.cpp', >diff --git a/Source/WebCore/WebCore.pro b/Source/WebCore/WebCore.pro >index f0babbc..87f51f6 100644 >--- a/Source/WebCore/WebCore.pro >+++ b/Source/WebCore/WebCore.pro >@@ -921,6 +921,7 @@ SOURCES += \ > page/PageGroup.cpp \ > page/PageGroupLoadDeferrer.cpp \ > page/PageSerializer.cpp \ >+ page/PageVisibilityState.cpp \ > page/Performance.cpp \ > page/PerformanceNavigation.cpp \ > page/PerformanceTiming.cpp \ >@@ -1861,6 +1862,7 @@ HEADERS += \ > page/PageGroupLoadDeferrer.h \ > page/Page.h \ > page/PageSerializer.h \ >+ page/PageVisibilityState.h \ > page/PluginHalter.h \ > page/PluginHalterClient.h \ > page/PrintContext.h \ >diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj >index 72ed781..45ca3ef 100755 >--- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj >+++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj >@@ -24750,6 +24750,12 @@ > > > </File> > <File >+ RelativePath="..\page\PageVisibilityState.cpp" >+ > >+ <File >+ RelativePath="..\page\PageVisibilityState.h" >+ > >+ <File > RelativePath="..\page\Performance.cpp" > > > </File> >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index a73a354..5334306 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -5924,6 +5924,8 @@ > FE80DA660E9C4703000D6F75 /* JSGeoposition.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80DA620E9C4703000D6F75 /* JSGeoposition.h */; }; > FE80DA710E9C472F000D6F75 /* JSPositionError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE80DA6D0E9C472F000D6F75 /* JSPositionError.cpp */; }; > FE80DA720E9C472F000D6F75 /* JSPositionError.h in Headers */ = {isa = PBXBuildFile; fileRef = FE80DA6E0E9C472F000D6F75 /* JSPositionError.h */; }; >+ FFD5B97A135CC97800D5E92A /* PageVisibilityState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FFD5B977135CC97800D5E92A /* PageVisibilityState.cpp */; }; >+ FFD5B97B135CC97800D5E92A /* PageVisibilityState.h in Headers */ = {isa = PBXBuildFile; fileRef = FFD5B978135CC97800D5E92A /* PageVisibilityState.h */; settings = {ATTRIBUTES = (Private, ); }; }; > /* End PBXBuildFile section */ > > /* Begin PBXContainerItemProxy section */ >@@ -12443,6 +12445,8 @@ > FE80DA620E9C4703000D6F75 /* JSGeoposition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGeoposition.h; sourceTree = "<group>"; }; > FE80DA6D0E9C472F000D6F75 /* JSPositionError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPositionError.cpp; sourceTree = "<group>"; }; > FE80DA6E0E9C472F000D6F75 /* JSPositionError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPositionError.h; sourceTree = "<group>"; }; >+ FFD5B977135CC97800D5E92A /* PageVisibilityState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageVisibilityState.cpp; sourceTree = "<group>"; }; >+ FFD5B978135CC97800D5E92A /* PageVisibilityState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageVisibilityState.h; sourceTree = "<group>"; }; > /* End PBXFileReference section */ > > /* Begin PBXFrameworksBuildPhase section */ >@@ -14168,6 +14172,8 @@ > 7A674BDA0F9EBF4E006CF099 /* PageGroupLoadDeferrer.h */, > 371E65CD13661EED00BEEDB0 /* PageSerializer.cpp */, > 371E65CB13661EDC00BEEDB0 /* PageSerializer.h */, >+ FFD5B977135CC97800D5E92A /* PageVisibilityState.cpp */, >+ FFD5B978135CC97800D5E92A /* PageVisibilityState.h */, > 8A844D0111D3C18E0014065C /* Performance.cpp */, > 8A844D0211D3C18E0014065C /* Performance.h */, > 8A844D0311D3C18E0014065C /* Performance.idl */, >@@ -21869,6 +21875,7 @@ > F34742E51343633C00531BC2 /* PageScriptDebugServer.h in Headers */, > 371E65CC13661EDC00BEEDB0 /* PageSerializer.h in Headers */, > E1284AE110447D4500EAEB52 /* PageTransitionEvent.h in Headers */, >+ FFD5B97B135CC97800D5E92A /* PageVisibilityState.h in Headers */, > 51E1ECC30C91C90400DC255B /* PageURLRecord.h in Headers */, > 0885067F11DA045B00182B98 /* PaintInfo.h in Headers */, > 0885068011DA045B00182B98 /* PaintPhase.h in Headers */, >@@ -24734,6 +24741,7 @@ > 371E65CE13661EED00BEEDB0 /* PageSerializer.cpp in Sources */, > E1284AEA10447DEE00EAEB52 /* PageTransitionEvent.cpp in Sources */, > 51E1ECC20C91C90400DC255B /* PageURLRecord.cpp in Sources */, >+ FFD5B97A135CC97800D5E92A /* PageVisibilityState.cpp in Sources */, > FD3160A212B026F700C1A359 /* Panner.cpp in Sources */, > F55B3DC91251F12D003EF269 /* PasswordInputType.cpp in Sources */, > 4B2709830AF2E5E00065127F /* PasteboardMac.mm in Sources */, >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index 5bcea73..34bcdfd 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -1354,6 +1354,34 @@ void Document::removeTitle(Element* titleElement) > updateTitle(StringWithDirection()); > } > >+#if ENABLE(PAGE_VISIBILITY_API) >+PageVisibilityState Document::visibilityState() const >+{ >+ // The visibility of the document is inherited from the visibility of the >+ // page. If there is no page associated with the document, we will assume >+ // that the page is visible i.e. invisibility has to be explicitly >+ // specified by the embedder. >+ if (!m_frame || !m_frame->page()) >+ return PageVisibilityStateVisible; >+ return m_frame->page()->visibilityState(); >+} >+ >+String Document::webkitVisibilityState() const >+{ >+ return GetPageVisibilityStateString(visibilityState()); >+} >+ >+bool Document::webkitIsVisible() const >+{ >+ return visibilityState() == PageVisibilityStateVisible; >+} >+ >+void Document::dispatchVisibilityStateChangeEvent() >+{ >+ dispatchEvent(Event::create(eventNames().webkitvisibilitystatechangeEvent, false, false)); >+} >+#endif >+ > String Document::nodeName() const > { > return "#document"; >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index 2315e79..71b7af7 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -34,6 +34,7 @@ > #include "DOMTimeStamp.h" > #include "DocumentTiming.h" > #include "IconURL.h" >+#include "PageVisibilityState.h" > #include "QualifiedName.h" > #include "ScriptExecutionContext.h" > #include "StringWithDirection.h" >@@ -304,6 +305,9 @@ public: > #if ENABLE(FULLSCREEN_API) > DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitfullscreenchange); > #endif >+#if ENABLE(PAGE_VISIBILITY_API) >+ DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitvisibilitystatechange); >+#endif > > ViewportArguments viewportArguments() const { return m_viewportArguments; } > >@@ -379,6 +383,12 @@ public: > > virtual KURL baseURI() const; > >+#if ENABLE(PAGE_VISIBILITY_API) >+ String webkitVisibilityState() const; >+ bool webkitIsVisible() const; >+ void dispatchVisibilityStateChangeEvent(); >+#endif >+ > PassRefPtr<Node> adoptNode(PassRefPtr<Node> source, ExceptionCode&); > > PassRefPtr<HTMLCollection> images(); >@@ -1132,6 +1142,10 @@ private: > > void loadEventDelayTimerFired(Timer<Document>*); > >+#if ENABLE(PAGE_VISIBILITY_API) >+ PageVisibilityState visibilityState() const; >+#endif >+ > int m_guardRefCount; > > OwnPtr<CSSStyleSelector> m_styleSelector; >diff --git a/Source/WebCore/dom/Document.idl b/Source/WebCore/dom/Document.idl >index 5cfab24..89ae65e 100644 >--- a/Source/WebCore/dom/Document.idl >+++ b/Source/WebCore/dom/Document.idl >@@ -334,6 +334,10 @@ module core { > boolean isHTMLDocument(); > #endif > >+ // Page visibility API. >+ readonly attribute [Conditional=PAGE_VISIBILITY_API] DOMString webkitVisibilityState; >+ readonly attribute [Conditional=PAGE_VISIBILITY_API] boolean webkitIsVisible; >+ > }; > > } >diff --git a/Source/WebCore/dom/EventNames.h b/Source/WebCore/dom/EventNames.h >index ece2a08..96f0383 100644 >--- a/Source/WebCore/dom/EventNames.h >+++ b/Source/WebCore/dom/EventNames.h >@@ -106,6 +106,7 @@ namespace WebCore { > macro(unload) \ > macro(updateready) \ > macro(versionchange) \ >+ macro(webkitvisibilitystatechange) \ > macro(write) \ > macro(writeend) \ > macro(writestart) \ >diff --git a/Source/WebCore/page/Frame.cpp b/Source/WebCore/page/Frame.cpp >index e835948..4824647 100644 >--- a/Source/WebCore/page/Frame.cpp >+++ b/Source/WebCore/page/Frame.cpp >@@ -718,6 +718,16 @@ void Frame::setDOMWindow(DOMWindow* domWindow) > m_domWindow = domWindow; > } > >+#if ENABLE(PAGE_VISIBILITY_API) >+void Frame::dispatchVisibilityStateChangeEvent() >+{ >+ if (m_doc) >+ m_doc->dispatchVisibilityStateChangeEvent(); >+ for (Frame* child = tree()->firstChild(); child; child = child->tree()->nextSibling()) >+ child->dispatchVisibilityStateChangeEvent(); >+} >+#endif >+ > DOMWindow* Frame::domWindow() const > { > if (!m_domWindow) >diff --git a/Source/WebCore/page/Frame.h b/Source/WebCore/page/Frame.h >index 2d76aee..8693253 100644 >--- a/Source/WebCore/page/Frame.h >+++ b/Source/WebCore/page/Frame.h >@@ -119,6 +119,10 @@ namespace WebCore { > > void transferChildFrameToNewDocument(); > >+#if ENABLE(PAGE_VISIBILITY_API) >+ void dispatchVisibilityStateChangeEvent(); >+#endif >+ > // ======== All public functions below this point are candidates to move out of Frame into another class. ======== > > bool isDisconnected() const; >diff --git a/Source/WebCore/page/Page.cpp b/Source/WebCore/page/Page.cpp >index 76642f8..4b88a8a 100644 >--- a/Source/WebCore/page/Page.cpp >+++ b/Source/WebCore/page/Page.cpp >@@ -163,6 +163,9 @@ Page::Page(const PageClients& pageClients) > , m_viewMode(ViewModeWindowed) > , m_minimumTimerInterval(Settings::defaultMinDOMTimerInterval()) > , m_isEditable(false) >+#if ENABLE(PAGE_VISIBILITY_API) >+ , m_visibilityState(PageVisibilityStateVisible) >+#endif > { > if (!allPages) { > allPages = new HashSet<Page*>; >@@ -934,6 +937,23 @@ void Page::checkFrameCountConsistency() const > } > #endif > >+#if ENABLE(PAGE_VISIBILITY_API) >+void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitialState) >+{ >+ if (m_visibilityState == visibilityState) >+ return; >+ m_visibilityState = visibilityState; >+ >+ if (!isInitialState && m_mainFrame) >+ m_mainFrame->dispatchVisibilityStateChangeEvent(); >+} >+ >+PageVisibilityState Page::visibilityState() const >+{ >+ return m_visibilityState; >+} >+#endif >+ > Page::PageClients::PageClients() > : chromeClient(0) > , contextMenuClient(0) >diff --git a/Source/WebCore/page/Page.h b/Source/WebCore/page/Page.h >index 60193fb..ea3f1d5 100644 >--- a/Source/WebCore/page/Page.h >+++ b/Source/WebCore/page/Page.h >@@ -23,6 +23,7 @@ > > #include "FrameLoaderTypes.h" > #include "FindOptions.h" >+#include "PageVisibilityState.h" > #include "PlatformString.h" > #include "ViewportArguments.h" > #include <wtf/Forward.h> >@@ -300,6 +301,11 @@ namespace WebCore { > void setEditable(bool isEditable) { m_isEditable = isEditable; } > bool isEditable() { return m_isEditable; } > >+#if ENABLE(PAGE_VISIBILITY_API) >+ PageVisibilityState visibilityState() const; >+ void setVisibilityState(PageVisibilityState, bool); >+#endif >+ > private: > void initGroup(); > >@@ -405,6 +411,10 @@ namespace WebCore { > OwnPtr<ScrollableAreaSet> m_scrollableAreaSet; > > bool m_isEditable; >+ >+#if ENABLE(PAGE_VISIBILITY_API) >+ PageVisibilityState m_visibilityState; >+#endif > }; > > } // namespace WebCore >diff --git a/Source/WebCore/page/PageVisibilityState.cpp b/Source/WebCore/page/PageVisibilityState.cpp >new file mode 100644 >index 0000000..fe18dfa >--- /dev/null >+++ b/Source/WebCore/page/PageVisibilityState.cpp >@@ -0,0 +1,56 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "PageVisibilityState.h" >+ >+#if ENABLE(PAGE_VISIBILITY_API) >+ >+namespace WebCore { >+ >+String GetPageVisibilityStateString(PageVisibilityState state) >+{ >+ DEFINE_STATIC_LOCAL(const String, visible, ("visible")); >+ DEFINE_STATIC_LOCAL(const String, hidden, ("hidden")); >+ >+ switch (state) { >+ case PageVisibilityStateVisible: >+ return visible; >+ case PageVisibilityStateHidden: >+ return hidden; >+ } >+ >+ ASSERT_NOT_REACHED(); >+ return String(); >+} >+ >+} // namespace WebCore >+ >+#endif // if ENABLE(PAGE_VISIBILITY_API) >diff --git a/Source/WebCore/page/PageVisibilityState.h b/Source/WebCore/page/PageVisibilityState.h >new file mode 100644 >index 0000000..a7d7021 >--- /dev/null >+++ b/Source/WebCore/page/PageVisibilityState.h >@@ -0,0 +1,51 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef PageVisibilityState_h >+#define PageVisibilityState_h >+ >+#include <wtf/text/WTFString.h> >+ >+namespace WebCore { >+ >+// The enum is not flag protected as it is used in the WebKit chromium API >+// without flag protection. >+enum PageVisibilityState { >+ PageVisibilityStateVisible, >+ PageVisibilityStateHidden >+}; >+ >+#if ENABLE(PAGE_VISIBILITY_API) >+String GetPageVisibilityStateString(PageVisibilityState); >+#endif >+ >+} // namespace WebCore >+ >+#endif // ifndef PageVisibilityState_h >diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog >index 3ca088d..51a5a73 100644 >--- a/Source/WebKit/chromium/ChangeLog >+++ b/Source/WebKit/chromium/ChangeLog >@@ -1,3 +1,22 @@ >+2011-05-04 Shishir Agrawal <shishir@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement Page Visibility API. >+ https://bugs.webkit.org/show_bug.cgi?id=54181 >+ >+ * WebKit.gyp: >+ * features.gypi: >+ * public/WebPageVisibilityState.h: Added. >+ * public/WebView.h: >+ (WebKit::WebView::setVisibilityState): >+ * public/WebViewClient.h: >+ (WebKit::WebViewClient::visibilityState): >+ * src/WebViewImpl.cpp: >+ (WebKit::WebViewImpl::WebViewImpl): >+ (WebKit::WebViewImpl::setVisibilityState): >+ * src/WebViewImpl.h: >+ > 2011-05-04 Nate Chapin <japhet@chromium.org> > > Reviewed by Mihai Parparita. >diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp >index 3e0b0d9..a6e9b27 100644 >--- a/Source/WebKit/chromium/WebKit.gyp >+++ b/Source/WebKit/chromium/WebKit.gyp >@@ -227,6 +227,7 @@ > 'public/WebOptionElement.h', > 'public/WebPageSerializer.h', > 'public/WebPageSerializerClient.h', >+ 'public/WebPageVisibilityState.h', > 'public/WebPasswordAutocompleteListener.h', > 'public/WebPasswordFormData.h', > 'public/WebPerformance.h', >diff --git a/Source/WebKit/chromium/features.gypi b/Source/WebKit/chromium/features.gypi >index 510fbe6..1448f9b 100644 >--- a/Source/WebKit/chromium/features.gypi >+++ b/Source/WebKit/chromium/features.gypi >@@ -75,7 +75,7 @@ > 'ENABLE_OFFLINE_WEB_APPLICATIONS=1', > 'ENABLE_OPENTYPE_SANITIZER=1', > 'ENABLE_ORIENTATION_EVENTS=0', >- 'ENABLE_PAGE_VISIBILITY_API=0', >+ 'ENABLE_PAGE_VISIBILITY_API=1', > 'ENABLE_PROGRESS_TAG=1', > 'ENABLE_QUOTA=1', > 'ENABLE_REGISTER_PROTOCOL_HANDLER=0', >diff --git a/Source/WebKit/chromium/public/WebPageVisibilityState.h b/Source/WebKit/chromium/public/WebPageVisibilityState.h >new file mode 100644 >index 0000000..5474be4 >--- /dev/null >+++ b/Source/WebKit/chromium/public/WebPageVisibilityState.h >@@ -0,0 +1,45 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef WebPageVisibilityState_h >+#define WebPageVisibilityState_h >+ >+namespace WebKit { >+ >+// The following enum should be consistent with the PageVisibilityState enum >+// defined in WebCore. >+enum WebPageVisibilityState { >+ WebPageVisibilityStateVisible, >+ WebPageVisibilityStateHidden >+}; >+ >+} // namespace WebKit >+ >+#endif >diff --git a/Source/WebKit/chromium/public/WebView.h b/Source/WebKit/chromium/public/WebView.h >index 3e9b3d6..4a3ab58 100644 >--- a/Source/WebKit/chromium/public/WebView.h >+++ b/Source/WebKit/chromium/public/WebView.h >@@ -32,6 +32,7 @@ > #define WebView_h > > #include "WebDragOperation.h" >+#include "WebPageVisibilityState.h" > #include "WebString.h" > #include "WebVector.h" > #include "WebWidget.h" >@@ -357,6 +358,12 @@ public: > // APIs. > virtual WebGraphicsContext3D* graphicsContext3D() = 0; > >+ // Visibility ----------------------------------------------------------- >+ >+ // Sets the visibility of the WebView. >+ virtual void setVisibilityState(WebPageVisibilityState visibilityState, >+ bool isInitialState) { } >+ > protected: > ~WebView() {} > }; >diff --git a/Source/WebKit/chromium/public/WebViewClient.h b/Source/WebKit/chromium/public/WebViewClient.h >index 5174351..f3be3ca 100644 >--- a/Source/WebKit/chromium/public/WebViewClient.h >+++ b/Source/WebKit/chromium/public/WebViewClient.h >@@ -36,6 +36,7 @@ > #include "WebEditingAction.h" > #include "WebFileChooserCompletion.h" > #include "WebFileChooserParams.h" >+#include "WebPageVisibilityState.h" > #include "WebPopupType.h" > #include "WebString.h" > #include "WebTextAffinity.h" >@@ -315,6 +316,14 @@ public: > const WebString& url, > const WebString& title) { } > >+ // Visibility ----------------------------------------------------------- >+ >+ // Returns the current visibility of the WebView. >+ virtual WebPageVisibilityState visibilityState() const >+ { >+ return WebPageVisibilityStateVisible; >+ } >+ > protected: > ~WebViewClient() { } > }; >diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp >index cb02466..abbf72e 100644 >--- a/Source/WebKit/chromium/src/WebViewImpl.cpp >+++ b/Source/WebKit/chromium/src/WebViewImpl.cpp >@@ -366,6 +366,10 @@ WebViewImpl::WebViewImpl(WebViewClient* client) > > m_page->setGroupName(pageGroupName); > >+#if ENABLE(PAGE_VISIBILITY_API) >+ setVisibilityState(m_client->visibilityState(), true); >+#endif >+ > m_inspectorSettingsMap = adoptPtr(new SettingsMap); > } > >@@ -2560,4 +2564,24 @@ WebGraphicsContext3D* WebViewImpl::graphicsContext3D() > return 0; > } > >+ >+void WebViewImpl::setVisibilityState(WebPageVisibilityState visibilityState, >+ bool isInitialState) { >+#if ENABLE(PAGE_VISIBILITY_API) >+ if (!page()) >+ return; >+ >+ switch (visibilityState) { >+ case WebPageVisibilityStateVisible: >+ m_page->setVisibilityState(PageVisibilityStateVisible, isInitialState); >+ return; >+ case WebPageVisibilityStateHidden: >+ m_page->setVisibilityState(PageVisibilityStateHidden, isInitialState); >+ return; >+ default: >+ ASSERT_NOT_REACHED(); >+ } >+#endif >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/chromium/src/WebViewImpl.h b/Source/WebKit/chromium/src/WebViewImpl.h >index d8d92a8..f290827 100644 >--- a/Source/WebKit/chromium/src/WebViewImpl.h >+++ b/Source/WebKit/chromium/src/WebViewImpl.h >@@ -355,6 +355,8 @@ public: > // WebGL. Returns 0 if compositing support is not compiled in. > virtual WebGraphicsContext3D* graphicsContext3D(); > >+ virtual void setVisibilityState(WebPageVisibilityState, bool); >+ > WebCore::PopupContainer* selectPopup() const { return m_selectPopup.get(); } > > // Returns true if the event leads to scrolling. >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 7f40e16..89a3b91 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,23 @@ >+2011-05-04 Shishir Agrawal <shishir@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement Page Visibility API. >+ https://bugs.webkit.org/show_bug.cgi?id=54181 >+ >+ * DumpRenderTree/LayoutTestController.cpp: >+ (setPageVisibilityCallback): >+ (resetPageVisibilityCallback): >+ (LayoutTestController::staticFunctions): >+ * DumpRenderTree/LayoutTestController.h: >+ (LayoutTestController::setPageVisibility): >+ (LayoutTestController::resetPageVisibility): >+ * DumpRenderTree/chromium/LayoutTestController.cpp: >+ (LayoutTestController::LayoutTestController): >+ (LayoutTestController::resetPageVisibility): >+ (LayoutTestController::setPageVisibility): >+ * DumpRenderTree/chromium/LayoutTestController.h: >+ > 2011-05-04 Siddharth Mathur <siddharth.mathur@nokia.com> > > Reviewed by Laszlo Gombos. >diff --git a/Tools/DumpRenderTree/LayoutTestController.cpp b/Tools/DumpRenderTree/LayoutTestController.cpp >index 4ca90d8..42fe81d 100644 >--- a/Tools/DumpRenderTree/LayoutTestController.cpp >+++ b/Tools/DumpRenderTree/LayoutTestController.cpp >@@ -1670,6 +1670,37 @@ static JSValueRef setPluginsEnabledCallback(JSContextRef context, JSObjectRef fu > return JSValueMakeUndefined(context); > } > >+static JSValueRef setPageVisibilityCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) >+{ >+ // Has mac & windows implementation >+ if (argumentCount < 1) >+ return JSValueMakeUndefined(context); >+ >+ JSRetainPtr<JSStringRef> visibility(Adopt, JSValueToStringCopy(context, arguments[0], exception)); >+ ASSERT(!*exception); >+ >+ size_t maxLength = JSStringGetMaximumUTF8CStringSize(visibility.get()); >+ char* visibilityBuffer = new char[maxLength + 1]; >+ JSStringGetUTF8CString(visibility.get(), visibilityBuffer, maxLength + 1); >+ >+ LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); >+ controller->setPageVisibility(visibilityBuffer); >+ delete[] visibilityBuffer; >+ >+ return JSValueMakeUndefined(context); >+} >+ >+static JSValueRef resetPageVisibilityCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) >+{ >+ // Has mac & windows implementation >+ if (argumentCount < 1) >+ return JSValueMakeUndefined(context); >+ >+ LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject)); >+ controller->resetPageVisibility(); >+ return JSValueMakeUndefined(context); >+} >+ > static JSValueRef setSmartInsertDeleteEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) > { > if (argumentCount < 1) >@@ -2256,6 +2287,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() > { "removeAllVisitedLinks", removeAllVisitedLinksCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "removeOriginAccessWhitelistEntry", removeOriginAccessWhitelistEntryCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "repaintSweepHorizontally", repaintSweepHorizontallyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, >+ { "resetPageVisibility", resetPageVisibilityCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "setAcceptsEditing", setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "setAllowUniversalAccessFromFileURLs", setAllowUniversalAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "setAllowFileAccessFromFileURLs", setAllowFileAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, >@@ -2288,6 +2320,7 @@ JSStaticFunction* LayoutTestController::staticFunctions() > { "setMockGeolocationPosition", setMockGeolocationPositionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "addMockSpeechInputResult", addMockSpeechInputResultCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "setNewWindowsCopyBackForwardList", setNewWindowsCopyBackForwardListCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, >+ { "setPageVisibility", setPageVisibilityCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "setPOSIXLocale", setPOSIXLocaleCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "setPersistentUserStyleSheetLocation", setPersistentUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "setPopupBlockingEnabled", setPopupBlockingEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, >diff --git a/Tools/DumpRenderTree/LayoutTestController.h b/Tools/DumpRenderTree/LayoutTestController.h >index a31e908..d4e3775 100644 >--- a/Tools/DumpRenderTree/LayoutTestController.h >+++ b/Tools/DumpRenderTree/LayoutTestController.h >@@ -123,6 +123,9 @@ public: > void setScrollbarPolicy(JSStringRef orientation, JSStringRef policy); > void setEditingBehavior(const char* editingBehavior); > >+ void setPageVisibility(const char* visibility) { } >+ void resetPageVisibility() { } >+ > JSValueRef shadowRoot(JSContextRef, JSValueRef); > JSValueRef ensureShadowRoot(JSContextRef, JSValueRef); > void removeShadowRoot(JSContextRef, JSValueRef); >diff --git a/Tools/DumpRenderTree/chromium/LayoutTestController.cpp b/Tools/DumpRenderTree/chromium/LayoutTestController.cpp >index ee8d5ac..62698c1 100644 >--- a/Tools/DumpRenderTree/chromium/LayoutTestController.cpp >+++ b/Tools/DumpRenderTree/chromium/LayoutTestController.cpp >@@ -134,6 +134,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) > bindMethod("removeOriginAccessWhitelistEntry", &LayoutTestController::removeOriginAccessWhitelistEntry); > bindMethod("removeShadowRoot", &LayoutTestController::removeShadowRoot); > bindMethod("repaintSweepHorizontally", &LayoutTestController::repaintSweepHorizontally); >+ bindMethod("resetPageVisibility", &LayoutTestController::resetPageVisibility); > bindMethod("resumeAnimations", &LayoutTestController::resumeAnimations); > bindMethod("sampleSVGAnimationForElementAtTime", &LayoutTestController::sampleSVGAnimationForElementAtTime); > bindMethod("setAcceptsEditing", &LayoutTestController::setAcceptsEditing); >@@ -157,6 +158,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) > bindMethod("setMockGeolocationError", &LayoutTestController::setMockGeolocationError); > bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition); > bindMethod("addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult); >+ bindMethod("setPageVisibility", &LayoutTestController::setPageVisibility); > bindMethod("setPluginsEnabled", &LayoutTestController::setPluginsEnabled); > bindMethod("setPopupBlockingEnabled", &LayoutTestController::setPopupBlockingEnabled); > bindMethod("setPOSIXLocale", &LayoutTestController::setPOSIXLocale); >@@ -1766,3 +1768,19 @@ void LayoutTestController::setPluginsEnabled(const CppArgumentList& arguments, C > } > result->setNull(); > } >+ >+void LayoutTestController::resetPageVisibility(const CppArgumentList& arguments, CppVariant* result) >+{ >+ m_shell->webView()->setVisibilityState(WebPageVisibilityStateVisible, true); >+} >+ >+void LayoutTestController::setPageVisibility(const CppArgumentList& arguments, CppVariant* result) >+{ >+ if (arguments.size() > 0 && arguments[0].isString()) { >+ string newVisibility = arguments[0].toString(); >+ if (newVisibility == "visible") >+ m_shell->webView()->setVisibilityState(WebPageVisibilityStateVisible, false); >+ else if (newVisibility == "hidden") >+ m_shell->webView()->setVisibilityState(WebPageVisibilityStateHidden, false); >+ } >+} >diff --git a/Tools/DumpRenderTree/chromium/LayoutTestController.h b/Tools/DumpRenderTree/chromium/LayoutTestController.h >index 44ac2cd..1071acd 100644 >--- a/Tools/DumpRenderTree/chromium/LayoutTestController.h >+++ b/Tools/DumpRenderTree/chromium/LayoutTestController.h >@@ -365,6 +365,10 @@ public: > // Enable or disable plugins. > void setPluginsEnabled(const CppArgumentList&, CppVariant*); > >+ // Switch the visibility of the page. >+ void setPageVisibility(const CppArgumentList&, CppVariant*); >+ void resetPageVisibility(const CppArgumentList&, CppVariant*); >+ > public: > // The following methods are not exposed to JavaScript. > void setWorkQueueFrozen(bool frozen) { m_workQueue.setFrozen(frozen); }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 54181
:
82102
|
82295
|
84908
|
89874
|
90455
|
91388
|
92357
|
92449
|
92502
|
92523
|
92746