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

  Changed paths:
    M Source/WTF/wtf/UUID.h
    M Source/WebCore/dom/DocumentMarker.h
    M Source/WebCore/editing/Editor.cpp
    M Source/WebCore/page/ChromeClient.h
    M Source/WebCore/page/writing-tools/WritingToolsController.h
    M Source/WebCore/page/writing-tools/WritingToolsController.mm
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
    M Source/WebKit/WebProcess/WebPage/Cocoa/TextAnimationController.h
    M Source/WebKit/WebProcess/WebPage/Cocoa/TextAnimationController.mm
    M Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Tools/TestWebKitAPI/Tests/WTF/cocoa/UUIDCocoa.mm

  Log Message:
  -----------
  Make WTF::UUID's empty value unnameable outside HashTraits and MarkableTraits
https://bugs.webkit.org/show_bug.cgi?id=323944

Reviewed by Darin Adler.

TextAnimationData's UUID fields and WritingTools::Context::identifier are
Markable<WTF::UUID>, but several Writing Tools callers were constructing
WTF::UUID { WTF::UUID::emptyValue } (or WTF::UUID { 0 }) to mean "no UUID".
MarkableTraits<UUID>::isEmptyValue is !uuid, so such a value does not survive
as an engaged Markable holding zero — it silently becomes a disengaged one.
The call sites read as though they are passing a UUID when they are in fact
passing "absent", and nothing at the call site says so.

This expresses the absence in the type instead. Where the sentinel only ever
filled a slot that the callee ignores, it becomes Markable's empty state; the
two ChromeClient-boundary methods that had to carry it take Markable<WTF::UUID>
parameters, and the null check is folded into the early return that
TextAnimationController already performs for the equivalent empty-range case.
DocumentMarker's TransparentContentData::uuid becomes Markable for the same
reason, which also means an empty query UUID can no longer match a marker:
operator==(const Markable<T>&, const T&) is bool(x) && x.value() == v.

With the last producer gone, UUID adopts what ObjectIdentifier already does,
so the sentinel cannot be reintroduced. emptyValue and deletedValue become
private, which makes WTF::UUID(WTF::UUID::emptyValue) a compile error, and
the UInt128 constructor gains the validity assertion ObjectIdentifier's
uint64_t constructor has, which catches the WTF::UUID { 0 } spelling that
privatizing the constants does not. UUID(uint64_t, uint64_t) is tightened to
reject the empty value as well; it previously rejected only the deleted one.
Code that needs to express "no UUID" must now use Markable or std::optional.

Two deliberate exceptions. The std::span constructors keep taking arbitrary
bytes without assertion, because an all-zero UUID is real data there — FIDO
authenticators commonly report an all-zero AAGUID. And 
UUID(HashTableDeletedValueType)
stays public so composite types can build their own hash traits, as
PushSubscriptionSetIdentifier does; unlike the empty value it is not usable as
a "no UUID" sentinel, since Markable and HashTraits both treat it as engaged.

This is a step toward the property ObjectIdentifier already has: an invalid
value that cannot be constructed cannot be sent over IPC. UUID does not have it
yet — the std::span constructors above still accept arbitrary bytes — and
neither type validates on encode today; both rely on the decoder's validator at
their single ArgumentCoder bottleneck. Finishing this means either reworking the
three remaining span callers so UUID cannot hold an invalid value at all, or
teaching the serializer generator to assert on encode for types that declare a
Validator.

The generated IPC decoder for WTF::UUID runs its isValid validator before
constructing, so the tightened constructor is not reachable from a malformed
message. The silent Markable conversion this removes is what let an empty
unanimatedRangeUUID reach the UI process in
https://bugs.webkit.org/show_bug.cgi?id=323917. This change does not fix that
crash — the receiver-side check there is still required, since a compromised
or fuzzed web process can set the Markable's empty bit directly on the wire
regardless of what the sender's type permits.

* Source/WTF/wtf/UUID.h:
(WTF::UUID::UUID):
(WTF::UUID::isValid):
(WTF::MarkableTraits<UUID>::emptyValue):
* Source/WebCore/dom/DocumentMarker.h:
* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::selectionStartSetMarkerForTesting):
* Source/WebCore/page/ChromeClient.h:
(WebCore::ChromeClient::addDestinationTextAnimationForActiveWritingToolsSession):
* Source/WebCore/page/writing-tools/WritingToolsController.h:
* Source/WebCore/page/writing-tools/WritingToolsController.mm:
(WebCore::WritingToolsController::willBeginWritingToolsSession):
(WebCore::WritingToolsController::proofreadingSessionDidReceiveSuggestions):
(WebCore::WritingToolsController::smartReplySessionDidReceiveTextWithReplacementRange):
(WebCore::WritingToolsController::compositionSessionDidFinishReplacement):
(WebCore::WritingToolsController::compositionSessionDidReceiveTextWithReplacementRangeAsync):
(WebCore::WritingToolsController::compositionSessionDidReceiveTextWithReplacementRange):
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView addTextAnimationForAnimationID:withData:]):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::addDestinationTextAnimationForActiveWritingToolsSession):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:
* Source/WebKit/WebProcess/WebPage/Cocoa/TextAnimationController.h:
* Source/WebKit/WebProcess/WebPage/Cocoa/TextAnimationController.mm:
(WebKit::TextAnimationController::addSourceTextAnimationForActiveWritingToolsSession):
(WebKit::TextAnimationController::addDestinationTextAnimationForActiveWritingToolsSession):
* Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::addDestinationTextAnimationForActiveWritingToolsSession):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Tools/TestWebKitAPI/Tests/WTF/cocoa/UUIDCocoa.mm:
(TEST):

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



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

Reply via email to