WebKit Bugzilla
Attachment 357155 Details for
Bug 192631
: Add a preference to enable / disable devicemotion and deviceorientation events
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192631-20181212121721.patch (text/plain), 10.98 KB, created by
Chris Dumez
on 2018-12-12 12:17:22 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Chris Dumez
Created:
2018-12-12 12:17:22 PST
Size:
10.98 KB
patch
obsolete
>Subversion Revision: 239107 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c0ae4ec3cd36a93400445791c559a829babf673d..20c52a6996b7fc853e90f642c67fa1059725b02e 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,18 @@ >+2018-12-12 Chris Dumez <cdumez@apple.com> >+ >+ Add a preference to enable / disable devicemotion and deviceorientation events >+ https://bugs.webkit.org/show_bug.cgi?id=192631 >+ <rdar://problem/46646244> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add setting to toggle support for the deviceorientation / devicemotion events: >+ - https://w3c.github.io/deviceorientation/ >+ >+ * page/DOMWindow.cpp: >+ (WebCore::DOMWindow::addEventListener): >+ * page/Settings.yaml: >+ > 2018-12-12 Wenson Hsieh <wenson_hsieh@apple.com> > > [iOS] A few API tests are failing after r239086 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 79cbefc1b389b5c407c73dc15394980702f553f8..7256869e463b78f94d7474d2792458ab61210473 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,20 @@ >+2018-12-12 Chris Dumez <cdumez@apple.com> >+ >+ Add a preference to enable / disable devicemotion and deviceorientation events >+ https://bugs.webkit.org/show_bug.cgi?id=192631 >+ <rdar://problem/46646244> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add setting to toggle support for the deviceorientation / devicemotion events: >+ - https://w3c.github.io/deviceorientation/ >+ >+ * Shared/WebPreferences.yaml: >+ * UIProcess/API/Cocoa/WKPreferences.mm: >+ (-[WKPreferences _setDeviceOrientationEventEnabled:]): >+ (-[WKPreferences _deviceOrientationEventEnabled]): >+ * UIProcess/API/Cocoa/WKPreferencesPrivate.h: >+ > 2018-12-09 Darin Adler <darin@apple.com> > > [iOS] Zero memory containing the password for PDF documents when a WKPDFView is deallocated >diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp >index 42c6e7e94a333ec310e0a020fff797942f473d9b..2772950454b30b852284d6ceb5156227b6a97de2 100644 >--- a/Source/WebCore/page/DOMWindow.cpp >+++ b/Source/WebCore/page/DOMWindow.cpp >@@ -1821,41 +1821,6 @@ bool DOMWindow::addEventListener(const AtomicString& eventType, Ref<EventListene > addUnloadEventListener(this); > else if (eventType == eventNames().beforeunloadEvent && allowsBeforeUnloadListeners(this)) > addBeforeUnloadEventListener(this); >-#if ENABLE(DEVICE_ORIENTATION) >-#if PLATFORM(IOS_FAMILY) >- else if ((eventType == eventNames().devicemotionEvent || eventType == eventNames().deviceorientationEvent) && document()) { >- if (isSameSecurityOriginAsMainFrame() && isSecureContext()) { >- if (eventType == eventNames().deviceorientationEvent) >- document()->deviceOrientationController()->addDeviceEventListener(this); >- else >- document()->deviceMotionController()->addDeviceEventListener(this); >- } else if (document()) { >- if (isSecureContext()) >- 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); >- else >- document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."_s); >- } >- } >-#else >- else if (eventType == eventNames().devicemotionEvent) { >- if (isSameSecurityOriginAsMainFrame() && isSecureContext()) { >- if (DeviceMotionController* controller = DeviceMotionController::from(page())) >- controller->addDeviceEventListener(this); >- } else if (document()) >- 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); >- } else if (eventType == eventNames().deviceorientationEvent) { >- if (isSameSecurityOriginAsMainFrame() && isSecureContext()) { >- if (DeviceOrientationController* controller = DeviceOrientationController::from(page())) >- controller->addDeviceEventListener(this); >- } else if (document()) { >- if (isSecureContext()) >- 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); >- else >- document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."_s); >- } >- } >-#endif // PLATFORM(IOS_FAMILY) >-#endif // ENABLE(DEVICE_ORIENTATION) > #if PLATFORM(IOS_FAMILY) > else if (eventType == eventNames().scrollEvent) > incrementScrollEventListenersCount(); >@@ -1873,6 +1838,44 @@ bool DOMWindow::addEventListener(const AtomicString& eventType, Ref<EventListene > incrementGamepadEventListenerCount(); > #endif > >+#if ENABLE(DEVICE_ORIENTATION) >+ if (frame() && frame()->settings().deviceOrientationEventEnabled()) { >+#if PLATFORM(IOS_FAMILY) >+ if ((eventType == eventNames().devicemotionEvent || eventType == eventNames().deviceorientationEvent) && document()) { >+ if (isSameSecurityOriginAsMainFrame() && isSecureContext()) { >+ if (eventType == eventNames().deviceorientationEvent) >+ document()->deviceOrientationController()->addDeviceEventListener(this); >+ else >+ document()->deviceMotionController()->addDeviceEventListener(this); >+ } else if (document()) { >+ if (isSecureContext()) >+ 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); >+ else >+ document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."_s); >+ } >+ } >+#else >+ if (eventType == eventNames().devicemotionEvent) { >+ if (isSameSecurityOriginAsMainFrame() && isSecureContext()) { >+ if (DeviceMotionController* controller = DeviceMotionController::from(page())) >+ controller->addDeviceEventListener(this); >+ } else if (document()) >+ 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); >+ } else if (eventType == eventNames().deviceorientationEvent) { >+ if (isSameSecurityOriginAsMainFrame() && isSecureContext()) { >+ if (DeviceOrientationController* controller = DeviceOrientationController::from(page())) >+ controller->addDeviceEventListener(this); >+ } else if (document()) { >+ if (isSecureContext()) >+ 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); >+ else >+ document()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, "Blocked attempt to add a device motion or orientation listener because the browsing context is not secure."_s); >+ } >+ } >+#endif // PLATFORM(IOS_FAMILY) >+ } >+#endif // ENABLE(DEVICE_ORIENTATION) >+ > return true; > } > >diff --git a/Source/WebCore/page/Settings.yaml b/Source/WebCore/page/Settings.yaml >index 6daec2ae5b79e2f2353e664d3629835121e512ed..a79719386b3c2cf9345f5806bdac03bf5743a19a 100644 >--- a/Source/WebCore/page/Settings.yaml >+++ b/Source/WebCore/page/Settings.yaml >@@ -745,6 +745,11 @@ touchEventEmulationEnabled: > getter: isTouchEventEmulationEnabled > conditional: TOUCH_EVENTS > >+deviceOrientationEventEnabled: >+ type: bool >+ initial: true >+ conditional: DEVICE_ORIENTATION >+ > shouldEnableTextAutosizingBoost: > type: bool > initial: false >diff --git a/Source/WebKit/Shared/WebPreferences.yaml b/Source/WebKit/Shared/WebPreferences.yaml >index 39d41a7186b3de7ce6cbb01ca1e55a32bcd8a312..077bde35ea562ec343ece0cb5205ca9e1db1000e 100644 >--- a/Source/WebKit/Shared/WebPreferences.yaml >+++ b/Source/WebKit/Shared/WebPreferences.yaml >@@ -6,6 +6,12 @@ BlankAnchorTargetImpliesNoOpenerEnabled: > humanReadableDescription: "target=_blank on anchor elements implies rel=noopener" > category: experimental > >+DeviceOrientationEventEnabled: >+ type: bool >+ defaultValue: true >+ condition: ENABLE(DEVICE_ORIENTATION) >+ webcoreName: deviceOrientationEventEnabled >+ > JavaScriptEnabled: > type: bool > defaultValue: true >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm b/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm >index eda9c818e66123bc148875afb737eddcb06167bb..3ac5b5c8601b9f973995137db339e7b70b323aec 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm >@@ -1346,6 +1346,22 @@ - (BOOL)_webAnimationsCSSIntegrationEnabled > return _preferences->webAnimationsCSSIntegrationEnabled(); > } > >+- (void)_setDeviceOrientationEventEnabled:(BOOL)enabled >+{ >+#if ENABLE(DEVICE_ORIENTATION) >+ _preferences->setDeviceOrientationEventEnabled(enabled); >+#endif >+} >+ >+- (BOOL)_deviceOrientationEventEnabled >+{ >+#if ENABLE(DEVICE_ORIENTATION) >+ return _preferences->deviceOrientationEventEnabled(); >+#else >+ return false; >+#endif >+} >+ > @end > > #endif // WK_API_ENABLED >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h b/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h >index 28698bfbe6e9a37c791ebc30d5df05005af28049..af64c612382b780c0543331417734d1be96a49d5 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h >@@ -150,6 +150,7 @@ typedef NS_ENUM(NSInteger, _WKEditableLinkBehavior) { > @property (nonatomic, setter=_setShouldIgnoreMetaViewport:) BOOL _shouldIgnoreMetaViewport WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); > @property (nonatomic, setter=_setVideoQualityIncludesDisplayCompositingEnabled:) BOOL _videoQualityIncludesDisplayCompositingEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); > @property (nonatomic, setter=_setWebAnimationsCSSIntegrationEnabled:) BOOL _webAnimationsCSSIntegrationEnabled WK_API_AVAILABLE(macosx(10.14), ios(WK_IOS_TBA)); >+@property (nonatomic, setter=_setDeviceOrientationEventEnabled:) BOOL _deviceOrientationEventEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); > > #if !TARGET_OS_IPHONE > @property (nonatomic, setter=_setWebGLEnabled:) BOOL _webGLEnabled WK_API_AVAILABLE(macosx(10.13.4));
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 192631
: 357155