[webkit-changes] [WebKit/WebKit] f61eef: Fix WTF::HashSet<Class> and WTF::HashSet<RetainPtr...

Commit Queue noreply at github.com
Sat Aug 31 11:58:04 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f61eefa7dc8c4fa3576a0d10d06f523b7e907e9b
      https://github.com/WebKit/WebKit/commit/f61eefa7dc8c4fa3576a0d10d06f523b7e907e9b
  Author: David Kilzer <ddkilzer at apple.com>
  Date:   2024-08-31 (Sat, 31 Aug 2024)

  Changed paths:
    M Source/WTF/wtf/RetainPtr.h
    M Source/WebCore/platform/mac/SerializedPlatformDataCueMac.h
    M Source/WebCore/platform/mac/SerializedPlatformDataCueMac.mm
    M Source/WebKit/Platform/IPC/Decoder.h
    M Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.h
    M Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    M Tools/TestWebKitAPI/Tests/WTF/cf/RetainPtrHashing.cpp
    A Tools/TestWebKitAPI/Tests/WTF/cocoa/RetainPtrHashingCocoa.mm
    A Tools/TestWebKitAPI/Tests/WTF/cocoa/RetainPtrHashingCocoaARC.mm

  Log Message:
  -----------
  Fix WTF::HashSet<Class> and WTF::HashSet<RetainPtr<>> to work with ARC and upstream clang
<https://bugs.webkit.org/show_bug.cgi?id=278624>
<rdar://134591290>

Reviewed by Darin Adler.

Upstream clang makes Class objects participate in ARC, so
WTF::HashSet<Class> must be changed to WTF::HashSet<RetainPtr<Class>>.

However, WTF::HashSet<RetainPtr<>> doesn't currently work with ARC, so
that had to be fixed with casting changes to WTF::RetainPtr<>.

Also introduce IPC::AllowedClassHashSet to use a consistent type
everywhere (except WebCore::SerializedPlatformDataCueMac).

* Source/WTF/wtf/RetainPtr.h:
(WTF::RetainPtr::RetainPtr):
(WTF::RetainPtr::isHashTableDeletedValue const):
- Use toStorageType() to fix compilation with ARC.
(WTF::RetainPtr::hashTableDeletedValue):
- Use fromStorageType() with reinterpret_cast<CFTypeRef>() to create the
  deleted value.
(WTF::RetainPtr::fromStorageTypeHelper):
(WTF::RetainPtr::fromStorageType):
(WTF::RetainPtr::toStorageType):
- Change to static so they can be used from hashTableDeletedValue().

* Source/WebCore/platform/mac/SerializedPlatformDataCueMac.h:
* Source/WebCore/platform/mac/SerializedPlatformDataCueMac.mm:
(WebCore::SerializedPlatformDataCueMac::allowedClassesForNativeValues):
- Switch from WTF::HashSet<Class> to WTF::HashSet<RetainPtr<Class>> for
  future ARC conversion and to eliminate raw pointer use.

* Source/WebKit/Platform/IPC/Decoder.h:
(IPC::AllowedClassHashSet): Add.
- Define common type for HashSet<RetainPtr<Class>> and use in WebKit.
  This replaces HashSet<Class> since that no longer works with ARC.
(IPC::Decoder::decodeWithAllowedClasses):
(IPC::Decoder::allowedClasses):
- Make use of AllowedClassHashSet type.
* Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.h:
(IPC::isObjectClassAllowed):
- Make use of AllowedClassHashSet type, and update for loop to work with
  the new type.
* Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm:
(IPC::shouldEnableStrictMode):
(IPC::decodeObjectDirectlyRequiringAllowedClasses<NSObject<NSSecureCoding>>):
- Make use of AllowedClassHashSet type, and update for loop to work with
  the new type.

* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
- Add RetainPtrHashingCocoa[ARC].mm to the project.
* Tools/TestWebKitAPI/Tests/WTF/cf/RetainPtrHashing.cpp:
(TestWebKitAPI::TEST(RetainPtrHashing, HashSet)):
(TestWebKitAPI::TEST(RetainPtrHashing, HashMapKey)):
(TestWebKitAPI::TEST(RetainPtrHashing, HashMapValue)):
- Add more expectations to tests and fix header sort order.
* Tools/TestWebKitAPI/Tests/WTF/cocoa/RetainPtrHashingCocoa.mm: Copied from Tools/TestWebKitAPI/Tests/WTF/cf/RetainPtrHashing.cpp.
(TestWebKitAPI::TEST(RetainPtrHashingCocoa, HashSet)):
(TestWebKitAPI::TEST(RetainPtrHashingCocoa, HashMapKey)):
(TestWebKitAPI::TEST(RetainPtrHashingCocoa, HashMapValue)):
- Add tests for HashMap<RetainPtr<>> and HashSet<RetainPtr<>>.
* Tools/TestWebKitAPI/Tests/WTF/cocoa/RetainPtrHashingCocoaARC.mm: Add.
- Add tests for HashMap<RetainPtr<>> and HashSet<RetainPtr<>> under ARC.

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



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


More information about the webkit-changes mailing list