Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 1ace22c8b2c0359734e1d71a1e23cc5b647eefee
https://github.com/WebKit/WebKit/commit/1ace22c8b2c0359734e1d71a1e23cc5b647eefee
Author: Anne van Kesteren <[email protected]>
Date: 2026-10-15 (Thu, 15 Oct 2026)
Changed paths:
M Source/WTF/wtf/TypeCasts.h
M Source/WTF/wtf/UniqueRef.h
M Source/WebCore/html/HTMLCanvasElement.cpp
M Source/WebCore/workers/WorkerOrWorkletThread.cpp
M Tools/Scripts/webkitpy/api_tests/allowlist.txt
M Tools/Scripts/webkitpy/style/checkers/cpp.py
M Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py
M Tools/TestWebKitAPI/Tests/WTF/UniqueRef.cpp
Log Message:
-----------
Allow casting a std::unique_ptr or UniqueRef without calling get()
https://bugs.webkit.org/show_bug.cgi?id=327673
rdar://190102641
Reviewed by Chris Dumez.
Casting a RefPtr, Ref, WeakPtr, WeakRef, CheckedPtr, or CheckedRef lvalue
returns what casting
its get() returns, but std::unique_ptr and UniqueRef only had is<>(), so their
callers still
write dynamicDowncast<T>(m_context.get()).
Add the same downcast<>(), dynamicDowncast<>(), and uncheckedDowncast<>()
overloads for a
std::unique_ptr lvalue, which return a pointer, and for a UniqueRef lvalue,
where downcast<>()
and uncheckedDowncast<>() return a reference. The cast result doesn't own the
object, so the
rvalue overloads are deleted rather than letting a temporary bind to the const
reference ones.
Drop get() from the casts in HTMLCanvasElement and WorkerOrWorkletThread, and
let
readability/redundant_get flag get() on a std::unique_ptr or UniqueRef passed
to these casts.
Test: Tools/TestWebKitAPI/Tests/WTF/UniqueRef.cpp
Canonical link: https://commits.webkit.org/323824@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications