[webkit-changes] [WebKit/WebKit] dbd981: Add byteCast for conversions between different byt...

Darin Adler noreply at github.com
Sun May 26 19:21:31 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: dbd9819325e88d1d46f1662949df2edd3bba2666
      https://github.com/WebKit/WebKit/commit/dbd9819325e88d1d46f1662949df2edd3bba2666
  Author: Darin Adler <darin at apple.com>
  Date:   2024-05-26 (Sun, 26 May 2024)

  Changed paths:
    M Source/JavaScriptCore/API/JSStringRef.cpp
    M Source/JavaScriptCore/assembler/MacroAssemblerPrinter.cpp
    M Source/JavaScriptCore/assembler/ProbeFrame.h
    M Source/JavaScriptCore/bytecode/UnlinkedMetadataTableInlines.h
    M Source/JavaScriptCore/runtime/Identifier.h
    M Source/JavaScriptCore/runtime/IntlCollator.cpp
    M Source/JavaScriptCore/runtime/IntlLocale.cpp
    M Source/JavaScriptCore/runtime/NumberPrototype.cpp
    M Source/JavaScriptCore/wasm/WasmFormat.h
    M Source/JavaScriptCore/wasm/WasmMemory.cpp
    M Source/JavaScriptCore/yarr/YarrPattern.cpp
    M Source/WTF/wtf/FastFloat.cpp
    M Source/WTF/wtf/FileSystem.cpp
    M Source/WTF/wtf/PageBlock.h
    M Source/WTF/wtf/StdLibExtras.h
    M Source/WTF/wtf/Threading.cpp
    M Source/WTF/wtf/cf/VectorCF.h
    M Source/WTF/wtf/persistence/PersistentCoders.cpp
    M Source/WTF/wtf/text/AtomStringImpl.h
    M Source/WTF/wtf/text/CString.h
    M Source/WTF/wtf/text/StringBuilder.h
    M Source/WTF/wtf/text/StringCommon.h
    M Source/WTF/wtf/text/StringConcatenate.h
    M Source/WTF/wtf/text/StringConcatenateNumbers.h
    M Source/WTF/wtf/text/StringImpl.cpp
    M Source/WTF/wtf/text/StringImpl.h
    M Source/WTF/wtf/text/StringView.h
    M Source/WTF/wtf/text/WTFString.cpp
    M Source/WTF/wtf/text/WTFString.h
    M Source/WTF/wtf/text/cf/AtomStringImplCF.cpp
    M Source/WTF/wtf/unicode/Collator.h
    M Source/WTF/wtf/unicode/CollatorDefault.cpp
    M Source/WTF/wtf/unicode/icu/CollatorICU.cpp
    M Source/WebCore/Modules/WebGPU/GPUQueue.cpp
    M Source/WebCore/Modules/encryptedmedia/InitDataRegistry.cpp
    M Source/WebCore/PAL/pal/text/EncodingTables.cpp
    M Source/WebCore/PAL/pal/text/TextCodecCJK.cpp
    M Source/WebCore/PAL/pal/text/TextCodecICU.cpp
    M Source/WebCore/PAL/pal/text/TextEncodingDetectorICU.cpp
    M Source/WebCore/css/process-css-pseudo-selectors.py
    M Source/WebCore/html/track/VTTScanner.h
    M Source/WebCore/html/track/WebVTTTokenizer.cpp
    M Source/WebCore/platform/SharedBufferChunkReader.cpp
    M Source/WebCore/platform/graphics/MIMESniffer.cpp
    M Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp
    M Source/WebCore/platform/graphics/cg/ShareableBitmapCG.mm
    M Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
    M Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm
    M Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm
    M Source/WebCore/platform/graphics/cpu/arm/filters/FEBlendNeonApplier.cpp
    M Source/WebCore/platform/network/cocoa/ResourceResponseCocoa.mm
    M Source/WebCore/workers/ScriptBuffer.cpp
    M Source/WebCore/xml/XSLTProcessorLibxslt.cpp
    M Source/WebCore/xml/XSLTUnicodeSort.cpp
    M Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp
    M Source/WebGPU/WebGPU/BindGroup.mm
    M Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h
    M Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
    M Source/WebKit/NetworkProcess/webrtc/LibWebRTCSocketClient.cpp
    M Source/WebKit/Shared/API/c/WKString.cpp
    M Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm
    M Source/WebKit/UIProcess/mac/LegacySessionStateCoding.cpp
    M Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocket.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
    M Source/WebKitLegacy/mac/Misc/WebNSDataExtras.mm
    M Tools/TestWebKitAPI/Tests/WTF/StdLibExtrasTests.cpp
    M Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp
    M Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp
    M Tools/TestWebKitAPI/Tests/WTF/StringView.cpp
    M Tools/TestWebKitAPI/Tests/WebCore/CBORWriterTest.cpp
    M Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm
    M Tools/TestWebKitAPI/cocoa/CGImagePixelReader.cpp
    M Tools/TestWebKitAPI/cocoa/HTTPServer.mm

  Log Message:
  -----------
  Add byteCast for conversions between different byte-sized types
https://bugs.webkit.org/show_bug.cgi?id=273380
rdar://127209334

Reviewed by Chris Dumez.

* Source/JavaScriptCore/API/JSStringRef.cpp:
(JSStringGetUTF8CString): Use byteCast.

* Source/JavaScriptCore/assembler/MacroAssemblerPrinter.cpp:
(JSC::Printer::printMemory): Use static_cast instead of reinterpret_cast.
* Source/JavaScriptCore/assembler/ProbeFrame.h:
(JSC::Probe::Frame::Frame): Ditto.
* Source/JavaScriptCore/bytecode/UnlinkedMetadataTableInlines.h:
(JSC::UnlinkedMetadataTable::link): Ditto.

* Source/JavaScriptCore/runtime/Identifier.h:
(JSC::Identifier::equal): Use byteCast.
(JSC::operator==): Ditto.
* Source/JavaScriptCore/runtime/IntlCollator.cpp:
(JSC::IntlCollator::compareStrings const): Ditto.
* Source/JavaScriptCore/runtime/IntlLocale.cpp:
(JSC::LocaleIDBuilder::setKeywordValue): Ditto.

* Source/JavaScriptCore/runtime/NumberPrototype.cpp:
(JSC::toStringWithRadixInternal): Removed unneeded static_cast.

* Source/JavaScriptCore/wasm/WasmFormat.h:
(JSC::Wasm::Segment::byte): Removed unneeded reinterpret_cast.

* Source/JavaScriptCore/wasm/WasmMemory.cpp:
(JSC::Wasm::Memory::fill): Use static_cast instead of reinterpret_cast.
(JSC::Wasm::Memory::copy): Ditto.
(JSC::Wasm::Memory::init): Ditto.

* Source/JavaScriptCore/yarr/YarrPattern.cpp:
(JSC::Yarr::dumpUChar32): Tweaked formatting.

* Source/WTF/wtf/FastFloat.cpp:
(WTF::parseDouble): Use byteCast.
* Source/WTF/wtf/FileSystem.cpp:
(WTF::FileSystemImpl::toStdFileSystemPath): Ditto.
(WTF::FileSystemImpl::fromStdFileSystemPath): Ditto.

* Source/WTF/wtf/PageBlock.h:
(WTF::PageBlock::end const): Use static_cast instead of reinterpret_cast.

* Source/WTF/wtf/StdLibExtras.h: Added byteCast.

* Source/WTF/wtf/Threading.cpp:
(WTF::Thread::normalizeThreadName): Use byteCast.

* Source/WTF/wtf/URLHelpers.cpp:
(WTF::URLHelpers::userVisibleURL): Use span instead of dataAsUInt8Ptr.
* Source/WTF/wtf/cf/URLCF.cpp:
(WTF::URL::createCFURL const): Ditto.

* Source/WTF/wtf/cf/VectorCF.h:
(WTF::span): Use static_cast instead of reinterpret_cast.

* Source/WTF/wtf/persistence/PersistentCoders.cpp:
(WTF::Persistence::Coder<CString>::encodeForPersistence): Use span
instead of dataAsUInt8Ptr.
(WTF::Persistence::Coder<CString>::decodeForPersistence): Use byteCast.

* Source/WTF/wtf/text/AtomStringImpl.h: Use byteCast.
* Source/WTF/wtf/text/CString.h: Ditto.
* Source/WTF/wtf/text/StringBuilder.h:
(WTF::StringBuilder::append): Ditto.
* Source/WTF/wtf/text/StringCommon.h: Ditto.
* Source/WTF/wtf/text/StringConcatenate.h: Ditto.
* Source/WTF/wtf/text/StringConcatenateNumbers.h: Ditto.
* Source/WTF/wtf/text/StringImpl.cpp:
(WTF::equalInner): Ditto.
* Source/WTF/wtf/text/StringImpl.h: Ditto.
* Source/WTF/wtf/text/StringView.h: Ditto.
* Source/WTF/wtf/text/WTFString.cpp:
(WTF::String::String): Ditto.
(WTF::String::fromUTF8): Ditto.
* Source/WTF/wtf/text/WTFString.h: Ditto.
* Source/WTF/wtf/text/cf/AtomStringImplCF.cpp:
(WTF::AtomStringImpl::add): Ditto.

* Source/WTF/wtf/unicode/Collator.h: Use char8_t instead of UTF8 in the
name for the collate function that takes null-terminated strings.
* Source/WTF/wtf/unicode/CollatorDefault.cpp:
(WTF::Collator::collate const): Use byteCast.
* Source/WTF/wtf/unicode/icu/CollatorICU.cpp:
(WTF::createIterator): Use byteCast.
(WTF::Collator::collate const): Use createIterator.

* Source/WebCore/Modules/WebGPU/GPUQueue.cpp:
(WebCore::getImageBytesFromVideoFrame): Use static_cast instead of reinterpret_cast.

* Source/WebCore/Modules/encryptedmedia/InitDataRegistry.cpp:
(WebCore::isPlayReadySanitizedInitializationData): Use byteCast.
* Source/WebCore/PAL/pal/text/EncodingTables.cpp:
(PAL::jis0208): Ditto.
(PAL::jis0212): Ditto.
(PAL::big5): Ditto.
(PAL::eucKR): Ditto.
(PAL::gb18030): Ditto.
* Source/WebCore/PAL/pal/text/TextCodecCJK.cpp:
(PAL::TextCodecCJK::eucJPDecode): Ditto.
(PAL::TextCodecCJK::big5Decode): Ditto.
* Source/WebCore/PAL/pal/text/TextCodecICU.cpp:
(PAL::TextCodecICU::decode): Ditto.
(PAL::TextCodecICU::encode const): Ditto.
* Source/WebCore/PAL/pal/text/TextEncodingDetectorICU.cpp:
(PAL::detectTextEncoding): Ditto.
* Source/WebCore/css/process-css-pseudo-selectors.py: Ditto.
* Source/WebCore/html/track/VTTScanner.h:
(WebCore::VTTScanner::scan): Ditto.

* Source/WebCore/html/track/WebVTTTokenizer.cpp:
(WebCore::equalLiteral): Deleted.

* Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::showText): Use span instead of dataAsUInt8Ptr.

* Source/WebCore/platform/SharedBuffer.h: Deleted dataAsCharPtr.

* Source/WebCore/platform/SharedBufferChunkReader.cpp:
(WebCore::SharedBufferChunkReader::nextChunk): Use byteCast.
* Source/WebCore/platform/graphics/MIMESniffer.cpp:
(WebCore::MIMESniffer::span8): Ditto.
* Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLANGLE::initialize): Ditto.
(WebCore::GraphicsContextGLANGLE::getString): Ditto.
* Source/WebCore/platform/graphics/cg/ShareableBitmapCG.mm:
(WebCore::ShareableBitmap::createFromImagePixels): Ditto.

* Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::defaultVariationValues): Use assignment instead of static_cast.

* Source/WebCore/platform/graphics/cocoa/WebCoreDecompressionSession.mm:
(WebCore::WebCoreDecompressionSession::decodeSample): Use byteCast.
* Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm:
(WebCore::parseOpusPrivateData): Ditto.
* Source/WebCore/platform/graphics/cpu/arm/filters/FEBlendNeonApplier.cpp:
(WebCore::FEBlendNeonApplier::applyPlatform const): Ditto.
* Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp:
(WebCore::ScalableImageDecoder::create): Ditto.

* Source/WebCore/platform/network/cf/ResourceRequestCFNet.h:
(WebCore::httpHeaderValueUsingSuitableEncoding): Use span instead of
dataAsUInt8Ptr.
* Source/WebCore/platform/network/cocoa/ResourceResponseCocoa.mm:
(WebCore::ResourceResponse::platformCertificateInfo const): Ditto.

* Source/WebCore/workers/ScriptBuffer.cpp:
(WebCore::ScriptBuffer::toString const): Use byteCast.
(WebCore::ScriptBuffer::append): Ditto. Also fixed a mistake where this was
using uint8_t instead of char8_t.

* Source/WebCore/xml/XSLTProcessorLibxslt.cpp:
(WebCore::docLoaderFunc): Use byteCast.
(WebCore::writeToStringBuilder): Ditto.
(WebCore::XSLTProcessor::transformToString): Ditto.
* Source/WebCore/xml/XSLTUnicodeSort.cpp:
(WebCore::xsltUnicodeSortFunction): Ditto.
* Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLParserContext::createMemoryParser): Use byteCast.
(WebCore::toString): Ditto.
(WebCore::toAtomString): Ditto.
(WebCore::sharedXHTMLEntity): Ditto.
(WebCore::convertUTF16EntityToUTF8): Ditto.
(WebCore::getXHTMLEntity): Ditto.
(WebCore::xmlDocPtrForString): Ditto.
(WebCore::attributesStartElementNsHandler): Ditto.
* Source/WebGPU/WebGPU/BindGroup.mm:
(WebGPU::Device::createExternalTextureFromPixelBuffer const): Ditto.
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGLFunctionsGenerated.h:
(getBufferSubData): Ditto.
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::logOnBehalfOfWebContent): Ditto.
* Source/WebKit/NetworkProcess/webrtc/LibWebRTCSocketClient.cpp:
(WebKit::LibWebRTCSocketClient::signalReadPacket): Ditto.
* Source/WebKit/Shared/API/c/WKString.cpp:
(WKStringGetUTF8CStringImpl): Ditto.

* Source/WebKit/Shared/API/c/cf/WKURLCF.mm:
(WKURLCopyCFURL): Use span instead of dataAsUInt8Ptr.
* Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm:
(WebKit::SandboxExtensionImpl::SandboxExtensionImpl): Ditto.

* Source/WebKit/UIProcess/mac/LegacySessionStateCoding.cpp:
(WebKit::HistoryEntryDataEncoder::operator<<): Use byteCast.
(WebKit::encodeLegacySessionState): Use checked_cf_cast.

* Source/WebKit/UIProcess/mac/LegacySessionStateCoding.cpp:
(WebKit::HistoryEntryDataEncoder::operator<<): Use byteCast.
* Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocket.cpp:
(WebKit::LibWebRTCSocket::signalReadPacket): Ditto.

* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::getAccessibilityTreeData): Use checked_cf_cast.

* Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::registerLogHook): Use byteCast.
* Source/WebKitLegacy/mac/Misc/WebNSDataExtras.mm:
(-[NSData _webkit_guessedMIMETypeForXML]): Ditto.

* Tools/TestWebKitAPI/Tests/WTF/StdLibExtrasTests.cpp:
(TestWebKitAPI::TEST(WTF_StdLibExtras, ByteCast)): Added some tests.

* Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp: Rewrite tests so it's easier
to see which one failed. Did not use byteCast here.

* Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp:
(TestWebKitAPI::TEST(WTF, StringImplEqualIgnoringASCIICaseBasic)): Ditto.
(TestWebKitAPI::TEST(WTF, StringImplEqualIgnoringASCIICaseWithEmpty)): Ditto.
(TestWebKitAPI::TEST(WTF, StringImplFindIgnoringASCIICaseOnEmpty)): Ditto.
(TestWebKitAPI::TEST(WTF, StringImplStartsWithIgnoringASCIICaseWithNull)): Ditto.
(TestWebKitAPI::TEST(WTF, StringImplStartsWithIgnoringASCIICaseWithEmpty)): Ditto.
(TestWebKitAPI::TEST(WTF, StringImplEndsWithIgnoringASCIICaseWithNull)): Ditto.
(TestWebKitAPI::TEST(WTF, StringImplEndsWithIgnoringASCIICaseWithEmpty)): Ditto.
* Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:
(TestWebKitAPI::TEST(WTF, StringViewEqualIgnoringASCIICaseBasic)): Ditto.
(TestWebKitAPI::TEST(WTF, StringViewEqualIgnoringASCIICaseWithEmpty)): Ditto.

* Tools/TestWebKitAPI/Tests/WebCore/CBORWriterTest.cpp:
(TestWebKitAPI::eq): Remomved unneeded reinterpret_cast.

* Tools/TestWebKitAPI/Tests/WebCore/SharedBuffer.cpp:
(TestWebKitAPI::TEST_F(FragmentedSharedBufferTest, getSomeData)): Use byteCast
and span instead of dataAsCharPtr.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm:
(TEST(WebKit, PDFLinkReferrer)): Use byteCast.

* Tools/TestWebKitAPI/cocoa/CGImagePixelReader.cpp:
(TestWebKitAPI::CGImagePixelReader::at const): Use static_cast instead of
reinterpret_cast.

* Tools/TestWebKitAPI/cocoa/HTTPServer.mm:
(TestWebKitAPI::proxyDefinition): Use byteCast.
(TestWebKitAPI::Connection::webSocketHandshake): Ditto.

Canonical link: https://commits.webkit.org/279338@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list