Changeset 293703 in webkit
- Timestamp:
- May 2, 2022, 5:37:42 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 22 edited
-
Source/JavaScriptCore/API/JSValue.mm (modified) (1 diff)
-
Source/JavaScriptCore/runtime/CachedTypes.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/Identifier.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/Identifier.h (modified) (3 diffs)
-
Source/JavaScriptCore/runtime/ObjectPrototype.cpp (modified) (5 diffs)
-
Source/JavaScriptCore/runtime/SmallStrings.cpp (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/SmallStrings.h (modified) (1 diff)
-
Source/WTF/wtf/text/AtomString.h (modified) (4 diffs)
-
Source/WTF/wtf/text/AtomStringImpl.cpp (modified) (2 diffs)
-
Source/WTF/wtf/text/AtomStringImpl.h (modified) (3 diffs)
-
Source/WTF/wtf/text/StringImpl.cpp (modified) (1 diff)
-
Source/WTF/wtf/text/StringImpl.h (modified) (3 diffs)
-
Source/WTF/wtf/text/WTFString.cpp (modified) (2 diffs)
-
Source/WTF/wtf/text/WTFString.h (modified) (2 diffs)
-
Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp (modified) (4 diffs)
-
Source/WebCore/platform/win/PasteboardWin.cpp (modified) (3 diffs)
-
Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp (modified) (1 diff)
-
Source/WebKitLegacy/win/DOMCoreClasses.cpp (modified) (4 diffs)
-
Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp (modified) (7 diffs)
-
Tools/TestWebKitAPI/Tests/WTF/StringOperators.cpp (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WTF/StringView.cpp (modified) (4 diffs)
-
Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSValue.mm
r292929 r293703 1160 1160 { 1161 1161 auto type = adoptSystem<char[]>(method_copyArgumentType(method, 2)); 1162 structHandlers->add(StringImpl::create (type.get()), (StructTagHandler) { selector, 0 });1162 structHandlers->add(StringImpl::createFromCString(type.get()), (StructTagHandler) { selector, 0 }); 1163 1163 } 1164 1164 }); -
trunk/Source/JavaScriptCore/runtime/CachedTypes.cpp
r292929 r293703 756 756 if (m_isSymbol) 757 757 return &SymbolImpl::createNullSymbol().leakRef(); 758 return AtomStringImpl::add("").leakRef();758 return RefPtr { emptyAtom().impl() }.leakRef(); 759 759 } 760 760 -
trunk/Source/JavaScriptCore/runtime/Identifier.cpp
r292193 r293703 27 27 28 28 namespace JSC { 29 30 Ref<AtomStringImpl> Identifier::addLiteral(VM& vm, const char* literal, size_t length)31 {32 if (length == 1)33 return vm.smallStrings.singleCharacterStringRep(literal[0]);34 35 return AtomStringImpl::addLiteral(literal, length);36 }37 29 38 30 Ref<AtomStringImpl> Identifier::add8(VM& vm, const UChar* s, int length) -
trunk/Source/JavaScriptCore/runtime/Identifier.h
r293292 r293703 170 170 Identifier(VM& vm, const LChar* s, int length) : m_string(add(vm, s, length)) { ASSERT(m_string.impl()->isAtom()); } 171 171 Identifier(VM& vm, const UChar* s, int length) : m_string(add(vm, s, length)) { ASSERT(m_string.impl()->isAtom()); } 172 ALWAYS_INLINE Identifier(VM& vm, ASCIILiteral literal) : m_string(add Literal(vm, literal.characters(), literal.length())) { ASSERT(m_string.impl()->isAtom()); }172 ALWAYS_INLINE Identifier(VM& vm, ASCIILiteral literal) : m_string(add(vm, literal)) { ASSERT(m_string.impl()->isAtom()); } 173 173 Identifier(VM&, AtomStringImpl*); 174 174 Identifier(VM&, const AtomString&); … … 195 195 196 196 static Ref<AtomStringImpl> add(VM&, StringImpl*); 197 JS_EXPORT_PRIVATE static Ref<AtomStringImpl> addLiteral(VM&, const char*, size_t length);197 static Ref<AtomStringImpl> add(VM&, ASCIILiteral); 198 198 199 199 #ifndef NDEBUG … … 227 227 228 228 return *AtomStringImpl::add(s, length); 229 } 230 231 inline Ref<AtomStringImpl> Identifier::add(VM& vm, ASCIILiteral literal) 232 { 233 if (literal.length() == 1) 234 return vm.smallStrings.singleCharacterStringRep(literal.characterAt(0)); 235 return AtomStringImpl::add(literal); 229 236 } 230 237 -
trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp
r292929 r293703 322 322 #endif 323 323 324 inline const char*inferBuiltinTag(JSGlobalObject* globalObject, JSObject* object)324 inline ASCIILiteral inferBuiltinTag(JSGlobalObject* globalObject, JSObject* object) 325 325 { 326 326 VM& vm = globalObject->vm(); … … 332 332 auto scope = DECLARE_THROW_SCOPE(vm); 333 333 bool objectIsArray = isArray(globalObject, object); 334 RETURN_IF_EXCEPTION(scope, nullptr);334 RETURN_IF_EXCEPTION(scope, { }); 335 335 if (objectIsArray) 336 return "Array" ;336 return "Array"_s; 337 337 if (object->isCallable()) 338 return "Function" ;338 return "Function"_s; 339 339 JSType type = object->type(); 340 340 if (TypeInfo::isArgumentsType(type) … … 347 347 || type == RegExpObjectType) 348 348 return object->className(); 349 return "Object" ;349 return "Object"_s; 350 350 } 351 351 … … 367 367 return asString(result); 368 368 369 const char*tag = inferBuiltinTag(globalObject, thisObject);369 ASCIILiteral tag = inferBuiltinTag(globalObject, thisObject); 370 370 RETURN_IF_EXCEPTION(scope, nullptr); 371 371 JSString* jsTag = nullptr; … … 382 382 383 383 if (!jsTag) 384 jsTag = jsString(vm, AtomStringImpl::add(tag) .releaseNonNull());384 jsTag = jsString(vm, AtomStringImpl::add(tag)); 385 385 386 386 JSString* jsResult = jsString(globalObject, vm.smallStrings.objectStringStart(), jsTag, vm.smallStrings.singleCharacterString(']')); -
trunk/Source/JavaScriptCore/runtime/SmallStrings.cpp
r291946 r293703 53 53 } 54 54 55 #define JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE(name) initialize(&vm, m_##name, #name );55 #define JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE(name) initialize(&vm, m_##name, #name ## _s); 56 56 JSC_COMMON_STRINGS_EACH_NAME(JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE) 57 57 #undef JSC_COMMON_STRINGS_ATTRIBUTE_INITIALIZE 58 initialize(&vm, m_objectStringStart, "[object " );59 initialize(&vm, m_nullObjectString, "[object Null]" );60 initialize(&vm, m_undefinedObjectString, "[object Undefined]" );61 initialize(&vm, m_boundPrefixString, "bound " );62 initialize(&vm, m_notEqualString, "not-equal" );63 initialize(&vm, m_timedOutString, "timed-out" );64 initialize(&vm, m_okString, "ok" );65 initialize(&vm, m_sentinelString, "$" );58 initialize(&vm, m_objectStringStart, "[object "_s); 59 initialize(&vm, m_nullObjectString, "[object Null]"_s); 60 initialize(&vm, m_undefinedObjectString, "[object Undefined]"_s); 61 initialize(&vm, m_boundPrefixString, "bound "_s); 62 initialize(&vm, m_notEqualString, "not-equal"_s); 63 initialize(&vm, m_timedOutString, "timed-out"_s); 64 initialize(&vm, m_okString, "ok"_s); 65 initialize(&vm, m_sentinelString, "$"_s); 66 66 67 67 setIsInitialized(true); … … 103 103 } 104 104 105 void SmallStrings::initialize(VM* vm, JSString*& string, const char*value)105 void SmallStrings::initialize(VM* vm, JSString*& string, ASCIILiteral value) 106 106 { 107 string = JSString::create(*vm, AtomStringImpl::add(value) .releaseNonNull());107 string = JSString::create(*vm, AtomStringImpl::add(value)); 108 108 ASSERT(m_needsToBeVisited); 109 109 } -
trunk/Source/JavaScriptCore/runtime/SmallStrings.h
r283098 r293703 132 132 static constexpr unsigned singleCharacterStringCount = maxSingleCharacterString + 1; 133 133 134 void initialize(VM*, JSString*&, const char*value);134 void initialize(VM*, JSString*&, ASCIILiteral value); 135 135 136 136 JSString* m_emptyString { nullptr }; -
trunk/Source/WTF/wtf/text/AtomString.h
r293701 r293703 41 41 AtomString(const LChar*, unsigned length); 42 42 AtomString(const UChar*, unsigned length); 43 AtomString(const UChar*);44 43 45 44 ALWAYS_INLINE static AtomString fromLatin1(const char* characters) { return AtomString(characters); } … … 143 142 144 143 AtomString(const wchar_t* characters) 145 : AtomString( ucharFrom(characters)) { }144 : AtomString(characters, characters ? wcslen(characters) : 0) { } 146 145 #endif 147 146 … … 204 203 205 204 inline AtomString::AtomString(const char* string) 206 : m_string(AtomStringImpl::add (string))205 : m_string(AtomStringImpl::addCString(string)) 207 206 { 208 207 } … … 215 214 inline AtomString::AtomString(const UChar* string, unsigned length) 216 215 : m_string(AtomStringImpl::add(string, length)) 217 {218 }219 220 inline AtomString::AtomString(const UChar* string)221 : m_string(AtomStringImpl::add(string))222 216 { 223 217 } -
trunk/Source/WTF/wtf/text/AtomStringImpl.cpp
r293656 r293703 89 89 } 90 90 91 struct CStringTranslator {92 static unsigned hash(const LChar* characters)93 {94 return StringHasher::computeHashAndMaskTop8Bits(characters);95 }96 97 static inline bool equal(PackedPtr<StringImpl> str, const LChar* characters)98 {99 return WTF::equal(str.get(), characters);100 }101 102 static void translate(PackedPtr<StringImpl>& location, const LChar* const& characters, unsigned hash)103 {104 auto* pointer = &StringImpl::create(characters).leakRef();105 pointer->setHash(hash);106 pointer->setIsAtom(true);107 location = pointer;108 }109 };110 111 RefPtr<AtomStringImpl> AtomStringImpl::add(const LChar* characters)112 {113 if (!characters)114 return nullptr;115 if (!*characters)116 return static_cast<AtomStringImpl*>(StringImpl::empty());117 118 return addToStringTable<const LChar*, CStringTranslator>(characters);119 }120 121 91 using UCharBuffer = HashTranslatorCharBuffer<UChar>; 122 92 struct UCharBufferTranslator { … … 222 192 } 223 193 224 RefPtr<AtomStringImpl> AtomStringImpl::add(const UChar* characters)225 {226 if (!characters)227 return nullptr;228 229 unsigned length = 0;230 while (characters[length] != UChar(0))231 ++length;232 233 if (!length)234 return static_cast<AtomStringImpl*>(StringImpl::empty());235 236 UCharBuffer buffer { characters, length };237 return addToStringTable<UCharBuffer, UCharBufferTranslator>(buffer);238 }239 240 194 struct SubstringLocation { 241 195 StringImpl* baseString; -
trunk/Source/WTF/wtf/text/AtomStringImpl.h
r293656 r293703 40 40 static void remove(AtomStringImpl*); 41 41 42 WTF_EXPORT_PRIVATE static RefPtr<AtomStringImpl> add(const LChar*);43 ALWAYS_INLINE static RefPtr<AtomStringImpl> add(const char* s) { return add(reinterpret_cast<const LChar*>(s)); };44 42 WTF_EXPORT_PRIVATE static RefPtr<AtomStringImpl> add(const LChar*, unsigned length); 45 43 WTF_EXPORT_PRIVATE static RefPtr<AtomStringImpl> add(const UChar*, unsigned length); 46 ALWAYS_INLINE static RefPtr<AtomStringImpl> add(const char* s, unsigned length) { return add(reinterpret_cast<const LChar*>(s), length); }; 47 WTF_EXPORT_PRIVATE static RefPtr<AtomStringImpl> add(const UChar*); 44 ALWAYS_INLINE static RefPtr<AtomStringImpl> add(const char* s, unsigned length) { return add(reinterpret_cast<const LChar*>(s), length); } 48 45 WTF_EXPORT_PRIVATE static RefPtr<AtomStringImpl> add(StringImpl*, unsigned offset, unsigned length); 49 46 ALWAYS_INLINE static RefPtr<AtomStringImpl> add(StringImpl* string) … … 60 57 } 61 58 WTF_EXPORT_PRIVATE static RefPtr<AtomStringImpl> add(const StaticStringImpl*); 62 WTF_EXPORT_PRIVATE static Ref<AtomStringImpl> addLiteral(const char* characters, unsigned length); 59 ALWAYS_INLINE static Ref<AtomStringImpl> add(ASCIILiteral literal) { return addLiteral(literal.characters(), literal.length()); } 60 61 // Not using the add() naming to encourage developers to call add(ASCIILiteral) when they have a string literal. 62 ALWAYS_INLINE static RefPtr<AtomStringImpl> addCString(const char* s) { return s ? add(s, strlen(s)) : nullptr; } 63 63 64 64 // Returns null if the input data contains an invalid UTF-8 sequence. … … 102 102 } 103 103 104 WTF_EXPORT_PRIVATE static Ref<AtomStringImpl> addLiteral(const char* characters, unsigned length); 105 104 106 ALWAYS_INLINE static Ref<AtomStringImpl> add(AtomStringTable& stringTable, StringImpl& string) 105 107 { -
trunk/Source/WTF/wtf/text/StringImpl.cpp
r293639 r293703 320 320 } 321 321 322 Ref<StringImpl> StringImpl::create8BitIfPossible(const UChar* string)323 {324 return StringImpl::create8BitIfPossible(string, lengthOfNullTerminatedString(string));325 }326 327 Ref<StringImpl> StringImpl::create(const LChar* string)328 {329 if (!string)330 return *empty();331 size_t length = strlen(reinterpret_cast<const char*>(string));332 if (length > MaxLength)333 CRASH();334 return create(string, length);335 }336 337 322 Ref<StringImpl> StringImpl::substring(unsigned start, unsigned length) 338 323 { -
trunk/Source/WTF/wtf/text/StringImpl.h
r293639 r293703 238 238 WTF_EXPORT_PRIVATE static Ref<StringImpl> create(const UChar*, unsigned length); 239 239 WTF_EXPORT_PRIVATE static Ref<StringImpl> create(const LChar*, unsigned length); 240 ALWAYS_INLINE static Ref<StringImpl> create(const char* characters, unsigned length) { return create(reinterpret_cast<const LChar*>(characters), length); } 240 241 WTF_EXPORT_PRIVATE static Ref<StringImpl> create8BitIfPossible(const UChar*, unsigned length); 241 242 template<size_t inlineCapacity> static Ref<StringImpl> create8BitIfPossible(const Vector<UChar, inlineCapacity>&); 242 WTF_EXPORT_PRIVATE static Ref<StringImpl> create8BitIfPossible(const UChar*); 243 244 ALWAYS_INLINE static Ref<StringImpl> create(const char* characters, unsigned length) { return create(reinterpret_cast<const LChar*>(characters), length); } 245 WTF_EXPORT_PRIVATE static Ref<StringImpl> create(const LChar*); 246 ALWAYS_INLINE static Ref<StringImpl> create(const char* string) { return create(reinterpret_cast<const LChar*>(string)); } 243 244 // Not using create() naming to encourage developers to call create(ASCIILiteral) when they have a string literal. 245 ALWAYS_INLINE static Ref<StringImpl> createFromCString(const char* characters) { return create(characters, strlen(characters)); } 247 246 248 247 static Ref<StringImpl> createSubstringSharingImpl(StringImpl&, unsigned offset, unsigned length); … … 610 609 bool isNotSpaceOrNewline(UChar32); 611 610 612 template<typename CharacterType> unsigned lengthOfNullTerminatedString(const CharacterType*);613 614 611 // StringHashd is the default hash for StringImpl* and RefPtr<StringImpl> 615 612 template<typename> struct DefaultHash; … … 774 771 { 775 772 return !isSpaceOrNewline(character); 776 }777 778 template<typename CharacterType> inline unsigned lengthOfNullTerminatedString(const CharacterType* string)779 {780 ASSERT(string);781 size_t length = 0;782 while (string[length])783 ++length;784 785 RELEASE_ASSERT(length < StringImpl::MaxLength);786 return static_cast<unsigned>(length);787 773 } 788 774 -
trunk/Source/WTF/wtf/text/WTFString.cpp
r293301 r293703 47 47 } 48 48 49 // Construct a string with UTF-16 data, from a null-terminated source.50 String::String(const UChar* nullTerminatedString)51 {52 if (nullTerminatedString)53 m_impl = StringImpl::create(nullTerminatedString, lengthOfNullTerminatedString(nullTerminatedString));54 }55 56 49 // Construct a string with latin1 data. 57 50 String::String(const LChar* characters, unsigned length) … … 71 64 { 72 65 if (nullTerminatedString) 73 m_impl = StringImpl::create (reinterpret_cast<const LChar*>(nullTerminatedString));66 m_impl = StringImpl::createFromCString(nullTerminatedString); 74 67 } 75 68 -
trunk/Source/WTF/wtf/text/WTFString.h
r293656 r293703 74 74 explicit String(const Vector<UChar, inlineCapacity, OverflowHandler>&); 75 75 76 // Construct a string with UTF-16 data, from a null-terminated source.77 WTF_EXPORT_PRIVATE String(const UChar*);78 79 76 // Construct a string with Latin-1 data. 80 77 WTF_EXPORT_PRIVATE String(const LChar* characters, unsigned length); … … 276 273 277 274 String(const wchar_t* characters) 278 : String( ucharFrom(characters)) { }275 : String(characters, characters ? wcslen(characters) : 0) { } 279 276 280 277 WTF_EXPORT_PRIVATE Vector<wchar_t> wideCharacters() const; -
trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
r293326 r293703 84 84 if (title) { 85 85 PathRemoveExtension(filename); 86 *title = String( (UChar*)filename);86 *title = String(filename); 87 87 } 88 88 89 url = String( (UChar*)urlBuffer);89 url = String(urlBuffer); 90 90 succeeded = true; 91 91 … … 449 449 if (SUCCEEDED(dataObject->GetData(urlWFormat(), &store))) { 450 450 // URL using Unicode 451 UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal));451 auto* data = static_cast<wchar_t*>(GlobalLock(store.hGlobal)); 452 452 url = extractURL(String(data), title); 453 453 GlobalUnlock(store.hGlobal); … … 520 520 if (SUCCEEDED(dataObject->GetData(plainTextWFormat(), &store))) { 521 521 // Unicode text 522 UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal));522 auto* data = static_cast<wchar_t*>(GlobalLock(store.hGlobal)); 523 523 text = String(data); 524 524 GlobalUnlock(store.hGlobal); … … 555 555 String html; 556 556 if (SUCCEEDED(data->GetData(texthtmlFormat(), &store))) { 557 UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal));557 auto* data = static_cast<wchar_t*>(GlobalLock(store.hGlobal)); 558 558 html = String(data); 559 559 GlobalUnlock(store.hGlobal); -
trunk/Source/WebCore/platform/win/PasteboardWin.cpp
r293484 r293703 631 631 632 632 if (extension.isEmpty()) 633 return String( fsPathBuffer);633 return String(wcharFrom(fsPathBuffer)); 634 634 635 635 if (!isLink && usedURL) { 636 636 PathRenameExtension(wcharFrom(fsPathBuffer), extension.wideCharacters().data()); 637 return String( fsPathBuffer);637 return String(wcharFrom(fsPathBuffer)); 638 638 } 639 639 … … 830 830 if (::IsClipboardFormatAvailable(CF_UNICODETEXT) && ::OpenClipboard(m_owner)) { 831 831 if (HANDLE cbData = ::GetClipboardData(CF_UNICODETEXT)) { 832 text.text = static_cast< UChar*>(GlobalLock(cbData));832 text.text = static_cast<wchar_t*>(GlobalLock(cbData)); 833 833 GlobalUnlock(cbData); 834 834 ::CloseClipboard(); … … 873 873 HANDLE cbData = ::GetClipboardData(CF_UNICODETEXT); 874 874 if (cbData) { 875 UChar* buffer = static_cast<UChar*>(GlobalLock(cbData));875 auto* buffer = static_cast<wchar_t*>(GlobalLock(cbData)); 876 876 String str(buffer); 877 877 GlobalUnlock(cbData); -
trunk/Source/WebCore/rendering/mathml/RenderMathMLFenced.cpp
r292810 r293703 76 76 } else { 77 77 // The separator defaults to a single comma. 78 m_separators = StringImpl::create (",");78 m_separators = StringImpl::createFromLiteral(","_s); 79 79 } 80 80 -
trunk/Source/WebKitLegacy/win/DOMCoreClasses.cpp
r278253 r293703 417 417 { 418 418 auto webListener = WebEventListener::create(listener); 419 m_node->addEventListener( ucharFrom(type), WTFMove(webListener), useCapture);419 m_node->addEventListener(String(type), WTFMove(webListener), useCapture); 420 420 421 421 return S_OK; … … 429 429 return E_FAIL; 430 430 auto webListener = WebEventListener::create(listener); 431 m_node->removeEventListener( ucharFrom(type), webListener, useCapture);431 m_node->removeEventListener(String(type), webListener, useCapture); 432 432 return S_OK; 433 433 } … … 927 927 return E_FAIL; 928 928 auto webListener = WebEventListener::create(listener); 929 m_window->addEventListener( ucharFrom(type), WTFMove(webListener), useCapture);929 m_window->addEventListener(String(type), WTFMove(webListener), useCapture); 930 930 return S_OK; 931 931 } … … 938 938 return E_FAIL; 939 939 auto webListener = WebEventListener::create(listener); 940 m_window->removeEventListener( ucharFrom(type), webListener, useCapture);940 m_window->removeEventListener(String(type), webListener, useCapture); 941 941 return S_OK; 942 942 } -
trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp
r293639 r293703 120 120 auto c = StringImpl::createFromLiteral("abcdefg"_s); 121 121 constexpr auto d = "aBcDeFG"_s; 122 auto empty = StringImpl::create(reinterpret_cast<const LChar*>("") );122 auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""), 0); 123 123 auto shorter = StringImpl::createFromLiteral("abcdef"_s); 124 124 auto different = StringImpl::createFromLiteral("abcrefg"_s); … … 163 163 TEST(WTF, StringImplEqualIgnoringASCIICaseWithEmpty) 164 164 { 165 auto a = StringImpl::create(reinterpret_cast<const LChar*>("") );166 auto b = StringImpl::create(reinterpret_cast<const LChar*>("") );165 auto a = StringImpl::create(reinterpret_cast<const LChar*>(""), 0); 166 auto b = StringImpl::create(reinterpret_cast<const LChar*>(""), 0); 167 167 ASSERT_TRUE(equalIgnoringASCIICase(a.ptr(), b.ptr())); 168 168 ASSERT_TRUE(equalIgnoringASCIICase(b.ptr(), a.ptr())); … … 342 342 { 343 343 auto reference = stringFromUTF8("ABCÉEFG"); 344 auto empty = StringImpl::create(reinterpret_cast<const LChar*>("") );344 auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""), 0); 345 345 EXPECT_EQ(static_cast<size_t>(0), reference->findIgnoringASCIICase(empty.ptr())); 346 346 EXPECT_EQ(static_cast<size_t>(0), reference->findIgnoringASCIICase(empty.ptr(), 0)); … … 418 418 ASSERT_FALSE(reference->startsWithIgnoringASCIICase(StringView { })); 419 419 420 auto empty = StringImpl::create(reinterpret_cast<const LChar*>("") );420 auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""), 0); 421 421 ASSERT_FALSE(empty->startsWithIgnoringASCIICase(StringView { })); 422 422 } … … 425 425 { 426 426 auto reference = StringImpl::createFromLiteral("aBcDeFG"_s); 427 auto empty = StringImpl::create(reinterpret_cast<const LChar*>("") );427 auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""), 0); 428 428 ASSERT_TRUE(reference->startsWithIgnoringASCIICase(empty.ptr())); 429 429 ASSERT_TRUE(reference->startsWithIgnoringASCIICase(*empty.ptr())); … … 507 507 ASSERT_FALSE(reference->endsWithIgnoringASCIICase(StringView { })); 508 508 509 auto empty = StringImpl::create(reinterpret_cast<const LChar*>("") );509 auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""), 0); 510 510 ASSERT_FALSE(empty->endsWithIgnoringASCIICase(StringView { })); 511 511 } … … 514 514 { 515 515 auto reference = StringImpl::createFromLiteral("aBcDeFG"_s); 516 auto empty = StringImpl::create(reinterpret_cast<const LChar*>("") );516 auto empty = StringImpl::create(reinterpret_cast<const LChar*>(""), 0); 517 517 ASSERT_TRUE(reference->endsWithIgnoringASCIICase(empty.ptr())); 518 518 ASSERT_TRUE(reference->endsWithIgnoringASCIICase(*empty.ptr())); -
trunk/Tools/TestWebKitAPI/Tests/WTF/StringOperators.cpp
r292810 r293703 259 259 String concatenation16 = ucharArray + emptyString; 260 260 ASSERT_EQ(static_cast<unsigned>(4), concatenation16.length()); 261 ASSERT_TRUE(concatenation16 == String(ucharArray ));261 ASSERT_TRUE(concatenation16 == String(ucharArray, 4)); 262 262 263 263 LChar lcharArray[] = { 't', 'e', 's', 't' }; -
trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp
r293639 r293703 340 340 RefPtr<StringImpl> c = StringImpl::createFromLiteral("abcdefg"_s); 341 341 constexpr auto d = "aBcDeFG"_s; 342 RefPtr<StringImpl> empty = StringImpl::create(reinterpret_cast<const LChar*>("") );342 RefPtr<StringImpl> empty = StringImpl::create(reinterpret_cast<const LChar*>(""), 0); 343 343 RefPtr<StringImpl> shorter = StringImpl::createFromLiteral("abcdef"_s); 344 344 RefPtr<StringImpl> different = StringImpl::createFromLiteral("abcrefg"_s); … … 385 385 TEST(WTF, StringViewEqualIgnoringASCIICaseWithEmpty) 386 386 { 387 RefPtr<StringImpl> a = StringImpl::create(reinterpret_cast<const LChar*>("") );388 RefPtr<StringImpl> b = StringImpl::create(reinterpret_cast<const LChar*>("") );387 RefPtr<StringImpl> a = StringImpl::create(reinterpret_cast<const LChar*>(""), 0); 388 RefPtr<StringImpl> b = StringImpl::create(reinterpret_cast<const LChar*>(""), 0); 389 389 StringView stringViewA(*a.get()); 390 390 StringView stringViewB(*b.get()); … … 395 395 TEST(WTF, StringViewEqualIgnoringASCIICaseWithLatin1Characters) 396 396 { 397 RefPtr<StringImpl> a = StringImpl::create(reinterpret_cast<const LChar*>("aBcéeFG") );398 RefPtr<StringImpl> b = StringImpl::create(reinterpret_cast<const LChar*>("ABCÉEFG") );399 RefPtr<StringImpl> c = StringImpl::create(reinterpret_cast<const LChar*>("ABCéEFG") );400 RefPtr<StringImpl> d = StringImpl::create(reinterpret_cast<const LChar*>("abcéefg") );397 RefPtr<StringImpl> a = StringImpl::create(reinterpret_cast<const LChar*>("aBcéeFG"), 7); 398 RefPtr<StringImpl> b = StringImpl::create(reinterpret_cast<const LChar*>("ABCÉEFG"), 7); 399 RefPtr<StringImpl> c = StringImpl::create(reinterpret_cast<const LChar*>("ABCéEFG"), 7); 400 RefPtr<StringImpl> d = StringImpl::create(reinterpret_cast<const LChar*>("abcéefg"), 7); 401 401 StringView stringViewA(*a.get()); 402 402 StringView stringViewB(*b.get()); … … 983 983 EXPECT_FALSE(StringView(String::fromLatin1("📱")).isAllASCII()); 984 984 EXPECT_FALSE(StringView(String::fromLatin1("\u0080")).isAllASCII()); 985 EXPECT_TRUE(StringView(String(bitwise_cast<const UChar*>(u"Hello") )).isAllASCII());985 EXPECT_TRUE(StringView(String(bitwise_cast<const UChar*>(u"Hello"), 0)).isAllASCII()); 986 986 } 987 987 -
trunk/Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm
r292856 r293703 235 235 236 236 std::array<UChar, 3> utf16 { 0xC2, 0xB6, 0x00 }; 237 WTF::URL url3 { String(utf16.data() ) };237 WTF::URL url3 { String(utf16.data(), utf16.size()) }; 238 238 EXPECT_FALSE(url3.string().is8Bit()); 239 239 EXPECT_FALSE(url3.isValid());
Note:
See TracChangeset
for help on using the changeset viewer.