Title: [272058] trunk/Source/WebKit
Revision
272058
Author
[email protected]
Date
2021-01-29 05:03:11 -0800 (Fri, 29 Jan 2021)

Log Message

Some type serialization encoders are implemented in Encoder class
https://bugs.webkit.org/show_bug.cgi?id=220519

Patch by Kimmo Kinnunen <[email protected]> on 2021-01-29
Reviewed by Chris Dumez.

Move arithmetic type and enum type serialization from Encoder to
ArgumentCoder. This makes it a bit simpler to implement multiple
Encoder types, as the serialization code is consistently separate
from the Encoder. WebGL SHM IPC stream extensions would eventually
need a similar but slightly different Encoder.

Since Encoder is intentionally coupled with the Decoder, do the
corresponding modification to Decoder class for consistency.

Reimplement Has{Legacy,Modern}Decoder for ease of forward declaration
and (perhaps?) in a bit simpler terms.

Encoder::operator<<() and Encoder::encode() were the same function.
Remove Encoder::encode().

No new tests, a refactor.

* NetworkProcess/NetworkSocketChannel.h:
* Platform/IPC/ArgumentCoder.h:
(IPC::Detail::TestLegacyDecoder):
(IPC::Detail::TestModernDecoder):
(IPC::ArgumentCoder::encode):
(IPC::ArgumentCoder::decode):
* Platform/IPC/ArgumentCoders.h:
* Platform/IPC/Connection.h:
(IPC::Connection::send):
(IPC::Connection::sendWithAsyncReply):
(IPC::Connection::sendSync):
* Platform/IPC/Decoder.h:
(IPC::Decoder::decode):
(IPC::Decoder::operator>>):
* Platform/IPC/Encoder.h:
* Platform/IPC/MessageSender.h:
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::Connection::open):
* Platform/cocoa/SharedMemoryCocoa.cpp:
* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerProperties::encode const):
* Shared/RemoteLayerTree/RemoteScrollingUIState.cpp:
(WebKit::RemoteScrollingUIState::encode const):
* UIProcess/AuxiliaryProcessProxy.h:
(WebKit::AuxiliaryProcessProxy::send):
(WebKit::AuxiliaryProcessProxy::sendWithAsyncReply):
* WebProcess/WebPage/IPCTestingAPI.cpp:
(WebKit::IPCTestingAPI::JSIPC::sendMessage):
* WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::updateRendering):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (272057 => 272058)


--- trunk/Source/WebKit/ChangeLog	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/ChangeLog	2021-01-29 13:03:11 UTC (rev 272058)
@@ -1,3 +1,58 @@
+2021-01-29  Kimmo Kinnunen  <[email protected]>
+
+        Some type serialization encoders are implemented in Encoder class
+        https://bugs.webkit.org/show_bug.cgi?id=220519
+
+        Reviewed by Chris Dumez.
+
+        Move arithmetic type and enum type serialization from Encoder to
+        ArgumentCoder. This makes it a bit simpler to implement multiple
+        Encoder types, as the serialization code is consistently separate
+        from the Encoder. WebGL SHM IPC stream extensions would eventually
+        need a similar but slightly different Encoder.
+
+        Since Encoder is intentionally coupled with the Decoder, do the
+        corresponding modification to Decoder class for consistency.
+
+        Reimplement Has{Legacy,Modern}Decoder for ease of forward declaration
+        and (perhaps?) in a bit simpler terms.
+
+        Encoder::operator<<() and Encoder::encode() were the same function.
+        Remove Encoder::encode().
+
+        No new tests, a refactor.
+
+        * NetworkProcess/NetworkSocketChannel.h:
+        * Platform/IPC/ArgumentCoder.h:
+        (IPC::Detail::TestLegacyDecoder):
+        (IPC::Detail::TestModernDecoder):
+        (IPC::ArgumentCoder::encode):
+        (IPC::ArgumentCoder::decode):
+        * Platform/IPC/ArgumentCoders.h:
+        * Platform/IPC/Connection.h:
+        (IPC::Connection::send):
+        (IPC::Connection::sendWithAsyncReply):
+        (IPC::Connection::sendSync):
+        * Platform/IPC/Decoder.h:
+        (IPC::Decoder::decode):
+        (IPC::Decoder::operator>>):
+        * Platform/IPC/Encoder.h:
+        * Platform/IPC/MessageSender.h:
+        * Platform/IPC/cocoa/ConnectionCocoa.mm:
+        (IPC::Connection::open):
+        * Platform/cocoa/SharedMemoryCocoa.cpp:
+        * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode const):
+        * Shared/RemoteLayerTree/RemoteScrollingUIState.cpp:
+        (WebKit::RemoteScrollingUIState::encode const):
+        * UIProcess/AuxiliaryProcessProxy.h:
+        (WebKit::AuxiliaryProcessProxy::send):
+        (WebKit::AuxiliaryProcessProxy::sendWithAsyncReply):
+        * WebProcess/WebPage/IPCTestingAPI.cpp:
+        (WebKit::IPCTestingAPI::JSIPC::sendMessage):
+        * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::updateRendering):
+
 2021-01-29  Philippe Normand  <[email protected]>
 
         [GTK] return-type-c-linkage warnings

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h (272057 => 272058)


--- trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h	2021-01-29 13:03:11 UTC (rev 272058)
@@ -36,6 +36,7 @@
 
 namespace WebCore {
 class ResourceRequest;
+class ResourceResponse;
 }
 
 namespace IPC {

Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h (272057 => 272058)


--- trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h	2021-01-29 13:03:11 UTC (rev 272058)
@@ -25,90 +25,85 @@
 
 #pragma once
 
+#include "Decoder.h"
+#include "Encoder.h"
 #include <wtf/Optional.h>
 
-namespace WebCore {
-class IntConstraint;
-class DoubleConstraint;
-class ResourceResponse;
-struct ViewportArguments;
+namespace IPC {
+namespace Detail {
+template<typename T, typename I> auto TestLegacyDecoder(int) -> decltype(I::decode(std::declval<Decoder&>(), std::declval<T&>()), std::true_type { });
+template<typename T, typename I> auto TestLegacyDecoder(long) -> std::false_type;
+template<typename T, typename I> auto TestModernDecoder(int) -> decltype(I::decode(std::declval<Decoder&>()), std::true_type { });
+template<typename T, typename I> auto TestModernDecoder(long) -> std::false_type;
 }
+template<typename T, typename I = T> struct HasLegacyDecoder : decltype(Detail::TestLegacyDecoder<T, I>(0)) { };
+template<typename T, typename I = T> inline constexpr bool HasLegacyDecoderV = HasLegacyDecoder<T, I>::value;
+template<typename T, typename I = T> struct HasModernDecoder : decltype(Detail::TestModernDecoder<T, I>(0)) { };
+template<typename T, typename I = T> inline constexpr bool HasModernDecoderV = HasModernDecoder<T, I>::value;
 
-namespace IPC {
+template<typename T, typename = void> struct ArgumentCoder {
+    static void encode(Encoder& encoder, const T& t)
+    {
+        t.encode(encoder);
+    }
 
-class Decoder;
-class Encoder;
+    static Optional<T> decode(Decoder& decoder)
+    {
+        if constexpr(HasModernDecoderV<T>)
+            return T::decode(decoder);
+        else {
+            T t;
+            if (T::decode(decoder, t))
+                return t;
+            return WTF::nullopt;
+        }
+    }
 
-template<typename> struct ArgumentCoder;
-
-template<typename> class UsesModernDecoder;
-
-template<typename U>
-class UsesModernDecoder {
-private:
-    template<typename T, T> struct Helper;
-    template<typename T> static uint8_t check(Helper<Optional<U> (*)(Decoder&), &T::decode>*);
-    template<typename T> static uint16_t check(...);
-    template<typename T> static uint8_t checkArgumentCoder(Helper<Optional<U> (*)(Decoder&), &ArgumentCoder<T>::decode>*);
-    template<typename T> static uint16_t checkArgumentCoder(...);
-public:
-    static constexpr bool argumentCoderValue = sizeof(check<U>(nullptr)) == sizeof(uint8_t);
-    static constexpr bool value = argumentCoderValue || sizeof(checkArgumentCoder<U>(nullptr)) == sizeof(uint8_t);
+    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, T& t)
+    {
+        if constexpr(HasLegacyDecoderV<T>)
+            return T::decode(decoder, t);
+        else {
+            Optional<T> optional = T::decode(decoder);
+            if (!optional)
+                return false;
+            t = WTFMove(*optional);
+            return true;
+        }
+    }
 };
-    
-template<typename... Types>
-class UsesModernDecoder<std::tuple<Types...>> {
-public:
-    static constexpr bool value = true;
-    static constexpr bool argumentCoderValue = true;
-};
 
-template<typename U>
-class UsesLegacyDecoder {
-private:
-    template<typename T, T> struct Helper;
-    template<typename T> static uint8_t check(Helper<bool (*)(Decoder&, U&), &T::decode>*);
-    template<typename T> static uint16_t check(...);
-    template<typename T> static uint8_t checkArgumentCoder(Helper<bool (*)(Decoder&, U&), &ArgumentCoder<T>::decode>*);
-    template<typename T> static uint16_t checkArgumentCoder(...);
-public:
-    static constexpr bool argumentCoderValue = sizeof(check<U>(nullptr)) == sizeof(uint8_t);
-    static constexpr bool value = argumentCoderValue || sizeof(checkArgumentCoder<U>(nullptr)) == sizeof(uint8_t);
-};
+template<typename T>
+struct ArgumentCoder<T, typename std::enable_if_t<std::is_arithmetic_v<T>>> {
+    static void encode(Encoder& encoder, T value)
+    {
+        encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(&value), sizeof(T), alignof(T));
+    }
 
-template<typename BoolType>
-class DefaultDecoderValues {
-public:
-    static constexpr bool argumentCoderValue = BoolType::value;
-    static constexpr bool value = BoolType::value;
-};
-
-// ResourceResponseBase has the legacy decode template, not ResourceResponse.
-template<> class UsesModernDecoder<WebCore::ResourceResponse> : public DefaultDecoderValues<std::false_type> { };
-template<> class UsesLegacyDecoder<WebCore::ResourceResponse> : public DefaultDecoderValues<std::true_type> { };
-
-// IntConstraint and DoubleConstraint have their legacy decoder templates in NumericConstraint.
-template<> class UsesModernDecoder<WebCore::IntConstraint> : public DefaultDecoderValues<std::false_type> { };
-template<> class UsesLegacyDecoder<WebCore::IntConstraint> : public DefaultDecoderValues<std::true_type> { };
-template<> class UsesModernDecoder<WebCore::DoubleConstraint> : public DefaultDecoderValues<std::false_type> { };
-template<> class UsesLegacyDecoder<WebCore::DoubleConstraint> : public DefaultDecoderValues<std::true_type> { };
-
-template<typename T> struct ArgumentCoder {
-    static void encode(Encoder& encoder, const T& t)
+    static Optional<T> decode(Decoder& decoder)
     {
-        t.encode(encoder);
+        T result;
+        if (decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(&result), sizeof(T), alignof(T)))
+            return result;
+        return WTF::nullopt;
     }
+};
 
-    template<typename U = T, std::enable_if_t<UsesLegacyDecoder<U>::argumentCoderValue>* = nullptr> WARN_UNUSED_RETURN
-    static bool decode(Decoder& decoder, U& u)
+template<typename T>
+struct ArgumentCoder<T, typename std::enable_if_t<std::is_enum_v<T>>> {
+    static void encode(Encoder& encoder, T value)
     {
-        return U::decode(decoder, u);
+        ASSERT(WTF::isValidEnum<T>(WTF::enumToUnderlyingType<T>(value)));
+        encoder << WTF::enumToUnderlyingType<T>(value);
     }
 
-    template<typename U = T, std::enable_if_t<UsesModernDecoder<U>::argumentCoderValue>* = nullptr>
-    static Optional<U> decode(Decoder& decoder)
+    static Optional<T> decode(Decoder& decoder)
     {
-        return U::decode(decoder);
+        Optional<std::underlying_type_t<T>> value;
+        decoder >> value;
+        if (value && WTF::isValidEnum<T>(*value))
+            return static_cast<T>(*value);
+        return WTF::nullopt;
     }
 };
 

Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h (272057 => 272058)


--- trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2021-01-29 13:03:11 UTC (rev 272058)
@@ -25,9 +25,8 @@
 
 #pragma once
 
+#include "ArgumentCoder.h"
 #include "ArrayReference.h"
-#include "Decoder.h"
-#include "Encoder.h"
 #include <utility>
 #include <wtf/Box.h>
 #include <wtf/CheckedArithmetic.h>
@@ -77,7 +76,7 @@
     using ArrayReferenceType = ArrayReference<T, arrayReferenceDynamicExtent>;
     static void encode(Encoder& encoder, const ArrayReferenceType& arrayReference)
     {
-        encoder.encode(static_cast<uint64_t>(arrayReference.size()));
+        encoder << static_cast<uint64_t>(arrayReference.size());
         if (!arrayReference.size())
             return;
         encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(arrayReference.data()), arrayReference.size() * sizeof(T), alignof(T));

Modified: trunk/Source/WebKit/Platform/IPC/Connection.h (272057 => 272058)


--- trunk/Source/WebKit/Platform/IPC/Connection.h	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/Platform/IPC/Connection.h	2021-01-29 13:03:11 UTC (rev 272058)
@@ -505,7 +505,7 @@
     COMPILE_ASSERT(!T::isSync, AsyncMessageExpected);
 
     auto encoder = makeUnique<Encoder>(T::name(), destinationID);
-    encoder->encode(message.arguments());
+    *encoder << message.arguments();
     
     return sendMessage(WTFMove(encoder), sendOptions);
 }
@@ -527,8 +527,8 @@
         else
             T::cancelReply(WTFMove(completionHandler));
     }, CompletionHandlerCallThread::MainThread));
-    encoder->encode(listenerID);
-    encoder->encode(message.arguments());
+    *encoder << listenerID;
+    *encoder << message.arguments();
     sendMessage(WTFMove(encoder), sendOptions);
 }
 
@@ -565,7 +565,7 @@
     }
 
     // Encode the rest of the input arguments.
-    encoder->encode(message.arguments());
+    *encoder << message.arguments();
 
     // Now send the message and wait for a reply.
     std::unique_ptr<Decoder> replyDecoder = sendSyncMessage(syncRequestID, WTFMove(encoder), timeout, sendSyncOptions);

Modified: trunk/Source/WebKit/Platform/IPC/Decoder.h (272057 => 272058)


--- trunk/Source/WebKit/Platform/IPC/Decoder.h	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/Platform/IPC/Decoder.h	2021-01-29 13:03:11 UTC (rev 272058)
@@ -25,11 +25,9 @@
 
 #pragma once
 
-#include "ArgumentCoder.h"
 #include "Attachment.h"
 #include "MessageNames.h"
 #include "StringReference.h"
-#include <WebCore/ContextMenuItem.h>
 #include <WebCore/SharedBuffer.h>
 #include <wtf/OptionSet.h>
 #include <wtf/Vector.h>
@@ -44,6 +42,10 @@
 enum class MessageFlags : uint8_t;
 enum class ShouldDispatchWhenWaitingForSyncReply : uint8_t;
 
+template<typename, typename> struct ArgumentCoder;
+template<typename, typename> struct HasLegacyDecoder;
+template<typename, typename> struct HasModernDecoder;
+
 class Decoder {
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -77,48 +79,40 @@
 
     WARN_UNUSED_RETURN bool decodeFixedLengthData(uint8_t* data, size_t, size_t alignment);
 
-    // The data in the returned pointer here will only be valid for the lifetime of the ArgumentDecoder object.
+    // The data in the returned pointer here will only be valid for the lifetime of the Decoder object.
     // Returns nullptr on failure.
     WARN_UNUSED_RETURN const uint8_t* decodeFixedLengthReference(size_t, size_t alignment);
 
-    template<typename T, std::enable_if_t<std::is_arithmetic<T>::value>* = nullptr>
-    WARN_UNUSED_RETURN bool decode(T& value)
+    template<typename T>
+    WARN_UNUSED_RETURN bool decode(T& t)
     {
-        return decodeFixedLengthData(reinterpret_cast<uint8_t*>(&value), sizeof(T), alignof(T));
+        using Impl = ArgumentCoder<std::remove_const_t<std::remove_reference_t<T>>, void>;
+        if constexpr(HasLegacyDecoder<T, Impl>::value)
+            return Impl::decode(*this, t);
+        else {
+            Optional<T> optional;
+            *this >> optional;
+            if (!optional)
+                return false;
+            t = WTFMove(*optional);
+            return true;
+        }
     }
 
-    template<typename T, std::enable_if_t<std::is_arithmetic<T>::value>* = nullptr>
-    Decoder& operator>>(Optional<T>& optional)
+    template<typename T>
+    Decoder& operator>>(Optional<T>& t)
     {
-        T result;
-        if (decodeFixedLengthData(reinterpret_cast<uint8_t*>(&result), sizeof(T), alignof(T)))
-            optional = result;
+        using Impl = ArgumentCoder<std::remove_const_t<std::remove_reference_t<T>>, void>;
+        if constexpr(HasModernDecoder<T, Impl>::value)
+            t = Impl::decode(*this);
+        else {
+            T v;
+            if (Impl::decode(*this, v))
+                t = WTFMove(v);
+        }
         return *this;
     }
 
-    template<typename E, std::enable_if_t<std::is_enum<E>::value>* = nullptr>
-    WARN_UNUSED_RETURN bool decode(E& enumValue)
-    {
-        std::underlying_type_t<E> value;
-        if (!decode(value))
-            return false;
-        if (!WTF::isValidEnum<E>(value))
-            return false;
-
-        enumValue = static_cast<E>(value);
-        return true;
-    }
-
-    template<typename E, std::enable_if_t<std::is_enum<E>::value>* = nullptr>
-    Decoder& operator>>(Optional<E>& optional)
-    {
-        Optional<std::underlying_type_t<E>> value;
-        *this >> value;
-        if (value && WTF::isValidEnum<E>(*value))
-            optional = static_cast<E>(*value);
-        return *this;
-    }
-
     template<typename T>
     bool bufferIsLargeEnoughToContain(size_t numElements) const
     {
@@ -130,42 +124,6 @@
         return bufferIsLargeEnoughToContain(alignof(T), numElements * sizeof(T));
     }
 
-    template<typename T, std::enable_if_t<!std::is_enum<T>::value && !std::is_arithmetic<T>::value && UsesLegacyDecoder<T>::value>* = nullptr>
-    WARN_UNUSED_RETURN bool decode(T& t)
-    {
-        return ArgumentCoder<T>::decode(*this, t);
-    }
-
-    template<typename T, std::enable_if_t<!std::is_enum<T>::value && !std::is_arithmetic<T>::value && !UsesLegacyDecoder<T>::value>* = nullptr>
-    WARN_UNUSED_RETURN bool decode(T& t)
-    {
-        Optional<T> optional;
-        *this >> optional;
-        if (!optional)
-            return false;
-        t = WTFMove(*optional);
-        return true;
-    }
-
-    template<typename T, std::enable_if_t<UsesModernDecoder<T>::value>* = nullptr>
-    Decoder& operator>>(Optional<T>& t)
-    {
-        t = ArgumentCoder<T>::decode(*this);
-        return *this;
-    }
-    
-    template<typename T, std::enable_if_t<!std::is_enum<T>::value && !std::is_arithmetic<T>::value && !UsesModernDecoder<T>::value>* = nullptr>
-    Decoder& operator>>(Optional<T>& optional)
-    {
-        T t;
-        if (ArgumentCoder<T>::decode(*this, t)) {
-            optional = WTFMove(t);
-            return *this;
-        }
-        optional = WTF::nullopt;
-        return *this;
-    }
-
     bool removeAttachment(Attachment&);
 
     static const bool isIPCDecoder = true;

Modified: trunk/Source/WebKit/Platform/IPC/Encoder.h (272057 => 272058)


--- trunk/Source/WebKit/Platform/IPC/Encoder.h	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/Platform/IPC/Encoder.h	2021-01-29 13:03:11 UTC (rev 272058)
@@ -25,11 +25,9 @@
 
 #pragma once
 
-#include "ArgumentCoder.h"
 #include "Attachment.h"
 #include "MessageNames.h"
 #include "StringReference.h"
-#include <WebCore/ContextMenuItem.h>
 #include <WebCore/SharedBuffer.h>
 #include <wtf/OptionSet.h>
 #include <wtf/Vector.h>
@@ -37,9 +35,10 @@
 namespace IPC {
 
 enum class MessageFlags : uint8_t;
-enum class MessageName : uint16_t;
 enum class ShouldDispatchWhenWaitingForSyncReply : uint8_t;
 
+template<typename, typename> struct ArgumentCoder;
+
 class Encoder final {
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -61,33 +60,13 @@
 
     void encodeFixedLengthData(const uint8_t* data, size_t, size_t alignment);
 
-    template<typename T, std::enable_if_t<!std::is_enum<typename std::remove_const_t<std::remove_reference_t<T>>>::value && !std::is_arithmetic<typename std::remove_const_t<std::remove_reference_t<T>>>::value>* = nullptr>
-    void encode(T&& t)
-    {
-        ArgumentCoder<typename std::remove_const<typename std::remove_reference<T>::type>::type>::encode(*this, std::forward<T>(t));
-    }
-
-    template<typename E, std::enable_if_t<std::is_enum<E>::value>* = nullptr>
-    Encoder& operator<<(E&& enumValue)
-    {
-        ASSERT(WTF::isValidEnum<E>(WTF::enumToUnderlyingType<E>(enumValue)));
-        encode(WTF::enumToUnderlyingType<E>(enumValue));
-        return *this;
-    }
-
-    template<typename T, std::enable_if_t<!std::is_enum<T>::value>* = nullptr>
+    template<typename T>
     Encoder& operator<<(T&& t)
     {
-        encode(std::forward<T>(t));
+        ArgumentCoder<std::remove_const_t<std::remove_reference_t<T>>, void>::encode(*this, std::forward<T>(t));
         return *this;
     }
 
-    template<typename T, std::enable_if_t<std::is_arithmetic<T>::value>* = nullptr>
-    void encode(T value)
-    {
-        encodeFixedLengthData(reinterpret_cast<const uint8_t*>(&value), sizeof(T), alignof(T));
-    }
-
     uint8_t* buffer() const { return m_buffer; }
     size_t bufferSize() const { return m_bufferSize; }
 
@@ -117,13 +96,6 @@
 
     uint8_t* grow(size_t alignment, size_t);
 
-    template<typename E, std::enable_if_t<std::is_enum<E>::value>* = nullptr>
-    void encode(E enumValue)
-    {
-        ASSERT(WTF::isValidEnum<E>(WTF::enumToUnderlyingType<E>(enumValue)));
-        encode(WTF::enumToUnderlyingType<E>(enumValue));
-    }
-
     bool hasAttachments() const;
 
     void encodeHeader();

Modified: trunk/Source/WebKit/Platform/IPC/MessageSender.h (272057 => 272058)


--- trunk/Source/WebKit/Platform/IPC/MessageSender.h	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/Platform/IPC/MessageSender.h	2021-01-29 13:03:11 UTC (rev 272058)
@@ -44,7 +44,7 @@
         static_assert(!U::isSync, "Message is sync!");
 
         auto encoder = makeUnique<Encoder>(U::name(), destinationID);
-        encoder->encode(message.arguments());
+        *encoder << message.arguments();
         
         return sendMessage(WTFMove(encoder), sendOptions);
     }
@@ -92,8 +92,8 @@
 
         auto encoder = makeUnique<IPC::Encoder>(T::name(), destinationID);
         uint64_t listenerID = IPC::nextAsyncReplyHandlerID();
-        encoder->encode(listenerID);
-        encoder->encode(message.arguments());
+        *encoder << listenerID;
+        *encoder << message.arguments();
         sendMessage(WTFMove(encoder), sendOptions, {{ [completionHandler = WTFMove(completionHandler)] (IPC::Decoder* decoder) mutable {
             if (decoder && decoder->isValid())
                 T::callReply(*decoder, WTFMove(completionHandler));

Modified: trunk/Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm (272057 => 272058)


--- trunk/Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/Platform/IPC/cocoa/ConnectionCocoa.mm	2021-01-29 13:03:11 UTC (rev 272058)
@@ -219,7 +219,7 @@
         
         // Send the initialize message, which contains a send right for the server to use.
         auto encoder = makeUnique<Encoder>(MessageName::InitializeConnection, 0);
-        encoder->encode(MachPort(m_receivePort, MACH_MSG_TYPE_MAKE_SEND));
+        *encoder << MachPort(m_receivePort, MACH_MSG_TYPE_MAKE_SEND);
 
         initializeSendSource();
 

Modified: trunk/Source/WebKit/Platform/IPC/win/AttachmentWin.cpp (272057 => 272058)


--- trunk/Source/WebKit/Platform/IPC/win/AttachmentWin.cpp	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/Platform/IPC/win/AttachmentWin.cpp	2021-01-29 13:03:11 UTC (rev 272058)
@@ -28,9 +28,9 @@
 #include "config.h"
 #include "Attachment.h"
 
-#include "Decoder.h"
-#include "Encoder.h"
+#include "ArgumentCoder.h"
 
+
 // FIXME: This code is duplicated with SharedMemory::Handle implementation for Win
 
 namespace IPC {

Modified: trunk/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp (272057 => 272058)


--- trunk/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp	2021-01-29 13:03:11 UTC (rev 272058)
@@ -26,8 +26,7 @@
 #include "config.h"
 #include "SharedMemory.h"
 
-#include "Decoder.h"
-#include "Encoder.h"
+#include "ArgumentCoders.h"
 #include "Logging.h"
 #include "MachPort.h"
 #include <WebCore/SharedBuffer.h>

Modified: trunk/Source/WebKit/Platform/win/SharedMemoryWin.cpp (272057 => 272058)


--- trunk/Source/WebKit/Platform/win/SharedMemoryWin.cpp	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/Platform/win/SharedMemoryWin.cpp	2021-01-29 13:03:11 UTC (rev 272058)
@@ -27,8 +27,7 @@
 #include "config.h"
 #include "SharedMemory.h"
 
-#include "Decoder.h"
-#include "Encoder.h"
+#include "ArgumentCoder.h"
 #include <wtf/RefPtr.h>
 
 namespace WebKit {

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm (272057 => 272058)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm	2021-01-29 13:03:11 UTC (rev 272058)
@@ -164,7 +164,7 @@
 
 void RemoteLayerTreeTransaction::LayerProperties::encode(IPC::Encoder& encoder) const
 {
-    encoder.encode(changedProperties);
+    encoder << changedProperties;
 
     if (changedProperties & NameChanged)
         encoder << name;

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingUIState.cpp (272057 => 272058)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingUIState.cpp	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteScrollingUIState.cpp	2021-01-29 13:03:11 UTC (rev 272058)
@@ -33,7 +33,7 @@
 
 void RemoteScrollingUIState::encode(IPC::Encoder& encoder) const
 {
-    encoder.encode(m_changes);
+    encoder << m_changes;
 
     if (m_changes.contains(Changes::ScrollSnapNodes))
         encoder << m_nodesWithActiveScrollSnap;

Modified: trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h (272057 => 272058)


--- trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h	2021-01-29 13:03:11 UTC (rev 272058)
@@ -163,7 +163,7 @@
     COMPILE_ASSERT(!T::isSync, AsyncMessageExpected);
 
     auto encoder = makeUnique<IPC::Encoder>(T::name(), destinationID);
-    encoder->encode(message.arguments());
+    *encoder << message.arguments();
 
     return sendMessage(WTFMove(encoder), sendOptions);
 }
@@ -188,8 +188,8 @@
 
     auto encoder = makeUnique<IPC::Encoder>(T::name(), destinationID);
     uint64_t listenerID = IPC::nextAsyncReplyHandlerID();
-    encoder->encode(listenerID);
-    encoder->encode(message.arguments());
+    *encoder << listenerID;
+    *encoder << message.arguments();
     sendMessage(WTFMove(encoder), sendOptions, {{ [completionHandler = WTFMove(completionHandler)] (IPC::Decoder* decoder) mutable {
         if (decoder && decoder->isValid())
             T::callReply(*decoder, WTFMove(completionHandler));

Modified: trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp (272057 => 272058)


--- trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp	2021-01-29 13:03:11 UTC (rev 272058)
@@ -651,7 +651,7 @@
     bool hasReply = !!messageReplyArgumentDescriptions(messageName);
     if (hasReply) {
         uint64_t listenerID = IPC::nextAsyncReplyHandlerID();
-        encoder->encode(listenerID);
+        *encoder << listenerID;
 
         JSObjectRef resolve;
         JSObjectRef reject;

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm (272057 => 272058)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm	2021-01-29 11:01:23 UTC (rev 272057)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm	2021-01-29 13:03:11 UTC (rev 272058)
@@ -386,7 +386,7 @@
 
     Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree message(layerTransaction, scrollingTransaction);
     auto commitEncoder = makeUnique<IPC::Encoder>(Messages::RemoteLayerTreeDrawingAreaProxy::CommitLayerTree::name(), m_identifier.toUInt64());
-    commitEncoder->encode(message.arguments());
+    *commitEncoder << message.arguments();
 
     // FIXME: Move all backing store flushing management to RemoteLayerBackingStoreCollection.
     bool hadAnyChangedBackingStore = false;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to