Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 26dd620584929051fb686703df2da90997db739c
      
https://github.com/WebKit/WebKit/commit/26dd620584929051fb686703df2da90997db739c
  Author: Darin Adler <[email protected]>
  Date:   2025-11-24 (Mon, 24 Nov 2025)

  Changed paths:
    M Source/JavaScriptCore/API/JSStringRef.cpp
    M Source/JavaScriptCore/API/JSValue.mm
    M Source/JavaScriptCore/runtime/Identifier.h
    M Source/JavaScriptCore/runtime/Options.cpp
    M Source/JavaScriptCore/wasm/WasmParser.h
    M Source/WTF/wtf/FileSystem.cpp
    M Source/WTF/wtf/text/ASCIILiteral.h
    M Source/WTF/wtf/text/StringCommon.h
    M Source/WTF/wtf/text/StringConcatenate.h
    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/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp
    M Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm
    M Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp
    M Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp
    M Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp
    M Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h
    M Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
    M Source/WebKit/UIProcess/gtk/SystemSettingsManagerProxyGtk.cpp
    M Source/WebKit/WebProcess/GPU/media/RemoteVideoCodecFactory.cpp
    M 
Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/GObjectEventListener.cpp
    M Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/GObjectEventListener.h
    M Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
    M Tools/TestWebKitAPI/Tests/WTF/CString.cpp
    M Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp
    M Tools/TestWebKitAPI/Tests/WTF/StringCommon.cpp
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleEditingDelegatePlugIn.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm
    M Tools/TestWebKitAPI/Tests/mac/WebViewIconLoading.mm

  Log Message:
  -----------
  Streamline handling of null-terminated strings to improve clarity and safety
rdar://165305546
https://bugs.webkit.org/show_bug.cgi?id=303027

Reviewed by Sam Weinig.

Eliminated other members of the unsafeSpan function family, leaving only
unsafeSpan and unsafeSpanIncludingNullTerminator.

Eliminated some functions that take null-terminated strings, such as
String::createFromCString. Changed callers to safe interfaces that pass
lengths and sizes instead or to call unsafeSpan.

Redid the UTF-8 span literal operator so we can use it in constant expressions.
Syntax is now u8""_span instead of ""_spanChar8.

Simplified test code that was unnecessarily using null-terminated strings
to instead use ASCIILiteral or similar. Also used toNSData in test code
rather than toNSDataNoCopy; the "no copy" optimization is unnecessary for tests.

* Source/JavaScriptCore/API/JSStringRef.cpp:
(JSStringCreateWithUTF8CString): Use unsafeSpan. Use conversion from UTF-8
built into the String class. Take advantage of null handling built into the
function so we don't need a special case for the null pointer.

* Source/JavaScriptCore/API/JSValue.mm:
(createStructHandlerMap): Use unsafeSpan.

* Source/JavaScriptCore/runtime/Identifier.h: Removed overloads of
the == operator and the equal function that take null-terminated strings.

(JSC::Identifier::equal):
* Source/JavaScriptCore/runtime/Options.cpp:
(JSC::OptionsHelper::Option::dump const): Use unsafeSpan.

* Source/JavaScriptCore/wasm/WasmParser.h:
(JSC::Wasm::ParserBase::consumeUTF8String): Use byteCast.

* Source/WTF/wtf/FileSystem.cpp:
(WTF::FileSystemImpl::fromStdFileSystemPath): Use unsafeSpan.

* Source/WTF/wtf/text/ASCIILiteral.h: Added u8""_span. Removed ""_spanChar8.

* Source/WTF/wtf/text/StringCommon.h:
Deleted the unsafeSpan overload that takes const Latin1Character*.
(WTF::unsafeSpan8): Deleted.
(WTF::unsafeSpanChar8): Deleted.
(WTF::unsafeSpan8IncludingNullTerminator): Deleted.

* Source/WTF/wtf/text/StringConcatenate.h: Deleted the StringTypeAdapter
that takes const Latin1Character*.

* Source/WTF/wtf/text/StringImpl.h: Use unsafeSpan.
(WTF::StringImpl::createFromCString): Deleted.

* Source/WTF/wtf/text/StringView.h: Use unsafeSpan.
Replaced the equal function that takes const Latin1Character* with one
that takes span<const Latin1Character>.

* Source/WTF/wtf/text/WTFString.cpp:
(WTF::String::String): Use unsafeSpan.

* Source/WTF/wtf/text/WTFString.h: Use unsafeSpan.
Some updates to the fromUTF8 family of functions, clarifying deprecation.

* Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLANGLE::initialize): Use unsafeSpan.

* Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
(WebCore::initializeEGLDisplay): Use unsafeSpan.
(WebCore::GraphicsContextGLCocoa::platformInitializeContext): Ditto.

* Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp:
(WebCore::FontPlatformData::familyName const): Use unsafeSpan.

* Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp:
(WebCore::TrackPrivateBaseGStreamer::TrackPrivateBaseGStreamer): Use unsafeSpan.
(WebCore::TrackPrivateBaseGStreamer::setPad): Ditto.
(WebCore::TrackPrivateBaseGStreamer::getLanguageCode): Ditto.
(WebCore::TrackPrivateBaseGStreamer::notifyTrackOfStreamChanged): Ditto.
(WebCore::TrackPrivateBaseGStreamer::updateTrackIDFromTags): Ditto.

* Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp:
(WebCore::AppendPipeline::recycleTrackForPad): Use unsafeSpan.
(WebCore::serializeLowercase): Moved this function up in the file, changed it
to return ASCIILiteral, and made it a non-member function so it can be internal
to the file rather than in the header.
(WebCore::AppendPipeline::Track::emplaceOptionalElementsForFormat): Use
serializeLowercase.

* Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.h:
Removed now-unused streamTypeToStringLower.

* Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp:
(webkit_web_view_load_plain_text): Use unsafeSpan.

* Source/WebKit/UIProcess/gtk/SystemSettingsManagerProxyGtk.cpp:
(WebKit::SystemSettingsManagerProxy::updateFontProperties): Use unsafeSpan.

* Source/WebKit/WebProcess/GPU/media/RemoteVideoCodecFactory.cpp:
(WebKit::RemoteVideoCodecFactory::createEncoder): Use byteCast.

* Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/GObjectEventListener.cpp:
(WebKit::GObjectEventListener::GObjectEventListener): Store event type as
m_eventType AtomString instead of m_domEventName CString, previously we 
converted
it to an AtomString any time it is used. Also, used the term event type from
the DOM rather than coining a different name for the same concept.
(WebKit::GObjectEventListener::gobjectDestroyed): Use m_eventType.

* Source/WebKit/WebProcess/InjectedBundle/API/gtk/DOM/GObjectEventListener.h:
(WebKit::GObjectEventListener::addEventListener): Use m_eventType instead of
converting to AtomString.
(WebKit::GObjectEventListener::removeEventListener): Ditto.

* Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::accessibilityFocusedUIElement): Use 
unsafeSpanIncludingNullTerminator.

* Tools/TestWebKitAPI/Tests/WTF/CString.cpp:
(TEST(WTF, CStringViewASCIICaseConversions)): Use u8""_span.

* Tools/TestWebKitAPI/Tests/WTF/StringBuilder.cpp:
(TestWebKitAPI::TEST(StringBuilderTest, Append)): Use u8""_span.

* Tools/TestWebKitAPI/Tests/WTF/StringCommon.cpp:
(TestWebKitAPI::TEST(WTF_StringCommon, Equal)): Use u8""_span.
(TestWebKitAPI::TEST(WTF_StringCommon, EqualIgnoringASCIICase)): Ditto.
(TestWebKitAPI::TEST(WTF_StringCommon, StartsWith)): Ditto.
(TestWebKitAPI::TEST(WTF_StringCommon, EndsWith)): Ditto.
(TestWebKitAPI::TEST(WTF_StringCommon, Find)): Ditto.
(TestWebKitAPI::TEST(WTF_StringCommon, ReverseFind)): Ditto.
(TestWebKitAPI::TEST(WTF_StringCommon, Contains)): Ditto.
(TestWebKitAPI::TEST(WTF_StringCommon, StartsWithLettersIgnoringASCIICase)): 
Ditto.
(TestWebKitAPI::TEST(WTF_StringCommon, EndsWithLettersIgnoringASCIICase)): 
Ditto.
(TestWebKitAPI::TEST(WTF_StringCommon, FindIgnoringASCIICase)): Ditto.
(TestWebKitAPI::TEST(WTF_StringCommon, ContainsIgnoringASCIICase)): Ditto.
(TestWebKitAPI::TEST(WTF_StringCommon, CharactersAreAllASCII)): Ditto.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleEditingDelegatePlugIn.mm:
(-[BundleEditingDelegatePlugIn 
_webProcessPlugInBrowserContextController:pasteboardDataForRange:]):
Use [NSData dataUsingEncoding:].

* Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
(-[PSONScheme initWithBytes:]): Use ASCIILiteral.
(-[PSONScheme addMappingFromURLString:toData:]): Ditto.
(-[PSONScheme webView:startURLSchemeTask:]): Ditto.
((ProcessSwap, HistoryNavigationToFragmentURL)): Ditto.
((ProcessSwap, PolicyCancelAfterServerRedirect)): Ditto.
((ProcessSwap, SameOriginSystemPreview)): Ditto.
((ProcessSwap, SessionStorage)): Ditto.
((ProcessSwap, ReuseSuspendedProcessEvenIfPageCacheFails)): Ditto.
((ProcessSwap, HistoryItemIDConfusion)): Ditto.
((ProcessSwap, MainFramesOnly)): Ditto.
((ProcessSwap, MediaTypeAfterSwap)): Ditto.
((ProcessSwap, NavigateCrossSiteBeforePageLoadEnd)): Ditto.
((ProcessSwap, PageShowHide)): Ditto.
((ProcessSwap, LoadUnload)): Ditto.
((ProcessSwap, SameOriginBlobNavigation)): Ditto.
((ProcessSwap, NavigateToDataURLThenBack)): Ditto.
((ProcessSwap, SwapOnFormSubmission)): Ditto.
((ProcessSwap, OpenerLinkAfterAPIControlledProcessSwappingOfOpener)): Ditto.
((ProcessSwap, NavigateCrossOriginWithOpener)): Ditto.
((ProcessSwap, ContentBlockingAfterProcessSwap)): Ditto.
((ProcessSwap, ContentExtensionBlocksMainLoadThenReloadWithoutExtensions)): 
Ditto.
((ProcessSwap, GetUserMediaCaptureState)): Ditto.
((ProcessSwap, PassMinimumDeviceWidthOnNewWebView)): Ditto.
((ProcessSwap, ResizeWebViewDuringCrossSiteProvisionalNavigation)): Ditto.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
(-[ServiceWorkerSchemeHandler webView:startURLSchemeTask:]): Use unsafeSpan.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:
(mainBytesData): Added.
(TEST(URLSchemeHandler, Basic)): Use ASCIILiteral.
(TEST(URLSchemeHandler, BasicWithHTTPS)): Ditto.
(TEST(URLSchemeHandler, BasicWithAsyncPolicyDelegate)): Ditto.
(TEST(URLSchemeHandler, NoMIMEType)): Ditto.
(-[SyncScheme webView:startURLSchemeTask:]): Ditto.
(-[SyncErrorScheme webView:startURLSchemeTask:]): Ditto.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm:
(-[DataMappingSchemeHandler addMappingFromURLString:toData:]): Use ASCIILiteral.
((WebpagePreferences, WebsitePoliciesCustomUserAgent)): Ditto.

* Tools/TestWebKitAPI/Tests/mac/WebViewIconLoading.mm:
(mainResourceData): Use ASCIILiteral.
(imageFromData): Ditto.
(TestWebKitAPI::TEST(WebKitLegacy, IconLoadingDelegateDefaultFirst)): Ditto.
(TestWebKitAPI::TEST(WebKitLegacy, IconLoadingDelegateCustomFirst)): Ditto.

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



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

Reply via email to