[webkit-changes] [WebKit/WebKit] 361273: Add WKKeyedCoder as an alternate code path for Web...

Brady Eidson noreply at github.com
Wed Dec 6 23:49:49 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 361273dff3a1320574cb743de6930e21cbea87a6
      https://github.com/WebKit/WebKit/commit/361273dff3a1320574cb743de6930e21cbea87a6
  Author: Brady Eidson <beidson at apple.com>
  Date:   2023-12-06 (Wed, 06 Dec 2023)

  Changed paths:
    M Source/WebKit/DerivedSources-input.xcfilelist
    M Source/WebKit/DerivedSources.make
    M Source/WebKit/Scripts/generate-serializers.py
    M Source/WebKit/Scripts/webkit/tests/GeneratedSerializers.cpp
    M Source/WebKit/Scripts/webkit/tests/GeneratedSerializers.h
    M Source/WebKit/Scripts/webkit/tests/GeneratedWebKitSecureCoding.cpp
    M Source/WebKit/Scripts/webkit/tests/GeneratedWebKitSecureCoding.h
    M Source/WebKit/Scripts/webkit/tests/SerializedTypeInfo.cpp
    M Source/WebKit/Scripts/webkit/tests/TestSerializedType.serialization.in
    M Source/WebKit/Scripts/webkit/tests/WebKitPlatformGeneratedSerializers.cpp
    M Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.h
    M Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm
    A Source/WebKit/Shared/Cocoa/CoreIPCAVOutputContext.serialization.in
    M Source/WebKit/Shared/Cocoa/CoreIPCNSCFObject.h
    M Source/WebKit/Shared/Cocoa/CoreIPCNSCFObject.mm
    A Source/WebKit/Shared/Cocoa/WKKeyedCoder.h
    A Source/WebKit/Shared/Cocoa/WKKeyedCoder.mm
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    M Tools/TestWebKitAPI/Tests/IPC/IPCSerialization.mm

  Log Message:
  -----------
  Add WKKeyedCoder as an alternate code path for WebKit secure coding types (and use it to serialize AVOutputContext)
https://bugs.webkit.org/show_bug.cgi?id=265972
rdar://119279237

Reviewed by Alex Christensen.

For some types where adopting the WebKit property list format is slow-to-happen or not possible
(e.g. older operating systems) we can gather the equivalent property list ourselves with our own NSCoder.

WKKeyedCoder fills that role. It accumulates the key/value pairs encoded into an NSDictionary which
is then treated by the CoreIPC machinery as equivalent to a WebKit secure coding property list.

On the decode side, once validated like other WebKit property lists, it is used to recreate the object.

I chose a very simple first class to use this feature on - AVOutputContext and its (2) NSString members.
As we apply this strategy to more advanced classes we will also flesh out WKKeyedCoder's feature set.

* Source/WebKit/DerivedSources-input.xcfilelist:
* Source/WebKit/DerivedSources.make:
* Source/WebKit/Scripts/generate-serializers.py:
(SerializedType.__init__):
(generate_webkit_secure_coding_impl):
(generate_webkit_secure_coding_impl.is):
* Source/WebKit/Scripts/webkit/tests/GeneratedSerializers.cpp:
* Source/WebKit/Scripts/webkit/tests/GeneratedSerializers.h:
* Source/WebKit/Scripts/webkit/tests/GeneratedWebKitSecureCoding.cpp:
(WebKit::dictionaryForWebKitSecureCodingType):
(WebKit::CoreIPCAVOutputContext::CoreIPCAVOutputContext):
(WebKit::CoreIPCAVOutputContext::isValidDictionary):
(WebKit::CoreIPCAVOutputContext::toID const):
* Source/WebKit/Scripts/webkit/tests/GeneratedWebKitSecureCoding.h:
(WebKit::CoreIPCAVOutputContext::CoreIPCAVOutputContext):
* Source/WebKit/Scripts/webkit/tests/SerializedTypeInfo.cpp:
(WebKit::allSerializedTypes):
* Source/WebKit/Scripts/webkit/tests/TestSerializedType.serialization.in:
* Source/WebKit/Scripts/webkit/tests/WebKitPlatformGeneratedSerializers.cpp:
(IPC::ArgumentCoder<WebKit::CoreIPCAVOutputContext>::encode):
(IPC::ArgumentCoder<WebKit::CoreIPCAVOutputContext>::decode):
* Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.h:
* Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm:
(IPC::getClass<AVOutputContext>):
(IPC::typeFromObject):
* Source/WebKit/Shared/Cocoa/CoreIPCAVOutputContext.serialization.in: Added.
* Source/WebKit/Shared/Cocoa/CoreIPCNSCFObject.h:
* Source/WebKit/Shared/Cocoa/CoreIPCNSCFObject.mm:
(WebKit::valueFromID):
* Source/WebKit/Shared/Cocoa/WKKeyedCoder.h: Added.
* Source/WebKit/Shared/Cocoa/WKKeyedCoder.mm: Added.
(-[WKKeyedCoder init]):
(-[WKKeyedCoder initWithDictionary:]):
(-[WKKeyedCoder allowsKeyedCoding]):
(-[WKKeyedCoder encodeObject:forKey:]):
(-[WKKeyedCoder containsValueForKey:]):
(-[WKKeyedCoder decodeObjectOfClass:forKey:]):
(-[WKKeyedCoder decodeObjectForKey:]):
(-[WKKeyedCoder accumulatedDictionary]):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/IPC/IPCSerialization.mm:
(TEST):

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




More information about the webkit-changes mailing list