Changeset 207378 in webkit
- Timestamp:
- Oct 15, 2016, 2:15:17 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 2 deleted
- 11 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r207345 r207378 1076 1076 bindings/js/JSCallbackData.cpp 1077 1077 bindings/js/JSCanvasRenderingContext2DCustom.cpp 1078 bindings/js/JSClientRectCustom.cpp1079 1078 bindings/js/JSCommandLineAPIHostCustom.cpp 1080 1079 bindings/js/JSCryptoAlgorithmBuilder.cpp … … 1166 1165 bindings/js/JSNodeListCustom.cpp 1167 1166 bindings/js/JSPerformanceEntryCustom.cpp 1168 bindings/js/JSPerformanceTimingCustom.cpp1169 1167 bindings/js/JSPluginElementFunctions.cpp 1170 1168 bindings/js/JSPopStateEventCustom.cpp -
trunk/Source/WebCore/ChangeLog
r207376 r207378 1 2016-10-15 Simon Fraser <simon.fraser@apple.com> 2 3 Implement serializer = { attribute } 4 https://bugs.webkit.org/show_bug.cgi?id=163466 5 6 Reviewed by Darin Adler. 7 8 Fix the code generator to generate code for serializer = { attribute }. 9 In IDLParser, extend domSerializable with flags for the 'inherit', 'getter' and 10 'attribute' values (the first two are still unsupported). Fix parseSerializationPattern() 11 to detect these; it needs to create the domSerializable() now. Basic support 12 for isSerializableAttribute() is added (primitive types only). 13 14 GenerateSerializerFunction is fixed to output code for the serializable attributes 15 in the order specified in "serializer = {}", as specified in WebIDL. 16 17 Removed custom serialization for ClientRect and PerformanceTiming. 18 19 Other minor cleanup to always get $interfaceName from $interface->name, and to fix 20 ObjectConstructor.h to be included as <runtime/ObjectConstructor.h>. 21 22 * CMakeLists.txt: 23 * WebCore.xcodeproj/project.pbxproj: 24 * bindings/js/JSBindingsAllInOne.cpp: 25 * bindings/js/JSClientRectCustom.cpp: Removed. 26 * bindings/js/JSPerformanceTimingCustom.cpp: Removed. 27 * bindings/scripts/CodeGeneratorJS.pm: 28 (GenerateImplementation): 29 (GenerateSerializerFunction): 30 * bindings/scripts/IDLParser.pm: 31 (parseSerializerRest): 32 (parseSerializationPattern): 33 (parseSerializationAttributes): 34 (isSerializableAttribute): 35 (applyMemberList): 36 * bindings/scripts/test/JS/JSTestNode.cpp: 37 * bindings/scripts/test/JS/JSTestObj.cpp: 38 (WebCore::jsTestObjPrototypeFunctionToJSONCaller): 39 * bindings/scripts/test/JS/JSTestSerialization.cpp: Added. 40 * bindings/scripts/test/JS/JSTestSerialization.h: Added. 41 * bindings/scripts/test/TestObj.idl: 42 * bindings/scripts/test/TestSerialization.idl: Copied from Source/WebCore/dom/ClientRect.idl. 43 * dom/ClientRect.idl: 44 * page/PerformanceTiming.idl: 45 1 46 2016-10-15 Michael Catanzaro <mcatanzaro@igalia.com> 2 47 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r207361 r207378 1380 1380 31C0FF3F0E4CEFAC007D6FE5 /* JSWebKitTransitionEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31C0FF3B0E4CEFAC007D6FE5 /* JSWebKitTransitionEvent.cpp */; }; 1381 1381 31C0FF400E4CEFAC007D6FE5 /* JSWebKitTransitionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 31C0FF3C0E4CEFAC007D6FE5 /* JSWebKitTransitionEvent.h */; }; 1382 31C422461D74EB9A00F12342 /* JSPerformanceTimingCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31C422451D74EB9A00F12342 /* JSPerformanceTimingCustom.cpp */; };1383 1382 31D591B316697A6C00E6BF02 /* PlugInClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 31D591B116697A6C00E6BF02 /* PlugInClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1384 1383 31DCD29D1AB4FBDE0072E817 /* AnimationTrigger.h in Headers */ = {isa = PBXBuildFile; fileRef = 31DCD29C1AB4FBDE0072E817 /* AnimationTrigger.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 1740 1739 467302021C4EFE7800BCB357 /* IgnoreOpensDuringUnloadCountIncrementer.h in Headers */ = {isa = PBXBuildFile; fileRef = 467302011C4EFE6600BCB357 /* IgnoreOpensDuringUnloadCountIncrementer.h */; }; 1741 1740 4689F1AF1267BAE100E8D380 /* FileMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 4689F1AE1267BAE100E8D380 /* FileMetadata.h */; }; 1742 46A58AC51D46B3FA00432036 /* JSClientRectCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46A58AC41D46B3FA00432036 /* JSClientRectCustom.cpp */; };1743 1741 46B63F6C1C6E8D19002E914B /* JSEventTargetCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B63F6B1C6E8CDF002E914B /* JSEventTargetCustom.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1744 1742 46C83EFD1A9BBE2900A79A41 /* GeoNotifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46C83EFB1A9BBE2900A79A41 /* GeoNotifier.cpp */; }; … … 8348 8346 31C0FF3B0E4CEFAC007D6FE5 /* JSWebKitTransitionEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitTransitionEvent.cpp; sourceTree = "<group>"; }; 8349 8347 31C0FF3C0E4CEFAC007D6FE5 /* JSWebKitTransitionEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitTransitionEvent.h; sourceTree = "<group>"; }; 8350 31C422451D74EB9A00F12342 /* JSPerformanceTimingCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPerformanceTimingCustom.cpp; sourceTree = "<group>"; };8351 8348 31D591B116697A6C00E6BF02 /* PlugInClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlugInClient.h; sourceTree = "<group>"; }; 8352 8349 31DCD29C1AB4FBDE0072E817 /* AnimationTrigger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationTrigger.h; sourceTree = "<group>"; }; … … 8756 8753 467302011C4EFE6600BCB357 /* IgnoreOpensDuringUnloadCountIncrementer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IgnoreOpensDuringUnloadCountIncrementer.h; sourceTree = "<group>"; }; 8757 8754 4689F1AE1267BAE100E8D380 /* FileMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileMetadata.h; sourceTree = "<group>"; }; 8758 46A58AC41D46B3FA00432036 /* JSClientRectCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSClientRectCustom.cpp; sourceTree = "<group>"; };8759 8755 46B63F6B1C6E8CDF002E914B /* JSEventTargetCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEventTargetCustom.h; sourceTree = "<group>"; }; 8760 8756 46C83EFB1A9BBE2900A79A41 /* GeoNotifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeoNotifier.cpp; sourceTree = "<group>"; }; … … 21202 21198 8931DE5A14C44C44000DC9D2 /* JSBlobCustom.cpp */, 21203 21199 49EED14B1051971900099FAB /* JSCanvasRenderingContext2DCustom.cpp */, 21204 46A58AC41D46B3FA00432036 /* JSClientRectCustom.cpp */,21205 21200 A584FE371864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp */, 21206 21201 7CEF26181D6A92E300BE905D /* JSCryptoCustom.cpp */, … … 21283 21278 1A750DD30A90E729000FF215 /* JSNodeIteratorCustom.cpp */, 21284 21279 BCD9C2610C17AA67005C90A2 /* JSNodeListCustom.cpp */, 21285 31C422451D74EB9A00F12342 /* JSPerformanceTimingCustom.cpp */,21286 21280 AD20B18C18E9D216005A8083 /* JSNodeListCustom.h */, 21287 21281 A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */, … … 27730 27724 FD31600712B0267600C1A359 /* AudioDestinationNode.cpp in Sources */, 27731 27725 FD31608112B026F700C1A359 /* AudioDSPKernelProcessor.cpp in Sources */, 27732 31C422461D74EB9A00F12342 /* JSPerformanceTimingCustom.cpp in Sources */,27733 27726 CD5596911475B678001D0BD0 /* AudioFileReaderIOS.cpp in Sources */, 27734 27727 FD3160BE12B0272A00C1A359 /* AudioFileReaderMac.cpp in Sources */, … … 28718 28711 65DF31F309D1CC60000BE325 /* JSCharacterData.cpp in Sources */, 28719 28712 BCC065870F3CE2A700CD2D87 /* JSClientRect.cpp in Sources */, 28720 46A58AC51D46B3FA00432036 /* JSClientRectCustom.cpp in Sources */,28721 28713 BCC065890F3CE2A700CD2D87 /* JSClientRectList.cpp in Sources */, 28722 28714 E3150EA61DA7219000194012 /* JSNodeDOMJIT.cpp in Sources */, -
trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
r206956 r207378 42 42 #include "JSCallbackData.cpp" 43 43 #include "JSCanvasRenderingContext2DCustom.cpp" 44 #include "JSClientRectCustom.cpp"45 44 #include "JSCommandLineAPIHostCustom.cpp" 46 45 #include "JSCryptoCustom.cpp" -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r207355 r207378 3746 3746 3747 3747 GenerateImplementationIterableFunctions($interface) if $interface->iterable; 3748 GenerateSerializerFunction($interface, $ interfaceName, $className) if $interface->serializable;3748 GenerateSerializerFunction($interface, $className) if $interface->serializable; 3749 3749 3750 3750 if ($needsVisitChildren) { … … 3969 3969 sub GenerateSerializerFunction 3970 3970 { 3971 my ($interface, $interfaceName, $className) = @_; 3971 my ($interface, $className) = @_; 3972 3973 my $interfaceName = $interface->name; 3974 3972 3975 my $serializerFunctionName = "toJSON"; 3973 3976 my $serializerNativeFunctionName = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($serializerFunctionName); 3974 3977 3975 AddToImplIncludes(" ObjectConstructor.h");3978 AddToImplIncludes("<runtime/ObjectConstructor.h>"); 3976 3979 push(@implContent, "static inline EncodedJSValue ${serializerNativeFunctionName}Caller(ExecState* state, JS$interfaceName* thisObject, JSC::ThrowScope& throwScope)\n"); 3977 3980 push(@implContent, "{\n"); … … 3979 3982 push(@implContent, " auto* result = constructEmptyObject(state);\n"); 3980 3983 push(@implContent, "\n"); 3981 foreach my $attribute (@{$interface->attributes}) { 3984 3985 my @serializedAttributes = (); 3986 foreach my $attribute_name (@{$interface->serializable->attributes}) { 3987 foreach my $attribute (@{$interface->attributes}) { 3988 if ($attribute_name eq $attribute->signature->name) { 3989 push @serializedAttributes, $attribute; 3990 last; 3991 } 3992 } 3993 } 3994 3995 foreach my $attribute (@serializedAttributes) { 3982 3996 my $name = $attribute->signature->name; 3983 if (grep $_ eq $name, @{$interface->serializable->attributes}) { 3984 3985 3986 3987 3988 3989 3990 } 3997 3998 my $getFunctionName = GetAttributeGetterName($interface, $className, $attribute); 3999 push(@implContent, " auto ${name}Value = ${getFunctionName}Getter(*state, *thisObject, throwScope);\n"); 4000 push(@implContent, " ASSERT(!throwScope.exception());\n"); 4001 push(@implContent, " result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), ${name}Value);\n"); 4002 push(@implContent, "\n"); 4003 } 4004 3991 4005 push(@implContent, " return JSValue::encode(result);\n"); 3992 4006 push(@implContent, "}\n"); -
trunk/Source/WebCore/bindings/scripts/IDLParser.pm
r207150 r207378 113 113 struct( domSerializable => { 114 114 attributes => '@', # List of attributes to serialize 115 hasAttribute => '$', # serializer = { attribute } 116 hasInherit => '$', # serializer = { inherit } 117 hasGetter => '$', # serializer = { getter } 115 118 functions => '@', # toJSON function 116 119 }); … … 1149 1152 if ($next->value() eq "=") { 1150 1153 $self->assertTokenValue($self->getToken(), "=", __LINE__); 1151 my $attributes = $self->parseSerializationPattern(); 1152 1153 my $newDataNode = domSerializable->new(); 1154 $newDataNode->attributes($attributes); 1155 1156 return $newDataNode; 1154 1155 return $self->parseSerializationPattern(); 1156 1157 1157 } 1158 1158 if ($next->type() == IdentifierToken || $next->value() eq "(") { … … 1168 1168 if ($next->value() eq "{") { 1169 1169 $self->assertTokenValue($self->getToken(), "{", __LINE__); 1170 my $attributes = $self->parseSerializationAttributes(); 1170 my $newDataNode = domSerializable->new(); 1171 $self->parseSerializationAttributes($newDataNode); 1171 1172 $self->assertTokenValue($self->getToken(), "}", __LINE__); 1172 return \@{$attributes};1173 return $newDataNode; 1173 1174 } 1174 1175 if ($next->value() eq "[") { … … 1180 1181 $self->assertTokenType($token, IdentifierToken); 1181 1182 push(@attributes, $token->value()); 1182 return \@attributes; 1183 1184 my $newDataNode = domSerializable->new(); 1185 $newDataNode->attributes(\@attributes); 1186 1187 return $newDataNode; 1183 1188 } 1184 1189 $self->assertUnexpectedToken($next->value(), __LINE__); … … 1188 1193 { 1189 1194 my $self = shift; 1195 my $domSerializable = shift; 1190 1196 my $token = $self->getToken(); 1191 1197 1192 1198 if ($token->value() eq "getter") { 1199 $domSerializable->hasGetter(1); 1193 1200 die "Serializer getter keyword is not currently supported."; 1194 1201 1195 1202 } 1196 1203 if ($token->value() eq "inherit") { 1204 $domSerializable->hasInherit(1); 1197 1205 die "Serializer inherit keyword is not currently supported."; 1206 } 1207 1208 if ($token->value() eq "attribute") { 1209 $domSerializable->hasAttribute(1); 1210 # Attributes will be filled in via applyMemberList() 1211 return; 1198 1212 } 1199 1213 … … 1202 1216 push(@attributes, $token->value()); 1203 1217 push(@attributes, @{$self->parseIdentifiers()}); 1204 return \@attributes;1218 $domSerializable->attributes(\@attributes); 1205 1219 } 1206 1220 … … 2317 2331 } 2318 2332 2333 sub isSerializableAttribute 2334 { 2335 my $attribute = shift; 2336 2337 # FIXME: Need to support more than primitive serializable types. 2338 # This check may have to move to the code generator, if we don't have enough information 2339 # here to determine serializability: https://heycam.github.io/webidl/#idl-serializers 2340 my $serializable_types = '^(\(byte|octet|short|unsigned short|long|unsigned long|long long|unsigned long long|float|unrestricted float|double|unrestricted double|boolean|DOMString|ByteString|USVString)$'; 2341 return $attribute->signature->type =~ /$serializable_types/; 2342 } 2319 2343 2320 2344 sub applyMemberList … … 2352 2376 if ($interface->serializable) { 2353 2377 my $numSerializerAttributes = @{$interface->serializable->attributes}; 2354 if ($numSerializerAttributes == 0) { 2378 if ($interface->serializable->hasAttribute) { 2379 foreach my $attribute (@{$interface->attributes}) { 2380 if (isSerializableAttribute($attribute)) { 2381 push(@{$interface->serializable->attributes}, $attribute->signature->name); 2382 } 2383 } 2384 } elsif ($numSerializerAttributes == 0) { 2355 2385 foreach my $attribute (@{$interface->attributes}) { 2356 2386 push(@{$interface->serializable->attributes}, $attribute->signature->name); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp
r207324 r207378 27 27 #include "JSDOMIterator.h" 28 28 #include "JSDOMPromise.h" 29 #include "ObjectConstructor.h"30 29 #include "RuntimeEnabledFeatures.h" 31 30 #include "URL.h" 32 31 #include <runtime/Error.h> 33 32 #include <runtime/JSString.h> 33 #include <runtime/ObjectConstructor.h> 34 34 #include <wtf/GetPtr.h> 35 35 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r207328 r207378 54 54 #include "JSTestSubObj.h" 55 55 #include "JSXPathNSResolver.h" 56 #include "ObjectConstructor.h"57 56 #include "RuntimeEnabledFeatures.h" 58 57 #include "SVGDocument.h" … … 7741 7740 auto* result = constructEmptyObject(state); 7742 7741 7742 auto createValue = jsTestObjCreateGetter(*state, *thisObject, throwScope); 7743 ASSERT(!throwScope.exception()); 7744 result->putDirect(vm, Identifier::fromString(&vm, "create"), createValue); 7745 7743 7746 auto readOnlyStringAttrValue = jsTestObjReadOnlyStringAttrGetter(*state, *thisObject, throwScope); 7744 7747 ASSERT(!throwScope.exception()); … … 7752 7755 ASSERT(!throwScope.exception()); 7753 7756 result->putDirect(vm, Identifier::fromString(&vm, "longAttr"), longAttrValue); 7754 7755 auto createValue = jsTestObjCreateGetter(*state, *thisObject, throwScope);7756 ASSERT(!throwScope.exception());7757 result->putDirect(vm, Identifier::fromString(&vm, "create"), createValue);7758 7757 7759 7758 return JSValue::encode(result); -
trunk/Source/WebCore/bindings/scripts/test/TestObj.idl
r207170 r207378 415 415 stringifier attribute USVString stringifierAttribute; 416 416 417 418 serializer = {readOnlyStringAttr, create, enumAttr, longAttr}; 417 serializer = {create, readOnlyStringAttr, enumAttr, longAttr}; 419 418 }; 420 419 -
trunk/Source/WebCore/bindings/scripts/test/TestSerialization.idl
r207377 r207378 1 1 /* 2 * Copyright (C) 20 09 Apple Inc. All Rights Reserved.2 * Copyright (C) 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 *25 24 */ 26 25 27 [ 28 ImplementationLacksVTable, 29 ExportMacro=WEBCORE_EXPORT, 30 ] interface ClientRect { 31 readonly attribute unrestricted float top; 32 readonly attribute unrestricted float right; 33 readonly attribute unrestricted float bottom; 34 readonly attribute unrestricted float left; 35 readonly attribute unrestricted float width; 36 readonly attribute unrestricted float height; 26 interface TestSerialization { 27 attribute DOMString firstStringAttribute; 28 attribute long secondLongAttribute; 29 attribute TestNode thirdUnserializableAttribute; 30 attribute unrestricted double fourthUnrestrictedDoubleAttribute; 31 attribute long fifthLongAttribute; 37 32 38 // FIXME: should be serializer = { attribute }; 39 [Custom] Object toJSON(); 33 serializer = { attribute }; 40 34 }; 41 -
trunk/Source/WebCore/dom/ClientRect.idl
r203702 r207378 36 36 readonly attribute unrestricted float height; 37 37 38 // FIXME: should be serializer = { attribute }; 39 [Custom] Object toJSON(); 38 serializer = { attribute }; 40 39 }; 41 -
trunk/Source/WebCore/page/PerformanceTiming.idl
r205161 r207378 55 55 readonly attribute unsigned long long loadEventEnd; 56 56 57 // FIXME: Should be serializer = { attribute }; 58 [Custom] Object toJSON(); 57 serializer = { attribute }; 59 58 }; 60
Note:
See TracChangeset
for help on using the changeset viewer.