Changeset 242664 in webkit
- Timestamp:
- Mar 8, 2019, 4:30:45 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 20 added
- 57 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/fast/device-orientation (added)
-
LayoutTests/fast/device-orientation/device-motion-request-permission-denied-expected.txt (added)
-
LayoutTests/fast/device-orientation/device-motion-request-permission-denied.html (added)
-
LayoutTests/fast/device-orientation/device-motion-request-permission-granted-expected.txt (added)
-
LayoutTests/fast/device-orientation/device-motion-request-permission-granted.html (added)
-
LayoutTests/fast/device-orientation/device-motion-request-permission-user-gesture-expected.txt (added)
-
LayoutTests/fast/device-orientation/device-motion-request-permission-user-gesture.html (added)
-
LayoutTests/fast/device-orientation/device-orientation-request-permission-denied-expected.txt (added)
-
LayoutTests/fast/device-orientation/device-orientation-request-permission-denied.html (added)
-
LayoutTests/fast/device-orientation/device-orientation-request-permission-granted-expected.txt (added)
-
LayoutTests/fast/device-orientation/device-orientation-request-permission-granted.html (added)
-
LayoutTests/fast/device-orientation/device-orientation-request-permission-user-gesture-expected.txt (added)
-
LayoutTests/fast/device-orientation/device-orientation-request-permission-user-gesture.html (added)
-
LayoutTests/http/tests/events/device-orientation-motion-non-secure-context.html (modified) (2 diffs)
-
LayoutTests/http/tests/events/device-orientation-motion-secure-context-expected.txt (modified) (1 diff)
-
LayoutTests/http/tests/events/device-orientation-motion-secure-context.html (modified) (4 diffs)
-
LayoutTests/platform/ios-wk2/TestExpectations (modified) (1 diff)
-
LayoutTests/platform/ios/http/tests/events/device-orientation-motion-non-secure-context-expected.txt (modified) (2 diffs)
-
LayoutTests/platform/ios/http/tests/events/device-orientation-motion-secure-context-expected.txt (modified) (2 diffs)
-
Source/WebCore/CMakeLists.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/DerivedSources-input.xcfilelist (modified) (1 diff)
-
Source/WebCore/DerivedSources-output.xcfilelist (modified) (1 diff)
-
Source/WebCore/DerivedSources.make (modified) (1 diff)
-
Source/WebCore/Sources.txt (modified) (2 diffs)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (9 diffs)
-
Source/WebCore/dom/DeviceMotionEvent.h (modified) (2 diffs)
-
Source/WebCore/dom/DeviceMotionEvent.idl (modified) (1 diff)
-
Source/WebCore/dom/DeviceOrientationAndMotionAccessController.cpp (added)
-
Source/WebCore/dom/DeviceOrientationAndMotionAccessController.h (added)
-
Source/WebCore/dom/DeviceOrientationEvent.h (modified) (2 diffs)
-
Source/WebCore/dom/DeviceOrientationEvent.idl (modified) (1 diff)
-
Source/WebCore/dom/DeviceOrientationOrMotionEvent.cpp (added)
-
Source/WebCore/dom/DeviceOrientationOrMotionEvent.h (added)
-
Source/WebCore/dom/DeviceOrientationOrMotionEvent.idl (added)
-
Source/WebCore/dom/DeviceOrientationOrMotionPermissionState.h (added)
-
Source/WebCore/dom/DeviceOrientationOrMotionPermissionState.idl (added)
-
Source/WebCore/dom/Document.cpp (modified) (2 diffs)
-
Source/WebCore/dom/Document.h (modified) (4 diffs)
-
Source/WebCore/dom/Event.cpp (modified) (1 diff)
-
Source/WebCore/dom/MessagePort.cpp (modified) (1 diff)
-
Source/WebCore/dom/Microtasks.cpp (modified) (1 diff)
-
Source/WebCore/page/ChromeClient.h (modified) (1 diff)
-
Source/WebCore/page/DOMWindow.cpp (modified) (5 diffs)
-
Source/WebCore/page/DOMWindow.h (modified) (2 diffs)
-
Source/WebCore/page/DeviceController.cpp (modified) (1 diff)
-
Source/WebCore/page/DeviceController.h (modified) (1 diff)
-
Source/WebCore/page/Settings.yaml (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Shared/WebPreferences.yaml (modified) (1 diff)
-
Source/WebKit/Shared/WebPreferencesDefaultValues.cpp (modified) (1 diff)
-
Source/WebKit/Shared/WebPreferencesDefaultValues.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/APIUIClient.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/C/WKPage.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/API/C/WKPageUIClient.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (modified) (1 diff)
-
Source/WebKit/UIProcess/Cocoa/UIDelegate.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/Cocoa/UIDelegate.mm (modified) (2 diffs)
-
Source/WebKit/UIProcess/Cocoa/VersionChecks.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebPageProxy.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/WebPageProxy.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebPageProxy.messages.in (modified) (1 diff)
-
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/WebPage.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/WebPage.h (modified) (3 diffs)
-
Source/WebKit/WebProcess/WebPage/WebPage.messages.in (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (modified) (1 diff)
-
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (modified) (1 diff)
-
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (modified) (1 diff)
-
Tools/WebKitTestRunner/TestController.cpp (modified) (5 diffs)
-
Tools/WebKitTestRunner/TestController.h (modified) (3 diffs)
-
Tools/WebKitTestRunner/TestInvocation.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r242661 r242664 1 2019-03-08 Chris Dumez <cdumez@apple.com> 2 3 Add support for Device Orientation / Motion permission API 4 https://bugs.webkit.org/show_bug.cgi?id=195329 5 <rdar://problem/47645367> 6 7 Reviewed by Geoffrey Garen. 8 9 Add layout test coverage. 10 11 * TestExpectations: 12 * fast/device-orientation/device-motion-request-permission-denied-expected.txt: Added. 13 * fast/device-orientation/device-motion-request-permission-denied.html: Added. 14 * fast/device-orientation/device-motion-request-permission-granted-expected.txt: Added. 15 * fast/device-orientation/device-motion-request-permission-granted.html: Added. 16 * fast/device-orientation/device-motion-request-permission-user-gesture-expected.txt: Added. 17 * fast/device-orientation/device-motion-request-permission-user-gesture.html: Added. 18 * fast/device-orientation/device-orientation-request-permission-denied-expected.txt: Added. 19 * fast/device-orientation/device-orientation-request-permission-denied.html: Added. 20 * fast/device-orientation/device-orientation-request-permission-granted-expected.txt: Added. 21 * fast/device-orientation/device-orientation-request-permission-granted.html: Added. 22 * fast/device-orientation/device-orientation-request-permission-user-gesture-expected.txt: Added. 23 * fast/device-orientation/device-orientation-request-permission-user-gesture.html: Added. 24 * http/tests/events/device-orientation-motion-non-secure-context.html: 25 * http/tests/events/device-orientation-motion-secure-context-expected.txt: 26 * http/tests/events/device-orientation-motion-secure-context.html: 27 * platform/ios-wk2/TestExpectations: 28 * platform/ios/http/tests/events/device-orientation-motion-non-secure-context-expected.txt: 29 * platform/ios/http/tests/events/device-orientation-motion-secure-context-expected.txt: 30 1 31 2019-03-08 Zalan Bujtas <zalan@apple.com> 2 32 -
trunk/LayoutTests/TestExpectations
r242624 r242664 34 34 fast/viewport/ios [ Skip ] 35 35 fast/visual-viewport/ios/ [ Skip ] 36 fast/device-orientation [ Skip ] 36 37 fast/events/ios [ Skip ] 37 38 fast/events/watchos [ Skip ] -
trunk/LayoutTests/http/tests/events/device-orientation-motion-non-secure-context.html
r239089 r242664 28 28 addEventListener("devicemotion", function() { }); 29 29 internals.postTask(() => { 30 shouldBeEqualToString("lastConsoleMessage", "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure.");30 shouldBeEqualToString("lastConsoleMessage", "Blocked attempt to add a device motion or orientation event listener, reason: Browsing context is not secure."); 31 31 finishJSTest(); 32 32 }); … … 45 45 addEventListener("deviceorientation", function() { }); 46 46 internals.postTask(() => { 47 shouldBeEqualToString("lastConsoleMessage", "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure.");47 shouldBeEqualToString("lastConsoleMessage", "Blocked attempt to add a device motion or orientation event listener, reason: Browsing context is not secure."); 48 48 runDeviceMotionTest(); 49 49 }); -
trunk/LayoutTests/http/tests/events/device-orientation-motion-secure-context-expected.txt
r239087 r242664 1 CONSOLE MESSAGE: line 37: Device Orientation API is not supported2 CONSOLE MESSAGE: line 19: Device Motion API is not supported1 CONSOLE MESSAGE: line 50: Device Orientation API is not supported 2 CONSOLE MESSAGE: line 25: Device Motion API is not supported 3 3 Tests that trying to set an event listener for deviceorientation and deviceorientation does not log an error in secure contexts. 4 4 5 5 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 6 6 7 7 8 -
trunk/LayoutTests/http/tests/events/device-orientation-motion-secure-context.html
r239087 r242664 6 6 description("Tests that trying to set an event listener for deviceorientation and deviceorientation does not log an error in secure contexts."); 7 7 jsTestIsAsync = true; 8 9 if (window.testRunner) { 10 if (testRunner.setShouldAllowDeviceOrientationAndMotionAccess) 11 testRunner.setShouldAllowDeviceOrientationAndMotionAccess(true); 12 } 8 13 9 14 // localhost is secure by default. … … 16 21 function runDeviceMotionTest() 17 22 { 23 debug(""); 18 24 if (!window.DeviceMotionEvent) { 19 25 console.log("Device Motion API is not supported"); … … 22 28 } 23 29 24 lastConsoleMessage = null; 25 debug(""); 26 debug("* Registering device motion listener"); 27 addEventListener("devicemotion", function() { }); 28 internals.postTask(() => { 29 shouldBeNull("lastConsoleMessage"); 30 finishJSTest(); 30 debug("* Requesting device motion access..."); 31 internals.withUserGesture(() => { 32 DeviceMotionEvent.requestPermission().then((_result) => { 33 result = _result; 34 shouldBeEqualToString("result", "granted"); 35 36 lastConsoleMessage = null; 37 debug("* Registering device motion listener"); 38 addEventListener("devicemotion", function() { }); 39 internals.postTask(() => { 40 shouldBeNull("lastConsoleMessage"); 41 finishJSTest(); 42 }); 43 }); 31 44 }); 32 45 } … … 40 53 } 41 54 42 lastConsoleMessage = null; 43 debug("* Registering device orientation listener"); 44 addEventListener("deviceorientation", function() { }); 45 internals.postTask(() => { 46 shouldBeNull("lastConsoleMessage"); 47 runDeviceMotionTest(); 55 debug("* Requesting device orientation access..."); 56 internals.withUserGesture(() => { 57 DeviceOrientationEvent.requestPermission().then((_result) => { 58 result = _result; 59 shouldBeEqualToString("result", "granted"); 60 61 lastConsoleMessage = null; 62 debug("* Registering device orientation listener"); 63 addEventListener("deviceorientation", function() { }); 64 internals.postTask(() => { 65 shouldBeNull("lastConsoleMessage"); 66 runDeviceMotionTest(); 67 }); 68 }); 48 69 }); 49 70 } -
trunk/LayoutTests/platform/ios-wk2/TestExpectations
r242333 r242664 8 8 9 9 compositing/ios [ Pass ] 10 fast/device-orientation [ Pass ] 10 11 fast/history/ios [ Pass ] 11 12 fast/scrolling/ios [ Pass ] -
trunk/LayoutTests/platform/ios/http/tests/events/device-orientation-motion-non-secure-context-expected.txt
r239089 r242664 1 CONSOLE MESSAGE: line 45: Blocked attempt to add a device motion or orientation listener because the browsing context is not secure.2 CONSOLE MESSAGE: line 28: Blocked attempt to add a device motion or orientation listener because the browsing context is not secure.1 CONSOLE MESSAGE: line 45: Blocked attempt to add a device motion or orientation event listener, reason: Browsing context is not secure. 2 CONSOLE MESSAGE: line 28: Blocked attempt to add a device motion or orientation event listener, reason: Browsing context is not secure. 3 3 Tests that trying to set an event listener for deviceorientation and deviceorientation logs an error in non-secure contexts. 4 4 … … 7 7 8 8 * Registering device orientation listener 9 PASS lastConsoleMessage is "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."9 PASS lastConsoleMessage is "Blocked attempt to add a device motion or orientation event listener, reason: Browsing context is not secure." 10 10 11 11 * Registering device motion listener 12 PASS lastConsoleMessage is "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."12 PASS lastConsoleMessage is "Blocked attempt to add a device motion or orientation event listener, reason: Browsing context is not secure." 13 13 PASS successfullyParsed is true 14 14 -
trunk/LayoutTests/platform/ios/http/tests/events/device-orientation-motion-secure-context-expected.txt
r239087 r242664 1 Received device orientation & motion access request for security origin "http://127.0.0.1:8000". 1 2 Tests that trying to set an event listener for deviceorientation and deviceorientation does not log an error in secure contexts. 2 3 … … 4 5 5 6 7 * Requesting device orientation access... 8 PASS result is "granted" 6 9 * Registering device orientation listener 7 10 PASS lastConsoleMessage is null 8 11 12 * Requesting device motion access... 13 PASS result is "granted" 9 14 * Registering device motion listener 10 15 PASS lastConsoleMessage is null -
trunk/Source/WebCore/CMakeLists.txt
r242615 r242664 672 672 dom/DeviceMotionEvent.idl 673 673 dom/DeviceOrientationEvent.idl 674 dom/DeviceOrientationOrMotionEvent.idl 675 dom/DeviceOrientationOrMotionPermissionState.idl 674 676 dom/Document.idl 675 677 dom/DocumentAndElementEventHandlers.idl -
trunk/Source/WebCore/ChangeLog
r242661 r242664 1 2019-03-08 Chris Dumez <cdumez@apple.com> 2 3 Add support for Device Orientation / Motion permission API 4 https://bugs.webkit.org/show_bug.cgi?id=195329 5 <rdar://problem/47645367> 6 7 Reviewed by Geoffrey Garen. 8 9 Add support for Device Orientation / Motion permission API: 10 - https://github.com/w3c/deviceorientation/issues/57 11 12 Pages can add event listeners for 'deviceorientation' / 'devicemotion' events but 13 such events will not be fired until the page's JavaScript calls 14 DeviceOrientationEvent.requestPermission() / DeviceMotionEvent.requestPermission() 15 and the user grants the request. 16 17 The feature is currently behind an experimental feature flag, off by default. 18 19 Tests: fast/device-orientation/device-motion-request-permission-denied.html 20 fast/device-orientation/device-motion-request-permission-granted.html 21 fast/device-orientation/device-motion-request-permission-user-gesture.html 22 fast/device-orientation/device-orientation-request-permission-denied.html 23 fast/device-orientation/device-orientation-request-permission-granted.html 24 fast/device-orientation/device-orientation-request-permission-user-gesture.html 25 26 * CMakeLists.txt: 27 * DerivedSources-input.xcfilelist: 28 * DerivedSources-output.xcfilelist: 29 * DerivedSources.make: 30 * Sources.txt: 31 * WebCore.xcodeproj/project.pbxproj: 32 * dom/DeviceMotionEvent.h: 33 * dom/DeviceMotionEvent.idl: 34 * dom/DeviceOrientationAndMotionAccessController.cpp: Added. 35 (WebCore::DeviceOrientationAndMotionAccessController::DeviceOrientationAndMotionAccessController): 36 (WebCore::DeviceOrientationAndMotionAccessController::shouldAllowAccess): 37 (WebCore::DeviceOrientationAndMotionAccessController::setAccessState): 38 * dom/DeviceOrientationAndMotionAccessController.h: Added. 39 (WebCore::DeviceOrientationAndMotionAccessController::accessState const): 40 * dom/DeviceOrientationEvent.h: 41 * dom/DeviceOrientationEvent.idl: 42 * dom/DeviceOrientationOrMotionEvent.cpp: Added. 43 (WebCore::DeviceOrientationOrMotionEvent::requestPermission): 44 * dom/DeviceOrientationOrMotionEvent.h: Added. 45 * dom/DeviceOrientationOrMotionEvent.idl: Added. 46 * dom/DeviceOrientationOrMotionPermissionState.h: Added. 47 * dom/DeviceOrientationOrMotionPermissionState.idl: Added. 48 * dom/Document.cpp: 49 (WebCore::Document::deviceOrientationAndMotionAccessController): 50 * dom/Document.h: 51 * dom/Event.cpp: 52 * dom/MessagePort.cpp: 53 * dom/Microtasks.cpp: 54 * page/ChromeClient.h: 55 * page/DOMWindow.cpp: 56 (WebCore::DOMWindow::addEventListener): 57 (WebCore::DOMWindow::deviceOrientationController const): 58 (WebCore::DOMWindow::deviceMotionController const): 59 (WebCore::DOMWindow::isAllowedToUseDeviceMotionOrientation const): 60 (WebCore::DOMWindow::isAllowedToAddDeviceMotionOrientationListener const): 61 (WebCore::DOMWindow::startListeningForDeviceOrientationIfNecessary): 62 (WebCore::DOMWindow::stopListeningForDeviceOrientationIfNecessary): 63 (WebCore::DOMWindow::startListeningForDeviceMotionIfNecessary): 64 (WebCore::DOMWindow::stopListeningForDeviceMotionIfNecessary): 65 (WebCore::DOMWindow::removeEventListener): 66 (WebCore::DOMWindow::removeAllEventListeners): 67 * page/DOMWindow.h: 68 * page/DeviceController.cpp: 69 (WebCore::DeviceController::hasDeviceEventListener const): 70 * page/DeviceController.h: 71 * page/Settings.yaml: 72 1 73 2019-03-08 Zalan Bujtas <zalan@apple.com> 2 74 -
trunk/Source/WebCore/DerivedSources-input.xcfilelist
r242615 r242664 565 565 $(PROJECT_DIR)/dom/DeviceMotionEvent.idl 566 566 $(PROJECT_DIR)/dom/DeviceOrientationEvent.idl 567 $(PROJECT_DIR)/dom/DeviceOrientationOrMotionEvent.idl 568 $(PROJECT_DIR)/dom/DeviceOrientationOrMotionPermissionState.idl 567 569 $(PROJECT_DIR)/dom/Document.idl 568 570 $(PROJECT_DIR)/dom/DocumentAndElementEventHandlers.idl -
trunk/Source/WebCore/DerivedSources-output.xcfilelist
r242615 r242664 460 460 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceOrientationEvent.cpp 461 461 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceOrientationEvent.h 462 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceOrientationOrMotionEvent.cpp 463 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceOrientationOrMotionEvent.h 464 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceOrientationOrMotionPermissionState.cpp 465 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDeviceOrientationOrMotionPermissionState.h 462 466 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDocument.cpp 463 467 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSDocument.h -
trunk/Source/WebCore/DerivedSources.make
r242615 r242664 572 572 $(WebCore)/dom/DeviceMotionEvent.idl \ 573 573 $(WebCore)/dom/DeviceOrientationEvent.idl \ 574 $(WebCore)/dom/DeviceOrientationOrMotionEvent.idl \ 575 $(WebCore)/dom/DeviceOrientationOrMotionPermissionState.idl \ 574 576 $(WebCore)/dom/Document.idl \ 575 577 $(WebCore)/dom/DocumentAndElementEventHandlers.idl \ -
trunk/Source/WebCore/Sources.txt
r242624 r242664 821 821 dom/DeviceMotionData.cpp 822 822 dom/DeviceMotionEvent.cpp 823 dom/DeviceOrientationAndMotionAccessController.cpp 823 824 dom/DeviceOrientationController.cpp 824 825 dom/DeviceOrientationData.cpp 825 826 dom/DeviceOrientationEvent.cpp 827 dom/DeviceOrientationOrMotionEvent.cpp 826 828 dom/Document.cpp 827 829 dom/DocumentEventQueue.cpp … … 2724 2726 JSDeviceMotionEvent.cpp 2725 2727 JSDeviceOrientationEvent.cpp 2728 JSDeviceOrientationOrMotionPermissionState.cpp 2729 JSDeviceOrientationOrMotionEvent.cpp 2726 2730 JSDocument.cpp 2727 2731 JSDocumentAndElementEventHandlers.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r242624 r242664 1255 1255 460BB6161D0A1BF000221812 /* Base64Utilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 460BB6141D0A1BEC00221812 /* Base64Utilities.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1256 1256 460CBF361D4BCD0E0092E88E /* JSDOMWindowProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 460CBF341D4BCCFE0092E88E /* JSDOMWindowProperties.h */; }; 1257 460E3075222F4EFD009A0606 /* DeviceOrientationOrMotionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 461DA52A222F486F00D05A87 /* DeviceOrientationOrMotionEvent.h */; }; 1258 460E3077222F4F03009A0606 /* DeviceOrientationOrMotionPermissionState.h in Headers */ = {isa = PBXBuildFile; fileRef = 465EDD9F222F4EC300B46E16 /* DeviceOrientationOrMotionPermissionState.h */; }; 1257 1259 46218ACB1F72D64E00574FBE /* DOMHighResTimeStamp.h in Headers */ = {isa = PBXBuildFile; fileRef = 46E016AD1F72D61E00282B2C /* DOMHighResTimeStamp.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1258 1260 463521AD2081092A00C28922 /* WindowProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 463521AA2081090B00C28922 /* WindowProxy.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 1272 1274 46B95199207D634D00A7D2DD /* RemoteDOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B9518E207D632A00A7D2DD /* RemoteDOMWindow.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1273 1275 46B9519A207D635400A7D2DD /* RemoteFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B95192207D632E00A7D2DD /* RemoteFrame.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1276 46B95BF52231CFD60053A504 /* DeviceOrientationAndMotionAccessController.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B95BF42231CFB80053A504 /* DeviceOrientationAndMotionAccessController.h */; }; 1274 1277 46BCBBC22085008F00710638 /* JSRemoteDOMWindowBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 46BCBBC02085007F00710638 /* JSRemoteDOMWindowBase.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1275 1278 46C376622085177D00C73829 /* JSRemoteDOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C376612085176D00C73829 /* JSRemoteDOMWindow.h */; }; … … 7726 7729 460CBF341D4BCCFE0092E88E /* JSDOMWindowProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMWindowProperties.h; sourceTree = "<group>"; }; 7727 7730 460D19441FCE21DD00C3DB85 /* JSServiceWorkerGlobalScopeCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSServiceWorkerGlobalScopeCustom.cpp; sourceTree = "<group>"; }; 7731 461DA52A222F486F00D05A87 /* DeviceOrientationOrMotionEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceOrientationOrMotionEvent.h; sourceTree = "<group>"; }; 7732 461DA52C222F486F00D05A87 /* DeviceOrientationOrMotionEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceOrientationOrMotionEvent.cpp; sourceTree = "<group>"; }; 7728 7733 4634592B1AC2271000ECB71C /* PowerObserverMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PowerObserverMac.cpp; sourceTree = "<group>"; }; 7729 7734 463521AA2081090B00C28922 /* WindowProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowProxy.h; sourceTree = "<group>"; }; … … 7733 7738 4642404520EAF0ED00B29FD2 /* DatabaseManagerCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DatabaseManagerCocoa.mm; sourceTree = "<group>"; }; 7734 7739 465A8E781C8A24CE00E7D3E4 /* RuntimeApplicationChecksCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RuntimeApplicationChecksCocoa.mm; sourceTree = "<group>"; }; 7740 465EDD9D222F4EC300B46E16 /* DeviceOrientationOrMotionEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DeviceOrientationOrMotionEvent.idl; sourceTree = "<group>"; }; 7741 465EDD9F222F4EC300B46E16 /* DeviceOrientationOrMotionPermissionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceOrientationOrMotionPermissionState.h; sourceTree = "<group>"; }; 7742 465EDDA0222F4EC400B46E16 /* DeviceOrientationOrMotionPermissionState.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DeviceOrientationOrMotionPermissionState.idl; sourceTree = "<group>"; }; 7735 7743 466DC6AB1EDE021D00746224 /* JSDOMRectList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMRectList.cpp; sourceTree = "<group>"; }; 7736 7744 466ED8D21EDE0135005E43F6 /* JSDOMRectList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMRectList.h; sourceTree = "<group>"; }; … … 7755 7763 46B95193207D632F00A7D2DD /* AbstractDOMWindow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractDOMWindow.cpp; sourceTree = "<group>"; }; 7756 7764 46B95194207D633000A7D2DD /* AbstractFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractFrame.cpp; sourceTree = "<group>"; }; 7765 46B95BF22231CFB80053A504 /* DeviceOrientationAndMotionAccessController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceOrientationAndMotionAccessController.cpp; sourceTree = "<group>"; }; 7766 46B95BF42231CFB80053A504 /* DeviceOrientationAndMotionAccessController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceOrientationAndMotionAccessController.h; sourceTree = "<group>"; }; 7757 7767 46BCBBBE2085005B00710638 /* JSRemoteDOMWindowCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRemoteDOMWindowCustom.cpp; sourceTree = "<group>"; }; 7758 7768 46BCBBC02085007F00710638 /* JSRemoteDOMWindowBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRemoteDOMWindowBase.h; sourceTree = "<group>"; }; … … 27499 27509 31FB1A55120A5D0600DC02A0 /* DeviceMotionEvent.h */, 27500 27510 31FB1A56120A5D0600DC02A0 /* DeviceMotionEvent.idl */, 27511 46B95BF22231CFB80053A504 /* DeviceOrientationAndMotionAccessController.cpp */, 27512 46B95BF42231CFB80053A504 /* DeviceOrientationAndMotionAccessController.h */, 27501 27513 59A8F1D711A69520001AC34A /* DeviceOrientationClient.h */, 27502 27514 59A8F1D311A69508001AC34A /* DeviceOrientationController.cpp */, … … 27507 27519 59A85EA3119D68EC00DEF1EF /* DeviceOrientationEvent.h */, 27508 27520 59A85EAA119D7B6E00DEF1EF /* DeviceOrientationEvent.idl */, 27521 461DA52C222F486F00D05A87 /* DeviceOrientationOrMotionEvent.cpp */, 27522 461DA52A222F486F00D05A87 /* DeviceOrientationOrMotionEvent.h */, 27523 465EDD9D222F4EC300B46E16 /* DeviceOrientationOrMotionEvent.idl */, 27524 465EDD9F222F4EC300B46E16 /* DeviceOrientationOrMotionPermissionState.h */, 27525 465EDDA0222F4EC400B46E16 /* DeviceOrientationOrMotionPermissionState.idl */, 27509 27526 A8185F3409765765005826D9 /* Document.cpp */, 27510 27527 A8185F3809765765005826D9 /* Document.h */, … … 29031 29048 31FB1A5B120A5D0600DC02A0 /* DeviceMotionData.h in Headers */, 29032 29049 31FB1A5D120A5D0600DC02A0 /* DeviceMotionEvent.h in Headers */, 29050 46B95BF52231CFD60053A504 /* DeviceOrientationAndMotionAccessController.h in Headers */, 29033 29051 59A8F1D811A69520001AC34A /* DeviceOrientationClient.h in Headers */, 29034 29052 3140379D124BEA7F00AF40E4 /* DeviceOrientationClientIOS.h in Headers */, … … 29037 29055 590E1B4911E4EF4B0069F784 /* DeviceOrientationData.h in Headers */, 29038 29056 59A85EA4119D68EC00DEF1EF /* DeviceOrientationEvent.h in Headers */, 29057 460E3075222F4EFD009A0606 /* DeviceOrientationOrMotionEvent.h in Headers */, 29058 460E3077222F4F03009A0606 /* DeviceOrientationOrMotionPermissionState.h in Headers */, 29039 29059 572B401F21757A64000AD43E /* DeviceRequestConverter.h in Headers */, 29040 29060 572B403A21772581000AD43E /* DeviceResponseConverter.h in Headers */, -
trunk/Source/WebCore/dom/DeviceMotionEvent.h
r239427 r242664 26 26 #pragma once 27 27 28 #include "DeviceOrientationOrMotionEvent.h" 28 29 #include "Event.h" 29 30 … … 32 33 class DeviceMotionData; 33 34 34 class DeviceMotionEvent final : public Event {35 class DeviceMotionEvent final : public Event, public DeviceOrientationOrMotionEvent { 35 36 public: 36 37 virtual ~DeviceMotionEvent(); -
trunk/Source/WebCore/dom/DeviceMotionEvent.idl
r210741 r242664 58 58 double? gamma; 59 59 }; 60 61 DeviceMotionEvent implements DeviceOrientationOrMotionEvent; -
trunk/Source/WebCore/dom/DeviceOrientationEvent.h
r239427 r242664 26 26 #pragma once 27 27 28 #include "DeviceOrientationOrMotionEvent.h" 28 29 #include "Event.h" 29 30 … … 32 33 class DeviceOrientationData; 33 34 34 class DeviceOrientationEvent final : public Event {35 class DeviceOrientationEvent final : public Event, public DeviceOrientationOrMotionEvent { 35 36 public: 36 37 static Ref<DeviceOrientationEvent> create(const AtomicString& eventType, DeviceOrientationData* orientation) -
trunk/Source/WebCore/dom/DeviceOrientationEvent.idl
r237266 r242664 56 56 }; 57 57 58 DeviceOrientationEvent implements DeviceOrientationOrMotionEvent; -
trunk/Source/WebCore/dom/Document.cpp
r242624 r242664 245 245 #if ENABLE(DEVICE_ORIENTATION) 246 246 #include "DeviceMotionEvent.h" 247 #include "DeviceOrientationAndMotionAccessController.h" 247 248 #include "DeviceOrientationEvent.h" 248 249 #endif … … 8612 8613 } 8613 8614 8615 #if ENABLE(DEVICE_ORIENTATION) 8616 8617 DeviceOrientationAndMotionAccessController& Document::deviceOrientationAndMotionAccessController() 8618 { 8619 if (&topDocument() != this) 8620 return topDocument().deviceOrientationAndMotionAccessController(); 8621 8622 if (!m_deviceOrientationAndMotionAccessController) 8623 m_deviceOrientationAndMotionAccessController = std::make_unique<DeviceOrientationAndMotionAccessController>(*this); 8624 return *m_deviceOrientationAndMotionAccessController; 8625 } 8626 8627 #endif 8628 8614 8629 #if ENABLE(CSS_PAINTING_API) 8615 8630 Worklet& Document::ensurePaintWorklet() -
trunk/Source/WebCore/dom/Document.h
r242624 r242664 225 225 #endif 226 226 227 #if ENABLE(DEVICE_ORIENTATION) 227 228 #if PLATFORM(IOS_FAMILY) 228 229 class DeviceMotionClient; … … 230 231 class DeviceOrientationClient; 231 232 class DeviceOrientationController; 233 #endif 234 class DeviceOrientationAndMotionAccessController; 232 235 #endif 233 236 … … 1217 1220 #endif 1218 1221 1219 #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY) 1222 #if ENABLE(DEVICE_ORIENTATION) 1223 #if PLATFORM(IOS_FAMILY) 1220 1224 DeviceMotionController& deviceMotionController() const; 1221 1225 DeviceOrientationController& deviceOrientationController() const; 1222 1226 WEBCORE_EXPORT void simulateDeviceOrientationChange(double alpha, double beta, double gamma); 1223 1227 #endif 1228 1229 DeviceOrientationAndMotionAccessController& deviceOrientationAndMotionAccessController(); 1230 #endif // ENABLE(DEVICE_ORIENTATION) 1224 1231 1225 1232 const DocumentTiming& timing() const { return m_documentTiming; } … … 1870 1877 #endif 1871 1878 1872 #if ENABLE(DEVICE_ORIENTATION) && PLATFORM(IOS_FAMILY) 1879 #if ENABLE(DEVICE_ORIENTATION) 1880 #if PLATFORM(IOS_FAMILY) 1873 1881 std::unique_ptr<DeviceMotionClient> m_deviceMotionClient; 1874 1882 std::unique_ptr<DeviceMotionController> m_deviceMotionController; 1875 1883 std::unique_ptr<DeviceOrientationClient> m_deviceOrientationClient; 1876 1884 std::unique_ptr<DeviceOrientationController> m_deviceOrientationController; 1885 #endif 1886 std::unique_ptr<DeviceOrientationAndMotionAccessController> m_deviceOrientationAndMotionAccessController; 1877 1887 #endif 1878 1888 -
trunk/Source/WebCore/dom/Event.cpp
r241432 r242664 29 29 #include "EventPath.h" 30 30 #include "EventTarget.h" 31 #include "InspectorInstrumentation.h" 31 32 #include "Performance.h" 32 33 #include "UserGestureIndicator.h" -
trunk/Source/WebCore/dom/MessagePort.cpp
r234347 r242664 36 36 #include "WorkerGlobalScope.h" 37 37 #include "WorkerThread.h" 38 #include <wtf/CompletionHandler.h> 38 39 39 40 namespace WebCore { -
trunk/Source/WebCore/dom/Microtasks.cpp
r234854 r242664 23 23 #include "Microtasks.h" 24 24 25 #include "WorkerGlobalScope.h" 25 26 #include <wtf/MainThread.h> 26 27 #include <wtf/NeverDestroyed.h> -
trunk/Source/WebCore/page/ChromeClient.h
r242108 r242664 483 483 virtual void requestStorageAccess(String&& /*subFrameHost*/, String&& /*topFrameHost*/, uint64_t /*frameID*/, uint64_t /*pageID*/, WTF::CompletionHandler<void (bool)>&& callback) { callback(false); } 484 484 485 #if ENABLE(DEVICE_ORIENTATION) 486 virtual void shouldAllowDeviceOrientationAndMotionAccess(const SecurityOrigin&, WTF::CompletionHandler<void(bool)>&& callback) { callback(true); } 487 #endif 488 485 489 virtual void didInsertMenuElement(HTMLMenuElement&) { } 486 490 virtual void didRemoveMenuElement(HTMLMenuElement&) { } -
trunk/Source/WebCore/page/DOMWindow.cpp
r242253 r242664 50 50 #include "DeviceMotionData.h" 51 51 #include "DeviceMotionEvent.h" 52 #include "DeviceOrientationAndMotionAccessController.h" 52 53 #include "DeviceOrientationController.h" 53 54 #include "Document.h" … … 1827 1828 incrementGamepadEventListenerCount(); 1828 1829 #endif 1829 1830 1830 #if ENABLE(DEVICE_ORIENTATION) 1831 if (frame() && frame()->settings().deviceOrientationEventEnabled() && document() && document()->loader() && document()->loader()->deviceOrientationEventEnabled()) { 1831 else if (eventType == eventNames().deviceorientationEvent) 1832 startListeningForDeviceOrientationIfNecessary(); 1833 else if (eventType == eventNames().devicemotionEvent) 1834 startListeningForDeviceMotionIfNecessary(); 1835 #endif 1836 1837 return true; 1838 } 1839 1840 #if ENABLE(DEVICE_ORIENTATION) 1841 1842 DeviceOrientationController* DOMWindow::deviceOrientationController() const 1843 { 1832 1844 #if PLATFORM(IOS_FAMILY) 1833 if ((eventType == eventNames().devicemotionEvent || eventType == eventNames().deviceorientationEvent)) { 1834 if (isSameSecurityOriginAsMainFrame() && isSecureContext()) { 1835 if (eventType == eventNames().deviceorientationEvent) 1836 document()->deviceOrientationController().addDeviceEventListener(*this); 1837 else 1838 document()->deviceMotionController().addDeviceEventListener(*this); 1839 } else if (document()) { 1840 if (isSecureContext()) 1841 document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device motion or orientation listener from child frame that wasn't the same security origin as the main page."_s); 1842 else 1843 document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."_s); 1844 } 1845 return document() ? &document()->deviceOrientationController() : nullptr; 1846 #else 1847 return DeviceOrientationController::from(page()); 1848 #endif 1849 } 1850 1851 DeviceMotionController* DOMWindow::deviceMotionController() const 1852 { 1853 #if PLATFORM(IOS_FAMILY) 1854 return document() ? &document()->deviceMotionController() : nullptr; 1855 #else 1856 return DeviceMotionController::from(page()); 1857 #endif 1858 } 1859 1860 bool DOMWindow::isAllowedToUseDeviceMotionOrientation(String& message) const 1861 { 1862 if (!frame() || !frame()->settings().deviceOrientationEventEnabled() || !document() || !document()->loader() || !document()->loader()->deviceOrientationEventEnabled()) { 1863 message = "API is disabled"_s; 1864 return false; 1865 } 1866 1867 if (!isSecureContext()) { 1868 message = "Browsing context is not secure"_s; 1869 return false; 1870 } 1871 1872 if (!isSameSecurityOriginAsMainFrame()) { 1873 message = "Source frame did not have the same security origin as the main page"_s; 1874 return false; 1875 } 1876 return true; 1877 } 1878 1879 bool DOMWindow::isAllowedToAddDeviceMotionOrientationListener(String& message) const 1880 { 1881 String innerMessage; 1882 if (!isAllowedToUseDeviceMotionOrientation(innerMessage)) { 1883 message = makeString("Blocked attempt to add a device motion or orientation event listener, reason: ", innerMessage, "."); 1884 return false; 1885 } 1886 1887 if (frame()->settings().deviceOrientationPermissionAPIEnabled()) { 1888 auto accessState = document()->deviceOrientationAndMotionAccessController().accessState(); 1889 if (accessState && !*accessState) { 1890 message = "No device motion or orientation events will be fired because permission to use the API was denied."_s; 1891 return false; 1845 1892 } 1846 #else 1847 if (eventType == eventNames().devicemotionEvent) { 1848 if (isSameSecurityOriginAsMainFrame() && isSecureContext()) { 1849 if (DeviceMotionController* controller = DeviceMotionController::from(page())) 1850 controller->addDeviceEventListener(*this); 1851 } else 1852 document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device motion listener from child frame that wasn't the same security origin as the main page."_s); 1853 } else if (eventType == eventNames().deviceorientationEvent) { 1854 if (isSameSecurityOriginAsMainFrame() && isSecureContext()) { 1855 if (DeviceOrientationController* controller = DeviceOrientationController::from(page())) 1856 controller->addDeviceEventListener(*this); 1857 } else { 1858 if (isSecureContext()) 1859 document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device orientation listener from child frame that wasn't the same security origin as the main page."_s); 1860 else 1861 document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."_s); 1862 } 1893 if (!accessState) { 1894 message = "No device motion or orientation events will be fired until permission has been requested and granted."_s; 1895 return false; 1863 1896 } 1864 #endif // PLATFORM(IOS_FAMILY) 1865 } else if (eventType == eventNames().devicemotionEvent) 1897 } 1898 1899 return true; 1900 } 1901 1902 void DOMWindow::startListeningForDeviceOrientationIfNecessary() 1903 { 1904 if (!hasEventListeners(eventNames().deviceorientationEvent)) 1905 return; 1906 1907 auto* deviceController = deviceOrientationController(); 1908 if (!deviceController || deviceController->hasDeviceEventListener(*this)) 1909 return; 1910 1911 String errorMessage; 1912 if (!isAllowedToAddDeviceMotionOrientationListener(errorMessage)) { 1913 if (auto* document = this->document()) 1914 document->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, errorMessage); 1915 return; 1916 } 1917 1918 deviceController->addDeviceEventListener(*this); 1919 } 1920 1921 void DOMWindow::stopListeningForDeviceOrientationIfNecessary() 1922 { 1923 if (hasEventListeners(eventNames().deviceorientationEvent)) 1924 return; 1925 1926 if (auto* deviceController = deviceOrientationController()) 1927 deviceController->removeDeviceEventListener(*this); 1928 } 1929 1930 void DOMWindow::startListeningForDeviceMotionIfNecessary() 1931 { 1932 if (!hasEventListeners(eventNames().devicemotionEvent)) 1933 return; 1934 1935 auto* deviceController = deviceMotionController(); 1936 if (!deviceController || deviceController->hasDeviceEventListener(*this)) 1937 return; 1938 1939 String errorMessage; 1940 if (!isAllowedToAddDeviceMotionOrientationListener(errorMessage)) { 1866 1941 failedToRegisterDeviceMotionEventListener(); 1867 #endif // ENABLE(DEVICE_ORIENTATION) 1868 1869 return true; 1870 } 1871 1872 #if ENABLE(DEVICE_ORIENTATION) 1942 if (auto* document = this->document()) 1943 document->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, errorMessage); 1944 return; 1945 } 1946 1947 deviceController->addDeviceEventListener(*this); 1948 } 1949 1950 void DOMWindow::stopListeningForDeviceMotionIfNecessary() 1951 { 1952 if (hasEventListeners(eventNames().devicemotionEvent)) 1953 return; 1954 1955 if (auto* deviceController = deviceMotionController()) 1956 deviceController->removeDeviceEventListener(*this); 1957 } 1873 1958 1874 1959 void DOMWindow::failedToRegisterDeviceMotionEventListener() … … 1942 2027 else if (eventType == eventNames().beforeunloadEvent && allowsBeforeUnloadListeners(this)) 1943 2028 removeBeforeUnloadEventListener(this); 1944 #if ENABLE(DEVICE_ORIENTATION)1945 #if PLATFORM(IOS_FAMILY)1946 else if (eventType == eventNames().devicemotionEvent && document())1947 document()->deviceMotionController().removeDeviceEventListener(*this);1948 else if (eventType == eventNames().deviceorientationEvent && document())1949 document()->deviceOrientationController().removeDeviceEventListener(*this);1950 #else1951 else if (eventType == eventNames().devicemotionEvent) {1952 if (DeviceMotionController* controller = DeviceMotionController::from(page()))1953 controller->removeDeviceEventListener(*this);1954 } else if (eventType == eventNames().deviceorientationEvent) {1955 if (DeviceOrientationController* controller = DeviceOrientationController::from(page()))1956 controller->removeDeviceEventListener(*this);1957 }1958 #endif // PLATFORM(IOS_FAMILY)1959 #endif // ENABLE(DEVICE_ORIENTATION)1960 2029 #if PLATFORM(IOS_FAMILY) 1961 2030 else if (eventType == eventNames().scrollEvent) … … 1977 2046 else if (eventNames().isGamepadEventType(eventType)) 1978 2047 decrementGamepadEventListenerCount(); 2048 #endif 2049 #if ENABLE(DEVICE_ORIENTATION) 2050 else if (eventType == eventNames().deviceorientationEvent) 2051 stopListeningForDeviceOrientationIfNecessary(); 2052 else if (eventType == eventNames().devicemotionEvent) 2053 stopListeningForDeviceMotionIfNecessary(); 1979 2054 #endif 1980 2055 … … 2060 2135 2061 2136 #if ENABLE(DEVICE_ORIENTATION) 2062 #if PLATFORM(IOS_FAMILY) 2063 if (Document* document = this->document()) { 2064 document->deviceMotionController().removeAllDeviceEventListeners(*this); 2065 document->deviceOrientationController().removeAllDeviceEventListeners(*this); 2066 } 2067 #else 2068 if (DeviceMotionController* controller = DeviceMotionController::from(page())) 2069 controller->removeAllDeviceEventListeners(*this); 2070 if (DeviceOrientationController* controller = DeviceOrientationController::from(page())) 2071 controller->removeAllDeviceEventListeners(*this); 2072 #endif // PLATFORM(IOS_FAMILY) 2073 #endif // ENABLE(DEVICE_ORIENTATION) 2137 stopListeningForDeviceOrientationIfNecessary(); 2138 stopListeningForDeviceMotionIfNecessary(); 2139 #endif 2074 2140 2075 2141 #if PLATFORM(IOS_FAMILY) -
trunk/Source/WebCore/page/DOMWindow.h
r242138 r242664 83 83 class WebKitPoint; 84 84 85 #if ENABLE(DEVICE_ORIENTATION) 86 class DeviceMotionController; 87 class DeviceOrientationController; 88 #endif 89 85 90 struct ImageBitmapOptions; 86 91 struct WindowFeatures; … … 310 315 void decrementScrollEventListenersCount(); 311 316 unsigned scrollEventListenerCount() const { return m_scrollEventListenerCount; } 317 #endif 318 319 #if ENABLE(DEVICE_ORIENTATION) 320 void startListeningForDeviceOrientationIfNecessary(); 321 void stopListeningForDeviceOrientationIfNecessary(); 322 void startListeningForDeviceMotionIfNecessary(); 323 void stopListeningForDeviceMotionIfNecessary(); 324 325 bool isAllowedToUseDeviceMotionOrientation(String& message) const; 326 bool isAllowedToAddDeviceMotionOrientationListener(String& message) const; 327 328 DeviceOrientationController* deviceOrientationController() const; 329 DeviceMotionController* deviceMotionController() const; 312 330 #endif 313 331 -
trunk/Source/WebCore/page/DeviceController.cpp
r240237 r242664 70 70 } 71 71 72 bool DeviceController::hasDeviceEventListener(DOMWindow& window) const 73 { 74 return m_listeners.contains(&window); 75 } 76 72 77 void DeviceController::dispatchDeviceEvent(Event& event) 73 78 { -
trunk/Source/WebCore/page/DeviceController.h
r240237 r242664 47 47 void removeDeviceEventListener(DOMWindow&); 48 48 void removeAllDeviceEventListeners(DOMWindow&); 49 bool hasDeviceEventListener(DOMWindow&) const; 49 50 50 51 void dispatchDeviceEvent(Event&); -
trunk/Source/WebCore/page/Settings.yaml
r242621 r242664 768 768 conditional: DEVICE_ORIENTATION 769 769 770 deviceOrientationPermissionAPIEnabled: 771 type: bool 772 initial: false 773 conditional: DEVICE_ORIENTATION 774 770 775 shouldEnableTextAutosizingBoost: 771 776 type: bool -
trunk/Source/WebKit/ChangeLog
r242662 r242664 1 2019-03-08 Chris Dumez <cdumez@apple.com> 2 3 Add support for Device Orientation / Motion permission API 4 https://bugs.webkit.org/show_bug.cgi?id=195329 5 <rdar://problem/47645367> 6 7 Reviewed by Geoffrey Garen. 8 9 Add support for Device Orientation / Motion permission API: 10 - https://github.com/w3c/deviceorientation/issues/57 11 12 This adds new SPI to WKUIDelegatePrivate, until we can make this API. 13 14 * Shared/WebPreferences.yaml: 15 * UIProcess/API/APIUIClient.h: 16 (API::UIClient::shouldAllowDeviceOrientationAndMotionAccess): 17 * UIProcess/API/C/WKPage.cpp: 18 (WKPageSetPageUIClient): 19 * UIProcess/API/C/WKPageUIClient.h: 20 * UIProcess/API/Cocoa/WKUIDelegate.h: 21 * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: 22 * UIProcess/Cocoa/UIDelegate.h: 23 * UIProcess/Cocoa/UIDelegate.mm: 24 (WebKit::UIDelegate::setDelegate): 25 (WebKit::UIDelegate::UIClient::shouldAllowDeviceOrientationAndMotionAccess): 26 * UIProcess/WebPageProxy.cpp: 27 (WebKit::WebPageProxy::requestDeviceOrientationAndMotionAccess): 28 * UIProcess/WebPageProxy.h: 29 * UIProcess/WebPageProxy.messages.in: 30 * WebProcess/WebCoreSupport/WebChromeClient.cpp: 31 (WebKit::WebChromeClient::shouldAllowDeviceOrientationAndMotionAccess): 32 * WebProcess/WebCoreSupport/WebChromeClient.h: 33 * WebProcess/WebPage/WebPage.cpp: 34 (WebKit::nextDeviceOrientationAndMotionPermissionCallbackID): 35 (WebKit::WebPage::shouldAllowDeviceOrientationAndMotionAccess): 36 (WebKit::WebPage::didReceiveDeviceOrientationAndMotionAccessDecision): 37 * WebProcess/WebPage/WebPage.h: 38 * WebProcess/WebPage/WebPage.messages.in: 39 1 40 2019-03-08 Brady Eidson <beidson@apple.com> 2 41 -
trunk/Source/WebKit/Shared/WebPreferences.yaml
r242621 r242664 12 12 condition: ENABLE(DEVICE_ORIENTATION) 13 13 webcoreName: deviceOrientationEventEnabled 14 15 DeviceOrientationPermissionAPIEnabled: 16 type: bool 17 defaultValue: defaultDeviceOrientationPermissionAPIEnabled() 18 condition: ENABLE(DEVICE_ORIENTATION) 19 webcoreName: deviceOrientationPermissionAPIEnabled 20 humanReadableName: "Permission API for device orientation / motion access." 21 humanReadableDescription: "DeviceOrientationEvent.requestPermission() / DeviceMotionEvent.requestPermission()" 22 category: experimental 14 23 15 24 JavaScriptEnabled: -
trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp
r238461 r242664 45 45 } 46 46 47 bool defaultDeviceOrientationPermissionAPIEnabled() 48 { 49 #if PLATFORM(IOS) && ENABLE(DEVICE_ORIENTATION) 50 return linkedOnOrAfter(WebKit::SDKVersion::FirstWithDeviceOrientationAndMotionPermissionAPI); 51 #else 52 return false; 53 #endif 54 } 55 47 56 bool defaultCustomPasteboardDataEnabled() 48 57 { -
trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h
r242350 r242664 228 228 229 229 bool defaultPassiveTouchListenersAsDefaultOnDocument(); 230 bool defaultDeviceOrientationPermissionAPIEnabled(); 230 231 bool defaultCustomPasteboardDataEnabled(); 231 232 -
trunk/Source/WebKit/UIProcess/API/APIUIClient.h
r241926 r242664 174 174 #endif 175 175 176 #if ENABLE(DEVICE_ORIENTATION) 177 virtual void shouldAllowDeviceOrientationAndMotionAccess(WebKit::WebPageProxy&, SecurityOrigin&, CompletionHandler<void(bool)>&& completionHandler) { completionHandler(true); } 178 #endif 179 176 180 virtual void didClickAutoFillButton(WebKit::WebPageProxy&, Object*) { } 177 181 -
trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp
r241584 r242664 116 116 117 117 template<> struct ClientTraits<WKPageUIClientBase> { 118 typedef std::tuple<WKPageUIClientV0, WKPageUIClientV1, WKPageUIClientV2, WKPageUIClientV3, WKPageUIClientV4, WKPageUIClientV5, WKPageUIClientV6, WKPageUIClientV7, WKPageUIClientV8, WKPageUIClientV9, WKPageUIClientV10, WKPageUIClientV11, WKPageUIClientV12 > Versions;118 typedef std::tuple<WKPageUIClientV0, WKPageUIClientV1, WKPageUIClientV2, WKPageUIClientV3, WKPageUIClientV4, WKPageUIClientV5, WKPageUIClientV6, WKPageUIClientV7, WKPageUIClientV8, WKPageUIClientV9, WKPageUIClientV10, WKPageUIClientV11, WKPageUIClientV12, WKPageUIClientV13> Versions; 119 119 }; 120 120 … … 1904 1904 } 1905 1905 1906 #if ENABLE(DEVICE_ORIENTATION) 1907 void shouldAllowDeviceOrientationAndMotionAccess(WebPageProxy& page, API::SecurityOrigin& origin, CompletionHandler<void(bool)>&& completionHandler) final 1908 { 1909 if (!m_client.shouldAllowDeviceOrientationAndMotionAccess) 1910 return completionHandler(true); 1911 1912 completionHandler(m_client.shouldAllowDeviceOrientationAndMotionAccess(toAPI(&page), toAPI(&origin), m_client.base.clientInfo)); 1913 } 1914 #endif 1915 1906 1916 // Printing. 1907 1917 float headerHeight(WebPageProxy& page, WebFrameProxy& frame) final -
trunk/Source/WebKit/UIProcess/API/C/WKPageUIClient.h
r239625 r242664 135 135 typedef void (*WKDidExceedBackgroundResourceLimitWhileInForegroundCallback)(WKPageRef page, WKResourceLimit limit, const void* clientInfo); 136 136 typedef void (*WKPageDidResignInputElementStrongPasswordAppearanceCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo); 137 typedef bool (*WKPageShouldAllowDeviceOrientationAndMotionAccessCallback)(WKPageRef page, WKSecurityOriginRef securityOrigin, const void *clientInfo); 137 138 138 139 // Deprecated … … 1141 1142 } WKPageUIClientV12; 1142 1143 1144 typedef struct WKPageUIClientV13 { 1145 WKPageUIClientBase base; 1146 1147 // Version 0. 1148 WKPageCreateNewPageCallback_deprecatedForUseWithV0 createNewPage_deprecatedForUseWithV0; 1149 WKPageUIClientCallback showPage; 1150 WKPageUIClientCallback close; 1151 WKPageTakeFocusCallback takeFocus; 1152 WKPageFocusCallback focus; 1153 WKPageUnfocusCallback unfocus; 1154 WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV0 runJavaScriptAlert_deprecatedForUseWithV0; 1155 WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV0 runJavaScriptConfirm_deprecatedForUseWithV0; 1156 WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV0 runJavaScriptPrompt_deprecatedForUseWithV0; 1157 WKPageSetStatusTextCallback setStatusText; 1158 WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0 mouseDidMoveOverElement_deprecatedForUseWithV0; 1159 WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0 missingPluginButtonClicked_deprecatedForUseWithV0; 1160 WKPageDidNotHandleKeyEventCallback didNotHandleKeyEvent; 1161 WKPageDidNotHandleWheelEventCallback didNotHandleWheelEvent; 1162 WKPageGetToolbarsAreVisibleCallback toolbarsAreVisible; 1163 WKPageSetToolbarsAreVisibleCallback setToolbarsAreVisible; 1164 WKPageGetMenuBarIsVisibleCallback menuBarIsVisible; 1165 WKPageSetMenuBarIsVisibleCallback setMenuBarIsVisible; 1166 WKPageGetStatusBarIsVisibleCallback statusBarIsVisible; 1167 WKPageSetStatusBarIsVisibleCallback setStatusBarIsVisible; 1168 WKPageGetIsResizableCallback isResizable; 1169 WKPageSetIsResizableCallback setIsResizable; 1170 WKPageGetWindowFrameCallback getWindowFrame; 1171 WKPageSetWindowFrameCallback setWindowFrame; 1172 WKPageRunBeforeUnloadConfirmPanelCallback_deprecatedForUseWithV6 runBeforeUnloadConfirmPanel_deprecatedForUseWithV6; 1173 WKPageUIClientCallback didDraw; 1174 WKPageUIClientCallback pageDidScroll; 1175 WKPageExceededDatabaseQuotaCallback exceededDatabaseQuota; 1176 WKPageRunOpenPanelCallback runOpenPanel; 1177 WKPageDecidePolicyForGeolocationPermissionRequestCallback decidePolicyForGeolocationPermissionRequest; 1178 WKPageHeaderHeightCallback headerHeight; 1179 WKPageFooterHeightCallback footerHeight; 1180 WKPageDrawHeaderCallback drawHeader; 1181 WKPageDrawFooterCallback drawFooter; 1182 WKPagePrintFrameCallback printFrame; 1183 WKPageUIClientCallback runModal; 1184 void* unused1; // Used to be didCompleteRubberBandForMainFrame 1185 WKPageSaveDataToFileInDownloadsFolderCallback saveDataToFileInDownloadsFolder; 1186 void* shouldInterruptJavaScript_unavailable; 1187 1188 // Version 1. 1189 WKPageCreateNewPageCallback_deprecatedForUseWithV1 createNewPage_deprecatedForUseWithV1; 1190 WKPageMouseDidMoveOverElementCallback mouseDidMoveOverElement; 1191 WKPageDecidePolicyForNotificationPermissionRequestCallback decidePolicyForNotificationPermissionRequest; 1192 WKPageUnavailablePluginButtonClickedCallback_deprecatedForUseWithV1 unavailablePluginButtonClicked_deprecatedForUseWithV1; 1193 1194 // Version 2. 1195 WKPageShowColorPickerCallback showColorPicker; 1196 WKPageHideColorPickerCallback hideColorPicker; 1197 WKPageUnavailablePluginButtonClickedCallback unavailablePluginButtonClicked; 1198 1199 // Version 3. 1200 WKPagePinnedStateDidChangeCallback pinnedStateDidChange; 1201 1202 // Version 4. 1203 void* unused2; // Used to be didBeginTrackingPotentialLongMousePress. 1204 void* unused3; // Used to be didRecognizeLongMousePress. 1205 void* unused4; // Used to be didCancelTrackingPotentialLongMousePress. 1206 WKPageIsPlayingAudioDidChangeCallback isPlayingAudioDidChange; 1207 1208 // Version 5. 1209 WKPageDecidePolicyForUserMediaPermissionRequestCallback decidePolicyForUserMediaPermissionRequest; 1210 WKPageDidClickAutoFillButtonCallback didClickAutoFillButton; 1211 WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV5 runJavaScriptAlert_deprecatedForUseWithV5; 1212 WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV5 runJavaScriptConfirm_deprecatedForUseWithV5; 1213 WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV5 runJavaScriptPrompt_deprecatedForUseWithV5; 1214 WKPageMediaSessionMetadataDidChangeCallback mediaSessionMetadataDidChange; 1215 1216 // Version 6. 1217 WKPageCreateNewPageCallback createNewPage; 1218 WKPageRunJavaScriptAlertCallback runJavaScriptAlert; 1219 WKPageRunJavaScriptConfirmCallback runJavaScriptConfirm; 1220 WKPageRunJavaScriptPromptCallback runJavaScriptPrompt; 1221 WKCheckUserMediaPermissionCallback checkUserMediaPermissionForOrigin; 1222 1223 // Version 7. 1224 WKPageRunBeforeUnloadConfirmPanelCallback runBeforeUnloadConfirmPanel; 1225 WKFullscreenMayReturnToInlineCallback fullscreenMayReturnToInline; 1226 1227 // Version 8. 1228 WKRequestPointerLockCallback requestPointerLock; 1229 WKDidLosePointerLockCallback didLosePointerLock; 1230 1231 // Version 9. 1232 WKHandleAutoplayEventCallback handleAutoplayEvent; 1233 1234 // Version 10. 1235 WKHasVideoInPictureInPictureDidChangeCallback hasVideoInPictureInPictureDidChange; 1236 WKDidExceedBackgroundResourceLimitWhileInForegroundCallback didExceedBackgroundResourceLimitWhileInForeground; 1237 1238 // Version 11. 1239 WKPageDidResignInputElementStrongPasswordAppearanceCallback didResignInputElementStrongPasswordAppearance; 1240 1241 // Version 12. 1242 WKPageRequestStorageAccessConfirmCallback requestStorageAccessConfirm; 1243 1244 // Version 13. 1245 WKPageShouldAllowDeviceOrientationAndMotionAccessCallback shouldAllowDeviceOrientationAndMotionAccess; 1246 } WKPageUIClientV13; 1247 1143 1248 #ifdef __cplusplus 1144 1249 } -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h
r242339 r242664 35 35 @class WKOpenPanelParameters; 36 36 @class WKPreviewElementInfo; 37 @class WKSecurityOrigin; 37 38 @class WKWebView; 38 39 @class WKWebViewConfiguration; -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
r242339 r242664 172 172 - (void)_webView:(WKWebView *)webView didPresentFocusedElementViewController:(UIViewController *)controller WK_API_AVAILABLE(ios(12.0)); 173 173 - (void)_webView:(WKWebView *)webView didDismissFocusedElementViewController:(UIViewController *)controller WK_API_AVAILABLE(ios(12.0)); 174 175 /*! @abstract Allows your app to determine whether or not the given security origin should have access to the device's orientation and motion. 176 @param securityOrigin The security origin which requested access to the device's orientation and motion. 177 @param decisionHandler The decision handler to call once the app has made its decision. Pass YES to allow the origin access, NO otherwise. 178 179 If you do not implement this method, access to the device's orientation and motion will be granted. 180 */ 181 - (void)_webView:(WKWebView *)webView shouldAllowDeviceOrientationAndMotionAccessForSecurityOrigin:(WKSecurityOrigin *)securityOrigin decisionHandler:(void (^)(BOOL))decisionHandler WK_API_AVAILABLE(ios(WK_IOS_TBA)); 182 174 183 #else // TARGET_OS_IPHONE 175 184 - (void)_prepareForImmediateActionAnimationForWebView:(WKWebView *)webView WK_API_AVAILABLE(macosx(10.13.4)); -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h
r242339 r242664 121 121 void saveDataToFileInDownloadsFolder(WebPageProxy*, const WTF::String&, const WTF::String&, const URL&, API::Data&) final; 122 122 #endif 123 #if ENABLE(DEVICE_ORIENTATION) 124 void shouldAllowDeviceOrientationAndMotionAccess(WebKit::WebPageProxy&, API::SecurityOrigin&, CompletionHandler<void(bool)>&&) final; 125 #endif 123 126 bool needsFontAttributes() const final { return m_uiDelegate.m_delegateMethods.webViewDidChangeFontAttributes; } 124 127 void didChangeFontAttributes(const WebCore::FontAttributes&) final; … … 189 192 bool webViewRequestNotificationPermissionForSecurityOriginDecisionHandler : 1; 190 193 #endif 194 #if ENABLE(DEVICE_ORIENTATION) 195 bool webViewShouldAllowDeviceOrientationAndMotionAccessForSecurityOriginDecisionHandler : 1; 196 #endif 191 197 bool webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1; 192 198 bool webViewDecideDatabaseQuotaForSecurityOriginDatabaseNameDisplayNameCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1; -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
r242339 r242664 134 134 m_delegateMethods.webViewRequestNotificationPermissionForSecurityOriginDecisionHandler = [delegate respondsToSelector:@selector(_webView:requestNotificationPermissionForSecurityOrigin:decisionHandler:)]; 135 135 #endif 136 #if ENABLE(DEVICE_ORIENTATION) 137 m_delegateMethods.webViewShouldAllowDeviceOrientationAndMotionAccessForSecurityOriginDecisionHandler = [delegate respondsToSelector:@selector(_webView:shouldAllowDeviceOrientationAndMotionAccessForSecurityOrigin:decisionHandler:)]; 138 #endif 136 139 m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)]; 137 140 m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginDatabaseNameDisplayNameCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:databaseName:displayName:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)]; … … 845 848 #endif 846 849 850 #if ENABLE(DEVICE_ORIENTATION) 851 void UIDelegate::UIClient::shouldAllowDeviceOrientationAndMotionAccess(WebKit::WebPageProxy&, API::SecurityOrigin& securityOrigin, CompletionHandler<void(bool)>&& completionHandler) 852 { 853 if (!m_uiDelegate.m_delegateMethods.webViewShouldAllowDeviceOrientationAndMotionAccessForSecurityOriginDecisionHandler) 854 return completionHandler(true); 855 856 auto delegate = m_uiDelegate.m_delegate.get(); 857 if (!delegate) 858 return completionHandler(true); 859 860 auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:shouldAllowDeviceOrientationAndMotionAccessForSecurityOrigin:decisionHandler:)); 861 [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView shouldAllowDeviceOrientationAndMotionAccessForSecurityOrigin:wrapper(securityOrigin) decisionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)] (BOOL granted) mutable { 862 if (checker->completionHandlerHasBeenCalled()) 863 return; 864 checker->didCallCompletionHandler(); 865 completionHandler(granted); 866 }).get()]; 867 } 868 #endif 869 847 870 void UIDelegate::UIClient::didChangeFontAttributes(const WebCore::FontAttributes& fontAttributes) 848 871 { -
trunk/Source/WebKit/UIProcess/Cocoa/VersionChecks.h
r242521 r242664 39 39 #endif 40 40 41 #ifndef DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API 42 #define DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API 0 43 #endif 44 41 45 namespace WebKit { 42 46 … … 57 61 FirstWithSnapshotAfterScreenUpdates = DYLD_IOS_VERSION_FIRST_WITH_SNAPSHOT_AFTER_SCREEN_UPDATES, 58 62 FirstWhereDownloadAttributeDoesNotOverrideNavigationDelegate = DYLD_IOS_VERSION_FIRST_WHERE_DOWNLOAD_ATTRIBUTE_DOES_NOT_OVERRIDE_NAVIGATION_DELEGATE, 63 FirstWithDeviceOrientationAndMotionPermissionAPI = DYLD_IOS_VERSION_FIRST_WITH_DEVICE_ORIENTATION_AND_MOTION_PERMISSION_API, 59 64 #elif PLATFORM(MAC) 60 65 FirstWithNetworkCache = DYLD_MACOSX_VERSION_10_11, -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r242603 r242664 7175 7175 } 7176 7176 7177 #if ENABLE(DEVICE_ORIENTATION) 7178 void WebPageProxy::requestDeviceOrientationAndMotionAccess(WebCore::SecurityOriginData&& originData, uint64_t callbackID) 7179 { 7180 auto origin = API::SecurityOrigin::create(originData.securityOrigin()); 7181 m_uiClient->shouldAllowDeviceOrientationAndMotionAccess(*this, origin.get(), [this, weakThis = makeWeakPtr(*this), callbackID](bool granted) { 7182 if (!weakThis || !isValid()) 7183 return; 7184 m_process->send(Messages::WebPage::DidReceiveDeviceOrientationAndMotionAccessDecision(callbackID, granted), m_pageID); 7185 }); 7186 } 7187 #endif 7188 7177 7189 void WebPageProxy::requestNotificationPermission(uint64_t requestID, const String& originString) 7178 7190 { -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r242616 r242664 1402 1402 #endif 1403 1403 1404 #if ENABLE(DEVICE_ORIENTATION) 1405 void requestDeviceOrientationAndMotionAccess(WebCore::SecurityOriginData&&, uint64_t callbackID); 1406 #endif 1407 1404 1408 static WebPageProxy* nonEphemeralWebPageProxy(); 1405 1409 -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r242551 r242664 534 534 LoadSynchronousURLSchemeTask(struct WebKit::URLSchemeTaskParameters parameters) -> (WebCore::ResourceResponse response, WebCore::ResourceError error, IPC::DataReference data) Delayed 535 535 536 #if ENABLE(DEVICE_ORIENTATION) 537 RequestDeviceOrientationAndMotionAccess(struct WebCore::SecurityOriginData origin, uint64_t callbackID); 538 #endif 539 536 540 #if ENABLE(ATTACHMENT_ELEMENT) 537 541 RegisterAttachmentIdentifierFromData(String identifier, String contentType, String preferredFileName, IPC::SharedBufferDataReference data) -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
r242010 r242664 1321 1321 #endif 1322 1322 1323 #if ENABLE(DEVICE_ORIENTATION) 1324 void WebChromeClient::shouldAllowDeviceOrientationAndMotionAccess(const SecurityOrigin& origin, CompletionHandler<void(bool)>&& callback) 1325 { 1326 m_page.shouldAllowDeviceOrientationAndMotionAccess(origin, WTFMove(callback)); 1327 } 1328 #endif 1329 1323 1330 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
r242108 r242664 367 367 #endif 368 368 369 #if ENABLE(DEVICE_ORIENTATION) 370 void shouldAllowDeviceOrientationAndMotionAccess(const WebCore::SecurityOrigin&, CompletionHandler<void(bool)>&&) final; 371 #endif 372 369 373 String m_cachedToolTip; 370 374 mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame; -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r242624 r242664 6340 6340 } 6341 6341 #endif 6342 6343 #if ENABLE(DEVICE_ORIENTATION) 6344 static uint64_t nextDeviceOrientationAndMotionPermissionCallbackID() 6345 { 6346 static uint64_t nextCallbackID = 0; 6347 return ++nextCallbackID; 6348 } 6349 6350 void WebPage::shouldAllowDeviceOrientationAndMotionAccess(const WebCore::SecurityOrigin& origin, CompletionHandler<void(bool)>&& callback) 6351 { 6352 auto callbackID = nextDeviceOrientationAndMotionPermissionCallbackID(); 6353 ASSERT(!m_deviceOrientationAndMotionPermissionCallbackMap.contains(callbackID)); 6354 m_deviceOrientationAndMotionPermissionCallbackMap.add(callbackID, WTFMove(callback)); 6355 6356 send(Messages::WebPageProxy::RequestDeviceOrientationAndMotionAccess(origin.data(), callbackID)); 6357 } 6358 6359 void WebPage::didReceiveDeviceOrientationAndMotionAccessDecision(uint64_t callbackID, bool granted) 6360 { 6361 auto callback = m_deviceOrientationAndMotionPermissionCallbackMap.take(callbackID); 6362 ASSERT(callback); 6363 callback(granted); 6364 } 6365 #endif 6342 6366 6343 6367 static ShareSheetCallbackID nextShareSheetCallbackID() -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r242624 r242664 1111 1111 #endif 1112 1112 1113 #if ENABLE(DEVICE_ORIENTATION) 1114 void shouldAllowDeviceOrientationAndMotionAccess(const WebCore::SecurityOrigin&, CompletionHandler<void(bool)>&&); 1115 #endif 1116 1113 1117 void showShareSheet(WebCore::ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&& callback); 1114 1118 void didCompleteShareSheet(bool wasCompleted, ShareSheetCallbackID contextId); … … 1205 1209 void requestDragStart(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition); 1206 1210 void requestAdditionalItemsForDragSession(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition); 1211 #endif 1212 1213 #if ENABLE(DEVICE_ORIENTATION) 1214 void didReceiveDeviceOrientationAndMotionAccessDecision(uint64_t callbackID, bool granted); 1207 1215 #endif 1208 1216 … … 1837 1845 HashMap<ShareSheetCallbackID, WTF::Function<void(bool completed)>> m_shareSheetResponseCallbackMap; 1838 1846 1847 #if ENABLE(DEVICE_ORIENTATION) 1848 HashMap<uint64_t, WTF::CompletionHandler<void(bool granted)>> m_deviceOrientationAndMotionPermissionCallbackMap; 1849 #endif 1850 1839 1851 #if ENABLE(APPLICATION_MANIFEST) 1840 1852 HashMap<uint64_t, uint64_t> m_applicationManifestFetchCallbackMap; -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r242551 r242664 364 364 DidReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed) 365 365 366 #if ENABLE(DEVICE_ORIENTATION) 367 DidReceiveDeviceOrientationAndMotionAccessDecision(uint64_t callbackID, bool granted) 368 #endif 369 366 370 # Printing. 367 371 BeginPrinting(uint64_t frameID, struct WebKit::PrintInfo printInfo) -
trunk/Tools/ChangeLog
r242658 r242664 1 2019-03-08 Chris Dumez <cdumez@apple.com> 2 3 Add support for Device Orientation / Motion permission API 4 https://bugs.webkit.org/show_bug.cgi?id=195329 5 <rdar://problem/47645367> 6 7 Reviewed by Geoffrey Garen. 8 9 Add test infrastructure to help test the Device Orientation / Motion permission API. 10 11 * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: 12 * WebKitTestRunner/InjectedBundle/TestRunner.cpp: 13 (WTR::TestRunner::setShouldAllowDeviceOrientationAndMotionAccess): 14 * WebKitTestRunner/InjectedBundle/TestRunner.h: 15 * WebKitTestRunner/TestController.cpp: 16 (WTR::shouldAllowDeviceOrientationAndMotionAccess): 17 (WTR::TestController::createWebViewWithOptions): 18 (WTR::TestController::resetStateToConsistentValues): 19 (WTR::TestController::handleDeviceOrientationAndMotionAccessRequest): 20 * WebKitTestRunner/TestController.h: 21 (WTR::TestController::setShouldAllowDeviceOrientationAndMotionAccess): 22 * WebKitTestRunner/TestInvocation.cpp: 23 (WTR::TestInvocation::didReceiveMessageFromInjectedBundle): 24 1 25 2019-03-08 Saam barati <sbarati@apple.com> 2 26 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r242598 r242664 104 104 boolean isCommandEnabled(DOMString name); 105 105 unsigned long windowCount(); 106 107 // Device Orientation Motion. 108 void setShouldAllowDeviceOrientationAndMotionAccess(boolean value); 106 109 107 110 // Special DOM variables. -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
r242598 r242664 1295 1295 } 1296 1296 1297 void TestRunner::setShouldAllowDeviceOrientationAndMotionAccess(bool value) 1298 { 1299 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetShouldAllowDeviceOrientationAndMotionAccess")); 1300 WKRetainPtr<WKBooleanRef> messageBody(AdoptWK, WKBooleanCreate(value)); 1301 WKBundlePagePostMessage(InjectedBundle::singleton().page()->page(), messageName.get(), messageBody.get()); 1302 } 1303 1297 1304 void TestRunner::terminateNetworkProcess() 1298 1305 { -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r242598 r242664 349 349 void setIgnoresViewportScaleLimits(bool); 350 350 void setShouldDownloadUndisplayableMIMETypes(bool); 351 void setShouldAllowDeviceOrientationAndMotionAccess(bool); 351 352 352 353 bool didCancelClientRedirect() const { return m_didCancelClientRedirect; } -
trunk/Tools/WebKitTestRunner/TestController.cpp
r242598 r242664 261 261 { 262 262 WKPageDidAllowPointerLock(page); 263 } 264 265 static bool shouldAllowDeviceOrientationAndMotionAccess(WKPageRef, WKSecurityOriginRef origin, const void*) 266 { 267 return TestController::singleton().handleDeviceOrientationAndMotionAccessRequest(origin); 263 268 } 264 269 … … 571 576 572 577 platformCreateWebView(configuration.get(), options); 573 WKPageUIClientV 8pageUIClient = {574 { 8, m_mainWebView.get() },578 WKPageUIClientV13 pageUIClient = { 579 { 13, m_mainWebView.get() }, 575 580 0, // createNewPage_deprecatedForUseWithV0 576 581 0, // showPage … … 638 643 0, // fullscreenMayReturnToInline 639 644 requestPointerLock, 640 0, 645 0, // didLosePointerLock 646 0, // handleAutoplayEvent 647 0, // hasVideoInPictureInPictureDidChange 648 0, // didExceedBackgroundResourceLimitWhileInForeground 649 0, // didResignInputElementStrongPasswordAppearance 650 0, // requestStorageAccessConfirm 651 shouldAllowDeviceOrientationAndMotionAccess 641 652 }; 642 653 WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient.base); … … 943 954 944 955 m_shouldDownloadUndisplayableMIMETypes = false; 956 957 m_shouldAllowDeviceOrientationAndMotionAccess = false; 945 958 946 959 m_workQueueManager.clearWorkQueue(); … … 2549 2562 } 2550 2563 2564 bool TestController::handleDeviceOrientationAndMotionAccessRequest(WKSecurityOriginRef origin) 2565 { 2566 m_currentInvocation->outputText(makeString("Received device orientation & motion access request for security origin \"", originUserVisibleName(origin), "\".\n")); 2567 return m_shouldAllowDeviceOrientationAndMotionAccess; 2568 } 2569 2551 2570 void TestController::handleUserMediaPermissionRequest(WKFrameRef frame, WKSecurityOriginRef userMediaDocumentOrigin, WKSecurityOriginRef topLevelDocumentOrigin, WKUserMediaPermissionRequestRef request) 2552 2571 { -
trunk/Tools/WebKitTestRunner/TestController.h
r242598 r242664 151 151 void resetUserMediaPermissionRequestCountForOrigin(WKStringRef userMediaDocumentOriginString, WKStringRef topLevelDocumentOriginString); 152 152 153 // Device Orientation / Motion. 154 bool handleDeviceOrientationAndMotionAccessRequest(WKSecurityOriginRef); 155 153 156 // Content Extensions. 154 157 void configureContentExtensionForTest(const TestInvocation&); … … 200 203 201 204 void setShouldDownloadUndisplayableMIMETypes(bool value) { m_shouldDownloadUndisplayableMIMETypes = value; } 205 void setShouldAllowDeviceOrientationAndMotionAccess(bool value) { m_shouldAllowDeviceOrientationAndMotionAccess = value; } 202 206 203 207 void setStatisticsDebugMode(bool value); … … 510 514 bool m_policyDelegatePermissive { false }; 511 515 bool m_shouldDownloadUndisplayableMIMETypes { false }; 516 bool m_shouldAllowDeviceOrientationAndMotionAccess { false }; 512 517 513 518 bool m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges { false }; -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r242598 r242664 748 748 } 749 749 750 if (WKStringIsEqualToUTF8CString(messageName, "SetShouldAllowDeviceOrientationAndMotionAccess")) { 751 ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID()); 752 WKBooleanRef value = static_cast<WKBooleanRef>(messageBody); 753 TestController::singleton().setShouldAllowDeviceOrientationAndMotionAccess(WKBooleanGetValue(value)); 754 return; 755 } 756 750 757 if (WKStringIsEqualToUTF8CString(messageName, "RunUIProcessScript")) { 751 758 WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
Note:
See TracChangeset
for help on using the changeset viewer.