Skip to content

Commit 891fa6d

Browse files
darinadlercalvaris
authored andcommitted
Add casts that will be needed once Latin1Character is a distinct type
rdar://161524685 https://bugs.webkit.org/show_bug.cgi?id=299706 Reviewed by Geoffrey Garen. * Source/JavaScriptCore/API/JSScript.mm: (+[JSScript scriptOfType:memoryMappedFromASCIIFile:withSourceURL:andBytecodeCache:inVirtualMachine:error:]): Cast to Latin1Character. * Source/JavaScriptCore/API/JSStringRefCF.cpp: (JSStringCreateWithCFString): Cast to UInt8. (JSStringCopyCFString): Ditto. * Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorSocket.cpp: (Inspector::RemoteInspector::backendCommands const): Eliminate use of String::adopt. It doesn't really work for vectors any more, and likely we should remove it to avoid making a promise we can't keep. It doesn't work with byteCast, which is why we need to do this here now. * Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototype.cpp: (JSC::uint8ArrayPrototypeToHex): Cast to uint8_t. * Source/JavaScriptCore/runtime/LiteralParser.cpp: (JSC::reviverMode>::Lexer::lexString): Reduce mixing char with Latin1Character a bit. * Source/WTF/wtf/URLParser.cpp: (WTF::URLParser::appendNumberToASCIIBuffer): Cast to char. * Source/WTF/wtf/cf/CFURLExtras.cpp: (WTF::bytesAsString): Cast to UInt8. (WTF::isSameOrigin): Cast to Latin1Character. * Source/WTF/wtf/cf/URLCF.cpp: (WTF::URL::createCFURL): Cast to UInt8. * Source/WTF/wtf/cocoa/NSURLExtras.mm: (WTF::userVisibleString): Cast to Latin1Character. * Source/WTF/wtf/persistence/PersistentCoders.cpp: (WTF::Persistence::Coder<String>::encodeForPersistence): Use asBytes. * Source/WTF/wtf/text/StringBuilder.h: (WTF::StringBuilder::operator[] const): Cast so the conditional operator does not mix types. * Source/WTF/wtf/text/WTFString.cpp: (WTF::String::String): Cast to Latin1Character. (WTF::String::ascii const): Cast so the conditional operator does not mix types. * Source/WTF/wtf/text/cf/StringCF.cpp: (WTF::String::String): Cast to UInt8. * Source/WTF/wtf/text/cf/StringImplCF.cpp: (WTF::StringImpl::createCFString): Ditto. * Source/WTF/wtf/text/cf/StringViewCF.cpp: (WTF::StringView::createCFString const): Ditto. (WTF::StringView::createCFStringWithoutCopying const): Ditto. * Source/WebCore/Modules/encryptedmedia/InitDataRegistry.cpp: (WebCore::extractKeyIDsKeyids): Cast to Latin1Character to pass to parseJSON and remove the unnecessary copy into a temporary String. * Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp: (WebCore::PeerConnectionBackend::handleLogMessage): Cast to uint8_t. * Source/WebCore/Modules/mediastream/RTCRtpSFrameTransformerCocoa.cpp: (WebCore::RTCRtpSFrameTransformer::computeSaltKey): Ditto. (WebCore::createBaseSFrameKey): Ditto. (WebCore::RTCRtpSFrameTransformer::computeAuthenticationKey): Ditto. (WebCore::RTCRtpSFrameTransformer::computeEncryptionKey): Ditto. * Source/WebCore/Modules/mediastream/gstreamer/GStreamerDtlsTransportBackend.cpp: (WebCore::GStreamerDtlsTransportBackendObserver::stateChanged): Ditto. * Source/WebCore/Modules/push-api/PushMessageCrypto.cpp: (WebCore::PushCrypto::decryptAES128GCMPayload): Ditto. (WebCore::PushCrypto::decryptAESGCMPayload): Ditto. * Source/WebCore/Modules/websockets/WebSocketHandshake.cpp: (WebCore::trimInputSample): Cast to Latin1Character. (WebCore::WebSocketHandshake::readStatusLine): Ditto. * Source/WebCore/bindings/js/ScriptBufferSourceProvider.h: Cast to Latin1Character. * Source/WebCore/bindings/js/SerializedScriptValue.cpp: (WebCore::CloneDeserializer::readString): Ditto. * Source/WebCore/contentextensions/DFABytecodeInterpreter.cpp: (WebCore::ContentExtensions::DFABytecodeInterpreter::interpretJumpTable): Cast so the conditional operator does not mix types. (WebCore::ContentExtensions::DFABytecodeInterpreter::interpret): Ditto. * Source/WebCore/crypto/SubtleCrypto.cpp: (WebCore::SubtleCrypto::unwrapKey): Cast to Latin1Character to pass to JSONParse and remove the unnecessary copy into a temporary String. * Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm: (WebCore::replaceRichContentWithAttachments): Cast to Latin1Character. * Source/WebCore/fileapi/FileReaderLoader.cpp: (WebCore::FileReaderLoader::stringResult): Ditto. * Source/WebCore/html/FTPDirectoryDocument.cpp: (WebCore::FTPDirectoryDocumentParser::loadDocumentTemplate): Ditto. * Source/WebCore/html/parser/HTMLEntityParser.cpp: (WebCore::StringParsingBufferSource::currentCharacter const): Cast so the conditional operator does not mix types. * Source/WebCore/html/track/VTTScanner.h: (WebCore::VTTScanner::currentChar const): Ditto. * Source/WebCore/html/track/WebVTTParser.cpp: (WebCore::WebVTTParser::fileFinished): Cast to uint8_t. * Source/WebCore/loader/FTPDirectoryParser.cpp: (WebCore::parseOneFTPLine): Cast to Latin1Character. * Source/WebCore/loader/FormSubmission.cpp: (WebCore::appendMailtoPostFormDataToURL): Cast to Latin1Character. (WebCore::FormSubmission::create): Ditto. * Source/WebCore/loader/TextResourceDecoder.cpp: (WebCore::findXMLEncoding): Cast to uint8_t. (WebCore::TextResourceDecoder::checkForCSSCharset): Cast to uint8_t and Latin1Character. (WebCore::TextResourceDecoder::checkForHeadCharset): Ditto. * Source/WebCore/loader/cache/CachedScript.cpp: (WebCore::CachedScript::script): Cast to Latin1Character. (WebCore::CachedScript::codeBlockHashConcurrently): Ditto. * Source/WebCore/platform/encryptedmedia/CDMUtilities.cpp: (WebCore::CDMUtilities::parseJSONObject): Cast to Latin1Character to pass to parseJSON and remove the unnecessary copy into a temporary String. * Source/WebCore/platform/graphics/avfoundation/CDMFairPlayStreaming.cpp: (WebCore::extractSinfData): Ditto. (WebCore::CDMPrivateFairPlayStreaming::extractKeyIDsMpts): Ditto. * Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm: (WebCore::parseJSONValue): Cast to Latin1Character. * Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp: (WebCore::fontNameMapName): Ditto. * Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.cpp: (WebCore::ParsedResponseMessage::ParsedResponseMessage): Cast to Latin1Character. (WebCore::CDMInstanceSessionThunder::loadSession): Ditto. * Source/WebCore/platform/gstreamer/GStreamerElementHarness.cpp: (WebCore::MermaidBuilder::span const): Cast to uint8_t. * Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp: (WebCore::decodingWarning): Cast to char. (WebCore::PNGImageDecoder::readChunks): Ditto. * Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.cpp: (WebCore::MediaRecorderPrivateMock::fetchData): Cast to uint8_t. * Source/WebCore/platform/network/curl/OpenSSLHelper.cpp: (OpenSSL::BIO::getDataAsString const): Cast to Latin1Character. (OpenSSL::toString): Ditto. * Source/WebCore/platform/network/soup/CertificateInfoSoup.cpp: (WebCore::CertificateInfo::summary const): Ditto. * Source/WebCore/platform/text/SegmentedString.h: (WebCore::SegmentedString::Substring::currentCharacter const): Cast so the conditional operator does not mix types. * Source/WebCore/testing/MockCDMFactory.cpp: (WebCore::MockCDM::sanitizeResponse const): Cast to Latin1Character. (WebCore::MockCDMInstance::setServerCertificate): Ditto. (WebCore::MockCDMInstanceSession::updateLicense): Ditto. * Source/WebGPU/WebGPU/Pipeline.mm: (WebKit::printToFileForPsoRepro): Cast to uint8_t. * Source/WebKit/NetworkProcess/cache/NetworkCache.cpp: (WebKit::NetworkCache::Cache::dumpContentsToFile): Ditto. * Source/WebKit/NetworkProcess/storage/CacheStorageManager.cpp: (WebKit::readSizeFile): Cast to Latin1Character. * Source/WebKit/Platform/IPC/DaemonCoders.h: (WebKit::Daemon::Coder<WTF::String>::encode): Cast to uint8_t. * Source/WebKit/Shared/API/c/cf/WKStringCF.mm: (WKStringCopyCFString): Cast to UInt8. * Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm: (WebKit::SandboxExtensionImpl::SandboxExtensionImpl): Cast to Latin1Character. * Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp: (API::getContentRuleListSourceFromMappedFile): Cast to Latin1Character. * Source/WebKit/UIProcess/API/C/WKPage.cpp: (dataFrom): Cast to uint8_t. * Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: (WebKit::WebPasteboardProxy::testIPCSharedMemory): Cast to Latin1Character. * Source/WebKit/UIProcess/Extensions/WebExtensionDeclarativeNetRequestSQLiteStore.cpp: (WebKit::WebExtensionDeclarativeNetRequestSQLiteStore::getKeysAndValuesFromRowIterator): Ditto. * Source/WebKit/UIProcess/Inspector/glib/RemoteInspectorClient.cpp: (WebKit::RemoteInspectorClient::setBackendCommands): Cast to std::byte. * Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorUIProxyMac.mm: (WebKit::RemoteWebInspectorUIProxy::platformLoad): Cast to Latin1Character. * Source/WebKit/UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm: (WebKit::WebInspectorUIProxy::platformLoad): Ditto. * Source/WebKit/UIProcess/wpe/WebPasteboardProxyWPE.cpp: (WebKit::WebPasteboardProxy::readURLFromPasteboard): Ditto. * Source/WebKit/WebProcess/Network/webrtc/RTCDataChannelRemoteManager.cpp: (WebKit::RTCDataChannelRemoteManager::sendData): Ditto. * Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm: (WebKit::registerLogClient): Cast to uint8_t. * Tools/TestWebKitAPI/Tests/WTF/Base64.cpp: (TestWebKitAPI::TEST(Base64, Encode)): Cast to uint8_t. (TestWebKitAPI::TEST(Base64, EncodeOmitPadding)): Ditto. (TestWebKitAPI::TEST(Base64, EncodeURL)): Ditto. (TestWebKitAPI::TEST(Base64, EncodeURLOmitPadding)): Ditto. * Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp: (TestWebKitAPI::createTestFile): Ditto. (TestWebKitAPI::TEST_F(FileSystemTest, openExistingFileTruncate)): Ditto. (TestWebKitAPI::TEST_F(FileSystemTest, openExistingFileReadWrite)): Ditto. (TestWebKitAPI::TEST_F(FileSystemTest, deleteEmptyDirectoryContainingDSStoreFile)): Ditto. (TestWebKitAPI::TEST_F(FileSystemTest, deleteEmptyDirectoryOnNonEmptyDirectory)): Ditto. (TestWebKitAPI::TEST_F(FileSystemTest, moveDirectory)): Ditto. (TestWebKitAPI::runGetFileModificationTimeTest): Ditto. (TestWebKitAPI::TEST_F(FileSystemTest, readEntireFile)): Ditto. * Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp: (TestWebKitAPI::TEST(WTF, ExternalStringImplCreate8bit)): Use char and cast to Latin1Character. (TestWebKitAPI::TEST(WTF, ExternalStringAtom)): Ditto. * Tools/TestWebKitAPI/Tests/WTF/StringView.cpp: (TestWebKitAPI::TEST(WTF, StringViewEqualIgnoringASCIICaseWithLatin1Characters)): Use byteCast instead of reinterpret_cast. * Tools/TestWebKitAPI/Tests/WTF/cocoa/URLExtras.mm: (TestWebKitAPI::dataAsString): Pass a character instead of an int. * Tools/TestWebKitAPI/Tests/WebCore/PushMessageCrypto.cpp: (TestWebKitAPI::mustBase64URLDecode): Use ASCIILiteral. (TestWebKitAPI::stringView): Added. (TestWebKitAPI::TEST(PushMessageCrypto, AES128GCMPayloadWithMinimalPadding)): Use stringView. (TestWebKitAPI::TEST(PushMessageCrypto, AES128GCMPayloadWithPadding)): Ditto. (TestWebKitAPI::TEST(PushMessageCrypto, AESGCMPayloadWithMinimalPadding)): Ditto. (TestWebKitAPI::TEST(PushMessageCrypto, AESGCMPayloadWithPadding)): Ditto. * Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp: (TestWebKitAPI::TEST_F(FragmentedSharedBufferTest, createWithContentsOfExistingFile)): Cast to Latin1Character. (TestWebKitAPI::TEST_F(FragmentedSharedBufferTest, read)): Ditto. (TestWebKitAPI::TEST_F(SharedBufferChunkReaderTest, includeSeparator)): Use uint8_t. (TestWebKitAPI::TEST_F(SharedBufferChunkReaderTest, peekData)): Cast to Latin1Character. * Tools/TestWebKitAPI/Tests/WebCore/SharedBufferTest.cpp: (TestWebKitAPI::FragmentedSharedBufferTest::SetUp): Cast to uint8_t. * Tools/TestWebKitAPI/Tests/WebCore/curl/CurlMultipartHandleTests.cpp: (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, SimpleMessage)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, NoHeader)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, NoBody)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, TransportPadding)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, NoEndOfBoundary)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, NoEndOfBoundaryAfterCompleted)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, NoCloseDelimiter)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, NoCloseDelimiterAfterCompleted)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, CloseDelimiter)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, CloseDelimiterAfterCompleted)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, DivideFirstDelimiter)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, DivideSecondDelimiter)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, DivideLastDelimiter)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, DivideCloseDelimiter)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, DivideTransportPadding)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, DivideHeader)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, DivideBody)): Ditto. (TestWebKitAPI::Curl::TEST(CurlMultipartHandleTests, CompleteWhileHeaderProcessing)): Ditto. * Tools/TestWebKitAPI/Tests/WebKitCocoa/IndexedDBPersistence.mm: (-[IndexedDBOpenPanelUIDelegate webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:]): Ditto. * Tools/TestWebKitAPI/Tests/WebKitCocoa/WebPushDaemon.mm: (TestWebKitAPI::WebPushDTestWebView::injectPushMessage): Cast to Latin1Character. Canonical link: https://commits.webkit.org/301031@main Signed-off-by: Xabier Rodriguez Calvar <calvaris@igalia.com>
1 parent 80604fc commit 891fa6d

61 files changed

Lines changed: 190 additions & 194 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Source/JavaScriptCore/API/JSScript.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ + (instancetype)scriptOfType:(JSScriptType)type memoryMappedFromASCIIFile:(NSURL
146146
auto result = adoptNS([[JSScript alloc] init]);
147147
result->m_virtualMachine = vm;
148148
result->m_type = type;
149-
result->m_source = String(StringImpl::createWithoutCopying(fileData.span()));
149+
result->m_source = StringImpl::createWithoutCopying(byteCast<Latin1Character>(fileData.span()));
150150
result->m_mappedSource = WTFMove(fileData);
151151
result->m_sourceURL = sourceURL;
152152
result->m_cachePath = cachePath;

Source/JavaScriptCore/API/JSStringRefCF.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ JSStringRef JSStringCreateWithCFString(CFStringRef string)
4747

4848
Vector<Latin1Character, 1024> lcharBuffer(length);
4949
CFIndex usedBufferLength;
50-
CFIndex convertedSize = CFStringGetBytes(string, CFRangeMake(0, length), kCFStringEncodingISOLatin1, 0, false, lcharBuffer.data(), length, &usedBufferLength);
50+
CFIndex convertedSize = CFStringGetBytes(string, CFRangeMake(0, length), kCFStringEncodingISOLatin1, 0, false, byteCast<UInt8>(lcharBuffer.data()), length, &usedBufferLength);
5151
if (static_cast<size_t>(convertedSize) == length && static_cast<size_t>(usedBufferLength) == length)
5252
return &OpaqueJSString::create(lcharBuffer.span()).leakRef();
5353

@@ -64,7 +64,7 @@ CFStringRef JSStringCopyCFString(CFAllocatorRef allocator, JSStringRef string)
6464

6565
if (string->is8Bit()) {
6666
auto characters = string->span8();
67-
return CFStringCreateWithBytes(allocator, characters.data(), characters.size(), kCFStringEncodingISOLatin1, false);
67+
return CFStringCreateWithBytes(allocator, byteCast<UInt8>(characters.data()), characters.size(), kCFStringEncodingISOLatin1, false);
6868
}
6969
auto characters = string->span16();
7070
return CFStringCreateWithCharacters(allocator, reinterpret_cast<const UniChar*>(characters.data()), characters.size());

Source/JavaScriptCore/inspector/remote/socket/RemoteInspectorSocket.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ String RemoteInspector::backendCommands() const
262262

263263
auto contents = FileSystem::readEntireFile(m_backendCommandsPath);
264264

265-
return contents ? String::adopt(WTFMove(*contents)) : emptyString();
265+
return contents ? String { byteCast<Latin1Character>(contents->span()) } : emptyString();
266266
}
267267

268268
// RemoteInspectorConnectionClient handlers

Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototype.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ JSC_DEFINE_HOST_FUNCTION(uint8ArrayPrototypeToHex, (JSGlobalObject* globalObject
233233

234234
std::span<Latin1Character> buffer;
235235
auto result = StringImpl::createUninitialized(length * 2, buffer);
236-
Latin1Character* bufferEnd = std::to_address(buffer.end());
237236
constexpr size_t stride = 8; // Because loading uint8x8_t.
238237
if (length >= stride) {
239238
auto encodeVector = [&](auto input) {
@@ -259,11 +258,10 @@ JSC_DEFINE_HOST_FUNCTION(uint8ArrayPrototypeToHex, (JSGlobalObject* globalObject
259258
};
260259

261260
const auto* cursor = data;
262-
auto* output = buffer.data();
263-
for (; cursor + stride <= end; cursor += stride, output += stride * 2)
261+
for (auto* output = byteCast<uint8_t>(buffer.data()); cursor + stride <= end; cursor += stride, output += stride * 2)
264262
simde_vst1q_u8(output, encodeVector(simde_vld1_u8(cursor)));
265263
if (cursor < end)
266-
simde_vst1q_u8(bufferEnd - stride * 2, encodeVector(simde_vld1_u8(end - stride)));
264+
simde_vst1q_u8(byteCast<uint8_t>(std::to_address(buffer.end())) - stride * 2, encodeVector(simde_vld1_u8(end - stride)));
267265
} else {
268266
const auto* cursor = data;
269267
auto* output = buffer.data();

Source/JavaScriptCore/runtime/LiteralParser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ ALWAYS_INLINE TokenType LiteralParser<CharType, reviverMode>::Lexer::lexString(L
911911
if (m_mode == StrictJSON) {
912912
ASSERT(terminator == '"');
913913
if constexpr (hint == JSONIdentifierHint::MaybeIdentifier) {
914-
while (m_ptr < m_end && isSafeStringCharacterForIdentifier<SafeStringCharacterSet::Strict>(*m_ptr, '"'))
914+
while (m_ptr < m_end && isSafeStringCharacterForIdentifier<SafeStringCharacterSet::Strict>(*m_ptr, terminator))
915915
++m_ptr;
916916
} else {
917917
using UnsignedType = std::make_unsigned_t<CharType>;
@@ -926,8 +926,8 @@ ALWAYS_INLINE TokenType LiteralParser<CharType, reviverMode>::Lexer::lexString(L
926926
return SIMD::findFirstNonZeroIndex(mask);
927927
};
928928

929-
auto scalarMatch = [&](auto character) ALWAYS_INLINE_LAMBDA {
930-
return !isSafeStringCharacter<SafeStringCharacterSet::Strict>(character, '"');
929+
auto scalarMatch = [&](CharType character) ALWAYS_INLINE_LAMBDA {
930+
return !isSafeStringCharacter<SafeStringCharacterSet::Strict>(character, terminator);
931931
};
932932

933933
m_ptr = SIMD::find(std::span { m_ptr, m_end }, vectorMatch, scalarMatch);

Source/WTF/wtf/cf/CFURLExtras.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ String bytesAsString(CFURLRef url)
5656
RELEASE_ASSERT(bytesLength <= static_cast<CFIndex>(String::MaxLength));
5757
Latin1Character* buffer;
5858
auto result = String::createUninitialized(bytesLength, buffer);
59-
CFURLGetBytes(url, buffer, bytesLength);
59+
CFURLGetBytes(url, byteCast<UInt8>(buffer()), bytesLength);
6060
return result;
6161
}
6262

@@ -90,7 +90,7 @@ bool isSameOrigin(CFURLRef a, const URL& b)
9090
auto aBytes = bytesAsVector(a);
9191
RELEASE_ASSERT(aBytes.size() <= String::MaxLength);
9292

93-
StringView aString { aBytes.span() };
93+
StringView aString { byteCast<Latin1Character>(aBytes.span()) };
9494
StringView bString { b.string() };
9595

9696
if (!b.hasPath())

Source/WTF/wtf/cocoa/NSURLExtras.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static bool hasQuestionMarkOnlyQueryString(NSURL *URL)
317317

318318
NSString *userVisibleString(NSURL *URL)
319319
{
320-
return URLHelpers::userVisibleURL(span(originalURLData(URL)));
320+
return URLHelpers::userVisibleURL(byteCast<Latin1Character>(span(originalURLData(URL))));
321321
}
322322

323323
BOOL isUserVisibleURL(NSString *string)

Source/WTF/wtf/persistence/PersistentCoders.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void Coder<String>::encodeForPersistence(Encoder& encoder, const String& string)
100100
encoder << string.length() << is8Bit;
101101

102102
if (is8Bit)
103-
encoder.encodeFixedLengthData(string.span8());
103+
encoder.encodeFixedLengthData(asBytes(string.span8()));
104104
else
105105
encoder.encodeFixedLengthData(asBytes(string.span16()));
106106
}

Source/WTF/wtf/text/StringBuilder.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,7 @@ inline unsigned StringBuilder::capacity() const
278278

279279
inline char16_t StringBuilder::operator[](unsigned i) const
280280
{
281-
RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(i < length());
282-
return is8Bit() ? characters<Latin1Character>()[i] : characters<char16_t>()[i];
281+
return is8Bit() ? char16_t { span8()[i] } : span16()[i];
283282
}
284283

285284
inline bool StringBuilder::is8Bit() const

Source/WTF/wtf/text/WTFString.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ String::String(std::span<const Latin1Character> characters)
5151
{
5252
}
5353

54+
// Construct a string with Latin-1 data.
5455
String::String(std::span<const char> characters)
55-
: m_impl(characters.data() ? RefPtr { StringImpl::create(byteCast<uint8_t>(characters)) } : nullptr)
56+
: m_impl(characters.data() ? RefPtr { StringImpl::create(byteCast<Latin1Character>(characters)) } : nullptr)
5657
{
5758
}
5859

@@ -392,9 +393,9 @@ CString String::ascii() const
392393
CString result = CString::newUninitialized(characters.size(), characterBuffer);
393394

394395
for (auto character : characters)
395-
*characterBuffer++ = character && (character < 0x20 || character > 0x7f) ? '?' : character;
396+
*characterBuffer++ = character && (character < 0x20 || character > 0x7f) ? '?' : byteCast<char>(character);
396397

397-
return result;
398+
return result;
398399
}
399400

400401
auto characters = span16();

0 commit comments

Comments
 (0)