Changeset 200288 in webkit
- Timestamp:
- Apr 29, 2016, 10:09:10 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 18 edited
-
JavaScriptCore/ChangeLog (modified) (1 diff)
-
JavaScriptCore/runtime/JSString.h (modified) (1 diff)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/bindings/scripts/CodeGenerator.pm (modified) (4 diffs)
-
WebCore/bindings/scripts/CodeGeneratorJS.pm (modified) (13 diffs)
-
WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp (modified) (1 diff)
-
WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp (modified) (1 diff)
-
WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp (modified) (4 diffs)
-
WebCore/bindings/scripts/test/JS/JSTestInterface.cpp (modified) (7 diffs)
-
WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp (modified) (1 diff)
-
WebCore/bindings/scripts/test/JS/JSTestNode.cpp (modified) (1 diff)
-
WebCore/bindings/scripts/test/JS/JSTestNondeterministic.cpp (modified) (4 diffs)
-
WebCore/bindings/scripts/test/JS/JSTestObj.cpp (modified) (37 diffs)
-
WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp (modified) (1 diff)
-
WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp (modified) (1 diff)
-
WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp (modified) (4 diffs)
-
WebCore/css/FontFace.cpp (modified) (1 diff)
-
WebCore/css/FontFace.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r200277 r200288 1 2016-04-28 Darin Adler <darin@apple.com> 2 3 First step in using "enum class" instead of "String" for enumerations in DOM 4 https://bugs.webkit.org/show_bug.cgi?id=157163 5 6 Reviewed by Chris Dumez. 7 8 * runtime/JSString.h: 9 (JSC::jsStringWithCache): Deleted unneeded overload for AtomicString. 10 1 11 2016-04-29 Benjamin Poulain <bpoulain@apple.com> 2 12 -
trunk/Source/JavaScriptCore/runtime/JSString.h
r199686 r200288 654 654 } 655 655 656 ALWAYS_INLINE JSString* jsStringWithCache(ExecState* exec, const AtomicString& s)657 {658 return jsStringWithCache(exec, s.string());659 }660 661 656 ALWAYS_INLINE bool JSString::getStringPropertySlot(ExecState* exec, PropertyName propertyName, PropertySlot& slot) 662 657 { -
trunk/Source/WebCore/ChangeLog
r200287 r200288 1 2016-04-28 Darin Adler <darin@apple.com> 2 3 First step in using "enum class" instead of "String" for enumerations in DOM 4 https://bugs.webkit.org/show_bug.cgi?id=157163 5 6 Reviewed by Chris Dumez. 7 8 This patch adds the basic support for using "enum class" to implement enumerations 9 in the C++ DOM. This is enough so we can use it for one case, but not enough for 10 others. For example, it correctly generates code to get an attribute, but likely 11 does not correctly generate code to set an attribute or call a function with an 12 argument type that is the new style of enum. 13 14 * bindings/scripts/CodeGenerator.pm: Cleaned up the formatting of the hashes 15 at the start of this file. Added a new one named stringBasedEnumerationHash 16 and a comment explaining that we need to eventually make it empty. 17 (ProcessDocument): Pass the enumerations into the GenerateInterface function. 18 (IsStringBasedEnumType): Added. Returns 1 for the old-style string-based enumerations, 19 as opposed to enumerations we use "enum class" for. 20 21 * bindings/scripts/CodeGeneratorJS.pm: 22 (GenerateInterface): Take the enumerations argument and pass it along to the 23 functions that generate headers and implementation files. 24 (EnumerationClassName): Added. Maps from an enumeration type name as seen 25 in the IDL file to the enumeration class name used in the C++ DOM implementation. 26 (EnumerationValueName): Added. Maps from an anumeration string value as seen 27 in the IDL file to an enumeration value name used in the C++ DOM implementatino. 28 (EnumerationImplementationContent): Added. Generates a string with all the content 29 needed in the implementation file to define the helper functions for enumerations. 30 (GenerateHeader): Tweak. 31 (GenerateImplementation): Added call to EnumerationImplementationContent. 32 (GenerateParametersCheck): Use toWTFString instead of toString/value, which is a 33 longer way of writing out the same thing. 34 (GenerateCallbackHeader): Tweak. 35 (GenerateCallbackImplementation): Added call to EnumerationImplementationContent. 36 (GetNativeType): Continue to return String for string-based enum types, but for 37 other enum types, return the result of EnumerationClassName instead. 38 (JSValueToNative): Use toWTFString instead of toString/value (see above), convert 39 to a string only for string-based enum types, and add a preliminary, probably not 40 yet working, version of the code for non-string-based enum types. Will finish this 41 in the next patch when we are trying to use one of the new enumerations for a setter 42 or a function argument. 43 (NativeToJSValue): Call the stringValue function to convert an enumeration value 44 into a string when it's not a string-based enumeration. 45 46 * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: 47 * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp: 48 * bindings/scripts/test/JS/JSTestGlobalObject.cpp: 49 * bindings/scripts/test/JS/JSTestInterface.cpp: 50 * bindings/scripts/test/JS/JSTestNamedConstructor.cpp: 51 * bindings/scripts/test/JS/JSTestNode.cpp: 52 * bindings/scripts/test/JS/JSTestNondeterministic.cpp: 53 * bindings/scripts/test/JS/JSTestObj.cpp: 54 * bindings/scripts/test/JS/JSTestObj.h: 55 * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp: 56 * bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp: 57 * bindings/scripts/test/JS/JSTestTypedefs.cpp: 58 Regenerated. 59 60 * css/FontFace.cpp: 61 (WebCore::FontFace::status): Updated to return enum values rather than strings. 62 63 * css/FontFace.h: Removed unneeded forward declaration of Deprecated::ScriptValue. 64 Added enum class for FontFaceLoadStatus, with names that match the names from the 65 enumeration in the IDL, but with our standard enum capitalization style. Changed 66 the return value of the status function to FontFaceLoadStatus. 67 1 68 2016-04-29 Chris Dumez <cdumez@apple.com> 2 69 -
trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm
r200236 r200288 45 45 my $verbose = 0; 46 46 47 my %numericTypeHash = ("int" => 1, "short" => 1, "long" => 1, "long long" => 1, 48 "unsigned int" => 1, "unsigned short" => 1, 49 "unsigned long" => 1, "unsigned long long" => 1, 50 "float" => 1, "double" => 1, 51 "unrestricted float" => 1, "unrestricted double" => 1, 52 "byte" => 1, "octet" => 1); 53 54 my %primitiveTypeHash = ( "boolean" => 1, "void" => 1, "Date" => 1); 55 56 my %stringTypeHash = ("DOMString" => 1); 47 my %numericTypeHash = ( 48 "byte" => 1, 49 "double" => 1, 50 "float" => 1, 51 "int" => 1, 52 "long long" => 1, 53 "long" => 1, 54 "octet" => 1, 55 "short" => 1, 56 "unrestricted double" => 1, 57 "unrestricted float" => 1, 58 "unsigned int" => 1, 59 "unsigned long long" => 1, 60 "unsigned long" => 1, 61 "unsigned short" => 1, 62 ); 63 64 my %primitiveTypeHash = ( "boolean" => 1, "void" => 1, "Date" => 1 ); 65 66 my %stringTypeHash = ( "DOMString" => 1 ); 57 67 58 68 # WebCore types used directly in IDL files. 59 69 my %webCoreTypeHash = ( 70 "Dictionary" => 1, 60 71 "SerializedScriptValue" => 1, 61 "Dictionary" => 162 72 ); 63 73 64 74 my %enumTypeHash = (); 65 75 66 my %nonPointerTypeHash = ("DOMTimeStamp" => 1); 67 68 my %svgAttributesInHTMLHash = ("class" => 1, "id" => 1, "onabort" => 1, "onclick" => 1, 69 "onerror" => 1, "onload" => 1, "onmousedown" => 1, 70 "onmouseenter" => 1, "onmouseleave" => 1, 71 "onmousemove" => 1, "onmouseout" => 1, "onmouseover" => 1, 72 "onmouseup" => 1, "onresize" => 1, "onscroll" => 1, 73 "onunload" => 1); 76 my %nonPointerTypeHash = ( "DOMTimeStamp" => 1 ); 77 78 my %svgAttributesInHTMLHash = ( 79 "class" => 1, 80 "id" => 1, 81 "onabort" => 1, 82 "onclick" => 1, 83 "onerror" => 1, 84 "onload" => 1, 85 "onmousedown" => 1, 86 "onmouseenter" => 1, 87 "onmouseleave" => 1, 88 "onmousemove" => 1, 89 "onmouseout" => 1, 90 "onmouseover" => 1, 91 "onmouseup" => 1, 92 "onresize" => 1, 93 "onscroll" => 1, 94 "onunload" => 1, 95 ); 74 96 75 97 my %svgTypeNeedingTearOff = ( … … 95 117 ); 96 118 119 # FIXME: Remove each enum from this hash as we convert it from the string-based 120 # enumeration to using an actual enum class in the C++. Once that is done, we should 121 # remove this hash and the function that calls it. 122 my %stringBasedEnumerationHash = ( 123 "AppendMode" => 1, 124 "AudioContextState" => 1, 125 "AutoFillButtonType" => 1, 126 "CachePolicy" => 1, 127 "CanvasWindingRule" => 1, 128 "DeviceType" => 1, 129 "EndOfStreamError" => 1, 130 "FontFaceSetLoadStatus" => 1, 131 "IDBCursorDirection" => 1, 132 "IDBRequestReadyState" => 1, 133 "IDBTransactionMode" => 1, 134 "ImageSmoothingQuality" => 1, 135 "KeyType" => 1, 136 "KeyUsage" => 1, 137 "MediaControlEvent" => 1, 138 "MediaDeviceKind" => 1, 139 "MediaSessionInterruptingCategory" => 1, 140 "MediaSessionKind" => 1, 141 "MediaStreamTrackState" => 1, 142 "OverSampleType" => 1, 143 "PageOverlayType" => 1, 144 "RTCBundlePolicyEnum" => 1, 145 "RTCIceTransportPolicyEnum" => 1, 146 "ReferrerPolicy" => 1, 147 "RequestCache" => 1, 148 "RequestCredentials" => 1, 149 "RequestDestination" => 1, 150 "RequestMode" => 1, 151 "RequestRedirect" => 1, 152 "RequestType" => 1, 153 "ResourceLoadPriority" => 1, 154 "ResponseType" => 1, 155 "TextTrackKind" => 1, 156 "TextTrackMode" => 1, 157 "VideoPresentationMode" => 1, 158 "XMLHttpRequestResponseType" => 1, 159 ); 160 97 161 # Cache of IDL file pathnames. 98 162 my $idlFiles; … … 142 206 foreach my $interface (@$interfaces) { 143 207 print "Generating $useGenerator bindings code for IDL interface \"" . $interface->name . "\"...\n" if $verbose; 144 $codeGenerator->GenerateInterface($interface, $defines); 208 # FIXME: Repeating each enumeration for every interface would not work if we actually were using 209 # multiple interfaces per file, but we aren't, so this is fine for now. 210 $codeGenerator->GenerateInterface($interface, $defines, $useDocument->enumerations); 145 211 $codeGenerator->WriteData($interface, $useOutputDir, $useOutputHeadersDir); 146 212 } … … 333 399 334 400 return 1 if $stringTypeHash{$type}; 401 return 0; 402 } 403 404 sub IsStringBasedEnumType 405 { 406 my $object = shift; 407 my $type = shift; 408 409 return 0 if !$object->IsEnumType($type); 410 return 1 if exists $stringBasedEnumerationHash{$type}; 335 411 return 0; 336 412 } -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r200286 r200288 124 124 my $interface = shift; 125 125 my $defines = shift; 126 my $enumerations = shift; 126 127 127 128 $codeGenerator->LinkOverloadedFunctions($interface); … … 130 131 if ($interface->isCallback) { 131 132 $object->GenerateCallbackHeader($interface); 132 $object->GenerateCallbackImplementation($interface );133 $object->GenerateCallbackImplementation($interface, $enumerations); 133 134 } else { 134 135 $object->GenerateHeader($interface); 135 $object->GenerateImplementation($interface );136 $object->GenerateImplementation($interface, $enumerations); 136 137 } 137 138 } … … 831 832 } 832 833 834 sub GetEnumerationClassName { 835 my ($name) = @_; 836 return $codeGenerator->WK_ucfirst($name); 837 }; 838 839 sub GetEnumerationValueName { 840 my ($name) = @_; 841 return "EmptyString" if $name eq ""; 842 return $codeGenerator->WK_ucfirst($name); 843 }; 844 845 sub GetEnumerationImplementationContent 846 { 847 my ($enumerations) = @_; 848 849 my $result = ""; 850 foreach my $enumeration (@$enumerations) { 851 my $name = $enumeration->name; 852 next if $codeGenerator->IsStringBasedEnumType($name); 853 854 my $className = GetEnumerationClassName($name); 855 856 # Declare these instead of using "static" because these functions may be unused 857 # and we don't want to get warnings about unused static functions. 858 $result .= "const String& stringValue($className);\n"; 859 $result .= "Optional<$className> enumerationValue$className(const String&);\n\n"; 860 861 $result .= "const String& stringValue($className enumerationValue)\n"; 862 $result .= "{\n"; 863 # FIXME: Might be nice to make this global be "const", but NeverDestroyed does not currently support that. 864 # FIXME: Might be nice to make the entire array be NeverDestroyed instead of each value, but not sure the syntax for that. 865 $result .= " static NeverDestroyed<const String> values[] = {\n"; 866 foreach my $value (@{$enumeration->values}) { 867 $result .= " ASCIILiteral(\"$value\"),\n"; 868 } 869 $result .= " };\n"; 870 my $index = 0; 871 foreach my $value (@{$enumeration->values}) { 872 my $enumerationValueName = GetEnumerationValueName($value); 873 if ($index) { 874 $result .= " static_assert(static_cast<size_t>($className::$enumerationValueName) == $index, \"$className::$enumerationValueName is not $index as expected\");\n"; 875 } else { 876 # Keep the style checker happy. Not sure I still love this style guideline. 877 $result .= " static_assert(!static_cast<size_t>($className::$enumerationValueName), \"$className::$enumerationValueName is not $index as expected\");\n"; 878 } 879 $index++; 880 } 881 $result .= " ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));\n"; 882 $result .= " return values[static_cast<size_t>(enumerationValue)];\n"; 883 $result .= "}\n\n"; 884 885 $result .= "Optional<$className> enumerationValue$className(const String& stringValue)\n"; 886 $result .= "{\n"; 887 foreach my $value (@{$enumeration->values}) { 888 my $enumerationValueName = GetEnumerationValueName($value); 889 $result .= " if (stringValue == \"$value\")\n"; 890 $result .= " return $className::$enumerationValueName;\n"; 891 } 892 $result .= " return Nullopt;\n"; 893 $result .= "}\n\n"; 894 } 895 return $result; 896 } 897 833 898 sub GenerateHeader 834 899 { 835 my $object = shift; 836 my $interface = shift; 900 my ($object, $interface) = @_; 837 901 838 902 my $interfaceName = $interface->name; … … 1797 1861 sub GenerateImplementation 1798 1862 { 1799 my ($object, $interface ) = @_;1863 my ($object, $interface, $enumerations) = @_; 1800 1864 1801 1865 my $interfaceName = $interface->name; … … 1828 1892 push(@implContent, "\nusing namespace JSC;\n\n"); 1829 1893 push(@implContent, "namespace WebCore {\n\n"); 1894 1895 push(@implContent, GetEnumerationImplementationContent($enumerations)); 1830 1896 1831 1897 my @functions = @{$interface->functions}; … … 3603 3669 push(@$outputArray, " $name = ASCIILiteral(" . $parameter->default . ");\n"); 3604 3670 push(@$outputArray, " else {\n"); 3605 push(@$outputArray, " $name = state->uncheckedArgument($argsIndex).to String(state)->value(state);\n");3671 push(@$outputArray, " $name = state->uncheckedArgument($argsIndex).toWTFString(state);\n"); 3606 3672 &$exceptionCheck(" "); 3607 3673 &$enumValueCheck(" "); … … 3722 3788 sub GenerateCallbackHeader 3723 3789 { 3724 my $object = shift; 3725 my $interface = shift; 3790 my ($object, $interface) = @_; 3726 3791 3727 3792 my $interfaceName = $interface->name; … … 3807 3872 sub GenerateCallbackImplementation 3808 3873 { 3809 my ($object, $interface ) = @_;3874 my ($object, $interface, $enumerations) = @_; 3810 3875 3811 3876 my $interfaceName = $interface->name; … … 3823 3888 push(@implContent, "\nusing namespace JSC;\n\n"); 3824 3889 push(@implContent, "namespace WebCore {\n\n"); 3890 3891 push(@implContent, GetEnumerationImplementationContent($enumerations)); 3825 3892 3826 3893 # Constructor … … 4180 4247 4181 4248 return "Vector<" . GetNativeVectorInnerType($arrayOrSequenceType) . ">" if $arrayOrSequenceType; 4182 return "String" if $codeGenerator->IsEnumType($type); 4249 return "String" if $codeGenerator->IsStringBasedEnumType($type); 4250 return GetEnumerationClassName($type) if $codeGenerator->IsEnumType($type); 4183 4251 4184 4252 # For all other types, the native type is a pointer with same type name as the IDL type. … … 4297 4365 return "$value.toString(state)->toAtomicString(state)" if $signature->extendedAttributes->{"AtomicString"}; 4298 4366 4299 return "$value.to String(state)->value(state)";4367 return "$value.toWTFString(state)"; 4300 4368 } 4301 4369 … … 4343 4411 } 4344 4412 4413 return "$value.toWTFString(state)" if $codeGenerator->IsStringBasedEnumType($type); 4414 4345 4415 if ($codeGenerator->IsEnumType($type)) { 4346 return "$value.toString(state)->value(state)"; 4416 my $className = GetEnumerationClassName($type); 4417 return "enumerationValue$className($value.toWTFString(state)).value()"; 4347 4418 } 4348 4419 … … 4395 4466 if ($codeGenerator->IsEnumType($type)) { 4396 4467 AddToImplIncludes("<runtime/JSString.h>", $conditional); 4468 $value = "stringValue($value)" unless $codeGenerator->IsStringBasedEnumType($type); 4397 4469 return "jsStringWithCache(state, $value)"; 4398 4470 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp
r200286 r200288 223 223 if (UNLIKELY(state->argumentCount() < 1)) 224 224 return throwVMError(state, createNotEnoughArgumentsError(state)); 225 String message = state->argument(0).to String(state)->value(state);225 String message = state->argument(0).toWTFString(state); 226 226 if (UNLIKELY(state->hadException())) 227 227 return JSValue::encode(jsUndefined()); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp
r200286 r200288 194 194 if (UNLIKELY(state->argumentCount() < 1)) 195 195 return throwVMError(state, createNotEnoughArgumentsError(state)); 196 String str = state->argument(0).to String(state)->value(state);196 String str = state->argument(0).toWTFString(state); 197 197 if (UNLIKELY(state->hadException())) 198 198 return JSValue::encode(jsUndefined()); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp
r200286 r200288 215 215 } 216 216 auto& impl = castedThis->wrapped(); 217 String nativeValue = value.to String(state)->value(state);217 String nativeValue = value.toWTFString(state); 218 218 if (UNLIKELY(state->hadException())) 219 219 return false; … … 233 233 } 234 234 auto& impl = castedThis->wrapped(); 235 String nativeValue = value.to String(state)->value(state);235 String nativeValue = value.toWTFString(state); 236 236 if (UNLIKELY(state->hadException())) 237 237 return false; … … 257 257 if (UNLIKELY(state->argumentCount() < 1)) 258 258 return throwVMError(state, createNotEnoughArgumentsError(state)); 259 String testParam = state->argument(0).to String(state)->value(state);259 String testParam = state->argument(0).toWTFString(state); 260 260 if (UNLIKELY(state->hadException())) 261 261 return JSValue::encode(jsUndefined()); … … 275 275 if (UNLIKELY(state->argumentCount() < 1)) 276 276 return throwVMError(state, createNotEnoughArgumentsError(state)); 277 String testParam = state->argument(0).to String(state)->value(state);277 String testParam = state->argument(0).toWTFString(state); 278 278 if (UNLIKELY(state->hadException())) 279 279 return JSValue::encode(jsUndefined()); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
r200286 r200288 229 229 return throwVMError(state, createNotEnoughArgumentsError(state)); 230 230 ExceptionCode ec = 0; 231 String str1 = state->argument(0).to String(state)->value(state);231 String str1 = state->argument(0).toWTFString(state); 232 232 if (UNLIKELY(state->hadException())) 233 233 return JSValue::encode(jsUndefined()); 234 String str2 = state->argument(1).isUndefined() ? ASCIILiteral("defaultString") : state->uncheckedArgument(1).to String(state)->value(state);234 String str2 = state->argument(1).isUndefined() ? ASCIILiteral("defaultString") : state->uncheckedArgument(1).toWTFString(state); 235 235 if (UNLIKELY(state->hadException())) 236 236 return JSValue::encode(jsUndefined()); … … 633 633 { 634 634 JSValue value = JSValue::decode(encodedValue); 635 String nativeValue = value.to String(state)->value(state);635 String nativeValue = value.toWTFString(state); 636 636 if (UNLIKELY(state->hadException())) 637 637 return false; … … 652 652 } 653 653 auto& impl = castedThis->wrapped(); 654 String nativeValue = value.to String(state)->value(state);654 String nativeValue = value.toWTFString(state); 655 655 if (UNLIKELY(state->hadException())) 656 656 return false; … … 699 699 { 700 700 JSValue value = JSValue::decode(encodedValue); 701 String nativeValue = value.to String(state)->value(state);701 String nativeValue = value.toWTFString(state); 702 702 if (UNLIKELY(state->hadException())) 703 703 return false; … … 718 718 } 719 719 auto& impl = castedThis->wrapped(); 720 String nativeValue = value.to String(state)->value(state);720 String nativeValue = value.toWTFString(state); 721 721 if (UNLIKELY(state->hadException())) 722 722 return false; … … 796 796 if (!context) 797 797 return JSValue::encode(jsUndefined()); 798 String strArg = state->argument(0).to String(state)->value(state);798 String strArg = state->argument(0).toWTFString(state); 799 799 if (UNLIKELY(state->hadException())) 800 800 return JSValue::encode(jsUndefined()); … … 864 864 if (!context) 865 865 return JSValue::encode(jsUndefined()); 866 String strArg = state->argument(0).to String(state)->value(state);866 String strArg = state->argument(0).toWTFString(state); 867 867 if (UNLIKELY(state->hadException())) 868 868 return JSValue::encode(jsUndefined()); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp
r200286 r200288 87 87 return throwVMError(state, createNotEnoughArgumentsError(state)); 88 88 ExceptionCode ec = 0; 89 String str1 = state->argument(0).to String(state)->value(state);89 String str1 = state->argument(0).toWTFString(state); 90 90 if (UNLIKELY(state->hadException())) 91 91 return JSValue::encode(jsUndefined()); 92 String str2 = state->argument(1).isUndefined() ? ASCIILiteral("defaultString") : state->uncheckedArgument(1).to String(state)->value(state);92 String str2 = state->argument(1).isUndefined() ? ASCIILiteral("defaultString") : state->uncheckedArgument(1).toWTFString(state); 93 93 if (UNLIKELY(state->hadException())) 94 94 return JSValue::encode(jsUndefined()); 95 String str3 = state->argument(2).isUndefined() ? String() : state->uncheckedArgument(2).to String(state)->value(state);95 String str3 = state->argument(2).isUndefined() ? String() : state->uncheckedArgument(2).toWTFString(state); 96 96 if (UNLIKELY(state->hadException())) 97 97 return JSValue::encode(jsUndefined()); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp
r200286 r200288 166 166 } 167 167 auto& impl = castedThis->wrapped(); 168 String nativeValue = value.to String(state)->value(state);168 String nativeValue = value.toWTFString(state); 169 169 if (UNLIKELY(state->hadException())) 170 170 return false; -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNondeterministic.cpp
r200286 r200288 353 353 } 354 354 auto& impl = castedThis->wrapped(); 355 String nativeValue = value.to String(state)->value(state);355 String nativeValue = value.toWTFString(state); 356 356 if (UNLIKELY(state->hadException())) 357 357 return false; … … 370 370 } 371 371 auto& impl = castedThis->wrapped(); 372 String nativeValue = value.to String(state)->value(state);372 String nativeValue = value.toWTFString(state); 373 373 if (UNLIKELY(state->hadException())) 374 374 return false; … … 387 387 } 388 388 auto& impl = castedThis->wrapped(); 389 String nativeValue = value.to String(state)->value(state);389 String nativeValue = value.toWTFString(state); 390 390 if (UNLIKELY(state->hadException())) 391 391 return false; … … 405 405 auto& impl = castedThis->wrapped(); 406 406 ExceptionCode ec = 0; 407 String nativeValue = value.to String(state)->value(state);407 String nativeValue = value.toWTFString(state); 408 408 if (UNLIKELY(state->hadException())) 409 409 return false; -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r200286 r200288 89 89 90 90 namespace WebCore { 91 92 const String& stringValue(TestEnumType); 93 Optional<TestEnumType> enumerationValueTestEnumType(const String&); 94 95 const String& stringValue(TestEnumType enumerationValue) 96 { 97 static NeverDestroyed<const String> values[] = { 98 ASCIILiteral(""), 99 ASCIILiteral("EnumValue1"), 100 ASCIILiteral("EnumValue2"), 101 ASCIILiteral("EnumValue3"), 102 }; 103 static_assert(!static_cast<size_t>(TestEnumType::EmptyString), "TestEnumType::EmptyString is not 0 as expected"); 104 static_assert(static_cast<size_t>(TestEnumType::EnumValue1) == 1, "TestEnumType::EnumValue1 is not 1 as expected"); 105 static_assert(static_cast<size_t>(TestEnumType::EnumValue2) == 2, "TestEnumType::EnumValue2 is not 2 as expected"); 106 static_assert(static_cast<size_t>(TestEnumType::EnumValue3) == 3, "TestEnumType::EnumValue3 is not 3 as expected"); 107 ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); 108 return values[static_cast<size_t>(enumerationValue)]; 109 } 110 111 Optional<TestEnumType> enumerationValueTestEnumType(const String& stringValue) 112 { 113 if (stringValue == "") 114 return TestEnumType::EmptyString; 115 if (stringValue == "EnumValue1") 116 return TestEnumType::EnumValue1; 117 if (stringValue == "EnumValue2") 118 return TestEnumType::EnumValue2; 119 if (stringValue == "EnumValue3") 120 return TestEnumType::EnumValue3; 121 return Nullopt; 122 } 123 124 const String& stringValue(Optional); 125 Optional<Optional> enumerationValueOptional(const String&); 126 127 const String& stringValue(Optional enumerationValue) 128 { 129 static NeverDestroyed<const String> values[] = { 130 ASCIILiteral(""), 131 ASCIILiteral("OptionalValue1"), 132 ASCIILiteral("OptionalValue2"), 133 ASCIILiteral("OptionalValue3"), 134 }; 135 static_assert(!static_cast<size_t>(Optional::EmptyString), "Optional::EmptyString is not 0 as expected"); 136 static_assert(static_cast<size_t>(Optional::OptionalValue1) == 1, "Optional::OptionalValue1 is not 1 as expected"); 137 static_assert(static_cast<size_t>(Optional::OptionalValue2) == 2, "Optional::OptionalValue2 is not 2 as expected"); 138 static_assert(static_cast<size_t>(Optional::OptionalValue3) == 3, "Optional::OptionalValue3 is not 3 as expected"); 139 ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); 140 return values[static_cast<size_t>(enumerationValue)]; 141 } 142 143 Optional<Optional> enumerationValueOptional(const String& stringValue) 144 { 145 if (stringValue == "") 146 return Optional::EmptyString; 147 if (stringValue == "OptionalValue1") 148 return Optional::OptionalValue1; 149 if (stringValue == "OptionalValue2") 150 return Optional::OptionalValue2; 151 if (stringValue == "OptionalValue3") 152 return Optional::OptionalValue3; 153 return Nullopt; 154 } 91 155 92 156 // Functions … … 991 1055 } 992 1056 auto& impl = castedThis->wrapped(); 993 JSValue result = jsStringWithCache(state, impl.enumAttr());1057 JSValue result = jsStringWithCache(state, stringValue(impl.enumAttr())); 994 1058 return JSValue::encode(result); 995 1059 } … … 2148 2212 } 2149 2213 auto& impl = castedThis->wrapped(); 2150 JSValue result = jsStringWithCache(state, impl.attributeWithReservedEnumType());2214 JSValue result = jsStringWithCache(state, stringValue(impl.attributeWithReservedEnumType())); 2151 2215 return JSValue::encode(result); 2152 2216 } … … 2206 2270 { 2207 2271 JSValue value = JSValue::decode(encodedValue); 2208 String nativeValue = value.to String(state)->value(state);2272 String nativeValue = value.toWTFString(state); 2209 2273 if (UNLIKELY(state->hadException())) 2210 2274 return false; … … 2236 2300 } 2237 2301 auto& impl = castedThis->wrapped(); 2238 String nativeValue = value.toString(state)->value(state);2302 TestEnumType nativeValue = enumerationValueTestEnumType(value.toWTFString(state)).value(); 2239 2303 if (UNLIKELY(state->hadException())) 2240 2304 return false; … … 2408 2472 } 2409 2473 auto& impl = castedThis->wrapped(); 2410 String nativeValue = value.to String(state)->value(state);2474 String nativeValue = value.toWTFString(state); 2411 2475 if (UNLIKELY(state->hadException())) 2412 2476 return false; … … 2510 2574 } 2511 2575 auto& impl = castedThis->wrapped(); 2512 String nativeValue = value.to String(state)->value(state);2576 String nativeValue = value.toWTFString(state); 2513 2577 if (UNLIKELY(state->hadException())) 2514 2578 return false; … … 2578 2642 } 2579 2643 auto& impl = castedThis->wrapped(); 2580 String nativeValue = value.to String(state)->value(state);2644 String nativeValue = value.toWTFString(state); 2581 2645 if (UNLIKELY(state->hadException())) 2582 2646 return false; … … 2595 2659 } 2596 2660 auto& impl = castedThis->wrapped(); 2597 String nativeValue = value.to String(state)->value(state);2661 String nativeValue = value.toWTFString(state); 2598 2662 if (UNLIKELY(state->hadException())) 2599 2663 return false; … … 2646 2710 } 2647 2711 auto& impl = castedThis->wrapped(); 2648 String nativeValue = value.to String(state)->value(state);2712 String nativeValue = value.toWTFString(state); 2649 2713 if (UNLIKELY(state->hadException())) 2650 2714 return false; … … 2664 2728 } 2665 2729 auto& impl = castedThis->wrapped(); 2666 String nativeValue = value.to String(state)->value(state);2730 String nativeValue = value.toWTFString(state); 2667 2731 if (UNLIKELY(state->hadException())) 2668 2732 return false; … … 2771 2835 } 2772 2836 auto& impl = castedThis->wrapped(); 2773 String nativeValue = value.to String(state)->value(state);2837 String nativeValue = value.toWTFString(state); 2774 2838 if (UNLIKELY(state->hadException())) 2775 2839 return false; … … 2789 2853 auto& impl = castedThis->wrapped(); 2790 2854 ExceptionCode ec = 0; 2791 String nativeValue = value.to String(state)->value(state);2855 String nativeValue = value.toWTFString(state); 2792 2856 if (UNLIKELY(state->hadException())) 2793 2857 return false; … … 3303 3367 } 3304 3368 auto& impl = castedThis->wrapped(); 3305 String nativeValue = value.toString(state)->value(state);3369 Optional nativeValue = enumerationValueOptional(value.toWTFString(state)).value(); 3306 3370 if (UNLIKELY(state->hadException())) 3307 3371 return false; … … 3323 3387 Ref<TestNode> forwardedImpl = castedThis->wrapped().putForwardsAttribute(); 3324 3388 auto& impl = forwardedImpl.get(); 3325 String nativeValue = value.to String(state)->value(state);3389 String nativeValue = value.toWTFString(state); 3326 3390 if (UNLIKELY(state->hadException())) 3327 3391 return false; … … 3343 3407 return false; 3344 3408 auto& impl = *forwardedImpl; 3345 String nativeValue = value.to String(state)->value(state);3409 String nativeValue = value.toWTFString(state); 3346 3410 if (UNLIKELY(state->hadException())) 3347 3411 return false; … … 3376 3440 if (UNLIKELY(state->argumentCount() < 1)) 3377 3441 return throwVMError(state, createNotEnoughArgumentsError(state)); 3378 String testParam = state->argument(0).to String(state)->value(state);3442 String testParam = state->argument(0).toWTFString(state); 3379 3443 if (UNLIKELY(state->hadException())) 3380 3444 return JSValue::encode(jsUndefined()); … … 3448 3512 if (UNLIKELY(state->hadException())) 3449 3513 return JSValue::encode(jsUndefined()); 3450 String strArg = state->argument(1).to String(state)->value(state);3514 String strArg = state->argument(1).toWTFString(state); 3451 3515 if (UNLIKELY(state->hadException())) 3452 3516 return JSValue::encode(jsUndefined()); … … 3485 3549 if (UNLIKELY(state->hadException())) 3486 3550 return JSValue::encode(jsUndefined()); 3487 String strArg = state->argument(1).to String(state)->value(state);3551 String strArg = state->argument(1).toWTFString(state); 3488 3552 if (UNLIKELY(state->hadException())) 3489 3553 return JSValue::encode(jsUndefined()); … … 3522 3586 if (UNLIKELY(state->hadException())) 3523 3587 return JSValue::encode(jsUndefined()); 3524 String strArg = state->argument(1).to String(state)->value(state);3588 String strArg = state->argument(1).toWTFString(state); 3525 3589 if (UNLIKELY(state->hadException())) 3526 3590 return JSValue::encode(jsUndefined()); … … 3559 3623 if (UNLIKELY(state->hadException())) 3560 3624 return JSValue::encode(jsUndefined()); 3561 String strArg = state->argument(1).to String(state)->value(state);3625 String strArg = state->argument(1).toWTFString(state); 3562 3626 if (UNLIKELY(state->hadException())) 3563 3627 return JSValue::encode(jsUndefined()); … … 3596 3660 if (UNLIKELY(state->hadException())) 3597 3661 return JSValue::encode(jsUndefined()); 3598 String strArg = state->argument(1).to String(state)->value(state);3662 String strArg = state->argument(1).toWTFString(state); 3599 3663 if (UNLIKELY(state->hadException())) 3600 3664 return JSValue::encode(jsUndefined()); … … 3739 3803 enumArg = ASCIILiteral("EnumValue1"); 3740 3804 else { 3741 enumArg = state->uncheckedArgument(0).to String(state)->value(state);3805 enumArg = state->uncheckedArgument(0).toWTFString(state); 3742 3806 if (UNLIKELY(state->hadException())) 3743 3807 return JSValue::encode(jsUndefined()); … … 3760 3824 return throwVMError(state, createNotEnoughArgumentsError(state)); 3761 3825 ExceptionCode ec = 0; 3762 String strArg = state->argument(0).to String(state)->value(state);3826 String strArg = state->argument(0).toWTFString(state); 3763 3827 if (UNLIKELY(state->hadException())) 3764 3828 return JSValue::encode(jsUndefined()); … … 3869 3933 if (UNLIKELY(state->argumentCount() < 1)) 3870 3934 return throwVMError(state, createNotEnoughArgumentsError(state)); 3871 String argument = state->argument(0).to String(state)->value(state);3935 String argument = state->argument(0).toWTFString(state); 3872 3936 if (UNLIKELY(state->hadException())) 3873 3937 return JSValue::encode(jsUndefined()); … … 4141 4205 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info()); 4142 4206 auto& impl = castedThis->wrapped(); 4143 String str = state->argument(0).isUndefined() ? String() : state->uncheckedArgument(0).to String(state)->value(state);4207 String str = state->argument(0).isUndefined() ? String() : state->uncheckedArgument(0).toWTFString(state); 4144 4208 if (UNLIKELY(state->hadException())) 4145 4209 return JSValue::encode(jsUndefined()); … … 4171 4235 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info()); 4172 4236 auto& impl = castedThis->wrapped(); 4173 String str = state->argument(0).isUndefined() ? ASCIILiteral("foo") : state->uncheckedArgument(0).to String(state)->value(state);4237 String str = state->argument(0).isUndefined() ? ASCIILiteral("foo") : state->uncheckedArgument(0).toWTFString(state); 4174 4238 if (UNLIKELY(state->hadException())) 4175 4239 return JSValue::encode(jsUndefined()); … … 4201 4265 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info()); 4202 4266 auto& impl = castedThis->wrapped(); 4203 String str = state->argument(0).isUndefined() ? String() : state->uncheckedArgument(0).to String(state)->value(state);4267 String str = state->argument(0).isUndefined() ? String() : state->uncheckedArgument(0).toWTFString(state); 4204 4268 if (UNLIKELY(state->hadException())) 4205 4269 return JSValue::encode(jsUndefined()); … … 4216 4280 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info()); 4217 4281 auto& impl = castedThis->wrapped(); 4218 String str = state->argument(0).to String(state)->value(state);4282 String str = state->argument(0).toWTFString(state); 4219 4283 if (UNLIKELY(state->hadException())) 4220 4284 return JSValue::encode(jsUndefined()); … … 4246 4310 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info()); 4247 4311 auto& impl = castedThis->wrapped(); 4248 String str = state->argument(0).isUndefined() ? emptyString() : state->uncheckedArgument(0).to String(state)->value(state);4312 String str = state->argument(0).isUndefined() ? emptyString() : state->uncheckedArgument(0).toWTFString(state); 4249 4313 if (UNLIKELY(state->hadException())) 4250 4314 return JSValue::encode(jsUndefined()); … … 4669 4733 if (UNLIKELY(state->hadException())) 4670 4734 return JSValue::encode(jsUndefined()); 4671 String strArg = state->argument(1).to String(state)->value(state);4735 String strArg = state->argument(1).toWTFString(state); 4672 4736 if (UNLIKELY(state->hadException())) 4673 4737 return JSValue::encode(jsUndefined()); … … 4706 4770 if (UNLIKELY(state->argumentCount() < 1)) 4707 4771 return throwVMError(state, createNotEnoughArgumentsError(state)); 4708 String strArg = state->argument(0).to String(state)->value(state);4772 String strArg = state->argument(0).toWTFString(state); 4709 4773 if (UNLIKELY(state->hadException())) 4710 4774 return JSValue::encode(jsUndefined()); … … 4844 4908 if (UNLIKELY(state->argumentCount() < 1)) 4845 4909 return throwVMError(state, createNotEnoughArgumentsError(state)); 4846 String strArg = state->argument(0).to String(state)->value(state);4910 String strArg = state->argument(0).toWTFString(state); 4847 4911 if (UNLIKELY(state->hadException())) 4848 4912 return JSValue::encode(jsUndefined()); … … 4998 5062 if (UNLIKELY(state->argumentCount() < 1)) 4999 5063 return throwVMError(state, createNotEnoughArgumentsError(state)); 5000 String type = state->argument(0).to String(state)->value(state);5064 String type = state->argument(0).toWTFString(state); 5001 5065 if (UNLIKELY(state->hadException())) 5002 5066 return JSValue::encode(jsUndefined()); … … 5226 5290 if (UNLIKELY(state->argumentCount() < 1)) 5227 5291 return throwVMError(state, createNotEnoughArgumentsError(state)); 5228 String value = state->argument(0).to String(state)->value(state);5292 String value = state->argument(0).toWTFString(state); 5229 5293 if (UNLIKELY(state->hadException())) 5230 5294 return JSValue::encode(jsUndefined()); … … 5297 5361 return throwVMError(state, createNotEnoughArgumentsError(state)); 5298 5362 ExceptionCode ec = 0; 5299 String str = state->argument(0).to String(state)->value(state);5363 String str = state->argument(0).toWTFString(state); 5300 5364 if (UNLIKELY(state->hadException())) 5301 5365 return JSValue::encode(jsUndefined()); … … 5376 5440 if (UNLIKELY(state->argumentCount() < 1)) 5377 5441 return throwVMError(state, createNotEnoughArgumentsError(state)); 5378 String head = state->argument(0).to String(state)->value(state);5442 String head = state->argument(0).toWTFString(state); 5379 5443 if (UNLIKELY(state->hadException())) 5380 5444 return JSValue::encode(jsUndefined()); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp
r200286 r200288 111 111 if (UNLIKELY(state->argumentCount() < 1)) 112 112 return throwVMError(state, createNotEnoughArgumentsError(state)); 113 String string = state->argument(0).to String(state)->value(state);113 String string = state->argument(0).toWTFString(state); 114 114 if (UNLIKELY(state->hadException())) 115 115 return JSValue::encode(jsUndefined()); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp
r200286 r200288 201 201 ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestOverrideBuiltins::info()); 202 202 auto& impl = castedThis->wrapped(); 203 String name = state->argument(0).isUndefined() ? ASCIILiteral("test") : state->uncheckedArgument(0).to String(state)->value(state);203 String name = state->argument(0).isUndefined() ? ASCIILiteral("test") : state->uncheckedArgument(0).toWTFString(state); 204 204 if (UNLIKELY(state->hadException())) 205 205 return JSValue::encode(jsUndefined()); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
r200286 r200288 129 129 if (UNLIKELY(state->argumentCount() < 2)) 130 130 return throwVMError(state, createNotEnoughArgumentsError(state)); 131 String hello = state->argument(0).to String(state)->value(state);131 String hello = state->argument(0).toWTFString(state); 132 132 if (UNLIKELY(state->hadException())) 133 133 return JSValue::encode(jsUndefined()); … … 424 424 } 425 425 auto& impl = castedThis->wrapped(); 426 String nativeValue = value.to String(state)->value(state);426 String nativeValue = value.toWTFString(state); 427 427 if (UNLIKELY(state->hadException())) 428 428 return false; … … 442 442 auto& impl = castedThis->wrapped(); 443 443 ExceptionCode ec = 0; 444 String nativeValue = value.to String(state)->value(state);444 String nativeValue = value.toWTFString(state); 445 445 if (UNLIKELY(state->hadException())) 446 446 return false; … … 490 490 if (UNLIKELY(state->hadException())) 491 491 return JSValue::encode(jsUndefined()); 492 String color = state->argument(3).isUndefined() ? String() : state->uncheckedArgument(3).to String(state)->value(state);492 String color = state->argument(3).isUndefined() ? String() : state->uncheckedArgument(3).toWTFString(state); 493 493 if (UNLIKELY(state->hadException())) 494 494 return JSValue::encode(jsUndefined()); -
trunk/Source/WebCore/css/FontFace.cpp
r199642 r200288 318 318 } 319 319 320 StringFontFace::status() const320 FontFaceLoadStatus FontFace::status() const 321 321 { 322 322 switch (m_backing->status()) { 323 323 case CSSFontFace::Status::Pending: 324 return String("unloaded", String::ConstructFromLiteral);324 return FontFaceLoadStatus::Unloaded; 325 325 case CSSFontFace::Status::Loading: 326 return String("loading", String::ConstructFromLiteral);326 return FontFaceLoadStatus::Loading; 327 327 case CSSFontFace::Status::TimedOut: 328 return String("error", String::ConstructFromLiteral);328 return FontFaceLoadStatus::Error; 329 329 case CSSFontFace::Status::Success: 330 return String("loaded", String::ConstructFromLiteral);330 return FontFaceLoadStatus::Loaded; 331 331 case CSSFontFace::Status::Failure: 332 return String("error", String::ConstructFromLiteral);332 return FontFaceLoadStatus::Error; 333 333 } 334 334 ASSERT_NOT_REACHED(); 335 return String("error", String::ConstructFromLiteral);335 return FontFaceLoadStatus::Error; 336 336 } 337 337 -
trunk/Source/WebCore/css/FontFace.h
r199642 r200288 37 37 #include <wtf/text/WTFString.h> 38 38 39 namespace Deprecated {40 class ScriptValue;41 }42 43 39 namespace WebCore { 44 40 … … 46 42 class CSSValue; 47 43 class Dictionary; 44 45 enum class FontFaceLoadStatus { Unloaded, Loading, Loaded, Error }; 48 46 49 47 class FontFace final : public RefCounted<FontFace>, public CSSFontFace::Client { … … 68 66 String variant() const; 69 67 String featureSettings() const; 70 Stringstatus() const;68 FontFaceLoadStatus status() const; 71 69 72 70 typedef DOMPromise<FontFace&, DOMCoreException&> Promise;
Note:
See TracChangeset
for help on using the changeset viewer.