Title: [206877] trunk/Source/WebCore
Revision
206877
Author
cdu...@apple.com
Date
2016-10-06 13:22:16 -0700 (Thu, 06 Oct 2016)

Log Message

[WebIDL] Add support for having dictionaries in their own IDL file
https://bugs.webkit.org/show_bug.cgi?id=162912

Reviewed by Darin Adler.

Add support for having dictionaries in their own IDL file so that they
can be shared by multiple interfaces.

Leverage this new support to merge Element::ScrollToOptions and
DOMWindow::ScrollToOptions.

No new tests, extended bindings tests.

* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* bindings/scripts/CodeGenerator.pm:
(ProcessDocument):
(IDLFileForInterface):
(GetDictionaryByName):
(IsDictionaryType):
(HasEnumImplementationNameOverride): Deleted.
(GetEnumImplementationNameOverride): Deleted.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateDictionary):
(GetEnumerationClassName):
(GenerateEnumerationImplementationContent):
(GenerateEnumerationHeaderContent):
(GetDictionaryClassName):
(GenerateDefaultValue):
(GenerateDictionaryHeaderContent):
(GenerateDictionariesHeaderContent):
(GenerateDictionaryImplementationContent):
(GenerateDictionariesImplementationContent):
(GenerateHeader):
(GenerateImplementation):
(GenerateParametersCheck):
(GenerateDictionaryHeader):
(GenerateDictionaryImplementation):
(GenerateCallbackHeader):
(GenerateCallbackImplementation):
(GetNativeType):
(JSValueToNative):
(GetNestedClassName): Deleted.
(GenerateConversionRuleWithLeadingComma): Deleted.
(addIterableProperties): Deleted.
* bindings/scripts/preprocess-idls.pl:
(containsInterfaceOrExceptionFromIDL):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionOperationWithExternalDictionaryParameter):
(WebCore::jsTestObjPrototypeFunctionAttachShadowRoot): Deleted.
* bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: Added.
(WebCore::convertDictionary<TestStandaloneDictionary>):
* bindings/scripts/test/JS/JSTestStandaloneDictionary.h: Added.
* bindings/scripts/test/TestObj.idl:
* bindings/scripts/test/TestStandaloneDictionary.idl: Added.
* dom/Element.h:
* dom/Element.idl:
* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::scrollTo):
* page/DOMWindow.h:
* page/DOMWindow.idl:
* page/ScrollToOptions.h: Added.
* page/ScrollToOptions.idl: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (206876 => 206877)


--- trunk/Source/WebCore/CMakeLists.txt	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/CMakeLists.txt	2016-10-06 20:22:16 UTC (rev 206877)
@@ -576,6 +576,7 @@
     page/PerformanceResourceTiming.idl
     page/PerformanceTiming.idl
     page/Screen.idl
+    page/ScrollToOptions.idl
     page/WebKitPoint.idl
     page/WindowEventHandlers.idl
     page/WindowOrWorkerGlobalScope.idl

Modified: trunk/Source/WebCore/ChangeLog (206876 => 206877)


--- trunk/Source/WebCore/ChangeLog	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/ChangeLog	2016-10-06 20:22:16 UTC (rev 206877)
@@ -1,3 +1,71 @@
+2016-10-06  Chris Dumez  <cdu...@apple.com>
+
+        [WebIDL] Add support for having dictionaries in their own IDL file
+        https://bugs.webkit.org/show_bug.cgi?id=162912
+
+        Reviewed by Darin Adler.
+
+        Add support for having dictionaries in their own IDL file so that they
+        can be shared by multiple interfaces.
+
+        Leverage this new support to merge Element::ScrollToOptions and
+        DOMWindow::ScrollToOptions.
+
+        No new tests, extended bindings tests.
+
+        * CMakeLists.txt:
+        * DerivedSources.cpp:
+        * DerivedSources.make:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/scripts/CodeGenerator.pm:
+        (ProcessDocument):
+        (IDLFileForInterface):
+        (GetDictionaryByName):
+        (IsDictionaryType):
+        (HasEnumImplementationNameOverride): Deleted.
+        (GetEnumImplementationNameOverride): Deleted.
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateDictionary):
+        (GetEnumerationClassName):
+        (GenerateEnumerationImplementationContent):
+        (GenerateEnumerationHeaderContent):
+        (GetDictionaryClassName):
+        (GenerateDefaultValue):
+        (GenerateDictionaryHeaderContent):
+        (GenerateDictionariesHeaderContent):
+        (GenerateDictionaryImplementationContent):
+        (GenerateDictionariesImplementationContent):
+        (GenerateHeader):
+        (GenerateImplementation):
+        (GenerateParametersCheck):
+        (GenerateDictionaryHeader):
+        (GenerateDictionaryImplementation):
+        (GenerateCallbackHeader):
+        (GenerateCallbackImplementation):
+        (GetNativeType):
+        (JSValueToNative):
+        (GetNestedClassName): Deleted.
+        (GenerateConversionRuleWithLeadingComma): Deleted.
+        (addIterableProperties): Deleted.
+        * bindings/scripts/preprocess-idls.pl:
+        (containsInterfaceOrExceptionFromIDL):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjPrototypeFunctionOperationWithExternalDictionaryParameter):
+        (WebCore::jsTestObjPrototypeFunctionAttachShadowRoot): Deleted.
+        * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: Added.
+        (WebCore::convertDictionary<TestStandaloneDictionary>):
+        * bindings/scripts/test/JS/JSTestStandaloneDictionary.h: Added.
+        * bindings/scripts/test/TestObj.idl:
+        * bindings/scripts/test/TestStandaloneDictionary.idl: Added.
+        * dom/Element.h:
+        * dom/Element.idl:
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::scrollTo):
+        * page/DOMWindow.h:
+        * page/DOMWindow.idl:
+        * page/ScrollToOptions.h: Added.
+        * page/ScrollToOptions.idl: Added.
+
 2016-10-06  Brent Fulgham  <bfulg...@apple.com>
 
         Unreviewed build fix.

Modified: trunk/Source/WebCore/DerivedSources.cpp (206876 => 206877)


--- trunk/Source/WebCore/DerivedSources.cpp	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/DerivedSources.cpp	2016-10-06 20:22:16 UTC (rev 206877)
@@ -419,6 +419,7 @@
 #include "JSRTCTrackEvent.cpp"
 #include "JSScreen.cpp"
 #include "JSScriptProcessorNode.cpp"
+#include "JSScrollToOptions.cpp"
 #include "JSSecurityPolicyViolationEvent.cpp"
 #include "JSSourceBuffer.cpp"
 #include "JSSourceBufferList.cpp"

Modified: trunk/Source/WebCore/DerivedSources.make (206876 => 206877)


--- trunk/Source/WebCore/DerivedSources.make	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/DerivedSources.make	2016-10-06 20:22:16 UTC (rev 206877)
@@ -532,6 +532,7 @@
     $(WebCore)/page/PerformanceResourceTiming.idl \
     $(WebCore)/page/PerformanceTiming.idl \
     $(WebCore)/page/Screen.idl \
+    $(WebCore)/page/ScrollToOptions.idl \
     $(WebCore)/page/UserMessageHandler.idl \
     $(WebCore)/page/UserMessageHandlersNamespace.idl \
     $(WebCore)/page/WebKitNamespace.idl \

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (206876 => 206877)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-10-06 20:22:16 UTC (rev 206877)
@@ -2871,6 +2871,8 @@
 		83120C711C56F3FB001CB112 /* HTMLDataElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 834B86A71C56E83A00F3F0E3 /* HTMLDataElement.h */; };
 		832B843419D8E55100B26055 /* SVGAnimateElementBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 832B843319D8E55100B26055 /* SVGAnimateElementBase.h */; };
 		832B843619D8E57400B26055 /* SVGAnimateElementBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 832B843519D8E57400B26055 /* SVGAnimateElementBase.cpp */; };
+		834476EE1DA5BC57002B6ED2 /* JSScrollToOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83E9B3001DA5A51E00FFE8F6 /* JSScrollToOptions.cpp */; };
+		834476EF1DA5BC5E002B6ED2 /* JSScrollToOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E9B3011DA5A51E00FFE8F6 /* JSScrollToOptions.h */; };
 		8348BFAB1B85729800912F36 /* ClassCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8348BFA91B85729500912F36 /* ClassCollection.cpp */; };
 		8348BFAC1B85729800912F36 /* ClassCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 8348BFAA1B85729500912F36 /* ClassCollection.h */; };
 		834DD4F41BE08989002C9C3E /* PageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 834DD4F31BE08989002C9C3E /* PageMac.mm */; };
@@ -2915,6 +2917,7 @@
 		83C1D434178D5AB500141E68 /* SVGPathSegLinetoVerticalRel.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C1D422178D5AB400141E68 /* SVGPathSegLinetoVerticalRel.h */; };
 		83C1D435178D5AB500141E68 /* SVGPathSegMovetoAbs.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C1D423178D5AB400141E68 /* SVGPathSegMovetoAbs.h */; };
 		83C1D436178D5AB500141E68 /* SVGPathSegMovetoRel.h in Headers */ = {isa = PBXBuildFile; fileRef = 83C1D424178D5AB400141E68 /* SVGPathSegMovetoRel.h */; };
+		83C5795D1DA5C301006FACA8 /* ScrollToOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 8350C3E71DA59B6200356446 /* ScrollToOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		83D35AEC1C7187FA00F70D5A /* XMLHttpRequestEventTarget.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D35AEA1C7187ED00F70D5A /* XMLHttpRequestEventTarget.h */; };
 		83D35AF11C718D9000F70D5A /* JSXMLHttpRequestEventTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83D35AEF1C718D8400F70D5A /* JSXMLHttpRequestEventTarget.cpp */; };
 		83D35AF21C718D9000F70D5A /* JSXMLHttpRequestEventTarget.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D35AF01C718D8400F70D5A /* JSXMLHttpRequestEventTarget.h */; };
@@ -9999,6 +10002,8 @@
 		834B86A81C56E93E00F3F0E3 /* JSHTMLDataElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLDataElement.h; sourceTree = "<group>"; };
 		834B86A91C56E93E00F3F0E3 /* JSHTMLDataElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLDataElement.cpp; sourceTree = "<group>"; };
 		834DD4F31BE08989002C9C3E /* PageMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageMac.mm; sourceTree = "<group>"; };
+		8350C3E71DA59B6200356446 /* ScrollToOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollToOptions.h; sourceTree = "<group>"; };
+		8350C3E81DA59B6200356446 /* ScrollToOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ScrollToOptions.idl; sourceTree = "<group>"; };
 		83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFamily.h; sourceTree = "<group>"; };
 		835D363619FF6193004C93AB /* StyleBuilderCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleBuilderCustom.h; sourceTree = "<group>"; };
 		835F8B261D2D90BA00E408EC /* Slotable.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Slotable.idl; sourceTree = "<group>"; };
@@ -10046,6 +10051,8 @@
 		83E359A01BB1031D002CEB98 /* JSHTMLTimeElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLTimeElement.h; sourceTree = "<group>"; };
 		83E359A11BB1031D002CEB98 /* JSHTMLTimeElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLTimeElement.cpp; sourceTree = "<group>"; };
 		83E959E11B8BC22B004D9385 /* NativeNodeFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeNodeFilter.h; sourceTree = "<group>"; };
+		83E9B3001DA5A51E00FFE8F6 /* JSScrollToOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScrollToOptions.cpp; sourceTree = "<group>"; };
+		83E9B3011DA5A51E00FFE8F6 /* JSScrollToOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollToOptions.h; sourceTree = "<group>"; };
 		83F1206A1B8C103600D75F63 /* JSNodeFilterCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeFilterCustom.cpp; sourceTree = "<group>"; };
 		83F570AD1C53268E007FD6CB /* JSXMLDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSXMLDocument.h; sourceTree = "<group>"; };
 		83F570AE1C53268E007FD6CB /* JSXMLDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXMLDocument.cpp; sourceTree = "<group>"; };
@@ -17362,6 +17369,8 @@
 				BCEC01BA0C274DAC009F4EC9 /* Screen.cpp */,
 				BCEC01BB0C274DAC009F4EC9 /* Screen.h */,
 				BCEC01BC0C274DAC009F4EC9 /* Screen.idl */,
+				8350C3E71DA59B6200356446 /* ScrollToOptions.h */,
+				8350C3E81DA59B6200356446 /* ScrollToOptions.idl */,
 				BCD0E0F70E972C3500265DEA /* SecurityOrigin.cpp */,
 				BCD0E0F80E972C3500265DEA /* SecurityOrigin.h */,
 				51E3AA081B98BC9A0036AD81 /* SecurityOriginData.cpp */,
@@ -21376,6 +21385,8 @@
 				8A9A587711E84C98008ACFD1 /* JSPerformanceTiming.h */,
 				BCEC01C00C274DDD009F4EC9 /* JSScreen.cpp */,
 				BCEC01C10C274DDD009F4EC9 /* JSScreen.h */,
+				83E9B3001DA5A51E00FFE8F6 /* JSScrollToOptions.cpp */,
+				83E9B3011DA5A51E00FFE8F6 /* JSScrollToOptions.h */,
 				7C73FB0F191EF6F4007DE061 /* JSUserMessageHandler.cpp */,
 				7C73FB10191EF6F4007DE061 /* JSUserMessageHandler.h */,
 				7C73FB0A191EF5A8007DE061 /* JSUserMessageHandlersNamespace.cpp */,
@@ -25031,6 +25042,7 @@
 				40ECAE7E16B8B67200C36103 /* JSDOMError.h in Headers */,
 				2E0888D51148848A00AF4265 /* JSDOMFormData.h in Headers */,
 				E1C36C030EB076D6007410BC /* JSDOMGlobalObject.h in Headers */,
+				834476EF1DA5BC5E002B6ED2 /* JSScrollToOptions.h in Headers */,
 				7C2BDD3E17C7F98C0038FF15 /* JSDOMGlobalObjectTask.h in Headers */,
 				65DF31F809D1CC60000BE325 /* JSDOMImplementation.h in Headers */,
 				4138F8581D253F0E001CB61E /* JSDOMIterator.h in Headers */,
@@ -26191,6 +26203,7 @@
 				0854B0191255E4E600B9CDD0 /* RenderSVGText.h in Headers */,
 				0854B01B1255E4E600B9CDD0 /* RenderSVGTextPath.h in Headers */,
 				436708E912D9CA4B00044234 /* RenderSVGTransformableContainer.h in Headers */,
+				83C5795D1DA5C301006FACA8 /* ScrollToOptions.h in Headers */,
 				0854B01D1255E4E600B9CDD0 /* RenderSVGTSpan.h in Headers */,
 				436708EB12D9CA4B00044234 /* RenderSVGViewportContainer.h in Headers */,
 				A8DF4AEB0980C42C0052981B /* RenderTable.h in Headers */,
@@ -30124,6 +30137,7 @@
 				71CC7A20152A0BFE009EEAF9 /* SVGAnimatedEnumeration.cpp in Sources */,
 				43F6FD9613BCD0B100224052 /* SVGAnimatedInteger.cpp in Sources */,
 				1A3586E115264F950022A659 /* SVGAnimatedIntegerOptionalInteger.cpp in Sources */,
+				834476EE1DA5BC57002B6ED2 /* JSScrollToOptions.cpp in Sources */,
 				4381763B13A697D4007D1187 /* SVGAnimatedLength.cpp in Sources */,
 				431A2FD713B7707A007791E4 /* SVGAnimatedLengthList.cpp in Sources */,
 				43A0F0B113AC7D6D00A5F0A7 /* SVGAnimatedNumber.cpp in Sources */,

Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (206876 => 206877)


--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm	2016-10-06 20:22:16 UTC (rev 206877)
@@ -138,6 +138,7 @@
 # Cache of IDL file pathnames.
 my $idlFiles;
 my $cachedInterfaces = {};
+my $cachedExternalDictionaries = {};
 
 # Default constructor
 sub new
@@ -199,6 +200,14 @@
         $codeGenerator->GenerateInterface($interface, $defines, $useDocument->enumerations, $useDocument->dictionaries);
         $codeGenerator->WriteData($interface, $useOutputDir, $useOutputHeadersDir);
     }
+
+    # It is possible to have dictionaries in an IDL file without any interface.
+    unless (@$interfaces) {
+        foreach my $dictionary (@{$useDocument->dictionaries}) {
+            $codeGenerator->GenerateDictionary($dictionary);
+            $codeGenerator->WriteData($dictionary, $useOutputDir, $useOutputHeadersDir);
+        }
+    }
 }
 
 sub FileNamePrefix
@@ -449,14 +458,6 @@
     return $enumTypeImplementationNameOverrides{$type};
 }
 
-sub IsDictionaryType
-{
-    my ($object, $type) = @_;
-
-    return 1 if exists $dictionaryTypes{$type};
-    return 0;
-}
-
 sub GetDictionaryByName
 {
     my ($object, $name) = @_;
@@ -465,8 +466,47 @@
     for my $dictionary (@{$useDocument->dictionaries}) {
         return $dictionary if $dictionary->name eq $name;
     }
+
+    return $cachedExternalDictionaries->{$name} if exists($cachedExternalDictionaries->{$name});
+
+    # Find the IDL file associated with the dictionary.
+    my $filename = $object->IDLFileForInterface($name) or return;
+
+    # Do a fast check to see if it seems to contain a dictionary.
+    my $fileContents = slurp($filename);
+
+    if ($fileContents =~ /\bdictionary\s+$name/gs) {
+        # Parse the IDL.
+        my $parser = IDLParser->new(1);
+        my $document = $parser->Parse($filename, $defines, $preprocessor);
+
+        foreach my $dictionary (@{$document->dictionaries}) {
+            next unless $dictionary->name eq $name;
+
+            $cachedExternalDictionaries->{$name} = $dictionary;
+            my $implementedAs = $dictionary->extendedAttributes->{ImplementedAs};
+            $dictionaryTypeImplementationNameOverrides{$dictionary->name} = $implementedAs if $implementedAs;
+            return $dictionary;
+        }
+    }
+    $cachedExternalDictionaries->{$name} = undef;
 }
 
+sub IsDictionaryType
+{
+    my ($object, $type) = @_;
+
+    return $type =~ /^[A-Z]/ && defined($object->GetDictionaryByName($type));
+}
+
+# A dictionary defined in its own IDL file.
+sub IsExternalDictionaryType
+{
+    my ($object, $type) = @_;
+
+    return $object->IsDictionaryType($type) && defined($cachedExternalDictionaries->{$type});
+}
+
 sub HasDictionaryImplementationNameOverride
 {
     my ($object, $type) = @_;
@@ -660,6 +700,16 @@
     return $ret;
 }
 
+sub slurp {
+    my $file = shift;
+
+    open my $fh, '<', $file or die;
+    local $/ = undef;
+    my $content = <$fh>;
+    close $fh;
+    return $content;
+}
+
 sub trim
 {
     my $string = shift;

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (206876 => 206877)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2016-10-06 20:22:16 UTC (rev 206877)
@@ -120,6 +120,15 @@
     return $reference;
 }
 
+sub GenerateDictionary
+{
+    my ($object, $dictionary) = @_;
+
+    my $className = GetDictionaryClassName($dictionary->name);
+    $object->GenerateDictionaryHeader($dictionary, $className);
+    $object->GenerateDictionaryImplementation($dictionary, $className);
+}
+
 sub GenerateInterface
 {
     my ($object, $interface, $defines, $enumerations, $dictionaries) = @_;
@@ -783,12 +792,13 @@
 
 sub GetEnumerationClassName
 {
-    my ($interface, $name) = @_;
+    my ($name, $interface) = @_;
 
     if ($codeGenerator->HasEnumImplementationNameOverride($name)) {
         return $codeGenerator->GetEnumImplementationNameOverride($name);
     }
 
+    return $name unless defined($interface);
     return GetNestedClassName($interface, $name);
 }
 
@@ -802,7 +812,7 @@
     return $name;
 }
 
-sub GenerateEnumerationImplementationContent
+sub GenerateEnumerationsImplementationContent
 {
     my ($interface, $enumerations) = @_;
 
@@ -812,7 +822,7 @@
     foreach my $enumeration (@$enumerations) {
         my $name = $enumeration->name;
 
-        my $className = GetEnumerationClassName($interface, $name);
+        my $className = GetEnumerationClassName($name, $interface);
 
         # FIXME: A little ugly to have this be a side effect instead of a return value.
         AddToImplIncludes("<runtime/JSString.h>");
@@ -888,7 +898,7 @@
     return $result;
 }
 
-sub GenerateEnumerationHeaderContent
+sub GenerateEnumerationsHeaderContent
 {
     my ($interface, $enumerations) = @_;
 
@@ -904,7 +914,7 @@
     foreach my $enumeration (@$enumerations) {
         my $name = $enumeration->name;
 
-        my $className = GetEnumerationClassName($interface, $name);
+        my $className = GetEnumerationClassName($name, $interface);
 
         my $conditionalString = $codeGenerator->GenerateConditionalString($enumeration);
         $result .= "#if ${conditionalString}\n\n" if $conditionalString;
@@ -926,12 +936,14 @@
 
 sub GetDictionaryClassName
 {
-    my ($interface, $name) = @_;
+    my ($name, $interface) = @_;
 
     if ($codeGenerator->HasDictionaryImplementationNameOverride($name)) {
         return $codeGenerator->GetDictionaryImplementationNameOverride($name);
     }
 
+    return $name if $codeGenerator->IsExternalDictionaryType($name);
+    return $name unless defined($interface);
     return GetNestedClassName($interface, $name);
 }
 
@@ -944,7 +956,7 @@
     if ($codeGenerator->IsEnumType($member->type)) {
         # FIXME: Would be nice to report an error if the value does not have quote marks around it.
         # FIXME: Would be nice to report an error if the value is not one of the enumeration values.
-        my $className = GetEnumerationClassName($interface, $member->type);
+        my $className = GetEnumerationClassName($member->type, $interface);
         my $enumerationValueName = GetEnumerationValueName(substr($value, 1, -1));
         $value = $className . "::" . $enumerationValueName;
     }
@@ -975,6 +987,18 @@
 
 sub GenerateDictionaryHeaderContent
 {
+    my ($dictionary, $className) = @_;
+
+    my $result = "";
+    my $conditionalString = $codeGenerator->GenerateConditionalString($dictionary);
+    $result .= "#if ${conditionalString}\n\n" if $conditionalString;
+    $result .= "template<> Optional<$className> convertDictionary<$className>(JSC::ExecState&, JSC::JSValue);\n\n";
+    $result .= "#endif\n\n" if $conditionalString;
+    return $result;
+}
+
+sub GenerateDictionariesHeaderContent
+{
     my ($interface, $allDictionaries) = @_;
 
     return "" unless @$allDictionaries;
@@ -983,17 +1007,9 @@
 
     my $result = "";
     foreach my $dictionary (@$allDictionaries) {
-        my $name = $dictionary->name;
-
-        my $conditionalString = $codeGenerator->GenerateConditionalString($dictionary);
-        $result .= "#if ${conditionalString}\n\n" if $conditionalString;
-
         $headerIncludes{$interface->name . ".h"} = 1;
-
-        my $className = GetDictionaryClassName($interface, $name);
-        $result .= "template<> Optional<$className> convertDictionary<$className>(JSC::ExecState&, JSC::JSValue);\n\n";
-
-        $result .= "#endif\n\n" if $conditionalString;
+        my $className = GetDictionaryClassName($dictionary->name, $interface);
+        $result .= GenerateDictionaryHeaderContent($dictionary, $className);
     }
     return $result;
 }
@@ -1000,126 +1016,136 @@
 
 sub GenerateDictionaryImplementationContent
 {
-    my ($interface, $allDictionaries) = @_;
+    my ($dictionary, $className, $interface) = @_;
 
     my $result = "";
-    foreach my $dictionary (@$allDictionaries) {
-        my $name = $dictionary->name;
 
-        my $conditionalString = $codeGenerator->GenerateConditionalString($dictionary);
-        $result .= "#if ${conditionalString}\n\n" if $conditionalString;
+    my $name = $dictionary->name;
 
-        my $className = GetDictionaryClassName($interface, $name);
+    my $conditionalString = $codeGenerator->GenerateConditionalString($dictionary);
+    $result .= "#if ${conditionalString}\n\n" if $conditionalString;
 
-        # FIXME: A little ugly to have this be a side effect instead of a return value.
-        AddToImplIncludes("JSDOMConvert.h");
+    # FIXME: A little ugly to have this be a side effect instead of a return value.
+    AddToImplIncludes("JSDOMConvert.h");
 
-        # https://heycam.github.io/webidl/#es-dictionary
-        $result .= "template<> Optional<$className> convertDictionary<$className>(ExecState& state, JSValue value)\n";
-        $result .= "{\n";
-        $result .= "    VM& vm = state.vm();\n";
-        $result .= "    auto throwScope = DECLARE_THROW_SCOPE(vm);\n";
-        $result .= "    bool isNullOrUndefined = value.isUndefinedOrNull();\n";
-        $result .= "    auto* object = isNullOrUndefined ? nullptr : value.getObject();\n";
-        # 1. If Type(V) is not Undefined, Null or Object, then throw a TypeError.
-        $result .= "    if (UNLIKELY(!isNullOrUndefined && !object)) {\n";
-        $result .= "        throwTypeError(&state, throwScope);\n";
-        $result .= "        return Nullopt;\n";
-        $result .= "    }\n";
+    # https://heycam.github.io/webidl/#es-dictionary
+    $result .= "template<> Optional<$className> convertDictionary<$className>(ExecState& state, JSValue value)\n";
+    $result .= "{\n";
+    $result .= "    VM& vm = state.vm();\n";
+    $result .= "    auto throwScope = DECLARE_THROW_SCOPE(vm);\n";
+    $result .= "    bool isNullOrUndefined = value.isUndefinedOrNull();\n";
+    $result .= "    auto* object = isNullOrUndefined ? nullptr : value.getObject();\n";
+    # 1. If Type(V) is not Undefined, Null or Object, then throw a TypeError.
+    $result .= "    if (UNLIKELY(!isNullOrUndefined && !object)) {\n";
+    $result .= "        throwTypeError(&state, throwScope);\n";
+    $result .= "        return Nullopt;\n";
+    $result .= "    }\n";
 
-        # 2. If V is a native RegExp object, then throw a TypeError.
-        # FIXME: This RegExp special handling is likely to go away in the specification.
-        $result .= "    if (UNLIKELY(object && object->type() == RegExpObjectType)) {\n";
-        $result .= "        throwTypeError(&state, throwScope);\n";
-        $result .= "        return Nullopt;\n";
-        $result .= "    }\n";
+    # 2. If V is a native RegExp object, then throw a TypeError.
+    # FIXME: This RegExp special handling is likely to go away in the specification.
+    $result .= "    if (UNLIKELY(object && object->type() == RegExpObjectType)) {\n";
+    $result .= "        throwTypeError(&state, throwScope);\n";
+    $result .= "        return Nullopt;\n";
+    $result .= "    }\n";
 
-        # 3. Let dict be an empty dictionary value of type D; every dictionary member is initially considered to be not present.
+    # 3. Let dict be an empty dictionary value of type D; every dictionary member is initially considered to be not present.
 
-        # 4. Let dictionaries be a list consisting of D and all of D’s inherited dictionaries, in order from least to most derived.
-        my @dictionaries;
-        push(@dictionaries, $dictionary);
-        my $parentDictionary = $codeGenerator->GetDictionaryByName($dictionary->parent);
-        while (defined($parentDictionary)) {
-            unshift(@dictionaries, $parentDictionary);
-            $parentDictionary = $codeGenerator->GetDictionaryByName($parentDictionary->parent);
-        }
+    # 4. Let dictionaries be a list consisting of D and all of D’s inherited dictionaries, in order from least to most derived.
+    my @dictionaries;
+    push(@dictionaries, $dictionary);
+    my $parentDictionary = $codeGenerator->GetDictionaryByName($dictionary->parent);
+    while (defined($parentDictionary)) {
+        unshift(@dictionaries, $parentDictionary);
+        $parentDictionary = $codeGenerator->GetDictionaryByName($parentDictionary->parent);
+    }
 
-        my $arguments = "";
-        my $comma = "";
+    my $arguments = "";
+    my $comma = "";
 
-        # 5. For each dictionary dictionary in dictionaries, in order:
-        foreach my $dictionary (@dictionaries) {
-            # For each dictionary member member declared on dictionary, in lexicographical order:
-            my @sortedMembers = sort { $a->name cmp $b->name } @{$dictionary->members};
-            foreach my $member (@sortedMembers) {
-                $member->default("undefined") if $member->type eq "any"; # Use undefined as default value for member of type 'any'.
+    # 5. For each dictionary dictionary in dictionaries, in order:
+    foreach my $dictionary (@dictionaries) {
+        # For each dictionary member member declared on dictionary, in lexicographical order:
+        my @sortedMembers = sort { $a->name cmp $b->name } @{$dictionary->members};
+        foreach my $member (@sortedMembers) {
+            $member->default("undefined") if $member->type eq "any"; # Use undefined as default value for member of type 'any'.
 
-                my $type = $member->type;
+            my $type = $member->type;
 
-                # 5.1. Let key be the identifier of member.
-                my $key = $member->name;
+            # 5.1. Let key be the identifier of member.
+            my $key = $member->name;
 
-                # 5.2. Let value be an ECMAScript value, depending on Type(V):
-                $result .= "    JSValue ${key}Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, \"${key}\"));\n";
+            # 5.2. Let value be an ECMAScript value, depending on Type(V):
+            $result .= "    JSValue ${key}Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, \"${key}\"));\n";
 
-                my $nativeType = GetNativeTypeFromSignature($interface, $member);
-                if ($member->isOptional && !defined $member->default) {
-                    $result .= "    Converter<$nativeType>::OptionalValue $key;\n";
-                } else {
-                    $result .= "    $nativeType $key;\n";
-                }
+            my $nativeType = GetNativeTypeFromSignature($interface, $member);
+            if ($member->isOptional && !defined $member->default) {
+                $result .= "    Converter<$nativeType>::OptionalValue $key;\n";
+            } else {
+                $result .= "    $nativeType $key;\n";
+            }
 
-                # 5.3. If value is not undefined, then:
-                $result .= "    if (!${key}Value.isUndefined()) {\n";
-                # FIXME: Eventually we will want this to share a lot more code with JSValueToNative.
-                if ($codeGenerator->IsWrapperType($type)) {
-                    AddToImplIncludes("JS${type}.h");
-                    die "Dictionary members of non-nullable wrapper types must be marked as required" if !$member->isNullable && $member->isOptional;
-                    my $nullableParameter = $member->isNullable ? "IsNullable::Yes" : "IsNullable::No";
-                    $result .= "        $key = convertWrapperType<$type, JS${type}>(state, ${key}Value, $nullableParameter);\n";
-                } elsif ($codeGenerator->IsDictionaryType($type)) {
-                    my $nativeType = GetNativeType($interface, $type);
-                    $result .= "        $key = convertDictionary<${nativeType}>(state, ${key}Value);\n";
-                } else {
-                    my $conversionRuleWithLeadingComma = GenerateConversionRuleWithLeadingComma($interface, $member);
-                    $result .= "        $key = convert<${nativeType}>(state, ${key}Value${conversionRuleWithLeadingComma});\n";
-                }
-                $result .= "        RETURN_IF_EXCEPTION(throwScope, Nullopt);\n";
-                # Value is undefined.
-                # 5.4. Otherwise, if value is undefined but the dictionary member has a default value, then:
-                if ($member->isOptional && defined $member->default) {
-                    $result .= "    } else\n";
-                    $result .= "        $key = " . GenerateDefaultValue($interface, $member) . ";\n";
-                } elsif (!$member->isOptional) {
-                    # 5.5. Otherwise, if value is undefined and the dictionary member is a required dictionary member, then throw a TypeError.
-                    $result .= "    } else {\n";
-                    $result .= "        throwTypeError(&state, throwScope);\n";
-                    $result .= "        return Nullopt;\n";
-                    $result .= "    }\n";
-                } else {
-                    $result .= "    }\n";
-                }
+            # 5.3. If value is not undefined, then:
+            $result .= "    if (!${key}Value.isUndefined()) {\n";
+            # FIXME: Eventually we will want this to share a lot more code with JSValueToNative.
+            if ($codeGenerator->IsWrapperType($type)) {
+                AddToImplIncludes("JS${type}.h");
+                die "Dictionary members of non-nullable wrapper types must be marked as required" if !$member->isNullable && $member->isOptional;
+                my $nullableParameter = $member->isNullable ? "IsNullable::Yes" : "IsNullable::No";
+                $result .= "        $key = convertWrapperType<$type, JS${type}>(state, ${key}Value, $nullableParameter);\n";
+            } elsif ($codeGenerator->IsDictionaryType($type)) {
+                my $nativeType = GetNativeType($interface, $type);
+                $result .= "        $key = convertDictionary<${nativeType}>(state, ${key}Value);\n";
+            } else {
+                my $conversionRuleWithLeadingComma = GenerateConversionRuleWithLeadingComma($interface, $member);
+                $result .= "        $key = convert<${nativeType}>(state, ${key}Value${conversionRuleWithLeadingComma});\n";
             }
+            $result .= "        RETURN_IF_EXCEPTION(throwScope, Nullopt);\n";
+            # Value is undefined.
+            # 5.4. Otherwise, if value is undefined but the dictionary member has a default value, then:
+            if ($member->isOptional && defined $member->default) {
+                $result .= "    } else\n";
+                $result .= "        $key = " . GenerateDefaultValue($interface, $member) . ";\n";
+            } elsif (!$member->isOptional) {
+                # 5.5. Otherwise, if value is undefined and the dictionary member is a required dictionary member, then throw a TypeError.
+                $result .= "    } else {\n";
+                $result .= "        throwTypeError(&state, throwScope);\n";
+                $result .= "        return Nullopt;\n";
+                $result .= "    }\n";
+            } else {
+                $result .= "    }\n";
+            }
+        }
 
-            # 6. Return dict.
-            foreach my $member (@{$dictionary->members}) {
-                my $value;
-                if ($codeGenerator->IsWrapperType($member->type) && !$member->isNullable) {
-                    $value = "*" . $member->name;
-                } elsif ($codeGenerator->IsDictionaryType($member->type)) {
-                    $value = $member->name . ".value()";
-                } else {
-                    $value = "WTFMove(" . $member->name . ")";
-                }
-                $arguments .= $comma . $value;
-                $comma = ", ";
+        # 6. Return dict.
+        foreach my $member (@{$dictionary->members}) {
+            my $value;
+            if ($codeGenerator->IsWrapperType($member->type) && !$member->isNullable) {
+                $value = "*" . $member->name;
+            } elsif ($codeGenerator->IsDictionaryType($member->type)) {
+                $value = $member->name . ".value()";
+            } else {
+                $value = "WTFMove(" . $member->name . ")";
             }
+            $arguments .= $comma . $value;
+            $comma = ", ";
         }
+    }
 
-        $result .= "    return $className { " . $arguments . " };\n";
-        $result .= "}\n\n";
-        $result .= "#endif\n\n" if $conditionalString;
+    $result .= "    return $className { " . $arguments . " };\n";
+    $result .= "}\n\n";
+    $result .= "#endif\n\n" if $conditionalString;
+
+    return $result;
+}
+
+sub GenerateDictionariesImplementationContent
+{
+    my ($interface, $allDictionaries) = @_;
+
+    my $result = "";
+    foreach my $dictionary (@$allDictionaries) {
+        my $className = GetDictionaryClassName($dictionary->name, $interface);
+        $result .= GenerateDictionaryImplementationContent($dictionary, $className, $interface);
     }
     return $result;
 }
@@ -1618,8 +1644,8 @@
         push(@headerContent, "};\n");
     }
 
-    push(@headerContent, GenerateEnumerationHeaderContent($interface, $enumerations));
-    push(@headerContent, GenerateDictionaryHeaderContent($interface, $dictionaries));
+    push(@headerContent, GenerateEnumerationsHeaderContent($interface, $enumerations));
+    push(@headerContent, GenerateDictionariesHeaderContent($interface, $dictionaries));
 
     my $conditionalString = $codeGenerator->GenerateConditionalString($interface);
     push(@headerContent, "\n} // namespace WebCore\n");
@@ -2339,8 +2365,8 @@
     push(@implContent, "\nusing namespace JSC;\n\n");
     push(@implContent, "namespace WebCore {\n\n");
 
-    push(@implContent, GenerateEnumerationImplementationContent($interface, $enumerations));
-    push(@implContent, GenerateDictionaryImplementationContent($interface, $dictionaries));
+    push(@implContent, GenerateEnumerationsImplementationContent($interface, $enumerations));
+    push(@implContent, GenerateDictionariesImplementationContent($interface, $dictionaries));
 
     my @functions = @{$interface->functions};
     push(@functions, @{$interface->iterable->functions}) if IsKeyValueIterableInterface($interface);
@@ -4040,7 +4066,7 @@
             $value = "WTFMove($name.arguments.value())";
 
         } elsif ($codeGenerator->IsEnumType($type)) {
-            my $className = GetEnumerationClassName($interface, $type);
+            my $className = GetEnumerationClassName($type, $interface);
 
             $implIncludes{"<runtime/Error.h>"} = 1;
 
@@ -4174,6 +4200,36 @@
     return @arguments;
 }
 
+sub GenerateDictionaryHeader
+{
+    my ($object, $dictionary, $className) = @_;
+
+    my $dictionaryName = $dictionary->name;
+
+    # - Add default header template and header protection.
+    push(@headerContentHeader, GenerateHeaderContentHeader($dictionary));
+
+    $headerIncludes{"$dictionaryName.h"} = 1;
+    $headerIncludes{"JSDOMConvert.h"} = 1;
+
+    push(@headerContent, "\nnamespace WebCore {\n\n");
+    push(@headerContent, GenerateDictionaryHeaderContent($dictionary, $className));
+    push(@headerContent, "} // namespace WebCore\n");
+}
+
+sub GenerateDictionaryImplementation
+{
+    my ($object, $dictionary, $className) = @_;
+
+    # - Add default header template
+    push(@implContentHeader, GenerateImplementationContentHeader($dictionary));
+
+    push(@implContent, "\nusing namespace JSC;\n\n");
+    push(@implContent, "namespace WebCore {\n\n");
+    push(@implContent, GenerateDictionaryImplementationContent($dictionary, $className));
+    push(@implContent, "} // namespace WebCore\n");
+}
+
 sub GenerateCallbackHeader
 {
     my ($object, $interface, $enumerations, $dictionaries) = @_;
@@ -4235,8 +4291,8 @@
     push(@headerContent, "JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, $interfaceName&);\n");
     push(@headerContent, "inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, $interfaceName* impl) { return impl ? toJS(state, globalObject, *impl) : JSC::jsNull(); }\n\n");
 
-    push(@headerContent, GenerateEnumerationHeaderContent($interface, $enumerations));
-    push(@headerContent, GenerateDictionaryHeaderContent($interface, $dictionaries));
+    push(@headerContent, GenerateEnumerationsHeaderContent($interface, $enumerations));
+    push(@headerContent, GenerateDictionariesHeaderContent($interface, $dictionaries));
 
     push(@headerContent, "} // namespace WebCore\n");
 
@@ -4263,8 +4319,8 @@
     push(@implContent, "\nusing namespace JSC;\n\n");
     push(@implContent, "namespace WebCore {\n\n");
 
-    push(@implContent, GenerateEnumerationImplementationContent($interface, $enumerations));
-    push(@implContent, GenerateDictionaryImplementationContent($interface, $dictionaries));
+    push(@implContent, GenerateEnumerationsImplementationContent($interface, $enumerations));
+    push(@implContent, GenerateDictionariesImplementationContent($interface, $dictionaries));
 
     # Constructor
     push(@implContent, "${className}::${className}(JSObject* callback, JSDOMGlobalObject* globalObject)\n");
@@ -4650,8 +4706,8 @@
 
     return $nativeType{$type} if exists $nativeType{$type};
 
-    return GetEnumerationClassName($interface, $type) if $codeGenerator->IsEnumType($type);
-    return GetDictionaryClassName($interface, $type) if $codeGenerator->IsDictionaryType($type);
+    return GetEnumerationClassName($type, $interface) if $codeGenerator->IsEnumType($type);
+    return GetDictionaryClassName($type, $interface) if $codeGenerator->IsDictionaryType($type);
 
     my $tearOffType = $codeGenerator->GetSVGTypeNeedingTearOff($type);
     return "${tearOffType}*" if $tearOffType;
@@ -4811,8 +4867,12 @@
     return ("valueToDate(state, $value)", 1) if $type eq "Date";
 
     return ("to$type($value)", 1) if $codeGenerator->IsTypedArrayType($type);
-    return ("parse<" . GetEnumerationClassName($interface, $type) . ">(*state, $value)", 1) if $codeGenerator->IsEnumType($type);
-    return ("convertDictionary<" . GetDictionaryClassName($interface, $type) . ">(*state, $value)", 1) if $codeGenerator->IsDictionaryType($type);
+    return ("parse<" . GetEnumerationClassName($type, $interface) . ">(*state, $value)", 1) if $codeGenerator->IsEnumType($type);
+    if ($codeGenerator->IsDictionaryType($type)) {
+        my $dictionary = $codeGenerator->GetDictionaryByName($type);
+        AddToImplIncludes("JS$type.h", $conditional) if $codeGenerator->IsExternalDictionaryType($type);
+        return ("convertDictionary<" . GetDictionaryClassName($type, $interface) . ">(*state, $value)", 1);
+    }
 
     AddToImplIncludes("JS$type.h", $conditional);
 

Modified: trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl (206876 => 206877)


--- trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/bindings/scripts/preprocess-idls.pl	2016-10-06 20:22:16 UTC (rev 206877)
@@ -94,6 +94,13 @@
         $supplementalDependencies{$fullPath} = [$partialInterfaceName];
         next;
     }
+
+    $supplementals{$fullPath} = [];
+
+    # Skip if the IDL file does not contain an interface, a callback interface or an exception.
+    # The IDL may contain a dictionary.
+    next unless containsInterfaceOrExceptionFromIDL($idlFileContents);
+
     my $interfaceName = fileparse(basename($idlFile), ".idl");
     # Handle implements statements.
     my $implementedInterfaces = getImplementedInterfacesFromIDL($idlFileContents, $interfaceName);
@@ -132,7 +139,6 @@
             }
         }
     }
-    $supplementals{$fullPath} = [];
 }
 
 # Generate partial interfaces for Constructors.
@@ -305,6 +311,16 @@
     return ($fileContents =~ /callback\s+interface\s+\w+/gs);
 }
 
+sub containsInterfaceOrExceptionFromIDL
+{
+    my $fileContents = shift;
+
+    return 1 if $fileContents =~ /\bcallback\s+interface\s+\w+/gs;
+    return 1 if $fileContents =~ /\binterface\s+\w+/gs;
+    return 1 if $fileContents =~ /\bexception\s+\w+/gs;
+    return 0;
+}
+
 sub trim
 {
     my $string = shift;

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (206876 => 206877)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2016-10-06 20:22:16 UTC (rev 206877)
@@ -50,6 +50,7 @@
 #include "JSTestCallbackFunction.h"
 #include "JSTestNode.h"
 #include "JSTestObj.h"
+#include "JSTestStandaloneDictionary.h"
 #include "JSTestSubObj.h"
 #include "JSXPathNSResolver.h"
 #include "ObjectConstructor.h"
@@ -998,6 +999,7 @@
 #endif
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSingleConditionalOverload(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAttachShadowRoot(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOperationWithExternalDictionaryParameter(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionToString(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionToJSON(JSC::ExecState*);
 
@@ -1604,6 +1606,7 @@
 #endif
     { "singleConditionalOverload", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionSingleConditionalOverload), (intptr_t) (1) } },
     { "attachShadowRoot", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAttachShadowRoot), (intptr_t) (1) } },
+    { "operationWithExternalDictionaryParameter", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOperationWithExternalDictionaryParameter), (intptr_t) (1) } },
     { "toString", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionToString), (intptr_t) (0) } },
     { "toJSON", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionToJSON), (intptr_t) (0) } },
 #if ENABLE(Condition1)
@@ -7601,6 +7604,25 @@
     return JSValue::encode(jsUndefined());
 }
 
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOperationWithExternalDictionaryParameter(ExecState* state)
+{
+    VM& vm = state->vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    UNUSED_PARAM(throwScope);
+    JSValue thisValue = state->thisValue();
+    auto castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*state, throwScope, "TestObject", "operationWithExternalDictionaryParameter");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->wrapped();
+    if (UNLIKELY(state->argumentCount() < 1))
+        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
+    auto dict = convertDictionary<TestStandaloneDictionary>(*state, state->uncheckedArgument(0));
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+    impl.operationWithExternalDictionaryParameter(dict.value());
+    return JSValue::encode(jsUndefined());
+}
+
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionToString(ExecState* state)
 {
     VM& vm = state->vm();

Added: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp (0 => 206877)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp	                        (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp	2016-10-06 20:22:16 UTC (rev 206877)
@@ -0,0 +1,58 @@
+/*
+    This file is part of the WebKit open source project.
+    This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSTestStandaloneDictionary.h"
+
+
+using namespace JSC;
+
+namespace WebCore {
+
+template<> Optional<TestStandaloneDictionary> convertDictionary<TestStandaloneDictionary>(ExecState& state, JSValue value)
+{
+    VM& vm = state.vm();
+    auto throwScope = DECLARE_THROW_SCOPE(vm);
+    bool isNullOrUndefined = value.isUndefinedOrNull();
+    auto* object = isNullOrUndefined ? nullptr : value.getObject();
+    if (UNLIKELY(!isNullOrUndefined && !object)) {
+        throwTypeError(&state, throwScope);
+        return Nullopt;
+    }
+    if (UNLIKELY(object && object->type() == RegExpObjectType)) {
+        throwTypeError(&state, throwScope);
+        return Nullopt;
+    }
+    JSValue boolMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "boolMember"));
+    Converter<bool>::OptionalValue boolMember;
+    if (!boolMemberValue.isUndefined()) {
+        boolMember = convert<bool>(state, boolMemberValue);
+        RETURN_IF_EXCEPTION(throwScope, Nullopt);
+    }
+    JSValue stringMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "stringMember"));
+    Converter<String>::OptionalValue stringMember;
+    if (!stringMemberValue.isUndefined()) {
+        stringMember = convert<String>(state, stringMemberValue);
+        RETURN_IF_EXCEPTION(throwScope, Nullopt);
+    }
+    return TestStandaloneDictionary { WTFMove(boolMember), WTFMove(stringMember) };
+}
+
+} // namespace WebCore

Added: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.h (0 => 206877)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.h	                        (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.h	2016-10-06 20:22:16 UTC (rev 206877)
@@ -0,0 +1,30 @@
+/*
+    This file is part of the WebKit open source project.
+    This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMConvert.h"
+#include "TestStandaloneDictionary.h"
+
+namespace WebCore {
+
+template<> Optional<TestStandaloneDictionary> convertDictionary<TestStandaloneDictionary>(JSC::ExecState&, JSC::JSValue);
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (206876 => 206877)


--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2016-10-06 20:22:16 UTC (rev 206877)
@@ -409,6 +409,7 @@
 #endif
 
     void attachShadowRoot(TestDictionary init);
+    void operationWithExternalDictionaryParameter(TestStandaloneDictionary dict);
 
     stringifier attribute USVString stringifierAttribute;
 

Added: trunk/Source/WebCore/bindings/scripts/test/TestStandaloneDictionary.idl (0 => 206877)


--- trunk/Source/WebCore/bindings/scripts/test/TestStandaloneDictionary.idl	                        (rev 0)
+++ trunk/Source/WebCore/bindings/scripts/test/TestStandaloneDictionary.idl	2016-10-06 20:22:16 UTC (rev 206877)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary form, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+dictionary TestStandaloneDictionary {
+    boolean boolMember;
+    DOMString stringMember;
+};

Modified: trunk/Source/WebCore/dom/Element.h (206876 => 206877)


--- trunk/Source/WebCore/dom/Element.h	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/dom/Element.h	2016-10-06 20:22:16 UTC (rev 206877)
@@ -30,6 +30,7 @@
 #include "ElementData.h"
 #include "HTMLNames.h"
 #include "RegionOversetState.h"
+#include "ScrollToOptions.h"
 #include "ScrollTypes.h"
 #include "SimulatedClickOptions.h"
 #include "StyleChange.h"
@@ -136,11 +137,6 @@
     WEBCORE_EXPORT void scrollIntoViewIfNeeded(bool centerIfNeeded = true);
     WEBCORE_EXPORT void scrollIntoViewIfNotVisible(bool centerIfNotVisible = true);
 
-    struct ScrollToOptions {
-        Optional<double> left;
-        Optional<double> top;
-    };
-
     void scrollBy(const ScrollToOptions&);
     void scrollBy(double x, double y);
     virtual void scrollTo(const ScrollToOptions&);

Modified: trunk/Source/WebCore/dom/Element.idl (206876 => 206877)


--- trunk/Source/WebCore/dom/Element.idl	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/dom/Element.idl	2016-10-06 20:22:16 UTC (rev 206877)
@@ -185,12 +185,6 @@
     required ShadowRootMode mode;
 };
 
-// FIXME: Support ScrollBehavior.
-dictionary ScrollToOptions {
-    unrestricted double left;
-    unrestricted double top;
-};
-
 Element implements Animatable;
 Element implements ChildNode;
 Element implements NonDocumentTypeChildNode;

Modified: trunk/Source/WebCore/html/HTMLBodyElement.cpp (206876 => 206877)


--- trunk/Source/WebCore/html/HTMLBodyElement.cpp	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/html/HTMLBodyElement.cpp	2016-10-06 20:22:16 UTC (rev 206877)
@@ -306,7 +306,7 @@
         if (!window)
             return;
 
-        window->scrollTo({ options.left, options.top });
+        window->scrollTo(options);
         return;
     }
     return HTMLElement::scrollTo(options);

Modified: trunk/Source/WebCore/page/DOMWindow.h (206876 => 206877)


--- trunk/Source/WebCore/page/DOMWindow.h	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/page/DOMWindow.h	2016-10-06 20:22:16 UTC (rev 206877)
@@ -30,8 +30,9 @@
 #include "ContextDestructionObserver.h"
 #include "EventTarget.h"
 #include "FrameDestructionObserver.h"
+#include "ScrollToOptions.h"
+#include "Supplementable.h"
 #include "URL.h"
-#include "Supplementable.h"
 #include <functional>
 #include <memory>
 #include <wtf/HashSet.h>
@@ -246,11 +247,6 @@
         void postMessageTimerFired(PostMessageTimer&);
         void dispatchMessageEventWithOriginCheck(SecurityOrigin* intendedTargetOrigin, Event&, PassRefPtr<Inspector::ScriptCallStack>);
 
-        struct ScrollToOptions {
-            Optional<double> left;
-            Optional<double> top;
-        };
-
         void scrollBy(const ScrollToOptions&) const;
         void scrollBy(double x, double y) const;
         void scrollTo(const ScrollToOptions&) const;

Modified: trunk/Source/WebCore/page/DOMWindow.idl (206876 => 206877)


--- trunk/Source/WebCore/page/DOMWindow.idl	2016-10-06 20:13:50 UTC (rev 206876)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2016-10-06 20:22:16 UTC (rev 206877)
@@ -211,12 +211,6 @@
     [NotEnumerable, Conditional=PROXIMITY_EVENTS] attribute EventHandler onwebkitdeviceproximity;
 };
 
-// FIXME: Support ScrollBehavior.
-dictionary ScrollToOptions {
-    unrestricted double left;
-    unrestricted double top;
-};
-
 DOMWindow implements GlobalCrypto;
 DOMWindow implements GlobalEventHandlers;
 DOMWindow implements WindowEventHandlers;

Added: trunk/Source/WebCore/page/ScrollToOptions.h (0 => 206877)


--- trunk/Source/WebCore/page/ScrollToOptions.h	                        (rev 0)
+++ trunk/Source/WebCore/page/ScrollToOptions.h	2016-10-06 20:22:16 UTC (rev 206877)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2016 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/Optional.h>
+
+namespace WebCore {
+
+struct ScrollToOptions {
+    Optional<double> left;
+    Optional<double> top;
+};
+
+}

Added: trunk/Source/WebCore/page/ScrollToOptions.idl (0 => 206877)


--- trunk/Source/WebCore/page/ScrollToOptions.idl	                        (rev 0)
+++ trunk/Source/WebCore/page/ScrollToOptions.idl	2016-10-06 20:22:16 UTC (rev 206877)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// FIXME: Support ScrollBehavior.
+dictionary ScrollToOptions {
+    unrestricted double left;
+    unrestricted double top;
+};
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to