[Web IDL] Specify default values for parameters of type 'unsigned short'
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Apr 2016 18:38:56 +0000 (18:38 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Apr 2016 18:38:56 +0000 (18:38 +0000)
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:

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl

index 3472dbd..f552bc6 100644 (file)
@@ -1,3 +1,24 @@
+2016-04-25  Chris Dumez  <cdumez@apple.com>
+
+        [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  <peavo@outlook.com>
 
         [Win][IndexedDB] Fix build errors.
index 14a3d38..5799bb1 100644 (file)
@@ -3370,12 +3370,16 @@ sub GenerateArgumentsCountCheck
     }
 }
 
-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 @@ sub CanUseWTFOptionalForParameterType
     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 @@ sub GenerateParametersCheck
         # 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 @@ sub GenerateParametersCheck
 
                     $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>()";
index f675cef..d45accd 100644 (file)
@@ -1826,12 +1826,7 @@ bool Internals::isPageBoxVisible(int pageNumber, ExceptionCode& ec)
 // 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
-{
-    return layerTreeAsText(document, 0, ec);
-}
-
-String Internals::layerTreeAsText(Document& document, unsigned flags, ExceptionCode& ec) const
+String Internals::layerTreeAsText(Document& document, unsigned short flags, ExceptionCode& ec) const
 {
     if (!document.frame()) {
         ec = INVALID_ACCESS_ERR;
@@ -1973,12 +1968,7 @@ void Internals::setElementTracksDisplayListReplay(Element& element, bool isTrack
     layer->backing()->setIsTrackingDisplayListReplay(isTrackingReplay);
 }
 
-String Internals::displayListForElement(Element& element, ExceptionCode& ec)
-{
-    return displayListForElement(element, 0, ec);
-}
-
-String Internals::displayListForElement(Element& element, unsigned flags, ExceptionCode& ec)
+String Internals::displayListForElement(Element& element, unsigned short flags, ExceptionCode& ec)
 {
     Document* document = contextDocument();
     if (!document || !document->renderView()) {
@@ -2012,12 +2002,7 @@ String Internals::displayListForElement(Element& element, unsigned flags, Except
     return layer->backing()->displayListAsText(displayListFlags);
 }
 
-String Internals::replayDisplayListForElement(Element& element, ExceptionCode& ec)
-{
-    return replayDisplayListForElement(element, 0, ec);
-}
-
-String Internals::replayDisplayListForElement(Element& element, unsigned flags, ExceptionCode& ec)
+String Internals::replayDisplayListForElement(Element& element, unsigned short flags, ExceptionCode& ec)
 {
     Document* document = contextDocument();
     if (!document || !document->renderView()) {
index e9009ef..e38d14d 100644 (file)
@@ -243,8 +243,7 @@ public:
         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 @@ public:
         // 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;
 
index f78d567..58fc440 100644 (file)
@@ -226,7 +226,7 @@ enum AutoFillButtonType {
     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 @@ enum AutoFillButtonType {
     // 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();