Enable GAMEPAD in the Mac build, but disabled at runtime.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jun 2014 23:17:22 +0000 (23:17 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jun 2014 23:17:22 +0000 (23:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134255

Reviewed by Dean Jackson.

Source/JavaScriptCore:
* Configurations/FeatureDefines.xcconfig:

* runtime/JSObject.h: Export JSObject::removeDirect() to allow disabling
  functions at runtime.

Source/WebCore:
No new tests (No changes to a tested config).

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation): Add the ability to have a function be EnabledAtRuntime by
  removing such functions from the prototype if they are disabled.

Change the three new objects and the one new function to be EnabledAtRuntime
* Modules/gamepad/Gamepad.idl:
* Modules/gamepad/GamepadButton.idl:
* Modules/gamepad/GamepadEvent.idl:
* Modules/gamepad/NavigatorGamepad.idl:

Add a RuntimeEnabledFeature for Gamepads:
* bindings/generic/RuntimeEnabledFeatures.cpp:
(WebCore::RuntimeEnabledFeatures::RuntimeEnabledFeatures):
* bindings/generic/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::setGamepadsEnabled):
(WebCore::RuntimeEnabledFeatures::gamepadsEnabled):

* Configurations/FeatureDefines.xcconfig:

Source/WebKit/mac:
* Configurations/FeatureDefines.xcconfig:

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(-[WebPreferences gamepadsEnabled]):
(-[WebPreferences setGamepadsEnabled:]):
* WebView/WebPreferencesPrivate.h:

* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Source/WebKit2:
* Configurations/FeatureDefines.xcconfig:

* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetGamepadsEnabled):
(WKPreferencesGetGamepadsEnabled):
* UIProcess/API/C/WKPreferencesRefPrivate.h:

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170400 268f45cc-cd09-0410-ab3c-d52691b4dbfc

24 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Configurations/FeatureDefines.xcconfig
Source/JavaScriptCore/runtime/JSObject.h
Source/WebCore/ChangeLog
Source/WebCore/Configurations/FeatureDefines.xcconfig
Source/WebCore/Modules/gamepad/Gamepad.idl
Source/WebCore/Modules/gamepad/GamepadButton.idl
Source/WebCore/Modules/gamepad/GamepadEvent.idl
Source/WebCore/Modules/gamepad/NavigatorGamepad.idl
Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp
Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Configurations/FeatureDefines.xcconfig
Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKit/mac/WebView/WebPreferences.mm
Source/WebKit/mac/WebView/WebPreferencesPrivate.h
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Configurations/FeatureDefines.xcconfig
Source/WebKit2/Shared/WebPreferencesDefinitions.h
Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
Source/WebKit2/UIProcess/API/C/WKPreferencesRefPrivate.h
Source/WebKit2/WebProcess/WebPage/WebPage.cpp

index 2f70f49..648dd97 100644 (file)
@@ -1,3 +1,15 @@
+2014-06-24  Brady Eidson  <beidson@apple.com>
+
+        Enable GAMEPAD in the Mac build, but disabled at runtime.
+        https://bugs.webkit.org/show_bug.cgi?id=134255
+
+        Reviewed by Dean Jackson.
+
+        * Configurations/FeatureDefines.xcconfig:
+
+        * runtime/JSObject.h: Export JSObject::removeDirect() to allow disabling
+          functions at runtime.
+
 2014-06-24  Mark Hahnenberg  <mhahnenberg@apple.com>
 
         REGRESSION (r169703): Invalid cast in JSC::asGetterSetter / JSC::JSObject::defineOwnNonIndexProperty
index 0a85c2d..b566172 100644 (file)
@@ -87,7 +87,8 @@ ENABLE_FILTERS = ENABLE_FILTERS;
 ENABLE_FONT_LOAD_EVENTS = ;
 ENABLE_FULLSCREEN_API = $(ENABLE_FULLSCREEN_API_$(PLATFORM_NAME));
 ENABLE_FULLSCREEN_API_macosx = ENABLE_FULLSCREEN_API;
-ENABLE_GAMEPAD = ;
+ENABLE_GAMEPAD = $(ENABLE_GAMEPAD_$(PLATFORM_NAME));
+ENABLE_GAMEPAD_macosx = ENABLE_GAMEPAD;
 ENABLE_GAMEPAD_DEPRECATED = ;
 ENABLE_GEOLOCATION = ENABLE_GEOLOCATION;
 ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING = $(ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING_$(PLATFORM_NAME));
index fd44002..bd24abd 100644 (file)
@@ -572,7 +572,7 @@ public:
 
     void transitionTo(VM&, Structure*);
 
-    bool removeDirect(VM&, PropertyName); // Return true if anything is removed.
+    JS_EXPORT_PRIVATE bool removeDirect(VM&, PropertyName); // Return true if anything is removed.
     bool hasCustomProperties() { return structure()->didTransition(); }
     bool hasGetterSetterProperties() { return structure()->hasGetterSetterProperties(); }
     bool hasCustomGetterSetterProperties() { return structure()->hasCustomGetterSetterProperties(); }
index 54c8370..338b4f5 100644 (file)
@@ -1,3 +1,31 @@
+2014-06-24  Brady Eidson  <beidson@apple.com>
+
+        Enable GAMEPAD in the Mac build, but disabled at runtime.
+        https://bugs.webkit.org/show_bug.cgi?id=134255
+
+        Reviewed by Dean Jackson.
+
+        No new tests (No changes to a tested config).
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation): Add the ability to have a function be EnabledAtRuntime by
+          removing such functions from the prototype if they are disabled.
+
+        Change the three new objects and the one new function to be EnabledAtRuntime
+        * Modules/gamepad/Gamepad.idl:
+        * Modules/gamepad/GamepadButton.idl:
+        * Modules/gamepad/GamepadEvent.idl:
+        * Modules/gamepad/NavigatorGamepad.idl:
+
+        Add a RuntimeEnabledFeature for Gamepads:
+        * bindings/generic/RuntimeEnabledFeatures.cpp:
+        (WebCore::RuntimeEnabledFeatures::RuntimeEnabledFeatures):
+        * bindings/generic/RuntimeEnabledFeatures.h:
+        (WebCore::RuntimeEnabledFeatures::setGamepadsEnabled):
+        (WebCore::RuntimeEnabledFeatures::gamepadsEnabled):
+
+        * Configurations/FeatureDefines.xcconfig:
+
 2014-06-24  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         CSS JIT: Add positionInRootFragments to SelectorFragment
index 0a85c2d..b566172 100644 (file)
@@ -87,7 +87,8 @@ ENABLE_FILTERS = ENABLE_FILTERS;
 ENABLE_FONT_LOAD_EVENTS = ;
 ENABLE_FULLSCREEN_API = $(ENABLE_FULLSCREEN_API_$(PLATFORM_NAME));
 ENABLE_FULLSCREEN_API_macosx = ENABLE_FULLSCREEN_API;
-ENABLE_GAMEPAD = ;
+ENABLE_GAMEPAD = $(ENABLE_GAMEPAD_$(PLATFORM_NAME));
+ENABLE_GAMEPAD_macosx = ENABLE_GAMEPAD;
 ENABLE_GAMEPAD_DEPRECATED = ;
 ENABLE_GEOLOCATION = ENABLE_GEOLOCATION;
 ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING = $(ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING_$(PLATFORM_NAME));
index 5b6a937..73f9d40 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 [
+    EnabledAtRuntime=Gamepads,
     Conditional=GAMEPAD,
     ImplementationLacksVTable
 ] interface Gamepad {
index 1b6f188..0a2e67b 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 [
+    EnabledAtRuntime=Gamepads,
     Conditional=GAMEPAD,
     ImplementationLacksVTable
 ] interface GamepadButton {
index 1577918..904aeb9 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 [
+    EnabledAtRuntime=Gamepads,
     Conditional=GAMEPAD,
     ConstructorTemplate=Event
 ] interface GamepadEvent : Event {
index bac2a73..d35a89e 100644 (file)
@@ -26,6 +26,6 @@
 [
     Conditional=GAMEPAD,
 ] partial interface Navigator {
-    Gamepad[] getGamepads();
+    [EnabledAtRuntime=Gamepads] Gamepad[] getGamepads();
 };
 
index dee49a5..e6d4c75 100644 (file)
@@ -102,6 +102,9 @@ RuntimeEnabledFeatures::RuntimeEnabledFeatures()
 #if ENABLE(FONT_LOAD_EVENTS)
     , m_isFontLoadEventsEnabled(false)
 #endif
+#if ENABLE(GAMEPAD)
+    , m_areGamepadsEnabled(false)
+#endif
 {
 }
 
index e76ab62..a4213f9 100644 (file)
@@ -218,6 +218,11 @@ public:
     void setPluginReplacementEnabled(bool isEnabled) { m_isPluginReplacementEnabled = isEnabled; }
     bool pluginReplacementEnabled() const { return m_isPluginReplacementEnabled; }
 
+#if ENABLE(GAMEPAD)
+    void setGamepadsEnabled(bool areEnabled) { m_areGamepadsEnabled = areEnabled; }
+    bool gamepadsEnabled() const { return m_areGamepadsEnabled; }
+#endif
+
     static RuntimeEnabledFeatures& sharedFeatures();
 
 private:
@@ -295,6 +300,10 @@ private:
     bool m_isFontLoadEventsEnabled;
 #endif
 
+#if ENABLE(GAMEPAD)
+    bool m_areGamepadsEnabled;
+#endif
+
     friend class WTF::NeverDestroyed<RuntimeEnabledFeatures>;
 };
 
index 45b841a..73eb274 100644 (file)
@@ -1940,6 +1940,8 @@ sub GenerateImplementation
         $hashSize++;
     }
 
+    my @runtimeEnabledFunctions = ();
+
     foreach my $function (@{$interface->functions}) {
         next if ($function->isStatic);
         next if $function->{overloadIndex} && $function->{overloadIndex} > 1;
@@ -1965,6 +1967,8 @@ sub GenerateImplementation
             $conditionals{$name} = $conditional;
         }
 
+        push(@runtimeEnabledFunctions, $function) if $function->signature->extendedAttributes->{"EnabledAtRuntime"};
+
         $hashSize++;
     }
 
@@ -2011,6 +2015,20 @@ sub GenerateImplementation
             push(@implContent, "{\n");
             push(@implContent, "    Base::finishCreation(vm);\n");
             push(@implContent, "    reifyStaticProperties(vm, ${className}PrototypeTableValues, *this);\n");
+
+            foreach my $function (@runtimeEnabledFunctions) {
+                my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature);
+                push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
+                AddToImplIncludes("RuntimeEnabledFeatures.h");
+                my $signature = $function->signature;
+                my $enable_function = GetRuntimeEnableFunctionName($signature);
+                my $name = $signature->name;
+                push(@implContent, "    if (!${enable_function}()) {\n");
+                push(@implContent, "        Identifier propertyName(&vm, reinterpret_cast<const LChar*>(\"$name\"), strlen(\"$name\"));\n");
+                push(@implContent, "        removeDirect(vm, propertyName);\n");
+                push(@implContent, "    }\n");
+                push(@implContent, "#endif\n") if $conditionalString;
+            }
             push(@implContent, "}\n\n");
         } else {
             push(@implContent, "void ${className}Prototype::finishCreation(VM& vm)\n");
index 4137398..d7d6e7e 100644 (file)
@@ -1,3 +1,21 @@
+2014-06-24  Brady Eidson  <beidson@apple.com>
+
+        Enable GAMEPAD in the Mac build, but disabled at runtime.
+        https://bugs.webkit.org/show_bug.cgi?id=134255
+
+        Reviewed by Dean Jackson.
+
+        * Configurations/FeatureDefines.xcconfig:
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (-[WebPreferences gamepadsEnabled]):
+        (-[WebPreferences setGamepadsEnabled:]):
+        * WebView/WebPreferencesPrivate.h:
+
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2014-06-24  Dan Bernstein  <mitz@apple.com>
 
         Fixed the iOS build after r170358.
index 0a85c2d..b566172 100644 (file)
@@ -87,7 +87,8 @@ ENABLE_FILTERS = ENABLE_FILTERS;
 ENABLE_FONT_LOAD_EVENTS = ;
 ENABLE_FULLSCREEN_API = $(ENABLE_FULLSCREEN_API_$(PLATFORM_NAME));
 ENABLE_FULLSCREEN_API_macosx = ENABLE_FULLSCREEN_API;
-ENABLE_GAMEPAD = ;
+ENABLE_GAMEPAD = $(ENABLE_GAMEPAD_$(PLATFORM_NAME));
+ENABLE_GAMEPAD_macosx = ENABLE_GAMEPAD;
 ENABLE_GAMEPAD_DEPRECATED = ;
 ENABLE_GEOLOCATION = ENABLE_GEOLOCATION;
 ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING = $(ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING_$(PLATFORM_NAME));
index 6423f74..9cbbd2b 100644 (file)
 #define WebKitMediaSourceEnabledPreferenceKey @"WebKitMediaSourceEnabled"
 #define WebKitShouldConvertPositionStyleOnCopyPreferenceKey @"WebKitShouldConvertPositionStyleOnCopy"
 #define WebKitImageControlsEnabledPreferenceKey @"WebKitImageControlsEnabled"
+#define WebKitGamepadsEnabledPreferenceKey @"WebKitGamepadsEnabled"
 
 #if !TARGET_OS_IPHONE
 // These are private both because callers should be using the cover methods and because the
index 065f8b2..1c2efc1 100644 (file)
@@ -2538,6 +2538,16 @@ static bool needsScreenFontsEnabledQuirk()
     [self _setBoolValue:enabled forKey:WebKitImageControlsEnabledPreferenceKey];
 }
 
+- (BOOL)gamepadsEnabled
+{
+    return [self _boolValueForKey:WebKitGamepadsEnabledPreferenceKey];
+}
+
+- (void)setGamepadsEnabled:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitGamepadsEnabledPreferenceKey];
+}
+
 - (BOOL)shouldConvertPositionStyleOnCopy
 {
     return [self _boolValueForKey:WebKitShouldConvertPositionStyleOnCopyPreferenceKey];
index c935ec1..72b8da3 100644 (file)
@@ -436,6 +436,9 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification;
 - (void)setImageControlsEnabled:(BOOL)flag;
 - (BOOL)imageControlsEnabled;
 
+- (void)setGamepadsEnabled:(BOOL)flag;
+- (BOOL)gamepadsEnabled;
+
 #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < 80000
 - (void)_setAllowCompositingLayerVisualDegradation:(BOOL)flag;
 #endif
index a3fd888..2c2c41f 100644 (file)
@@ -2404,7 +2404,11 @@ static bool needsSelfRetainWhileLoadingQuirk()
     settings.setHiddenPageDOMTimerThrottlingEnabled([preferences hiddenPageDOMTimerThrottlingEnabled]);
 #endif
 
-settings.setHiddenPageCSSAnimationSuspensionEnabled([preferences hiddenPageCSSAnimationSuspensionEnabled]);
+    settings.setHiddenPageCSSAnimationSuspensionEnabled([preferences hiddenPageCSSAnimationSuspensionEnabled]);
+
+#if ENABLE(GAMEPAD)
+    RuntimeEnabledFeatures::sharedFeatures().setGamepadsEnabled([preferences gamepadsEnabled]);
+#endif
 
     NSTimeInterval timeout = [preferences incrementalRenderingSuppressionTimeoutInSeconds];
     if (timeout > 0)
index 622bb65..9784a57 100644 (file)
@@ -1,3 +1,21 @@
+2014-06-24  Brady Eidson  <beidson@apple.com>
+
+        Enable GAMEPAD in the Mac build, but disabled at runtime.
+        https://bugs.webkit.org/show_bug.cgi?id=134255
+
+        Reviewed by Dean Jackson.
+
+        * Configurations/FeatureDefines.xcconfig:
+
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/API/C/WKPreferences.cpp:
+        (WKPreferencesSetGamepadsEnabled):
+        (WKPreferencesGetGamepadsEnabled):
+        * UIProcess/API/C/WKPreferencesRefPrivate.h:
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+
 2014-06-24  Anders Carlsson  <andersca@apple.com>
 
         Add support for v0 legacy decoding
index 0a85c2d..b566172 100644 (file)
@@ -87,7 +87,8 @@ ENABLE_FILTERS = ENABLE_FILTERS;
 ENABLE_FONT_LOAD_EVENTS = ;
 ENABLE_FULLSCREEN_API = $(ENABLE_FULLSCREEN_API_$(PLATFORM_NAME));
 ENABLE_FULLSCREEN_API_macosx = ENABLE_FULLSCREEN_API;
-ENABLE_GAMEPAD = ;
+ENABLE_GAMEPAD = $(ENABLE_GAMEPAD_$(PLATFORM_NAME));
+ENABLE_GAMEPAD_macosx = ENABLE_GAMEPAD;
 ENABLE_GAMEPAD_DEPRECATED = ;
 ENABLE_GEOLOCATION = ENABLE_GEOLOCATION;
 ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING = $(ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING_$(PLATFORM_NAME));
index 24214bb..928a8ba 100644 (file)
     macro(ImageControlsEnabled, imageControlsEnabled, Bool, bool, false) \
     macro(EnableInheritURIQueryComponent, enableInheritURIQueryComponent, Bool, bool, false) \
     macro(ServiceControlsEnabled, serviceControlsEnabled, Bool, bool, false) \
+    macro(GamepadsEnabled, gamepadsEnabled, Bool, bool, false) \
 
 #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
     macro(PDFScaleFactor, pdfScaleFactor, Double, double, 0) \
index 9e39655..20def3a 100644 (file)
@@ -1275,3 +1275,13 @@ bool WKPreferencesGetImageControlsEnabled(WKPreferencesRef preferencesRef)
 {
     return toImpl(preferencesRef)->imageControlsEnabled();
 }
+
+void WKPreferencesSetGamepadsEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+    toImpl(preferencesRef)->setGamepadsEnabled(enabled);
+}
+
+bool WKPreferencesGetGamepadsEnabled(WKPreferencesRef preferencesRef)
+{
+    return toImpl(preferencesRef)->gamepadsEnabled();
+}
index 0939e76..1682ef8 100644 (file)
@@ -330,6 +330,10 @@ WK_EXPORT bool WKPreferencesGetServiceControlsEnabled(WKPreferencesRef preferenc
 WK_EXPORT void WKPreferencesSetImageControlsEnabled(WKPreferencesRef preferencesRef, bool enabled);
 WK_EXPORT bool WKPreferencesGetImageControlsEnabled(WKPreferencesRef preferencesRef);
 
+// Default to false.
+WK_EXPORT void WKPreferencesSetGamepadsEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetGamepadsEnabled(WKPreferencesRef preferencesRef);
+
 #ifdef __cplusplus
 }
 #endif
index 7f3e0f2..e3ecdcd 100644 (file)
@@ -2775,6 +2775,10 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
     settings.setUseImageDocumentForSubframePDF(true);
 #endif
 
+#if ENABLE(GAMEPAD)
+    RuntimeEnabledFeatures::sharedFeatures().setGamepadsEnabled(store.getBoolValueForKey(WebPreferencesKey::gamepadsEnabledKey()));
+#endif
+
     if (store.getBoolValueForKey(WebPreferencesKey::pageVisibilityBasedProcessSuppressionEnabledKey()))
         m_processSuppressionDisabledByWebPreference.stop();
     else