Changeset 293301 in webkit
- Timestamp:
- Apr 23, 2022, 9:48:31 PM (4 years ago)
- Location:
- trunk/Source
- Files:
-
- 12 edited
-
WTF/wtf/text/AtomString.cpp (modified) (2 diffs)
-
WTF/wtf/text/AtomString.h (modified) (1 diff)
-
WTF/wtf/text/WTFString.cpp (modified) (1 diff)
-
WTF/wtf/text/WTFString.h (modified) (1 diff)
-
WebCore/Modules/fetch/FetchResponse.h (modified) (1 diff)
-
WebCore/Modules/fetch/FetchResponse.idl (modified) (1 diff)
-
WebCore/bindings/js/JSDOMConvertStrings.cpp (modified) (4 diffs)
-
WebCore/bindings/js/JSDOMConvertStrings.h (modified) (3 diffs)
-
WebCore/html/HTMLAnchorElement.idl (modified) (1 diff)
-
WebCore/html/HTMLAreaElement.idl (modified) (1 diff)
-
WebCore/platform/network/ResourceResponseBase.cpp (modified) (4 diffs)
-
WebCore/platform/network/ResourceResponseBase.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/wtf/text/AtomString.cpp
r293285 r293301 28 28 29 29 #include <wtf/dtoa.h> 30 #include <wtf/text/StringBuilder.h> 31 #include <wtf/unicode/CharacterNames.h> 30 32 31 33 namespace WTF { … … 161 163 } 162 164 165 static inline StringBuilder replaceUnpairedSurrogatesWithReplacementCharacterInternal(StringView view) 166 { 167 // Slow path: https://infra.spec.whatwg.org/#javascript-string-convert 168 // Replaces unpaired surrogates with the replacement character. 169 StringBuilder result; 170 result.reserveCapacity(view.length()); 171 for (auto codePoint : view.codePoints()) { 172 if (U_IS_SURROGATE(codePoint)) 173 result.append(replacementCharacter); 174 else 175 result.appendCharacter(codePoint); 176 } 177 return result; 178 } 179 180 AtomString replaceUnpairedSurrogatesWithReplacementCharacter(AtomString&& string) 181 { 182 // Fast path for the case where there are no unpaired surrogates. 183 if (LIKELY(!hasUnpairedSurrogate(string))) 184 return WTFMove(string); 185 return replaceUnpairedSurrogatesWithReplacementCharacterInternal(string).toAtomString(); 186 } 187 188 String replaceUnpairedSurrogatesWithReplacementCharacter(String&& string) 189 { 190 // Fast path for the case where there are no unpaired surrogates. 191 if (LIKELY(!hasUnpairedSurrogate(string))) 192 return WTFMove(string); 193 return replaceUnpairedSurrogatesWithReplacementCharacterInternal(string).toString(); 194 } 195 163 196 } // namespace WTF -
trunk/Source/WTF/wtf/text/AtomString.h
r293292 r293301 209 209 template<unsigned length> bool equalLettersIgnoringASCIICase(const AtomString&, const char (&lowercaseLetters)[length]); 210 210 211 WTF_EXPORT_PRIVATE AtomString replaceUnpairedSurrogatesWithReplacementCharacter(AtomString&&); 212 WTF_EXPORT_PRIVATE String replaceUnpairedSurrogatesWithReplacementCharacter(String&&); 213 211 214 inline AtomString::AtomString() 212 215 { -
trunk/Source/WTF/wtf/text/WTFString.cpp
r292945 r293301 666 666 } 667 667 668 String replaceUnpairedSurrogatesWithReplacementCharacter(String&& string)669 {670 // Fast path for the case where there are no unpaired surrogates.671 if (!hasUnpairedSurrogate(string))672 return WTFMove(string);673 674 // Slow path: https://infra.spec.whatwg.org/#javascript-string-convert675 // Replaces unpaired surrogates with the replacement character.676 StringBuilder result;677 result.reserveCapacity(string.length());678 StringView view { string };679 for (auto codePoint : view.codePoints()) {680 if (U_IS_SURROGATE(codePoint))681 result.append(replacementCharacter);682 else683 result.appendCharacter(codePoint);684 }685 return result.toString();686 }687 688 668 } // namespace WTF 689 669 -
trunk/Source/WTF/wtf/text/WTFString.h
r293056 r293301 414 414 #endif 415 415 416 WTF_EXPORT_PRIVATE String replaceUnpairedSurrogatesWithReplacementCharacter(String&&);417 418 416 // Definitions of string operations 419 417 -
trunk/Source/WebCore/Modules/fetch/FetchResponse.h
r289533 r293301 54 54 struct Init { 55 55 unsigned short status { 200 }; 56 String statusText;56 AtomString statusText; 57 57 std::optional<FetchHeaders::Init> headers; 58 58 }; -
trunk/Source/WebCore/Modules/fetch/FetchResponse.idl
r289117 r293301 34 34 dictionary FetchResponseInit { 35 35 unsigned short status = 200; 36 ByteString statusText = "";36 [AtomString] ByteString statusText = ""; 37 37 HeadersInit headers; 38 38 }; -
trunk/Source/WebCore/bindings/js/JSDOMConvertStrings.cpp
r280181 r293301 44 44 } 45 45 46 static inline String stringToByteString(JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope, String&& string)46 static inline bool throwIfInvalidByteString(JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope, const String& string) 47 47 { 48 if ( !string.isAllLatin1()) {48 if (UNLIKELY(!string.isAllLatin1())) { 49 49 throwTypeError(&lexicalGlobalObject, scope); 50 return { };50 return true; 51 51 } 52 53 return WTFMove(string); 52 return false; 54 53 } 55 54 … … 61 60 auto string = identifierToString(lexicalGlobalObject, identifier); 62 61 RETURN_IF_EXCEPTION(scope, { }); 63 return stringToByteString(lexicalGlobalObject, scope, WTFMove(string)); 62 if (UNLIKELY(throwIfInvalidByteString(lexicalGlobalObject, scope, string))) 63 return { }; 64 return string; 64 65 } 65 66 … … 72 73 RETURN_IF_EXCEPTION(scope, { }); 73 74 74 return stringToByteString(lexicalGlobalObject, scope, WTFMove(string)); 75 if (UNLIKELY(throwIfInvalidByteString(lexicalGlobalObject, scope, string))) 76 return { }; 77 return string; 78 } 79 80 AtomString valueToByteAtomString(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue value) 81 { 82 VM& vm = lexicalGlobalObject.vm(); 83 auto scope = DECLARE_THROW_SCOPE(vm); 84 85 auto string = value.toString(&lexicalGlobalObject)->toAtomString(&lexicalGlobalObject); 86 RETURN_IF_EXCEPTION(scope, { }); 87 88 if (UNLIKELY(throwIfInvalidByteString(lexicalGlobalObject, scope, string.string()))) 89 return nullAtom(); 90 91 return string; 75 92 } 76 93 … … 91 108 } 92 109 110 AtomString valueToUSVAtomString(JSGlobalObject& lexicalGlobalObject, JSValue value) 111 { 112 VM& vm = lexicalGlobalObject.vm(); 113 auto scope = DECLARE_THROW_SCOPE(vm); 114 115 auto string = value.toString(&lexicalGlobalObject)->toAtomString(&lexicalGlobalObject); 116 RETURN_IF_EXCEPTION(scope, { }); 117 118 return replaceUnpairedSurrogatesWithReplacementCharacter(WTFMove(string)); 119 } 120 93 121 } // namespace WebCore -
trunk/Source/WebCore/bindings/js/JSDOMConvertStrings.h
r280181 r293301 35 35 WEBCORE_EXPORT String identifierToByteString(JSC::JSGlobalObject&, const JSC::Identifier&); 36 36 WEBCORE_EXPORT String valueToByteString(JSC::JSGlobalObject&, JSC::JSValue); 37 WEBCORE_EXPORT AtomString valueToByteAtomString(JSC::JSGlobalObject&, JSC::JSValue); 37 38 WEBCORE_EXPORT String identifierToUSVString(JSC::JSGlobalObject&, const JSC::Identifier&); 38 39 WEBCORE_EXPORT String valueToUSVString(JSC::JSGlobalObject&, JSC::JSValue); 40 WEBCORE_EXPORT AtomString valueToUSVAtomString(JSC::JSGlobalObject&, JSC::JSValue); 39 41 40 42 inline String propertyNameToString(JSC::PropertyName propertyName) … … 178 180 }; 179 181 182 template<> struct Converter<IDLAtomStringAdaptor<IDLUSVString>> : DefaultConverter<IDLAtomStringAdaptor<IDLUSVString>> { 183 static AtomString convert(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue value) 184 { 185 return valueToUSVAtomString(lexicalGlobalObject, value); 186 } 187 }; 188 189 template<> struct Converter<IDLAtomStringAdaptor<IDLByteString>> : DefaultConverter<IDLAtomStringAdaptor<IDLByteString>> { 190 static String convert(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue value) 191 { 192 return valueToByteAtomString(lexicalGlobalObject, value); 193 } 194 }; 195 180 196 template<typename T> struct JSConverter<IDLAtomStringAdaptor<T>> { 181 197 static constexpr bool needsState = true; … … 187 203 188 204 return JSConverter<T>::convert(lexicalGlobalObject, value); 205 } 206 }; 207 208 template<> struct JSConverter<IDLAtomStringAdaptor<IDLUSVString>> { 209 static constexpr bool needsState = true; 210 static constexpr bool needsGlobalObject = false; 211 212 static JSC::JSValue convert(JSC::JSGlobalObject& lexicalGlobalObject, const AtomString& value) 213 { 214 return JSConverter<IDLUSVString>::convert(lexicalGlobalObject, value.string()); 215 } 216 }; 217 218 template<> struct JSConverter<IDLAtomStringAdaptor<IDLByteString>> { 219 static constexpr bool needsState = true; 220 static constexpr bool needsGlobalObject = false; 221 222 static JSC::JSValue convert(JSC::JSGlobalObject& lexicalGlobalObject, const AtomString& value) 223 { 224 return JSConverter<IDLByteString>::convert(lexicalGlobalObject, value.string()); 189 225 } 190 226 }; -
trunk/Source/WebCore/html/HTMLAnchorElement.idl
r293292 r293301 30 30 [CEReactions=NotNeeded, Reflect] attribute [AtomString] DOMString hreflang; 31 31 [CEReactions=NotNeeded, Reflect] attribute [AtomString] DOMString name; 32 [CEReactions=NotNeeded, Reflect] attribute USVString ping;32 [CEReactions=NotNeeded, Reflect] attribute [AtomString] USVString ping; 33 33 [CEReactions=NotNeeded, Reflect] attribute [AtomString] DOMString rel; 34 34 [CEReactions=NotNeeded, Reflect] attribute [AtomString] DOMString rev; -
trunk/Source/WebCore/html/HTMLAreaElement.idl
r293292 r293301 25 25 [CEReactions=NotNeeded, Reflect] attribute [AtomString] DOMString coords; 26 26 [CEReactions=NotNeeded, Reflect] attribute boolean noHref; 27 [CEReactions=NotNeeded, Reflect] attribute USVString ping;27 [CEReactions=NotNeeded, Reflect] attribute [AtomString] USVString ping; 28 28 [CEReactions=NotNeeded, Reflect] attribute DOMString rel; 29 29 [CEReactions=NotNeeded, Reflect] attribute DOMString shape; -
trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp
r293056 r293301 98 98 99 99 data.httpStatusCode = httpStatusCode(); 100 data.httpStatusText = httpStatusText(). isolatedCopy();100 data.httpStatusText = httpStatusText().string().isolatedCopy(); 101 101 data.httpVersion = httpVersion().isolatedCopy(); 102 102 … … 122 122 123 123 response.setHTTPStatusCode(data.httpStatusCode); 124 response.setHTTPStatusText( data.httpStatusText);124 response.setHTTPStatusText(AtomString { data.httpStatusText }); 125 125 response.setHTTPVersion(data.httpVersion); 126 126 … … 343 343 } 344 344 345 const String& ResourceResponseBase::httpStatusText() const345 const AtomString& ResourceResponseBase::httpStatusText() const 346 346 { 347 347 lazyInit(AllFields); … … 350 350 } 351 351 352 void ResourceResponseBase::setHTTPStatusText(const String& statusText)352 void ResourceResponseBase::setHTTPStatusText(const AtomString& statusText) 353 353 { 354 354 lazyInit(AllFields); -
trunk/Source/WebCore/platform/network/ResourceResponseBase.h
r293292 r293301 107 107 WEBCORE_EXPORT bool isRedirection() const; 108 108 109 WEBCORE_EXPORT const String& httpStatusText() const;110 WEBCORE_EXPORT void setHTTPStatusText(const String&);109 WEBCORE_EXPORT const AtomString& httpStatusText() const; 110 WEBCORE_EXPORT void setHTTPStatusText(const AtomString&); 111 111 112 112 WEBCORE_EXPORT const String& httpVersion() const;
Note:
See TracChangeset
for help on using the changeset viewer.