Title: [199096] trunk/Source
Revision
199096
Author
[email protected]
Date
2016-04-05 23:10:32 -0700 (Tue, 05 Apr 2016)

Log Message

Add support for [EnabledAtRuntime] operations on DOMWindow
https://bugs.webkit.org/show_bug.cgi?id=156272

Reviewed by Alex Christensen.

Source/_javascript_Core:

Add identifier for 'fetch' so it can be used from the generated
bindings.

* runtime/CommonIdentifiers.h:

Source/WebCore:

Add support for [EnabledAtRuntime] operations on DOMWindow by omitting
such operations from the static table and add them at run-time in
JSDOMWindow::finishCreation() if the corresponding feature is enabled.

This was needed for window.fetch() for which a hack was temporarily
landed in r199081. This patch drops this hack now that the generated
bindings do the right thing.

* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSDOMGlobalObject::scriptExecutionContext):
Drop hack landed in r199081.

* bindings/scripts/CodeGeneratorJS.pm:
(OperationShouldBeOnInstance):
(GeneratePropertiesHashTable):
(GenerateImplementation):
Add support for [EnabledAtRuntime] operations on DOMWindow.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (199095 => 199096)


--- trunk/Source/_javascript_Core/ChangeLog	2016-04-06 05:45:13 UTC (rev 199095)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-04-06 06:10:32 UTC (rev 199096)
@@ -1,3 +1,15 @@
+2016-04-05  Chris Dumez  <[email protected]>
+
+        Add support for [EnabledAtRuntime] operations on DOMWindow
+        https://bugs.webkit.org/show_bug.cgi?id=156272
+
+        Reviewed by Alex Christensen.
+
+        Add identifier for 'fetch' so it can be used from the generated
+        bindings.
+
+        * runtime/CommonIdentifiers.h:
+
 2016-04-05  Alex Christensen  <[email protected]>
 
         Make CMake-generated binaries on Mac able to run

Modified: trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h (199095 => 199096)


--- trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h	2016-04-06 05:45:13 UTC (rev 199095)
+++ trunk/Source/_javascript_Core/runtime/CommonIdentifiers.h	2016-04-06 06:10:32 UTC (rev 199096)
@@ -143,6 +143,7 @@
     macro(exec) \
     macro(executionCount) \
     macro(exitKind) \
+    macro(fetch) \
     macro(flags) \
     macro(focus) \
     macro(forEach) \

Modified: trunk/Source/WebCore/ChangeLog (199095 => 199096)


--- trunk/Source/WebCore/ChangeLog	2016-04-06 05:45:13 UTC (rev 199095)
+++ trunk/Source/WebCore/ChangeLog	2016-04-06 06:10:32 UTC (rev 199096)
@@ -1,3 +1,28 @@
+2016-04-05  Chris Dumez  <[email protected]>
+
+        Add support for [EnabledAtRuntime] operations on DOMWindow
+        https://bugs.webkit.org/show_bug.cgi?id=156272
+
+        Reviewed by Alex Christensen.
+
+        Add support for [EnabledAtRuntime] operations on DOMWindow by omitting
+        such operations from the static table and add them at run-time in
+        JSDOMWindow::finishCreation() if the corresponding feature is enabled.
+
+        This was needed for window.fetch() for which a hack was temporarily
+        landed in r199081. This patch drops this hack now that the generated
+        bindings do the right thing.
+
+        * bindings/js/JSDOMGlobalObject.cpp:
+        (WebCore::JSDOMGlobalObject::scriptExecutionContext):
+        Drop hack landed in r199081.
+        
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (OperationShouldBeOnInstance):
+        (GeneratePropertiesHashTable):
+        (GenerateImplementation):
+        Add support for [EnabledAtRuntime] operations on DOMWindow.
+
 2016-04-05  Alex Christensen  <[email protected]>
 
         Make CMake-generated binaries on Mac able to run

Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp (199095 => 199096)


--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp	2016-04-06 05:45:13 UTC (rev 199095)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp	2016-04-06 06:10:32 UTC (rev 199096)
@@ -112,15 +112,6 @@
 {
     Base::finishCreation(vm, thisValue);
     ASSERT(inherits(info()));
-
-#if ENABLE(FETCH_API)
-    // FIXME: Modify the bindings generator so this was never added in the first place.
-    if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) {
-        JSObject* prototype = getPrototypeDirect().getObject();
-        ASSERT(prototype);
-        prototype->putDirect(vm, Identifier::fromString(&vm, "fetch"), jsUndefined());
-    }
-#endif
     
     addBuiltinGlobals(vm);
 }

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (199095 => 199096)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-04-06 05:45:13 UTC (rev 199095)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-04-06 06:10:32 UTC (rev 199096)
@@ -721,8 +721,8 @@
     my $interface = shift;
     my $function = shift;
 
-    # FIXME: The bindings generator does not support putting runtime-enabled on the instance yet.
-    return 0 if $function->signature->extendedAttributes->{"EnabledAtRuntime"};
+    # FIXME: The bindings generator does not support putting runtime-enabled on the instance yet (except for Window).
+    return 0 if $function->signature->extendedAttributes->{"EnabledAtRuntime"} && $interface->name ne "DOMWindow";
 
     return 1 if IsDOMGlobalObject($interface);
 
@@ -1448,6 +1448,12 @@
         next if OperationShouldBeOnInstance($interface, $function) != $isInstance;
         next if $function->signature->name eq "[Symbol.Iterator]";
 
+        # DOMWindow adds RuntimeEnabled operations after creation so do not add them to the static table.
+        if ($interfaceName eq "DOMWindow" && $function->signature->extendedAttributes->{"EnabledAtRuntime"}) {
+            $propertyCount -= 1;
+            next;
+        }
+
         my $name = $function->signature->name;
         push(@$hashKeys, $name);
 
@@ -2213,6 +2219,23 @@
             push(@implContent, "    }\n");
             push(@implContent, "#endif\n") if $conditionalString;
         }
+        # Support for RuntimeEnabled operations on DOMWindow.
+        foreach my $function (@{$interface->functions}) {
+            next unless $function->signature->extendedAttributes->{"EnabledAtRuntime"};
+            next if $function->{overloadIndex} && $function->{overloadIndex} > 1;
+
+            AddToImplIncludes("RuntimeEnabledFeatures.h");
+            my $conditionalString = $codeGenerator->GenerateConditionalString($function->signature);
+            push(@implContent, "#if ${conditionalString}\n") if $conditionalString;
+            my $enable_function = GetRuntimeEnableFunctionName($function->signature);
+            my $functionName = $function->signature->name;
+            my $implementationFunction = GetFunctionName($interface, $className, $function);
+            my $functionLength = GetFunctionLength($function);
+            my $jsAttributes = ComputeFunctionSpecial($interface, $function);
+            push(@implContent, "    if (${enable_function}())\n");
+            push(@implContent, "        putDirectNativeFunction(vm, this, vm.propertyNames->$functionName, $functionLength, $implementationFunction, NoIntrinsic, attributesForStructure($jsAttributes));\n");
+            push(@implContent, "#endif\n") if $conditionalString;
+        }
         push(@implContent, "}\n\n");
     } elsif ($codeGenerator->InheritsInterface($interface, "WorkerGlobalScope")) {
         AddIncludesForTypeInImpl($interfaceName);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to