Diff
Modified: trunk/Source/WebCore/ChangeLog (239129 => 239130)
--- trunk/Source/WebCore/ChangeLog 2018-12-12 21:44:07 UTC (rev 239129)
+++ trunk/Source/WebCore/ChangeLog 2018-12-12 22:04:02 UTC (rev 239130)
@@ -1,3 +1,18 @@
+2018-12-12 Chris Dumez <[email protected]>
+
+ Add a preference to enable / disable devicemotion and deviceorientation events
+ https://bugs.webkit.org/show_bug.cgi?id=192631
+ <rdar://problem/46646244>
+
+ Reviewed by Geoffrey Garen.
+
+ 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-11 Ryosuke Niwa <[email protected]>
Make HTMLConverter take two Positions in preparation to make it work with shadow DOM
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (239129 => 239130)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2018-12-12 21:44:07 UTC (rev 239129)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2018-12-12 22:04:02 UTC (rev 239130)
@@ -1821,42 +1821,7 @@
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();
#endif
@@ -1873,6 +1838,44 @@
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;
}
Modified: trunk/Source/WebCore/page/Settings.yaml (239129 => 239130)
--- trunk/Source/WebCore/page/Settings.yaml 2018-12-12 21:44:07 UTC (rev 239129)
+++ trunk/Source/WebCore/page/Settings.yaml 2018-12-12 22:04:02 UTC (rev 239130)
@@ -745,6 +745,11 @@
getter: isTouchEventEmulationEnabled
conditional: TOUCH_EVENTS
+deviceOrientationEventEnabled:
+ type: bool
+ initial: true
+ conditional: DEVICE_ORIENTATION
+
shouldEnableTextAutosizingBoost:
type: bool
initial: false
Modified: trunk/Source/WebKit/ChangeLog (239129 => 239130)
--- trunk/Source/WebKit/ChangeLog 2018-12-12 21:44:07 UTC (rev 239129)
+++ trunk/Source/WebKit/ChangeLog 2018-12-12 22:04:02 UTC (rev 239130)
@@ -1,3 +1,20 @@
+2018-12-12 Chris Dumez <[email protected]>
+
+ Add a preference to enable / disable devicemotion and deviceorientation events
+ https://bugs.webkit.org/show_bug.cgi?id=192631
+ <rdar://problem/46646244>
+
+ Reviewed by Geoffrey Garen.
+
+ 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-12 Ross Kirsling <[email protected]>
Unreviewed build fix for WinCairo Debug after r239080(?).
Modified: trunk/Source/WebKit/Shared/WebPreferences.yaml (239129 => 239130)
--- trunk/Source/WebKit/Shared/WebPreferences.yaml 2018-12-12 21:44:07 UTC (rev 239129)
+++ trunk/Source/WebKit/Shared/WebPreferences.yaml 2018-12-12 22:04:02 UTC (rev 239130)
@@ -6,6 +6,12 @@
humanReadableDescription: "target=_blank on anchor elements implies rel=noopener"
category: experimental
+DeviceOrientationEventEnabled:
+ type: bool
+ defaultValue: true
+ condition: ENABLE(DEVICE_ORIENTATION)
+ webcoreName: deviceOrientationEventEnabled
+
_javascript_Enabled:
type: bool
defaultValue: true
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm (239129 => 239130)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm 2018-12-12 21:44:07 UTC (rev 239129)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm 2018-12-12 22:04:02 UTC (rev 239130)
@@ -1346,6 +1346,22 @@
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
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h (239129 => 239130)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h 2018-12-12 21:44:07 UTC (rev 239129)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h 2018-12-12 22:04:02 UTC (rev 239130)
@@ -150,6 +150,7 @@
@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));