X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/2d39b0e377c0896910ee49ae70082ba665faf986..HEAD:/inspector/ContentSearchUtilities.cpp?ds=sidebyside diff --git a/inspector/ContentSearchUtilities.cpp b/inspector/ContentSearchUtilities.cpp index bcd691b..ed32a15 100644 --- a/inspector/ContentSearchUtilities.cpp +++ b/inspector/ContentSearchUtilities.cpp @@ -29,9 +29,6 @@ #include "config.h" #include "ContentSearchUtilities.h" -#if ENABLE(INSPECTOR) - -#include "InspectorJSTypeBuilders.h" #include "InspectorValues.h" #include "RegularExpression.h" #include "Yarr.h" @@ -121,9 +118,9 @@ std::unique_ptr> lineEndings(const String& text) return result; } -static PassRefPtr buildObjectForSearchMatch(size_t lineNumber, const String& lineContent) +static Ref buildObjectForSearchMatch(size_t lineNumber, const String& lineContent) { - return Inspector::TypeBuilder::GenericTypes::SearchMatch::create() + return Inspector::Protocol::GenericTypes::SearchMatch::create() .setLineNumber(lineNumber) .setLineContent(lineContent) .release(); @@ -154,15 +151,17 @@ int countRegularExpressionMatches(const JSC::Yarr::RegularExpression& regex, con return result; } -PassRefPtr> searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex) +Ref> searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex) { - RefPtr> result = Inspector::TypeBuilder::Array::create(); + Ref> result = Inspector::Protocol::Array::create(); JSC::Yarr::RegularExpression regex = ContentSearchUtilities::createSearchRegex(query, caseSensitive, isRegex); Vector> matches = getRegularExpressionMatchesByLines(regex, text); - for (const auto& match : matches) - result->addItem(buildObjectForSearchMatch(match.first, match.second)); + for (const auto& match : matches) { + Ref matchObject = buildObjectForSearchMatch(match.first, match.second); + result->addItem(WTF::move(matchObject)); + } return result; } @@ -181,11 +180,12 @@ static String stylesheetCommentPattern(const String& name) static String findMagicComment(const String& content, const String& patternString) { + ASSERT(!content.isNull()); const char* error = nullptr; JSC::Yarr::YarrPattern pattern(patternString, false, true, &error); ASSERT(!error); BumpPointerAllocator regexAllocator; - OwnPtr bytecodePattern = JSC::Yarr::byteCompile(pattern, ®exAllocator); + auto bytecodePattern = JSC::Yarr::byteCompile(pattern, ®exAllocator); ASSERT(bytecodePattern); ASSERT(pattern.m_numSubpatterns == 1); @@ -216,5 +216,3 @@ String findStylesheetSourceMapURL(const String& content) } // namespace ContentSearchUtilities } // namespace Inspector - -#endif // ENABLE(INSPECTOR)