Allow modern decoding of Vectors
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Sep 2017 23:17:48 +0000 (23:17 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Sep 2017 23:17:48 +0000 (23:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=177102

Reviewed by Andy Estes.

Source/WebCore:

* Modules/cache/DOMCacheEngine.h:
(WebCore::DOMCacheEngine::CacheInfos::decode):
(WebCore::DOMCacheEngine::CacheIdentifierOperationResult::decode):
* Modules/indexeddb/IDBDatabaseIdentifier.cpp:
(WebCore::IDBDatabaseIdentifier::IDBDatabaseIdentifier):
* Modules/indexeddb/IDBDatabaseIdentifier.h:
(WebCore::IDBDatabaseIdentifier::decode):
* Modules/indexeddb/IDBFactory.cpp:
(WebCore::IDBFactory::openInternal):
(WebCore::IDBFactory::deleteDatabase):
* Modules/indexeddb/IDBGetAllResult.h:
(WebCore::IDBGetAllResult::decode):
* Modules/indexeddb/IDBGetResult.h:
(WebCore::IDBGetResult::decode):
* Modules/indexeddb/IDBKeyData.h:
(WebCore::IDBKeyData::decode):
* Modules/indexeddb/IDBKeyRangeData.h:
(WebCore::IDBKeyRangeData::decode):
* Modules/indexeddb/IDBValue.h:
(WebCore::IDBValue::decode):
* Modules/indexeddb/shared/IDBError.h:
* Modules/indexeddb/shared/IDBIterateCursorData.h:
(WebCore::IDBIterateCursorData::decode):
* Modules/indexeddb/shared/IDBRequestData.h:
(WebCore::IDBRequestData::decode):
* Modules/indexeddb/shared/IDBResultData.h:
(WebCore::IDBResultData::decode):
* page/SecurityOriginData.h:
(WebCore::SecurityOriginData::decode):
* platform/Cookie.h:
(WebCore::Cookie::decode):
* platform/mediastream/MediaConstraints.h:
(WebCore::MediaTrackConstraintSetMap::decode):
* platform/network/FormData.h:
(WebCore::FormDataElement::decode):
* workers/service/ServiceWorkerJobData.h:
(WebCore::ServiceWorkerJobData::decode):
* workers/service/ServiceWorkerRegistrationData.h:
(WebCore::ServiceWorkerRegistrationData::decode):
* workers/service/ServiceWorkerRegistrationKey.h:
(WebCore::ServiceWorkerRegistrationKey::decode):

Source/WebKit:

Rather than allow modern decoding of Vectors of types that only allow legacy decoding,
I just made modern decoders for all types that we need to decode in Vectors.

* NetworkProcess/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::decode):
* Platform/IPC/ArgumentCoders.cpp:
(IPC::ArgumentCoder<std::chrono::system_clock::time_point>::decode):
* Platform/IPC/ArgumentCoders.h:
* Shared/AssistedNodeInformation.cpp:
(WebKit::OptionItem::decode):
* Shared/AssistedNodeInformation.h:
* Shared/CallbackID.h:
(WebKit::CallbackID::decode):
* Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
(IPC::ArgumentCoder<WebCore::PaymentError>::decode):
(IPC::ArgumentCoder<WebCore::PaymentMethodUpdate>::decode):
(IPC::ArgumentCoder<ApplePaySessionPaymentRequest>::decode):
(IPC::ArgumentCoder<ApplePaySessionPaymentRequest::LineItem>::decode):
(IPC::ArgumentCoder<ApplePaySessionPaymentRequest::ShippingMethod>::decode):
(IPC::ArgumentCoder<ApplePaySessionPaymentRequest::TotalAndLineItems>::decode):
(IPC::ArgumentCoder<WebCore::ShippingContactUpdate>::decode):
(IPC::ArgumentCoder<WebCore::ShippingMethodUpdate>::decode):
* Shared/Databases/IndexedDB/WebIDBResult.cpp:
(WebKit::WebIDBResult::decode):
* Shared/FrameInfoData.cpp:
(WebKit::FrameInfoData::decode):
* Shared/Gamepad/GamepadData.cpp:
(WebKit::GamepadData::decode):
* Shared/Gamepad/GamepadData.h:
* Shared/PlatformPopupMenuData.cpp:
(WebKit::PlatformPopupMenuData::decode):
* Shared/PlatformPopupMenuData.h:
* Shared/Plugins/NPIdentifierData.cpp:
(WebKit::NPIdentifierData::decode):
* Shared/Plugins/NPIdentifierData.h:
* Shared/Plugins/NPVariantData.cpp:
(WebKit::NPVariantData::decode):
* Shared/Plugins/NPVariantData.h:
* Shared/RTCNetwork.cpp:
(WebKit::RTCNetwork::IPAddress::decode):
(WebKit::RTCNetwork::SocketAddress::decode):
(WebKit::RTCNetwork::decode):
* Shared/RTCNetwork.h:
* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::decode):
(WebKit::RemoteLayerTreeTransaction::decode):
* Shared/SessionState.cpp:
(WebKit::HTTPBody::Element::decode):
(WebKit::FrameState::decode):
(WebKit::PageState::decode):
(WebKit::BackForwardListItemState::decode):
(WebKit::BackForwardListState::decode):
* Shared/SessionState.h:
* Shared/WebCompiledContentRuleListData.cpp:
(WebKit::WebCompiledContentRuleListData::decode):
* Shared/WebCompiledContentRuleListData.h:
* Shared/WebContextMenuItemData.cpp:
(WebKit::WebContextMenuItemData::decode):
* Shared/WebContextMenuItemData.h:
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<DOMCacheEngine::CacheInfo>::decode):
(IPC::ArgumentCoder<DOMCacheEngine::Record>::decode):
(IPC::ArgumentCoder<FloatRect>::decode):
(IPC::ArgumentCoder<FloatQuad>::decode):
(IPC::ArgumentCoder<IntRect>::decode):
(IPC::ArgumentCoder<RecentSearch>::decode):
(IPC::ArgumentCoder<Region::Span>::decode):
(IPC::ArgumentCoder<MimeClassInfo>::decode):
(IPC::ArgumentCoder<PluginInfo>::decode):
(IPC::ArgumentCoder<SelectionRect>::decode):
(IPC::ArgumentCoder<CompositionUnderline>::decode):
(IPC::ArgumentCoder<DictationAlternative>::decode):
(IPC::ArgumentCoder<GrammarDetail>::decode):
(IPC::ArgumentCoder<TextCheckingResult>::decode):
(IPC::ArgumentCoder<BlobPart>::decode):
(IPC::ArgumentCoder<ResourceLoadStatistics>::decode):
(IPC::ArgumentCoder<MediaConstraints>::decode):
(IPC::ArgumentCoder<CaptureDevice>::decode):
(IPC::ArgumentCoder<ScrollOffsetRange<float>>::decode):
(IPC::ArgumentCoder<MediaSelectionOption>::decode):
* Shared/WebCoreArgumentCoders.h:
* Shared/WebEvent.h:
* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPlatformTouchPoint.cpp:
(WebKit::WebPlatformTouchPoint::decode):
* Shared/WebPopupItem.cpp:
(WebKit::WebPopupItem::decode):
* Shared/WebPopupItem.h:
* Shared/WebUserContentControllerDataTypes.cpp:
(WebKit::WebUserScriptData::decode):
(WebKit::WebUserStyleSheetData::decode):
(WebKit::WebScriptMessageHandlerData::decode):
* Shared/WebUserContentControllerDataTypes.h:
* Shared/WebsiteData/WebsiteData.cpp:
(WebKit::WebsiteData::Entry::decode):
* Shared/WebsiteData/WebsiteData.h:
* Shared/WebsiteDataStoreParameters.cpp:
(WebKit::WebsiteDataStoreParameters::decode):
* Shared/ios/WebPlatformTouchPointIOS.cpp:
(WebKit::WebPlatformTouchPoint::decode):
* Shared/mac/WebCoreArgumentCodersMac.mm:
(IPC::ArgumentCoder<KeypressCommand>::decode):
* UIProcess/LegacySessionStateCodingNone.cpp:
(WebKit::decodeLegacySessionState):
* WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h:
* WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm:
(WebKit::PlatformCAAnimationRemote::KeyframeValue::decode):
(WebKit::PlatformCAAnimationRemote::Properties::decode):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222233 268f45cc-cd09-0410-ab3c-d52691b4dbfc

66 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/cache/DOMCacheEngine.h
Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp
Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h
Source/WebCore/Modules/indexeddb/IDBFactory.cpp
Source/WebCore/Modules/indexeddb/IDBGetAllResult.h
Source/WebCore/Modules/indexeddb/IDBGetResult.h
Source/WebCore/Modules/indexeddb/IDBKeyData.h
Source/WebCore/Modules/indexeddb/IDBKeyRangeData.h
Source/WebCore/Modules/indexeddb/IDBValue.h
Source/WebCore/Modules/indexeddb/shared/IDBError.h
Source/WebCore/Modules/indexeddb/shared/IDBIterateCursorData.h
Source/WebCore/Modules/indexeddb/shared/IDBRequestData.h
Source/WebCore/Modules/indexeddb/shared/IDBResultData.h
Source/WebCore/page/SecurityOriginData.h
Source/WebCore/platform/Cookie.h
Source/WebCore/platform/mediastream/MediaConstraints.h
Source/WebCore/platform/network/FormData.h
Source/WebCore/workers/service/ServiceWorkerJobData.h
Source/WebCore/workers/service/ServiceWorkerRegistrationData.h
Source/WebCore/workers/service/ServiceWorkerRegistrationKey.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp
Source/WebKit/Platform/IPC/ArgumentCoders.cpp
Source/WebKit/Platform/IPC/ArgumentCoders.h
Source/WebKit/Shared/AssistedNodeInformation.cpp
Source/WebKit/Shared/AssistedNodeInformation.h
Source/WebKit/Shared/CallbackID.h
Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm
Source/WebKit/Shared/Databases/IndexedDB/WebIDBResult.cpp
Source/WebKit/Shared/FrameInfoData.cpp
Source/WebKit/Shared/Gamepad/GamepadData.cpp
Source/WebKit/Shared/Gamepad/GamepadData.h
Source/WebKit/Shared/PlatformPopupMenuData.cpp
Source/WebKit/Shared/PlatformPopupMenuData.h
Source/WebKit/Shared/Plugins/NPIdentifierData.cpp
Source/WebKit/Shared/Plugins/NPIdentifierData.h
Source/WebKit/Shared/Plugins/NPVariantData.cpp
Source/WebKit/Shared/Plugins/NPVariantData.h
Source/WebKit/Shared/RTCNetwork.cpp
Source/WebKit/Shared/RTCNetwork.h
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h
Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm
Source/WebKit/Shared/SessionState.cpp
Source/WebKit/Shared/SessionState.h
Source/WebKit/Shared/WebCompiledContentRuleListData.cpp
Source/WebKit/Shared/WebCompiledContentRuleListData.h
Source/WebKit/Shared/WebContextMenuItemData.cpp
Source/WebKit/Shared/WebContextMenuItemData.h
Source/WebKit/Shared/WebCoreArgumentCoders.cpp
Source/WebKit/Shared/WebCoreArgumentCoders.h
Source/WebKit/Shared/WebEvent.h
Source/WebKit/Shared/WebPageCreationParameters.cpp
Source/WebKit/Shared/WebPlatformTouchPoint.cpp
Source/WebKit/Shared/WebPopupItem.cpp
Source/WebKit/Shared/WebPopupItem.h
Source/WebKit/Shared/WebUserContentControllerDataTypes.cpp
Source/WebKit/Shared/WebUserContentControllerDataTypes.h
Source/WebKit/Shared/WebsiteData/WebsiteData.cpp
Source/WebKit/Shared/WebsiteData/WebsiteData.h
Source/WebKit/Shared/WebsiteDataStoreParameters.cpp
Source/WebKit/Shared/ios/WebPlatformTouchPointIOS.cpp
Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm
Source/WebKit/UIProcess/LegacySessionStateCodingNone.cpp
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm

index 7b88b36..dff41c8 100644 (file)
@@ -1,3 +1,52 @@
+2017-09-19  Alex Christensen  <achristensen@webkit.org>
+
+        Allow modern decoding of Vectors
+        https://bugs.webkit.org/show_bug.cgi?id=177102
+
+        Reviewed by Andy Estes.
+
+        * Modules/cache/DOMCacheEngine.h:
+        (WebCore::DOMCacheEngine::CacheInfos::decode):
+        (WebCore::DOMCacheEngine::CacheIdentifierOperationResult::decode):
+        * Modules/indexeddb/IDBDatabaseIdentifier.cpp:
+        (WebCore::IDBDatabaseIdentifier::IDBDatabaseIdentifier):
+        * Modules/indexeddb/IDBDatabaseIdentifier.h:
+        (WebCore::IDBDatabaseIdentifier::decode):
+        * Modules/indexeddb/IDBFactory.cpp:
+        (WebCore::IDBFactory::openInternal):
+        (WebCore::IDBFactory::deleteDatabase):
+        * Modules/indexeddb/IDBGetAllResult.h:
+        (WebCore::IDBGetAllResult::decode):
+        * Modules/indexeddb/IDBGetResult.h:
+        (WebCore::IDBGetResult::decode):
+        * Modules/indexeddb/IDBKeyData.h:
+        (WebCore::IDBKeyData::decode):
+        * Modules/indexeddb/IDBKeyRangeData.h:
+        (WebCore::IDBKeyRangeData::decode):
+        * Modules/indexeddb/IDBValue.h:
+        (WebCore::IDBValue::decode):
+        * Modules/indexeddb/shared/IDBError.h:
+        * Modules/indexeddb/shared/IDBIterateCursorData.h:
+        (WebCore::IDBIterateCursorData::decode):
+        * Modules/indexeddb/shared/IDBRequestData.h:
+        (WebCore::IDBRequestData::decode):
+        * Modules/indexeddb/shared/IDBResultData.h:
+        (WebCore::IDBResultData::decode):
+        * page/SecurityOriginData.h:
+        (WebCore::SecurityOriginData::decode):
+        * platform/Cookie.h:
+        (WebCore::Cookie::decode):
+        * platform/mediastream/MediaConstraints.h:
+        (WebCore::MediaTrackConstraintSetMap::decode):
+        * platform/network/FormData.h:
+        (WebCore::FormDataElement::decode):
+        * workers/service/ServiceWorkerJobData.h:
+        (WebCore::ServiceWorkerJobData::decode):
+        * workers/service/ServiceWorkerRegistrationData.h:
+        (WebCore::ServiceWorkerRegistrationData::decode):
+        * workers/service/ServiceWorkerRegistrationKey.h:
+        (WebCore::ServiceWorkerRegistrationKey::decode):
+
 2017-09-19  Ryosuke Niwa  <rniwa@webkit.org>
 
         On iOS, getData can't get text set by setData during copy event
index ea66bbc..eb555a5 100644 (file)
@@ -79,7 +79,7 @@ struct CacheInfos {
     CacheInfos isolatedCopy();
 
     template<class Encoder> void encode(Encoder&) const;
-    template<class Decoder> static bool decode(Decoder&, CacheInfos&);
+    template<class Decoder> static std::optional<CacheInfos> decode(Decoder&);
 
     Vector<CacheInfo> infos;
     uint64_t updateCounter;
@@ -87,7 +87,7 @@ struct CacheInfos {
 
 struct CacheIdentifierOperationResult {
     template<class Encoder> void encode(Encoder&) const;
-    template<class Decoder> static bool decode(Decoder&, CacheIdentifierOperationResult&);
+    template<class Decoder> static std::optional<CacheIdentifierOperationResult> decode(Decoder&);
 
     uint64_t identifier { 0 };
     // True in case storing cache list on the filesystem failed.
@@ -115,11 +115,19 @@ template<class Encoder> inline void CacheInfos::encode(Encoder& encoder) const
     encoder << updateCounter;
 }
 
-template<class Decoder> inline bool CacheInfos::decode(Decoder& decoder, CacheInfos& cacheInfos)
+template<class Decoder> inline std::optional<CacheInfos> CacheInfos::decode(Decoder& decoder)
 {
-    if (!decoder.decode(cacheInfos.infos))
-        return false;
-    return decoder.decode(cacheInfos.updateCounter);
+    std::optional<Vector<CacheInfo>> infos;
+    decoder >> infos;
+    if (!infos)
+        return std::nullopt;
+    
+    std::optional<uint64_t> updateCounter;
+    decoder >> updateCounter;
+    if (!updateCounter)
+        return std::nullopt;
+    
+    return {{ WTFMove(*infos), WTFMove(*updateCounter) }};
 }
 
 template<class Encoder> inline void CacheIdentifierOperationResult::encode(Encoder& encoder) const
@@ -128,12 +136,18 @@ template<class Encoder> inline void CacheIdentifierOperationResult::encode(Encod
     encoder << hadStorageError;
 }
 
-template<class Decoder> inline bool CacheIdentifierOperationResult::decode(Decoder& decoder, CacheIdentifierOperationResult& result)
+template<class Decoder> inline std::optional<CacheIdentifierOperationResult> CacheIdentifierOperationResult::decode(Decoder& decoder)
 {
-    if (!decoder.decode(result.identifier))
-        return false;
-
-    return decoder.decode(result.hadStorageError);
+    std::optional<uint64_t> identifier;
+    decoder >> identifier;
+    if (!identifier)
+        return std::nullopt;
+    
+    std::optional<bool> hadStorageError;
+    decoder >> hadStorageError;
+    if (!hadStorageError)
+        return std::nullopt;
+    return {{ WTFMove(*identifier), WTFMove(*hadStorageError) }};
 }
 
 } // namespace DOMCacheEngine
index 81975a2..d946be4 100644 (file)
 
 namespace WebCore {
 
-IDBDatabaseIdentifier::IDBDatabaseIdentifier(const String& databaseName, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin)
+IDBDatabaseIdentifier::IDBDatabaseIdentifier(const String& databaseName, SecurityOriginData&& openingOrigin, SecurityOriginData&& mainFrameOrigin)
     : m_databaseName(databaseName)
-    , m_openingOrigin(SecurityOriginData::fromSecurityOrigin(openingOrigin))
-    , m_mainFrameOrigin(SecurityOriginData::fromSecurityOrigin(mainFrameOrigin))
+    , m_openingOrigin(WTFMove(openingOrigin))
+    , m_mainFrameOrigin(WTFMove(mainFrameOrigin))
 
 {
     // The empty string is a valid database name, but a null string is not.
index 5978428..79da554 100644 (file)
@@ -43,6 +43,8 @@ public:
     {
     }
 
+    WEBCORE_EXPORT IDBDatabaseIdentifier(const String& databaseName, SecurityOriginData&& openingOrigin, SecurityOriginData&& mainFrameOrigin);
+
     IDBDatabaseIdentifier isolatedCopy() const;
 
     bool isHashTableDeletedValue() const
@@ -62,8 +64,6 @@ public:
         return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
     }
 
-    IDBDatabaseIdentifier(const String& databaseName, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin);
-
     bool isValid() const
     {
         return !m_databaseName.isNull()
@@ -88,7 +88,7 @@ public:
     static String databaseDirectoryRelativeToRoot(const SecurityOriginData& topLevelOrigin, const SecurityOriginData& openingOrigin, const String& rootDirectory);
 
     template<class Encoder> void encode(Encoder&) const;
-    template<class Decoder> static bool decode(Decoder&, IDBDatabaseIdentifier&);
+    template<class Decoder> static std::optional<IDBDatabaseIdentifier> decode(Decoder&);
 
 #if !LOG_DISABLED
     String debugString() const;
@@ -124,18 +124,28 @@ void IDBDatabaseIdentifier::encode(Encoder& encoder) const
 }
 
 template<class Decoder>
-bool IDBDatabaseIdentifier::decode(Decoder& decoder, IDBDatabaseIdentifier& identifier)
+std::optional<IDBDatabaseIdentifier> IDBDatabaseIdentifier::decode(Decoder& decoder)
 {
-    if (!decoder.decode(identifier.m_databaseName))
-        return false;
-
-    if (!decoder.decode(identifier.m_openingOrigin))
-        return false;
-
-    if (!decoder.decode(identifier.m_mainFrameOrigin))
-        return false;
-
-    return true;
+    std::optional<String> databaseName;
+    decoder >> databaseName;
+    if (!databaseName)
+        return std::nullopt;
+
+    std::optional<SecurityOriginData> openingOrigin;
+    decoder >> openingOrigin;
+    if (!openingOrigin)
+        return std::nullopt;
+
+    std::optional<SecurityOriginData> mainFrameOrigin;
+    decoder >> mainFrameOrigin;
+    if (!mainFrameOrigin)
+        return std::nullopt;
+
+    IDBDatabaseIdentifier identifier;
+    identifier.m_databaseName = WTFMove(*databaseName); // FIXME: When decoding from IPC, databaseName can be null, and the non-empty constructor asserts that this is not the case.
+    identifier.m_openingOrigin = WTFMove(*openingOrigin);
+    identifier.m_mainFrameOrigin = WTFMove(*mainFrameOrigin);
+    return WTFMove(identifier);
 }
 
 } // namespace WebCore
index b88ac34..0bca714 100644 (file)
@@ -93,7 +93,7 @@ ExceptionOr<Ref<IDBOpenDBRequest>> IDBFactory::openInternal(ScriptExecutionConte
         return Exception { SecurityError, ASCIILiteral("IDBFactory.open() called in an invalid security context") };
 
     ASSERT(context.securityOrigin());
-    IDBDatabaseIdentifier databaseIdentifier(name, *context.securityOrigin(), context.topOrigin());
+    IDBDatabaseIdentifier databaseIdentifier(name, SecurityOriginData::fromSecurityOrigin(*context.securityOrigin()), SecurityOriginData::fromSecurityOrigin(context.topOrigin()));
     if (!databaseIdentifier.isValid())
         return Exception { TypeError, ASCIILiteral("IDBFactory.open() called with an invalid security origin") };
 
@@ -113,7 +113,7 @@ ExceptionOr<Ref<IDBOpenDBRequest>> IDBFactory::deleteDatabase(ScriptExecutionCon
         return Exception { SecurityError, ASCIILiteral("IDBFactory.deleteDatabase() called in an invalid security context") };
 
     ASSERT(context.securityOrigin());
-    IDBDatabaseIdentifier databaseIdentifier(name, *context.securityOrigin(), context.topOrigin());
+    IDBDatabaseIdentifier databaseIdentifier(name, SecurityOriginData::fromSecurityOrigin(*context.securityOrigin()), SecurityOriginData::fromSecurityOrigin(context.topOrigin()));
     if (!databaseIdentifier.isValid())
         return Exception { TypeError, ASCIILiteral("IDBFactory.deleteDatabase() called with an invalid security origin") };
 
index ef7c257..27b759d 100644 (file)
@@ -107,16 +107,21 @@ bool IDBGetAllResult::decode(Decoder& decoder, IDBGetAllResult& result)
         return false;
 
     switch (index) {
-    case 0:
+    case 0: {
         result.m_results = Vector<IDBKeyData>();
         if (!decoder.decode(WTF::get<Vector<IDBKeyData>>(result.m_results)))
             return false;
         break;
-    case 1:
+    }
+    case 1: {
         result.m_results = Vector<IDBValue>();
-        if (!decoder.decode(WTF::get<Vector<IDBValue>>(result.m_results)))
+        std::optional<Vector<IDBValue>> optional;
+        decoder >> optional;
+        if (!optional)
             return false;
+        WTF::get<Vector<IDBValue>>(result.m_results) = WTFMove(*optional);
         break;
+    }
     case 2:
         result.m_results = nullptr;
         break;
index 6224464..109e489 100644 (file)
@@ -131,11 +131,17 @@ void IDBGetResult::encode(Encoder& encoder) const
 template<class Decoder>
 bool IDBGetResult::decode(Decoder& decoder, IDBGetResult& result)
 {
-    if (!decoder.decode(result.m_keyData))
+    std::optional<IDBKeyData> keyData;
+    decoder >> keyData;
+    if (!keyData)
         return false;
+    result.m_keyData = WTFMove(*keyData);
 
-    if (!decoder.decode(result.m_primaryKeyData))
+    std::optional<IDBKeyData> primaryKeyData;
+    decoder >> primaryKeyData;
+    if (!primaryKeyData)
         return false;
+    result.m_primaryKeyData = WTFMove(*primaryKeyData);
 
     if (!decoder.decode(result.m_keyPath))
         return false;
@@ -143,8 +149,11 @@ bool IDBGetResult::decode(Decoder& decoder, IDBGetResult& result)
     if (!decoder.decode(result.m_isDefined))
         return false;
 
-    if (!decoder.decode(result.m_value))
+    std::optional<IDBValue> value;
+    decoder >> value;
+    if (!value)
         return false;
+    result.m_value = WTFMove(*value);
 
     return true;
 }
index fcc1688..8cc864a 100644 (file)
@@ -86,7 +86,7 @@ public:
     WEBCORE_EXPORT void setNumberValue(double);
 
     template<class Encoder> void encode(Encoder&) const;
-    template<class Decoder> static bool decode(Decoder&, IDBKeyData&);
+    template<class Decoder> static std::optional<IDBKeyData> decode(Decoder&);
     
 #if !LOG_DISABLED
     WEBCORE_EXPORT String loggingString() const;
@@ -258,16 +258,17 @@ void IDBKeyData::encode(Encoder& encoder) const
 }
 
 template<class Decoder>
-bool IDBKeyData::decode(Decoder& decoder, IDBKeyData& keyData)
+std::optional<IDBKeyData> IDBKeyData::decode(Decoder& decoder)
 {
+    IDBKeyData keyData;
     if (!decoder.decode(keyData.m_isNull))
-        return false;
+        return std::nullopt;
 
     if (keyData.m_isNull)
-        return true;
+        return WTFMove(keyData);
 
     if (!decoder.decodeEnum(keyData.m_type))
-        return false;
+        return std::nullopt;
 
     switch (keyData.m_type) {
     case KeyType::Invalid:
@@ -277,27 +278,27 @@ bool IDBKeyData::decode(Decoder& decoder, IDBKeyData& keyData)
     case KeyType::Array:
         keyData.m_value = Vector<IDBKeyData>();
         if (!decoder.decode(WTF::get<Vector<IDBKeyData>>(keyData.m_value)))
-            return false;
+            return std::nullopt;
         break;
     case KeyType::Binary:
         keyData.m_value = ThreadSafeDataBuffer();
         if (!decoder.decode(WTF::get<ThreadSafeDataBuffer>(keyData.m_value)))
-            return false;
+            return std::nullopt;
         break;
     case KeyType::String:
         keyData.m_value = String();
         if (!decoder.decode(WTF::get<String>(keyData.m_value)))
-            return false;
+            return std::nullopt;
         break;
     case KeyType::Date:
     case KeyType::Number:
         keyData.m_value = 0.0;
         if (!decoder.decode(WTF::get<double>(keyData.m_value)))
-            return false;
+            return std::nullopt;
         break;
     }
 
-    return true;
+    return WTFMove(keyData);
 }
 
 using IDBKeyDataSet = std::set<IDBKeyData, std::less<IDBKeyData>, FastAllocator<IDBKeyData>>;
index 12ecd4d..6a62fa6 100644 (file)
@@ -111,11 +111,17 @@ bool IDBKeyRangeData::decode(Decoder& decoder, IDBKeyRangeData& keyRange)
     if (keyRange.isNull)
         return true;
 
-    if (!decoder.decode(keyRange.upperKey))
+    std::optional<IDBKeyData> upperKey;
+    decoder >> upperKey;
+    if (!upperKey)
         return false;
-
-    if (!decoder.decode(keyRange.lowerKey))
+    keyRange.upperKey = WTFMove(*upperKey);
+    
+    std::optional<IDBKeyData> lowerKey;
+    decoder >> lowerKey;
+    if (!lowerKey)
         return false;
+    keyRange.lowerKey = WTFMove(*lowerKey);
 
     if (!decoder.decode(keyRange.upperOpen))
         return false;
index 2b2cfac..d944859 100644 (file)
@@ -50,7 +50,7 @@ public:
     const Vector<String>& blobFilePaths() const { return m_blobFilePaths; }
 
     template<class Encoder> void encode(Encoder&) const;
-    template<class Decoder> static bool decode(Decoder&, IDBValue&);
+    template<class Decoder> static std::optional<IDBValue> decode(Decoder&);
 
 private:
     ThreadSafeDataBuffer m_data;
@@ -68,18 +68,19 @@ void IDBValue::encode(Encoder& encoder) const
 }
 
 template<class Decoder>
-bool IDBValue::decode(Decoder& decoder, IDBValue& result)
+std::optional<IDBValue> IDBValue::decode(Decoder& decoder)
 {
+    IDBValue result;
     if (!decoder.decode(result.m_data))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.m_blobURLs))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.m_blobFilePaths))
-        return false;
+        return std::nullopt;
 
-    return true;
+    return WTFMove(result);
 }
 
 } // namespace WebCore
index ad1cd0b..4c6e0ca 100644 (file)
@@ -42,7 +42,7 @@ public:
         return IDBError { UnknownError, ASCIILiteral("Database deleted by request of the user") };
     }
 
-    IDBError& operator=(const IDBError&);
+    WEBCORE_EXPORT IDBError& operator=(const IDBError&);
 
     RefPtr<DOMError> toDOMError() const;
 
index 609f748..1f3c7c5 100644 (file)
@@ -55,11 +55,17 @@ void IDBIterateCursorData::encode(Encoder& encoder) const
 template<class Decoder>
 bool IDBIterateCursorData::decode(Decoder& decoder, IDBIterateCursorData& iteratorCursorData)
 {
-    if (!decoder.decode(iteratorCursorData.keyData))
+    std::optional<IDBKeyData> keyData;
+    decoder >> keyData;
+    if (!keyData)
         return false;
+    iteratorCursorData.keyData = WTFMove(*keyData);
 
-    if (!decoder.decode(iteratorCursorData.primaryKeyData))
+    std::optional<IDBKeyData> primaryKeyData;
+    decoder >> primaryKeyData;
+    if (!primaryKeyData)
         return false;
+    iteratorCursorData.primaryKeyData = WTFMove(*primaryKeyData);
 
     uint64_t count;
     if (!decoder.decode(count))
index 8948bb9..9432511 100644 (file)
@@ -126,8 +126,11 @@ bool IDBRequestData::decode(Decoder& decoder, IDBRequestData& request)
     if (!decoder.decode(request.m_indexIdentifier))
         return false;
 
-    if (!decoder.decode(request.m_databaseIdentifier))
+    std::optional<IDBDatabaseIdentifier> databaseIdentifier;
+    decoder >> databaseIdentifier;
+    if (!databaseIdentifier)
         return false;
+    request.m_databaseIdentifier = WTFMove(*databaseIdentifier);
 
     if (!decoder.decode(request.m_requestedVersion))
         return false;
index 217c9a3..56bdcbf 100644 (file)
@@ -88,6 +88,7 @@ public:
     static IDBResultData iterateCursorSuccess(const IDBResourceIdentifier&, const IDBGetResult&);
 
     WEBCORE_EXPORT IDBResultData(const IDBResultData&);
+    IDBResultData& operator=(IDBResultData&&) = default;
 
     enum IsolatedCopyTag { IsolatedCopy };
     IDBResultData(const IDBResultData&, IsolatedCopyTag);
@@ -110,7 +111,7 @@ public:
 
     WEBCORE_EXPORT IDBResultData();
     template<class Encoder> void encode(Encoder&) const;
-    template<class Decoder> static bool decode(Decoder&, IDBResultData&);
+    template<class Decoder> static std::optional<IDBResultData> decode(Decoder&);
 
 private:
     IDBResultData(const IDBResourceIdentifier&);
@@ -159,71 +160,75 @@ void IDBResultData::encode(Encoder& encoder) const
         encoder << *m_getAllResult;
 }
 
-template<class Decoder> bool IDBResultData::decode(Decoder& decoder, IDBResultData& result)
+template<class Decoder> std::optional<IDBResultData> IDBResultData::decode(Decoder& decoder)
 {
+    IDBResultData result;
     if (!decoder.decode(result.m_requestIdentifier))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.m_error))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.m_databaseConnectionIdentifier))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.m_resultInteger))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decodeEnum(result.m_type))
-        return false;
+        return std::nullopt;
 
     bool hasObject;
 
     if (!decoder.decode(hasObject))
-        return false;
+        return std::nullopt;
     if (hasObject) {
         auto object = std::make_unique<IDBDatabaseInfo>();
         if (!decoder.decode(*object))
-            return false;
+            return std::nullopt;
         result.m_databaseInfo = WTFMove(object);
     }
 
     if (!decoder.decode(hasObject))
-        return false;
+        return std::nullopt;
     if (hasObject) {
         auto object = std::make_unique<IDBTransactionInfo>();
         if (!decoder.decode(*object))
-            return false;
+            return std::nullopt;
         result.m_transactionInfo = WTFMove(object);
     }
 
     if (!decoder.decode(hasObject))
-        return false;
+        return std::nullopt;
     if (hasObject) {
         auto object = std::make_unique<IDBKeyData>();
-        if (!decoder.decode(*object))
-            return false;
+        std::optional<IDBKeyData> optional;
+        decoder >> optional;
+        if (!optional)
+            return std::nullopt;
+        *object = WTFMove(*optional);
         result.m_resultKey = WTFMove(object);
     }
 
     if (!decoder.decode(hasObject))
-        return false;
+        return std::nullopt;
     if (hasObject) {
         auto object = std::make_unique<IDBGetResult>();
         if (!decoder.decode(*object))
-            return false;
+            return std::nullopt;
         result.m_getResult = WTFMove(object);
     }
 
     if (!decoder.decode(hasObject))
-        return false;
+        return std::nullopt;
     if (hasObject) {
         auto object = std::make_unique<IDBGetAllResult>();
         if (!decoder.decode(*object))
-            return false;
+            return std::nullopt;
         result.m_getAllResult = WTFMove(object);
     }
 
-    return true;
+    return WTFMove(result);
 }
 
 } // namespace WebCore
index 82de096..2cb231f 100644 (file)
@@ -65,7 +65,7 @@ struct SecurityOriginData {
     WEBCORE_EXPORT static std::optional<SecurityOriginData> fromDatabaseIdentifier(const String&);
     
     template<class Encoder> void encode(Encoder&) const;
-    template<class Decoder> static bool decode(Decoder&, SecurityOriginData&);
+    template<class Decoder> static std::optional<SecurityOriginData> decode(Decoder&);
 
     bool isEmpty() const
     {
@@ -93,16 +93,23 @@ void SecurityOriginData::encode(Encoder& encoder) const
 }
 
 template<class Decoder>
-bool SecurityOriginData::decode(Decoder& decoder, SecurityOriginData& securityOriginData)
+std::optional<SecurityOriginData> SecurityOriginData::decode(Decoder& decoder)
 {
-    if (!decoder.decode(securityOriginData.protocol))
-        return false;
-    if (!decoder.decode(securityOriginData.host))
-        return false;
-    if (!decoder.decode(securityOriginData.port))
-        return false;
-
-    return true;
+    std::optional<String> protocol;
+    decoder >> protocol;
+    if (!protocol)
+        return std::nullopt;
+    
+    std::optional<String> host;
+    decoder >> host;
+    if (!host)
+        return std::nullopt;
+    
+    std::optional<uint16_t> port;
+    if (!decoder.decode(port))
+        return std::nullopt;
+    
+    return {{ WTFMove(*protocol), WTFMove(*host), WTFMove(port) }};
 }
 
 struct SecurityOriginDataHashTraits : WTF::SimpleClassHashTraits<SecurityOriginData> {
index 99c9a7d..0933cca 100644 (file)
@@ -59,7 +59,7 @@ struct Cookie {
     }
 
     template<class Encoder> void encode(Encoder&) const;
-    template<class Decoder> static bool decode(Decoder&, Cookie&);
+    template<class Decoder> static std::optional<Cookie> decode(Decoder&);
 
     WEBCORE_EXPORT bool operator==(const Cookie&) const;
     WEBCORE_EXPORT unsigned hash() const;
@@ -117,32 +117,63 @@ void Cookie::encode(Encoder& encoder) const
 }
 
 template<class Decoder>
-bool Cookie::decode(Decoder& decoder, Cookie& cookie)
+std::optional<Cookie> Cookie::decode(Decoder& decoder)
 {
-    if (!decoder.decode(cookie.name))
-        return false;
-    if (!decoder.decode(cookie.value))
-        return false;
-    if (!decoder.decode(cookie.domain))
-        return false;
-    if (!decoder.decode(cookie.path))
-        return false;
-    if (!decoder.decode(cookie.expires))
-        return false;
-    if (!decoder.decode(cookie.httpOnly))
-        return false;
-    if (!decoder.decode(cookie.secure))
-        return false;
-    if (!decoder.decode(cookie.session))
-        return false;
-    if (!decoder.decode(cookie.comment))
-        return false;
-    if (!decoder.decode(cookie.commentURL))
-        return false;
-    if (!decoder.decode(cookie.ports))
-        return false;
-
-    return true;
+    std::optional<String> name;
+    decoder >> name;
+    if (!name)
+        return std::nullopt;
+    
+    std::optional<String> value;
+    decoder >> value;
+    if (!value)
+        return std::nullopt;
+
+    std::optional<String> domain;
+    decoder >> domain;
+    if (!domain)
+        return std::nullopt;
+
+    std::optional<String> path;
+    decoder >> path;
+    if (!path)
+        return std::nullopt;
+
+    std::optional<double> expires;
+    decoder >> expires;
+    if (!expires)
+        return std::nullopt;
+
+    std::optional<bool> httpOnly;
+    decoder >> httpOnly;
+    if (!httpOnly)
+        return std::nullopt;
+
+    std::optional<bool> secure;
+    decoder >> secure;
+    if (!secure)
+        return std::nullopt;
+
+    std::optional<bool> session;
+    decoder >> session;
+    if (!session)
+        return std::nullopt;
+
+    std::optional<String> comment;
+    decoder >> comment;
+    if (!comment)
+        return std::nullopt;
+
+    URL commentURL;
+    if (!decoder.decode(commentURL))
+        return std::nullopt;
+
+    std::optional<Vector<uint16_t>> ports;
+    decoder >> ports;
+    if (!ports)
+        return std::nullopt;
+
+    return {{ WTFMove(*name), WTFMove(*value), WTFMove(*domain), WTFMove(*path), WTFMove(*expires), WTFMove(*httpOnly), WTFMove(*secure), WTFMove(*session), WTFMove(*comment), WTFMove(commentURL), WTFMove(*ports) }};
 }
 
 }
index bffa05e..4c96969 100644 (file)
@@ -616,35 +616,36 @@ public:
         encoder << m_groupId;
     }
 
-    template <class Decoder> static bool decode(Decoder& decoder, MediaTrackConstraintSetMap& map)
+    template <class Decoder> static std::optional<MediaTrackConstraintSetMap> decode(Decoder& decoder)
     {
+        MediaTrackConstraintSetMap map;
         if (!decoder.decode(map.m_width))
-            return false;
+            return std::nullopt;
         if (!decoder.decode(map.m_height))
-            return false;
+            return std::nullopt;
         if (!decoder.decode(map.m_sampleRate))
-            return false;
+            return std::nullopt;
         if (!decoder.decode(map.m_sampleSize))
-            return false;
+            return std::nullopt;
 
         if (!decoder.decode(map.m_aspectRatio))
-            return false;
+            return std::nullopt;
         if (!decoder.decode(map.m_frameRate))
-            return false;
+            return std::nullopt;
         if (!decoder.decode(map.m_volume))
-            return false;
+            return std::nullopt;
 
         if (!decoder.decode(map.m_echoCancellation))
-            return false;
+            return std::nullopt;
 
         if (!decoder.decode(map.m_facingMode))
-            return false;
+            return std::nullopt;
         if (!decoder.decode(map.m_deviceId))
-            return false;
+            return std::nullopt;
         if (!decoder.decode(map.m_groupId))
-            return false;
+            return std::nullopt;
 
-        return true;
+        return WTFMove(map);
     }
 
 private:
index d1abc01..fe4f58e 100644 (file)
@@ -76,7 +76,7 @@ public:
     template<typename Encoder>
     void encode(Encoder&) const;
     template<typename Decoder>
-    static bool decode(Decoder&, FormDataElement& result);
+    static std::optional<FormDataElement> decode(Decoder&);
 
     Type m_type;
     Vector<char> m_data;
@@ -143,51 +143,52 @@ void FormDataElement::encode(Encoder& encoder) const
 }
 
 template<typename Decoder>
-bool FormDataElement::decode(Decoder& decoder, FormDataElement& result)
+std::optional<FormDataElement> FormDataElement::decode(Decoder& decoder)
 {
+    FormDataElement result;
     if (!decoder.decodeEnum(result.m_type))
-        return false;
+        return std::nullopt;
 
     switch (result.m_type) {
     case Type::Data:
         if (!decoder.decode(result.m_data))
-            return false;
+            return std::nullopt;
 
-        return true;
+        return WTFMove(result);
 
     case Type::EncodedFile:
         if (!decoder.decode(result.m_filename))
-            return false;
+            return std::nullopt;
         if (!decoder.decode(result.m_generatedFilename))
-            return false;
+            return std::nullopt;
         if (!decoder.decode(result.m_shouldGenerateFile))
-            return false;
+            return std::nullopt;
         result.m_ownsGeneratedFile = false;
         if (!decoder.decode(result.m_fileStart))
-            return false;
+            return std::nullopt;
         if (!decoder.decode(result.m_fileLength))
-            return false;
+            return std::nullopt;
 
         if (result.m_fileLength != BlobDataItem::toEndOfFile && result.m_fileLength < result.m_fileStart)
-            return false;
+            return std::nullopt;
 
         if (!decoder.decode(result.m_expectedFileModificationTime))
-            return false;
+            return std::nullopt;
 
-        return true;
+        return WTFMove(result);
 
     case Type::EncodedBlob: {
         String blobURLString;
         if (!decoder.decode(blobURLString))
-            return false;
+            return std::nullopt;
 
         result.m_url = URL(URL(), blobURLString);
 
-        return true;
+        return WTFMove(result);
     }
     }
 
-    return false;
+    return std::nullopt;
 }
 
 class FormData : public RefCounted<FormData> {
index 7065261..a6d371a 100644 (file)
@@ -93,8 +93,13 @@ std::optional<ServiceWorkerJobData> ServiceWorkerJobData::decode(Decoder& decode
         return std::nullopt;
     if (!decoder.decode(jobData->clientCreationURL))
         return std::nullopt;
-    if (!decoder.decode(jobData->topOrigin))
+
+    std::optional<SecurityOriginData> topOrigin;
+    decoder >> topOrigin;
+    if (!topOrigin)
         return std::nullopt;
+    jobData->topOrigin = WTFMove(*topOrigin);
+
     if (!decoder.decode(jobData->scopeURL))
         return std::nullopt;
     if (!decoder.decodeEnum(jobData->type))
index ba6c584..85850aa 100644 (file)
@@ -38,7 +38,7 @@ struct ServiceWorkerRegistrationData {
     ServiceWorkerRegistrationData isolatedCopy() const;
 
     template<class Encoder> void encode(Encoder&) const;
-    template<class Decoder> static bool decode(Decoder&, ServiceWorkerRegistrationData&);
+    template<class Decoder> static std::optional<ServiceWorkerRegistrationData> decode(Decoder&);
 };
 
 
@@ -49,14 +49,19 @@ void ServiceWorkerRegistrationData::encode(Encoder& encoder) const
 }
 
 template<class Decoder>
-bool ServiceWorkerRegistrationData::decode(Decoder& decoder, ServiceWorkerRegistrationData& data)
+std::optional<ServiceWorkerRegistrationData> ServiceWorkerRegistrationData::decode(Decoder& decoder)
 {
-    if (!decoder.decode(data.key))
-        return false;
-    if (!decoder.decodeEnum(data.identifier))
-        return false;
-
-    return true;
+    std::optional<ServiceWorkerRegistrationKey> key;
+    decoder >> key;
+    if (!key)
+        return std::nullopt;
+    
+    std::optional<uint64_t> identifier;
+    decoder >> identifier;
+    if (!identifier)
+        return std::nullopt;
+    
+    return {{ WTFMove(*key), WTFMove(*identifier) }};
 }
 
 } // namespace WTF
index 6fe9550..e58326a 100644 (file)
@@ -44,7 +44,7 @@ struct ServiceWorkerRegistrationKey {
     ServiceWorkerRegistrationKey isolatedCopy() const;
 
     template<class Encoder> void encode(Encoder&) const;
-    template<class Decoder> static bool decode(Decoder&, ServiceWorkerRegistrationKey&);
+    template<class Decoder> static std::optional<ServiceWorkerRegistrationKey> decode(Decoder&);
 };
 
 template<class Encoder>
@@ -54,14 +54,18 @@ void ServiceWorkerRegistrationKey::encode(Encoder& encoder) const
 }
 
 template<class Decoder>
-bool ServiceWorkerRegistrationKey::decode(Decoder& decoder, ServiceWorkerRegistrationKey& key)
+std::optional<ServiceWorkerRegistrationKey> ServiceWorkerRegistrationKey::decode(Decoder& decoder)
 {
-    if (!decoder.decode(key.clientCreationURL))
-        return false;
-    if (!decoder.decode(key.topOrigin))
-        return false;
-
-    return true;
+    URL clientCreationURL;
+    if (!decoder.decode(clientCreationURL))
+        return std::nullopt;
+
+    std::optional<SecurityOriginData> topOrigin;
+    decoder >> topOrigin;
+    if (!topOrigin)
+        return std::nullopt;
+    
+    return {{ WTFMove(clientCreationURL), WTFMove(*topOrigin) }};
 }
 
 } // namespace WebCore
index 51c3a1e..b0a60eb 100644 (file)
@@ -1,3 +1,121 @@
+2017-09-19  Alex Christensen  <achristensen@webkit.org>
+
+        Allow modern decoding of Vectors
+        https://bugs.webkit.org/show_bug.cgi?id=177102
+
+        Reviewed by Andy Estes.
+
+        Rather than allow modern decoding of Vectors of types that only allow legacy decoding,
+        I just made modern decoders for all types that we need to decode in Vectors.
+
+        * NetworkProcess/NetworkResourceLoadParameters.cpp:
+        (WebKit::NetworkResourceLoadParameters::decode):
+        * Platform/IPC/ArgumentCoders.cpp:
+        (IPC::ArgumentCoder<std::chrono::system_clock::time_point>::decode):
+        * Platform/IPC/ArgumentCoders.h:
+        * Shared/AssistedNodeInformation.cpp:
+        (WebKit::OptionItem::decode):
+        * Shared/AssistedNodeInformation.h:
+        * Shared/CallbackID.h:
+        (WebKit::CallbackID::decode):
+        * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
+        (IPC::ArgumentCoder<WebCore::PaymentError>::decode):
+        (IPC::ArgumentCoder<WebCore::PaymentMethodUpdate>::decode):
+        (IPC::ArgumentCoder<ApplePaySessionPaymentRequest>::decode):
+        (IPC::ArgumentCoder<ApplePaySessionPaymentRequest::LineItem>::decode):
+        (IPC::ArgumentCoder<ApplePaySessionPaymentRequest::ShippingMethod>::decode):
+        (IPC::ArgumentCoder<ApplePaySessionPaymentRequest::TotalAndLineItems>::decode):
+        (IPC::ArgumentCoder<WebCore::ShippingContactUpdate>::decode):
+        (IPC::ArgumentCoder<WebCore::ShippingMethodUpdate>::decode):
+        * Shared/Databases/IndexedDB/WebIDBResult.cpp:
+        (WebKit::WebIDBResult::decode):
+        * Shared/FrameInfoData.cpp:
+        (WebKit::FrameInfoData::decode):
+        * Shared/Gamepad/GamepadData.cpp:
+        (WebKit::GamepadData::decode):
+        * Shared/Gamepad/GamepadData.h:
+        * Shared/PlatformPopupMenuData.cpp:
+        (WebKit::PlatformPopupMenuData::decode):
+        * Shared/PlatformPopupMenuData.h:
+        * Shared/Plugins/NPIdentifierData.cpp:
+        (WebKit::NPIdentifierData::decode):
+        * Shared/Plugins/NPIdentifierData.h:
+        * Shared/Plugins/NPVariantData.cpp:
+        (WebKit::NPVariantData::decode):
+        * Shared/Plugins/NPVariantData.h:
+        * Shared/RTCNetwork.cpp:
+        (WebKit::RTCNetwork::IPAddress::decode):
+        (WebKit::RTCNetwork::SocketAddress::decode):
+        (WebKit::RTCNetwork::decode):
+        * Shared/RTCNetwork.h:
+        * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
+        * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::decode):
+        (WebKit::RemoteLayerTreeTransaction::decode):
+        * Shared/SessionState.cpp:
+        (WebKit::HTTPBody::Element::decode):
+        (WebKit::FrameState::decode):
+        (WebKit::PageState::decode):
+        (WebKit::BackForwardListItemState::decode):
+        (WebKit::BackForwardListState::decode):
+        * Shared/SessionState.h:
+        * Shared/WebCompiledContentRuleListData.cpp:
+        (WebKit::WebCompiledContentRuleListData::decode):
+        * Shared/WebCompiledContentRuleListData.h:
+        * Shared/WebContextMenuItemData.cpp:
+        (WebKit::WebContextMenuItemData::decode):
+        * Shared/WebContextMenuItemData.h:
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<DOMCacheEngine::CacheInfo>::decode):
+        (IPC::ArgumentCoder<DOMCacheEngine::Record>::decode):
+        (IPC::ArgumentCoder<FloatRect>::decode):
+        (IPC::ArgumentCoder<FloatQuad>::decode):
+        (IPC::ArgumentCoder<IntRect>::decode):
+        (IPC::ArgumentCoder<RecentSearch>::decode):
+        (IPC::ArgumentCoder<Region::Span>::decode):
+        (IPC::ArgumentCoder<MimeClassInfo>::decode):
+        (IPC::ArgumentCoder<PluginInfo>::decode):
+        (IPC::ArgumentCoder<SelectionRect>::decode):
+        (IPC::ArgumentCoder<CompositionUnderline>::decode):
+        (IPC::ArgumentCoder<DictationAlternative>::decode):
+        (IPC::ArgumentCoder<GrammarDetail>::decode):
+        (IPC::ArgumentCoder<TextCheckingResult>::decode):
+        (IPC::ArgumentCoder<BlobPart>::decode):
+        (IPC::ArgumentCoder<ResourceLoadStatistics>::decode):
+        (IPC::ArgumentCoder<MediaConstraints>::decode):
+        (IPC::ArgumentCoder<CaptureDevice>::decode):
+        (IPC::ArgumentCoder<ScrollOffsetRange<float>>::decode):
+        (IPC::ArgumentCoder<MediaSelectionOption>::decode):
+        * Shared/WebCoreArgumentCoders.h:
+        * Shared/WebEvent.h:
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPlatformTouchPoint.cpp:
+        (WebKit::WebPlatformTouchPoint::decode):
+        * Shared/WebPopupItem.cpp:
+        (WebKit::WebPopupItem::decode):
+        * Shared/WebPopupItem.h:
+        * Shared/WebUserContentControllerDataTypes.cpp:
+        (WebKit::WebUserScriptData::decode):
+        (WebKit::WebUserStyleSheetData::decode):
+        (WebKit::WebScriptMessageHandlerData::decode):
+        * Shared/WebUserContentControllerDataTypes.h:
+        * Shared/WebsiteData/WebsiteData.cpp:
+        (WebKit::WebsiteData::Entry::decode):
+        * Shared/WebsiteData/WebsiteData.h:
+        * Shared/WebsiteDataStoreParameters.cpp:
+        (WebKit::WebsiteDataStoreParameters::decode):
+        * Shared/ios/WebPlatformTouchPointIOS.cpp:
+        (WebKit::WebPlatformTouchPoint::decode):
+        * Shared/mac/WebCoreArgumentCodersMac.mm:
+        (IPC::ArgumentCoder<KeypressCommand>::decode):
+        * UIProcess/LegacySessionStateCodingNone.cpp:
+        (WebKit::decodeLegacySessionState):
+        * WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h:
+        * WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm:
+        (WebKit::PlatformCAAnimationRemote::KeyframeValue::decode):
+        (WebKit::PlatformCAAnimationRemote::Properties::decode):
+
 2017-09-19  Ryosuke Niwa  <rniwa@webkit.org>
 
         On iOS, getData can't get text set by setData during copy event
index 722258c..9087ea3 100644 (file)
@@ -161,11 +161,12 @@ bool NetworkResourceLoadParameters::decode(IPC::Decoder& decoder, NetworkResourc
     if (!decoder.decode(hasSourceOrigin))
         return false;
     if (hasSourceOrigin) {
-        SecurityOriginData sourceOriginData;
-        if (!decoder.decode(sourceOriginData))
+        std::optional<SecurityOriginData> sourceOriginData;
+        decoder >> sourceOriginData;
+        if (!sourceOriginData)
             return false;
-        ASSERT(!sourceOriginData.isEmpty());
-        result.sourceOrigin = sourceOriginData.securityOrigin();
+        ASSERT(!sourceOriginData->isEmpty());
+        result.sourceOrigin = sourceOriginData->securityOrigin();
     }
     if (!decoder.decodeEnum(result.mode))
         return false;
@@ -176,8 +177,11 @@ bool NetworkResourceLoadParameters::decode(IPC::Decoder& decoder, NetworkResourc
     if (!decoder.decode(result.mainDocumentURL))
         return false;
 
-    if (!decoder.decode(result.contentRuleLists))
+    std::optional<Vector<std::pair<String, WebCompiledContentRuleListData>>> contentRuleLists;
+    decoder >> contentRuleLists;
+    if (!contentRuleLists)
         return false;
+    result.contentRuleLists = WTFMove(*contentRuleLists);
 #endif
 
     return true;
index 04ae85a..38437fc 100644 (file)
@@ -47,6 +47,15 @@ bool ArgumentCoder<std::chrono::system_clock::time_point>::decode(Decoder& decod
     return true;
 }
 
+std::optional<std::chrono::system_clock::time_point> ArgumentCoder<std::chrono::system_clock::time_point>::decode(Decoder& decoder)
+{
+    std::optional<int64_t> time;
+    decoder >> time;
+    if (!time)
+        return std::nullopt;
+    return { std::chrono::system_clock::time_point { std::chrono::system_clock::duration(static_cast<std::chrono::system_clock::rep>(*time)) }};
+}
+    
 void ArgumentCoder<AtomicString>::encode(Encoder& encoder, const AtomicString& atomicString)
 {
     encoder << atomicString.string();
index d2d0521..ad6dbac 100644 (file)
@@ -132,6 +132,21 @@ template<typename T, typename U> struct ArgumentCoder<std::pair<T, U>> {
         pair.second = second;
         return true;
     }
+
+    static std::optional<std::pair<T, U>> decode(Decoder& decoder)
+    {
+        std::optional<T> first;
+        decoder >> first;
+        if (!first)
+            return std::nullopt;
+        
+        std::optional<U> second;
+        decoder >> second;
+        if (!second)
+            return std::nullopt;
+        
+        return {{ WTFMove(*first), WTFMove(*second) }};
+    }
 };
 
 template<size_t index, typename... Elements>
@@ -238,22 +253,30 @@ template<typename T, size_t inlineCapacity> struct VectorArgumentCoder<false, T,
 
     static bool decode(Decoder& decoder, Vector<T, inlineCapacity>& vector)
     {
+        std::optional<Vector<T, inlineCapacity>> optional;
+        decoder >> optional;
+        if (!optional)
+            return false;
+        vector = WTFMove(*optional);
+        return true;
+    }
+
+    static std::optional<Vector<T, inlineCapacity>> decode(Decoder& decoder)
+    {
         uint64_t size;
         if (!decoder.decode(size))
-            return false;
+            return std::nullopt;
 
-        Vector<T, inlineCapacity> tmp;
+        Vector<T, inlineCapacity> vector;
         for (size_t i = 0; i < size; ++i) {
-            T element;
-            if (!decoder.decode(element))
-                return false;
-            
-            tmp.append(WTFMove(element));
+            std::optional<T> element;
+            decoder >> element;
+            if (!element)
+                return std::nullopt;
+            vector.append(WTFMove(*element));
         }
-
-        tmp.shrinkToFit();
-        vector.swap(tmp);
-        return true;
+        vector.shrinkToFit();
+        return WTFMove(vector);
     }
 };
 
@@ -286,6 +309,28 @@ template<typename T, size_t inlineCapacity> struct VectorArgumentCoder<true, T,
         vector.swap(temp);
         return true;
     }
+    
+    static std::optional<Vector<T, inlineCapacity>> decode(Decoder& decoder)
+    {
+        uint64_t size;
+        if (!decoder.decode(size))
+            return std::nullopt;
+        
+        // Since we know the total size of the elements, we can allocate the vector in
+        // one fell swoop. Before allocating we must however make sure that the decoder buffer
+        // is big enough.
+        if (!decoder.bufferIsLargeEnoughToContain<T>(size)) {
+            decoder.markInvalid();
+            return std::nullopt;
+        }
+        
+        Vector<T, inlineCapacity> vector;
+        vector.grow(size);
+        
+        decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(vector.data()), size * sizeof(T), alignof(T));
+        
+        return vector;
+    }
 };
 
 template<typename T, size_t inlineCapacity> struct ArgumentCoder<Vector<T, inlineCapacity>> : VectorArgumentCoder<std::is_arithmetic<T>::value, T, inlineCapacity> { };
@@ -325,6 +370,31 @@ template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTrai
         hashMap.swap(tempHashMap);
         return true;
     }
+
+    static std::optional<HashMapType> decode(Decoder& decoder)
+    {
+        uint64_t hashMapSize;
+        if (!decoder.decode(hashMapSize))
+            return std::nullopt;
+        
+        HashMapType hashMap;
+        for (uint64_t i = 0; i < hashMapSize; ++i) {
+            KeyArg key;
+            MappedArg value;
+            if (!decoder.decode(key))
+                return std::nullopt;
+            if (!decoder.decode(value))
+                return std::nullopt;
+            
+            if (!hashMap.add(key, value).isNewEntry) {
+                // The hash map already has the specified key, bail.
+                decoder.markInvalid();
+                return std::nullopt;
+            }
+        }
+        
+        return WTFMove(hashMap);
+    }
 };
 
 template<typename KeyArg, typename HashArg, typename KeyTraitsArg> struct ArgumentCoder<HashSet<KeyArg, HashArg, KeyTraitsArg>> {
@@ -414,32 +484,34 @@ template<typename ValueType, typename ErrorType> struct ArgumentCoder<WTF::Expec
         encoder << expected.value();
     }
 
-    static bool decode(Decoder& decoder, WTF::Expected<ValueType, ErrorType>& expected)
+    static std::optional<WTF::Expected<ValueType, ErrorType>> decode(Decoder& decoder)
     {
-        bool hasValue;
-        if (!decoder.decode(hasValue))
-            return false;
-
-        if (!hasValue) {
-            ErrorType error;
-            if (!decoder.decode(error))
-                return false;
-            expected = WTF::UnexpectedType<ErrorType> { WTFMove(error) };
-            return true;
+        std::optional<bool> hasValue;
+        decoder >> hasValue;
+        if (!hasValue)
+            return std::nullopt;
+        
+        if (*hasValue) {
+            std::optional<ValueType> value;
+            decoder >> value;
+            if (!value)
+                return std::nullopt;
+            
+            WTF::Expected<ValueType, ErrorType> expected(WTFMove(*value));
+            return WTFMove(expected);
         }
-        ValueType value;
-        if (!decoder.decode(value))
-            return false;
-
-        expected = WTFMove(value);
-        return true;
+        std::optional<ErrorType> error;
+        decoder >> error;
+        if (!error)
+            return std::nullopt;
+        return { makeUnexpected(WTFMove(*error)) };
     }
 };
 
-
 template<> struct ArgumentCoder<std::chrono::system_clock::time_point> {
     static void encode(Encoder&, const std::chrono::system_clock::time_point&);
     static bool decode(Decoder&, std::chrono::system_clock::time_point&);
+    static std::optional<std::chrono::system_clock::time_point> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<AtomicString> {
index ac96f00..66c9f2a 100644 (file)
@@ -40,24 +40,25 @@ void OptionItem::encode(IPC::Encoder& encoder) const
     encoder << parentGroupID;
 }
 
-bool OptionItem::decode(IPC::Decoder& decoder, OptionItem& result)
+std::optional<OptionItem> OptionItem::decode(IPC::Decoder& decoder)
 {
+    OptionItem result;
     if (!decoder.decode(result.text))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.isGroup))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.isSelected))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.disabled))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.parentGroupID))
-        return false;
+        return std::nullopt;
     
-    return true;
+    return WTFMove(result);
 }
 
 void AssistedNodeInformation::encode(IPC::Encoder& encoder) const
index c671937..6827be7 100644 (file)
@@ -82,7 +82,7 @@ struct OptionItem {
     int parentGroupID { 0 };
 
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, OptionItem&);
+    static std::optional<OptionItem> decode(IPC::Decoder&);
 };
 
 struct AssistedNodeInformation {
index 2a311d9..c5d93dc 100644 (file)
@@ -75,11 +75,14 @@ public:
         encoder << m_id;
     }
 
-    template<class Decoder> static bool decode(Decoder& decoder, CallbackID& callbackID)
+    template<class Decoder> static std::optional<CallbackID> decode(Decoder& decoder)
     {
-        auto result = decoder.decode(callbackID.m_id);
-        RELEASE_ASSERT(callbackID.isValid());
-        return result;
+        std::optional<uint64_t> identifier;
+        decoder >> identifier;
+        if (!identifier)
+            return std::nullopt;
+        RELEASE_ASSERT(isValidCallbackID(*identifier));
+        return fromInteger(*identifier);
     }
 
 private:
index 5ccc690..1548703 100644 (file)
@@ -139,16 +139,17 @@ void ArgumentCoder<WebCore::PaymentError>::encode(Encoder& encoder, const WebCor
     encoder << error.contactField;
 }
 
-bool ArgumentCoder<WebCore::PaymentError>::decode(Decoder& decoder, WebCore::PaymentError& error)
+std::optional<WebCore::PaymentError> ArgumentCoder<WebCore::PaymentError>::decode(Decoder& decoder)
 {
+    WebCore::PaymentError error;
     if (!decoder.decode(error.code))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(error.message))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(error.contactField))
-        return false;
+        return std::nullopt;
 
-    return true;
+    return WTFMove(error);
 }
 
 void ArgumentCoder<WebCore::PaymentMerchantSession>::encode(Encoder& encoder, const WebCore::PaymentMerchantSession& paymentMerchantSession)
@@ -227,9 +228,11 @@ void ArgumentCoder<WebCore::PaymentMethodUpdate>::encode(Encoder& encoder, const
 
 bool ArgumentCoder<WebCore::PaymentMethodUpdate>::decode(Decoder& decoder, WebCore::PaymentMethodUpdate& update)
 {
-    if (!decoder.decode(update.newTotalAndLineItems))
+    std::optional<ApplePaySessionPaymentRequest::TotalAndLineItems> newTotalAndLineItems;
+    decoder >> newTotalAndLineItems;
+    if (!newTotalAndLineItems)
         return false;
-
+    update = { WTFMove(*newTotalAndLineItems) };
     return true;
 }
 
@@ -308,10 +311,11 @@ bool ArgumentCoder<ApplePaySessionPaymentRequest>::decode(Decoder& decoder, Appl
         return false;
     request.setLineItems(lineItems);
 
-    ApplePaySessionPaymentRequest::LineItem total;
-    if (!decoder.decode(total))
+    std::optional<ApplePaySessionPaymentRequest::LineItem> total;
+    decoder >> total;
+    if (!total)
         return false;
-    request.setTotal(total);
+    request.setTotal(*total);
 
     String applicationData;
     if (!decoder.decode(applicationData))
@@ -358,16 +362,17 @@ void ArgumentCoder<ApplePaySessionPaymentRequest::LineItem>::encode(Encoder& enc
     encoder << lineItem.amount;
 }
 
-bool ArgumentCoder<ApplePaySessionPaymentRequest::LineItem>::decode(Decoder& decoder, ApplePaySessionPaymentRequest::LineItem& lineItem)
+std::optional<ApplePaySessionPaymentRequest::LineItem> ArgumentCoder<ApplePaySessionPaymentRequest::LineItem>::decode(Decoder& decoder)
 {
+    WebCore::ApplePaySessionPaymentRequest::LineItem lineItem;
     if (!decoder.decodeEnum(lineItem.type))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(lineItem.label))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(lineItem.amount))
-        return false;
+        return std::nullopt;
 
-    return true;
+    return WTFMove(lineItem);
 }
 
 void ArgumentCoder<ApplePaySessionPaymentRequest::MerchantCapabilities>::encode(Encoder& encoder, const ApplePaySessionPaymentRequest::MerchantCapabilities& merchantCapabilities)
@@ -400,17 +405,18 @@ void ArgumentCoder<ApplePaySessionPaymentRequest::ShippingMethod>::encode(Encode
     encoder << shippingMethod.identifier;
 }
 
-bool ArgumentCoder<ApplePaySessionPaymentRequest::ShippingMethod>::decode(Decoder& decoder, ApplePaySessionPaymentRequest::ShippingMethod& shippingMethod)
+std::optional<ApplePaySessionPaymentRequest::ShippingMethod> ArgumentCoder<ApplePaySessionPaymentRequest::ShippingMethod>::decode(Decoder& decoder)
 {
+    ApplePaySessionPaymentRequest::ShippingMethod shippingMethod;
     if (!decoder.decode(shippingMethod.label))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(shippingMethod.detail))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(shippingMethod.amount))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(shippingMethod.identifier))
-        return false;
-    return true;
+        return std::nullopt;
+    return WTFMove(shippingMethod);
 }
 
 void ArgumentCoder<ApplePaySessionPaymentRequest::TotalAndLineItems>::encode(Encoder& encoder, const ApplePaySessionPaymentRequest::TotalAndLineItems& totalAndLineItems)
@@ -419,13 +425,19 @@ void ArgumentCoder<ApplePaySessionPaymentRequest::TotalAndLineItems>::encode(Enc
     encoder << totalAndLineItems.lineItems;
 }
 
-bool ArgumentCoder<ApplePaySessionPaymentRequest::TotalAndLineItems>::decode(Decoder& decoder, ApplePaySessionPaymentRequest::TotalAndLineItems& totalAndLineItems)
+std::optional<ApplePaySessionPaymentRequest::TotalAndLineItems> ArgumentCoder<ApplePaySessionPaymentRequest::TotalAndLineItems>::decode(Decoder& decoder)
 {
-    if (!decoder.decode(totalAndLineItems.total))
-        return false;
-    if (!decoder.decode(totalAndLineItems.lineItems))
-        return false;
-    return true;
+    std::optional<ApplePaySessionPaymentRequest::LineItem> total;
+    decoder >> total;
+    if (!total)
+        return std::nullopt;
+    
+    std::optional<Vector<ApplePaySessionPaymentRequest::LineItem>> lineItems;
+    decoder >> lineItems;
+    if (!lineItems)
+        return std::nullopt;
+    
+    return {{ WTFMove(*total), WTFMove(*lineItems) }};
 }
 
 void ArgumentCoder<WebCore::ShippingContactUpdate>::encode(Encoder& encoder, const WebCore::ShippingContactUpdate& update)
@@ -441,8 +453,12 @@ bool ArgumentCoder<WebCore::ShippingContactUpdate>::decode(Decoder& decoder, Web
         return false;
     if (!decoder.decode(update.newShippingMethods))
         return false;
-    if (!decoder.decode(update.newTotalAndLineItems))
+    
+    std::optional<ApplePaySessionPaymentRequest::TotalAndLineItems> newTotalAndLineItems;
+    decoder >> newTotalAndLineItems;
+    if (!newTotalAndLineItems)
         return false;
+    update.newTotalAndLineItems = WTFMove(*newTotalAndLineItems);
 
     return true;
 }
@@ -454,9 +470,11 @@ void ArgumentCoder<WebCore::ShippingMethodUpdate>::encode(Encoder& encoder, cons
 
 bool ArgumentCoder<WebCore::ShippingMethodUpdate>::decode(Decoder& decoder, WebCore::ShippingMethodUpdate& update)
 {
-    if (!decoder.decode(update.newTotalAndLineItems))
+    std::optional<ApplePaySessionPaymentRequest::TotalAndLineItems> newTotalAndLineItems;
+    decoder >> newTotalAndLineItems;
+    if (!newTotalAndLineItems)
         return false;
-
+    update = { WTFMove(*newTotalAndLineItems) };
     return true;
 }
 
index 706c62e..de8467e 100644 (file)
@@ -40,8 +40,11 @@ void WebIDBResult::encode(IPC::Encoder& encoder) const
 
 bool WebIDBResult::decode(IPC::Decoder& decoder, WebIDBResult& result)
 {
-    if (!WebCore::IDBResultData::decode(decoder, result.m_resultData))
+    std::optional<WebCore::IDBResultData> resultData;
+    decoder >> resultData;
+    if (!resultData)
         return false;
+    result.m_resultData = WTFMove(*resultData);
 
     if (!SandboxExtension::HandleArray::decode(decoder, result.m_handles))
         return false;
index 4002b81..3c9c9b3 100644 (file)
@@ -44,8 +44,11 @@ bool FrameInfoData::decode(IPC::Decoder& decoder, FrameInfoData& result)
         return false;
     if (!decoder.decode(result.request))
         return false;
-    if (!decoder.decode(result.securityOrigin))
+    std::optional<WebCore::SecurityOriginData> securityOrigin;
+    decoder >> securityOrigin;
+    if (!securityOrigin)
         return false;
+    result.securityOrigin = WTFMove(*securityOrigin);
     if (!decoder.decode(result.frameID))
         return false;
 
index 7dbce7e..4e9cf87 100644 (file)
@@ -59,30 +59,31 @@ void GamepadData::encode(IPC::Encoder& encoder) const
     encoder << m_index << m_id << m_axisValues << m_buttonValues << m_lastUpdateTime;
 }
 
-bool GamepadData::decode(IPC::Decoder& decoder, GamepadData& data)
+std::optional<GamepadData> GamepadData::decode(IPC::Decoder& decoder)
 {
+    GamepadData data;
     if (!decoder.decode(data.m_isNull))
-        return false;
+        return std::nullopt;
 
     if (data.m_isNull)
-        return true;
+        return data;
 
     if (!decoder.decode(data.m_index))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(data.m_id))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(data.m_axisValues))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(data.m_buttonValues))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(data.m_lastUpdateTime))
-        return false;
+        return std::nullopt;
 
-    return true;
+    return WTFMove(data);
 }
 
 #if !LOG_DISABLED
index ce43dcf..059f2de 100644 (file)
@@ -48,7 +48,7 @@ public:
     GamepadData(unsigned index, const String& id, const Vector<double>& axisValues, const Vector<double>& buttonValues, double lastUpdateTime);
 
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, GamepadData&);
+    static std::optional<GamepadData> decode(IPC::Decoder&);
 
     bool isNull() const { return m_isNull; }
 
index efa7976..9ef1204 100644 (file)
@@ -61,8 +61,16 @@ bool PlatformPopupMenuData::decode(IPC::Decoder& decoder, PlatformPopupMenuData&
     UNUSED_PARAM(decoder);
     UNUSED_PARAM(data);
 #endif
-
+    
     return true;
 }
 
+std::optional<PlatformPopupMenuData> PlatformPopupMenuData::decode(IPC::Decoder& decoder)
+{
+    PlatformPopupMenuData data;
+    if (!decode(decoder, data))
+        return std::nullopt;
+    return data;
+}
+
 } // namespace WebKit
index a156963..13991f3 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef PlatformPopupMenuData_h
-#define PlatformPopupMenuData_h
+#pragma once
 
 #include "FontInfo.h"
 #include "ShareableBitmap.h"
@@ -43,6 +42,7 @@ struct PlatformPopupMenuData {
 
     void encode(IPC::Encoder&) const;
     static bool decode(IPC::Decoder&, PlatformPopupMenuData&);
+    static std::optional<PlatformPopupMenuData> decode(IPC::Decoder&);
 
 #if PLATFORM(COCOA)
     FontInfo fontInfo;
@@ -53,5 +53,3 @@ struct PlatformPopupMenuData {
 };
 
 } // namespace WebKit
-
-#endif // PlatformPopupMenuData_h
index 93c3ce9..75d6093 100644 (file)
@@ -76,15 +76,21 @@ void NPIdentifierData::encode(IPC::Encoder& encoder) const
         encoder << m_number;
 }
 
-bool NPIdentifierData::decode(IPC::Decoder& decoder, NPIdentifierData& result)
+std::optional<NPIdentifierData> NPIdentifierData::decode(IPC::Decoder& decoder)
 {
+    NPIdentifierData result;
     if (!decoder.decode(result.m_isString))
-        return false;
+        return std::nullopt;
         
-    if (result.m_isString)
-        return decoder.decode(result.m_string);
-
-    return decoder.decode(result.m_number);
+    if (result.m_isString) {
+        if (!decoder.decode(result.m_string))
+            return std::nullopt;
+        return result;
+    }
+
+    if (!decoder.decode(result.m_number))
+        return std::nullopt;
+    return WTFMove(result);
 }
 
 } // namespace WebKit
index 4f678a4..c4aa24f 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef NPIdentifierData_h
-#define NPIdentifierData_h
+#pragma once
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
 
@@ -46,7 +45,7 @@ public:
     NPIdentifier createNPIdentifier() const;
 
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, NPIdentifierData&);
+    static std::optional<NPIdentifierData> decode(IPC::Decoder&);
 
 private:
     bool m_isString;
@@ -57,5 +56,3 @@ private:
 } // namespace WebKit
 
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
-    
-#endif // NPIdentifierData_h
index d2e671b..07dddbc 100644 (file)
@@ -147,11 +147,12 @@ void NPVariantData::encode(IPC::Encoder& encoder) const
     }
 }
 
-bool NPVariantData::decode(IPC::Decoder& decoder, NPVariantData& result)
+std::optional<NPVariantData> NPVariantData::decode(IPC::Decoder& decoder)
 {
+    NPVariantData result;
     uint32_t type;
     if (!decoder.decode(type))
-        return false;
+        return std::nullopt;
 
     // We special-case LocalNPObjectID and RemoteNPObjectID here so a LocalNPObjectID is
     // decoded as a RemoteNPObjectID and vice versa.
@@ -167,22 +168,34 @@ bool NPVariantData::decode(IPC::Decoder& decoder, NPVariantData& result)
     switch (result.m_type) {
     case NPVariantData::Void:
     case NPVariantData::Null:
-        return true;
+        return WTFMove(result);
     case NPVariantData::Bool:
-        return decoder.decode(result.m_boolValue);
+        if (!decoder.decode(result.m_boolValue))
+            return std::nullopt;
+        return WTFMove(result);
     case NPVariantData::Int32:
-        return decoder.decode(result.m_int32Value);
+        if (!decoder.decode(result.m_int32Value))
+            return std::nullopt;
+        return WTFMove(result);
     case NPVariantData::Double:
-        return decoder.decode(result.m_doubleValue);
+        if (!decoder.decode(result.m_doubleValue))
+            return std::nullopt;
+        return WTFMove(result);
     case NPVariantData::String:
-        return decoder.decode(result.m_stringValue);
+        if (!decoder.decode(result.m_stringValue))
+            return std::nullopt;
+        return WTFMove(result);
     case NPVariantData::LocalNPObjectID:
-        return decoder.decode(result.m_localNPObjectIDValue);
+        if (!decoder.decode(result.m_localNPObjectIDValue))
+            return std::nullopt;
+        return WTFMove(result);
     case NPVariantData::RemoteNPObjectID:
-        return decoder.decode(result.m_remoteNPObjectIDValue);
+        if (!decoder.decode(result.m_remoteNPObjectIDValue))
+            return std::nullopt;
+        return WTFMove(result);
     }
 
-    return false;
+    return std::nullopt;
 }
 
 } // namespace WebKit
index 2c5f2c9..c58e2d5 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef NPVariantData_h
-#define NPVariantData_h
+#pragma once
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
 
@@ -99,7 +98,7 @@ public:
     }
 
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, NPVariantData&);
+    static std::optional<NPVariantData> decode(IPC::Decoder&);
 
 private:
     uint32_t m_type;
@@ -114,5 +113,3 @@ private:
 } // namespace WebKit
 
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
-    
-#endif // NPVariantData_h
index a143229..09096ab 100644 (file)
@@ -60,32 +60,33 @@ rtc::Network RTCNetwork::value() const
     return network;
 }
 
-bool RTCNetwork::IPAddress::decode(IPC::Decoder& decoder, IPAddress& result)
+auto RTCNetwork::IPAddress::decode(IPC::Decoder& decoder) -> std::optional<IPAddress>
 {
+    IPAddress result;
     int family;
     if (!decoder.decode(family))
-        return false;
+        return std::nullopt;
 
     ASSERT(family == AF_INET || family == AF_INET6 || family == AF_UNSPEC);
 
     if (family == AF_UNSPEC)
-        return true;
+        return WTFMove(result);
 
     IPC::DataReference data;
     if (!decoder.decode(data))
-        return false;
+        return std::nullopt;
 
     if (family == AF_INET) {
         if (data.size() != sizeof(in_addr))
-            return false;
+            return std::nullopt;
         result.value = rtc::IPAddress(*reinterpret_cast<const in_addr*>(data.data()));
-        return true;
+        return WTFMove(result);
     }
 
     if (data.size() != sizeof(in6_addr))
-        return false;
+        return std::nullopt;
     result.value = rtc::IPAddress(*reinterpret_cast<const in6_addr*>(data.data()));
-    return true;
+    return WTFMove(result);
 }
 
 void RTCNetwork::IPAddress::encode(IPC::Encoder& encoder) const
@@ -118,33 +119,35 @@ rtc::SocketAddress RTCNetwork::isolatedCopy(const rtc::SocketAddress& value)
     return rtc::SocketAddress(copy);
 }
 
-bool RTCNetwork::SocketAddress::decode(IPC::Decoder& decoder, SocketAddress& result)
+auto RTCNetwork::SocketAddress::decode(IPC::Decoder& decoder) -> std::optional<SocketAddress>
 {
+    SocketAddress result;
     uint16_t port;
     if (!decoder.decode(port))
-        return false;
+        return std::nullopt;
     int scopeId;
     if (!decoder.decode(scopeId))
-        return false;
+        return std::nullopt;
     result.value.SetPort(port);
     result.value.SetScopeID(scopeId);
 
     IPC::DataReference hostname;
     if (!decoder.decode(hostname))
-        return false;
+        return std::nullopt;
     result.value.SetIP(std::string(reinterpret_cast<const char*>(hostname.data()), hostname.size()));
 
     bool isUnresolved;
     if (!decoder.decode(isUnresolved))
-        return false;
+        return std::nullopt;
     if (isUnresolved)
-        return true;
-
-    RTCNetwork::IPAddress ipAddress;
-    if (!decoder.decode(ipAddress))
-        return false;
-    result.value.SetResolvedIP(ipAddress.value);
-    return true;
+        return result;
+
+    std::optional<IPAddress> ipAddress;
+    decoder >> ipAddress;
+    if (!ipAddress)
+        return std::nullopt;
+    result.value.SetResolvedIP(ipAddress->value);
+    return result;
 }
 
 void RTCNetwork::SocketAddress::encode(IPC::Encoder& encoder) const
@@ -163,46 +166,51 @@ void RTCNetwork::SocketAddress::encode(IPC::Encoder& encoder) const
     encoder << RTCNetwork::IPAddress(value.ipaddr());
 }
 
-bool RTCNetwork::decode(IPC::Decoder& decoder, RTCNetwork& result)
+std::optional<RTCNetwork> RTCNetwork::decode(IPC::Decoder& decoder)
 {
+    RTCNetwork result;
     IPC::DataReference name, description;
     if (!decoder.decode(name))
-        return false;
+        return std::nullopt;
     result.name = std::string(reinterpret_cast<const char*>(name.data()), name.size());
     if (!decoder.decode(description))
-        return false;
+        return std::nullopt;
     result.description = std::string(reinterpret_cast<const char*>(description.data()), description.size());
-    if (!decoder.decode(result.prefix))
-        return false;
+    std::optional<IPAddress> prefix;
+    decoder >> prefix;
+    if (!prefix)
+        return std::nullopt;
+    result.prefix = WTFMove(*prefix);
     if (!decoder.decode(result.prefixLength))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.type))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.id))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.preference))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.active))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.ignored))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.scopeID))
-        return false;
+        return std::nullopt;
 
     uint64_t length;
     if (!decoder.decode(length))
-        return false;
+        return std::nullopt;
     result.ips.reserve(length);
     for (size_t index = 0; index < length; ++index) {
-        IPAddress address;
-        if (!decoder.decode(address))
-            return false;
+        std::optional<IPAddress> address;
+        decoder >> address;
+        if (!address)
+            return std::nullopt;
         int flags;
         if (!decoder.decode(flags))
-            return false;
-        result.ips.push_back({ address.value, flags });
+            return std::nullopt;
+        result.ips.push_back({ address->value, flags });
     }
-    return true;
+    return result;
 }
 
 void RTCNetwork::encode(IPC::Encoder& encoder) const
index a030a1a..4dc3fa8 100644 (file)
@@ -45,14 +45,14 @@ struct RTCNetwork {
     rtc::Network value() const;
 
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, RTCNetwork&);
+    static std::optional<RTCNetwork> decode(IPC::Decoder&);
 
     struct IPAddress {
         IPAddress() = default;
         explicit IPAddress(const rtc::IPAddress& address): value(address) { }
 
         void encode(IPC::Encoder&) const;
-        static bool decode(IPC::Decoder&, IPAddress&);
+        static std::optional<IPAddress> decode(IPC::Decoder&);
 
         rtc::IPAddress value;
     };
@@ -64,7 +64,7 @@ struct RTCNetwork {
         explicit SocketAddress(const rtc::SocketAddress& address): value(address) { }
 
         void encode(IPC::Encoder&) const;
-        static bool decode(IPC::Decoder&, SocketAddress&);
+        static std::optional<SocketAddress> decode(IPC::Decoder&);
 
         rtc::SocketAddress value;
     };
index 3b1a71c..f156c23 100644 (file)
@@ -98,7 +98,7 @@ public:
         LayerCreationProperties();
 
         void encode(IPC::Encoder&) const;
-        static bool decode(IPC::Decoder&, LayerCreationProperties&);
+        static std::optional<LayerCreationProperties> decode(IPC::Decoder&);
 
         WebCore::GraphicsLayer::PlatformLayerID layerID;
         WebCore::PlatformCALayer::LayerType type;
index e94f4e9..151c7ad 100644 (file)
@@ -56,21 +56,22 @@ void RemoteLayerTreeTransaction::LayerCreationProperties::encode(IPC::Encoder& e
     encoder << hostingDeviceScaleFactor;
 }
 
-bool RemoteLayerTreeTransaction::LayerCreationProperties::decode(IPC::Decoder& decoder, LayerCreationProperties& result)
+auto RemoteLayerTreeTransaction::LayerCreationProperties::decode(IPC::Decoder& decoder) -> std::optional<LayerCreationProperties>
 {
+    LayerCreationProperties result;
     if (!decoder.decode(result.layerID))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decodeEnum(result.type))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.hostingContextID))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.hostingDeviceScaleFactor))
-        return false;
+        return std::nullopt;
 
-    return true;
+    return WTFMove(result);
 }
 
 RemoteLayerTreeTransaction::LayerProperties::LayerProperties()
@@ -674,8 +675,11 @@ bool RemoteLayerTreeTransaction::decode(IPC::Decoder& decoder, RemoteLayerTreeTr
     if (!decoder.decode(result.m_isInStableState))
         return false;
 
-    if (!decoder.decode(result.m_callbackIDs))
+    std::optional<Vector<TransactionCallbackID>> callbackIDs;
+    decoder >> callbackIDs;
+    if (!callbackIDs)
         return false;
+    result.m_callbackIDs = WTFMove(*callbackIDs);
 
     bool hasEditorState;
     if (!decoder.decode(hasEditorState))
index 7fb60ae..b0aae59 100644 (file)
@@ -64,24 +64,25 @@ static bool isValidEnum(HTTPBody::Element::Type type)
     return false;
 }
 
-bool HTTPBody::Element::decode(IPC::Decoder& decoder, Element& result)
+auto HTTPBody::Element::decode(IPC::Decoder& decoder) -> std::optional<Element>
 {
+    Element result;
     if (!decoder.decodeEnum(result.type) || !isValidEnum(result.type))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.data))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.filePath))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.fileStart))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.fileLength))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.expectedFileModificationTime))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.blobURLString))
-        return false;
+        return std::nullopt;
 
-    return true;
+    return WTFMove(result);
 }
 
 void HTTPBody::encode(IPC::Encoder& encoder) const
@@ -130,54 +131,55 @@ void FrameState::encode(IPC::Encoder& encoder) const
     encoder << children;
 }
 
-bool FrameState::decode(IPC::Decoder& decoder, FrameState& result)
+std::optional<FrameState> FrameState::decode(IPC::Decoder& decoder)
 {
+    FrameState result;
     if (!decoder.decode(result.urlString))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.originalURLString))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.referrer))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.target))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.documentState))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.stateObjectData))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.documentSequenceNumber))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.itemSequenceNumber))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.scrollPosition))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.shouldRestoreScrollPosition))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.pageScaleFactor))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.httpBody))
-        return false;
+        return std::nullopt;
 
 #if PLATFORM(IOS)
     if (!decoder.decode(result.exposedContentRect))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.unobscuredContentRect))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.minimumLayoutSizeInScrollViewCoordinates))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.contentSize))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.scaleIsInitial))
-        return false;
+        return std::nullopt;
 #endif
 
     if (!decoder.decode(result.children))
-        return false;
+        return std::nullopt;
 
-    return true;
+    return WTFMove(result);
 }
 
 void PageState::encode(IPC::Encoder& encoder) const
@@ -191,8 +193,11 @@ bool PageState::decode(IPC::Decoder& decoder, PageState& result)
 {
     if (!decoder.decode(result.title))
         return false;
-    if (!decoder.decode(result.mainFrameState))
+    std::optional<FrameState> mainFrameState;
+    decoder >> mainFrameState;
+    if (!mainFrameState)
         return false;
+    result.mainFrameState = WTFMove(*mainFrameState);
     if (!decoder.decodeEnum(result.shouldOpenExternalURLsPolicy) || !isValidEnum(result.shouldOpenExternalURLsPolicy))
         return false;
 
@@ -205,15 +210,17 @@ void BackForwardListItemState::encode(IPC::Encoder& encoder) const
     encoder << pageState;
 }
 
-bool BackForwardListItemState::decode(IPC::Decoder& decoder, BackForwardListItemState& result)
+std::optional<BackForwardListItemState> BackForwardListItemState::decode(IPC::Decoder& decoder)
 {
+    BackForwardListItemState result;
+
     if (!decoder.decode(result.identifier))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.pageState))
-        return false;
+        return std::nullopt;
 
-    return true;
+    return WTFMove(result);
 }
 
 void BackForwardListState::encode(IPC::Encoder& encoder) const
@@ -222,14 +229,18 @@ void BackForwardListState::encode(IPC::Encoder& encoder) const
     encoder << currentIndex;
 }
 
-bool BackForwardListState::decode(IPC::Decoder& decoder, BackForwardListState& result)
+std::optional<BackForwardListState> BackForwardListState::decode(IPC::Decoder& decoder)
 {
-    if (!decoder.decode(result.items))
-        return false;
-    if (!decoder.decode(result.currentIndex))
-        return false;
+    std::optional<Vector<BackForwardListItemState>> items;
+    decoder >> items;
+    if (!items)
+        return std::nullopt;
 
-    return true;
+    std::optional<uint32_t> currentIndex;
+    if (!decoder.decode(currentIndex))
+        return std::nullopt;
+
+    return {{ WTFMove(*items), WTFMove(currentIndex) }};
 }
 
 } // namespace WebKit
index 61f4a6c..e97640f 100644 (file)
@@ -50,7 +50,7 @@ bool isValidEnum(WebCore::ShouldOpenExternalURLsPolicy);
 struct HTTPBody {
     struct Element {
         void encode(IPC::Encoder&) const;
-        static bool decode(IPC::Decoder&, Element&);
+        static std::optional<Element> decode(IPC::Decoder&);
 
         enum class Type {
             Data,
@@ -82,7 +82,7 @@ struct HTTPBody {
 
 struct FrameState {
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, FrameState&);
+    static std::optional<FrameState> decode(IPC::Decoder&);
 
     String urlString;
     String originalURLString;
@@ -124,7 +124,7 @@ struct PageState {
 
 struct BackForwardListItemState {
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, BackForwardListItemState&);
+    static std::optional<BackForwardListItemState> decode(IPC::Decoder&);
 
     uint64_t identifier;
 
@@ -137,7 +137,7 @@ struct BackForwardListItemState {
 
 struct BackForwardListState {
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, BackForwardListState&);
+    static std::optional<BackForwardListState> decode(IPC::Decoder&);
 
     Vector<BackForwardListItemState> items;
     std::optional<uint32_t> currentIndex;
index dc48dc2..514c8f0 100644 (file)
@@ -49,33 +49,34 @@ void WebCompiledContentRuleListData::encode(IPC::Encoder& encoder) const
     encoder << topURLFiltersBytecodeSize;
 }
 
-bool WebCompiledContentRuleListData::decode(IPC::Decoder& decoder, WebCompiledContentRuleListData& compiledContentRuleListData)
+std::optional<WebCompiledContentRuleListData> WebCompiledContentRuleListData::decode(IPC::Decoder& decoder)
 {
+    WebCompiledContentRuleListData compiledContentRuleListData;
     SharedMemory::Handle handle;
     if (!decoder.decode(handle))
-        return false;
+        return std::nullopt;
     compiledContentRuleListData.data = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly);
 
     if (!decoder.decode(compiledContentRuleListData.conditionsApplyOnlyToDomainOffset))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(compiledContentRuleListData.actionsOffset))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(compiledContentRuleListData.actionsSize))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(compiledContentRuleListData.filtersWithoutConditionsBytecodeOffset))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(compiledContentRuleListData.filtersWithoutConditionsBytecodeSize))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(compiledContentRuleListData.filtersWithConditionsBytecodeOffset))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(compiledContentRuleListData.filtersWithConditionsBytecodeSize))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(compiledContentRuleListData.topURLFiltersBytecodeOffset))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(compiledContentRuleListData.topURLFiltersBytecodeSize))
-        return false;
+        return std::nullopt;
 
-    return true;
+    return WTFMove(compiledContentRuleListData);
 }
 
 } // namespace WebKit
index b405640..f4383aa 100644 (file)
@@ -58,7 +58,7 @@ public:
     }
 
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, WebCompiledContentRuleListData&);
+    static std::optional<WebCompiledContentRuleListData> decode(IPC::Decoder&);
 
     RefPtr<SharedMemory> data;
     NetworkCache::Data fileData;
index 2ae8d1c..2a65ac4 100644 (file)
@@ -109,47 +109,45 @@ void WebContextMenuItemData::encode(IPC::Encoder& encoder) const
     encoder << m_submenu;
 }
 
-bool WebContextMenuItemData::decode(IPC::Decoder& decoder, WebContextMenuItemData& item)
+std::optional<WebContextMenuItemData> WebContextMenuItemData::decode(IPC::Decoder& decoder)
 {
     WebCore::ContextMenuItemType type;
     if (!decoder.decodeEnum(type))
-        return false;
+        return std::nullopt;
 
     WebCore::ContextMenuAction action;
     if (!decoder.decodeEnum(action))
-        return false;
+        return std::nullopt;
 
     String title;
     if (!decoder.decode(title))
-        return false;
+        return std::nullopt;
 
     bool checked;
     if (!decoder.decode(checked))
-        return false;
+        return std::nullopt;
 
     bool enabled;
     if (!decoder.decode(enabled))
-        return false;
+        return std::nullopt;
 
-    Vector<WebContextMenuItemData> submenu;
-    if (!decoder.decode(submenu))
-        return false;
+    std::optional<Vector<WebContextMenuItemData>> submenu;
+    decoder >> submenu;
+    if (!submenu)
+        return std::nullopt;
 
     switch (type) {
     case WebCore::ActionType:
     case WebCore::SeparatorType:
     case WebCore::CheckableActionType:
-        item = WebContextMenuItemData(type, action, title, enabled, checked);
+        return {{ type, action, title, enabled, checked }};
         break;
     case WebCore::SubmenuType:
-        item = WebContextMenuItemData(action, title, enabled, submenu);
+        return {{ action, title, enabled, WTFMove(*submenu) }};
         break;
-    default:
-        ASSERT_NOT_REACHED();
-        return false;
     }
-
-    return true;
+    ASSERT_NOT_REACHED();
+    return std::nullopt;
 }
 
 Vector<WebContextMenuItemData> kitItems(const Vector<WebCore::ContextMenuItem>& coreItemVector)
index 3f979fb..25ef165 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebContextMenuItemData_h
-#define WebContextMenuItemData_h
+#pragma once
 
 #if ENABLE(CONTEXT_MENUS)
 
@@ -62,7 +61,7 @@ public:
     void setUserData(API::Object*);
     
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, WebContextMenuItemData&);
+    static std::optional<WebContextMenuItemData> decode(IPC::Decoder&);
 
 private:
     WebCore::ContextMenuItemType m_type;
@@ -80,4 +79,3 @@ Vector<WebCore::ContextMenuItem> coreItems(const Vector<WebContextMenuItemData>&
 } // namespace WebKit
 
 #endif // ENABLE(CONTEXT_MENUS)
-#endif // WebContextMenuItemData_h
index 5e7ef0e..e7d41c7 100644 (file)
@@ -221,20 +221,19 @@ void ArgumentCoder<DOMCacheEngine::CacheInfo>::encode(Encoder& encoder, const DO
     encoder << info.name;
 }
 
-bool ArgumentCoder<DOMCacheEngine::CacheInfo>::decode(Decoder& decoder, DOMCacheEngine::CacheInfo& record)
+auto ArgumentCoder<DOMCacheEngine::CacheInfo>::decode(Decoder& decoder) -> std::optional<DOMCacheEngine::CacheInfo>
 {
-    uint64_t identifier;
-    if (!decoder.decode(identifier))
-        return false;
-
-    String name;
-    if (!decoder.decode(name))
-        return false;
-
-    record.identifier = identifier;
-    record.name = WTFMove(name);
-
-    return true;
+    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)
@@ -263,75 +262,64 @@ void ArgumentCoder<DOMCacheEngine::Record>::encode(Encoder& encoder, const DOMCa
     });
 }
 
-bool ArgumentCoder<DOMCacheEngine::Record>::decode(Decoder& decoder, DOMCacheEngine::Record& record)
+std::optional<DOMCacheEngine::Record> ArgumentCoder<DOMCacheEngine::Record>::decode(Decoder& decoder)
 {
     uint64_t identifier;
     if (!decoder.decode(identifier))
-        return false;
+        return std::nullopt;
 
     FetchHeaders::Guard requestHeadersGuard;
     if (!decoder.decode(requestHeadersGuard))
-        return false;
+        return std::nullopt;
 
     WebCore::ResourceRequest request;
     if (!decoder.decode(request))
-        return false;
+        return std::nullopt;
 
     WebCore::FetchOptions options;
     if (!decoder.decode(options))
-        return false;
+        return std::nullopt;
 
     String referrer;
     if (!decoder.decode(referrer))
-        return false;
+        return std::nullopt;
 
     FetchHeaders::Guard responseHeadersGuard;
     if (!decoder.decode(responseHeadersGuard))
-        return false;
+        return std::nullopt;
 
     WebCore::ResourceResponse response;
     if (!decoder.decode(response))
-        return false;
+        return std::nullopt;
 
     uint64_t updateResponseCounter;
     if (!decoder.decode(updateResponseCounter))
-        return false;
+        return std::nullopt;
 
     WebCore::DOMCacheEngine::ResponseBody responseBody;
     bool hasSharedBufferBody;
     if (!decoder.decode(hasSharedBufferBody))
-        return false;
+        return std::nullopt;
 
     if (hasSharedBufferBody) {
         RefPtr<SharedBuffer> buffer;
         if (!decodeSharedBuffer(decoder, buffer))
-            return false;
+            return std::nullopt;
         if (buffer)
             responseBody = buffer.releaseNonNull();
     } else {
         bool hasFormDataBody;
         if (!decoder.decode(hasFormDataBody))
-            return false;
+            return std::nullopt;
         if (hasFormDataBody) {
             auto formData = FormData::decode(decoder);
             if (!formData)
-                return false;
+                return std::nullopt;
             responseBody = formData.releaseNonNull();
         }
     }
 
-    record.identifier = identifier;
-    record.requestHeadersGuard = requestHeadersGuard;
-    record.request = WTFMove(request);
-    record.options = WTFMove(options);
-    record.referrer = WTFMove(referrer);
-
-    record.responseHeadersGuard = responseHeadersGuard;
-    record.response = WTFMove(response);
-    record.updateResponseCounter = updateResponseCounter;
-    record.responseBody = WTFMove(responseBody);
-
-    return true;
+    return {{ WTFMove(identifier), WTFMove(updateResponseCounter), WTFMove(requestHeadersGuard), WTFMove(request), WTFMove(options), WTFMove(referrer), WTFMove(responseHeadersGuard), WTFMove(response), WTFMove(responseBody) }};
 }
 
 void ArgumentCoder<EventTrackingRegions>::encode(Encoder& encoder, const EventTrackingRegions& eventTrackingRegions)
@@ -577,6 +565,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)
 {
@@ -616,9 +612,12 @@ void ArgumentCoder<FloatQuad>::encode(Encoder& encoder, const FloatQuad& floatQu
     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)
@@ -654,6 +653,14 @@ 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)
 {
@@ -798,20 +805,24 @@ void ArgumentCoder<RecentSearch>::encode(Encoder& encoder, const RecentSearch& r
     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<std::chrono::system_clock::time_point> 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)
@@ -820,17 +831,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)
@@ -886,16 +898,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);
 }
 
 
@@ -913,28 +926,29 @@ void ArgumentCoder<PluginInfo>::encode(Encoder& encoder, const PluginInfo& plugi
 #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;
+        return std::nullopt;
 #if PLATFORM(MAC)
     if (!decoder.decode(pluginInfo.bundleIdentifier))
-        return false;
+        return std::nullopt;
     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)
@@ -1239,61 +1253,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
@@ -1471,18 +1486,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)
@@ -1699,18 +1716,26 @@ 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;
@@ -1752,18 +1777,29 @@ 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)
@@ -1805,19 +1841,33 @@ void ArgumentCoder<TextCheckingResult>::encode(Encoder& encoder, const TextCheck
     encoder << result.replacement;
 }
 
-bool ArgumentCoder<TextCheckingResult>::decode(Decoder& decoder, TextCheckingResult& result)
+std::optional<TextCheckingResult> ArgumentCoder<TextCheckingResult>::decode(Decoder& decoder)
 {
-    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;
+    TextCheckingType type;
+    if (!decoder.decodeEnum(type))
+        return std::nullopt;
+    
+    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)
@@ -2184,32 +2234,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)
@@ -2414,51 +2468,52 @@ void ArgumentCoder<ResourceLoadStatistics>::encode(Encoder& encoder, const WebCo
     encoder << statistics.dataRecordsRemoved;
 }
 
-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 false;
+        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;
     
     // Prevalent Resource
     if (!decoder.decode(statistics.isPrevalentResource))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(statistics.dataRecordsRemoved))
-        return false;
+        return std::nullopt;
 
-    return true;
+    return WTFMove(statistics);
 }
 
 #if ENABLE(MEDIA_STREAM)
@@ -2472,8 +2527,12 @@ void ArgumentCoder<MediaConstraints>::encode(Encoder& encoder, const WebCore::Me
 
 bool ArgumentCoder<MediaConstraints>::decode(Decoder& decoder, WebCore::MediaConstraints& constraints)
 {
-    return decoder.decode(constraints.mandatoryConstraints)
-        && decoder.decode(constraints.advancedConstraints)
+    std::optional<WebCore::MediaTrackConstraintSetMap> mandatoryConstraints;
+    decoder >> mandatoryConstraints;
+    if (!mandatoryConstraints)
+        return false;
+    constraints.mandatoryConstraints = WTFMove(*mandatoryConstraints);
+    return decoder.decode(constraints.advancedConstraints)
         && decoder.decode(constraints.deviceIDHashSalt)
         && decoder.decode(constraints.isValid);
 }
@@ -2487,35 +2546,36 @@ void ArgumentCoder<CaptureDevice>::encode(Encoder& encoder, const WebCore::Captu
     encoder.encodeEnum(device.type());
 }
 
-bool ArgumentCoder<CaptureDevice>::decode(Decoder& decoder, WebCore::CaptureDevice& device)
+std::optional<CaptureDevice> ArgumentCoder<CaptureDevice>::decode(Decoder& decoder)
 {
-    String persistentId;
-    if (!decoder.decode(persistentId))
-        return false;
+    std::optional<String> persistentId;
+    decoder >> persistentId;
+    if (!persistentId)
+        return std::nullopt;
 
-    String label;
-    if (!decoder.decode(label))
-        return false;
+    std::optional<String> label;
+    decoder >> label;
+    if (!label)
+        return std::nullopt;
 
-    String groupId;
-    if (!decoder.decode(groupId))
-        return false;
+    std::optional<String> groupId;
+    decoder >> groupId;
+    if (!groupId)
+        return std::nullopt;
 
-    bool enabled;
-    if (!decoder.decode(enabled))
-        return false;
+    std::optional<bool> enabled;
+    decoder >> enabled;
+    if (!enabled)
+        return std::nullopt;
 
-    CaptureDevice::DeviceType type;
-    if (!decoder.decodeEnum(type))
-        return false;
-
-    device.setPersistentId(persistentId);
-    device.setLabel(label);
-    device.setGroupId(groupId);
-    device.setType(type);
-    device.setEnabled(enabled);
+    std::optional<CaptureDevice::DeviceType> type;
+    decoder >> type;
+    if (!type)
+        return std::nullopt;
 
-    return true;
+    std::optional<CaptureDevice> device = {{ WTFMove(*persistentId), WTFMove(*type), WTFMove(*label), WTFMove(*groupId) }};
+    device->setEnabled(*enabled);
+    return device;
 }
 #endif
 
@@ -2558,19 +2618,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
@@ -2581,15 +2642,19 @@ 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)
 {
-    if (!decoder.decode(option.displayName))
-        return false;
-
-    if (!decoder.decode(option.type))
-        return false;
-
-    return true;
+    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) }};
 }
 
 } // namespace IPC
index a6c5e5e..5b5fd39 100644 (file)
@@ -179,12 +179,12 @@ template<> struct ArgumentCoder<WebCore::CacheQueryOptions> {
 
 template<> struct ArgumentCoder<WebCore::DOMCacheEngine::CacheInfo> {
     static void encode(Encoder&, const WebCore::DOMCacheEngine::CacheInfo&);
-    static bool decode(Decoder&, WebCore::DOMCacheEngine::CacheInfo&);
+    static std::optional<WebCore::DOMCacheEngine::CacheInfo> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::DOMCacheEngine::Record> {
     static void encode(Encoder&, const WebCore::DOMCacheEngine::Record&);
-    static bool decode(Decoder&, WebCore::DOMCacheEngine::Record&);
+    static std::optional<WebCore::DOMCacheEngine::Record> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::EventTrackingRegions> {
@@ -235,6 +235,7 @@ template<> struct ArgumentCoder<WebCore::FloatPoint3D> {
 template<> struct ArgumentCoder<WebCore::FloatRect> {
     static void encode(Encoder&, const WebCore::FloatRect&);
     static bool decode(Decoder&, WebCore::FloatRect&);
+    static std::optional<WebCore::FloatRect> decode(Decoder&);
 };
     
 template<> struct ArgumentCoder<WebCore::FloatBoxExtent> {
@@ -255,7 +256,7 @@ template<> struct ArgumentCoder<WebCore::FloatRoundedRect> {
 #if PLATFORM(IOS)
 template<> struct ArgumentCoder<WebCore::FloatQuad> {
     static void encode(Encoder&, const WebCore::FloatQuad&);
-    static bool decode(Decoder&, WebCore::FloatQuad&);
+    static std::optional<WebCore::FloatQuad> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::ViewportArguments> {
@@ -272,6 +273,7 @@ template<> struct ArgumentCoder<WebCore::IntPoint> {
 template<> struct ArgumentCoder<WebCore::IntRect> {
     static void encode(Encoder&, const WebCore::IntRect&);
     static bool decode(Decoder&, WebCore::IntRect&);
+    static std::optional<WebCore::IntRect> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::IntSize> {
@@ -311,12 +313,12 @@ template<> struct ArgumentCoder<WebCore::ViewportAttributes> {
 
 template<> struct ArgumentCoder<WebCore::MimeClassInfo> {
     static void encode(Encoder&, const WebCore::MimeClassInfo&);
-    static bool decode(Decoder&, WebCore::MimeClassInfo&);
+    static std::optional<WebCore::MimeClassInfo> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::PluginInfo> {
     static void encode(Encoder&, const WebCore::PluginInfo&);
-    static bool decode(Decoder&, WebCore::PluginInfo&);
+    static std::optional<WebCore::PluginInfo> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::AuthenticationChallenge> {
@@ -383,14 +385,14 @@ template<> struct ArgumentCoder<WebCore::MachSendRight> {
 
 template<> struct ArgumentCoder<WebCore::KeypressCommand> {
     static void encode(Encoder&, const WebCore::KeypressCommand&);
-    static bool decode(Decoder&, WebCore::KeypressCommand&);
+    static std::optional<WebCore::KeypressCommand> decode(Decoder&);
 };
 #endif
 
 #if PLATFORM(IOS)
 template<> struct ArgumentCoder<WebCore::SelectionRect> {
     static void encode(Encoder&, const WebCore::SelectionRect&);
-    static bool decode(Decoder&, WebCore::SelectionRect&);
+    static std::optional<WebCore::SelectionRect> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::Highlight> {
@@ -430,7 +432,7 @@ template<> struct ArgumentCoder<WebCore::PasteboardWebContent> {
 
 template<> struct ArgumentCoder<WebCore::CompositionUnderline> {
     static void encode(Encoder&, const WebCore::CompositionUnderline&);
-    static bool decode(Decoder&, WebCore::CompositionUnderline&);
+    static std::optional<WebCore::CompositionUnderline> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::DatabaseDetails> {
@@ -440,7 +442,7 @@ template<> struct ArgumentCoder<WebCore::DatabaseDetails> {
 
 template<> struct ArgumentCoder<WebCore::DictationAlternative> {
     static void encode(Encoder&, const WebCore::DictationAlternative&);
-    static bool decode(Decoder&, WebCore::DictationAlternative&);
+    static std::optional<WebCore::DictationAlternative> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::FileChooserSettings> {
@@ -450,7 +452,7 @@ template<> struct ArgumentCoder<WebCore::FileChooserSettings> {
 
 template<> struct ArgumentCoder<WebCore::GrammarDetail> {
     static void encode(Encoder&, const WebCore::GrammarDetail&);
-    static bool decode(Decoder&, WebCore::GrammarDetail&);
+    static std::optional<WebCore::GrammarDetail> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::TextCheckingRequestData> {
@@ -460,7 +462,7 @@ template<> struct ArgumentCoder<WebCore::TextCheckingRequestData> {
 
 template<> struct ArgumentCoder<WebCore::TextCheckingResult> {
     static void encode(Encoder&, const WebCore::TextCheckingResult&);
-    static bool decode(Decoder&, WebCore::TextCheckingResult&);
+    static std::optional<WebCore::TextCheckingResult> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::UserStyleSheet> {
@@ -497,7 +499,7 @@ bool decodeFilterOperation(Decoder&, RefPtr<WebCore::FilterOperation>&);
 
 template<> struct ArgumentCoder<WebCore::BlobPart> {
     static void encode(Encoder&, const WebCore::BlobPart&);
-    static bool decode(Decoder&, WebCore::BlobPart&);
+    static std::optional<WebCore::BlobPart> decode(Decoder&);
 };
 
 #if ENABLE(CONTENT_FILTERING)
@@ -535,7 +537,7 @@ template<> struct ArgumentCoder<WebCore::MediaPlaybackTargetContext> {
 
 template<> struct ArgumentCoder<WebCore::RecentSearch> {
     static void encode(Encoder&, const WebCore::RecentSearch&);
-    static bool decode(Decoder&, WebCore::RecentSearch&);
+    static std::optional<WebCore::RecentSearch> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::ExceptionDetails> {
@@ -545,7 +547,7 @@ template<> struct ArgumentCoder<WebCore::ExceptionDetails> {
 
 template<> struct ArgumentCoder<WebCore::ResourceLoadStatistics> {
     static void encode(Encoder&, const WebCore::ResourceLoadStatistics&);
-    static bool decode(Decoder&, WebCore::ResourceLoadStatistics&);
+    static std::optional<WebCore::ResourceLoadStatistics> decode(Decoder&);
 };
 
 #if ENABLE(APPLE_PAY)
@@ -567,7 +569,7 @@ template<> struct ArgumentCoder<WebCore::PaymentContact> {
 
 template<> struct ArgumentCoder<WebCore::PaymentError> {
     static void encode(Encoder&, const WebCore::PaymentError&);
-    static bool decode(Decoder&, WebCore::PaymentError&);
+    static std::optional<WebCore::PaymentError> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::PaymentMerchantSession> {
@@ -597,7 +599,7 @@ template<> struct ArgumentCoder<WebCore::ApplePaySessionPaymentRequest::ContactF
 
 template<> struct ArgumentCoder<WebCore::ApplePaySessionPaymentRequest::LineItem> {
     static void encode(Encoder&, const WebCore::ApplePaySessionPaymentRequest::LineItem&);
-    static bool decode(Decoder&, WebCore::ApplePaySessionPaymentRequest::LineItem&);
+    static std::optional<WebCore::ApplePaySessionPaymentRequest::LineItem> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::ApplePaySessionPaymentRequest::MerchantCapabilities> {
@@ -607,12 +609,12 @@ template<> struct ArgumentCoder<WebCore::ApplePaySessionPaymentRequest::Merchant
 
 template<> struct ArgumentCoder<WebCore::ApplePaySessionPaymentRequest::ShippingMethod> {
     static void encode(Encoder&, const WebCore::ApplePaySessionPaymentRequest::ShippingMethod&);
-    static bool decode(Decoder&, WebCore::ApplePaySessionPaymentRequest::ShippingMethod&);
+    static std::optional<WebCore::ApplePaySessionPaymentRequest::ShippingMethod> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::ApplePaySessionPaymentRequest::TotalAndLineItems> {
     static void encode(Encoder&, const WebCore::ApplePaySessionPaymentRequest::TotalAndLineItems&);
-    static bool decode(Decoder&, WebCore::ApplePaySessionPaymentRequest::TotalAndLineItems&);
+    static std::optional<WebCore::ApplePaySessionPaymentRequest::TotalAndLineItems> decode(Decoder&);
 };
 
 template<> struct ArgumentCoder<WebCore::ShippingContactUpdate> {
@@ -635,7 +637,7 @@ template<> struct ArgumentCoder<WebCore::MediaConstraints> {
 
 template<> struct ArgumentCoder<WebCore::CaptureDevice> {
     static void encode(Encoder&, const WebCore::CaptureDevice&);
-    static bool decode(Decoder&, WebCore::CaptureDevice&);
+    static std::optional<WebCore::CaptureDevice> decode(Decoder&);
 };
 #endif
 
@@ -652,14 +654,14 @@ template<> struct ArgumentCoder<WebCore::IDBKeyPath> {
 
 template<> struct ArgumentCoder<WebCore::ScrollOffsetRange<float>> {
     static void encode(Encoder&, const WebCore::ScrollOffsetRange<float>&);
-    static bool decode(Decoder&, WebCore::ScrollOffsetRange<float>&);
+    static std::optional<WebCore::ScrollOffsetRange<float>> decode(Decoder&);
 };
 
 #endif
 
 template<> struct ArgumentCoder<WebCore::MediaSelectionOption> {
     static void encode(Encoder&, const WebCore::MediaSelectionOption&);
-    static bool decode(Decoder&, WebCore::MediaSelectionOption&);
+    static std::optional<WebCore::MediaSelectionOption> decode(Decoder&);
 };
 
 } // namespace IPC
index ecd7c38..210186d 100644 (file)
@@ -362,7 +362,7 @@ public:
 #endif
 
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, WebPlatformTouchPoint&);
+    static std::optional<WebPlatformTouchPoint> decode(IPC::Decoder&);
 
 private:
     unsigned m_identifier;
@@ -455,7 +455,7 @@ public:
     void setState(TouchPointState state) { m_state = state; }
 
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, WebPlatformTouchPoint&);
+    static std::optional<WebPlatformTouchPoint> decode(IPC::Decoder&);
 
 private:
     uint32_t m_id;
index ad2b045..f651570 100644 (file)
@@ -144,13 +144,19 @@ std::optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::
         return std::nullopt;
     if (!decoder.decode(parameters.paginationLineGridEnabled))
         return std::nullopt;
+
     std::optional<String> userAgent;
     decoder >> userAgent;
     if (!userAgent)
         return std::nullopt;
     parameters.userAgent = WTFMove(*userAgent);
-    if (!decoder.decode(parameters.itemStates))
+
+    std::optional<Vector<BackForwardListItemState>> itemStates;
+    decoder >> itemStates;
+    if (!itemStates)
         return std::nullopt;
+    parameters.itemStates = WTFMove(*itemStates);
+
     if (!decoder.decode(parameters.sessionID))
         return std::nullopt;
     if (!decoder.decode(parameters.highestUsedBackForwardItemID))
@@ -252,17 +258,36 @@ std::optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::
     if (!decoder.decode(parameters.enumeratingAllNetworkInterfacesEnabled))
         return std::nullopt;
 
-    if (!decoder.decode(parameters.userContentWorlds))
-        return std::nullopt;
-    if (!decoder.decode(parameters.userScripts))
-        return std::nullopt;
-    if (!decoder.decode(parameters.userStyleSheets))
-        return std::nullopt;
-    if (!decoder.decode(parameters.messageHandlers))
+    std::optional<Vector<std::pair<uint64_t, String>>> userContentWorlds;
+    decoder >> userContentWorlds;
+    if (!userContentWorlds)
         return std::nullopt;
+    parameters.userContentWorlds = WTFMove(*userContentWorlds);
+
+    std::optional<Vector<WebUserScriptData>> userScripts;
+    decoder >> userScripts;
+    if (!userScripts)
+        return std::nullopt;
+    parameters.userScripts = WTFMove(*userScripts);
+    
+    std::optional<Vector<WebUserStyleSheetData>> userStyleSheets;
+    decoder >> userStyleSheets;
+    if (!userStyleSheets)
+        return std::nullopt;
+    parameters.userStyleSheets = WTFMove(*userStyleSheets);
+    
+    std::optional<Vector<WebScriptMessageHandlerData>> messageHandlers;
+    decoder >> messageHandlers;
+    if (!messageHandlers)
+        return std::nullopt;
+    parameters.messageHandlers = WTFMove(*messageHandlers);
+    
 #if ENABLE(CONTENT_EXTENSIONS)
-    if (!decoder.decode(parameters.contentRuleLists))
+    std::optional<Vector<std::pair<String, WebCompiledContentRuleListData>>> contentRuleLists;
+    decoder >> contentRuleLists;
+    if (!contentRuleLists)
         return std::nullopt;
+    parameters.contentRuleLists = WTFMove(*contentRuleLists);
 #endif
     return WTFMove(parameters);
 }
index c7e0287..24a3064 100644 (file)
@@ -67,24 +67,25 @@ void WebPlatformTouchPoint::encode(IPC::Encoder& encoder) const
     encoder << m_force;
 }
 
-bool WebPlatformTouchPoint::decode(IPC::Decoder& decoder, WebPlatformTouchPoint& result)
+std::optional<WebPlatformTouchPoint> WebPlatformTouchPoint::decode(IPC::Decoder& decoder)
 {
+    WebPlatformTouchPoint result;
     if (!decoder.decode(result.m_id))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.m_state))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.m_screenPosition))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.m_position))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.m_radius))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.m_rotationAngle))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.m_force))
-        return false;
+        return std::nullopt;
 
-    return true;
+    return WTFMove(result);
 }
 
 } // namespace WebKit
index e80260e..7c3bd4e 100644 (file)
@@ -78,46 +78,45 @@ void WebPopupItem::encode(IPC::Encoder& encoder) const
     encoder << m_isSelected;
 }
 
-bool WebPopupItem::decode(IPC::Decoder& decoder, WebPopupItem& item)
+std::optional<WebPopupItem> WebPopupItem::decode(IPC::Decoder& decoder)
 {
     Type type;
     if (!decoder.decodeEnum(type))
-        return false;
+        return std::nullopt;
 
     String text;
     if (!decoder.decode(text))
-        return false;
+        return std::nullopt;
     
     TextDirection textDirection;
     if (!decoder.decodeEnum(textDirection))
-        return false;
+        return std::nullopt;
 
     bool hasTextDirectionOverride;
     if (!decoder.decode(hasTextDirectionOverride))
-        return false;
+        return std::nullopt;
 
     String toolTip;
     if (!decoder.decode(toolTip))
-        return false;
+        return std::nullopt;
 
     String accessibilityText;
     if (!decoder.decode(accessibilityText))
-        return false;
+        return std::nullopt;
 
     bool isEnabled;
     if (!decoder.decode(isEnabled))
-        return false;
+        return std::nullopt;
 
     bool isLabel;
     if (!decoder.decode(isLabel))
-        return false;
+        return std::nullopt;
 
     bool isSelected;
     if (!decoder.decode(isSelected))
-        return false;
+        return std::nullopt;
 
-    item = WebPopupItem(type, text, textDirection, hasTextDirectionOverride, toolTip, accessibilityText, isEnabled, isLabel, isSelected);
-    return true;
+    return {{ type, text, textDirection, hasTextDirectionOverride, toolTip, accessibilityText, isEnabled, isLabel, isSelected }};
 }
 
 } // namespace WebKit
index c18e7a9..7a51454 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebPopupItem_h
-#define WebPopupItem_h
+#pragma once
 
 #include <WebCore/WritingMode.h>
 #include <wtf/text/WTFString.h>
@@ -47,7 +46,7 @@ struct WebPopupItem {
     WebPopupItem(Type, const String& text, WebCore::TextDirection, bool hasTextDirectionOverride, const String& toolTip, const String& accessibilityText, bool isEnabled, bool isLabel, bool isSelected);
 
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, WebPopupItem&);
+    static std::optional<WebPopupItem> decode(IPC::Decoder&);
 
     Type m_type;
     String m_text;
@@ -61,5 +60,3 @@ struct WebPopupItem {
 };
 
 } // namespace WebKit
-
-#endif // WebPopupItem_h
index 71f3cf1..10b3c99 100644 (file)
@@ -37,15 +37,23 @@ void WebUserScriptData::encode(IPC::Encoder& encoder) const
     encoder << userScript;
 }
 
-bool WebUserScriptData::decode(IPC::Decoder& decoder, WebUserScriptData& data)
+std::optional<WebUserScriptData> WebUserScriptData::decode(IPC::Decoder& decoder)
 {
-    if (!decoder.decode(data.identifier))
-        return false;
-    if (!decoder.decode(data.worldIdentifier))
-        return false;
-    if (!decoder.decode(data.userScript))
-        return false;
-    return true;
+    std::optional<uint64_t> identifier;
+    decoder >> identifier;
+    if (!identifier)
+        return std::nullopt;
+    
+    std::optional<uint64_t> worldIdentifier;
+    decoder >> worldIdentifier;
+    if (!worldIdentifier)
+        return std::nullopt;
+    
+    WebCore::UserScript userScript;
+    if (!decoder.decode(userScript))
+        return std::nullopt;
+    
+    return {{ WTFMove(*identifier), WTFMove(*worldIdentifier), WTFMove(userScript) }};
 }
 
 void WebUserStyleSheetData::encode(IPC::Encoder& encoder) const
@@ -55,15 +63,23 @@ void WebUserStyleSheetData::encode(IPC::Encoder& encoder) const
     encoder << userStyleSheet;
 }
 
-bool WebUserStyleSheetData::decode(IPC::Decoder& decoder, WebUserStyleSheetData& data)
+std::optional<WebUserStyleSheetData> WebUserStyleSheetData::decode(IPC::Decoder& decoder)
 {
-    if (!decoder.decode(data.identifier))
-        return false;
-    if (!decoder.decode(data.worldIdentifier))
-        return false;
-    if (!decoder.decode(data.userStyleSheet))
-        return false;
-    return true;
+    std::optional<uint64_t> identifier;
+    decoder >> identifier;
+    if (!identifier)
+        return std::nullopt;
+    
+    std::optional<uint64_t> worldIdentifier;
+    decoder >> worldIdentifier;
+    if (!worldIdentifier)
+        return std::nullopt;
+    
+    WebCore::UserStyleSheet userStyleSheet;
+    if (!decoder.decode(userStyleSheet))
+        return std::nullopt;
+    
+    return {{ WTFMove(*identifier), WTFMove(*worldIdentifier), WTFMove(userStyleSheet) }};
 }
 
 
@@ -74,16 +90,24 @@ void WebScriptMessageHandlerData::encode(IPC::Encoder& encoder) const
     encoder << name;
 }
 
-bool WebScriptMessageHandlerData::decode(IPC::Decoder& decoder, WebScriptMessageHandlerData& data)
+std::optional<WebScriptMessageHandlerData> WebScriptMessageHandlerData::decode(IPC::Decoder& decoder)
 {
-    if (!decoder.decode(data.identifier))
-        return false;
-    if (!decoder.decode(data.worldIdentifier))
-        return false;
-    if (!decoder.decode(data.name))
-        return false;
+    std::optional<uint64_t> identifier;
+    decoder >> identifier;
+    if (!identifier)
+        return std::nullopt;
+    
+    std::optional<uint64_t> worldIdentifier;
+    decoder >> worldIdentifier;
+    if (!worldIdentifier)
+        return std::nullopt;
+    
+    std::optional<String> name;
+    decoder >> name;
+    if (!name)
+        return std::nullopt;
 
-    return true;
+    return {{ WTFMove(*identifier), WTFMove(*worldIdentifier), WTFMove(*name) }};
 }
 
 } // namespace WebKit
index e29593b..5293c43 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebUserContentControllerDataTypes_h
-#define WebUserContentControllerDataTypes_h
+#pragma once
 
 #include <WebCore/UserScript.h>
 #include <WebCore/UserStyleSheet.h>
@@ -38,7 +37,7 @@ namespace WebKit {
 
 struct WebUserScriptData {
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, WebUserScriptData&);
+    static std::optional<WebUserScriptData> decode(IPC::Decoder&);
 
     uint64_t identifier;
     uint64_t worldIdentifier;
@@ -47,7 +46,7 @@ struct WebUserScriptData {
 
 struct WebUserStyleSheetData {
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, WebUserStyleSheetData&);
+    static std::optional<WebUserStyleSheetData> decode(IPC::Decoder&);
 
     uint64_t identifier;
     uint64_t worldIdentifier;
@@ -56,7 +55,7 @@ struct WebUserStyleSheetData {
 
 struct WebScriptMessageHandlerData {
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, WebScriptMessageHandlerData&);
+    static std::optional<WebScriptMessageHandlerData> decode(IPC::Decoder&);
 
     uint64_t identifier;
     uint64_t worldIdentifier;
@@ -64,5 +63,3 @@ struct WebScriptMessageHandlerData {
 };
 
 } // namespace WebKit
-
-#endif // WebUserContentControllerDataTypes_h
index 016a3d9..57c49ea 100644 (file)
@@ -39,20 +39,23 @@ void WebsiteData::Entry::encode(IPC::Encoder& encoder) const
     encoder << size;
 }
 
-bool WebsiteData::Entry::decode(IPC::Decoder& decoder, WebsiteData::Entry& result)
+auto WebsiteData::Entry::decode(IPC::Decoder& decoder) -> std::optional<Entry>
 {
-    WebCore::SecurityOriginData securityOriginData;
-    if (!decoder.decode(securityOriginData))
-        return false;
+    Entry result;
+
+    std::optional<WebCore::SecurityOriginData> securityOriginData;
+    decoder >> securityOriginData;
+    if (!securityOriginData)
+        return std::nullopt;
+    result.origin = WTFMove(*securityOriginData);
 
     if (!decoder.decodeEnum(result.type))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(result.size))
-        return false;
+        return std::nullopt;
 
-    result.origin = securityOriginData;
-    return true;
+    return WTFMove(result);
 }
 
 void WebsiteData::encode(IPC::Encoder& encoder) const
index 39211d2..748fb14 100644 (file)
@@ -46,7 +46,7 @@ struct WebsiteData {
         uint64_t size;
 
         void encode(IPC::Encoder&) const;
-        static bool decode(IPC::Decoder&, WebsiteData::Entry&);
+        static std::optional<WebsiteData::Entry> decode(IPC::Decoder&);
     };
 
     Vector<Entry> entries;
index c13318c..d808583 100644 (file)
@@ -55,8 +55,11 @@ bool WebsiteDataStoreParameters::decode(IPC::Decoder& decoder, WebsiteDataStoreP
     if (!decoder.decode(parameters.cookieStoragePathExtensionHandle))
         return false;
 
-    if (!decoder.decode(parameters.pendingCookies))
+    std::optional<Vector<WebCore::Cookie>> pendingCookies;
+    decoder >> pendingCookies;
+    if (!pendingCookies)
         return false;
+    parameters.pendingCookies = WTFMove(*pendingCookies);
 
     if (!decoder.decode(parameters.cacheStorageDirectory))
         return false;
index 2c0493c..8b0b3fb 100644 (file)
@@ -50,31 +50,32 @@ void WebPlatformTouchPoint::encode(IPC::Encoder& encoder) const
 #endif
 }
 
-bool WebPlatformTouchPoint::decode(IPC::Decoder& decoder, WebPlatformTouchPoint& result)
+std::optional<WebPlatformTouchPoint> WebPlatformTouchPoint::decode(IPC::Decoder& decoder)
 {
+    WebPlatformTouchPoint result;
     if (!decoder.decode(result.m_identifier))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.m_location))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.m_phase))
-        return false;
+        return std::nullopt;
 #if ENABLE(IOS_TOUCH_EVENTS)
     if (!decoder.decode(result.m_radiusX))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.m_radiusY))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.m_rotationAngle))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.m_force))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.m_altitudeAngle))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.m_azimuthAngle))
-        return false;
+        return std::nullopt;
     if (!decoder.decode(result.m_touchType))
-        return false;
+        return std::nullopt;
 #endif
-    return true;
+    return WTFMove(result);
 }
 
 } // namespace WebKit
index 7b66751..feaab41 100644 (file)
@@ -602,15 +602,22 @@ void ArgumentCoder<KeypressCommand>::encode(Encoder& encoder, const KeypressComm
     encoder << keypressCommand.commandName << keypressCommand.text;
 }
     
-bool ArgumentCoder<KeypressCommand>::decode(Decoder& decoder, KeypressCommand& keypressCommand)
+std::optional<KeypressCommand> ArgumentCoder<KeypressCommand>::decode(Decoder& decoder)
 {
-    if (!decoder.decode(keypressCommand.commandName))
-        return false;
-
-    if (!decoder.decode(keypressCommand.text))
-        return false;
-
-    return true;
+    std::optional<String> commandName;
+    decoder >> commandName;
+    if (!commandName)
+        return std::nullopt;
+    
+    std::optional<String> text;
+    decoder >> text;
+    if (!text)
+        return std::nullopt;
+    
+    KeypressCommand command;
+    command.commandName = WTFMove(*commandName);
+    command.text = WTFMove(*text);
+    return WTFMove(command);
 }
 
 #if ENABLE(CONTENT_FILTERING)
index 9e98b7d..c22ec6e 100644 (file)
@@ -48,8 +48,11 @@ RefPtr<API::Data> encodeLegacySessionState(const SessionState& sessionState)
 bool decodeLegacySessionState(const uint8_t* data, size_t dataSize, SessionState& sessionState)
 {
     IPC::Decoder decoder(data, dataSize, nullptr, Vector<IPC::Attachment>());
-    if (!decoder.decode(sessionState.backForwardListState))
+    std::optional<BackForwardListState> backForwardListState;
+    decoder >> backForwardListState;
+    if (!backForwardListState)
         return false;
+    sessionState.backForwardListState = WTFMove(*backForwardListState);
     if (!decoder.decode(sessionState.renderTreeSize))
         return false;
     if (!decoder.decode(sessionState.provisionalURL))
index a13cfe5..8a4aead 100644 (file)
@@ -230,7 +230,7 @@ public:
         }
 
         void encode(IPC::Encoder&) const;
-        static bool decode(IPC::Decoder&, KeyframeValue&);
+        static std::optional<KeyframeValue> decode(IPC::Decoder&);
 
     private:
         KeyframeType keyType;
@@ -262,7 +262,7 @@ public:
         }
 
         void encode(IPC::Encoder&) const;
-        static bool decode(IPC::Decoder&, Properties&);
+        static std::optional<Properties> decode(IPC::Decoder&);
 
         String keyPath;
         PlatformCAAnimation::AnimationType animationType;
index 81f2bb1..0d2e9f3 100644 (file)
@@ -128,35 +128,36 @@ void PlatformCAAnimationRemote::KeyframeValue::encode(IPC::Encoder& encoder) con
     }
 }
 
-bool PlatformCAAnimationRemote::KeyframeValue::decode(IPC::Decoder& decoder, PlatformCAAnimationRemote::KeyframeValue& value)
+std::optional<PlatformCAAnimationRemote::KeyframeValue> PlatformCAAnimationRemote::KeyframeValue::decode(IPC::Decoder& decoder)
 {
+    PlatformCAAnimationRemote::KeyframeValue value;
     if (!decoder.decodeEnum(value.keyType))
-        return false;
+        return std::nullopt;
 
     switch (value.keyType) {
     case NumberKeyType:
         if (!decoder.decode(value.number))
-            return false;
+            return std::nullopt;
         break;
     case ColorKeyType:
         if (!decoder.decode(value.color))
-            return false;
+            return std::nullopt;
         break;
     case PointKeyType:
         if (!decoder.decode(value.point))
-            return false;
+            return std::nullopt;
         break;
     case TransformKeyType:
         if (!decoder.decode(value.transform))
-            return false;
+            return std::nullopt;
         break;
     case FilterKeyType:
         if (!decodeFilterOperation(decoder, value.filter))
-            return false;
+            return std::nullopt;
         break;
     }
 
-    return true;
+    return WTFMove(value);
 }
 
 void PlatformCAAnimationRemote::Properties::encode(IPC::Encoder& encoder) const
@@ -204,59 +205,60 @@ void PlatformCAAnimationRemote::Properties::encode(IPC::Encoder& encoder) const
     }
 }
 
-bool PlatformCAAnimationRemote::Properties::decode(IPC::Decoder& decoder, PlatformCAAnimationRemote::Properties& properties)
+std::optional<PlatformCAAnimationRemote::Properties> PlatformCAAnimationRemote::Properties::decode(IPC::Decoder& decoder)
 {
+    PlatformCAAnimationRemote::Properties properties;
     if (!decoder.decode(properties.keyPath))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decodeEnum(properties.animationType))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(properties.beginTime))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(properties.duration))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(properties.timeOffset))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(properties.repeatCount))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(properties.speed))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decodeEnum(properties.fillMode))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decodeEnum(properties.valueFunction))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(properties.autoReverses))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(properties.removedOnCompletion))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(properties.additive))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(properties.reverseTimingFunctions))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(properties.hasExplicitBeginTime))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(properties.keyValues))
-        return false;
+        return std::nullopt;
 
     if (!decoder.decode(properties.keyTimes))
-        return false;
+        return std::nullopt;
 
     uint64_t numTimingFunctions;
     if (!decoder.decode(numTimingFunctions))
-        return false;
+        return std::nullopt;
     
     if (numTimingFunctions) {
         properties.timingFunctions.reserveInitialCapacity(numTimingFunctions);
@@ -265,32 +267,32 @@ bool PlatformCAAnimationRemote::Properties::decode(IPC::Decoder& decoder, Platfo
         
             TimingFunction::TimingFunctionType type;
             if (!decoder.decodeEnum(type))
-                return false;
+                return std::nullopt;
 
             RefPtr<TimingFunction> timingFunction;
             switch (type) {
             case TimingFunction::LinearFunction:
                 timingFunction = LinearTimingFunction::create();
                 if (!decoder.decode(*static_cast<LinearTimingFunction*>(timingFunction.get())))
-                    return false;
+                    return std::nullopt;
                 break;
                 
             case TimingFunction::CubicBezierFunction:
                 timingFunction = CubicBezierTimingFunction::create();
                 if (!decoder.decode(*static_cast<CubicBezierTimingFunction*>(timingFunction.get())))
-                    return false;
+                    return std::nullopt;
                 break;
             
             case TimingFunction::StepsFunction:
                 timingFunction = StepsTimingFunction::create();
                 if (!decoder.decode(*static_cast<StepsTimingFunction*>(timingFunction.get())))
-                    return false;
+                    return std::nullopt;
                 break;
 
             case TimingFunction::SpringFunction:
                 timingFunction = SpringTimingFunction::create();
                 if (!decoder.decode(*static_cast<SpringTimingFunction*>(timingFunction.get())))
-                    return false;
+                    return std::nullopt;
                 break;
             }
             
@@ -298,7 +300,7 @@ bool PlatformCAAnimationRemote::Properties::decode(IPC::Decoder& decoder, Platfo
         }
     }
 
-    return true;
+    return WTFMove(properties);
 }
     
 Ref<PlatformCAAnimation> PlatformCAAnimationRemote::create(PlatformCAAnimation::AnimationType type, const String& keyPath)