Changeset 218511 in webkit
- Timestamp:
- Jun 19, 2017 2:55:00 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 7 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r218510 r218511 1 2017-06-19 Sam Weinig <sam@webkit.org> 2 3 [WebIDL] Add support for serializers that have members that are themselves serializers (or inherit being a serializer from a parent) 4 https://bugs.webkit.org/show_bug.cgi?id=173395 5 6 Reviewed by Simon Fraser. 7 8 * fast/css/DOMQuad-serialization-expected.txt: Added. 9 * fast/css/DOMQuad-serialization.html: Added. 10 Add test for DOMQuad serialization, now that it is supported. 11 1 12 2017-06-19 Commit Queue <commit-queue@webkit.org> 2 13 -
trunk/Source/WebCore/ChangeLog
r218510 r218511 1 2017-06-19 Sam Weinig <sam@webkit.org> 2 3 [WebIDL] Add support for serializers that have members that are themselves serializers (or inherit being a serializer from a parent) 4 https://bugs.webkit.org/show_bug.cgi?id=173395 5 6 Reviewed by Simon Fraser. 7 8 Test: fast/css/DOMQuad-serialization.html 9 10 * bindings/scripts/CodeGenerator.pm: 11 (InheritsSerializable): 12 Helper to determine if an interface inherits from any interfaces 13 that are serializable. This is necessary because an attribute is 14 serializable even if its interface is not marked as serializable. 15 16 (IsSerializableAttribute): 17 Check ancestor interfaces as well to determine serializability. 18 19 * bindings/scripts/CodeGeneratorJS.pm: 20 (GenerateSerializerDefinition): 21 Specialize attributes that are serializable interfaces to call its interfaces 22 serialize function, thus allowing nested objects to be serialized. 23 24 * dom/DOMQuad.idl: 25 Add serializer. 26 27 * bindings/scripts/test/JS/JSTestSerialization.cpp: 28 * bindings/scripts/test/JS/JSTestSerializationIndirectInheritance.cpp: Added. 29 * bindings/scripts/test/JS/JSTestSerializationIndirectInheritance.h: Added. 30 * bindings/scripts/test/TestSerialization.idl: 31 * bindings/scripts/test/TestSerializationIndirectInheritance.idl: Added. 32 Add and update tests. 33 1 34 2017-06-19 Commit Queue <commit-queue@webkit.org> 2 35 -
trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm
r218495 r218511 904 904 } 905 905 906 sub InheritsSerializable 907 { 908 my ($object, $interface) = @_; 909 910 my $anyParentIsSerializable = 0; 911 $object->ForAllParents($interface, sub { 912 my $parentInterface = shift; 913 $anyParentIsSerializable = 1 if $parentInterface->serializable; 914 }, 0); 915 916 return $anyParentIsSerializable; 917 } 918 906 919 sub IsSerializableAttribute 907 920 { 908 my ($object, $ currentInterface, $attribute) = @_;921 my ($object, $interface, $attribute) = @_; 909 922 910 923 # https://heycam.github.io/webidl/#dfn-serializable-type … … 921 934 } 922 935 923 my $interface = GetInterfaceForAttribute($object, $currentInterface, $attribute); 924 if ($interface && $interface->serializable) { 925 die "Serializer for non-primitive types is not currently supported\n"; 936 return 0 if !$object->IsInterfaceType($type); 937 938 my $interfaceForAttribute = $object->GetInterfaceForAttribute($interface, $attribute); 939 if ($interfaceForAttribute) { 940 return 1 if $interfaceForAttribute->serializable; 941 return $object->InheritsSerializable($interfaceForAttribute); 926 942 } 927 943 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r218495 r218511 5193 5193 5194 5194 foreach my $attribute (@serializedAttributes) { 5195 assert("Attributes that throw exceptions are not supported with serializers yet.") if $attribute->extendedAttributes->{GetterMayThrowException} || $attribute->extendedAttributes->{MayThrowException}; 5196 5195 5197 my $name = $attribute->name; 5196 5198 my $getFunctionName = GetAttributeGetterName($interface, $className, $attribute); 5197 5199 push(@implContent, " auto ${name}Value = ${getFunctionName}Getter(state, thisObject, throwScope);\n"); 5198 5200 push(@implContent, " throwScope.assertNoException();\n"); 5199 push(@implContent, " result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), ${name}Value);\n"); 5201 5202 if ($codeGenerator->IsInterfaceType($attribute->type)) { 5203 my $attributeInterfaceName = $attribute->type->name; 5204 push(@implContent, " auto* ${name}SerializedValue = JS${attributeInterfaceName}::serialize(state, *jsCast<JS${attributeInterfaceName}*>(${name}Value), globalObject, throwScope);\n"); 5205 push(@implContent, " result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), ${name}SerializedValue);\n"); 5206 } else { 5207 push(@implContent, " result->putDirect(vm, Identifier::fromString(&vm, \"${name}\"), ${name}Value);\n"); 5208 } 5209 5200 5210 push(@implContent, "\n"); 5201 5211 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerialization.cpp
r218342 r218511 33 33 #include "JSDOMWrapperCache.h" 34 34 #include "JSTestException.h" 35 #include "JSTestSerializationIndirectInheritance.h" 36 #include "JSTestSerializationInheritFinal.h" 35 37 #include <runtime/FunctionPrototype.h> 36 38 #include <runtime/JSCInlines.h> … … 62 64 JSC::EncodedJSValue jsTestSerializationSixthTypedefAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); 63 65 bool setJSTestSerializationSixthTypedefAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); 66 JSC::EncodedJSValue jsTestSerializationSeventhDirectlySerializableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); 67 bool setJSTestSerializationSeventhDirectlySerializableAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); 68 JSC::EncodedJSValue jsTestSerializationEighthIndirectlyAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); 69 bool setJSTestSerializationEighthIndirectlyAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); 64 70 65 71 class JSTestSerializationPrototype : public JSC::JSNonFinalObject { … … 116 122 { "fifthLongAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationFifthLongAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationFifthLongAttribute) } }, 117 123 { "sixthTypedefAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationSixthTypedefAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationSixthTypedefAttribute) } }, 124 { "seventhDirectlySerializableAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationSeventhDirectlySerializableAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationSeventhDirectlySerializableAttribute) } }, 125 { "eighthIndirectlyAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializationEighthIndirectlyAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializationEighthIndirectlyAttribute) } }, 118 126 { "toJSON", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestSerializationPrototypeFunctionToJSON), (intptr_t) (0) } }, 119 127 }; … … 375 383 } 376 384 385 static inline JSValue jsTestSerializationSeventhDirectlySerializableAttributeGetter(ExecState& state, JSTestSerialization& thisObject, ThrowScope& throwScope) 386 { 387 UNUSED_PARAM(throwScope); 388 UNUSED_PARAM(state); 389 auto& impl = thisObject.wrapped(); 390 JSValue result = toJS<IDLInterface<TestSerializationInheritFinal>>(state, *thisObject.globalObject(), impl.seventhDirectlySerializableAttribute()); 391 return result; 392 } 393 394 EncodedJSValue jsTestSerializationSeventhDirectlySerializableAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName) 395 { 396 return IDLAttribute<JSTestSerialization>::get<jsTestSerializationSeventhDirectlySerializableAttributeGetter>(*state, thisValue, "seventhDirectlySerializableAttribute"); 397 } 398 399 static inline bool setJSTestSerializationSeventhDirectlySerializableAttributeSetter(ExecState& state, JSTestSerialization& thisObject, JSValue value, ThrowScope& throwScope) 400 { 401 UNUSED_PARAM(state); 402 UNUSED_PARAM(throwScope); 403 auto& impl = thisObject.wrapped(); 404 auto nativeValue = convert<IDLInterface<TestSerializationInheritFinal>>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "TestSerialization", "seventhDirectlySerializableAttribute", "TestSerializationInheritFinal"); }); 405 RETURN_IF_EXCEPTION(throwScope, false); 406 impl.setSeventhDirectlySerializableAttribute(*nativeValue); 407 return true; 408 } 409 410 bool setJSTestSerializationSeventhDirectlySerializableAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) 411 { 412 return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationSeventhDirectlySerializableAttributeSetter>(*state, thisValue, encodedValue, "seventhDirectlySerializableAttribute"); 413 } 414 415 static inline JSValue jsTestSerializationEighthIndirectlyAttributeGetter(ExecState& state, JSTestSerialization& thisObject, ThrowScope& throwScope) 416 { 417 UNUSED_PARAM(throwScope); 418 UNUSED_PARAM(state); 419 auto& impl = thisObject.wrapped(); 420 JSValue result = toJS<IDLInterface<TestSerializationIndirectInheritance>>(state, *thisObject.globalObject(), impl.eighthIndirectlyAttribute()); 421 return result; 422 } 423 424 EncodedJSValue jsTestSerializationEighthIndirectlyAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName) 425 { 426 return IDLAttribute<JSTestSerialization>::get<jsTestSerializationEighthIndirectlyAttributeGetter>(*state, thisValue, "eighthIndirectlyAttribute"); 427 } 428 429 static inline bool setJSTestSerializationEighthIndirectlyAttributeSetter(ExecState& state, JSTestSerialization& thisObject, JSValue value, ThrowScope& throwScope) 430 { 431 UNUSED_PARAM(state); 432 UNUSED_PARAM(throwScope); 433 auto& impl = thisObject.wrapped(); 434 auto nativeValue = convert<IDLInterface<TestSerializationIndirectInheritance>>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "TestSerialization", "eighthIndirectlyAttribute", "TestSerializationIndirectInheritance"); }); 435 RETURN_IF_EXCEPTION(throwScope, false); 436 impl.setEighthIndirectlyAttribute(*nativeValue); 437 return true; 438 } 439 440 bool setJSTestSerializationEighthIndirectlyAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) 441 { 442 return IDLAttribute<JSTestSerialization>::set<setJSTestSerializationEighthIndirectlyAttributeSetter>(*state, thisValue, encodedValue, "eighthIndirectlyAttribute"); 443 } 444 377 445 JSC::JSObject* JSTestSerialization::serialize(ExecState& state, JSTestSerialization& thisObject, JSDOMGlobalObject& globalObject, ThrowScope& throwScope) 378 446 { … … 399 467 throwScope.assertNoException(); 400 468 result->putDirect(vm, Identifier::fromString(&vm, "sixthTypedefAttribute"), sixthTypedefAttributeValue); 469 470 auto seventhDirectlySerializableAttributeValue = jsTestSerializationSeventhDirectlySerializableAttributeGetter(state, thisObject, throwScope); 471 throwScope.assertNoException(); 472 auto* seventhDirectlySerializableAttributeSerializedValue = JSTestSerializationInheritFinal::serialize(state, *jsCast<JSTestSerializationInheritFinal*>(seventhDirectlySerializableAttributeValue), globalObject, throwScope); 473 result->putDirect(vm, Identifier::fromString(&vm, "seventhDirectlySerializableAttribute"), seventhDirectlySerializableAttributeSerializedValue); 474 475 auto eighthIndirectlyAttributeValue = jsTestSerializationEighthIndirectlyAttributeGetter(state, thisObject, throwScope); 476 throwScope.assertNoException(); 477 auto* eighthIndirectlyAttributeSerializedValue = JSTestSerializationIndirectInheritance::serialize(state, *jsCast<JSTestSerializationIndirectInheritance*>(eighthIndirectlyAttributeValue), globalObject, throwScope); 478 result->putDirect(vm, Identifier::fromString(&vm, "eighthIndirectlyAttribute"), eighthIndirectlyAttributeSerializedValue); 401 479 402 480 return result; -
trunk/Source/WebCore/bindings/scripts/test/TestSerialization.idl
r211409 r218511 34 34 attribute TestTimeStamp sixthTypedefAttribute; 35 35 36 attribute TestSerializationInheritFinal seventhDirectlySerializableAttribute; 37 attribute TestSerializationIndirectInheritance eighthIndirectlyAttribute; 38 36 39 serializer = { attribute }; 37 40 }; -
trunk/Source/WebCore/bindings/scripts/test/TestSerializationIndirectInheritance.idl
r218510 r218511 1 1 /* 2 * Copyright (C) 201 6Apple Inc. All rights reserved.2 * Copyright (C) 2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 typedef double TestTimeStamp; 27 28 interface TestSerialization { 29 attribute DOMString firstStringAttribute; 30 attribute long secondLongAttribute; 31 attribute TestException thirdUnserializableAttribute; 32 attribute unrestricted double fourthUnrestrictedDoubleAttribute; 33 attribute long fifthLongAttribute; 34 attribute TestTimeStamp sixthTypedefAttribute; 35 36 serializer = { attribute }; 26 interface TestSerializationIndirectInheritance : TestSerializationInherit { 37 27 }; -
trunk/Source/WebCore/dom/DOMQuad.idl
r218458 r218511 31 31 ImplementationLacksVTable, 32 32 JSCustomMarkFunction 33 ] 34 interface DOMQuad { 33 ] interface DOMQuad { 35 34 [NewObject] static DOMQuad fromRect(optional DOMRectInit other); 36 35 [NewObject] static DOMQuad fromQuad(optional DOMQuadInit other); … … 42 41 [NewObject] DOMRect getBounds(); 43 42 44 // serializer = { attribute }; FIXME: implement.43 serializer = { attribute }; 45 44 };
Note: See TracChangeset
for help on using the changeset viewer.