Title: [200037] trunk/Source/WebCore
Revision
200037
Author
[email protected]
Date
2016-04-25 11:38:56 -0700 (Mon, 25 Apr 2016)

Log Message

[Web IDL] Specify default values for parameters of type 'unsigned short'
https://bugs.webkit.org/show_bug.cgi?id=156967

Reviewed by Darin Adler.

Specify default values for parameters of type 'unsigned short' and let
the bindings generator use WTF::Optional<> for the ones without a
default value.

* bindings/scripts/CodeGeneratorJS.pm:
(CanUseWTFOptionalForParameter):
(GenerateParametersCheck):
* testing/Internals.cpp:
(WebCore::Internals::layerTreeAsText): Deleted.
(WebCore::Internals::displayListForElement): Deleted.
(WebCore::Internals::replayDisplayListForElement): Deleted.
* testing/Internals.h:
* testing/Internals.idl:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (200036 => 200037)


--- trunk/Source/WebCore/ChangeLog	2016-04-25 18:38:20 UTC (rev 200036)
+++ trunk/Source/WebCore/ChangeLog	2016-04-25 18:38:56 UTC (rev 200037)
@@ -1,3 +1,24 @@
+2016-04-25  Chris Dumez  <[email protected]>
+
+        [Web IDL] Specify default values for parameters of type 'unsigned short'
+        https://bugs.webkit.org/show_bug.cgi?id=156967
+
+        Reviewed by Darin Adler.
+
+        Specify default values for parameters of type 'unsigned short' and let
+        the bindings generator use WTF::Optional<> for the ones without a
+        default value.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (CanUseWTFOptionalForParameter):
+        (GenerateParametersCheck):
+        * testing/Internals.cpp:
+        (WebCore::Internals::layerTreeAsText): Deleted.
+        (WebCore::Internals::displayListForElement): Deleted.
+        (WebCore::Internals::replayDisplayListForElement): Deleted.
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2016-04-25  Per Arne Vollan  <[email protected]>
 
         [Win][IndexedDB] Fix build errors.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (200036 => 200037)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-04-25 18:38:20 UTC (rev 200036)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-04-25 18:38:56 UTC (rev 200037)
@@ -3370,12 +3370,16 @@
     }
 }
 
-sub CanUseWTFOptionalForParameterType
+sub CanUseWTFOptionalForParameter
 {
-    my $type  = shift;
+    my $parameter = shift;
+    my $type = $parameter->type;
 
     # FIXME: We should progressively stop blacklisting each type below
     # and eventually get rid of this function entirely.
+    return 0 if $parameter->extendedAttributes->{"Clamp"};
+    return 0 if $parameter->isVariadic;
+    return 0 if $codeGenerator->IsCallbackInterface($type);
     return 0 if $codeGenerator->IsEnumType($type);
     return 0 if $codeGenerator->IsTypedArrayType($type);
     return 0 if $codeGenerator->IsWrapperType($type);
@@ -3387,7 +3391,6 @@
     return 0 if $type eq "unrestricted float";
     return 0 if $type eq "unrestricted double";
     return 0 if $type eq "unsigned long";
-    return 0 if $type eq "unsigned short";
 
     return 1;
 }
@@ -3441,7 +3444,7 @@
         # Optional arguments with [Optional=...] should not generate the early call.
         # Optional Dictionary arguments always considered to have default of empty dictionary.
         my $optional = $parameter->isOptional;
-        if ($optional && !defined($parameter->default) && !CanUseWTFOptionalForParameterType($parameter->type) && $argType ne "Dictionary" && !$codeGenerator->IsCallbackInterface($argType)) {
+        if ($optional && !defined($parameter->default) && !CanUseWTFOptionalForParameter($parameter) && $argType ne "Dictionary" && !$codeGenerator->IsCallbackInterface($argType)) {
             # Generate early call if there are enough parameters.
             if (!$hasOptionalArguments) {
                 push(@$outputArray, "\n    size_t argsCount = state->argumentCount();\n");
@@ -3621,7 +3624,7 @@
 
                     $outer = "state->argument($argsIndex).isUndefined() ? $defaultValue : ";
                     $inner = "state->uncheckedArgument($argsIndex)";
-                } elsif ($optional && !defined($parameter->default) && CanUseWTFOptionalForParameterType($parameter->type)) {
+                } elsif ($optional && !defined($parameter->default) && CanUseWTFOptionalForParameter($parameter)) {
                     # Use WTF::Optional<>() for optional parameters that are missing or undefined and that do not have
                     # a default value in the IDL.
                     my $defaultValue = "Optional<$nativeType>()";

Modified: trunk/Source/WebCore/testing/Internals.cpp (200036 => 200037)


--- trunk/Source/WebCore/testing/Internals.cpp	2016-04-25 18:38:20 UTC (rev 200036)
+++ trunk/Source/WebCore/testing/Internals.cpp	2016-04-25 18:38:56 UTC (rev 200037)
@@ -1826,13 +1826,8 @@
 // contextDocument(), with the exception of a few tests that pass a
 // different document, and could just make the call through another Internals
 // instance instead.
-String Internals::layerTreeAsText(Document& document, ExceptionCode& ec) const
+String Internals::layerTreeAsText(Document& document, unsigned short flags, ExceptionCode& ec) const
 {
-    return layerTreeAsText(document, 0, ec);
-}
-
-String Internals::layerTreeAsText(Document& document, unsigned flags, ExceptionCode& ec) const
-{
     if (!document.frame()) {
         ec = INVALID_ACCESS_ERR;
         return String();
@@ -1973,13 +1968,8 @@
     layer->backing()->setIsTrackingDisplayListReplay(isTrackingReplay);
 }
 
-String Internals::displayListForElement(Element& element, ExceptionCode& ec)
+String Internals::displayListForElement(Element& element, unsigned short flags, ExceptionCode& ec)
 {
-    return displayListForElement(element, 0, ec);
-}
-
-String Internals::displayListForElement(Element& element, unsigned flags, ExceptionCode& ec)
-{
     Document* document = contextDocument();
     if (!document || !document->renderView()) {
         ec = INVALID_ACCESS_ERR;
@@ -2012,13 +2002,8 @@
     return layer->backing()->displayListAsText(displayListFlags);
 }
 
-String Internals::replayDisplayListForElement(Element& element, ExceptionCode& ec)
+String Internals::replayDisplayListForElement(Element& element, unsigned short flags, ExceptionCode& ec)
 {
-    return replayDisplayListForElement(element, 0, ec);
-}
-
-String Internals::replayDisplayListForElement(Element& element, unsigned flags, ExceptionCode& ec)
-{
     Document* document = contextDocument();
     if (!document || !document->renderView()) {
         ec = INVALID_ACCESS_ERR;

Modified: trunk/Source/WebCore/testing/Internals.h (200036 => 200037)


--- trunk/Source/WebCore/testing/Internals.h	2016-04-25 18:38:20 UTC (rev 200036)
+++ trunk/Source/WebCore/testing/Internals.h	2016-04-25 18:38:56 UTC (rev 200037)
@@ -243,8 +243,7 @@
         LAYER_TREE_INCLUDES_PAINTING_PHASES = 8,
         LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16
     };
-    String layerTreeAsText(Document&, unsigned flags, ExceptionCode&) const;
-    String layerTreeAsText(Document&, ExceptionCode&) const;
+    String layerTreeAsText(Document&, unsigned short flags, ExceptionCode&) const;
     String repaintRectsAsText(ExceptionCode&) const;
     String scrollingStateTreeAsText(ExceptionCode&) const;
     String mainThreadScrollingReasons(ExceptionCode&) const;
@@ -257,11 +256,9 @@
         // Values need to be kept in sync with Internals.idl.
         DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS = 1,
     };
-    String displayListForElement(Element&, unsigned flags, ExceptionCode&);
-    String displayListForElement(Element&, ExceptionCode&);
+    String displayListForElement(Element&, unsigned short flags, ExceptionCode&);
 
-    String replayDisplayListForElement(Element&, unsigned flags, ExceptionCode&);
-    String replayDisplayListForElement(Element&, ExceptionCode&);
+    String replayDisplayListForElement(Element&, unsigned short flags, ExceptionCode&);
 
     void garbageCollectDocumentResources(ExceptionCode&) const;
 

Modified: trunk/Source/WebCore/testing/Internals.idl (200036 => 200037)


--- trunk/Source/WebCore/testing/Internals.idl	2016-04-25 18:38:20 UTC (rev 200036)
+++ trunk/Source/WebCore/testing/Internals.idl	2016-04-25 18:38:56 UTC (rev 200037)
@@ -226,7 +226,7 @@
     const unsigned short LAYER_TREE_INCLUDES_REPAINT_RECTS = 4;
     const unsigned short LAYER_TREE_INCLUDES_PAINTING_PHASES = 8;
     const unsigned short LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16;
-    [RaisesException] DOMString layerTreeAsText(Document document, optional unsigned short flags);
+    [RaisesException] DOMString layerTreeAsText(Document document, optional unsigned short flags = 0);
 
     [RaisesException] DOMString scrollingStateTreeAsText();
     [RaisesException] DOMString mainThreadScrollingReasons(); // FIXME: rename to synchronousScrollingReasons().
@@ -241,9 +241,9 @@
     // Flags for displayListForElement.
     const unsigned short DISPLAY_LIST_INCLUDES_PLATFORM_OPERATIONS = 1;
     // Returns the recorded display list.
-    [RaisesException] DOMString displayListForElement(Element element, optional unsigned short flags);
+    [RaisesException] DOMString displayListForElement(Element element, optional unsigned short flags = 0);
     // Returns the display list that was actually painted.
-    [RaisesException] DOMString replayDisplayListForElement(Element element, optional unsigned short flags);
+    [RaisesException] DOMString replayDisplayListForElement(Element element, optional unsigned short flags = 0);
 
     [RaisesException] void garbageCollectDocumentResources();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to