[iOS] Suspend and resume device motion and device orientation updates when page is...
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Dec 2015 02:53:12 +0000 (02:53 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Dec 2015 02:53:12 +0000 (02:53 +0000)
commite47e57061a932a4d47b703870ade394cf11c10d5
tree27867a55d16e68c7559677328e7114b12fa1f315
parent478052ee41ba8d3f1abdcda5e90f45aadf8a6f62
[iOS] Suspend and resume device motion and device orientation updates when page is hidden and visible, respectively
https://bugs.webkit.org/show_bug.cgi?id=151840
<rdar://problem/23753931>

Reviewed by Simon Fraser.

.:

Add a manual test that can be used to verify that we suspend dispatching device motion and
device orientation events when the page is hidden.

* ManualTests/ios/resources/suspend-orientation-and-motion-events-when-page-becomes-hidden.js: Added.
(resetTest):
(checkEvent):
(handleVisibilityChange):
* ManualTests/ios/suspend-orientation-and-motion-events-when-page-becomes-hidden.html: Added.

Source/WebCore:

* dom/Document.cpp:
(WebCore::Document::suspendDeviceMotionAndOrientationUpdates): Added.
(WebCore::Document::resumeDeviceMotionAndOrientationUpdates): Added.
(WebCore::Document::platformSuspendOrStopActiveDOMObjects): Moved logic to suspend device motion and
orientation updates from here to Document::suspendDeviceMotionAndOrientationUpdates().
(WebCore::Document::suspendActiveDOMObjects): Modified to call Document::suspendDeviceMotionAndOrientationUpdates().
(WebCore::Document::resumeActiveDOMObjects): Modified to call Document::resumeDeviceMotionAndOrientationUpdates().
* dom/Document.h:
* page/Page.cpp:
(WebCore::Page::setIsVisibleInternal): Suspend device motion and orientation updates when the page is hidden and
resume updates when the page is visible.
(WebCore::Page::suspendDeviceMotionAndOrientationUpdates): Added.
(WebCore::Page::resumeDeviceMotionAndOrientationUpdates): Added.
* page/Page.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@193885 268f45cc-cd09-0410-ab3c-d52691b4dbfc
ChangeLog
ManualTests/ios/resources/suspend-orientation-and-motion-events-when-page-becomes-hidden.js [new file with mode: 0644]
ManualTests/ios/suspend-orientation-and-motion-events-when-page-becomes-hidden.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h