Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 277305bef9b08127390366a33d6e06281fa8cdab
      
https://github.com/WebKit/WebKit/commit/277305bef9b08127390366a33d6e06281fa8cdab
  Author: Anne van Kesteren <[email protected]>
  Date:   2026-10-08 (Thu, 08 Oct 2026)

  Changed paths:
    M Source/WTF/wtf/CheckedPtr.h
    M Source/WTF/wtf/CheckedRef.h
    M Source/WebCore/animation/AnimationTimelinesController.cpp
    M Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp
    M Source/WebCore/page/scrolling/ScrollAnchoringController.cpp
    M Source/WebCore/rendering/RenderListItem.cpp
    M Source/WebKit/UIProcess/Media/RemoteMediaSessionProxy.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Tools/TestWebKitAPI/Tests/WTF/CheckedPtr.cpp

  Log Message:
  -----------
  CheckedPtr and CheckedRef casts should return a smart pointer only for an 
rvalue
https://bugs.webkit.org/show_bug.cgi?id=326670
rdar://189406487

Reviewed by Chris Dumez.

CheckedPtr's downcast() overloads added in 307588@main return a reference built 
from a pointer,
so they fail to compile. So do the dynamicDowncast() overloads for a CheckedPtr 
or CheckedRef to
a const type, which drop the const from their result.

As WeakPtr and WeakRef do since 322963@main, return a raw pointer or reference 
for an lvalue,
also from dynamicDowncast(), which returned a CheckedPtr. The caller already 
holds a CheckedPtr
or CheckedRef, so another one would only add checked pointer count churn. For 
an rvalue, move the
count into the returned CheckedPtr or CheckedRef, so the object stays checked 
once the temporary
is gone; dynamicDowncast() leaves the source alone if the type does not match. 
Derive all result
types with match_constness_t, which makes the overloads for const types 
redundant, so remove
them.

Use -> in RemoteMediaSessionProxy and WebPage, which cast an rvalue CheckedRef, 
and drop .get()
from casts in AnimationTimelinesController, InlineItemsBuilder, RenderListItem 
and
ScrollAnchoringController.

Test: Tools/TestWebKitAPI/Tests/WTF/CheckedPtr.cpp
Canonical link: https://commits.webkit.org/323119@main



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

Reply via email to