Move URL from WebCore to WTF
[WebKit-https.git] / Source / WebKit / Shared / WebCoreArgumentCoders.cpp
index 130d63d..66ffe91 100644 (file)
 
 #include "DataReference.h"
 #include "ShareableBitmap.h"
+#include "SharedBufferDataReference.h"
 #include <WebCore/AuthenticationChallenge.h>
 #include <WebCore/BlobPart.h>
+#include <WebCore/CacheQueryOptions.h>
 #include <WebCore/CertificateInfo.h>
 #include <WebCore/CompositionUnderline.h>
 #include <WebCore/Credential.h>
 #include <WebCore/Cursor.h>
+#include <WebCore/DataListSuggestionPicker.h>
 #include <WebCore/DatabaseDetails.h>
 #include <WebCore/DictationAlternative.h>
 #include <WebCore/DictionaryPopupInfo.h>
 #include <WebCore/DragData.h>
 #include <WebCore/EventTrackingRegions.h>
+#include <WebCore/FetchOptions.h>
 #include <WebCore/FileChooser.h>
 #include <WebCore/FilterOperation.h>
 #include <WebCore/FilterOperations.h>
+#include <WebCore/FontAttributes.h>
 #include <WebCore/GraphicsContext.h>
 #include <WebCore/GraphicsLayer.h>
 #include <WebCore/IDBGetResult.h>
 #include <WebCore/Length.h>
 #include <WebCore/LengthBox.h>
 #include <WebCore/MediaSelectionOption.h>
+#include <WebCore/Pasteboard.h>
 #include <WebCore/Path.h>
 #include <WebCore/PluginData.h>
+#include <WebCore/PromisedAttachmentInfo.h>
 #include <WebCore/ProtectionSpace.h>
+#include <WebCore/RectEdges.h>
 #include <WebCore/Region.h>
 #include <WebCore/ResourceError.h>
 #include <WebCore/ResourceLoadStatistics.h>
 #include <WebCore/ScrollingConstraints.h>
 #include <WebCore/ScrollingCoordinator.h>
 #include <WebCore/SearchPopupMenu.h>
-#include <WebCore/SessionID.h>
+#include <WebCore/SecurityOrigin.h>
+#include <WebCore/SerializedAttachmentData.h>
+#include <WebCore/ServiceWorkerClientData.h>
+#include <WebCore/ServiceWorkerClientIdentifier.h>
+#include <WebCore/ServiceWorkerData.h>
+#include <WebCore/ShareData.h>
 #include <WebCore/TextCheckerClient.h>
 #include <WebCore/TextIndicator.h>
 #include <WebCore/TimingFunction.h>
 #include <WebCore/TransformationMatrix.h>
-#include <WebCore/URL.h>
 #include <WebCore/UserStyleSheet.h>
 #include <WebCore/ViewportArguments.h>
 #include <WebCore/WindowFeatures.h>
-#include <wtf/MonotonicTime.h>
-#include <wtf/Seconds.h>
+#include <pal/SessionID.h>
+#include <wtf/URL.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringHash.h>
 
 #include "ArgumentCodersMac.h"
 #endif
 
-#if PLATFORM(IOS)
+#if PLATFORM(IOS_FAMILY)
 #include <WebCore/FloatQuad.h>
 #include <WebCore/InspectorOverlay.h>
 #include <WebCore/SelectionRect.h>
 #include <WebCore/SharedBuffer.h>
-#endif // PLATFORM(IOS)
-
-#if PLATFORM(IOS) || PLATFORM(WPE)
-#include <WebCore/Pasteboard.h>
-#endif
+#endif // PLATFORM(IOS_FAMILY)
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
 #include <WebCore/MediaPlaybackTargetContext.h>
@@ -109,33 +117,63 @@ using namespace WebKit;
 
 namespace IPC {
 
-void ArgumentCoder<MonotonicTime>::encode(Encoder& encoder, const MonotonicTime& time)
+static void encodeSharedBuffer(Encoder& encoder, const SharedBuffer* buffer)
 {
-    encoder << time.secondsSinceEpoch().value();
+    SharedMemory::Handle handle;
+    uint64_t bufferSize = buffer ? buffer->size() : 0;
+    encoder << bufferSize;
+    if (!bufferSize)
+        return;
+
+    auto sharedMemoryBuffer = SharedMemory::allocate(buffer->size());
+    memcpy(sharedMemoryBuffer->data(), buffer->data(), buffer->size());
+    sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly);
+    encoder << handle;
 }
 
-bool ArgumentCoder<MonotonicTime>::decode(Decoder& decoder, MonotonicTime& time)
+static bool decodeSharedBuffer(Decoder& decoder, RefPtr<SharedBuffer>& buffer)
 {
-    double value;
-    if (!decoder.decode(value))
+    uint64_t bufferSize = 0;
+    if (!decoder.decode(bufferSize))
         return false;
 
-    time = MonotonicTime::fromRawSeconds(value);
+    if (!bufferSize)
+        return true;
+
+    SharedMemory::Handle handle;
+    if (!decoder.decode(handle))
+        return false;
+
+    auto sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly);
+    buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), bufferSize);
+
     return true;
 }
 
-void ArgumentCoder<Seconds>::encode(Encoder& encoder, const Seconds& seconds)
+static void encodeTypesAndData(Encoder& encoder, const Vector<String>& types, const Vector<RefPtr<SharedBuffer>>& data)
 {
-    encoder << seconds.value();
+    ASSERT(types.size() == data.size());
+    encoder << types;
+    encoder << static_cast<uint64_t>(data.size());
+    for (auto& buffer : data)
+        encodeSharedBuffer(encoder, buffer.get());
 }
 
-bool ArgumentCoder<Seconds>::decode(Decoder& decoder, Seconds& seconds)
+static bool decodeTypesAndData(Decoder& decoder, Vector<String>& types, Vector<RefPtr<SharedBuffer>>& data)
 {
-    double value;
-    if (!decoder.decode(value))
+    if (!decoder.decode(types))
         return false;
 
-    seconds = Seconds(value);
+    uint64_t dataSize;
+    if (!decoder.decode(dataSize))
+        return false;
+
+    ASSERT(dataSize == types.size());
+
+    data.resize(dataSize);
+    for (auto& buffer : data)
+        decodeSharedBuffer(decoder, buffer);
+
     return true;
 }
 
@@ -149,6 +187,149 @@ bool ArgumentCoder<AffineTransform>::decode(Decoder& decoder, AffineTransform& a
     return SimpleArgumentCoder<AffineTransform>::decode(decoder, affineTransform);
 }
 
+void ArgumentCoder<CacheQueryOptions>::encode(Encoder& encoder, const CacheQueryOptions& options)
+{
+    encoder << options.ignoreSearch;
+    encoder << options.ignoreMethod;
+    encoder << options.ignoreVary;
+    encoder << options.cacheName;
+}
+
+bool ArgumentCoder<CacheQueryOptions>::decode(Decoder& decoder, CacheQueryOptions& options)
+{
+    bool ignoreSearch;
+    if (!decoder.decode(ignoreSearch))
+        return false;
+    bool ignoreMethod;
+    if (!decoder.decode(ignoreMethod))
+        return false;
+    bool ignoreVary;
+    if (!decoder.decode(ignoreVary))
+        return false;
+    String cacheName;
+    if (!decoder.decode(cacheName))
+        return false;
+
+    options.ignoreSearch = ignoreSearch;
+    options.ignoreMethod = ignoreMethod;
+    options.ignoreVary = ignoreVary;
+    options.cacheName = WTFMove(cacheName);
+    return true;
+}
+
+void ArgumentCoder<DOMCacheEngine::CacheInfo>::encode(Encoder& encoder, const DOMCacheEngine::CacheInfo& info)
+{
+    encoder << info.identifier;
+    encoder << info.name;
+}
+
+auto ArgumentCoder<DOMCacheEngine::CacheInfo>::decode(Decoder& decoder) -> std::optional<DOMCacheEngine::CacheInfo>
+{
+    std::optional<uint64_t> identifier;
+    decoder >> identifier;
+    if (!identifier)
+        return std::nullopt;
+    
+    std::optional<String> name;
+    decoder >> name;
+    if (!name)
+        return std::nullopt;
+    
+    return {{ WTFMove(*identifier), WTFMove(*name) }};
+}
+
+void ArgumentCoder<DOMCacheEngine::Record>::encode(Encoder& encoder, const DOMCacheEngine::Record& record)
+{
+    encoder << record.identifier;
+
+    encoder << record.requestHeadersGuard;
+    encoder << record.request;
+    encoder << record.options;
+    encoder << record.referrer;
+
+    encoder << record.responseHeadersGuard;
+    encoder << record.response;
+    encoder << record.updateResponseCounter;
+    encoder << record.responseBodySize;
+
+    WTF::switchOn(record.responseBody, [&](const Ref<SharedBuffer>& buffer) {
+        encoder << true;
+        encodeSharedBuffer(encoder, buffer.ptr());
+    }, [&](const Ref<FormData>& formData) {
+        encoder << false;
+        encoder << true;
+        formData->encode(encoder);
+    }, [&](const std::nullptr_t&) {
+        encoder << false;
+        encoder << false;
+    });
+}
+
+std::optional<DOMCacheEngine::Record> ArgumentCoder<DOMCacheEngine::Record>::decode(Decoder& decoder)
+{
+    uint64_t identifier;
+    if (!decoder.decode(identifier))
+        return std::nullopt;
+
+    FetchHeaders::Guard requestHeadersGuard;
+    if (!decoder.decode(requestHeadersGuard))
+        return std::nullopt;
+
+    WebCore::ResourceRequest request;
+    if (!decoder.decode(request))
+        return std::nullopt;
+
+    std::optional<WebCore::FetchOptions> options;
+    decoder >> options;
+    if (!options)
+        return std::nullopt;
+
+    String referrer;
+    if (!decoder.decode(referrer))
+        return std::nullopt;
+
+    FetchHeaders::Guard responseHeadersGuard;
+    if (!decoder.decode(responseHeadersGuard))
+        return std::nullopt;
+
+    WebCore::ResourceResponse response;
+    if (!decoder.decode(response))
+        return std::nullopt;
+
+    uint64_t updateResponseCounter;
+    if (!decoder.decode(updateResponseCounter))
+        return std::nullopt;
+
+    uint64_t responseBodySize;
+    if (!decoder.decode(responseBodySize))
+        return std::nullopt;
+
+    WebCore::DOMCacheEngine::ResponseBody responseBody;
+    bool hasSharedBufferBody;
+    if (!decoder.decode(hasSharedBufferBody))
+        return std::nullopt;
+
+    if (hasSharedBufferBody) {
+        RefPtr<SharedBuffer> buffer;
+        if (!decodeSharedBuffer(decoder, buffer))
+            return std::nullopt;
+        if (buffer)
+            responseBody = buffer.releaseNonNull();
+    } else {
+        bool hasFormDataBody;
+        if (!decoder.decode(hasFormDataBody))
+            return std::nullopt;
+        if (hasFormDataBody) {
+            auto formData = FormData::decode(decoder);
+            if (!formData)
+                return std::nullopt;
+            responseBody = formData.releaseNonNull();
+        }
+    }
+
+    return {{ WTFMove(identifier), WTFMove(updateResponseCounter), WTFMove(requestHeadersGuard), WTFMove(request), WTFMove(options.value()), WTFMove(referrer), WTFMove(responseHeadersGuard), WTFMove(response), WTFMove(responseBody), responseBodySize }};
+}
+
 void ArgumentCoder<EventTrackingRegions>::encode(Encoder& encoder, const EventTrackingRegions& eventTrackingRegions)
 {
     encoder << eventTrackingRegions.asynchronousDispatchRegion;
@@ -370,6 +551,13 @@ bool ArgumentCoder<FloatPoint>::decode(Decoder& decoder, FloatPoint& floatPoint)
     return SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint);
 }
 
+std::optional<FloatPoint> ArgumentCoder<FloatPoint>::decode(Decoder& decoder)
+{
+    FloatPoint floatPoint;
+    if (!SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint))
+        return std::nullopt;
+    return WTFMove(floatPoint);
+}
 
 void ArgumentCoder<FloatPoint3D>::encode(Encoder& encoder, const FloatPoint3D& floatPoint)
 {
@@ -392,6 +580,14 @@ bool ArgumentCoder<FloatRect>::decode(Decoder& decoder, FloatRect& floatRect)
     return SimpleArgumentCoder<FloatRect>::decode(decoder, floatRect);
 }
 
+std::optional<FloatRect> ArgumentCoder<FloatRect>::decode(Decoder& decoder)
+{
+    FloatRect floatRect;
+    if (!SimpleArgumentCoder<FloatRect>::decode(decoder, floatRect))
+        return std::nullopt;
+    return WTFMove(floatRect);
+}
+
 
 void ArgumentCoder<FloatBoxExtent>::encode(Encoder& encoder, const FloatBoxExtent& floatBoxExtent)
 {
@@ -425,15 +621,18 @@ bool ArgumentCoder<FloatRoundedRect>::decode(Decoder& decoder, FloatRoundedRect&
     return SimpleArgumentCoder<FloatRoundedRect>::decode(decoder, roundedRect);
 }
 
-#if PLATFORM(IOS)
+#if PLATFORM(IOS_FAMILY)
 void ArgumentCoder<FloatQuad>::encode(Encoder& encoder, const FloatQuad& floatQuad)
 {
     SimpleArgumentCoder<FloatQuad>::encode(encoder, floatQuad);
 }
 
-bool ArgumentCoder<FloatQuad>::decode(Decoder& decoder, FloatQuad& floatQuad)
+std::optional<FloatQuad> ArgumentCoder<FloatQuad>::decode(Decoder& decoder)
 {
-    return SimpleArgumentCoder<FloatQuad>::decode(decoder, floatQuad);
+    FloatQuad floatQuad;
+    if (!SimpleArgumentCoder<FloatQuad>::decode(decoder, floatQuad))
+        return std::nullopt;
+    return WTFMove(floatQuad);
 }
 
 void ArgumentCoder<ViewportArguments>::encode(Encoder& encoder, const ViewportArguments& viewportArguments)
@@ -445,7 +644,15 @@ bool ArgumentCoder<ViewportArguments>::decode(Decoder& decoder, ViewportArgument
 {
     return SimpleArgumentCoder<ViewportArguments>::decode(decoder, viewportArguments);
 }
-#endif // PLATFORM(IOS)
+
+std::optional<ViewportArguments> ArgumentCoder<ViewportArguments>::decode(Decoder& decoder)
+{
+    ViewportArguments viewportArguments;
+    if (!SimpleArgumentCoder<ViewportArguments>::decode(decoder, viewportArguments))
+        return std::nullopt;
+    return WTFMove(viewportArguments);
+}
+#endif // PLATFORM(IOS_FAMILY)
 
 
 void ArgumentCoder<IntPoint>::encode(Encoder& encoder, const IntPoint& intPoint)
@@ -458,6 +665,13 @@ bool ArgumentCoder<IntPoint>::decode(Decoder& decoder, IntPoint& intPoint)
     return SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint);
 }
 
+std::optional<WebCore::IntPoint> ArgumentCoder<IntPoint>::decode(Decoder& decoder)
+{
+    IntPoint intPoint;
+    if (!SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint))
+        return std::nullopt;
+    return WTFMove(intPoint);
+}
 
 void ArgumentCoder<IntRect>::encode(Encoder& encoder, const IntRect& intRect)
 {
@@ -469,6 +683,13 @@ bool ArgumentCoder<IntRect>::decode(Decoder& decoder, IntRect& intRect)
     return SimpleArgumentCoder<IntRect>::decode(decoder, intRect);
 }
 
+std::optional<IntRect> ArgumentCoder<IntRect>::decode(Decoder& decoder)
+{
+    IntRect rect;
+    if (!decode(decoder, rect))
+        return std::nullopt;
+    return WTFMove(rect);
+}
 
 void ArgumentCoder<IntSize>::encode(Encoder& encoder, const IntSize& intSize)
 {
@@ -480,6 +701,13 @@ bool ArgumentCoder<IntSize>::decode(Decoder& decoder, IntSize& intSize)
     return SimpleArgumentCoder<IntSize>::decode(decoder, intSize);
 }
 
+std::optional<IntSize> ArgumentCoder<IntSize>::decode(Decoder& decoder)
+{
+    IntSize intSize;
+    if (!SimpleArgumentCoder<IntSize>::decode(decoder, intSize))
+        return std::nullopt;
+    return WTFMove(intSize);
+}
 
 void ArgumentCoder<LayoutSize>::encode(Encoder& encoder, const LayoutSize& layoutSize)
 {
@@ -608,25 +836,38 @@ bool ArgumentCoder<Path>::decode(Decoder& decoder, Path& path)
     return true;
 }
 
+std::optional<Path> ArgumentCoder<Path>::decode(Decoder& decoder)
+{
+    Path path;
+    if (!decode(decoder, path))
+        return std::nullopt;
+
+    return path;
+}
+
 void ArgumentCoder<RecentSearch>::encode(Encoder& encoder, const RecentSearch& recentSearch)
 {
     encoder << recentSearch.string << recentSearch.time;
 }
 
-bool ArgumentCoder<RecentSearch>::decode(Decoder& decoder, RecentSearch& recentSearch)
+std::optional<RecentSearch> ArgumentCoder<RecentSearch>::decode(Decoder& decoder)
 {
-    if (!decoder.decode(recentSearch.string))
-        return false;
-
-    if (!decoder.decode(recentSearch.time))
-        return false;
-
-    return true;
+    std::optional<String> string;
+    decoder >> string;
+    if (!string)
+        return std::nullopt;
+    
+    std::optional<WallTime> time;
+    decoder >> time;
+    if (!time)
+        return std::nullopt;
+    
+    return {{ WTFMove(*string), WTFMove(*time) }};
 }
 
 template<> struct ArgumentCoder<Region::Span> {
     static void encode(Encoder&, const Region::Span&);
-    static bool decode(Decoder&, Region::Span&);
+    static std::optional<Region::Span> decode(Decoder&);
 };
 
 void ArgumentCoder<Region::Span>::encode(Encoder& encoder, const Region::Span& span)
@@ -635,17 +876,18 @@ void ArgumentCoder<Region::Span>::encode(Encoder& encoder, const Region::Span& s
     encoder << (uint64_t)span.segmentIndex;
 }
 
-bool ArgumentCoder<Region::Span>::decode(Decoder& decoder, Region::Span& span)
+std::optional<Region::Span> ArgumentCoder<Region::Span>::decode(Decoder& decoder)
 {
+    Region::Span span;
     if (!decoder.decode(span.y))
-        return false;
+        return std::nullopt;
     
     uint64_t segmentIndex;
     if (!decoder.decode(segmentIndex))
-        return false;
+        return std::nullopt;
     
     span.segmentIndex = segmentIndex;
-    return true;
+    return WTFMove(span);
 }
 
 void ArgumentCoder<Region>::encode(Encoder& encoder, const Region& region)
@@ -701,16 +943,17 @@ void ArgumentCoder<MimeClassInfo>::encode(Encoder& encoder, const MimeClassInfo&
     encoder << mimeClassInfo.type << mimeClassInfo.desc << mimeClassInfo.extensions;
 }
 
-bool ArgumentCoder<MimeClassInfo>::decode(Decoder& decoder, MimeClassInfo& mimeClassInfo)
+std::optional<MimeClassInfo> ArgumentCoder<MimeClassInfo>::decode(Decoder& decoder)
 {
+    MimeClassInfo mimeClassInfo;
     if (!decoder.decode(mimeClassInfo.type))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(mimeClassInfo.desc))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(mimeClassInfo.extensions))
-        return false;
+        return std::nullopt;
 
-    return true;
+    return WTFMove(mimeClassInfo);
 }
 
 
@@ -722,34 +965,35 @@ void ArgumentCoder<PluginInfo>::encode(Encoder& encoder, const PluginInfo& plugi
     encoder << pluginInfo.mimes;
     encoder << pluginInfo.isApplicationPlugin;
     encoder.encodeEnum(pluginInfo.clientLoadPolicy);
-#if PLATFORM(MAC)
     encoder << pluginInfo.bundleIdentifier;
+#if PLATFORM(MAC)
     encoder << pluginInfo.versionString;
 #endif
 }
 
-bool ArgumentCoder<PluginInfo>::decode(Decoder& decoder, PluginInfo& pluginInfo)
+std::optional<WebCore::PluginInfo> ArgumentCoder<PluginInfo>::decode(Decoder& decoder)
 {
+    PluginInfo pluginInfo;
     if (!decoder.decode(pluginInfo.name))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(pluginInfo.file))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(pluginInfo.desc))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(pluginInfo.mimes))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(pluginInfo.isApplicationPlugin))
-        return false;
+        return std::nullopt;
     if (!decoder.decodeEnum(pluginInfo.clientLoadPolicy))
-        return false;
-#if PLATFORM(MAC)
+        return std::nullopt;
     if (!decoder.decode(pluginInfo.bundleIdentifier))
-        return false;
+        return std::nullopt;
+#if PLATFORM(MAC)
     if (!decoder.decode(pluginInfo.versionString))
-        return false;
+        return std::nullopt;
 #endif
 
-    return true;
+    return WTFMove(pluginInfo);
 }
 
 void ArgumentCoder<AuthenticationChallenge>::encode(Encoder& encoder, const AuthenticationChallenge& challenge)
@@ -871,7 +1115,7 @@ bool ArgumentCoder<Credential>::decode(Decoder& decoder, Credential& credential)
 
 static void encodeImage(Encoder& encoder, Image& image)
 {
-    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), ShareableBitmap::SupportsAlpha);
+    RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(IntSize(image.size()), { });
     bitmap->createGraphicsContext()->drawImage(image, IntPoint());
 
     ShareableBitmap::Handle handle;
@@ -918,7 +1162,7 @@ static bool decodeOptionalImage(Decoder& decoder, RefPtr<Image>& image)
     return decodeImage(decoder, image);
 }
 
-#if !PLATFORM(IOS)
+#if !PLATFORM(IOS_FAMILY)
 void ArgumentCoder<Cursor>::encode(Encoder& encoder, const Cursor& cursor)
 {
     encoder.encodeEnum(cursor.type());
@@ -996,6 +1240,14 @@ void ArgumentCoder<ResourceRequest>::encode(Encoder& encoder, const ResourceRequ
     encoder << resourceRequest.cachePartition();
     encoder << resourceRequest.hiddenFromInspector();
 
+#if USE(SYSTEM_PREVIEW)
+    if (resourceRequest.isSystemPreview()) {
+        encoder << true;
+        encoder << resourceRequest.systemPreviewRect();
+    } else
+        encoder << false;
+#endif
+
     if (resourceRequest.encodingRequiresPlatformData()) {
         encoder << true;
         encodePlatformData(encoder, resourceRequest);
@@ -1017,6 +1269,20 @@ bool ArgumentCoder<ResourceRequest>::decode(Decoder& decoder, ResourceRequest& r
         return false;
     resourceRequest.setHiddenFromInspector(isHiddenFromInspector);
 
+#if USE(SYSTEM_PREVIEW)
+    bool isSystemPreview;
+    if (!decoder.decode(isSystemPreview))
+        return false;
+    resourceRequest.setSystemPreview(isSystemPreview);
+
+    if (isSystemPreview) {
+        IntRect systemPreviewRect;
+        if (!decoder.decode(systemPreviewRect))
+            return false;
+        resourceRequest.setSystemPreviewRect(systemPreviewRect);
+    }
+#endif
+
     bool hasPlatformData;
     if (!decoder.decode(hasPlatformData))
         return false;
@@ -1028,15 +1294,31 @@ bool ArgumentCoder<ResourceRequest>::decode(Decoder& decoder, ResourceRequest& r
 
 void ArgumentCoder<ResourceError>::encode(Encoder& encoder, const ResourceError& resourceError)
 {
+    encoder.encodeEnum(resourceError.type());
+    if (resourceError.type() == ResourceError::Type::Null)
+        return;
     encodePlatformData(encoder, resourceError);
 }
 
 bool ArgumentCoder<ResourceError>::decode(Decoder& decoder, ResourceError& resourceError)
 {
-    return decodePlatformData(decoder, resourceError);
+    ResourceError::Type type;
+    if (!decoder.decodeEnum(type))
+        return false;
+
+    if (type == ResourceError::Type::Null) {
+        resourceError = { };
+        return true;
+    }
+
+    if (!decodePlatformData(decoder, resourceError))
+        return false;
+
+    resourceError.setType(type);
+    return true;
 }
 
-#if PLATFORM(IOS)
+#if PLATFORM(IOS_FAMILY)
 
 void ArgumentCoder<SelectionRect>::encode(Encoder& encoder, const SelectionRect& selectionRect)
 {
@@ -1054,61 +1336,62 @@ void ArgumentCoder<SelectionRect>::encode(Encoder& encoder, const SelectionRect&
     encoder << selectionRect.isHorizontal();
 }
 
-bool ArgumentCoder<SelectionRect>::decode(Decoder& decoder, SelectionRect& selectionRect)
+std::optional<SelectionRect> ArgumentCoder<SelectionRect>::decode(Decoder& decoder)
 {
+    SelectionRect selectionRect;
     IntRect rect;
     if (!decoder.decode(rect))
-        return false;
+        return std::nullopt;
     selectionRect.setRect(rect);
 
     uint32_t direction;
     if (!decoder.decode(direction))
-        return false;
+        return std::nullopt;
     selectionRect.setDirection((TextDirection)direction);
 
     int intValue;
     if (!decoder.decode(intValue))
-        return false;
+        return std::nullopt;
     selectionRect.setMinX(intValue);
 
     if (!decoder.decode(intValue))
-        return false;
+        return std::nullopt;
     selectionRect.setMaxX(intValue);
 
     if (!decoder.decode(intValue))
-        return false;
+        return std::nullopt;
     selectionRect.setMaxY(intValue);
 
     if (!decoder.decode(intValue))
-        return false;
+        return std::nullopt;
     selectionRect.setLineNumber(intValue);
 
     bool boolValue;
     if (!decoder.decode(boolValue))
-        return false;
+        return std::nullopt;
     selectionRect.setIsLineBreak(boolValue);
 
     if (!decoder.decode(boolValue))
-        return false;
+        return std::nullopt;
     selectionRect.setIsFirstOnLine(boolValue);
 
     if (!decoder.decode(boolValue))
-        return false;
+        return std::nullopt;
     selectionRect.setIsLastOnLine(boolValue);
 
     if (!decoder.decode(boolValue))
-        return false;
+        return std::nullopt;
     selectionRect.setContainsStart(boolValue);
 
     if (!decoder.decode(boolValue))
-        return false;
+        return std::nullopt;
     selectionRect.setContainsEnd(boolValue);
 
     if (!decoder.decode(boolValue))
-        return false;
+        return std::nullopt;
     selectionRect.setIsHorizontal(boolValue);
 
-    return true;
+    return WTFMove(selectionRect);
 }
 
 #endif
@@ -1225,6 +1508,15 @@ bool ArgumentCoder<Color>::decode(Decoder& decoder, Color& color)
     return true;
 }
 
+std::optional<Color> ArgumentCoder<Color>::decode(Decoder& decoder)
+{
+    Color color;
+    if (!decode(decoder, color))
+        return std::nullopt;
+
+    return color;
+}
+
 #if ENABLE(DRAG_SUPPORT)
 void ArgumentCoder<DragData>::encode(Encoder& encoder, const DragData& dragData)
 {
@@ -1286,18 +1578,20 @@ void ArgumentCoder<CompositionUnderline>::encode(Encoder& encoder, const Composi
     encoder << underline.color;
 }
 
-bool ArgumentCoder<CompositionUnderline>::decode(Decoder& decoder, CompositionUnderline& underline)
+std::optional<CompositionUnderline> ArgumentCoder<CompositionUnderline>::decode(Decoder& decoder)
 {
+    CompositionUnderline underline;
+
     if (!decoder.decode(underline.startOffset))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(underline.endOffset))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(underline.thick))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(underline.color))
-        return false;
+        return std::nullopt;
 
-    return true;
+    return WTFMove(underline);
 }
 
 void ArgumentCoder<DatabaseDetails>::encode(Encoder& encoder, const DatabaseDetails& details)
@@ -1340,70 +1634,50 @@ bool ArgumentCoder<DatabaseDetails>::decode(Decoder& decoder, DatabaseDetails& d
     return true;
 }
 
-#if PLATFORM(IOS)
-
-void ArgumentCoder<Highlight>::encode(Encoder& encoder, const Highlight& highlight)
+#if ENABLE(DATALIST_ELEMENT)
+void ArgumentCoder<DataListSuggestionInformation>::encode(Encoder& encoder, const WebCore::DataListSuggestionInformation& info)
 {
-    encoder << static_cast<uint32_t>(highlight.type);
-    encoder << highlight.usePageCoordinates;
-    encoder << highlight.contentColor;
-    encoder << highlight.contentOutlineColor;
-    encoder << highlight.paddingColor;
-    encoder << highlight.borderColor;
-    encoder << highlight.marginColor;
-    encoder << highlight.quads;
+    encoder.encodeEnum(info.activationType);
+    encoder << info.suggestions;
+    encoder << info.elementRect;
 }
 
-bool ArgumentCoder<Highlight>::decode(Decoder& decoder, Highlight& highlight)
+bool ArgumentCoder<DataListSuggestionInformation>::decode(Decoder& decoder, WebCore::DataListSuggestionInformation& info)
 {
-    uint32_t type;
-    if (!decoder.decode(type))
+    if (!decoder.decodeEnum(info.activationType))
         return false;
-    highlight.type = (HighlightType)type;
 
-    if (!decoder.decode(highlight.usePageCoordinates))
-        return false;
-    if (!decoder.decode(highlight.contentColor))
-        return false;
-    if (!decoder.decode(highlight.contentOutlineColor))
-        return false;
-    if (!decoder.decode(highlight.paddingColor))
+    if (!decoder.decode(info.suggestions))
         return false;
-    if (!decoder.decode(highlight.borderColor))
-        return false;
-    if (!decoder.decode(highlight.marginColor))
-        return false;
-    if (!decoder.decode(highlight.quads))
+
+    if (!decoder.decode(info.elementRect))
         return false;
+
     return true;
 }
+#endif
 
-static void encodeSharedBuffer(Encoder& encoder, SharedBuffer* buffer)
+void ArgumentCoder<PasteboardCustomData>::encode(Encoder& encoder, const PasteboardCustomData& data)
 {
-    SharedMemory::Handle handle;
-    encoder << (buffer ? static_cast<uint64_t>(buffer->size()): 0);
-    if (buffer) {
-        RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::allocate(buffer->size());
-        memcpy(sharedMemoryBuffer->data(), buffer->data(), buffer->size());
-        sharedMemoryBuffer->createHandle(handle, SharedMemory::Protection::ReadOnly);
-        encoder << handle;
-    }
+    encoder << data.origin;
+    encoder << data.orderedTypes;
+    encoder << data.platformData;
+    encoder << data.sameOriginCustomData;
 }
 
-static bool decodeSharedBuffer(Decoder& decoder, RefPtr<SharedBuffer>& buffer)
+bool ArgumentCoder<PasteboardCustomData>::decode(Decoder& decoder, PasteboardCustomData& data)
 {
-    uint64_t bufferSize = 0;
-    if (!decoder.decode(bufferSize))
+    if (!decoder.decode(data.origin))
         return false;
 
-    if (bufferSize) {
-        SharedMemory::Handle handle;
-        if (!decoder.decode(handle))
-            return false;
+    if (!decoder.decode(data.orderedTypes))
+        return false;
 
-        RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly);
-        buffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryBuffer->data()), bufferSize);
-    }
+    if (!decoder.decode(data.platformData))
+        return false;
+
+    if (!decoder.decode(data.sameOriginCustomData))
+        return false;
 
     return true;
 }
@@ -1412,6 +1686,12 @@ void ArgumentCoder<PasteboardURL>::encode(Encoder& encoder, const PasteboardURL&
 {
     encoder << content.url;
     encoder << content.title;
+#if PLATFORM(MAC)
+    encoder << content.userVisibleForm;
+#endif
+#if PLATFORM(GTK)
+    encoder << content.markup;
+#endif
 }
 
 bool ArgumentCoder<PasteboardURL>::decode(Decoder& decoder, PasteboardURL& content)
@@ -1422,55 +1702,81 @@ bool ArgumentCoder<PasteboardURL>::decode(Decoder& decoder, PasteboardURL& conte
     if (!decoder.decode(content.title))
         return false;
 
+#if PLATFORM(MAC)
+    if (!decoder.decode(content.userVisibleForm))
+        return false;
+#endif
+#if PLATFORM(GTK)
+    if (!decoder.decode(content.markup))
+        return false;
+#endif
+
     return true;
 }
 
-static void encodeClientTypesAndData(Encoder& encoder, const Vector<String>& types, const Vector<RefPtr<SharedBuffer>>& data)
+#if PLATFORM(IOS_FAMILY)
+
+void ArgumentCoder<Highlight>::encode(Encoder& encoder, const Highlight& highlight)
 {
-    ASSERT(types.size() == data.size());
-    encoder << types;
-    encoder << static_cast<uint64_t>(data.size());
-    for (auto& buffer : data)
-        encodeSharedBuffer(encoder, buffer.get());
+    encoder << static_cast<uint32_t>(highlight.type);
+    encoder << highlight.usePageCoordinates;
+    encoder << highlight.contentColor;
+    encoder << highlight.contentOutlineColor;
+    encoder << highlight.paddingColor;
+    encoder << highlight.borderColor;
+    encoder << highlight.marginColor;
+    encoder << highlight.quads;
 }
 
-static bool decodeClientTypesAndData(Decoder& decoder, Vector<String>& types, Vector<RefPtr<SharedBuffer>>& data)
+bool ArgumentCoder<Highlight>::decode(Decoder& decoder, Highlight& highlight)
 {
-    if (!decoder.decode(types))
+    uint32_t type;
+    if (!decoder.decode(type))
         return false;
+    highlight.type = (HighlightType)type;
 
-    uint64_t dataSize;
-    if (!decoder.decode(dataSize))
+    if (!decoder.decode(highlight.usePageCoordinates))
+        return false;
+    if (!decoder.decode(highlight.contentColor))
+        return false;
+    if (!decoder.decode(highlight.contentOutlineColor))
+        return false;
+    if (!decoder.decode(highlight.paddingColor))
+        return false;
+    if (!decoder.decode(highlight.borderColor))
+        return false;
+    if (!decoder.decode(highlight.marginColor))
+        return false;
+    if (!decoder.decode(highlight.quads))
         return false;
-
-    ASSERT(dataSize == types.size());
-
-    data.resize(dataSize);
-    for (auto& buffer : data)
-        decodeSharedBuffer(decoder, buffer);
-
     return true;
 }
 
 void ArgumentCoder<PasteboardWebContent>::encode(Encoder& encoder, const PasteboardWebContent& content)
 {
+    encoder << content.contentOrigin;
     encoder << content.canSmartCopyOrDelete;
     encoder << content.dataInStringFormat;
+    encoder << content.dataInHTMLFormat;
 
     encodeSharedBuffer(encoder, content.dataInWebArchiveFormat.get());
     encodeSharedBuffer(encoder, content.dataInRTFDFormat.get());
     encodeSharedBuffer(encoder, content.dataInRTFFormat.get());
     encodeSharedBuffer(encoder, content.dataInAttributedStringFormat.get());
 
-    encodeClientTypesAndData(encoder, content.clientTypes, content.clientData);
+    encodeTypesAndData(encoder, content.clientTypes, content.clientData);
 }
 
 bool ArgumentCoder<PasteboardWebContent>::decode(Decoder& decoder, PasteboardWebContent& content)
 {
+    if (!decoder.decode(content.contentOrigin))
+        return false;
     if (!decoder.decode(content.canSmartCopyOrDelete))
         return false;
     if (!decoder.decode(content.dataInStringFormat))
         return false;
+    if (!decoder.decode(content.dataInHTMLFormat))
+        return false;
     if (!decodeSharedBuffer(decoder, content.dataInWebArchiveFormat))
         return false;
     if (!decodeSharedBuffer(decoder, content.dataInRTFDFormat))
@@ -1479,7 +1785,7 @@ bool ArgumentCoder<PasteboardWebContent>::decode(Decoder& decoder, PasteboardWeb
         return false;
     if (!decodeSharedBuffer(decoder, content.dataInAttributedStringFormat))
         return false;
-    if (!decodeClientTypesAndData(decoder, content.clientTypes, content.clientData))
+    if (!decodeTypesAndData(decoder, content.clientTypes, content.clientData))
         return false;
     return true;
 }
@@ -1494,7 +1800,7 @@ void ArgumentCoder<PasteboardImage>::encode(Encoder& encoder, const PasteboardIm
     encoder << pasteboardImage.imageSize;
     if (pasteboardImage.resourceData)
         encodeSharedBuffer(encoder, pasteboardImage.resourceData.get());
-    encodeClientTypesAndData(encoder, pasteboardImage.clientTypes, pasteboardImage.clientData);
+    encodeTypesAndData(encoder, pasteboardImage.clientTypes, pasteboardImage.clientData);
 }
 
 bool ArgumentCoder<PasteboardImage>::decode(Decoder& decoder, PasteboardImage& pasteboardImage)
@@ -1513,14 +1819,14 @@ bool ArgumentCoder<PasteboardImage>::decode(Decoder& decoder, PasteboardImage& p
         return false;
     if (!decodeSharedBuffer(decoder, pasteboardImage.resourceData))
         return false;
-    if (!decodeClientTypesAndData(decoder, pasteboardImage.clientTypes, pasteboardImage.clientData))
+    if (!decodeTypesAndData(decoder, pasteboardImage.clientTypes, pasteboardImage.clientData))
         return false;
     return true;
 }
 
 #endif
 
-#if PLATFORM(WPE)
+#if USE(LIBWPE)
 void ArgumentCoder<PasteboardWebContent>::encode(Encoder& encoder, const PasteboardWebContent& content)
 {
     encoder << content.text;
@@ -1535,7 +1841,7 @@ bool ArgumentCoder<PasteboardWebContent>::decode(Decoder& decoder, PasteboardWeb
         return false;
     return true;
 }
-#endif // PLATFORM(WPE)
+#endif // USE(LIBWPE)
 
 void ArgumentCoder<DictationAlternative>::encode(Encoder& encoder, const DictationAlternative& dictationAlternative)
 {
@@ -1544,22 +1850,32 @@ void ArgumentCoder<DictationAlternative>::encode(Encoder& encoder, const Dictati
     encoder << dictationAlternative.dictationContext;
 }
 
-bool ArgumentCoder<DictationAlternative>::decode(Decoder& decoder, DictationAlternative& dictationAlternative)
+std::optional<DictationAlternative> ArgumentCoder<DictationAlternative>::decode(Decoder& decoder)
 {
-    if (!decoder.decode(dictationAlternative.rangeStart))
-        return false;
-    if (!decoder.decode(dictationAlternative.rangeLength))
-        return false;
-    if (!decoder.decode(dictationAlternative.dictationContext))
-        return false;
-    return true;
+    std::optional<unsigned> rangeStart;
+    decoder >> rangeStart;
+    if (!rangeStart)
+        return std::nullopt;
+    
+    std::optional<unsigned> rangeLength;
+    decoder >> rangeLength;
+    if (!rangeLength)
+        return std::nullopt;
+    
+    std::optional<uint64_t> dictationContext;
+    decoder >> dictationContext;
+    if (!dictationContext)
+        return std::nullopt;
+    
+    return {{ WTFMove(*rangeStart), WTFMove(*rangeLength), WTFMove(*dictationContext) }};
 }
 
-
 void ArgumentCoder<FileChooserSettings>::encode(Encoder& encoder, const FileChooserSettings& settings)
 {
+    encoder << settings.allowsDirectories;
     encoder << settings.allowsMultipleFiles;
     encoder << settings.acceptMIMETypes;
+    encoder << settings.acceptFileExtensions;
     encoder << settings.selectedFiles;
 #if ENABLE(MEDIA_CAPTURE)
     encoder.encodeEnum(settings.mediaCaptureType);
@@ -1568,10 +1884,14 @@ void ArgumentCoder<FileChooserSettings>::encode(Encoder& encoder, const FileChoo
 
 bool ArgumentCoder<FileChooserSettings>::decode(Decoder& decoder, FileChooserSettings& settings)
 {
+    if (!decoder.decode(settings.allowsDirectories))
+        return false;
     if (!decoder.decode(settings.allowsMultipleFiles))
         return false;
     if (!decoder.decode(settings.acceptMIMETypes))
         return false;
+    if (!decoder.decode(settings.acceptFileExtensions))
+        return false;
     if (!decoder.decode(settings.selectedFiles))
         return false;
 #if ENABLE(MEDIA_CAPTURE)
@@ -1581,7 +1901,39 @@ bool ArgumentCoder<FileChooserSettings>::decode(Decoder& decoder, FileChooserSet
 
     return true;
 }
+    
+void ArgumentCoder<ShareData>::encode(Encoder& encoder, const ShareData& settings)
+{
+    encoder << settings.title;
+    encoder << settings.text;
+    encoder << settings.url;
+}
+
+bool ArgumentCoder<ShareData>::decode(Decoder& decoder, ShareData& settings)
+{
+    if (!decoder.decode(settings.title))
+        return false;
+    if (!decoder.decode(settings.text))
+        return false;
+    if (!decoder.decode(settings.url))
+        return false;
+    return true;
+}
+    
+void ArgumentCoder<ShareDataWithParsedURL>::encode(Encoder& encoder, const ShareDataWithParsedURL& settings)
+{
+    encoder << settings.shareData;
+    encoder << settings.url;
+}
 
+bool ArgumentCoder<ShareDataWithParsedURL>::decode(Decoder& decoder, ShareDataWithParsedURL& settings)
+{
+    if (!decoder.decode(settings.shareData))
+        return false;
+    if (!decoder.decode(settings.url))
+        return false;
+    return true;
+}
 
 void ArgumentCoder<GrammarDetail>::encode(Encoder& encoder, const GrammarDetail& detail)
 {
@@ -1591,25 +1943,36 @@ void ArgumentCoder<GrammarDetail>::encode(Encoder& encoder, const GrammarDetail&
     encoder << detail.userDescription;
 }
 
-bool ArgumentCoder<GrammarDetail>::decode(Decoder& decoder, GrammarDetail& detail)
+std::optional<GrammarDetail> ArgumentCoder<GrammarDetail>::decode(Decoder& decoder)
 {
-    if (!decoder.decode(detail.location))
-        return false;
-    if (!decoder.decode(detail.length))
-        return false;
-    if (!decoder.decode(detail.guesses))
-        return false;
-    if (!decoder.decode(detail.userDescription))
-        return false;
+    std::optional<int> location;
+    decoder >> location;
+    if (!location)
+        return std::nullopt;
 
-    return true;
+    std::optional<int> length;
+    decoder >> length;
+    if (!length)
+        return std::nullopt;
+
+    std::optional<Vector<String>> guesses;
+    decoder >> guesses;
+    if (!guesses)
+        return std::nullopt;
+
+    std::optional<String> userDescription;
+    decoder >> userDescription;
+    if (!userDescription)
+        return std::nullopt;
+
+    return {{ WTFMove(*location), WTFMove(*length), WTFMove(*guesses), WTFMove(*userDescription) }};
 }
 
 void ArgumentCoder<TextCheckingRequestData>::encode(Encoder& encoder, const TextCheckingRequestData& request)
 {
     encoder << request.sequence();
     encoder << request.text();
-    encoder << request.mask();
+    encoder << request.checkingTypes();
     encoder.encodeEnum(request.processType());
 }
 
@@ -1623,15 +1986,15 @@ bool ArgumentCoder<TextCheckingRequestData>::decode(Decoder& decoder, TextChecki
     if (!decoder.decode(text))
         return false;
 
-    TextCheckingTypeMask mask;
-    if (!decoder.decode(mask))
+    OptionSet<TextCheckingType> checkingTypes;
+    if (!decoder.decode(checkingTypes))
         return false;
 
     TextCheckingProcessType processType;
     if (!decoder.decodeEnum(processType))
         return false;
 
-    request = TextCheckingRequestData(sequence, text, mask, processType);
+    request = TextCheckingRequestData { sequence, text, checkingTypes, processType };
     return true;
 }
 
@@ -1644,33 +2007,33 @@ void ArgumentCoder<TextCheckingResult>::encode(Encoder& encoder, const TextCheck
     encoder << result.replacement;
 }
 
-bool ArgumentCoder<TextCheckingResult>::decode(Decoder& decoder, TextCheckingResult& result)
-{
-    if (!decoder.decodeEnum(result.type))
-        return false;
-    if (!decoder.decode(result.location))
-        return false;
-    if (!decoder.decode(result.length))
-        return false;
-    if (!decoder.decode(result.details))
-        return false;
-    if (!decoder.decode(result.replacement))
-        return false;
-    return true;
-}
-
-void ArgumentCoder<URL>::encode(Encoder& encoder, const URL& result)
+std::optional<TextCheckingResult> ArgumentCoder<TextCheckingResult>::decode(Decoder& decoder)
 {
-    encoder << result.string();
-}
+    TextCheckingType type;
+    if (!decoder.decodeEnum(type))
+        return std::nullopt;
     
-bool ArgumentCoder<URL>::decode(Decoder& decoder, URL& result)
-{
-    String urlAsString;
-    if (!decoder.decode(urlAsString))
-        return false;
-    result = URL(ParsedURLString, urlAsString);
-    return true;
+    std::optional<int> location;
+    decoder >> location;
+    if (!location)
+        return std::nullopt;
+
+    std::optional<int> length;
+    decoder >> length;
+    if (!length)
+        return std::nullopt;
+
+    std::optional<Vector<GrammarDetail>> details;
+    decoder >> details;
+    if (!details)
+        return std::nullopt;
+
+    std::optional<String> replacement;
+    decoder >> replacement;
+    if (!replacement)
+        return std::nullopt;
+
+    return {{ WTFMove(type), WTFMove(*location), WTFMove(*length), WTFMove(*details), WTFMove(*replacement) }};
 }
 
 void ArgumentCoder<UserStyleSheet>::encode(Encoder& encoder, const UserStyleSheet& userStyleSheet)
@@ -1913,6 +2276,9 @@ void ArgumentCoder<FilterOperation>::encode(Encoder& encoder, const FilterOperat
     case FilterOperation::CONTRAST:
         encoder << downcast<BasicComponentTransferFilterOperation>(filter).amount();
         break;
+    case FilterOperation::APPLE_INVERT_LIGHTNESS:
+        ASSERT_NOT_REACHED(); // APPLE_INVERT_LIGHTNESS is only used in -apple-color-filter.
+        break;
     case FilterOperation::BLUR:
         encoder << downcast<BlurFilterOperation>(filter).stdDeviation();
         break;
@@ -1963,6 +2329,9 @@ bool decodeFilterOperation(Decoder& decoder, RefPtr<FilterOperation>& filter)
         filter = BasicComponentTransferFilterOperation::create(amount, type);
         break;
     }
+    case FilterOperation::APPLE_INVERT_LIGHTNESS:
+        ASSERT_NOT_REACHED(); // APPLE_INVERT_LIGHTNESS is only used in -apple-color-filter.
+        break;
     case FilterOperation::BLUR: {
         Length stdDeviation;
         if (!decoder.decode(stdDeviation))
@@ -2037,32 +2406,36 @@ void ArgumentCoder<BlobPart>::encode(Encoder& encoder, const BlobPart& blobPart)
     }
 }
 
-bool ArgumentCoder<BlobPart>::decode(Decoder& decoder, BlobPart& blobPart)
+std::optional<BlobPart> ArgumentCoder<BlobPart>::decode(Decoder& decoder)
 {
-    uint32_t type;
-    if (!decoder.decode(type))
-        return false;
+    BlobPart blobPart;
 
-    switch (type) {
+    std::optional<uint32_t> type;
+    decoder >> type;
+    if (!type)
+        return std::nullopt;
+
+    switch (*type) {
     case BlobPart::Data: {
-        Vector<uint8_t> data;
-        if (!decoder.decode(data))
-            return false;
-        blobPart = BlobPart(WTFMove(data));
+        std::optional<Vector<uint8_t>> data;
+        decoder >> data;
+        if (!data)
+            return std::nullopt;
+        blobPart = BlobPart(WTFMove(*data));
         break;
     }
     case BlobPart::Blob: {
         URL url;
         if (!decoder.decode(url))
-            return false;
+            return std::nullopt;
         blobPart = BlobPart(url);
         break;
     }
     default:
-        return false;
+        return std::nullopt;
     }
 
-    return true;
+    return WTFMove(blobPart);
 }
 
 void ArgumentCoder<TextIndicatorData>::encode(Encoder& encoder, const TextIndicatorData& textIndicatorData)
@@ -2081,44 +2454,45 @@ void ArgumentCoder<TextIndicatorData>::encode(Encoder& encoder, const TextIndica
     encodeOptionalImage(encoder, textIndicatorData.contentImageWithoutSelection.get());
 }
 
-bool ArgumentCoder<TextIndicatorData>::decode(Decoder& decoder, TextIndicatorData& textIndicatorData)
+std::optional<TextIndicatorData> ArgumentCoder<TextIndicatorData>::decode(Decoder& decoder)
 {
+    TextIndicatorData textIndicatorData;
     if (!decoder.decode(textIndicatorData.selectionRectInRootViewCoordinates))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(textIndicatorData.textBoundingRectInRootViewCoordinates))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(textIndicatorData.textRectsInBoundingRectCoordinates))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(textIndicatorData.contentImageWithoutSelectionRectInRootViewCoordinates))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(textIndicatorData.contentImageScaleFactor))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(textIndicatorData.estimatedBackgroundColor))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decodeEnum(textIndicatorData.presentationTransition))
-        return false;
+        return std::nullopt;
 
     uint64_t options;
     if (!decoder.decode(options))
-        return false;
+        return std::nullopt;
     textIndicatorData.options = static_cast<TextIndicatorOptions>(options);
 
     if (!decodeOptionalImage(decoder, textIndicatorData.contentImage))
-        return false;
+        return std::nullopt;
 
     if (!decodeOptionalImage(decoder, textIndicatorData.contentImageWithHighlight))
-        return false;
+        return std::nullopt;
 
     if (!decodeOptionalImage(decoder, textIndicatorData.contentImageWithoutSelection))
-        return false;
+        return std::nullopt;
 
-    return true;
+    return WTFMove(textIndicatorData);
 }
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
@@ -2191,8 +2565,11 @@ bool ArgumentCoder<DictionaryPopupInfo>::decode(IPC::Decoder& decoder, Dictionar
     if (!decoder.decode(result.origin))
         return false;
 
-    if (!decoder.decode(result.textIndicator))
+    std::optional<TextIndicatorData> textIndicator;
+    decoder >> textIndicator;
+    if (!textIndicator)
         return false;
+    result.textIndicator = WTFMove(*textIndicator);
 
 #if PLATFORM(COCOA)
     bool hadOptions;
@@ -2251,60 +2628,115 @@ void ArgumentCoder<ResourceLoadStatistics>::encode(Encoder& encoder, const WebCo
     encoder << statistics.hadUserInteraction;
     encoder << statistics.mostRecentUserInteractionTime.secondsSinceEpoch().value();
     encoder << statistics.grandfathered;
-    
+
+    // Storage access
+    encoder << statistics.storageAccessUnderTopFrameOrigins;
+
+    // Top frame stats
+    encoder << statistics.topFrameUniqueRedirectsTo;
+    encoder << statistics.topFrameUniqueRedirectsFrom;
+
     // Subframe stats
     encoder << statistics.subframeUnderTopFrameOrigins;
     
     // Subresource stats
     encoder << statistics.subresourceUnderTopFrameOrigins;
     encoder << statistics.subresourceUniqueRedirectsTo;
-    
+    encoder << statistics.subresourceUniqueRedirectsFrom;
+
     // Prevalent Resource
     encoder << statistics.isPrevalentResource;
+    encoder << statistics.isVeryPrevalentResource;
     encoder << statistics.dataRecordsRemoved;
+    
+    encoder << statistics.fontsFailedToLoad;
+    encoder << statistics.fontsSuccessfullyLoaded;
+    encoder << statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs;
+    
+    encoder << statistics.canvasActivityRecord;
+    
+    encoder << statistics.navigatorFunctionsAccessed;
+    encoder << statistics.screenFunctionsAccessed;
+    
 }
 
-bool ArgumentCoder<ResourceLoadStatistics>::decode(Decoder& decoder, WebCore::ResourceLoadStatistics& statistics)
+std::optional<ResourceLoadStatistics> ArgumentCoder<ResourceLoadStatistics>::decode(Decoder& decoder)
 {
+    ResourceLoadStatistics statistics;
     if (!decoder.decode(statistics.highLevelDomain))
-        return false;
+        return std::nullopt;
     
     double lastSeenTimeAsDouble;
     if (!decoder.decode(lastSeenTimeAsDouble))
-        return false;
+        return std::nullopt;
     statistics.lastSeen = WallTime::fromRawSeconds(lastSeenTimeAsDouble);
     
     // User interaction
     if (!decoder.decode(statistics.hadUserInteraction))
-        return false;
+        return std::nullopt;
 
     double mostRecentUserInteractionTimeAsDouble;
     if (!decoder.decode(mostRecentUserInteractionTimeAsDouble))
-        return false;
+        return std::nullopt;
     statistics.mostRecentUserInteractionTime = WallTime::fromRawSeconds(mostRecentUserInteractionTimeAsDouble);
 
     if (!decoder.decode(statistics.grandfathered))
-        return false;
-    
+        return std::nullopt;
+
+    // Storage access
+    if (!decoder.decode(statistics.storageAccessUnderTopFrameOrigins))
+        return std::nullopt;
+
+    // Top frame stats
+    if (!decoder.decode(statistics.topFrameUniqueRedirectsTo))
+        return std::nullopt;    
+
+    if (!decoder.decode(statistics.topFrameUniqueRedirectsFrom))
+        return std::nullopt;
+
     // Subframe stats
     if (!decoder.decode(statistics.subframeUnderTopFrameOrigins))
-        return false;
+        return std::nullopt;
     
     // Subresource stats
     if (!decoder.decode(statistics.subresourceUnderTopFrameOrigins))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(statistics.subresourceUniqueRedirectsTo))
-        return false;
+        return std::nullopt;
+    
+    if (!decoder.decode(statistics.subresourceUniqueRedirectsFrom))
+        return std::nullopt;
     
     // Prevalent Resource
     if (!decoder.decode(statistics.isPrevalentResource))
-        return false;
+        return std::nullopt;
 
+    if (!decoder.decode(statistics.isVeryPrevalentResource))
+        return std::nullopt;
+    
     if (!decoder.decode(statistics.dataRecordsRemoved))
-        return false;
-
-    return true;
+        return std::nullopt;
+    
+    if (!decoder.decode(statistics.fontsFailedToLoad))
+        return std::nullopt;
+    
+    if (!decoder.decode(statistics.fontsSuccessfullyLoaded))
+        return std::nullopt;
+    
+    if (!decoder.decode(statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs))
+        return std::nullopt;
+    
+    if (!decoder.decode(statistics.canvasActivityRecord))
+        return std::nullopt;
+    
+    if (!decoder.decode(statistics.navigatorFunctionsAccessed))
+        return std::nullopt;
+    
+    if (!decoder.decode(statistics.screenFunctionsAccessed))
+        return std::nullopt;
+    
+    return WTFMove(statistics);
 }
 
 #if ENABLE(MEDIA_STREAM)
@@ -2312,56 +2744,18 @@ void ArgumentCoder<MediaConstraints>::encode(Encoder& encoder, const WebCore::Me
 {
     encoder << constraint.mandatoryConstraints
         << constraint.advancedConstraints
-        << constraint.deviceIDHashSalt
         << constraint.isValid;
 }
 
 bool ArgumentCoder<MediaConstraints>::decode(Decoder& decoder, WebCore::MediaConstraints& constraints)
 {
-    return decoder.decode(constraints.mandatoryConstraints)
-        && decoder.decode(constraints.advancedConstraints)
-        && decoder.decode(constraints.deviceIDHashSalt)
-        && decoder.decode(constraints.isValid);
-}
-
-void ArgumentCoder<CaptureDevice>::encode(Encoder& encoder, const WebCore::CaptureDevice& device)
-{
-    encoder << device.persistentId();
-    encoder << device.label();
-    encoder << device.groupId();
-    encoder << device.enabled();
-    encoder.encodeEnum(device.type());
-}
-
-bool ArgumentCoder<CaptureDevice>::decode(Decoder& decoder, WebCore::CaptureDevice& device)
-{
-    String persistentId;
-    if (!decoder.decode(persistentId))
+    std::optional<WebCore::MediaTrackConstraintSetMap> mandatoryConstraints;
+    decoder >> mandatoryConstraints;
+    if (!mandatoryConstraints)
         return false;
-
-    String label;
-    if (!decoder.decode(label))
-        return false;
-
-    String groupId;
-    if (!decoder.decode(groupId))
-        return false;
-
-    bool enabled;
-    if (!decoder.decode(enabled))
-        return false;
-
-    CaptureDevice::DeviceType type;
-    if (!decoder.decodeEnum(type))
-        return false;
-
-    device.setPersistentId(persistentId);
-    device.setLabel(label);
-    device.setGroupId(groupId);
-    device.setType(type);
-    device.setEnabled(enabled);
-
-    return true;
+    constraints.mandatoryConstraints = WTFMove(*mandatoryConstraints);
+    return decoder.decode(constraints.advancedConstraints)
+        && decoder.decode(constraints.isValid);
 }
 #endif
 
@@ -2396,6 +2790,74 @@ bool ArgumentCoder<IDBKeyPath>::decode(Decoder& decoder, IDBKeyPath& keyPath)
 }
 #endif
 
+#if ENABLE(SERVICE_WORKER)
+void ArgumentCoder<ServiceWorkerOrClientData>::encode(Encoder& encoder, const ServiceWorkerOrClientData& data)
+{
+    bool isServiceWorkerData = WTF::holds_alternative<ServiceWorkerData>(data);
+    encoder << isServiceWorkerData;
+    if (isServiceWorkerData)
+        encoder << WTF::get<ServiceWorkerData>(data);
+    else
+        encoder << WTF::get<ServiceWorkerClientData>(data);
+}
+
+bool ArgumentCoder<ServiceWorkerOrClientData>::decode(Decoder& decoder, ServiceWorkerOrClientData& data)
+{
+    bool isServiceWorkerData;
+    if (!decoder.decode(isServiceWorkerData))
+        return false;
+    if (isServiceWorkerData) {
+        std::optional<ServiceWorkerData> workerData;
+        decoder >> workerData;
+        if (!workerData)
+            return false;
+
+        data = WTFMove(*workerData);
+    } else {
+        std::optional<ServiceWorkerClientData> clientData;
+        decoder >> clientData;
+        if (!clientData)
+            return false;
+
+        data = WTFMove(*clientData);
+    }
+    return true;
+}
+
+void ArgumentCoder<ServiceWorkerOrClientIdentifier>::encode(Encoder& encoder, const ServiceWorkerOrClientIdentifier& identifier)
+{
+    bool isServiceWorkerIdentifier = WTF::holds_alternative<ServiceWorkerIdentifier>(identifier);
+    encoder << isServiceWorkerIdentifier;
+    if (isServiceWorkerIdentifier)
+        encoder << WTF::get<ServiceWorkerIdentifier>(identifier);
+    else
+        encoder << WTF::get<ServiceWorkerClientIdentifier>(identifier);
+}
+
+bool ArgumentCoder<ServiceWorkerOrClientIdentifier>::decode(Decoder& decoder, ServiceWorkerOrClientIdentifier& identifier)
+{
+    bool isServiceWorkerIdentifier;
+    if (!decoder.decode(isServiceWorkerIdentifier))
+        return false;
+    if (isServiceWorkerIdentifier) {
+        std::optional<ServiceWorkerIdentifier> workerIdentifier;
+        decoder >> workerIdentifier;
+        if (!workerIdentifier)
+            return false;
+
+        identifier = WTFMove(*workerIdentifier);
+    } else {
+        std::optional<ServiceWorkerClientIdentifier> clientIdentifier;
+        decoder >> clientIdentifier;
+        if (!clientIdentifier)
+            return false;
+
+        identifier = WTFMove(*clientIdentifier);
+    }
+    return true;
+}
+#endif
+
 #if ENABLE(CSS_SCROLL_SNAP)
 
 void ArgumentCoder<ScrollOffsetRange<float>>::encode(Encoder& encoder, const ScrollOffsetRange<float>& range)
@@ -2404,19 +2866,20 @@ void ArgumentCoder<ScrollOffsetRange<float>>::encode(Encoder& encoder, const Scr
     encoder << range.end;
 }
 
-bool ArgumentCoder<ScrollOffsetRange<float>>::decode(Decoder& decoder, ScrollOffsetRange<float>& range)
+auto ArgumentCoder<ScrollOffsetRange<float>>::decode(Decoder& decoder) -> std::optional<WebCore::ScrollOffsetRange<float>>
 {
+    WebCore::ScrollOffsetRange<float> range;
     float start;
     if (!decoder.decode(start))
-        return false;
+        return std::nullopt;
 
     float end;
     if (!decoder.decode(end))
-        return false;
+        return std::nullopt;
 
     range.start = start;
     range.end = end;
-    return true;
+    return WTFMove(range);
 }
 
 #endif
@@ -2427,15 +2890,154 @@ void ArgumentCoder<MediaSelectionOption>::encode(Encoder& encoder, const MediaSe
     encoder << option.type;
 }
 
-bool ArgumentCoder<MediaSelectionOption>::decode(Decoder& decoder, MediaSelectionOption& option)
+std::optional<MediaSelectionOption> ArgumentCoder<MediaSelectionOption>::decode(Decoder& decoder)
+{
+    std::optional<String> displayName;
+    decoder >> displayName;
+    if (!displayName)
+        return std::nullopt;
+    
+    std::optional<MediaSelectionOption::Type> type;
+    decoder >> type;
+    if (!type)
+        return std::nullopt;
+    
+    return {{ WTFMove(*displayName), WTFMove(*type) }};
+}
+
+void ArgumentCoder<PromisedAttachmentInfo>::encode(Encoder& encoder, const PromisedAttachmentInfo& info)
+{
+    encoder << info.blobURL;
+    encoder << info.contentType;
+    encoder << info.fileName;
+#if ENABLE(ATTACHMENT_ELEMENT)
+    encoder << info.attachmentIdentifier;
+#endif
+    encodeTypesAndData(encoder, info.additionalTypes, info.additionalData);
+}
+
+bool ArgumentCoder<PromisedAttachmentInfo>::decode(Decoder& decoder, PromisedAttachmentInfo& info)
 {
-    if (!decoder.decode(option.displayName))
+    if (!decoder.decode(info.blobURL))
+        return false;
+
+    if (!decoder.decode(info.contentType))
         return false;
 
-    if (!decoder.decode(option.type))
+    if (!decoder.decode(info.fileName))
+        return false;
+
+#if ENABLE(ATTACHMENT_ELEMENT)
+    if (!decoder.decode(info.attachmentIdentifier))
+        return false;
+#endif
+
+    if (!decodeTypesAndData(decoder, info.additionalTypes, info.additionalData))
         return false;
 
     return true;
 }
 
+void ArgumentCoder<Vector<RefPtr<SecurityOrigin>>>::encode(Encoder& encoder, const Vector<RefPtr<SecurityOrigin>>& origins)
+{
+    encoder << static_cast<uint64_t>(origins.size());
+    for (auto& origin : origins)
+        encoder << *origin;
+}
+    
+bool ArgumentCoder<Vector<RefPtr<SecurityOrigin>>>::decode(Decoder& decoder, Vector<RefPtr<SecurityOrigin>>& origins)
+{
+    uint64_t dataSize;
+    if (!decoder.decode(dataSize))
+        return false;
+
+    origins.reserveInitialCapacity(dataSize);
+    for (uint64_t i = 0; i < dataSize; ++i) {
+        auto decodedOriginRefPtr = SecurityOrigin::decode(decoder);
+        if (!decodedOriginRefPtr)
+            return false;
+        origins.uncheckedAppend(decodedOriginRefPtr.releaseNonNull());
+    }
+    return true;
+}
+
+void ArgumentCoder<FontAttributes>::encode(Encoder& encoder, const FontAttributes& attributes)
+{
+    encoder << attributes.backgroundColor << attributes.foregroundColor << attributes.fontShadow << attributes.hasUnderline << attributes.hasStrikeThrough << attributes.textLists;
+    encoder.encodeEnum(attributes.horizontalAlignment);
+    encoder.encodeEnum(attributes.subscriptOrSuperscript);
+#if PLATFORM(COCOA)
+    bool hasFont = attributes.font;
+    encoder << hasFont;
+    if (hasFont)
+        IPC::encode(encoder, attributes.font.get());
+#endif
+}
+
+std::optional<FontAttributes> ArgumentCoder<FontAttributes>::decode(Decoder& decoder)
+{
+    FontAttributes attributes;
+
+    if (!decoder.decode(attributes.backgroundColor))
+        return std::nullopt;
+
+    if (!decoder.decode(attributes.foregroundColor))
+        return std::nullopt;
+
+    if (!decoder.decode(attributes.fontShadow))
+        return std::nullopt;
+
+    if (!decoder.decode(attributes.hasUnderline))
+        return std::nullopt;
+
+    if (!decoder.decode(attributes.hasStrikeThrough))
+        return std::nullopt;
+
+    if (!decoder.decode(attributes.textLists))
+        return std::nullopt;
+
+    if (!decoder.decodeEnum(attributes.horizontalAlignment))
+        return std::nullopt;
+
+    if (!decoder.decodeEnum(attributes.subscriptOrSuperscript))
+        return std::nullopt;
+
+#if PLATFORM(COCOA)
+    bool hasFont = false;
+    if (!decoder.decode(hasFont))
+        return std::nullopt;
+
+    if (hasFont && !IPC::decode(decoder, attributes.font))
+        return std::nullopt;
+#endif
+
+    return attributes;
+}
+
+#if ENABLE(ATTACHMENT_ELEMENT)
+
+void ArgumentCoder<SerializedAttachmentData>::encode(IPC::Encoder& encoder, const WebCore::SerializedAttachmentData& data)
+{
+    encoder << data.identifier << data.mimeType << IPC::SharedBufferDataReference { data.data.get() };
+}
+
+std::optional<SerializedAttachmentData> ArgumentCoder<WebCore::SerializedAttachmentData>::decode(IPC::Decoder& decoder)
+{
+    String identifier;
+    if (!decoder.decode(identifier))
+        return std::nullopt;
+
+    String mimeType;
+    if (!decoder.decode(mimeType))
+        return std::nullopt;
+
+    IPC::DataReference data;
+    if (!decoder.decode(data))
+        return std::nullopt;
+
+    return {{ WTFMove(identifier), WTFMove(mimeType), WebCore::SharedBuffer::create(data.data(), data.size()) }};
+}
+
+#endif // ENABLE(ATTACHMENT_ELEMENT)
+
 } // namespace IPC