Title: [283024] trunk/Source/WebKit
Revision
283024
Author
[email protected]
Date
2021-09-23 20:02:14 -0700 (Thu, 23 Sep 2021)

Log Message

[WebKit2] Refactor some IPC argument encoder logic to work with StreamConnectionEncoder
https://bugs.webkit.org/show_bug.cgi?id=230714

Reviewed by Simon Fraser.

Make it possible to use `IPC::StreamConnectionEncoder` to encode display list items (and their members) in an
IPC stream. This patch comprises two main sets of changes in `ArgumentCoders`, and `WebCoreArgumentCoders`. See
below for more details.

* Platform/IPC/ArgumentCoders.cpp:
(IPC::ArgumentCoder<audit_token_t>::decode):
(IPC::ArgumentCoder<Monostate>::encode): Deleted.
(IPC::ArgumentCoder<Monostate>::decode): Deleted.
* Platform/IPC/ArgumentCoders.h:
(IPC::ArgumentCoder<Monostate>::encode):
(IPC::ArgumentCoder<Monostate>::decode):

Many of these `encode()` methods are currently non-templated, which means that Encoder and Decoder used here
refer solely to IPC::Encoder and IPC::Decoder (respectively) instead of other types of encoders (namely,
StreamConnectionEncoder).

* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<AffineTransform>::encode): Deleted.
(IPC::ArgumentCoder<AffineTransform>::decode): Deleted.
(IPC::ArgumentCoder<TransformationMatrix>::encode): Deleted.
(IPC::ArgumentCoder<TransformationMatrix>::decode): Deleted.
(IPC::ArgumentCoder<FloatPoint>::encode): Deleted.
(IPC::ArgumentCoder<FloatPoint>::decode): Deleted.
(IPC::ArgumentCoder<FloatPoint3D>::encode): Deleted.
(IPC::ArgumentCoder<FloatPoint3D>::decode): Deleted.
(IPC::ArgumentCoder<FloatRect>::encode): Deleted.
(IPC::ArgumentCoder<FloatRect>::decode): Deleted.
(IPC::ArgumentCoder<FloatBoxExtent>::encode): Deleted.
(IPC::ArgumentCoder<FloatBoxExtent>::decode): Deleted.
(IPC::ArgumentCoder<FloatSize>::encode): Deleted.
(IPC::ArgumentCoder<FloatSize>::decode): Deleted.
(IPC::ArgumentCoder<FloatRoundedRect>::encode): Deleted.
(IPC::ArgumentCoder<FloatRoundedRect>::decode): Deleted.
(IPC::ArgumentCoder<IntPoint>::encode): Deleted.
(IPC::ArgumentCoder<IntPoint>::decode): Deleted.
(IPC::ArgumentCoder<IntRect>::encode): Deleted.
(IPC::ArgumentCoder<IntRect>::decode): Deleted.
(IPC::ArgumentCoder<IntSize>::encode): Deleted.
(IPC::ArgumentCoder<IntSize>::decode): Deleted.
(IPC::ArgumentCoder<LayoutSize>::encode): Deleted.
(IPC::ArgumentCoder<LayoutSize>::decode): Deleted.
(IPC::ArgumentCoder<LayoutPoint>::encode): Deleted.
(IPC::ArgumentCoder<LayoutPoint>::decode): Deleted.

These WebCore argument coders are also currently incompatible with StreamConnectionEncoder, since they are non-
templated (and thus only work with IPC::Encoder). Since these are all encodable as POD types, we can just use
SimpleArgumentCoder for all of these. We also add a new `DEFINE_SIMPLE_ARGUMENT_CODER` macro to make this code a
bit easier to read.

* Shared/WebCoreArgumentCoders.h:
* Shared/mac/WebCoreArgumentCodersMac.mm:
(IPC::ArgumentCoder<CGRect>::encode): Deleted.
(IPC::ArgumentCoder<CGRect>::decode): Deleted.
(IPC::ArgumentCoder<CGSize>::encode): Deleted.
(IPC::ArgumentCoder<CGSize>::decode): Deleted.
(IPC::ArgumentCoder<CGPoint>::encode): Deleted.
(IPC::ArgumentCoder<CGPoint>::decode): Deleted.
(IPC::ArgumentCoder<CGAffineTransform>::encode): Deleted.
(IPC::ArgumentCoder<CGAffineTransform>::decode): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (283023 => 283024)


--- trunk/Source/WebKit/ChangeLog	2021-09-24 03:00:07 UTC (rev 283023)
+++ trunk/Source/WebKit/ChangeLog	2021-09-24 03:02:14 UTC (rev 283024)
@@ -1,3 +1,70 @@
+2021-09-23  Wenson Hsieh  <[email protected]>
+
+        [WebKit2] Refactor some IPC argument encoder logic to work with StreamConnectionEncoder
+        https://bugs.webkit.org/show_bug.cgi?id=230714
+
+        Reviewed by Simon Fraser.
+
+        Make it possible to use `IPC::StreamConnectionEncoder` to encode display list items (and their members) in an
+        IPC stream. This patch comprises two main sets of changes in `ArgumentCoders`, and `WebCoreArgumentCoders`. See
+        below for more details.
+
+        * Platform/IPC/ArgumentCoders.cpp:
+        (IPC::ArgumentCoder<audit_token_t>::decode):
+        (IPC::ArgumentCoder<Monostate>::encode): Deleted.
+        (IPC::ArgumentCoder<Monostate>::decode): Deleted.
+        * Platform/IPC/ArgumentCoders.h:
+        (IPC::ArgumentCoder<Monostate>::encode):
+        (IPC::ArgumentCoder<Monostate>::decode):
+
+        Many of these `encode()` methods are currently non-templated, which means that Encoder and Decoder used here
+        refer solely to IPC::Encoder and IPC::Decoder (respectively) instead of other types of encoders (namely,
+        StreamConnectionEncoder).
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<AffineTransform>::encode): Deleted.
+        (IPC::ArgumentCoder<AffineTransform>::decode): Deleted.
+        (IPC::ArgumentCoder<TransformationMatrix>::encode): Deleted.
+        (IPC::ArgumentCoder<TransformationMatrix>::decode): Deleted.
+        (IPC::ArgumentCoder<FloatPoint>::encode): Deleted.
+        (IPC::ArgumentCoder<FloatPoint>::decode): Deleted.
+        (IPC::ArgumentCoder<FloatPoint3D>::encode): Deleted.
+        (IPC::ArgumentCoder<FloatPoint3D>::decode): Deleted.
+        (IPC::ArgumentCoder<FloatRect>::encode): Deleted.
+        (IPC::ArgumentCoder<FloatRect>::decode): Deleted.
+        (IPC::ArgumentCoder<FloatBoxExtent>::encode): Deleted.
+        (IPC::ArgumentCoder<FloatBoxExtent>::decode): Deleted.
+        (IPC::ArgumentCoder<FloatSize>::encode): Deleted.
+        (IPC::ArgumentCoder<FloatSize>::decode): Deleted.
+        (IPC::ArgumentCoder<FloatRoundedRect>::encode): Deleted.
+        (IPC::ArgumentCoder<FloatRoundedRect>::decode): Deleted.
+        (IPC::ArgumentCoder<IntPoint>::encode): Deleted.
+        (IPC::ArgumentCoder<IntPoint>::decode): Deleted.
+        (IPC::ArgumentCoder<IntRect>::encode): Deleted.
+        (IPC::ArgumentCoder<IntRect>::decode): Deleted.
+        (IPC::ArgumentCoder<IntSize>::encode): Deleted.
+        (IPC::ArgumentCoder<IntSize>::decode): Deleted.
+        (IPC::ArgumentCoder<LayoutSize>::encode): Deleted.
+        (IPC::ArgumentCoder<LayoutSize>::decode): Deleted.
+        (IPC::ArgumentCoder<LayoutPoint>::encode): Deleted.
+        (IPC::ArgumentCoder<LayoutPoint>::decode): Deleted.
+
+        These WebCore argument coders are also currently incompatible with StreamConnectionEncoder, since they are non-
+        templated (and thus only work with IPC::Encoder). Since these are all encodable as POD types, we can just use
+        SimpleArgumentCoder for all of these. We also add a new `DEFINE_SIMPLE_ARGUMENT_CODER` macro to make this code a
+        bit easier to read.
+
+        * Shared/WebCoreArgumentCoders.h:
+        * Shared/mac/WebCoreArgumentCodersMac.mm:
+        (IPC::ArgumentCoder<CGRect>::encode): Deleted.
+        (IPC::ArgumentCoder<CGRect>::decode): Deleted.
+        (IPC::ArgumentCoder<CGSize>::encode): Deleted.
+        (IPC::ArgumentCoder<CGSize>::decode): Deleted.
+        (IPC::ArgumentCoder<CGPoint>::encode): Deleted.
+        (IPC::ArgumentCoder<CGPoint>::decode): Deleted.
+        (IPC::ArgumentCoder<CGAffineTransform>::encode): Deleted.
+        (IPC::ArgumentCoder<CGAffineTransform>::decode): Deleted.
+
 2021-09-23  Per Arne Vollan  <[email protected]>
 
         Remove access to unused services in the Networking access

Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp (283023 => 283024)


--- trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp	2021-09-24 03:00:07 UTC (rev 283023)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp	2021-09-24 03:02:14 UTC (rev 283024)
@@ -30,6 +30,7 @@
 #include "PrivateClickMeasurementDecoder.h"
 #include "PrivateClickMeasurementEncoder.h"
 #include "StreamConnectionEncoder.h"
+#include <wtf/text/AtomString.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
 
@@ -218,6 +219,7 @@
 }
 
 #if HAVE(AUDIT_TOKEN)
+
 void ArgumentCoder<audit_token_t>::encode(Encoder& encoder, const audit_token_t& auditToken)
 {
     for (unsigned i = 0; i < WTF_ARRAY_LENGTH(auditToken.val); i++)
@@ -232,15 +234,7 @@
     }
     return true;
 }
-#endif
 
-void ArgumentCoder<Monostate>::encode(Encoder&, const Monostate&)
-{
-}
+#endif // HAVE(AUDIT_TOKEN)
 
-WARN_UNUSED_RETURN std::optional<Monostate> ArgumentCoder<Monostate>::decode(Decoder&)
-{
-    return Monostate { };
-}
-
 } // namespace IPC

Modified: trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h (283023 => 283024)


--- trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2021-09-24 03:00:07 UTC (rev 283023)
+++ trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h	2021-09-24 03:02:14 UTC (rev 283024)
@@ -40,6 +40,10 @@
 
 namespace IPC {
 
+#define DEFINE_SIMPLE_ARGUMENT_CODER(className) template<> struct ArgumentCoder<className> : SimpleArgumentCoder<className> { }; \
+    template void SimpleArgumentCoder<className>::encode<Encoder>(Encoder&, const className&); \
+    template bool SimpleArgumentCoder<className>::decode<Decoder>(Decoder&, className&);
+
 // An argument coder works on POD types
 template<typename T> struct SimpleArgumentCoder {
     template<typename Encoder>
@@ -48,6 +52,7 @@
         encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(&t), sizeof(T), alignof(T));
     }
 
+    template<typename Decoder>
     static WARN_UNUSED_RETURN bool decode(Decoder& decoder, T& t)
     {
         return decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(&t), sizeof(T), alignof(T));
@@ -107,6 +112,7 @@
 };
 
 template<typename T> struct ArgumentCoder<OptionSet<T>> {
+    template<typename Encoder>
     static void encode(Encoder& encoder, const OptionSet<T>& optionSet)
     {
         ASSERT(WTF::isValidOptionSet(optionSet));
@@ -113,6 +119,7 @@
         encoder << optionSet.toRaw();
     }
 
+    template<typename Decoder>
     static WARN_UNUSED_RETURN bool decode(Decoder& decoder, OptionSet<T>& optionSet)
     {
         typename OptionSet<T>::StorageType value;
@@ -124,6 +131,7 @@
         return true;
     }
 
+    template<typename Decoder>
     static std::optional<OptionSet<T>> decode(Decoder& decoder)
     {
         std::optional<typename OptionSet<T>::StorageType> value;
@@ -187,6 +195,7 @@
 };
 
 template<typename T> struct ArgumentCoder<Box<T>> {
+    template<typename Encoder>
     static void encode(Encoder& encoder, const Box<T>& box)
     {
         if (!box) {
@@ -198,6 +207,7 @@
         encoder << *box.get();
     }
 
+    template<typename Decoder>
     static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Box<T>& box)
     {
         bool isEngaged;
@@ -217,6 +227,7 @@
         return true;
     }
 
+    template<typename Decoder>
     static std::optional<Box<T>> decode(Decoder& decoder)
     {
         std::optional<bool> isEngaged;
@@ -235,11 +246,13 @@
 };
 
 template<typename T, typename U> struct ArgumentCoder<std::pair<T, U>> {
+    template<typename Encoder>
     static void encode(Encoder& encoder, const std::pair<T, U>& pair)
     {
         encoder << pair.first << pair.second;
     }
 
+    template<typename Decoder>
     static WARN_UNUSED_RETURN bool decode(Decoder& decoder, std::pair<T, U>& pair)
     {
         T first;
@@ -255,6 +268,7 @@
         return true;
     }
 
+    template<typename Decoder>
     static std::optional<std::pair<T, U>> decode(Decoder& decoder)
     {
         std::optional<T> first;
@@ -365,11 +379,13 @@
 };
 
 template<typename KeyType, typename ValueType> struct ArgumentCoder<WTF::KeyValuePair<KeyType, ValueType>> {
+    template<typename Encoder>
     static void encode(Encoder& encoder, const WTF::KeyValuePair<KeyType, ValueType>& pair)
     {
         encoder << pair.key << pair.value;
     }
 
+    template<typename Decoder>
     static WARN_UNUSED_RETURN bool decode(Decoder& decoder, WTF::KeyValuePair<KeyType, ValueType>& pair)
     {
         KeyType key;
@@ -397,6 +413,7 @@
             encoder << vector[i];
     }
 
+    template<typename Decoder>
     static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Vector<T, inlineCapacity, OverflowHandler, minCapacity>& vector)
     {
         std::optional<Vector<T, inlineCapacity, OverflowHandler, minCapacity>> optional;
@@ -436,6 +453,7 @@
         encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(vector.data()), vector.size() * sizeof(T), alignof(T));
     }
     
+    template<typename Decoder>
     static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Vector<T, inlineCapacity, OverflowHandler, minCapacity>& vector)
     {
         uint64_t decodedSize;
@@ -450,7 +468,7 @@
         // 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))
+        if (!decoder.template bufferIsLargeEnoughToContain<T>(size))
             return false;
 
         Vector<T, inlineCapacity, OverflowHandler, minCapacity> temp;
@@ -497,6 +515,7 @@
 template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg, typename HashTableTraits> struct ArgumentCoder<HashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg, HashTableTraits>> {
     typedef HashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg, HashTableTraits> HashMapType;
 
+    template<typename Encoder>
     static void encode(Encoder& encoder, const HashMapType& hashMap)
     {
         encoder << static_cast<uint32_t>(hashMap.size());
@@ -504,6 +523,7 @@
             encoder << *it;
     }
 
+    template<typename Decoder>
     static std::optional<HashMapType> decode(Decoder& decoder)
     {
         uint32_t hashMapSize;
@@ -534,6 +554,7 @@
         return hashMap;
     }
 
+    template<typename Decoder>
     static WARN_UNUSED_RETURN bool decode(Decoder& decoder, HashMapType& hashMap)
     {
         std::optional<HashMapType> tempHashMap;
@@ -548,6 +569,7 @@
 template<typename KeyArg, typename HashArg, typename KeyTraitsArg, typename HashTableTraits> struct ArgumentCoder<HashSet<KeyArg, HashArg, KeyTraitsArg, HashTableTraits>> {
     typedef HashSet<KeyArg, HashArg, KeyTraitsArg, HashTableTraits> HashSetType;
 
+    template<typename Encoder>
     static void encode(Encoder& encoder, const HashSetType& hashSet)
     {
         encoder << static_cast<uint64_t>(hashSet.size());
@@ -555,6 +577,7 @@
             encoder << *it;
     }
 
+    template<typename Decoder>
     static WARN_UNUSED_RETURN bool decode(Decoder& decoder, HashSetType& hashSet)
     {
         std::optional<HashSetType> tempHashSet;
@@ -566,6 +589,7 @@
         return true;
     }
 
+    template<typename Decoder>
     static std::optional<HashSetType> decode(Decoder& decoder)
     {
         uint64_t hashSetSize;
@@ -595,6 +619,7 @@
 template<typename KeyArg, typename HashArg, typename KeyTraitsArg> struct ArgumentCoder<HashCountedSet<KeyArg, HashArg, KeyTraitsArg>> {
     typedef HashCountedSet<KeyArg, HashArg, KeyTraitsArg> HashCountedSetType;
     
+    template<typename Encoder>
     static void encode(Encoder& encoder, const HashCountedSetType& hashCountedSet)
     {
         encoder << static_cast<uint64_t>(hashCountedSet.size());
@@ -605,6 +630,7 @@
         }
     }
     
+    template<typename Decoder>
     static WARN_UNUSED_RETURN bool decode(Decoder& decoder, HashCountedSetType& hashCountedSet)
     {
         uint64_t hashCountedSetSize;
@@ -636,6 +662,7 @@
 };
 
 template<typename ValueType, typename ErrorType> struct ArgumentCoder<Expected<ValueType, ErrorType>> {
+    template<typename Encoder>
     static void encode(Encoder& encoder, const Expected<ValueType, ErrorType>& expected)
     {
         if (!expected.has_value()) {
@@ -647,6 +674,7 @@
         encoder << expected.value();
     }
 
+    template<typename Decoder>
     static std::optional<Expected<ValueType, ErrorType>> decode(Decoder& decoder)
     {
         std::optional<bool> hasValue;
@@ -673,6 +701,7 @@
 
 template<size_t index, typename... Types>
 struct VariantCoder {
+    template<typename Encoder>
     static void encode(Encoder& encoder, const WTF::Variant<Types...>& variant, unsigned i)
     {
         if (i == index) {
@@ -682,6 +711,7 @@
         VariantCoder<index - 1, Types...>::encode(encoder, variant, i);
     }
     
+    template<typename Decoder>
     static std::optional<WTF::Variant<Types...>> decode(Decoder& decoder, unsigned i)
     {
         if (i == index) {
@@ -697,6 +727,7 @@
 
 template<typename... Types>
 struct VariantCoder<0, Types...> {
+    template<typename Encoder>
     static void encode(Encoder& encoder, const WTF::Variant<Types...>& variant, unsigned i)
     {
         ASSERT_UNUSED(i, !i);
@@ -703,6 +734,7 @@
         encoder << WTF::get<0>(variant);
     }
     
+    template<typename Decoder>
     static std::optional<WTF::Variant<Types...>> decode(Decoder& decoder, unsigned i)
     {
         ASSERT_UNUSED(i, !i);
@@ -715,6 +747,7 @@
 };
 
 template<typename... Types> struct ArgumentCoder<WTF::Variant<Types...>> {
+    template<typename Encoder>
     static void encode(Encoder& encoder, const WTF::Variant<Types...>& variant)
     {
         unsigned i = variant.index();
@@ -722,6 +755,7 @@
         VariantCoder<sizeof...(Types) - 1, Types...>::encode(encoder, variant, i);
     }
     
+    template<typename Decoder>
     static std::optional<WTF::Variant<Types...>> decode(Decoder& decoder)
     {
         std::optional<unsigned> i;
@@ -773,8 +807,14 @@
 #endif
 
 template<> struct ArgumentCoder<Monostate> {
-    static void encode(Encoder&, const Monostate&);
-    static std::optional<Monostate> decode(Decoder&);
+    template<typename Encoder>
+    static void encode(Encoder&, const Monostate&) { }
+
+    template<typename Decoder>
+    static std::optional<Monostate> decode(Decoder&)
+    {
+        return Monostate { };
+    }
 };
 
 } // namespace IPC

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp (283023 => 283024)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2021-09-24 03:00:07 UTC (rev 283023)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp	2021-09-24 03:02:14 UTC (rev 283024)
@@ -88,7 +88,6 @@
 #include <WebCore/TextCheckerClient.h>
 #include <WebCore/TextIndicator.h>
 #include <WebCore/TimingFunction.h>
-#include <WebCore/TransformationMatrix.h>
 #include <WebCore/UserStyleSheet.h>
 #include <WebCore/VelocityData.h>
 #include <WebCore/ViewportArguments.h>
@@ -231,16 +230,6 @@
     return true;
 }
 
-void ArgumentCoder<AffineTransform>::encode(Encoder& encoder, const AffineTransform& affineTransform)
-{
-    SimpleArgumentCoder<AffineTransform>::encode(encoder, affineTransform);
-}
-
-bool ArgumentCoder<AffineTransform>::decode(Decoder& decoder, AffineTransform& affineTransform)
-{
-    return SimpleArgumentCoder<AffineTransform>::decode(decoder, affineTransform);
-}
-
 void ArgumentCoder<CacheQueryOptions>::encode(Encoder& encoder, const CacheQueryOptions& options)
 {
     encoder << options.ignoreSearch;
@@ -425,87 +414,6 @@
     return true;
 }
 
-void ArgumentCoder<TransformationMatrix>::encode(Encoder& encoder, const TransformationMatrix& transformationMatrix)
-{
-    encoder << transformationMatrix.m11();
-    encoder << transformationMatrix.m12();
-    encoder << transformationMatrix.m13();
-    encoder << transformationMatrix.m14();
-
-    encoder << transformationMatrix.m21();
-    encoder << transformationMatrix.m22();
-    encoder << transformationMatrix.m23();
-    encoder << transformationMatrix.m24();
-
-    encoder << transformationMatrix.m31();
-    encoder << transformationMatrix.m32();
-    encoder << transformationMatrix.m33();
-    encoder << transformationMatrix.m34();
-
-    encoder << transformationMatrix.m41();
-    encoder << transformationMatrix.m42();
-    encoder << transformationMatrix.m43();
-    encoder << transformationMatrix.m44();
-}
-
-bool ArgumentCoder<TransformationMatrix>::decode(Decoder& decoder, TransformationMatrix& transformationMatrix)
-{
-    double m11;
-    if (!decoder.decode(m11))
-        return false;
-    double m12;
-    if (!decoder.decode(m12))
-        return false;
-    double m13;
-    if (!decoder.decode(m13))
-        return false;
-    double m14;
-    if (!decoder.decode(m14))
-        return false;
-
-    double m21;
-    if (!decoder.decode(m21))
-        return false;
-    double m22;
-    if (!decoder.decode(m22))
-        return false;
-    double m23;
-    if (!decoder.decode(m23))
-        return false;
-    double m24;
-    if (!decoder.decode(m24))
-        return false;
-
-    double m31;
-    if (!decoder.decode(m31))
-        return false;
-    double m32;
-    if (!decoder.decode(m32))
-        return false;
-    double m33;
-    if (!decoder.decode(m33))
-        return false;
-    double m34;
-    if (!decoder.decode(m34))
-        return false;
-
-    double m41;
-    if (!decoder.decode(m41))
-        return false;
-    double m42;
-    if (!decoder.decode(m42))
-        return false;
-    double m43;
-    if (!decoder.decode(m43))
-        return false;
-    double m44;
-    if (!decoder.decode(m44))
-        return false;
-
-    transformationMatrix.setMatrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44);
-    return true;
-}
-
 void ArgumentCoder<LinearTimingFunction>::encode(Encoder& encoder, const LinearTimingFunction& timingFunction)
 {
     encoder << timingFunction.type();
@@ -617,86 +525,6 @@
     return true;
 }
 
-void ArgumentCoder<FloatPoint>::encode(Encoder& encoder, const FloatPoint& floatPoint)
-{
-    SimpleArgumentCoder<FloatPoint>::encode(encoder, floatPoint);
-}
-
-bool ArgumentCoder<FloatPoint>::decode(Decoder& decoder, FloatPoint& floatPoint)
-{
-    return SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint);
-}
-
-std::optional<FloatPoint> ArgumentCoder<FloatPoint>::decode(Decoder& decoder)
-{
-    FloatPoint floatPoint;
-    if (!SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint))
-        return std::nullopt;
-    return floatPoint;
-}
-
-void ArgumentCoder<FloatPoint3D>::encode(Encoder& encoder, const FloatPoint3D& floatPoint)
-{
-    SimpleArgumentCoder<FloatPoint3D>::encode(encoder, floatPoint);
-}
-
-bool ArgumentCoder<FloatPoint3D>::decode(Decoder& decoder, FloatPoint3D& floatPoint)
-{
-    return SimpleArgumentCoder<FloatPoint3D>::decode(decoder, floatPoint);
-}
-
-
-void ArgumentCoder<FloatRect>::encode(Encoder& encoder, const FloatRect& floatRect)
-{
-    SimpleArgumentCoder<FloatRect>::encode(encoder, floatRect);
-}
-
-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 floatRect;
-}
-
-
-void ArgumentCoder<FloatBoxExtent>::encode(Encoder& encoder, const FloatBoxExtent& floatBoxExtent)
-{
-    SimpleArgumentCoder<FloatBoxExtent>::encode(encoder, floatBoxExtent);
-}
-    
-bool ArgumentCoder<FloatBoxExtent>::decode(Decoder& decoder, FloatBoxExtent& floatBoxExtent)
-{
-    return SimpleArgumentCoder<FloatBoxExtent>::decode(decoder, floatBoxExtent);
-}
-    
-
-void ArgumentCoder<FloatSize>::encode(Encoder& encoder, const FloatSize& floatSize)
-{
-    SimpleArgumentCoder<FloatSize>::encode(encoder, floatSize);
-}
-
-bool ArgumentCoder<FloatSize>::decode(Decoder& decoder, FloatSize& floatSize)
-{
-    return SimpleArgumentCoder<FloatSize>::decode(decoder, floatSize);
-}
-
-
-void ArgumentCoder<FloatRoundedRect>::encode(Encoder& encoder, const FloatRoundedRect& roundedRect)
-{
-    SimpleArgumentCoder<FloatRoundedRect>::encode(encoder, roundedRect);
-}
-
-bool ArgumentCoder<FloatRoundedRect>::decode(Decoder& decoder, FloatRoundedRect& roundedRect)
-{
-    return SimpleArgumentCoder<FloatRoundedRect>::decode(decoder, roundedRect);
-}
-
 #if ENABLE(META_VIEWPORT)
 void ArgumentCoder<ViewportArguments>::encode(Encoder& encoder, const ViewportArguments& viewportArguments)
 {
@@ -728,87 +556,6 @@
     return SimpleArgumentCoder<ViewportAttributes>::decode(decoder, viewportAttributes);
 }
 
-void ArgumentCoder<IntPoint>::encode(Encoder& encoder, const IntPoint& intPoint)
-{
-    SimpleArgumentCoder<IntPoint>::encode(encoder, intPoint);
-}
-
-bool ArgumentCoder<IntPoint>::decode(Decoder& decoder, IntPoint& intPoint)
-{
-    return SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint);
-}
-
-std::optional<WebCore::IntPoint> ArgumentCoder<IntPoint>::decode(Decoder& decoder)
-{
-    IntPoint intPoint;
-    if (!SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint))
-        return std::nullopt;
-    return intPoint;
-}
-
-void ArgumentCoder<IntRect>::encode(Encoder& encoder, const IntRect& intRect)
-{
-    SimpleArgumentCoder<IntRect>::encode(encoder, intRect);
-}
-
-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 rect;
-}
-
-template<typename Encoder>
-void ArgumentCoder<IntSize>::encode(Encoder& encoder, const IntSize& intSize)
-{
-    SimpleArgumentCoder<IntSize>::encode(encoder, intSize);
-}
-
-template
-void ArgumentCoder<IntSize>::encode<Encoder>(Encoder&, const IntSize&);
-template
-void ArgumentCoder<IntSize>::encode<StreamConnectionEncoder>(StreamConnectionEncoder&, const IntSize&);
-
-bool ArgumentCoder<IntSize>::decode(Decoder& decoder, IntSize& intSize)
-{
-    return SimpleArgumentCoder<IntSize>::decode(decoder, intSize);
-}
-
-std::optional<IntSize> ArgumentCoder<IntSize>::decode(Decoder& decoder)
-{
-    IntSize intSize;
-    if (!SimpleArgumentCoder<IntSize>::decode(decoder, intSize))
-        return std::nullopt;
-    return intSize;
-}
-
-void ArgumentCoder<LayoutSize>::encode(Encoder& encoder, const LayoutSize& layoutSize)
-{
-    SimpleArgumentCoder<LayoutSize>::encode(encoder, layoutSize);
-}
-
-bool ArgumentCoder<LayoutSize>::decode(Decoder& decoder, LayoutSize& layoutSize)
-{
-    return SimpleArgumentCoder<LayoutSize>::decode(decoder, layoutSize);
-}
-
-
-void ArgumentCoder<LayoutPoint>::encode(Encoder& encoder, const LayoutPoint& layoutPoint)
-{
-    SimpleArgumentCoder<LayoutPoint>::encode(encoder, layoutPoint);
-}
-
-bool ArgumentCoder<LayoutPoint>::decode(Decoder& decoder, LayoutPoint& layoutPoint)
-{
-    return SimpleArgumentCoder<LayoutPoint>::decode(decoder, layoutPoint);
-}
-
 void ArgumentCoder<RecentSearch>::encode(Encoder& encoder, const RecentSearch& recentSearch)
 {
     encoder << recentSearch.string << recentSearch.time;

Modified: trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h (283023 => 283024)


--- trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h	2021-09-24 03:00:07 UTC (rev 283023)
+++ trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h	2021-09-24 03:02:14 UTC (rev 283024)
@@ -26,12 +26,24 @@
 #pragma once
 
 #include "ArgumentCoders.h"
+#include <WebCore/AffineTransform.h>
 #include <WebCore/AutoplayEvent.h>
 #include <WebCore/ColorSpace.h>
 #include <WebCore/DiagnosticLoggingClient.h>
+#include <WebCore/FloatPoint.h>
+#include <WebCore/FloatPoint3D.h>
+#include <WebCore/FloatRect.h>
+#include <WebCore/FloatRoundedRect.h>
+#include <WebCore/FloatSize.h>
 #include <WebCore/FrameLoaderTypes.h>
 #include <WebCore/IndexedDB.h>
 #include <WebCore/InputMode.h>
+#include <WebCore/IntPoint.h>
+#include <WebCore/IntRect.h>
+#include <WebCore/IntSize.h>
+#include <WebCore/LayoutPoint.h>
+#include <WebCore/LayoutSize.h>
+#include <WebCore/LengthBox.h>
 #include <WebCore/MediaSelectionOption.h>
 #include <WebCore/NativeImage.h>
 #include <WebCore/NetworkLoadMetrics.h>
@@ -42,6 +54,7 @@
 #include <WebCore/SerializedPlatformDataCueValue.h>
 #include <WebCore/ServiceWorkerTypes.h>
 #include <WebCore/StoredCredentialsPolicy.h>
+#include <WebCore/TransformationMatrix.h>
 #include <WebCore/WorkerType.h>
 #include <wtf/EnumTraits.h>
 
@@ -96,7 +109,6 @@
 namespace WebCore {
 
 class AbsolutePositionConstraints;
-class AffineTransform;
 class AuthenticationChallenge;
 class BlobPart;
 class CertificateInfo;
@@ -109,21 +121,11 @@
 class File;
 class FilterOperation;
 class FilterOperations;
-class FloatPoint;
-class FloatPoint3D;
-class FloatRect;
-class FloatRoundedRect;
-class FloatSize;
 class FixedPositionViewportConstraints;
 class Font;
 class FontPlatformData;
 class HTTPHeaderMap;
-class IntPoint;
-class IntRect;
-class IntSize;
 class KeyframeValueList;
-class LayoutSize;
-class LayoutPoint;
 class LinearTimingFunction;
 class Notification;
 class PasteboardCustomData;
@@ -140,7 +142,6 @@
 class StepsTimingFunction;
 class StickyPositionViewportConstraints;
 class TextCheckingRequestData;
-class TransformationMatrix;
 class UserStyleSheet;
 
 struct AttributedString;
@@ -174,9 +175,7 @@
 struct VelocityData;
 struct ViewportAttributes;
 struct WindowFeatures;
-    
-template<typename> class RectEdges;
-using FloatBoxExtent = RectEdges<float>;
+
 using IDBKeyPath = Variant<String, Vector<String>>;
 
 #if PLATFORM(COCOA)
@@ -227,11 +226,27 @@
 
 namespace IPC {
 
-template<> struct ArgumentCoder<WebCore::AffineTransform> {
-    static void encode(Encoder&, const WebCore::AffineTransform&);
-    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::AffineTransform&);
-};
+DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::AffineTransform)
+DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatBoxExtent)
+DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatPoint)
+DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatPoint3D)
+DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatRect)
+DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatRoundedRect)
+DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatSize)
+DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::IntPoint)
+DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::IntRect)
+DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::IntSize)
+DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::LayoutSize)
+DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::LayoutPoint)
+DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::TransformationMatrix)
 
+#if USE(CG)
+DEFINE_SIMPLE_ARGUMENT_CODER(CGRect)
+DEFINE_SIMPLE_ARGUMENT_CODER(CGSize)
+DEFINE_SIMPLE_ARGUMENT_CODER(CGPoint)
+DEFINE_SIMPLE_ARGUMENT_CODER(CGAffineTransform)
+#endif
+
 template<> struct ArgumentCoder<WebCore::AttributedString> {
     static void encode(Encoder&, const WebCore::AttributedString&);
     static std::optional<WebCore::AttributedString> decode(Decoder&);
@@ -267,11 +282,6 @@
     static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::EventTrackingRegions&);
 };
 
-template<> struct ArgumentCoder<WebCore::TransformationMatrix> {
-    static void encode(Encoder&, const WebCore::TransformationMatrix&);
-    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::TransformationMatrix&);
-};
-
 template<> struct ArgumentCoder<WebCore::LinearTimingFunction> {
     static void encode(Encoder&, const WebCore::LinearTimingFunction&);
     static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::LinearTimingFunction&);
@@ -299,38 +309,6 @@
     static std::optional<WebCore::CertificateInfo> decode(Decoder&);
 };
 
-template<> struct ArgumentCoder<WebCore::FloatPoint> {
-    static void encode(Encoder&, const WebCore::FloatPoint&);
-    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatPoint&);
-    static std::optional<WebCore::FloatPoint> decode(Decoder&);
-};
-
-template<> struct ArgumentCoder<WebCore::FloatPoint3D> {
-    static void encode(Encoder&, const WebCore::FloatPoint3D&);
-    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatPoint3D&);
-};
-
-template<> struct ArgumentCoder<WebCore::FloatRect> {
-    static void encode(Encoder&, const WebCore::FloatRect&);
-    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatRect&);
-    static std::optional<WebCore::FloatRect> decode(Decoder&);
-};
-    
-template<> struct ArgumentCoder<WebCore::FloatBoxExtent> {
-    static void encode(Encoder&, const WebCore::FloatBoxExtent&);
-    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatBoxExtent&);
-};
-
-template<> struct ArgumentCoder<WebCore::FloatSize> {
-    static void encode(Encoder&, const WebCore::FloatSize&);
-    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatSize&);
-};
-
-template<> struct ArgumentCoder<WebCore::FloatRoundedRect> {
-    static void encode(Encoder&, const WebCore::FloatRoundedRect&);
-    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatRoundedRect&);
-};
-
 #if ENABLE(META_VIEWPORT)
 template<> struct ArgumentCoder<WebCore::ViewportArguments> {
     static void encode(Encoder&, const WebCore::ViewportArguments&);
@@ -345,35 +323,6 @@
     static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::ViewportAttributes&);
 };
 
-template<> struct ArgumentCoder<WebCore::IntPoint> {
-    static void encode(Encoder&, const WebCore::IntPoint&);
-    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::IntPoint&);
-    static std::optional<WebCore::IntPoint> decode(Decoder&);
-};
-
-template<> struct ArgumentCoder<WebCore::IntRect> {
-    static void encode(Encoder&, const WebCore::IntRect&);
-    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::IntRect&);
-    static std::optional<WebCore::IntRect> decode(Decoder&);
-};
-
-template<> struct ArgumentCoder<WebCore::IntSize> {
-    template<typename Encoder>
-    static void encode(Encoder&, const WebCore::IntSize&);
-    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::IntSize&);
-    static std::optional<WebCore::IntSize> decode(Decoder&);
-};
-
-template<> struct ArgumentCoder<WebCore::LayoutSize> {
-    static void encode(Encoder&, const WebCore::LayoutSize&);
-    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::LayoutSize&);
-};
-
-template<> struct ArgumentCoder<WebCore::LayoutPoint> {
-    static void encode(Encoder&, const WebCore::LayoutPoint&);
-    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::LayoutPoint&);
-};
-
 template<> struct ArgumentCoder<WebCore::Length> {
     static void encode(Encoder&, const WebCore::Length&);
     static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::Length&);
@@ -452,6 +401,7 @@
 #endif
 
 #if PLATFORM(COCOA)
+
 template<> struct ArgumentCoder<WTF::MachSendRight> {
     static void encode(Encoder&, const WTF::MachSendRight&);
     static void encode(Encoder&, WTF::MachSendRight&&);
@@ -463,27 +413,8 @@
     static std::optional<WebCore::KeypressCommand> decode(Decoder&);
 };
 
-template<> struct ArgumentCoder<CGPoint> {
-    static void encode(Encoder&, CGPoint);
-    static std::optional<CGPoint> decode(Decoder&);
-};
+#endif // PLATFORM(COCOA)
 
-template<> struct ArgumentCoder<CGSize> {
-    static void encode(Encoder&, CGSize);
-    static std::optional<CGSize> decode(Decoder&);
-};
-
-template<> struct ArgumentCoder<CGRect> {
-    static void encode(Encoder&, CGRect);
-    static std::optional<CGRect> decode(Decoder&);
-};
-
-template<> struct ArgumentCoder<CGAffineTransform> {
-    static void encode(Encoder&, CGAffineTransform);
-    static std::optional<CGAffineTransform> decode(Decoder&);
-};
-#endif
-
 #if PLATFORM(IOS_FAMILY)
 template<> struct ArgumentCoder<WebCore::SelectionGeometry> {
     static void encode(Encoder&, const WebCore::SelectionGeometry&);

Modified: trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm (283023 => 283024)


--- trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm	2021-09-24 03:00:07 UTC (rev 283023)
+++ trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm	2021-09-24 03:02:14 UTC (rev 283024)
@@ -321,79 +321,6 @@
     return WTFMove(command);
 }
 
-void ArgumentCoder<CGRect>::encode(Encoder& encoder, CGRect rect)
-{
-    encoder << rect.origin << rect.size;
-}
-
-std::optional<CGRect> ArgumentCoder<CGRect>::decode(Decoder& decoder)
-{
-    std::optional<CGPoint> origin;
-    decoder >> origin;
-    if (!origin)
-        return { };
-
-    std::optional<CGSize> size;
-    decoder >> size;
-    if (!size)
-        return { };
-
-    return CGRect { *origin, *size };
-}
-
-void ArgumentCoder<CGSize>::encode(Encoder& encoder, CGSize size)
-{
-    encoder << size.width << size.height;
-}
-
-std::optional<CGSize> ArgumentCoder<CGSize>::decode(Decoder& decoder)
-{
-    CGSize size;
-    if (!decoder.decode(size.width))
-        return { };
-    if (!decoder.decode(size.height))
-        return { };
-    return size;
-}
-
-void ArgumentCoder<CGPoint>::encode(Encoder& encoder, CGPoint point)
-{
-    encoder << point.x << point.y;
-}
-
-std::optional<CGPoint> ArgumentCoder<CGPoint>::decode(Decoder& decoder)
-{
-    CGPoint point;
-    if (!decoder.decode(point.x))
-        return { };
-    if (!decoder.decode(point.y))
-        return { };
-    return point;
-}
-
-void ArgumentCoder<CGAffineTransform>::encode(Encoder& encoder, CGAffineTransform transform)
-{
-    encoder << transform.a << transform.b << transform.c << transform.d << transform.tx << transform.ty;
-}
-
-std::optional<CGAffineTransform> ArgumentCoder<CGAffineTransform>::decode(Decoder& decoder)
-{
-    CGAffineTransform transform;
-    if (!decoder.decode(transform.a))
-        return { };
-    if (!decoder.decode(transform.b))
-        return { };
-    if (!decoder.decode(transform.c))
-        return { };
-    if (!decoder.decode(transform.d))
-        return { };
-    if (!decoder.decode(transform.tx))
-        return { };
-    if (!decoder.decode(transform.ty))
-        return { };
-    return transform;
-}
-
 #if ENABLE(CONTENT_FILTERING)
 
 void ArgumentCoder<WebCore::ContentFilterUnblockHandler>::encode(Encoder& encoder, const WebCore::ContentFilterUnblockHandler& contentFilterUnblockHandler)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to