Changeset 206974 in webkit
- Timestamp:
- Oct 9, 2016 6:16:05 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r206972 r206974 1 2016-10-09 Chris Dumez <cdumez@apple.com> 2 3 Update generated bindings code so that dictionary structures no longer need explicit constructors 4 https://bugs.webkit.org/show_bug.cgi?id=163188 5 6 Reviewed by Darin Adler. 7 8 Update generated bindings code so that dictionary structures no longer 9 need explicit constructors. We now call the default constructor and 10 then initialize the members one by one. 11 12 * bindings/scripts/CodeGeneratorJS.pm: 13 (GenerateDictionaryImplementationContent): 14 * bindings/scripts/test/JS/JSTestObj.cpp: 15 (WebCore::convertDictionary<TestObj::Dictionary>): 16 (WebCore::convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>): 17 (WebCore::convertDictionary<TestObj::DictionaryThatShouldTolerateNull>): 18 (WebCore::convertDictionary<AlternateDictionaryName>): 19 (WebCore::convertDictionary<TestObj::ParentDictionary>): 20 (WebCore::convertDictionary<TestObj::ChildDictionary>): 21 * bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp: 22 (WebCore::convertDictionary<TestStandaloneDictionary>): 23 * dom/ClipboardEvent.h: 24 * dom/CustomEvent.h: 25 * dom/EventInit.h: 26 (WebCore::EventInit::EventInit): Deleted. 27 * dom/EventModifierInit.h: 28 (WebCore::EventModifierInit::EventModifierInit): Deleted. 29 * dom/KeyboardEvent.cpp: 30 (WebCore::KeyboardEvent::KeyboardEvent): 31 * dom/KeyboardEvent.h: 32 * dom/KeyboardEvent.idl: 33 * dom/UIEventInit.h: 34 (WebCore::UIEventInit::UIEventInit): Deleted. 35 * editing/Editor.cpp: 36 (WebCore::Editor::dispatchCPPEvent): 37 1 38 2016-10-09 Fujii Hironori <Hironori.Fujii@sony.com> 2 39 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r206966 r206974 1087 1087 my $comma = ""; 1088 1088 1089 $result .= " $className result;\n"; 1090 1089 1091 # 5. For each dictionary dictionary in dictionaries, in order: 1090 1092 foreach my $dictionary (@dictionaries) { … … 1103 1105 1104 1106 my $nativeType = GetNativeTypeFromSignature($interface, $member); 1105 if ($member->isOptional && !defined $member->default) {1106 $result .= " Converter<$nativeType>::OptionalValue $key;\n";1107 } else {1108 $result .= " $nativeType $key;\n";1109 }1110 1107 1111 1108 # 5.3. If value is not undefined, then: … … 1116 1113 die "Dictionary members of non-nullable wrapper types must be marked as required" if !$member->isNullable && $member->isOptional; 1117 1114 my $nullableParameter = $member->isNullable ? "IsNullable::Yes" : "IsNullable::No"; 1118 $result .= " $key = convertWrapperType<$type, JS${type}>(state, ${key}Value, $nullableParameter);\n"; 1115 $result .= " result.$key = convertWrapperType<$type, JS${type}>(state, ${key}Value, $nullableParameter);\n"; 1116 $result .= " RETURN_IF_EXCEPTION(throwScope, Nullopt);\n"; 1119 1117 } elsif ($codeGenerator->IsDictionaryType($type)) { 1120 1118 my $nativeType = GetNativeType($interface, $type); 1121 $result .= " $key = convertDictionary<${nativeType}>(state, ${key}Value);\n"; 1119 $result .= " Optional<${nativeType}> $key = convertDictionary<${nativeType}>(state, ${key}Value).value();\n"; 1120 $result .= " RETURN_IF_EXCEPTION(throwScope, Nullopt);\n"; 1121 $result .= " result.$key = $key.value();\n"; 1122 1122 } else { 1123 1123 my $conversionRuleWithLeadingComma = GenerateConversionRuleWithLeadingComma($interface, $member); 1124 $result .= " $key = convert<${nativeType}>(state, ${key}Value${conversionRuleWithLeadingComma});\n";1125 }1126 $result .= " RETURN_IF_EXCEPTION(throwScope, Nullopt);\n";1124 $result .= " result.$key = convert<${nativeType}>(state, ${key}Value${conversionRuleWithLeadingComma});\n"; 1125 $result .= " RETURN_IF_EXCEPTION(throwScope, Nullopt);\n"; 1126 } 1127 1127 # Value is undefined. 1128 1128 # 5.4. Otherwise, if value is undefined but the dictionary member has a default value, then: 1129 1129 if ($member->isOptional && defined $member->default) { 1130 1130 $result .= " } else\n"; 1131 $result .= " $key = " . GenerateDefaultValue($interface, $member) . ";\n";1131 $result .= " result.$key = " . GenerateDefaultValue($interface, $member) . ";\n"; 1132 1132 } elsif (!$member->isOptional) { 1133 1133 # 5.5. Otherwise, if value is undefined and the dictionary member is a required dictionary member, then throw a TypeError. … … 1140 1140 } 1141 1141 } 1142 1143 # 6. Return dict. 1144 foreach my $member (@{$dictionary->members}) { 1145 my $value; 1146 if ($codeGenerator->IsWrapperType($member->type) && !$member->isNullable) { 1147 $value = "*" . $member->name; 1148 } elsif ($codeGenerator->IsDictionaryType($member->type)) { 1149 $value = $member->name . ".value()"; 1150 } else { 1151 $value = "WTFMove(" . $member->name . ")"; 1152 } 1153 $arguments .= $comma . $value; 1154 $comma = ", "; 1155 } 1156 } 1157 1158 $result .= " return $className { " . $arguments . " };\n"; 1142 } 1143 1144 $result .= " return WTFMove(result);\n"; 1159 1145 $result .= "}\n\n"; 1160 1146 $result .= "#endif\n\n" if $conditionalString; -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r206966 r206974 476 476 return Nullopt; 477 477 } 478 TestObj::Dictionary result; 478 479 JSValue anyTypedefValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "anyTypedefValue")); 479 JSC::JSValue anyTypedefValue;480 480 if (!anyTypedefValueValue.isUndefined()) { 481 anyTypedefValue = convert<JSC::JSValue>(state, anyTypedefValueValue);481 result.anyTypedefValue = convert<JSC::JSValue>(state, anyTypedefValueValue); 482 482 RETURN_IF_EXCEPTION(throwScope, Nullopt); 483 483 } else 484 anyTypedefValue = jsUndefined();484 result.anyTypedefValue = jsUndefined(); 485 485 JSValue anyValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "anyValue")); 486 JSC::JSValue anyValue;487 486 if (!anyValueValue.isUndefined()) { 488 anyValue = convert<JSC::JSValue>(state, anyValueValue);487 result.anyValue = convert<JSC::JSValue>(state, anyValueValue); 489 488 RETURN_IF_EXCEPTION(throwScope, Nullopt); 490 489 } else 491 anyValue = jsUndefined();490 result.anyValue = jsUndefined(); 492 491 JSValue anyValueWithNullDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "anyValueWithNullDefault")); 493 JSC::JSValue anyValueWithNullDefault;494 492 if (!anyValueWithNullDefaultValue.isUndefined()) { 495 anyValueWithNullDefault = convert<JSC::JSValue>(state, anyValueWithNullDefaultValue);493 result.anyValueWithNullDefault = convert<JSC::JSValue>(state, anyValueWithNullDefaultValue); 496 494 RETURN_IF_EXCEPTION(throwScope, Nullopt); 497 495 } else 498 anyValueWithNullDefault = jsNull();496 result.anyValueWithNullDefault = jsNull(); 499 497 JSValue booleanWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "booleanWithDefault")); 500 bool booleanWithDefault;501 498 if (!booleanWithDefaultValue.isUndefined()) { 502 booleanWithDefault = convert<bool>(state, booleanWithDefaultValue);499 result.booleanWithDefault = convert<bool>(state, booleanWithDefaultValue); 503 500 RETURN_IF_EXCEPTION(throwScope, Nullopt); 504 501 } else 505 booleanWithDefault = false;502 result.booleanWithDefault = false; 506 503 JSValue booleanWithoutDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "booleanWithoutDefault")); 507 Converter<bool>::OptionalValue booleanWithoutDefault;508 504 if (!booleanWithoutDefaultValue.isUndefined()) { 509 booleanWithoutDefault = convert<bool>(state, booleanWithoutDefaultValue);505 result.booleanWithoutDefault = convert<bool>(state, booleanWithoutDefaultValue); 510 506 RETURN_IF_EXCEPTION(throwScope, Nullopt); 511 507 } 512 508 JSValue dictionaryMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "dictionaryMember")); 513 Converter<TestObj::DictionaryThatShouldTolerateNull>::OptionalValue dictionaryMember;514 509 if (!dictionaryMemberValue.isUndefined()) { 515 dictionaryMember = convertDictionary<TestObj::DictionaryThatShouldTolerateNull>(state, dictionaryMemberValue);510 Optional<TestObj::DictionaryThatShouldTolerateNull> dictionaryMember = convertDictionary<TestObj::DictionaryThatShouldTolerateNull>(state, dictionaryMemberValue).value(); 516 511 RETURN_IF_EXCEPTION(throwScope, Nullopt); 512 result.dictionaryMember = dictionaryMember.value(); 517 513 } 518 514 JSValue enumerationValueWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "enumerationValueWithDefault")); 519 TestObj::EnumType enumerationValueWithDefault;520 515 if (!enumerationValueWithDefaultValue.isUndefined()) { 521 enumerationValueWithDefault = convert<TestObj::EnumType>(state, enumerationValueWithDefaultValue);516 result.enumerationValueWithDefault = convert<TestObj::EnumType>(state, enumerationValueWithDefaultValue); 522 517 RETURN_IF_EXCEPTION(throwScope, Nullopt); 523 518 } else 524 enumerationValueWithDefault = TestObj::EnumType::EnumValue1;519 result.enumerationValueWithDefault = TestObj::EnumType::EnumValue1; 525 520 JSValue enumerationValueWithEmptyStringDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "enumerationValueWithEmptyStringDefault")); 526 TestObj::EnumType enumerationValueWithEmptyStringDefault;527 521 if (!enumerationValueWithEmptyStringDefaultValue.isUndefined()) { 528 enumerationValueWithEmptyStringDefault = convert<TestObj::EnumType>(state, enumerationValueWithEmptyStringDefaultValue);522 result.enumerationValueWithEmptyStringDefault = convert<TestObj::EnumType>(state, enumerationValueWithEmptyStringDefaultValue); 529 523 RETURN_IF_EXCEPTION(throwScope, Nullopt); 530 524 } else 531 enumerationValueWithEmptyStringDefault = TestObj::EnumType::EmptyString;525 result.enumerationValueWithEmptyStringDefault = TestObj::EnumType::EmptyString; 532 526 JSValue enumerationValueWithoutDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "enumerationValueWithoutDefault")); 533 Converter<TestObj::EnumType>::OptionalValue enumerationValueWithoutDefault;534 527 if (!enumerationValueWithoutDefaultValue.isUndefined()) { 535 enumerationValueWithoutDefault = convert<TestObj::EnumType>(state, enumerationValueWithoutDefaultValue);528 result.enumerationValueWithoutDefault = convert<TestObj::EnumType>(state, enumerationValueWithoutDefaultValue); 536 529 RETURN_IF_EXCEPTION(throwScope, Nullopt); 537 530 } 538 531 JSValue integerValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "integer")); 539 Converter<int32_t>::OptionalValue integer;540 532 if (!integerValue.isUndefined()) { 541 integer = convert<int32_t>(state, integerValue, NormalConversion);533 result.integer = convert<int32_t>(state, integerValue, NormalConversion); 542 534 RETURN_IF_EXCEPTION(throwScope, Nullopt); 543 535 } 544 536 JSValue integerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "integerWithDefault")); 545 int32_t integerWithDefault;546 537 if (!integerWithDefaultValue.isUndefined()) { 547 integerWithDefault = convert<int32_t>(state, integerWithDefaultValue, NormalConversion);538 result.integerWithDefault = convert<int32_t>(state, integerWithDefaultValue, NormalConversion); 548 539 RETURN_IF_EXCEPTION(throwScope, Nullopt); 549 540 } else 550 integerWithDefault = 0;541 result.integerWithDefault = 0; 551 542 JSValue largeIntegerValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "largeInteger")); 552 Converter<int64_t>::OptionalValue largeInteger;553 543 if (!largeIntegerValue.isUndefined()) { 554 largeInteger = convert<int64_t>(state, largeIntegerValue, NormalConversion);544 result.largeInteger = convert<int64_t>(state, largeIntegerValue, NormalConversion); 555 545 RETURN_IF_EXCEPTION(throwScope, Nullopt); 556 546 } 557 547 JSValue largeIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "largeIntegerWithDefault")); 558 int64_t largeIntegerWithDefault;559 548 if (!largeIntegerWithDefaultValue.isUndefined()) { 560 largeIntegerWithDefault = convert<int64_t>(state, largeIntegerWithDefaultValue, NormalConversion);549 result.largeIntegerWithDefault = convert<int64_t>(state, largeIntegerWithDefaultValue, NormalConversion); 561 550 RETURN_IF_EXCEPTION(throwScope, Nullopt); 562 551 } else 563 largeIntegerWithDefault = 0;552 result.largeIntegerWithDefault = 0; 564 553 JSValue nullableNodeValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "nullableNode")); 565 Node* nullableNode;566 554 if (!nullableNodeValue.isUndefined()) { 567 nullableNode = convertWrapperType<Node, JSNode>(state, nullableNodeValue, IsNullable::Yes);555 result.nullableNode = convertWrapperType<Node, JSNode>(state, nullableNodeValue, IsNullable::Yes); 568 556 RETURN_IF_EXCEPTION(throwScope, Nullopt); 569 557 } else 570 nullableNode = nullptr;558 result.nullableNode = nullptr; 571 559 JSValue restrictedDoubleValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "restrictedDouble")); 572 Converter<double>::OptionalValue restrictedDouble;573 560 if (!restrictedDoubleValue.isUndefined()) { 574 res trictedDouble = convert<double>(state, restrictedDoubleValue, ShouldAllowNonFinite::No);561 result.restrictedDouble = convert<double>(state, restrictedDoubleValue, ShouldAllowNonFinite::No); 575 562 RETURN_IF_EXCEPTION(throwScope, Nullopt); 576 563 } 577 564 JSValue restrictedDoubleWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "restrictedDoubleWithDefault")); 578 double restrictedDoubleWithDefault;579 565 if (!restrictedDoubleWithDefaultValue.isUndefined()) { 580 res trictedDoubleWithDefault = convert<double>(state, restrictedDoubleWithDefaultValue, ShouldAllowNonFinite::No);566 result.restrictedDoubleWithDefault = convert<double>(state, restrictedDoubleWithDefaultValue, ShouldAllowNonFinite::No); 581 567 RETURN_IF_EXCEPTION(throwScope, Nullopt); 582 568 } else 583 res trictedDoubleWithDefault = 0;569 result.restrictedDoubleWithDefault = 0; 584 570 JSValue restrictedFloatValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "restrictedFloat")); 585 Converter<float>::OptionalValue restrictedFloat;586 571 if (!restrictedFloatValue.isUndefined()) { 587 res trictedFloat = convert<float>(state, restrictedFloatValue, ShouldAllowNonFinite::No);572 result.restrictedFloat = convert<float>(state, restrictedFloatValue, ShouldAllowNonFinite::No); 588 573 RETURN_IF_EXCEPTION(throwScope, Nullopt); 589 574 } 590 575 JSValue restrictedFloatWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "restrictedFloatWithDefault")); 591 float restrictedFloatWithDefault;592 576 if (!restrictedFloatWithDefaultValue.isUndefined()) { 593 res trictedFloatWithDefault = convert<float>(state, restrictedFloatWithDefaultValue, ShouldAllowNonFinite::No);577 result.restrictedFloatWithDefault = convert<float>(state, restrictedFloatWithDefaultValue, ShouldAllowNonFinite::No); 594 578 RETURN_IF_EXCEPTION(throwScope, Nullopt); 595 579 } else 596 res trictedFloatWithDefault = 0;580 result.restrictedFloatWithDefault = 0; 597 581 JSValue sequenceOfStringsValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "sequenceOfStrings")); 598 Converter<Vector<String>>::OptionalValue sequenceOfStrings;599 582 if (!sequenceOfStringsValue.isUndefined()) { 600 sequenceOfStrings = convert<Vector<String>>(state, sequenceOfStringsValue);583 result.sequenceOfStrings = convert<Vector<String>>(state, sequenceOfStringsValue); 601 584 RETURN_IF_EXCEPTION(throwScope, Nullopt); 602 585 } 603 586 JSValue smallIntegerClampedValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "smallIntegerClamped")); 604 Converter<int8_t>::OptionalValue smallIntegerClamped;605 587 if (!smallIntegerClampedValue.isUndefined()) { 606 smallIntegerClamped = convert<int8_t>(state, smallIntegerClampedValue, Clamp);588 result.smallIntegerClamped = convert<int8_t>(state, smallIntegerClampedValue, Clamp); 607 589 RETURN_IF_EXCEPTION(throwScope, Nullopt); 608 590 } 609 591 JSValue smallIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "smallIntegerWithDefault")); 610 Converter<int8_t>::OptionalValue smallIntegerWithDefault;611 592 if (!smallIntegerWithDefaultValue.isUndefined()) { 612 smallIntegerWithDefault = convert<int8_t>(state, smallIntegerWithDefaultValue, NormalConversion);593 result.smallIntegerWithDefault = convert<int8_t>(state, smallIntegerWithDefaultValue, NormalConversion); 613 594 RETURN_IF_EXCEPTION(throwScope, Nullopt); 614 595 } 615 596 JSValue smallUnsignedIntegerEnforcedRangeValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "smallUnsignedIntegerEnforcedRange")); 616 Converter<uint8_t>::OptionalValue smallUnsignedIntegerEnforcedRange;617 597 if (!smallUnsignedIntegerEnforcedRangeValue.isUndefined()) { 618 smallUnsignedIntegerEnforcedRange = convert<uint8_t>(state, smallUnsignedIntegerEnforcedRangeValue, EnforceRange);598 result.smallUnsignedIntegerEnforcedRange = convert<uint8_t>(state, smallUnsignedIntegerEnforcedRangeValue, EnforceRange); 619 599 RETURN_IF_EXCEPTION(throwScope, Nullopt); 620 600 } 621 601 JSValue smallUnsignedIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "smallUnsignedIntegerWithDefault")); 622 uint8_t smallUnsignedIntegerWithDefault;623 602 if (!smallUnsignedIntegerWithDefaultValue.isUndefined()) { 624 smallUnsignedIntegerWithDefault = convert<uint8_t>(state, smallUnsignedIntegerWithDefaultValue, NormalConversion);603 result.smallUnsignedIntegerWithDefault = convert<uint8_t>(state, smallUnsignedIntegerWithDefaultValue, NormalConversion); 625 604 RETURN_IF_EXCEPTION(throwScope, Nullopt); 626 605 } else 627 smallUnsignedIntegerWithDefault = 0;606 result.smallUnsignedIntegerWithDefault = 0; 628 607 JSValue stringWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "stringWithDefault")); 629 String stringWithDefault;630 608 if (!stringWithDefaultValue.isUndefined()) { 631 stringWithDefault = convert<String>(state, stringWithDefaultValue);609 result.stringWithDefault = convert<String>(state, stringWithDefaultValue); 632 610 RETURN_IF_EXCEPTION(throwScope, Nullopt); 633 611 } else 634 stringWithDefault = "defaultString";612 result.stringWithDefault = "defaultString"; 635 613 JSValue stringWithoutDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "stringWithoutDefault")); 636 Converter<String>::OptionalValue stringWithoutDefault;637 614 if (!stringWithoutDefaultValue.isUndefined()) { 638 stringWithoutDefault = convert<String>(state, stringWithoutDefaultValue);615 result.stringWithoutDefault = convert<String>(state, stringWithoutDefaultValue); 639 616 RETURN_IF_EXCEPTION(throwScope, Nullopt); 640 617 } 641 618 JSValue unrestrictedDoubleValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unrestrictedDouble")); 642 Converter<double>::OptionalValue unrestrictedDouble;643 619 if (!unrestrictedDoubleValue.isUndefined()) { 644 unrestrictedDouble = convert<double>(state, unrestrictedDoubleValue, ShouldAllowNonFinite::Yes);620 result.unrestrictedDouble = convert<double>(state, unrestrictedDoubleValue, ShouldAllowNonFinite::Yes); 645 621 RETURN_IF_EXCEPTION(throwScope, Nullopt); 646 622 } 647 623 JSValue unrestrictedDoubleWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unrestrictedDoubleWithDefault")); 648 double unrestrictedDoubleWithDefault;649 624 if (!unrestrictedDoubleWithDefaultValue.isUndefined()) { 650 unrestrictedDoubleWithDefault = convert<double>(state, unrestrictedDoubleWithDefaultValue, ShouldAllowNonFinite::Yes);625 result.unrestrictedDoubleWithDefault = convert<double>(state, unrestrictedDoubleWithDefaultValue, ShouldAllowNonFinite::Yes); 651 626 RETURN_IF_EXCEPTION(throwScope, Nullopt); 652 627 } else 653 unrestrictedDoubleWithDefault = 0;628 result.unrestrictedDoubleWithDefault = 0; 654 629 JSValue unrestrictedFloatValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unrestrictedFloat")); 655 Converter<float>::OptionalValue unrestrictedFloat;656 630 if (!unrestrictedFloatValue.isUndefined()) { 657 unrestrictedFloat = convert<float>(state, unrestrictedFloatValue, ShouldAllowNonFinite::Yes);631 result.unrestrictedFloat = convert<float>(state, unrestrictedFloatValue, ShouldAllowNonFinite::Yes); 658 632 RETURN_IF_EXCEPTION(throwScope, Nullopt); 659 633 } 660 634 JSValue unrestrictedFloatWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unrestrictedFloatWithDefault")); 661 float unrestrictedFloatWithDefault;662 635 if (!unrestrictedFloatWithDefaultValue.isUndefined()) { 663 unrestrictedFloatWithDefault = convert<float>(state, unrestrictedFloatWithDefaultValue, ShouldAllowNonFinite::Yes);636 result.unrestrictedFloatWithDefault = convert<float>(state, unrestrictedFloatWithDefaultValue, ShouldAllowNonFinite::Yes); 664 637 RETURN_IF_EXCEPTION(throwScope, Nullopt); 665 638 } else 666 unrestrictedFloatWithDefault = 0;639 result.unrestrictedFloatWithDefault = 0; 667 640 JSValue unsignedIntegerValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unsignedInteger")); 668 Converter<uint32_t>::OptionalValue unsignedInteger;669 641 if (!unsignedIntegerValue.isUndefined()) { 670 unsignedInteger = convert<uint32_t>(state, unsignedIntegerValue, NormalConversion);642 result.unsignedInteger = convert<uint32_t>(state, unsignedIntegerValue, NormalConversion); 671 643 RETURN_IF_EXCEPTION(throwScope, Nullopt); 672 644 } 673 645 JSValue unsignedIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unsignedIntegerWithDefault")); 674 uint32_t unsignedIntegerWithDefault;675 646 if (!unsignedIntegerWithDefaultValue.isUndefined()) { 676 unsignedIntegerWithDefault = convert<uint32_t>(state, unsignedIntegerWithDefaultValue, NormalConversion);647 result.unsignedIntegerWithDefault = convert<uint32_t>(state, unsignedIntegerWithDefaultValue, NormalConversion); 677 648 RETURN_IF_EXCEPTION(throwScope, Nullopt); 678 649 } else 679 unsignedIntegerWithDefault = 0;650 result.unsignedIntegerWithDefault = 0; 680 651 JSValue unsignedLargeIntegerValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unsignedLargeInteger")); 681 Converter<uint64_t>::OptionalValue unsignedLargeInteger;682 652 if (!unsignedLargeIntegerValue.isUndefined()) { 683 unsignedLargeInteger = convert<uint64_t>(state, unsignedLargeIntegerValue, NormalConversion);653 result.unsignedLargeInteger = convert<uint64_t>(state, unsignedLargeIntegerValue, NormalConversion); 684 654 RETURN_IF_EXCEPTION(throwScope, Nullopt); 685 655 } 686 656 JSValue unsignedLargeIntegerWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unsignedLargeIntegerWithDefault")); 687 uint64_t unsignedLargeIntegerWithDefault;688 657 if (!unsignedLargeIntegerWithDefaultValue.isUndefined()) { 689 unsignedLargeIntegerWithDefault = convert<uint64_t>(state, unsignedLargeIntegerWithDefaultValue, NormalConversion);658 result.unsignedLargeIntegerWithDefault = convert<uint64_t>(state, unsignedLargeIntegerWithDefaultValue, NormalConversion); 690 659 RETURN_IF_EXCEPTION(throwScope, Nullopt); 691 660 } else 692 unsignedLargeIntegerWithDefault = 0;693 return TestObj::Dictionary { WTFMove(enumerationValueWithoutDefault), WTFMove(enumerationValueWithDefault), WTFMove(enumerationValueWithEmptyStringDefault), WTFMove(stringWithDefault), WTFMove(stringWithoutDefault), WTFMove(booleanWithDefault), WTFMove(booleanWithoutDefault), WTFMove(sequenceOfStrings), WTFMove(restrictedDouble), WTFMove(unrestrictedDouble), WTFMove(restrictedDoubleWithDefault), WTFMove(unrestrictedDoubleWithDefault), WTFMove(restrictedFloat), WTFMove(unrestrictedFloat), WTFMove(restrictedFloatWithDefault), WTFMove(unrestrictedFloatWithDefault), WTFMove(smallIntegerClamped), WTFMove(smallIntegerWithDefault), WTFMove(smallUnsignedIntegerEnforcedRange), WTFMove(smallUnsignedIntegerWithDefault), WTFMove(integer), WTFMove(integerWithDefault), WTFMove(unsignedInteger), WTFMove(unsignedIntegerWithDefault), WTFMove(largeInteger), WTFMove(largeIntegerWithDefault), WTFMove(unsignedLargeInteger), WTFMove(unsignedLargeIntegerWithDefault), WTFMove(nullableNode), WTFMove(anyValue), WTFMove(anyValueWithNullDefault), WTFMove(anyTypedefValue), dictionaryMember.value() };661 result.unsignedLargeIntegerWithDefault = 0; 662 return WTFMove(result); 694 663 } 695 664 … … 708 677 return Nullopt; 709 678 } 679 TestObj::DictionaryThatShouldNotTolerateNull result; 710 680 JSValue booleanWithoutDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "booleanWithoutDefault")); 711 Converter<bool>::OptionalValue booleanWithoutDefault;712 681 if (!booleanWithoutDefaultValue.isUndefined()) { 713 booleanWithoutDefault = convert<bool>(state, booleanWithoutDefaultValue);682 result.booleanWithoutDefault = convert<bool>(state, booleanWithoutDefaultValue); 714 683 RETURN_IF_EXCEPTION(throwScope, Nullopt); 715 684 } 716 685 JSValue nonNullableNodeValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "nonNullableNode")); 717 Node* nonNullableNode;718 686 if (!nonNullableNodeValue.isUndefined()) { 719 nonNullableNode = convertWrapperType<Node, JSNode>(state, nonNullableNodeValue, IsNullable::No);687 result.nonNullableNode = convertWrapperType<Node, JSNode>(state, nonNullableNodeValue, IsNullable::No); 720 688 RETURN_IF_EXCEPTION(throwScope, Nullopt); 721 689 } else { … … 724 692 } 725 693 JSValue requiredDictionaryMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "requiredDictionaryMember")); 726 TestObj::Dictionary requiredDictionaryMember;727 694 if (!requiredDictionaryMemberValue.isUndefined()) { 728 requiredDictionaryMember = convertDictionary<TestObj::Dictionary>(state, requiredDictionaryMemberValue); 695 Optional<TestObj::Dictionary> requiredDictionaryMember = convertDictionary<TestObj::Dictionary>(state, requiredDictionaryMemberValue).value(); 696 RETURN_IF_EXCEPTION(throwScope, Nullopt); 697 result.requiredDictionaryMember = requiredDictionaryMember.value(); 698 } else { 699 throwTypeError(&state, throwScope); 700 return Nullopt; 701 } 702 JSValue requiredEnumerationValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "requiredEnumerationValue")); 703 if (!requiredEnumerationValueValue.isUndefined()) { 704 result.requiredEnumerationValue = convert<TestObj::EnumType>(state, requiredEnumerationValueValue); 729 705 RETURN_IF_EXCEPTION(throwScope, Nullopt); 730 706 } else { … … 732 708 return Nullopt; 733 709 } 734 JSValue requiredEnumerationValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "requiredEnumerationValue")); 735 TestObj::EnumType requiredEnumerationValue; 736 if (!requiredEnumerationValueValue.isUndefined()) { 737 requiredEnumerationValue = convert<TestObj::EnumType>(state, requiredEnumerationValueValue); 738 RETURN_IF_EXCEPTION(throwScope, Nullopt); 739 } else { 740 throwTypeError(&state, throwScope); 741 return Nullopt; 742 } 743 return TestObj::DictionaryThatShouldNotTolerateNull { WTFMove(requiredEnumerationValue), WTFMove(booleanWithoutDefault), *nonNullableNode, requiredDictionaryMember.value() }; 710 return WTFMove(result); 744 711 } 745 712 … … 758 725 return Nullopt; 759 726 } 727 TestObj::DictionaryThatShouldTolerateNull result; 760 728 JSValue booleanWithoutDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "booleanWithoutDefault")); 761 Converter<bool>::OptionalValue booleanWithoutDefault;762 729 if (!booleanWithoutDefaultValue.isUndefined()) { 763 booleanWithoutDefault = convert<bool>(state, booleanWithoutDefaultValue);730 result.booleanWithoutDefault = convert<bool>(state, booleanWithoutDefaultValue); 764 731 RETURN_IF_EXCEPTION(throwScope, Nullopt); 765 732 } 766 733 JSValue enumerationValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "enumerationValue")); 767 Converter<TestObj::EnumType>::OptionalValue enumerationValue;768 734 if (!enumerationValueValue.isUndefined()) { 769 enumerationValue = convert<TestObj::EnumType>(state, enumerationValueValue);735 result.enumerationValue = convert<TestObj::EnumType>(state, enumerationValueValue); 770 736 RETURN_IF_EXCEPTION(throwScope, Nullopt); 771 737 } 772 return TestObj::DictionaryThatShouldTolerateNull { WTFMove(enumerationValue), WTFMove(booleanWithoutDefault) };738 return WTFMove(result); 773 739 } 774 740 … … 787 753 return Nullopt; 788 754 } 755 AlternateDictionaryName result; 789 756 JSValue booleanWithoutDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "booleanWithoutDefault")); 790 Converter<bool>::OptionalValue booleanWithoutDefault;791 757 if (!booleanWithoutDefaultValue.isUndefined()) { 792 booleanWithoutDefault = convert<bool>(state, booleanWithoutDefaultValue);758 result.booleanWithoutDefault = convert<bool>(state, booleanWithoutDefaultValue); 793 759 RETURN_IF_EXCEPTION(throwScope, Nullopt); 794 760 } 795 761 JSValue enumerationValueValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "enumerationValue")); 796 Converter<TestObj::EnumType>::OptionalValue enumerationValue;797 762 if (!enumerationValueValue.isUndefined()) { 798 enumerationValue = convert<TestObj::EnumType>(state, enumerationValueValue);763 result.enumerationValue = convert<TestObj::EnumType>(state, enumerationValueValue); 799 764 RETURN_IF_EXCEPTION(throwScope, Nullopt); 800 765 } 801 return AlternateDictionaryName { WTFMove(enumerationValue), WTFMove(booleanWithoutDefault) };766 return WTFMove(result); 802 767 } 803 768 … … 816 781 return Nullopt; 817 782 } 783 TestObj::ParentDictionary result; 818 784 JSValue parentMember1Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "parentMember1")); 819 Converter<bool>::OptionalValue parentMember1;820 785 if (!parentMember1Value.isUndefined()) { 821 parentMember1 = convert<bool>(state, parentMember1Value);786 result.parentMember1 = convert<bool>(state, parentMember1Value); 822 787 RETURN_IF_EXCEPTION(throwScope, Nullopt); 823 788 } 824 789 JSValue parentMember2Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "parentMember2")); 825 Converter<bool>::OptionalValue parentMember2;826 790 if (!parentMember2Value.isUndefined()) { 827 parentMember2 = convert<bool>(state, parentMember2Value);791 result.parentMember2 = convert<bool>(state, parentMember2Value); 828 792 RETURN_IF_EXCEPTION(throwScope, Nullopt); 829 793 } 830 return TestObj::ParentDictionary { WTFMove(parentMember2), WTFMove(parentMember1) };794 return WTFMove(result); 831 795 } 832 796 … … 845 809 return Nullopt; 846 810 } 811 TestObj::ChildDictionary result; 847 812 JSValue parentMember1Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "parentMember1")); 848 Converter<bool>::OptionalValue parentMember1;849 813 if (!parentMember1Value.isUndefined()) { 850 parentMember1 = convert<bool>(state, parentMember1Value);814 result.parentMember1 = convert<bool>(state, parentMember1Value); 851 815 RETURN_IF_EXCEPTION(throwScope, Nullopt); 852 816 } 853 817 JSValue parentMember2Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "parentMember2")); 854 Converter<bool>::OptionalValue parentMember2;855 818 if (!parentMember2Value.isUndefined()) { 856 parentMember2 = convert<bool>(state, parentMember2Value);819 result.parentMember2 = convert<bool>(state, parentMember2Value); 857 820 RETURN_IF_EXCEPTION(throwScope, Nullopt); 858 821 } 859 822 JSValue childMember1Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "childMember1")); 860 Converter<bool>::OptionalValue childMember1;861 823 if (!childMember1Value.isUndefined()) { 862 childMember1 = convert<bool>(state, childMember1Value);824 result.childMember1 = convert<bool>(state, childMember1Value); 863 825 RETURN_IF_EXCEPTION(throwScope, Nullopt); 864 826 } 865 827 JSValue childMember2Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "childMember2")); 866 Converter<bool>::OptionalValue childMember2;867 828 if (!childMember2Value.isUndefined()) { 868 childMember2 = convert<bool>(state, childMember2Value);829 result.childMember2 = convert<bool>(state, childMember2Value); 869 830 RETURN_IF_EXCEPTION(throwScope, Nullopt); 870 831 } 871 return TestObj::ChildDictionary { WTFMove(parentMember2), WTFMove(parentMember1), WTFMove(childMember2), WTFMove(childMember1) };832 return WTFMove(result); 872 833 } 873 834 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestStandaloneDictionary.cpp
r206877 r206974 41 41 return Nullopt; 42 42 } 43 TestStandaloneDictionary result; 43 44 JSValue boolMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "boolMember")); 44 Converter<bool>::OptionalValue boolMember;45 45 if (!boolMemberValue.isUndefined()) { 46 boolMember = convert<bool>(state, boolMemberValue);46 result.boolMember = convert<bool>(state, boolMemberValue); 47 47 RETURN_IF_EXCEPTION(throwScope, Nullopt); 48 48 } 49 49 JSValue stringMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "stringMember")); 50 Converter<String>::OptionalValue stringMember;51 50 if (!stringMemberValue.isUndefined()) { 52 stringMember = convert<String>(state, stringMemberValue);51 result.stringMember = convert<String>(state, stringMemberValue); 53 52 RETURN_IF_EXCEPTION(throwScope, Nullopt); 54 53 } 55 return TestStandaloneDictionary { WTFMove(boolMember), WTFMove(stringMember) };54 return WTFMove(result); 56 55 } 57 56 -
trunk/Source/WebCore/dom/ClipboardEvent.h
r206963 r206974 35 35 virtual ~ClipboardEvent(); 36 36 37 struct Init : public EventInit { 38 Init(bool bubbles, bool cancelable, bool composed, RefPtr<DataTransfer>&& clipboardData) 39 : EventInit(bubbles, cancelable, composed) 40 , clipboardData(WTFMove(clipboardData)) 41 { 42 } 43 37 struct Init : EventInit { 44 38 RefPtr<DataTransfer> clipboardData; 45 39 }; -
trunk/Source/WebCore/dom/CustomEvent.h
r206964 r206974 42 42 } 43 43 44 struct Init : public EventInit { 45 Init(bool bubbles, bool cancelable, bool composed, JSC::JSValue detail) 46 : EventInit(bubbles, cancelable, composed) 47 , detail(detail) 48 { } 49 44 struct Init : EventInit { 50 45 JSC::JSValue detail; 51 46 }; -
trunk/Source/WebCore/dom/EventInit.h
r206963 r206974 29 29 30 30 struct EventInit { 31 EventInit() = default;32 EventInit(bool bubbles, bool cancelable, bool composed)33 : bubbles(bubbles)34 , cancelable(cancelable)35 , composed(composed)36 { }37 38 31 bool bubbles { false }; 39 32 bool cancelable { false }; -
trunk/Source/WebCore/dom/EventModifierInit.h
r206971 r206974 30 30 namespace WebCore { 31 31 32 struct EventModifierInit : public UIEventInit { 33 EventModifierInit() = default; 34 35 EventModifierInit(bool bubbles, bool cancelable, bool composed, RefPtr<DOMWindow>&& view, int detail, 36 bool ctrlKey, bool shiftKey, bool altKey, bool metaKey, bool modifierAltGraph, bool modifierCapsLock) 37 : UIEventInit(bubbles, cancelable, composed, WTFMove(view), detail) 38 , ctrlKey(ctrlKey) 39 , shiftKey(shiftKey) 40 , altKey(altKey) 41 , metaKey(metaKey) 42 , modifierAltGraph(modifierAltGraph) 43 , modifierCapsLock(modifierCapsLock) 44 { } 45 32 struct EventModifierInit : UIEventInit { 46 33 bool ctrlKey { false }; 47 34 bool shiftKey { false }; -
trunk/Source/WebCore/dom/KeyboardEvent.cpp
r206971 r206974 136 136 #endif 137 137 , m_keyIdentifier(initializer.keyIdentifier) 138 , m_location(initializer. location)138 , m_location(initializer.keyLocation ? *initializer.keyLocation : initializer.location) 139 139 , m_repeat(initializer.repeat) 140 140 , m_isComposing(initializer.isComposing) -
trunk/Source/WebCore/dom/KeyboardEvent.h
r206971 r206974 55 55 56 56 struct Init : public EventModifierInit { 57 Init(bool bubbles, bool cancelable, bool composed, RefPtr<DOMWindow>&& view, int detail,58 bool ctrlKey, bool shiftKey, bool altKey, bool metaKey, bool modifierAltGraph, bool modifierCapsLock,59 String key, String code, Optional<unsigned> location, bool repeat, bool isComposing, String keyIdentifier,60 Optional<unsigned> keyLocation)61 : EventModifierInit(bubbles, cancelable, composed, WTFMove(view), detail, ctrlKey, shiftKey, altKey, metaKey, modifierAltGraph, modifierCapsLock)62 , key(key)63 , code(code)64 , location(location ? *location : keyLocation.valueOr(DOM_KEY_LOCATION_STANDARD))65 , repeat(repeat)66 , isComposing(isComposing)67 , keyIdentifier(keyIdentifier)68 { }69 70 57 String key; 71 58 String code; … … 76 63 // Legacy. 77 64 String keyIdentifier; 65 Optional<unsigned> keyLocation; 78 66 }; 79 67 -
trunk/Source/WebCore/dom/KeyboardEvent.idl
r206971 r206974 57 57 DOMString key = ""; 58 58 DOMString code = ""; 59 unsigned long location ;59 unsigned long location = 0; 60 60 boolean repeat = false; 61 61 boolean isComposing = false; -
trunk/Source/WebCore/dom/UIEventInit.h
r206971 r206974 33 33 34 34 struct UIEventInit : public EventInit { 35 UIEventInit() = default;36 UIEventInit(bool bubbles, bool cancelable, bool composed, RefPtr<DOMWindow>&& view, int detail)37 : EventInit(bubbles, cancelable, composed)38 , view(WTFMove(view))39 , detail(detail)40 { }41 42 35 RefPtr<DOMWindow> view; 43 36 int detail { 0 }; -
trunk/Source/WebCore/editing/Editor.cpp
r206963 r206974 882 882 return true; 883 883 884 RefPtr<DataTransfer> dataTransfer = DataTransfer::createForCopyAndPaste(policy); 885 886 auto event = ClipboardEvent::create(eventType, { true, true, false, dataTransfer.get() }, Event::IsTrusted::Yes); 884 auto dataTransfer = DataTransfer::createForCopyAndPaste(policy); 885 886 ClipboardEvent::Init init; 887 init.bubbles = true; 888 init.cancelable = true; 889 init.clipboardData = dataTransfer.ptr(); 890 auto event = ClipboardEvent::create(eventType, init, Event::IsTrusted::Yes); 887 891 target->dispatchEvent(event); 888 892 bool noDefaultProcessing = event->defaultPrevented();
Note: See TracChangeset
for help on using the changeset viewer.