Changeset 190836 in webkit


Ignore:
Timestamp:
Oct 9, 2015 8:52:41 PM (8 years ago)
Author:
mmaxfield@apple.com
Message:

Unreviewed, rolling out r190689
https://bugs.webkit.org/show_bug.cgi?id=149992

Fixed in other repository.

Reverted changesets:

"Unreviewed, rolling out r190572, r190593, r190594, and r190639."
https://bugs.webkit.org/show_bug.cgi?id=149897

Location:
trunk
Files:
9 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r190833 r190836  
     12015-10-09  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Unreviewed, rolling out r190689
     4        https://bugs.webkit.org/show_bug.cgi?id=149992
     5
     6        Fixed in other repository.
     7
     8        Reverted changesets:
     9
     10        "Unreviewed, rolling out r190572, r190593, r190594, and r190639."
     11        https://bugs.webkit.org/show_bug.cgi?id=149897
     12
    1132015-10-09  Nan Wang  <n_wang@apple.com>
    214
  • trunk/LayoutTests/TestExpectations

    r190689 r190836  
    677677
    678678http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-overrides.html [ Failure Pass ]
    679 
    680 webkit.org/b/149218 http/tests/notifications/events.html [ Pass Crash Timeout ]
  • trunk/Source/WebKit2/ChangeLog

    r190832 r190836  
     12015-10-09  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Unreviewed, rolling out r190689
     4        https://bugs.webkit.org/show_bug.cgi?id=149992
     5
     6        Fixed in other repository.
     7
     8        Reverted changesets:
     9
     10        "Unreviewed, rolling out r190572, r190593, r190594, and r190639."
     11        https://bugs.webkit.org/show_bug.cgi?id=149897
     12
    1132015-10-09  Beth Dakin  <bdakin@apple.com>
    214
  • trunk/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h

    r190689 r190836  
    2929#include <WebKit/WKType.h>
    3030#include <algorithm>
     31#include <wtf/GetPtr.h>
     32#include <wtf/HashFunctions.h>
     33#include <wtf/HashTraits.h>
     34#include <wtf/RefPtr.h>
    3135
    3236namespace WebKit {
     
    8488            WKRelease(ptr);
    8589    }
     90
     91    // Hash table deleted values, which are only constructed and never copied or destroyed.
     92    WKRetainPtr(WTF::HashTableDeletedValueType)
     93        : m_ptr(hashTableDeletedValue())
     94    {
     95    }
     96
     97    bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedValue(); }
     98    constexpr static T hashTableDeletedValue() { return reinterpret_cast<T>(-1); }
    8699
    87100    PtrType get() const { return m_ptr; }
     
    251264using WebKit::adoptWK;
    252265
     266namespace WTF {
     267
     268template <typename T> struct IsSmartPtr<WKRetainPtr<T>> {
     269    static const bool value = true;
     270};
     271
     272template<typename P> struct DefaultHash<WKRetainPtr<P>> {
     273    typedef PtrHash<WKRetainPtr<P>> Hash;
     274};
     275
     276template<typename P> struct HashTraits<WKRetainPtr<P>> : SimpleClassHashTraits<WKRetainPtr<P>> {
     277    static P emptyValue() { return nullptr; }
     278
     279    typedef P PeekType;
     280    static PeekType peek(const WKRetainPtr<P>& value) { return value.get(); }
     281    static PeekType peek(P value) { return value; }
     282};
     283
     284} // namespace WTF
     285
    253286#endif // WKRetainPtr_h
  • trunk/Tools/ChangeLog

    r190821 r190836  
     12015-10-09  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Unreviewed, rolling out r190689
     4        https://bugs.webkit.org/show_bug.cgi?id=149992
     5
     6        Fixed in other repository.
     7
     8        Reverted changesets:
     9
     10        "Unreviewed, rolling out r190572, r190593, r190594, and r190639."
     11        https://bugs.webkit.org/show_bug.cgi?id=149897
     12
    1132015-10-09  Brian Burg  <bburg@apple.com>
    214
  • trunk/Tools/TestWebKitAPI/PlatformGTK.cmake

    r190689 r190836  
    111111    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WKPageGetScaleFactorNotZero.cpp
    112112    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WKPreferences.cpp
     113    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WKRetainPtr.cpp
    113114    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WKString.cpp
    114115    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WKStringJSString.cpp
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r190689 r190836  
    2323                1AEDE22613E5E7E700E62FE8 /* InjectedBundleControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AEDE22413E5E7A000E62FE8 /* InjectedBundleControllerMac.mm */; };
    2424                1CB9BC381A67482300FE5678 /* WeakPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CB9BC371A67482300FE5678 /* WeakPtr.cpp */; };
     25                1CF0D3791BBF2F3D00B4EF54 /* WKRetainPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CF0D3781BBF2F3D00B4EF54 /* WKRetainPtr.cpp */; };
    2526                260BA5791B1D2E7B004FA07C /* DFACombiner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260BA5781B1D2E7B004FA07C /* DFACombiner.cpp */; };
    2627                26DF5A6315A2A27E003689C2 /* CancelLoadFromResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 26DF5A6115A2A22B003689C2 /* CancelLoadFromResourceLoadDelegate.html */; };
     
    471472                1AFDE6541953B2C000C48FFA /* Optional.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Optional.cpp; sourceTree = "<group>"; };
    472473                1CB9BC371A67482300FE5678 /* WeakPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WeakPtr.cpp; sourceTree = "<group>"; };
     474                1CF0D3781BBF2F3D00B4EF54 /* WKRetainPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKRetainPtr.cpp; sourceTree = "<group>"; };
    473475                260BA5781B1D2E7B004FA07C /* DFACombiner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DFACombiner.cpp; sourceTree = "<group>"; };
    474476                260BA57A1B1D2EE2004FA07C /* DFAHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFAHelpers.h; sourceTree = "<group>"; };
     
    11421144                                BC90995D12567BC100083756 /* WKString.cpp */,
    11431145                                BC9099931256ACF100083756 /* WKStringJSString.cpp */,
     1146                                1CF0D3781BBF2F3D00B4EF54 /* WKRetainPtr.cpp */,
    11441147                        );
    11451148                        path = WebKit2;
     
    17461749                                7A5623111AD5AF3E0096B920 /* MenuTypesForMouseEvents.cpp in Sources */,
    17471750                                51CB4AD81B3A079C00C1B1C6 /* ModalAlertsSPI.cpp in Sources */,
     1751                                1CF0D3791BBF2F3D00B4EF54 /* WKRetainPtr.cpp in Sources */,
    17481752                                26F6E1F01ADC749B00DE696B /* DFAMinimizer.cpp in Sources */,
    17491753                                260BA5791B1D2E7B004FA07C /* DFACombiner.cpp in Sources */,
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2/WKRetainPtr.cpp

    r190835 r190836  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef WebNotificationProvider_h
    27 #define WebNotificationProvider_h
     26#include "config.h"
    2827
    29 #include <WebKit/WKNotificationManager.h>
    30 #include <WebKit/WKNotificationProvider.h>
    31 #include <WebKit/WKRetainPtr.h>
    32 #include <wtf/HashSet.h>
     28#if WK_HAVE_C_SPI
    3329
    34 namespace WTR {
     30#include "PlatformUtilities.h"
     31#include <wtf/HashMap.h>
    3532
    36 class WebNotificationProvider {
    37 public:
    38     WebNotificationProvider();
    39     ~WebNotificationProvider();
    40     WKNotificationProviderV0 provider();
     33namespace TestWebKitAPI {
    4134
    42     void showWebNotification(WKPageRef, WKNotificationRef);
    43     void closeWebNotification(WKNotificationRef);
    44     void addNotificationManager(WKNotificationManagerRef);
    45     void removeNotificationManager(WKNotificationManagerRef);
    46     WKDictionaryRef notificationPermissions();
     35TEST(WebKit2, WKRetainPtr)
     36{
     37    WKRetainPtr<WKStringRef> string1 = adoptWK(WKStringCreateWithUTF8CString("a"));
     38    WKRetainPtr<WKStringRef> string2 = adoptWK(WKStringCreateWithUTF8CString("a"));
     39    WKRetainPtr<WKStringRef> string3 = adoptWK(WKStringCreateWithUTF8CString("a"));
     40    WKRetainPtr<WKStringRef> string4 = adoptWK(WKStringCreateWithUTF8CString("a"));
    4741
    48     void simulateWebNotificationClick(uint64_t notificationID);
    49     void reset();
     42    HashMap<WKRetainPtr<WKStringRef>, int> map;
    5043
    51 private:
    52     WKRetainPtr<WKNotificationManagerRef> m_currentNotificationManager;
    53     HashSet<uint64_t> m_shownNotifications;
    54 };
     44    map.set(string2, 2);
     45    map.set(string1, 1);
    5546
     47    EXPECT_TRUE(map.contains(string1));
     48    EXPECT_TRUE(map.contains(string2));
     49    EXPECT_FALSE(map.contains(string3));
     50    EXPECT_FALSE(map.contains(string4));
     51
     52    EXPECT_EQ(1, map.get(string1));
     53    EXPECT_EQ(2, map.get(string2));
    5654}
    5755
     56} // namespace TestWebKitAPI
     57
    5858#endif
  • trunk/Tools/WebKitTestRunner/WebNotificationProvider.cpp

    r190689 r190836  
    6666WebNotificationProvider::~WebNotificationProvider()
    6767{
    68     if (m_currentNotificationManager)
    69         WKNotificationManagerSetProvider(m_currentNotificationManager.get(), nullptr);
     68    for (auto& manager : m_ownedNotifications)
     69        WKNotificationManagerSetProvider(manager.key.get(), nullptr);
    7070}
    7171
     
    8585}
    8686
    87 void WebNotificationProvider::showWebNotification(WKPageRef, WKNotificationRef notification)
     87void WebNotificationProvider::showWebNotification(WKPageRef page, WKNotificationRef notification)
    8888{
    89     if (!m_currentNotificationManager)
    90         return;
     89    auto context = WKPageGetContext(page);
     90    auto notificationManager = WKContextGetNotificationManager(context);
     91    uint64_t id = WKNotificationGetID(notification);
    9192
    92     uint64_t id = WKNotificationGetID(notification);
    93     ASSERT(!m_shownNotifications.contains(id));
    94     m_shownNotifications.add(id);
     93    ASSERT(m_ownedNotifications.contains(notificationManager));
     94    auto addResult = m_ownedNotifications.find(notificationManager)->value.add(id);
     95    ASSERT_UNUSED(addResult, addResult.isNewEntry);
     96    auto addResult2 = m_owningManager.set(id, notificationManager);
     97    ASSERT_UNUSED(addResult2, addResult2.isNewEntry);
    9598
    96     WKNotificationManagerProviderDidShowNotification(m_currentNotificationManager.get(), WKNotificationGetID(notification));
     99    WKNotificationManagerProviderDidShowNotification(notificationManager, id);
    97100}
    98101
    99102void WebNotificationProvider::closeWebNotification(WKNotificationRef notification)
    100103{
    101     if (!m_currentNotificationManager)
    102         return;
     104    uint64_t id = WKNotificationGetID(notification);
     105    ASSERT(m_owningManager.contains(id));
     106    auto notificationManager = m_owningManager.get(id);
    103107
    104     uint64_t id = WKNotificationGetID(notification);
     108    ASSERT(m_ownedNotifications.contains(notificationManager));
     109    bool success = m_ownedNotifications.find(notificationManager)->value.remove(id);
     110    ASSERT_UNUSED(success, success);
     111    m_owningManager.remove(id);
     112
    105113    WKRetainPtr<WKUInt64Ref> wkID = WKUInt64Create(id);
    106114    WKRetainPtr<WKMutableArrayRef> array(AdoptWK, WKMutableArrayCreate());
    107115    WKArrayAppendItem(array.get(), wkID.get());
    108     m_shownNotifications.remove(id);
    109     WKNotificationManagerProviderDidCloseNotifications(m_currentNotificationManager.get(), array.get());
     116    WKNotificationManagerProviderDidCloseNotifications(notificationManager, array.get());
    110117}
    111118
    112119void WebNotificationProvider::addNotificationManager(WKNotificationManagerRef manager)
    113120{
    114     m_currentNotificationManager = manager;
     121    m_ownedNotifications.add(manager, HashSet<uint64_t>());
    115122}
    116123
    117124void WebNotificationProvider::removeNotificationManager(WKNotificationManagerRef manager)
    118125{
     126    auto iterator = m_ownedNotifications.find(manager);
     127    ASSERT(iterator != m_ownedNotifications.end());
     128    auto toRemove = iterator->value;
     129    WKRetainPtr<WKNotificationManagerRef> guard(manager);
     130    m_ownedNotifications.remove(iterator);
     131    WKRetainPtr<WKMutableArrayRef> array = adoptWK(WKMutableArrayCreate());
     132    for (uint64_t notificationID : toRemove) {
     133        bool success = m_owningManager.remove(notificationID);
     134        ASSERT_UNUSED(success, success);
     135        WKArrayAppendItem(array.get(), adoptWK(WKUInt64Create(notificationID)).get());
     136    }
     137    WKNotificationManagerProviderDidCloseNotifications(manager, array.get());
    119138}
    120139
     
    127146void WebNotificationProvider::simulateWebNotificationClick(uint64_t notificationID)
    128147{
    129     if (!m_currentNotificationManager)
    130         return;
    131 
    132     ASSERT(m_shownNotifications.contains(notificationID));
    133     WKNotificationManagerProviderDidClickNotification(m_currentNotificationManager.get(), notificationID);
     148    ASSERT(m_owningManager.contains(notificationID));
     149    WKNotificationManagerProviderDidClickNotification(m_owningManager.get(notificationID), notificationID);
    134150}
    135151
    136152void WebNotificationProvider::reset()
    137153{
    138     if (!m_currentNotificationManager) {
    139         m_shownNotifications.clear();
    140         return;
     154    for (auto& notificationPair : m_ownedNotifications) {
     155        if (notificationPair.value.isEmpty())
     156            continue;
     157        WKRetainPtr<WKMutableArrayRef> array = adoptWK(WKMutableArrayCreate());
     158        for (uint64_t notificationID : notificationPair.value)
     159            WKArrayAppendItem(array.get(), adoptWK(WKUInt64Create(notificationID)).get());
     160
     161        notificationPair.value.clear();
     162        WKNotificationManagerProviderDidCloseNotifications(notificationPair.key.get(), array.get());
    141163    }
    142 
    143     WKRetainPtr<WKMutableArrayRef> array(AdoptWK, WKMutableArrayCreate());
    144     HashSet<uint64_t>::const_iterator itEnd = m_shownNotifications.end();
    145     for (HashSet<uint64_t>::const_iterator it = m_shownNotifications.begin(); it != itEnd; ++it) {
    146         WKRetainPtr<WKUInt64Ref> wkID = WKUInt64Create(*it);
    147         WKArrayAppendItem(array.get(), wkID.get());
    148     }
    149 
    150     m_shownNotifications.clear();
    151     WKNotificationManagerProviderDidCloseNotifications(m_currentNotificationManager.get(), array.get());
     164    m_owningManager.clear();
    152165}
    153166
  • trunk/Tools/WebKitTestRunner/WebNotificationProvider.h

    r190689 r190836  
    3030#include <WebKit/WKNotificationProvider.h>
    3131#include <WebKit/WKRetainPtr.h>
     32#include <wtf/HashMap.h>
    3233#include <wtf/HashSet.h>
    3334
     
    5051
    5152private:
    52     WKRetainPtr<WKNotificationManagerRef> m_currentNotificationManager;
    53     HashSet<uint64_t> m_shownNotifications;
     53    // Inverses of each other.
     54    HashMap<WKRetainPtr<WKNotificationManagerRef>, HashSet<uint64_t>> m_ownedNotifications;
     55    HashMap<uint64_t, WKNotificationManagerRef> m_owningManager;
    5456};
    5557
Note: See TracChangeset for help on using the changeset viewer.