Changeset 234873 in webkit


Ignore:
Timestamp:
Aug 14, 2018 5:30:50 PM (6 years ago)
Author:
achristensen@apple.com
Message:

isValidCSSSelector is unsafe to be called from a non-main thread
https://bugs.webkit.org/show_bug.cgi?id=188581
<rdar://problem/40517358>

Reviewed by Sam Weinig.

Source/WebCore:

Parsing and determining whether the css selectors are valid is fast enough to do before
hopping to the background thread for the slow NFA/DFA operations and writing to disk.
Doing it on the main thread avoids the thread safety issues in the CSSParser's use of strings.

  • contentextensions/ContentExtensionCompiler.cpp:

(WebCore::ContentExtensions::compileRuleList):

  • contentextensions/ContentExtensionCompiler.h:
  • contentextensions/ContentExtensionParser.cpp:

(WebCore::ContentExtensions::isValidCSSSelector):
(WebCore::ContentExtensions::loadEncodedRules):
(WebCore::ContentExtensions::parseRuleList):

  • contentextensions/ContentExtensionParser.h:
  • contentextensions/ContentExtensionRule.cpp:

(WebCore::ContentExtensions::Trigger::isolatedCopy const):
(WebCore::ContentExtensions::Action::isolatedCopy const):

  • contentextensions/ContentExtensionRule.h:

(WebCore::ContentExtensions::Trigger::isEmpty const):
(WebCore::ContentExtensions::Trigger::operator== const):
(WebCore::ContentExtensions::Action::Action):
(WebCore::ContentExtensions::ContentExtensionRule::isolatedCopy const):
(WebCore::ContentExtensions::ContentExtensionRule::operator== const):
(WebCore::ContentExtensions::vectorIsolatedCopy):

Source/WebKit:

  • UIProcess/API/APIContentRuleListStore.cpp:

(API::compiledToFile):
(API::ContentRuleListStore::lookupContentRuleList):
(API::ContentRuleListStore::getAvailableContentRuleListIdentifiers):
(API::ContentRuleListStore::compileContentRuleList):
(API::ContentRuleListStore::removeContentRuleList):
(API::ContentRuleListStore::getContentRuleListSource):

  • UIProcess/API/APIContentRuleListStore.h:
  • UIProcess/API/Cocoa/WKContentRuleListStore.mm:

Source/WTF:

  • wtf/Vector.h:

(WTF::minCapacity>::isolatedCopy):

Tools:

  • TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:

(TestWebKitAPI::InMemoryCompiledContentExtension::create):
(TestWebKitAPI::checkCompilerError):

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r234859 r234873  
     12018-08-14  Alex Christensen  <achristensen@webkit.org>
     2
     3        isValidCSSSelector is unsafe to be called from a non-main thread
     4        https://bugs.webkit.org/show_bug.cgi?id=188581
     5        <rdar://problem/40517358>
     6
     7        Reviewed by Sam Weinig.
     8
     9        * wtf/Vector.h:
     10        (WTF::minCapacity>::isolatedCopy):
     11
    1122018-08-14  Alex Christensen  <achristensen@webkit.org>
    213
  • trunk/Source/WTF/wtf/Vector.h

    r233157 r234873  
    767767    void clear() { shrinkCapacity(0); }
    768768
     769    template<typename U = T> Vector<U> isolatedCopy() const;
     770
    769771    ALWAYS_INLINE void append(ValueType&& value) { append<ValueType>(std::forward<ValueType>(value)); }
    770772    template<typename U> void append(U&&);
     
    16051607#endif
    16061608
     1609template<typename T, size_t inlineCapacity, typename OverflowHandler, size_t minCapacity>
     1610template<typename U>
     1611inline Vector<U> Vector<T, inlineCapacity, OverflowHandler, minCapacity>::isolatedCopy() const
     1612{
     1613    Vector<U> copy;
     1614    copy.reserveInitialCapacity(size());
     1615    for (const auto& element : *this)
     1616        copy.uncheckedAppend(element.isolatedCopy());
     1617    return copy;
     1618}
     1619   
    16071620template<typename VectorType, typename Func>
    16081621size_t removeRepeatedElements(VectorType& vector, const Func& func)
  • trunk/Source/WebCore/ChangeLog

    r234870 r234873  
     12018-08-14  Alex Christensen  <achristensen@webkit.org>
     2
     3        isValidCSSSelector is unsafe to be called from a non-main thread
     4        https://bugs.webkit.org/show_bug.cgi?id=188581
     5        <rdar://problem/40517358>
     6
     7        Reviewed by Sam Weinig.
     8
     9        Parsing and determining whether the css selectors are valid is fast enough to do before
     10        hopping to the background thread for the slow NFA/DFA operations and writing to disk.
     11        Doing it on the main thread avoids the thread safety issues in the CSSParser's use of strings.
     12
     13        * contentextensions/ContentExtensionCompiler.cpp:
     14        (WebCore::ContentExtensions::compileRuleList):
     15        * contentextensions/ContentExtensionCompiler.h:
     16        * contentextensions/ContentExtensionParser.cpp:
     17        (WebCore::ContentExtensions::isValidCSSSelector):
     18        (WebCore::ContentExtensions::loadEncodedRules):
     19        (WebCore::ContentExtensions::parseRuleList):
     20        * contentextensions/ContentExtensionParser.h:
     21        * contentextensions/ContentExtensionRule.cpp:
     22        (WebCore::ContentExtensions::Trigger::isolatedCopy const):
     23        (WebCore::ContentExtensions::Action::isolatedCopy const):
     24        * contentextensions/ContentExtensionRule.h:
     25        (WebCore::ContentExtensions::Trigger::isEmpty const):
     26        (WebCore::ContentExtensions::Trigger::operator== const):
     27        (WebCore::ContentExtensions::Action::Action):
     28        (WebCore::ContentExtensions::ContentExtensionRule::isolatedCopy const):
     29        (WebCore::ContentExtensions::ContentExtensionRule::operator== const):
     30        (WebCore::ContentExtensions::vectorIsolatedCopy):
     31
    1322018-08-14  Ansh Shukla  <ansh_shukla@apple.com>
    233
  • trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.cpp

    r229209 r234873  
    284284}
    285285
    286 std::error_code compileRuleList(ContentExtensionCompilationClient& client, String&& ruleJSON)
    287 {
    288     auto ruleList = parseRuleList(WTFMove(ruleJSON));
    289     if (!ruleList.has_value())
    290         return ruleList.error();
    291     Vector<ContentExtensionRule> parsedRuleList = WTFMove(ruleList.value());
     286std::error_code compileRuleList(ContentExtensionCompilationClient& client, String&& ruleJSON, Vector<ContentExtensionRule>&& parsedRuleList)
     287{
     288#if !ASSERT_DISABLED
     289    callOnMainThread([ruleJSON = ruleJSON.isolatedCopy(), parsedRuleList = parsedRuleList.isolatedCopy()] {
     290        ASSERT(parseRuleList(ruleJSON) == parsedRuleList);
     291    });
     292#endif
    292293
    293294    bool domainConditionSeen = false;
     
    314315#endif
    315316   
    316     client.writeSource(ruleJSON);
     317    client.writeSource(std::exchange(ruleJSON, String()));
    317318
    318319    Vector<SerializedActionByte> actions;
  • trunk/Source/WebCore/contentextensions/ContentExtensionCompiler.h

    r223728 r234873  
    4141   
    4242    // Functions should be called in this order. All except writeActions and finalize can be called multiple times, though.
    43     virtual void writeSource(const String&) = 0;
     43    virtual void writeSource(String&&) = 0;
    4444    virtual void writeActions(Vector<SerializedActionByte>&&, bool conditionsApplyOnlyToDomain) = 0;
    4545    virtual void writeFiltersWithoutConditionsBytecode(Vector<DFABytecode>&&) = 0;
     
    4949};
    5050
    51 WEBCORE_EXPORT std::error_code compileRuleList(ContentExtensionCompilationClient&, String&&);
     51WEBCORE_EXPORT std::error_code compileRuleList(ContentExtensionCompilationClient&, String&& ruleJSON, Vector<ContentExtensionRule>&&);
    5252
    5353} // namespace ContentExtensions
  • trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp

    r233520 r234873  
    231231bool isValidCSSSelector(const String& selector)
    232232{
     233    ASSERT(isMainThread());
    233234    AtomicString::init();
    234235    QualifiedName::init();
     
    300301}
    301302
    302 static Expected<Vector<ContentExtensionRule>, std::error_code> loadEncodedRules(ExecState& exec, String&& ruleJSON)
     303static Expected<Vector<ContentExtensionRule>, std::error_code> loadEncodedRules(ExecState& exec, const String& ruleJSON)
    303304{
    304305    VM& vm = exec.vm();
     
    348349}
    349350
    350 Expected<Vector<ContentExtensionRule>, std::error_code> parseRuleList(String&& ruleJSON)
     351Expected<Vector<ContentExtensionRule>, std::error_code> parseRuleList(const String& ruleJSON)
    351352{
    352353#if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING
     
    359360
    360361    ExecState* exec = globalObject->globalExec();
    361     auto ruleList = loadEncodedRules(*exec, WTFMove(ruleJSON));
     362    auto ruleList = loadEncodedRules(*exec, ruleJSON);
    362363
    363364    vm = nullptr;
  • trunk/Source/WebCore/contentextensions/ContentExtensionParser.h

    r214358 r234873  
    3939class ContentExtensionRule;
    4040
    41 Expected<Vector<ContentExtensionRule>, std::error_code> parseRuleList(String&&);
     41WEBCORE_EXPORT Expected<Vector<ContentExtensionRule>, std::error_code> parseRuleList(const String&);
    4242WEBCORE_EXPORT bool isValidCSSSelector(const String&);
    4343
  • trunk/Source/WebCore/contentextensions/ContentExtensionRule.cpp

    r222602 r234873  
    114114}
    115115
     116Trigger Trigger::isolatedCopy() const
     117{
     118    return {
     119        urlFilter.isolatedCopy(),
     120        urlFilterIsCaseSensitive,
     121        topURLConditionIsCaseSensitive,
     122        flags,
     123        conditions.isolatedCopy(),
     124        conditionType
     125    };
     126}
     127
     128Action Action::isolatedCopy() const
     129{
     130    return {
     131        m_extensionIdentifier.isolatedCopy(),
     132        m_type,
     133        m_actionID,
     134        m_stringArgument.isolatedCopy()
     135    };
     136}
     137
    116138} // namespace ContentExtensions
    117139
  • trunk/Source/WebCore/contentextensions/ContentExtensionRule.h

    r222602 r234873  
    5656    ConditionType conditionType { ConditionType::None };
    5757
     58    WEBCORE_EXPORT Trigger isolatedCopy() const;
     59   
    5860    ~Trigger()
    5961    {
     
    6769        return urlFilter.isEmpty()
    6870            && !urlFilterIsCaseSensitive
     71            && !topURLConditionIsCaseSensitive
    6972            && !flags
    7073            && conditions.isEmpty()
     
    7679        return urlFilter == other.urlFilter
    7780            && urlFilterIsCaseSensitive == other.urlFilterIsCaseSensitive
     81            && topURLConditionIsCaseSensitive == other.topURLConditionIsCaseSensitive
    7882            && flags == other.flags
    7983            && conditions == other.conditions
     
    164168    const String& stringArgument() const { return m_stringArgument; }
    165169
     170    WEBCORE_EXPORT Action isolatedCopy() const;
     171   
    166172private:
     173    Action(String&& extensionIdentifier, ActionType type, uint32_t actionID, String&& stringArgument)
     174        : m_extensionIdentifier(WTFMove(extensionIdentifier))
     175        , m_type(type)
     176        , m_actionID(actionID)
     177        , m_stringArgument(WTFMove(stringArgument))
     178    { }
     179
    167180    String m_extensionIdentifier;
    168181    ActionType m_type;
     
    173186class ContentExtensionRule {
    174187public:
    175     ContentExtensionRule(Trigger&&, Action&&);
     188    WEBCORE_EXPORT ContentExtensionRule(Trigger&&, Action&&);
    176189
    177190    const Trigger& trigger() const { return m_trigger; }
    178191    const Action& action() const { return m_action; }
     192
     193    ContentExtensionRule isolatedCopy() const
     194    {
     195        return { m_trigger.isolatedCopy(), m_action.isolatedCopy() };
     196    }
     197    bool operator==(const ContentExtensionRule& other) const
     198    {
     199        return m_trigger == other.m_trigger && m_action == other.m_action;
     200    }
    179201
    180202private:
  • trunk/Source/WebKit/ChangeLog

    r234870 r234873  
     12018-08-14  Alex Christensen  <achristensen@webkit.org>
     2
     3        isValidCSSSelector is unsafe to be called from a non-main thread
     4        https://bugs.webkit.org/show_bug.cgi?id=188581
     5        <rdar://problem/40517358>
     6
     7        Reviewed by Sam Weinig.
     8
     9        * UIProcess/API/APIContentRuleListStore.cpp:
     10        (API::compiledToFile):
     11        (API::ContentRuleListStore::lookupContentRuleList):
     12        (API::ContentRuleListStore::getAvailableContentRuleListIdentifiers):
     13        (API::ContentRuleListStore::compileContentRuleList):
     14        (API::ContentRuleListStore::removeContentRuleList):
     15        (API::ContentRuleListStore::getContentRuleListSource):
     16        * UIProcess/API/APIContentRuleListStore.h:
     17        * UIProcess/API/Cocoa/WKContentRuleListStore.mm:
     18
    1192018-08-14  Ansh Shukla  <ansh_shukla@apple.com>
    220
  • trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp

    r224900 r234873  
    3636#include <WebCore/ContentExtensionCompiler.h>
    3737#include <WebCore/ContentExtensionError.h>
     38#include <WebCore/ContentExtensionParser.h>
    3839#include <WebCore/QualifiedName.h>
    3940#include <string>
     41#include <wtf/CompletionHandler.h>
    4042#include <wtf/NeverDestroyed.h>
    4143#include <wtf/RunLoop.h>
     
    210212}
    211213
    212 static std::error_code compiledToFile(String&& json, const String& finalFilePath, ContentRuleListMetaData& metaData, Data& mappedData)
     214static std::error_code compiledToFile(String&& json, Vector<WebCore::ContentExtensions::ContentExtensionRule>&& parsedRules, const String& finalFilePath, ContentRuleListMetaData& metaData, Data& mappedData)
    213215{
    214216    using namespace WebCore::ContentExtensions;
     
    228230        }
    229231       
    230         void writeSource(const String& sourceJSON) final {
     232        void writeSource(String&& sourceJSON) final
     233        {
    231234            ASSERT(!m_filtersWithoutConditionsBytecodeWritten);
    232235            ASSERT(!m_filtersWithConditionBytecodeWritten);
     
    340343    CompilationClient compilationClient(temporaryFileHandle, metaData);
    341344   
    342     if (auto compilerError = compileRuleList(compilationClient, WTFMove(json))) {
     345    if (auto compilerError = compileRuleList(compilationClient, WTFMove(json), WTFMove(parsedRules))) {
    343346        WTFLogAlways("Content Rule List compiling failed: Compiling failed.");
    344347        closeFile(temporaryFileHandle);
     
    392395}
    393396
    394 void ContentRuleListStore::lookupContentRuleList(const WTF::String& identifier, Function<void(RefPtr<API::ContentRuleList>, std::error_code)> completionHandler)
     397void ContentRuleListStore::lookupContentRuleList(const WTF::String& identifier, CompletionHandler<void(RefPtr<API::ContentRuleList>, std::error_code)> completionHandler)
    395398{
    396399    m_readQueue->dispatch([protectedThis = makeRef(*this), identifier = identifier.isolatedCopy(), storePath = m_storePath.isolatedCopy(), legacyFilename = m_legacyFilename, completionHandler = WTFMove(completionHandler)]() mutable {
     
    400403        Data fileData;
    401404        if (!openAndMapContentRuleList(path, metaData, fileData)) {
    402             RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler)] {
     405            RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler)] () mutable {
    403406                completionHandler(nullptr, Error::LookupFailed);
    404407            });
     
    407410       
    408411        if (metaData.version != ContentRuleListStore::CurrentContentRuleListFileVersion) {
    409             RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler)] {
     412            RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler)] () mutable {
    410413                completionHandler(nullptr, Error::VersionMismatch);
    411414            });
     
    413416        }
    414417       
    415         RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), identifier = identifier.isolatedCopy(), fileData = WTFMove(fileData), metaData = WTFMove(metaData), completionHandler = WTFMove(completionHandler)] {
     418        RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), identifier = identifier.isolatedCopy(), fileData = WTFMove(fileData), metaData = WTFMove(metaData), completionHandler = WTFMove(completionHandler)] () mutable {
    416419            completionHandler(createExtension(identifier, metaData, fileData), { });
    417420        });
     
    419422}
    420423
    421 void ContentRuleListStore::getAvailableContentRuleListIdentifiers(Function<void(WTF::Vector<WTF::String>)> completionHandler)
     424void ContentRuleListStore::getAvailableContentRuleListIdentifiers(CompletionHandler<void(WTF::Vector<WTF::String>)> completionHandler)
    422425{
    423426    m_readQueue->dispatch([protectedThis = makeRef(*this), storePath = m_storePath.isolatedCopy(), legacyFilename = m_legacyFilename, completionHandler = WTFMove(completionHandler)]() mutable {
     
    436439}
    437440
    438 void ContentRuleListStore::compileContentRuleList(const WTF::String& identifier, WTF::String&& json, Function<void(RefPtr<API::ContentRuleList>, std::error_code)> completionHandler)
     441void ContentRuleListStore::compileContentRuleList(const WTF::String& identifier, WTF::String&& json, CompletionHandler<void(RefPtr<API::ContentRuleList>, std::error_code)> completionHandler)
    439442{
    440443    AtomicString::init();
    441444    WebCore::QualifiedName::init();
    442     m_compileQueue->dispatch([protectedThis = makeRef(*this), identifier = identifier.isolatedCopy(), legacyFilename = m_legacyFilename, json = json.isolatedCopy(), storePath = m_storePath.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable {
     445   
     446    auto parsedRules = WebCore::ContentExtensions::parseRuleList(json);
     447    if (!parsedRules.has_value())
     448        return completionHandler(nullptr, parsedRules.error());
     449   
     450    m_compileQueue->dispatch([protectedThis = makeRef(*this), identifier = identifier.isolatedCopy(), legacyFilename = m_legacyFilename, json = json.isolatedCopy(), parsedRules = parsedRules.value().isolatedCopy(), storePath = m_storePath.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable {
    443451        auto path = constructedPath(storePath, identifier, legacyFilename);
    444452
    445453        ContentRuleListMetaData metaData;
    446454        Data fileData;
    447         auto error = compiledToFile(WTFMove(json), path, metaData, fileData);
     455        auto error = compiledToFile(WTFMove(json), WTFMove(parsedRules), path, metaData, fileData);
    448456        if (error) {
    449             RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), error = WTFMove(error), completionHandler = WTFMove(completionHandler)] {
     457            RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), error = WTFMove(error), completionHandler = WTFMove(completionHandler)] () mutable {
    450458                completionHandler(nullptr, error);
    451459            });
     
    453461        }
    454462
    455         RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), identifier = WTFMove(identifier), fileData = WTFMove(fileData), metaData = WTFMove(metaData), completionHandler = WTFMove(completionHandler)] {
     463        RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), identifier = WTFMove(identifier), fileData = WTFMove(fileData), metaData = WTFMove(metaData), completionHandler = WTFMove(completionHandler)] () mutable {
    456464            RefPtr<API::ContentRuleList> contentRuleList = createExtension(identifier, metaData, fileData);
    457465            completionHandler(contentRuleList, { });
     
    460468}
    461469
    462 void ContentRuleListStore::removeContentRuleList(const WTF::String& identifier, Function<void(std::error_code)> completionHandler)
     470void ContentRuleListStore::removeContentRuleList(const WTF::String& identifier, CompletionHandler<void(std::error_code)> completionHandler)
    463471{
    464472    m_removeQueue->dispatch([protectedThis = makeRef(*this), identifier = identifier.isolatedCopy(), storePath = m_storePath.isolatedCopy(), legacyFilename = m_legacyFilename, completionHandler = WTFMove(completionHandler)]() mutable {
     
    466474
    467475        if (!deleteFile(path)) {
    468             RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler)] {
     476            RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler)] () mutable {
    469477                completionHandler(Error::RemoveFailed);
    470478            });
     
    472480        }
    473481
    474         RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler)] {
     482        RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler)] () mutable {
    475483            completionHandler({ });
    476484        });
     
    495503}
    496504
    497 void ContentRuleListStore::getContentRuleListSource(const WTF::String& identifier, Function<void(WTF::String)> completionHandler)
     505void ContentRuleListStore::getContentRuleListSource(const WTF::String& identifier, CompletionHandler<void(WTF::String)> completionHandler)
    498506{
    499507    m_readQueue->dispatch([protectedThis = makeRef(*this), identifier = identifier.isolatedCopy(), storePath = m_storePath.isolatedCopy(), legacyFilename = m_legacyFilename, completionHandler = WTFMove(completionHandler)]() mutable {
     
    501509       
    502510        auto complete = [protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler)](String source) mutable {
    503             RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler), source = source.isolatedCopy()] {
     511            RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler), source = source.isolatedCopy()] () mutable {
    504512                completionHandler(source);
    505513            });
  • trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.h

    r223286 r234873  
    6363    virtual ~ContentRuleListStore();
    6464
    65     void compileContentRuleList(const WTF::String& identifier, WTF::String&& json, Function<void(RefPtr<API::ContentRuleList>, std::error_code)>);
    66     void lookupContentRuleList(const WTF::String& identifier, Function<void(RefPtr<API::ContentRuleList>, std::error_code)>);
    67     void removeContentRuleList(const WTF::String& identifier, Function<void(std::error_code)>);
    68     void getAvailableContentRuleListIdentifiers(Function<void(WTF::Vector<WTF::String>)>);
     65    void compileContentRuleList(const WTF::String& identifier, WTF::String&& json, CompletionHandler<void(RefPtr<API::ContentRuleList>, std::error_code)>);
     66    void lookupContentRuleList(const WTF::String& identifier, CompletionHandler<void(RefPtr<API::ContentRuleList>, std::error_code)>);
     67    void removeContentRuleList(const WTF::String& identifier, CompletionHandler<void(std::error_code)>);
     68    void getAvailableContentRuleListIdentifiers(CompletionHandler<void(WTF::Vector<WTF::String>)>);
    6969
    7070    // For testing only.
    7171    void synchronousRemoveAllContentRuleLists();
    7272    void invalidateContentRuleListVersion(const WTF::String& identifier);
    73     void getContentRuleListSource(const WTF::String& identifier, Function<void(WTF::String)>);
     73    void getContentRuleListSource(const WTF::String& identifier, CompletionHandler<void(WTF::String)>);
    7474
    7575private:
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListStore.mm

    r216809 r234873  
    3333#import "WKErrorInternal.h"
    3434#import <wtf/BlockPtr.h>
     35#import <wtf/CompletionHandler.h>
    3536
    3637static WKErrorCode toWKErrorCode(const std::error_code& error)
  • trunk/Tools/ChangeLog

    r234870 r234873  
     12018-08-14  Alex Christensen  <achristensen@webkit.org>
     2
     3        isValidCSSSelector is unsafe to be called from a non-main thread
     4        https://bugs.webkit.org/show_bug.cgi?id=188581
     5        <rdar://problem/40517358>
     6
     7        Reviewed by Sam Weinig.
     8
     9        * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
     10        (TestWebKitAPI::InMemoryCompiledContentExtension::create):
     11        (TestWebKitAPI::checkCompilerError):
     12
    1132018-08-14  Ansh Shukla  <ansh_shukla@apple.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp

    r233122 r234873  
    101101
    102102private:
    103     void writeSource(const String&) final { }
     103    void writeSource(String&&) final { }
    104104
    105105    void writeActions(Vector<ContentExtensions::SerializedActionByte>&& actions, bool conditionsApplyOnlyToDomain) final
     
    151151        CompiledContentExtensionData extensionData;
    152152        InMemoryContentExtensionCompilationClient client(extensionData);
    153         auto compilerError = ContentExtensions::compileRuleList(client, WTFMove(filter));
     153        auto parsedRules = ContentExtensions::parseRuleList(filter);
     154        auto compilerError = ContentExtensions::compileRuleList(client, WTFMove(filter), WTFMove(parsedRules.value()));
    154155
    155156        // Compiling should always succeed here. We have other tests for compile failures.
     
    13721373    CompiledContentExtensionData extensionData;
    13731374    InMemoryContentExtensionCompilationClient client(extensionData);
    1374     std::error_code compilerError = ContentExtensions::compileRuleList(client, json);
     1375    auto parsedRules = ContentExtensions::parseRuleList(json);
     1376    std::error_code compilerError;
     1377    if (parsedRules.has_value())
     1378        compilerError = ContentExtensions::compileRuleList(client, json, WTFMove(parsedRules.value()));
     1379    else
     1380        compilerError = parsedRules.error();
    13751381    EXPECT_EQ(compilerError.value(), expectedError.value());
    13761382    if (compilerError.value())
Note: See TracChangeset for help on using the changeset viewer.