Changeset 206050 in webkit


Ignore:
Timestamp:
Sep 16, 2016 2:42:58 PM (8 years ago)
Author:
bshafiei@apple.com
Message:

Merge r204916. rdar://problem/27991573

Location:
branches/safari-602-branch
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-602-branch/Source/WTF/ChangeLog

    r205903 r206050  
     12016-09-16  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Merge r204916. rdar://problem/27991573
     4
     5    2016-08-23  Anders Carlsson  <andersca@apple.com>
     6
     7            Add enum traits and use them in the IPC::Decoder
     8            https://bugs.webkit.org/show_bug.cgi?id=161103
     9
     10            Reviewed by Sam Weinig.
     11
     12            Add EnumTraits.h which provides a forward declaration for WTF::EnumTraits as well as
     13            the WTF::isValidEnum function.
     14
     15            * WTF.xcodeproj/project.pbxproj:
     16            * wtf/EnumTraits.h: Added.
     17
    1182016-09-13  Babak Shafiei  <bshafiei@apple.com>
    219
  • branches/safari-602-branch/Source/WTF/WTF.xcodeproj/project.pbxproj

    r203038 r206050  
    8888                1A944F471C3D8814005BD28C /* BlockPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A944F461C3D8814005BD28C /* BlockPtr.h */; };
    8989                1ACADD841884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1ACADD821884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm */; };
     90                1AEA88E21D6BBCF400E5AD64 /* EnumTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEA88E11D6BBCF400E5AD64 /* EnumTraits.h */; };
    9091                1AFDE648195201C300C48FFA /* TypeCastsCF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFDE647195201C300C48FFA /* TypeCastsCF.h */; };
    9192                1AFDE6531953B23D00C48FFA /* Optional.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFDE6521953B23D00C48FFA /* Optional.h */; };
     
    422423                1A944F461C3D8814005BD28C /* BlockPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlockPtr.h; sourceTree = "<group>"; };
    423424                1ACADD821884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeprecatedSymbolsUsedBySafari.mm; sourceTree = "<group>"; };
     425                1AEA88E11D6BBCF400E5AD64 /* EnumTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EnumTraits.h; sourceTree = "<group>"; };
    424426                1AFDE647195201C300C48FFA /* TypeCastsCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypeCastsCF.h; sourceTree = "<group>"; };
    425427                1AFDE6521953B23D00C48FFA /* Optional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Optional.h; sourceTree = "<group>"; };
     
    868870                                A8A47297151A825A004123FF /* dtoa.cpp */,
    869871                                A8A47298151A825A004123FF /* dtoa.h */,
     872                                1AEA88E11D6BBCF400E5AD64 /* EnumTraits.h */,
    870873                                A8A4729F151A825A004123FF /* ExportMacros.h */,
    871874                                0F885E0E1845AE9F00F1E3FA /* FastBitVector.cpp */,
     
    12871290                                A8A473D3151A825B004123FF /* HashCountedSet.h in Headers */,
    12881291                                A8A4742D151A825B004123FF /* Hasher.h in Headers */,
     1292                                1AEA88E21D6BBCF400E5AD64 /* EnumTraits.h in Headers */,
    12891293                                1C181C901D307AB800F5FA16 /* UTextProvider.h in Headers */,
    12901294                                A8A473D4151A825B004123FF /* HashFunctions.h in Headers */,
  • branches/safari-602-branch/Source/WebKit2/ChangeLog

    r206013 r206050  
     12016-09-16  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Merge r204916. rdar://problem/27991573
     4
     5    2016-08-23  Anders Carlsson  <andersca@apple.com>
     6
     7            Add enum traits and use them in the IPC::Decoder
     8            https://bugs.webkit.org/show_bug.cgi?id=161103
     9
     10            Reviewed by Sam Weinig.
     11
     12            * Platform/IPC/Decoder.h:
     13            * Platform/IPC/Encoder.h:
     14            Add new encode/decode functions.
     15
     16            * Shared/mac/ArgumentCodersMac.mm:
     17            Change NSType to be a strongly typed enum. Use encode/decode
     18            instead of encodeEnum/decodeEnum since the latter don't have the
     19            enum check.
     20
    1212016-09-16  Babak Shafiei  <bshafiei@apple.com>
    222
  • branches/safari-602-branch/Source/WebKit2/Platform/IPC/ArgumentDecoder.h

    r176762 r206050  
    2929#include "ArgumentCoder.h"
    3030#include "Attachment.h"
     31#include <wtf/EnumTraits.h>
    3132#include <wtf/Vector.h>
    3233
     
    6162    bool decode(double&);
    6263
     64    template<typename E>
     65    auto decode(E& e) -> std::enable_if_t<std::is_enum<E>::value, bool>
     66    {
     67        uint64_t value;
     68        if (!decode(value))
     69            return false;
     70        if (!isValidEnum<E>(value))
     71            return false;
     72
     73        return true;
     74    }
     75
    6376    template<typename T> bool decodeEnum(T& result)
    6477    {
     
    8497    }
    8598
    86     // Generic type decode function.
    87     template<typename T> bool decode(T& t)
     99    template<typename T>
     100    auto decode(T& t) -> std::enable_if_t<!std::is_enum<T>::value, bool>
    88101    {
    89102        return ArgumentCoder<T>::decode(*this, t);
  • branches/safari-602-branch/Source/WebKit2/Platform/IPC/ArgumentEncoder.h

    r183189 r206050  
    2929#include "ArgumentCoder.h"
    3030#include "Attachment.h"
     31#include <wtf/EnumTraits.h>
    3132#include <wtf/Vector.h>
    3233
    3334namespace IPC {
    3435
    35 class ArgumentEncoder;
    3636class DataReference;
    3737
     
    5252    }
    5353
    54     template<typename T> void encode(T&& t)
     54    template<typename T>
     55    auto encode(T&& t) -> std::enable_if_t<!std::is_enum<typename std::remove_const_t<std::remove_reference_t<T>>>::value>
    5556    {
    5657        ArgumentCoder<typename std::remove_const<typename std::remove_reference<T>::type>::type>::encode(*this, std::forward<T>(t));
     
    8182    void encode(double);
    8283
     84    template<typename E>
     85    auto encode(E value) -> std::enable_if_t<std::is_enum<E>::value>
     86    {
     87        static_assert(sizeof(E) <= sizeof(uint64_t), "Enum type must not be larger than 64 bits.");
     88
     89        ASSERT(isValidEnum<E>(static_cast<uint64_t>(value)));
     90        encode(static_cast<uint64_t>(value));
     91    }
     92
    8393    uint8_t* grow(unsigned alignment, size_t size);
    8494
  • branches/safari-602-branch/Source/WebKit2/Shared/mac/ArgumentCodersMac.mm

    r202889 r206050  
    4242namespace IPC {
    4343
    44 enum NSType {
    45     NSAttributedStringType,
    46 #if USE(APPKIT)
    47     NSColorType,
    48 #endif
    49     NSDictionaryType,
    50     NSArrayType,
    51 #if USE(APPKIT)
    52     NSFontType,
    53 #endif
    54     NSNumberType,
    55     NSStringType,
    56     NSDateType,
    57     NSDataType,
    58     NSURLType,
     44enum class NSType {
     45    AttributedString,
     46#if USE(APPKIT)
     47    Color,
     48#endif
     49    Dictionary,
     50    Array,
     51#if USE(APPKIT)
     52    Font,
     53#endif
     54    Number,
     55    String,
     56    Date,
     57    Data,
     58    URL,
    5959    Unknown,
    6060};
    6161
     62}
     63
     64namespace IPC {
    6265static NSType typeFromObject(id object)
    6366{
     
    6568
    6669    if ([object isKindOfClass:[NSAttributedString class]])
    67         return NSAttributedStringType;
     70        return NSType::AttributedString;
    6871#if USE(APPKIT)
    6972    if ([object isKindOfClass:[NSColor class]])
    70         return NSColorType;
     73        return NSType::Color;
    7174#endif
    7275    if ([object isKindOfClass:[NSDictionary class]])
    73         return NSDictionaryType;
     76        return NSType::Dictionary;
    7477#if USE(APPKIT)
    7578    if ([object isKindOfClass:[NSFont class]])
    76         return NSFontType;
     79        return NSType::Font;
    7780#endif
    7881    if ([object isKindOfClass:[NSNumber class]])
    79         return NSNumberType;
     82        return NSType::Number;
    8083    if ([object isKindOfClass:[NSString class]])
    81         return NSStringType;
     84        return NSType::String;
    8285    if ([object isKindOfClass:[NSArray class]])
    83         return NSArrayType;
     86        return NSType::Array;
    8487    if ([object isKindOfClass:[NSDate class]])
    85         return NSDateType;
     88        return NSType::Date;
    8689    if ([object isKindOfClass:[NSData class]])
    87         return NSDataType;
     90        return NSType::Data;
    8891    if ([object isKindOfClass:[NSURL class]])
    89         return NSURLType;
     92        return NSType::URL;
    9093
    9194    ASSERT_NOT_REACHED();
    92     return Unknown;
     95    return NSType::Unknown;
    9396}
    9497
     
    9699{
    97100    NSType type = typeFromObject(object);
    98     encoder.encodeEnum(type);
     101    encoder << type;
    99102
    100103    switch (type) {
    101     case NSAttributedStringType:
     104    case NSType::AttributedString:
    102105        encode(encoder, static_cast<NSAttributedString *>(object));
    103106        return;
    104107#if USE(APPKIT)
    105     case NSColorType:
     108    case NSType::Color:
    106109        encode(encoder, static_cast<NSColor *>(object));
    107110        return;
    108111#endif
    109     case NSDictionaryType:
     112    case NSType::Dictionary:
    110113        encode(encoder, static_cast<NSDictionary *>(object));
    111114        return;
    112115#if USE(APPKIT)
    113     case NSFontType:
     116    case NSType::Font:
    114117        encode(encoder, static_cast<NSFont *>(object));
    115118        return;
    116119#endif
    117     case NSNumberType:
     120    case NSType::Number:
    118121        encode(encoder, static_cast<NSNumber *>(object));
    119122        return;
    120     case NSStringType:
     123    case NSType::String:
    121124        encode(encoder, static_cast<NSString *>(object));
    122125        return;
    123     case NSArrayType:
     126    case NSType::Array:
    124127        encode(encoder, static_cast<NSArray *>(object));
    125128        return;
    126     case NSDateType:
     129    case NSType::Date:
    127130        encode(encoder, static_cast<NSDate *>(object));
    128131        return;
    129     case NSDataType:
     132    case NSType::Data:
    130133        encode(encoder, static_cast<NSData *>(object));
    131134        return;
    132     case NSURLType:
     135    case NSType::URL:
    133136        encode(encoder, static_cast<NSURL *>(object));
    134137        return;
    135     case Unknown:
     138    case NSType::Unknown:
    136139        break;
    137140    }
     
    147150
    148151    switch (type) {
    149     case NSAttributedStringType: {
     152    case NSType::AttributedString: {
    150153        RetainPtr<NSAttributedString> string;
    151154        if (!decode(decoder, string))
     
    155158    }
    156159#if USE(APPKIT)
    157     case NSColorType: {
     160    case NSType::Color: {
    158161        RetainPtr<NSColor> color;
    159162        if (!decode(decoder, color))
     
    163166    }
    164167#endif
    165     case NSDictionaryType: {
     168    case NSType::Dictionary: {
    166169        RetainPtr<NSDictionary> dictionary;
    167170        if (!decode(decoder, dictionary))
     
    171174    }
    172175#if USE(APPKIT)
    173     case NSFontType: {
     176    case NSType::Font: {
    174177        RetainPtr<NSFont> font;
    175178        if (!decode(decoder, font))
     
    179182    }
    180183#endif
    181     case NSNumberType: {
     184    case NSType::Number: {
    182185        RetainPtr<NSNumber> number;
    183186        if (!decode(decoder, number))
     
    186189        return true;
    187190    }
    188     case NSStringType: {
     191    case NSType::String: {
    189192        RetainPtr<NSString> string;
    190193        if (!decode(decoder, string))
     
    193196        return true;
    194197    }
    195     case NSArrayType: {
     198    case NSType::Array: {
    196199        RetainPtr<NSArray> array;
    197200        if (!decode(decoder, array))
     
    200203        return true;
    201204    }
    202     case NSDateType: {
     205    case NSType::Date: {
    203206        RetainPtr<NSDate> date;
    204207        if (!decode(decoder, date))
     
    207210        return true;
    208211    }
    209     case NSDataType: {
     212    case NSType::Data: {
    210213        RetainPtr<NSData> data;
    211214        if (!decode(decoder, data))
     
    214217        return true;
    215218    }
    216     case NSURLType: {
     219    case NSType::URL: {
    217220        RetainPtr<NSURL> URL;
    218221        if (!decode(decoder, URL))
     
    221224        return true;
    222225    }
    223     case Unknown:
     226    case NSType::Unknown:
    224227        ASSERT_NOT_REACHED();
    225228        return false;
     
    370373
    371374        // Ignore values we don't recognize.
    372         if (typeFromObject(value) == Unknown)
     375        if (typeFromObject(value) == NSType::Unknown)
    373376            continue;
    374377
     
    461464
    462465        // Ignore values we don't recognize.
    463         if (typeFromObject(value) == Unknown)
     466        if (typeFromObject(value) == NSType::Unknown)
    464467            continue;
    465468
     
    535538
    536539} // namespace IPC
     540
     541namespace WTF {
     542template<> struct EnumTraits<IPC::NSType> {
     543    using values = EnumValues<
     544        IPC::NSType,
     545        IPC::NSType::AttributedString,
     546    #if USE(APPKIT)
     547        IPC::NSType::Color,
     548    #endif
     549        IPC::NSType::Dictionary,
     550        IPC::NSType::Array,
     551    #if USE(APPKIT)
     552        IPC::NSType::Font,
     553    #endif
     554        IPC::NSType::Number,
     555        IPC::NSType::String,
     556        IPC::NSType::Date,
     557        IPC::NSType::Data,
     558        IPC::NSType::URL,
     559        IPC::NSType::Unknown
     560    >;
     561};
     562}
  • branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r205952 r206050  
    23462346    // FIXME: A client can terminate the page at any time, so we should do something more meaningful than assert and fall apart in release builds.
    23472347    // See also <https://bugs.webkit.org/show_bug.cgi?id=136012>.
    2348     ASSERT(m_process->state() != WebProcessProxy::State::Launching);
     2348//    ASSERT(m_process->state() != WebProcessProxy::State::Launching);
    23492349
    23502350    // NOTE: This uses a check of m_isValid rather than calling isValid() since
  • branches/safari-602-branch/Tools/ChangeLog

    r205952 r206050  
     12016-09-16  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Merge r204916. rdar://problem/27991573
     4
     5    2016-08-23  Anders Carlsson  <andersca@apple.com>
     6
     7            Add enum traits and use them in the IPC::Decoder
     8            https://bugs.webkit.org/show_bug.cgi?id=161103
     9
     10            Reviewed by Sam Weinig.
     11
     12            Add API test.
     13
     14            * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     15            * TestWebKitAPI/Tests/WTF/EnumTraits.cpp: Added.
     16            (TestWebKitAPI::TEST):
     17
    1182016-09-14  Babak Shafiei  <bshafiei@apple.com>
    219
  • branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r205952 r206050  
    3535                1ADBEFE3130C6AA100D61D19 /* simple-accelerated-compositing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1ADBEFBC130C6A0100D61D19 /* simple-accelerated-compositing.html */; };
    3636                1AEDE22613E5E7E700E62FE8 /* InjectedBundleControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AEDE22413E5E7A000E62FE8 /* InjectedBundleControllerMac.mm */; };
     37                1AF7B21F1D6CD14D008C126C /* EnumTraits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AF7B21D1D6CD12E008C126C /* EnumTraits.cpp */; };
    3738                1C2B81801C891E7C00A5529F /* CancelFontSubresource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C2B817E1C891E4200A5529F /* CancelFontSubresource.mm */; };
    3839                1C2B81831C891F0900A5529F /* CancelFontSubresourcePlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C2B81811C891EFA00A5529F /* CancelFontSubresourcePlugIn.mm */; };
     
    690691                1AEDE22413E5E7A000E62FE8 /* InjectedBundleControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InjectedBundleControllerMac.mm; sourceTree = "<group>"; };
    691692                1AEF994817A09F5300998EF0 /* GetPIDAfterAbortedProcessLaunch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetPIDAfterAbortedProcessLaunch.cpp; sourceTree = "<group>"; };
     693                1AF7B21D1D6CD12E008C126C /* EnumTraits.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EnumTraits.cpp; sourceTree = "<group>"; };
    692694                1AFDE6541953B2C000C48FFA /* Optional.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Optional.cpp; sourceTree = "<group>"; };
    693695                1C2B817E1C891E4200A5529F /* CancelFontSubresource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CancelFontSubresource.mm; sourceTree = "<group>"; };
     
    16441646                                7AA021BA1AB09EA70052953F /* DateMath.cpp */,
    16451647                                E4A757D3178AEA5B00B5D7A4 /* Deque.cpp */,
     1648                                1AF7B21D1D6CD12E008C126C /* EnumTraits.cpp */,
    16461649                                7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */,
    16471650                                0BCD833414857CE400EA2003 /* HashMap.cpp */,
     
    21342137                                7C83DEE81D0A590C00FEBCF3 /* ListHashSet.cpp in Sources */,
    21352138                                7C83DEED1D0A590C00FEBCF3 /* MathExtras.cpp in Sources */,
     2139                                1AF7B21F1D6CD14D008C126C /* EnumTraits.cpp in Sources */,
    21362140                                7C83DEEF1D0A590C00FEBCF3 /* MD5.cpp in Sources */,
    21372141                                7C83DEF11D0A590C00FEBCF3 /* MediaTime.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.