Changeset 283048 in webkit


Ignore:
Timestamp:
Sep 24, 2021, 11:01:49 AM (4 years ago)
Author:
Eric Hutchison
Message:

Unreviewed, reverting r283024.

Causes slowdown and crash on EWS

Reverted changeset:

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

Location:
trunk/Source/WebKit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r283046 r283048  
     12021-09-24  Eric Hutchison  <ehutchison@apple.com>
     2
     3        Unreviewed, reverting r283024.
     4
     5        Causes slowdown and crash on EWS
     6
     7        Reverted changeset:
     8
     9        "[WebKit2] Refactor some IPC argument encoder logic to work
     10        with StreamConnectionEncoder"
     11        https://bugs.webkit.org/show_bug.cgi?id=230714
     12        https://commits.webkit.org/r283024
     13
    1142021-09-24  Youenn Fablet  <youenn@apple.com>
    215
  • trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp

    r283024 r283048  
    3131#include "PrivateClickMeasurementEncoder.h"
    3232#include "StreamConnectionEncoder.h"
    33 #include <wtf/text/AtomString.h>
    3433#include <wtf/text/CString.h>
    3534#include <wtf/text/WTFString.h>
     
    220219
    221220#if HAVE(AUDIT_TOKEN)
    222 
    223221void ArgumentCoder<audit_token_t>::encode(Encoder& encoder, const audit_token_t& auditToken)
    224222{
     
    235233    return true;
    236234}
    237 
    238 #endif // HAVE(AUDIT_TOKEN)
     235#endif
     236
     237void ArgumentCoder<Monostate>::encode(Encoder&, const Monostate&)
     238{
     239}
     240
     241WARN_UNUSED_RETURN std::optional<Monostate> ArgumentCoder<Monostate>::decode(Decoder&)
     242{
     243    return Monostate { };
     244}
    239245
    240246} // namespace IPC
  • trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h

    r283024 r283048  
    4141namespace IPC {
    4242
    43 #define DEFINE_SIMPLE_ARGUMENT_CODER(className) template<> struct ArgumentCoder<className> : SimpleArgumentCoder<className> { }; \
    44     template void SimpleArgumentCoder<className>::encode<Encoder>(Encoder&, const className&); \
    45     template bool SimpleArgumentCoder<className>::decode<Decoder>(Decoder&, className&);
    46 
    4743// An argument coder works on POD types
    4844template<typename T> struct SimpleArgumentCoder {
     
    5349    }
    5450
    55     template<typename Decoder>
    5651    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, T& t)
    5752    {
     
    113108
    114109template<typename T> struct ArgumentCoder<OptionSet<T>> {
    115     template<typename Encoder>
    116110    static void encode(Encoder& encoder, const OptionSet<T>& optionSet)
    117111    {
     
    120114    }
    121115
    122     template<typename Decoder>
    123116    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, OptionSet<T>& optionSet)
    124117    {
     
    132125    }
    133126
    134     template<typename Decoder>
    135127    static std::optional<OptionSet<T>> decode(Decoder& decoder)
    136128    {
     
    196188
    197189template<typename T> struct ArgumentCoder<Box<T>> {
    198     template<typename Encoder>
    199190    static void encode(Encoder& encoder, const Box<T>& box)
    200191    {
     
    208199    }
    209200
    210     template<typename Decoder>
    211201    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Box<T>& box)
    212202    {
     
    228218    }
    229219
    230     template<typename Decoder>
    231220    static std::optional<Box<T>> decode(Decoder& decoder)
    232221    {
     
    247236
    248237template<typename T, typename U> struct ArgumentCoder<std::pair<T, U>> {
    249     template<typename Encoder>
    250238    static void encode(Encoder& encoder, const std::pair<T, U>& pair)
    251239    {
     
    253241    }
    254242
    255     template<typename Decoder>
    256243    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, std::pair<T, U>& pair)
    257244    {
     
    269256    }
    270257
    271     template<typename Decoder>
    272258    static std::optional<std::pair<T, U>> decode(Decoder& decoder)
    273259    {
     
    380366
    381367template<typename KeyType, typename ValueType> struct ArgumentCoder<WTF::KeyValuePair<KeyType, ValueType>> {
    382     template<typename Encoder>
    383368    static void encode(Encoder& encoder, const WTF::KeyValuePair<KeyType, ValueType>& pair)
    384369    {
     
    386371    }
    387372
    388     template<typename Decoder>
    389373    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, WTF::KeyValuePair<KeyType, ValueType>& pair)
    390374    {
     
    414398    }
    415399
    416     template<typename Decoder>
    417400    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Vector<T, inlineCapacity, OverflowHandler, minCapacity>& vector)
    418401    {
     
    454437    }
    455438   
    456     template<typename Decoder>
    457439    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, Vector<T, inlineCapacity, OverflowHandler, minCapacity>& vector)
    458440    {
     
    465447
    466448        auto size = static_cast<size_t>(decodedSize);
     449
     450        // Since we know the total size of the elements, we can allocate the vector in
     451        // one fell swoop. Before allocating we must however make sure that the decoder buffer
     452        // is big enough.
     453        if (!decoder.bufferIsLargeEnoughToContain<T>(size))
     454            return false;
     455
     456        Vector<T, inlineCapacity, OverflowHandler, minCapacity> temp;
     457        temp.grow(size);
     458
     459        if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T), alignof(T)))
     460            return false;
     461
     462        vector.swap(temp);
     463        return true;
     464    }
     465   
     466    template<typename Decoder>
     467    static std::optional<Vector<T, inlineCapacity, OverflowHandler, minCapacity>> decode(Decoder& decoder)
     468    {
     469        std::optional<uint64_t> decodedSize;
     470        decoder >> decodedSize;
     471        if (!decodedSize)
     472            return std::nullopt;
     473
     474        if (!isInBounds<size_t>(decodedSize))
     475            return std::nullopt;
     476
     477        auto size = static_cast<size_t>(*decodedSize);
    467478
    468479        // Since we know the total size of the elements, we can allocate the vector in
     
    470481        // is big enough.
    471482        if (!decoder.template bufferIsLargeEnoughToContain<T>(size))
    472             return false;
    473 
    474         Vector<T, inlineCapacity, OverflowHandler, minCapacity> temp;
    475         temp.grow(size);
    476 
    477         if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T), alignof(T)))
    478             return false;
    479 
    480         vector.swap(temp);
    481         return true;
    482     }
    483    
    484     template<typename Decoder>
    485     static std::optional<Vector<T, inlineCapacity, OverflowHandler, minCapacity>> decode(Decoder& decoder)
    486     {
    487         std::optional<uint64_t> decodedSize;
    488         decoder >> decodedSize;
    489         if (!decodedSize)
    490             return std::nullopt;
    491 
    492         if (!isInBounds<size_t>(decodedSize))
    493             return std::nullopt;
    494 
    495         auto size = static_cast<size_t>(*decodedSize);
    496 
    497         // Since we know the total size of the elements, we can allocate the vector in
    498         // one fell swoop. Before allocating we must however make sure that the decoder buffer
    499         // is big enough.
    500         if (!decoder.template bufferIsLargeEnoughToContain<T>(size))
    501483            return std::nullopt;
    502484       
     
    516498    typedef HashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg, HashTableTraits> HashMapType;
    517499
    518     template<typename Encoder>
    519500    static void encode(Encoder& encoder, const HashMapType& hashMap)
    520501    {
     
    524505    }
    525506
    526     template<typename Decoder>
    527507    static std::optional<HashMapType> decode(Decoder& decoder)
    528508    {
     
    555535    }
    556536
    557     template<typename Decoder>
    558537    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, HashMapType& hashMap)
    559538    {
     
    570549    typedef HashSet<KeyArg, HashArg, KeyTraitsArg, HashTableTraits> HashSetType;
    571550
    572     template<typename Encoder>
    573551    static void encode(Encoder& encoder, const HashSetType& hashSet)
    574552    {
     
    578556    }
    579557
    580     template<typename Decoder>
    581558    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, HashSetType& hashSet)
    582559    {
     
    590567    }
    591568
    592     template<typename Decoder>
    593569    static std::optional<HashSetType> decode(Decoder& decoder)
    594570    {
     
    620596    typedef HashCountedSet<KeyArg, HashArg, KeyTraitsArg> HashCountedSetType;
    621597   
    622     template<typename Encoder>
    623598    static void encode(Encoder& encoder, const HashCountedSetType& hashCountedSet)
    624599    {
     
    631606    }
    632607   
    633     template<typename Decoder>
    634608    static WARN_UNUSED_RETURN bool decode(Decoder& decoder, HashCountedSetType& hashCountedSet)
    635609    {
     
    663637
    664638template<typename ValueType, typename ErrorType> struct ArgumentCoder<Expected<ValueType, ErrorType>> {
    665     template<typename Encoder>
    666639    static void encode(Encoder& encoder, const Expected<ValueType, ErrorType>& expected)
    667640    {
     
    675648    }
    676649
    677     template<typename Decoder>
    678650    static std::optional<Expected<ValueType, ErrorType>> decode(Decoder& decoder)
    679651    {
     
    702674template<size_t index, typename... Types>
    703675struct VariantCoder {
    704     template<typename Encoder>
    705676    static void encode(Encoder& encoder, const WTF::Variant<Types...>& variant, unsigned i)
    706677    {
     
    712683    }
    713684   
    714     template<typename Decoder>
    715685    static std::optional<WTF::Variant<Types...>> decode(Decoder& decoder, unsigned i)
    716686    {
     
    728698template<typename... Types>
    729699struct VariantCoder<0, Types...> {
    730     template<typename Encoder>
    731700    static void encode(Encoder& encoder, const WTF::Variant<Types...>& variant, unsigned i)
    732701    {
     
    735704    }
    736705   
    737     template<typename Decoder>
    738706    static std::optional<WTF::Variant<Types...>> decode(Decoder& decoder, unsigned i)
    739707    {
     
    748716
    749717template<typename... Types> struct ArgumentCoder<WTF::Variant<Types...>> {
    750     template<typename Encoder>
    751718    static void encode(Encoder& encoder, const WTF::Variant<Types...>& variant)
    752719    {
     
    756723    }
    757724   
    758     template<typename Decoder>
    759725    static std::optional<WTF::Variant<Types...>> decode(Decoder& decoder)
    760726    {
     
    808774
    809775template<> struct ArgumentCoder<Monostate> {
    810     template<typename Encoder>
    811     static void encode(Encoder&, const Monostate&) { }
    812 
    813     template<typename Decoder>
    814     static std::optional<Monostate> decode(Decoder&)
    815     {
    816         return Monostate { };
    817     }
     776    static void encode(Encoder&, const Monostate&);
     777    static std::optional<Monostate> decode(Decoder&);
    818778};
    819779
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp

    r283024 r283048  
    8989#include <WebCore/TextIndicator.h>
    9090#include <WebCore/TimingFunction.h>
     91#include <WebCore/TransformationMatrix.h>
    9192#include <WebCore/UserStyleSheet.h>
    9293#include <WebCore/VelocityData.h>
     
    229230
    230231    return true;
     232}
     233
     234void ArgumentCoder<AffineTransform>::encode(Encoder& encoder, const AffineTransform& affineTransform)
     235{
     236    SimpleArgumentCoder<AffineTransform>::encode(encoder, affineTransform);
     237}
     238
     239bool ArgumentCoder<AffineTransform>::decode(Decoder& decoder, AffineTransform& affineTransform)
     240{
     241    return SimpleArgumentCoder<AffineTransform>::decode(decoder, affineTransform);
    231242}
    232243
     
    415426}
    416427
     428void ArgumentCoder<TransformationMatrix>::encode(Encoder& encoder, const TransformationMatrix& transformationMatrix)
     429{
     430    encoder << transformationMatrix.m11();
     431    encoder << transformationMatrix.m12();
     432    encoder << transformationMatrix.m13();
     433    encoder << transformationMatrix.m14();
     434
     435    encoder << transformationMatrix.m21();
     436    encoder << transformationMatrix.m22();
     437    encoder << transformationMatrix.m23();
     438    encoder << transformationMatrix.m24();
     439
     440    encoder << transformationMatrix.m31();
     441    encoder << transformationMatrix.m32();
     442    encoder << transformationMatrix.m33();
     443    encoder << transformationMatrix.m34();
     444
     445    encoder << transformationMatrix.m41();
     446    encoder << transformationMatrix.m42();
     447    encoder << transformationMatrix.m43();
     448    encoder << transformationMatrix.m44();
     449}
     450
     451bool ArgumentCoder<TransformationMatrix>::decode(Decoder& decoder, TransformationMatrix& transformationMatrix)
     452{
     453    double m11;
     454    if (!decoder.decode(m11))
     455        return false;
     456    double m12;
     457    if (!decoder.decode(m12))
     458        return false;
     459    double m13;
     460    if (!decoder.decode(m13))
     461        return false;
     462    double m14;
     463    if (!decoder.decode(m14))
     464        return false;
     465
     466    double m21;
     467    if (!decoder.decode(m21))
     468        return false;
     469    double m22;
     470    if (!decoder.decode(m22))
     471        return false;
     472    double m23;
     473    if (!decoder.decode(m23))
     474        return false;
     475    double m24;
     476    if (!decoder.decode(m24))
     477        return false;
     478
     479    double m31;
     480    if (!decoder.decode(m31))
     481        return false;
     482    double m32;
     483    if (!decoder.decode(m32))
     484        return false;
     485    double m33;
     486    if (!decoder.decode(m33))
     487        return false;
     488    double m34;
     489    if (!decoder.decode(m34))
     490        return false;
     491
     492    double m41;
     493    if (!decoder.decode(m41))
     494        return false;
     495    double m42;
     496    if (!decoder.decode(m42))
     497        return false;
     498    double m43;
     499    if (!decoder.decode(m43))
     500        return false;
     501    double m44;
     502    if (!decoder.decode(m44))
     503        return false;
     504
     505    transformationMatrix.setMatrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44);
     506    return true;
     507}
     508
    417509void ArgumentCoder<LinearTimingFunction>::encode(Encoder& encoder, const LinearTimingFunction& timingFunction)
    418510{
     
    526618}
    527619
     620void ArgumentCoder<FloatPoint>::encode(Encoder& encoder, const FloatPoint& floatPoint)
     621{
     622    SimpleArgumentCoder<FloatPoint>::encode(encoder, floatPoint);
     623}
     624
     625bool ArgumentCoder<FloatPoint>::decode(Decoder& decoder, FloatPoint& floatPoint)
     626{
     627    return SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint);
     628}
     629
     630std::optional<FloatPoint> ArgumentCoder<FloatPoint>::decode(Decoder& decoder)
     631{
     632    FloatPoint floatPoint;
     633    if (!SimpleArgumentCoder<FloatPoint>::decode(decoder, floatPoint))
     634        return std::nullopt;
     635    return floatPoint;
     636}
     637
     638void ArgumentCoder<FloatPoint3D>::encode(Encoder& encoder, const FloatPoint3D& floatPoint)
     639{
     640    SimpleArgumentCoder<FloatPoint3D>::encode(encoder, floatPoint);
     641}
     642
     643bool ArgumentCoder<FloatPoint3D>::decode(Decoder& decoder, FloatPoint3D& floatPoint)
     644{
     645    return SimpleArgumentCoder<FloatPoint3D>::decode(decoder, floatPoint);
     646}
     647
     648
     649void ArgumentCoder<FloatRect>::encode(Encoder& encoder, const FloatRect& floatRect)
     650{
     651    SimpleArgumentCoder<FloatRect>::encode(encoder, floatRect);
     652}
     653
     654bool ArgumentCoder<FloatRect>::decode(Decoder& decoder, FloatRect& floatRect)
     655{
     656    return SimpleArgumentCoder<FloatRect>::decode(decoder, floatRect);
     657}
     658
     659std::optional<FloatRect> ArgumentCoder<FloatRect>::decode(Decoder& decoder)
     660{
     661    FloatRect floatRect;
     662    if (!SimpleArgumentCoder<FloatRect>::decode(decoder, floatRect))
     663        return std::nullopt;
     664    return floatRect;
     665}
     666
     667
     668void ArgumentCoder<FloatBoxExtent>::encode(Encoder& encoder, const FloatBoxExtent& floatBoxExtent)
     669{
     670    SimpleArgumentCoder<FloatBoxExtent>::encode(encoder, floatBoxExtent);
     671}
     672   
     673bool ArgumentCoder<FloatBoxExtent>::decode(Decoder& decoder, FloatBoxExtent& floatBoxExtent)
     674{
     675    return SimpleArgumentCoder<FloatBoxExtent>::decode(decoder, floatBoxExtent);
     676}
     677   
     678
     679void ArgumentCoder<FloatSize>::encode(Encoder& encoder, const FloatSize& floatSize)
     680{
     681    SimpleArgumentCoder<FloatSize>::encode(encoder, floatSize);
     682}
     683
     684bool ArgumentCoder<FloatSize>::decode(Decoder& decoder, FloatSize& floatSize)
     685{
     686    return SimpleArgumentCoder<FloatSize>::decode(decoder, floatSize);
     687}
     688
     689
     690void ArgumentCoder<FloatRoundedRect>::encode(Encoder& encoder, const FloatRoundedRect& roundedRect)
     691{
     692    SimpleArgumentCoder<FloatRoundedRect>::encode(encoder, roundedRect);
     693}
     694
     695bool ArgumentCoder<FloatRoundedRect>::decode(Decoder& decoder, FloatRoundedRect& roundedRect)
     696{
     697    return SimpleArgumentCoder<FloatRoundedRect>::decode(decoder, roundedRect);
     698}
     699
    528700#if ENABLE(META_VIEWPORT)
    529701void ArgumentCoder<ViewportArguments>::encode(Encoder& encoder, const ViewportArguments& viewportArguments)
     
    555727{
    556728    return SimpleArgumentCoder<ViewportAttributes>::decode(decoder, viewportAttributes);
     729}
     730
     731void ArgumentCoder<IntPoint>::encode(Encoder& encoder, const IntPoint& intPoint)
     732{
     733    SimpleArgumentCoder<IntPoint>::encode(encoder, intPoint);
     734}
     735
     736bool ArgumentCoder<IntPoint>::decode(Decoder& decoder, IntPoint& intPoint)
     737{
     738    return SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint);
     739}
     740
     741std::optional<WebCore::IntPoint> ArgumentCoder<IntPoint>::decode(Decoder& decoder)
     742{
     743    IntPoint intPoint;
     744    if (!SimpleArgumentCoder<IntPoint>::decode(decoder, intPoint))
     745        return std::nullopt;
     746    return intPoint;
     747}
     748
     749void ArgumentCoder<IntRect>::encode(Encoder& encoder, const IntRect& intRect)
     750{
     751    SimpleArgumentCoder<IntRect>::encode(encoder, intRect);
     752}
     753
     754bool ArgumentCoder<IntRect>::decode(Decoder& decoder, IntRect& intRect)
     755{
     756    return SimpleArgumentCoder<IntRect>::decode(decoder, intRect);
     757}
     758
     759std::optional<IntRect> ArgumentCoder<IntRect>::decode(Decoder& decoder)
     760{
     761    IntRect rect;
     762    if (!decode(decoder, rect))
     763        return std::nullopt;
     764    return rect;
     765}
     766
     767template<typename Encoder>
     768void ArgumentCoder<IntSize>::encode(Encoder& encoder, const IntSize& intSize)
     769{
     770    SimpleArgumentCoder<IntSize>::encode(encoder, intSize);
     771}
     772
     773template
     774void ArgumentCoder<IntSize>::encode<Encoder>(Encoder&, const IntSize&);
     775template
     776void ArgumentCoder<IntSize>::encode<StreamConnectionEncoder>(StreamConnectionEncoder&, const IntSize&);
     777
     778bool ArgumentCoder<IntSize>::decode(Decoder& decoder, IntSize& intSize)
     779{
     780    return SimpleArgumentCoder<IntSize>::decode(decoder, intSize);
     781}
     782
     783std::optional<IntSize> ArgumentCoder<IntSize>::decode(Decoder& decoder)
     784{
     785    IntSize intSize;
     786    if (!SimpleArgumentCoder<IntSize>::decode(decoder, intSize))
     787        return std::nullopt;
     788    return intSize;
     789}
     790
     791void ArgumentCoder<LayoutSize>::encode(Encoder& encoder, const LayoutSize& layoutSize)
     792{
     793    SimpleArgumentCoder<LayoutSize>::encode(encoder, layoutSize);
     794}
     795
     796bool ArgumentCoder<LayoutSize>::decode(Decoder& decoder, LayoutSize& layoutSize)
     797{
     798    return SimpleArgumentCoder<LayoutSize>::decode(decoder, layoutSize);
     799}
     800
     801
     802void ArgumentCoder<LayoutPoint>::encode(Encoder& encoder, const LayoutPoint& layoutPoint)
     803{
     804    SimpleArgumentCoder<LayoutPoint>::encode(encoder, layoutPoint);
     805}
     806
     807bool ArgumentCoder<LayoutPoint>::decode(Decoder& decoder, LayoutPoint& layoutPoint)
     808{
     809    return SimpleArgumentCoder<LayoutPoint>::decode(decoder, layoutPoint);
    557810}
    558811
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h

    r283024 r283048  
    2727
    2828#include "ArgumentCoders.h"
    29 #include <WebCore/AffineTransform.h>
    3029#include <WebCore/AutoplayEvent.h>
    3130#include <WebCore/ColorSpace.h>
    3231#include <WebCore/DiagnosticLoggingClient.h>
    33 #include <WebCore/FloatPoint.h>
    34 #include <WebCore/FloatPoint3D.h>
    35 #include <WebCore/FloatRect.h>
    36 #include <WebCore/FloatRoundedRect.h>
    37 #include <WebCore/FloatSize.h>
    3832#include <WebCore/FrameLoaderTypes.h>
    3933#include <WebCore/IndexedDB.h>
    4034#include <WebCore/InputMode.h>
    41 #include <WebCore/IntPoint.h>
    42 #include <WebCore/IntRect.h>
    43 #include <WebCore/IntSize.h>
    44 #include <WebCore/LayoutPoint.h>
    45 #include <WebCore/LayoutSize.h>
    46 #include <WebCore/LengthBox.h>
    4735#include <WebCore/MediaSelectionOption.h>
    4836#include <WebCore/NativeImage.h>
     
    5543#include <WebCore/ServiceWorkerTypes.h>
    5644#include <WebCore/StoredCredentialsPolicy.h>
    57 #include <WebCore/TransformationMatrix.h>
    5845#include <WebCore/WorkerType.h>
    5946#include <wtf/EnumTraits.h>
     
    11097
    11198class AbsolutePositionConstraints;
     99class AffineTransform;
    112100class AuthenticationChallenge;
    113101class BlobPart;
     
    122110class FilterOperation;
    123111class FilterOperations;
     112class FloatPoint;
     113class FloatPoint3D;
     114class FloatRect;
     115class FloatRoundedRect;
     116class FloatSize;
    124117class FixedPositionViewportConstraints;
    125118class Font;
    126119class FontPlatformData;
    127120class HTTPHeaderMap;
     121class IntPoint;
     122class IntRect;
     123class IntSize;
    128124class KeyframeValueList;
     125class LayoutSize;
     126class LayoutPoint;
    129127class LinearTimingFunction;
    130128class Notification;
     
    143141class StickyPositionViewportConstraints;
    144142class TextCheckingRequestData;
     143class TransformationMatrix;
    145144class UserStyleSheet;
    146145
     
    176175struct ViewportAttributes;
    177176struct WindowFeatures;
    178 
     177   
     178template<typename> class RectEdges;
     179using FloatBoxExtent = RectEdges<float>;
    179180using IDBKeyPath = Variant<String, Vector<String>>;
    180181
     
    227228namespace IPC {
    228229
    229 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::AffineTransform)
    230 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatBoxExtent)
    231 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatPoint)
    232 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatPoint3D)
    233 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatRect)
    234 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatRoundedRect)
    235 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::FloatSize)
    236 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::IntPoint)
    237 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::IntRect)
    238 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::IntSize)
    239 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::LayoutSize)
    240 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::LayoutPoint)
    241 DEFINE_SIMPLE_ARGUMENT_CODER(WebCore::TransformationMatrix)
    242 
    243 #if USE(CG)
    244 DEFINE_SIMPLE_ARGUMENT_CODER(CGRect)
    245 DEFINE_SIMPLE_ARGUMENT_CODER(CGSize)
    246 DEFINE_SIMPLE_ARGUMENT_CODER(CGPoint)
    247 DEFINE_SIMPLE_ARGUMENT_CODER(CGAffineTransform)
    248 #endif
     230template<> struct ArgumentCoder<WebCore::AffineTransform> {
     231    static void encode(Encoder&, const WebCore::AffineTransform&);
     232    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::AffineTransform&);
     233};
    249234
    250235template<> struct ArgumentCoder<WebCore::AttributedString> {
     
    281266    static void encode(Encoder&, const WebCore::EventTrackingRegions&);
    282267    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::EventTrackingRegions&);
     268};
     269
     270template<> struct ArgumentCoder<WebCore::TransformationMatrix> {
     271    static void encode(Encoder&, const WebCore::TransformationMatrix&);
     272    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::TransformationMatrix&);
    283273};
    284274
     
    310300};
    311301
     302template<> struct ArgumentCoder<WebCore::FloatPoint> {
     303    static void encode(Encoder&, const WebCore::FloatPoint&);
     304    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatPoint&);
     305    static std::optional<WebCore::FloatPoint> decode(Decoder&);
     306};
     307
     308template<> struct ArgumentCoder<WebCore::FloatPoint3D> {
     309    static void encode(Encoder&, const WebCore::FloatPoint3D&);
     310    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatPoint3D&);
     311};
     312
     313template<> struct ArgumentCoder<WebCore::FloatRect> {
     314    static void encode(Encoder&, const WebCore::FloatRect&);
     315    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatRect&);
     316    static std::optional<WebCore::FloatRect> decode(Decoder&);
     317};
     318   
     319template<> struct ArgumentCoder<WebCore::FloatBoxExtent> {
     320    static void encode(Encoder&, const WebCore::FloatBoxExtent&);
     321    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatBoxExtent&);
     322};
     323
     324template<> struct ArgumentCoder<WebCore::FloatSize> {
     325    static void encode(Encoder&, const WebCore::FloatSize&);
     326    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatSize&);
     327};
     328
     329template<> struct ArgumentCoder<WebCore::FloatRoundedRect> {
     330    static void encode(Encoder&, const WebCore::FloatRoundedRect&);
     331    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::FloatRoundedRect&);
     332};
     333
    312334#if ENABLE(META_VIEWPORT)
    313335template<> struct ArgumentCoder<WebCore::ViewportArguments> {
     
    324346};
    325347
     348template<> struct ArgumentCoder<WebCore::IntPoint> {
     349    static void encode(Encoder&, const WebCore::IntPoint&);
     350    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::IntPoint&);
     351    static std::optional<WebCore::IntPoint> decode(Decoder&);
     352};
     353
     354template<> struct ArgumentCoder<WebCore::IntRect> {
     355    static void encode(Encoder&, const WebCore::IntRect&);
     356    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::IntRect&);
     357    static std::optional<WebCore::IntRect> decode(Decoder&);
     358};
     359
     360template<> struct ArgumentCoder<WebCore::IntSize> {
     361    template<typename Encoder>
     362    static void encode(Encoder&, const WebCore::IntSize&);
     363    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::IntSize&);
     364    static std::optional<WebCore::IntSize> decode(Decoder&);
     365};
     366
     367template<> struct ArgumentCoder<WebCore::LayoutSize> {
     368    static void encode(Encoder&, const WebCore::LayoutSize&);
     369    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::LayoutSize&);
     370};
     371
     372template<> struct ArgumentCoder<WebCore::LayoutPoint> {
     373    static void encode(Encoder&, const WebCore::LayoutPoint&);
     374    static WARN_UNUSED_RETURN bool decode(Decoder&, WebCore::LayoutPoint&);
     375};
     376
    326377template<> struct ArgumentCoder<WebCore::Length> {
    327378    static void encode(Encoder&, const WebCore::Length&);
     
    402453
    403454#if PLATFORM(COCOA)
    404 
    405455template<> struct ArgumentCoder<WTF::MachSendRight> {
    406456    static void encode(Encoder&, const WTF::MachSendRight&);
     
    414464};
    415465
    416 #endif // PLATFORM(COCOA)
     466template<> struct ArgumentCoder<CGPoint> {
     467    static void encode(Encoder&, CGPoint);
     468    static std::optional<CGPoint> decode(Decoder&);
     469};
     470
     471template<> struct ArgumentCoder<CGSize> {
     472    static void encode(Encoder&, CGSize);
     473    static std::optional<CGSize> decode(Decoder&);
     474};
     475
     476template<> struct ArgumentCoder<CGRect> {
     477    static void encode(Encoder&, CGRect);
     478    static std::optional<CGRect> decode(Decoder&);
     479};
     480
     481template<> struct ArgumentCoder<CGAffineTransform> {
     482    static void encode(Encoder&, CGAffineTransform);
     483    static std::optional<CGAffineTransform> decode(Decoder&);
     484};
     485#endif
    417486
    418487#if PLATFORM(IOS_FAMILY)
  • trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm

    r283024 r283048  
    322322}
    323323
     324void ArgumentCoder<CGRect>::encode(Encoder& encoder, CGRect rect)
     325{
     326    encoder << rect.origin << rect.size;
     327}
     328
     329std::optional<CGRect> ArgumentCoder<CGRect>::decode(Decoder& decoder)
     330{
     331    std::optional<CGPoint> origin;
     332    decoder >> origin;
     333    if (!origin)
     334        return { };
     335
     336    std::optional<CGSize> size;
     337    decoder >> size;
     338    if (!size)
     339        return { };
     340
     341    return CGRect { *origin, *size };
     342}
     343
     344void ArgumentCoder<CGSize>::encode(Encoder& encoder, CGSize size)
     345{
     346    encoder << size.width << size.height;
     347}
     348
     349std::optional<CGSize> ArgumentCoder<CGSize>::decode(Decoder& decoder)
     350{
     351    CGSize size;
     352    if (!decoder.decode(size.width))
     353        return { };
     354    if (!decoder.decode(size.height))
     355        return { };
     356    return size;
     357}
     358
     359void ArgumentCoder<CGPoint>::encode(Encoder& encoder, CGPoint point)
     360{
     361    encoder << point.x << point.y;
     362}
     363
     364std::optional<CGPoint> ArgumentCoder<CGPoint>::decode(Decoder& decoder)
     365{
     366    CGPoint point;
     367    if (!decoder.decode(point.x))
     368        return { };
     369    if (!decoder.decode(point.y))
     370        return { };
     371    return point;
     372}
     373
     374void ArgumentCoder<CGAffineTransform>::encode(Encoder& encoder, CGAffineTransform transform)
     375{
     376    encoder << transform.a << transform.b << transform.c << transform.d << transform.tx << transform.ty;
     377}
     378
     379std::optional<CGAffineTransform> ArgumentCoder<CGAffineTransform>::decode(Decoder& decoder)
     380{
     381    CGAffineTransform transform;
     382    if (!decoder.decode(transform.a))
     383        return { };
     384    if (!decoder.decode(transform.b))
     385        return { };
     386    if (!decoder.decode(transform.c))
     387        return { };
     388    if (!decoder.decode(transform.d))
     389        return { };
     390    if (!decoder.decode(transform.tx))
     391        return { };
     392    if (!decoder.decode(transform.ty))
     393        return { };
     394    return transform;
     395}
     396
    324397#if ENABLE(CONTENT_FILTERING)
    325398
Note: See TracChangeset for help on using the changeset viewer.