Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f2ca04538ea6d3a62bc93f351e248795229cb9a6
      
https://github.com/WebKit/WebKit/commit/f2ca04538ea6d3a62bc93f351e248795229cb9a6
  Author: Chris Dumez <[email protected]>
  Date:   2026-09-27 (Sun, 27 Sep 2026)

  Changed paths:
    M Source/WTF/wtf/Forward.h
    M Source/WTF/wtf/PrintStream.h
    M Source/WTF/wtf/text/CString.cpp
    M Source/WTF/wtf/text/CString.h
    M Source/WTF/wtf/text/StringConcatenate.h
    M Source/WTF/wtf/text/StringView.h
    M Source/WTF/wtf/text/TextStream.h
    M Source/WTF/wtf/text/WTFString.h
    M Source/WebCore/accessibility/AXLogger.h
    M Source/WebCore/contentextensions/ContentExtensionActions.cpp
    M Source/WebCore/platform/network/FormDataBuilder.cpp
    M Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
    M Tools/TestWebKitAPI/Tests/WTF/CString.cpp
    M Tools/TestWebKitAPI/Tests/WTF/cocoa/CStringCocoa.mm
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/glib/TestResources.cpp
    M Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.h
    M Tools/gdb/webkit.py

  Log Message:
  -----------
  Make CString usable only as the base of CStringWithEncoding and rename to 
CStringBase
https://bugs.webkit.org/show_bug.cgi?id=325361

Reviewed by Darin Adler.

Now that bytes only get into a CString through CStringWithEncoding, the 
remaining way
to hold an untyped CString is to slice one out of a typed string. Make its 
constructors,
assignment operators and destructor protected, so that it can no longer be 
created,
copied, moved or destroyed on its own. A const reference is now the only way to 
handle
one directly, which is what the encoding-agnostic helpers need. Protecting 
assignment also
stops a reference from relabeling the encoding of the string it refers to.

Rename the class to CStringBase to match what it now is. A follow-up will rename
CStringWithEncoding to CString.

The copy and move operations are defaulted explicitly: declaring the destructor 
would
otherwise remove the implicit moves and turn every typed-string move into a 
copy.

CString::newUninitialized() returned a CString by value, which a protected 
destructor
no longer allows. It becomes CStringBase::allocateUninitialized(), which fills 
in an
existing string, and the private CStringWithEncoding(CString&&) constructor 
that received
its result goes away. CStringHash, DefaultHash<CString> and HashTraits<CString> 
had no
users and are removed.

Comparing strings of different encodings is removed as well. Comparing two 
CStringBases
ignored their encodings, and nothing compares strings of different encodings, 
so the
comparison operators now require both sides to have the same encoding.

Swift cannot import a class with a protected destructor, so it no longer sees 
members
that CStringWithEncoding inherits from the base. CStringWithEncoding now 
forwards
toStdString(), which StdlibExtras.swift uses.

* Source/WTF/wtf/Forward.h:
* Source/WTF/wtf/PrintStream.h:
* Source/WTF/wtf/text/CString.cpp:
(WTF::CStringBase::CStringBase):
(WTF::CStringBase::init):
(WTF::CStringBase::allocateUninitialized):
(WTF::CStringBase::copyBufferIfNeeded):
(WTF::CStringBase::isSafeToSendToAnotherThread const):
(WTF::CStringBase::grow):
(WTF::operator==):
(WTF::CStringBase::hash const):
(WTF::operator<): Deleted.
(WTF::CString::CString): Deleted.
(WTF::CString::init): Deleted.
(WTF::CString::newUninitialized): Deleted.
(WTF::CString::copyBufferIfNeeded): Deleted.
(WTF::CString::isSafeToSendToAnotherThread const): Deleted.
(WTF::CString::grow): Deleted.
(WTF::CString::hash const): Deleted.
(WTF::CStringHash::equal): Deleted.
* Source/WTF/wtf/text/CString.h:
(WTF::CStringBase::CStringBase):
(WTF::CStringBase::length const):
(WTF::CStringBase::toStdString const):
(WTF::safePrintfType):
(WTF::CString::CString): Deleted.
(WTF::CString::isNull const): Deleted.
(WTF::CString::isEmpty const): Deleted.
(WTF::CString::isHashTableDeletedValue const): Deleted.
(WTF::CStringHash::hash): Deleted.
(WTF::CString::length const): Deleted.
(WTF::CString::toStdString const): Deleted.
* Source/WTF/wtf/text/StringConcatenate.h:
* Source/WTF/wtf/text/StringView.h:
* Source/WTF/wtf/text/TextStream.h:
* Source/WTF/wtf/text/WTFString.h:
* Source/WebCore/accessibility/AXLogger.h:
* Source/WebCore/contentextensions/ContentExtensionActions.cpp:
(WebCore::ContentExtensions::append):
(WebCore::ContentExtensions::RedirectAction::URLTransformAction::serialize 
const):
* Source/WebCore/platform/network/FormDataBuilder.cpp:
(WebCore::FormDataBuilder::append):
* Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp:
(WebCore::append):
* Tools/TestWebKitAPI/Tests/WTF/CString.cpp:
(TEST(WTF, CStringNullStringConstructor)):
(TEST(WTF, CStringLegacyCStringPointer)):
(TEST(WTF, CStringComparison)):
(TEST(WTF, CStringWithEncodingHashing)):
(TEST(WTF, CStringWithEncodingCrossEncodingComparison)): Deleted.
(TEST(WTF, CStringWithEncodingMakeString)):
(TEST(WTF, CStringWithEncodingPrintStream)):
* Tools/TestWebKitAPI/Tests/WTF/cocoa/CStringCocoa.mm:
(TestWebKitAPI::TEST(WTF, CStringWithEncodingCreateNSString)):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/glib/TestResources.cpp:
* Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.h:
(assertCmpCStringPointer):
* Tools/gdb/webkit.py:
(WTFCStringPrinter):
(add_pretty_printers):

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



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

Reply via email to