Ref<JSON::ArrayOf<Protocol::GenericTypes::SearchMatch>> searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex) { auto result = JSON::ArrayOf<Protocol::GenericTypes::SearchMatch>::create(); auto regex = ContentSearchUtilities::createSearchRegex(query, caseSensitive, isRegex); for (const auto& match : getRegularExpressionMatchesByLines(regex, text)) result->addItem(buildObjectForSearchMatch(match.first, match.second)); return result; }
std::unique_ptr<protocol::Array<protocol::Debugger::SearchMatch>> searchInTextByLines(V8InspectorSession* session, const String16& text, const String16& query, const bool caseSensitive, const bool isRegex) { std::unique_ptr<protocol::Array<protocol::Debugger::SearchMatch>> result = protocol::Array<protocol::Debugger::SearchMatch>::create(); std::unique_ptr<V8Regex> regex = createSearchRegex(static_cast<V8InspectorSessionImpl*>(session)->debugger(), query, caseSensitive, isRegex); std::vector<std::pair<int, String16>> matches = scriptRegexpMatchesByLines(*regex.get(), text); for (const auto& match : matches) result->addItem(buildObjectForSearchMatch(match.first, match.second)); return result; }
PassRefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::GenericTypes::SearchMatch>> searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex) { RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::GenericTypes::SearchMatch>> result = Inspector::TypeBuilder::Array<Inspector::TypeBuilder::GenericTypes::SearchMatch>::create(); RegularExpression regex = ContentSearchUtils::createSearchRegex(query, caseSensitive, isRegex); Vector<std::pair<int, String>> matches = getRegularExpressionMatchesByLines(regex, text); for (Vector<std::pair<int, String>>::const_iterator it = matches.begin(); it != matches.end(); ++it) result->addItem(buildObjectForSearchMatch(it->first, it->second)); return result; }
PassRefPtr<TypeBuilder::Array<TypeBuilder::Page::SearchMatch> > searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex) { RefPtr<TypeBuilder::Array<TypeBuilder::Page::SearchMatch> > result = TypeBuilder::Array<TypeBuilder::Page::SearchMatch>::create(); OwnPtr<ScriptRegexp> regex = ContentSearchUtils::createSearchRegex(query, caseSensitive, isRegex); Vector<pair<int, String> > matches = getScriptRegexpMatchesByLines(regex.get(), text); for (Vector<pair<int, String> >::const_iterator it = matches.begin(); it != matches.end(); ++it) result->addItem(buildObjectForSearchMatch(it->first, it->second)); return result; }
PassRefPtr<TypeBuilder::Array<TypeBuilder::Debugger::SearchMatch>> searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex) { RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::SearchMatch>> result = TypeBuilder::Array<TypeBuilder::Debugger::SearchMatch>::create(); OwnPtr<ScriptRegexp> regex = ContentSearchUtils::createSearchRegex(query, caseSensitive, isRegex); Vector<std::pair<int, String>> matches = getScriptRegexpMatchesByLines(regex.get(), text); for (const auto& match : matches) result->addItem(buildObjectForSearchMatch(match.first, match.second)); return result; }
void InspectorPageAgent::searchInResources(ErrorString*, const String& text, const bool* const optionalCaseSensitive, const bool* const optionalIsRegex, RefPtr<InspectorArray>* object) { RefPtr<InspectorArray> result = InspectorArray::create(); bool isRegex = optionalIsRegex ? *optionalIsRegex : false; String regexSource = isRegex ? text : createSearchRegexSource(text); bool caseSensitive = optionalCaseSensitive ? *optionalCaseSensitive : false; RegularExpression regex(regexSource, caseSensitive ? TextCaseSensitive : TextCaseInsensitive); for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext(m_page->mainFrame())) { String content; bool base64Encoded; Vector<CachedResource*> allResources = cachedResourcesForFrame(frame); for (Vector<CachedResource*>::const_iterator it = allResources.begin(); it != allResources.end(); ++it) { CachedResource* cachedResource = *it; switch (InspectorPageAgent::cachedResourceType(*cachedResource)) { case InspectorPageAgent::StylesheetResource: case InspectorPageAgent::ScriptResource: if (cachedResourceContent(cachedResource, &content, &base64Encoded)) { ASSERT(!base64Encoded); int matchesCount = countRegularExpressionMatches(regex, content); if (matchesCount) result->pushValue(buildObjectForSearchMatch(frameId(frame), cachedResource->url(), matchesCount)); } break; default: break; } } if (mainResourceContent(frame, false, &content)) { int matchesCount = countRegularExpressionMatches(regex, content); if (matchesCount) result->pushValue(buildObjectForSearchMatch(frameId(frame), frame->document()->url(), matchesCount)); } } *object = result; }