Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(994)

Unified Diff: Source/core/inspector/ContentSearchUtils.cpp

Issue 15832007: DevTools: Add support for //# sourceURL (sourceMappingURL) comments and deprecate //@ ones (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/inspector/ContentSearchUtils.cpp
diff --git a/Source/core/inspector/ContentSearchUtils.cpp b/Source/core/inspector/ContentSearchUtils.cpp
index d994fc36231b8c649006a24dff083bec1ace11b0..d241dc055f272a1eccdc65c9cd1f6f4ec2116e99 100644
--- a/Source/core/inspector/ContentSearchUtils.cpp
+++ b/Source/core/inspector/ContentSearchUtils.cpp
@@ -163,25 +163,36 @@ PassRefPtr<TypeBuilder::Array<TypeBuilder::Page::SearchMatch> > searchInTextByLi
return result;
}
-String findMagicComment(const String& content, const String& name, MagicCommentType commentType)
+static String findMagicComment(const String& content, const String& name, MagicCommentType commentType, bool* deprecated = 0)
{
ASSERT(name.find("=") == notFound);
+ if (deprecated)
+ *deprecated = false;
String pattern;
+ String deprecatedPattern;
switch (commentType) {
case JavaScriptMagicComment:
- pattern= "//@[\040\t]" + createSearchRegexSource(name) + "=[\040\t]*([^\\s\'\"]*)[\040\t]*$";
+ pattern = "//#[\040\t]" + createSearchRegexSource(name) + "=[\040\t]*([^\\s\'\"]*)[\040\t]*$";
+ deprecatedPattern = "//@[\040\t]" + createSearchRegexSource(name) + "=[\040\t]*([^\\s\'\"]*)[\040\t]*$";
break;
case CSSMagicComment:
- pattern= "/\\*@[\040\t]" + createSearchRegexSource(name) + "=[\040\t]*([^\\s]*)[\040\t]*\\*/[\040\t]*$";
+ pattern = "/\\*#[\040\t]" + createSearchRegexSource(name) + "=[\040\t]*([^\\s]*)[\040\t]*\\*/[\040\t]*$";
+ deprecatedPattern = "/\\*@[\040\t]" + createSearchRegexSource(name) + "=[\040\t]*([^\\s]*)[\040\t]*\\*/[\040\t]*$";
break;
default:
ASSERT_NOT_REACHED();
return String();
}
RegularExpression regex(pattern, TextCaseSensitive, MultilineEnabled);
+ RegularExpression deprecatedRegex(deprecatedPattern, TextCaseSensitive, MultilineEnabled);
int matchLength;
int offset = regex.match(content, 0, &matchLength);
+ if (offset == -1) {
+ offset = deprecatedRegex.match(content, 0, &matchLength);
+ if (offset != -1 && deprecated)
+ *deprecated = true;
+ }
if (offset == -1)
return String();
@@ -204,14 +215,14 @@ String findMagicComment(const String& content, const String& name, MagicCommentT
}
}
-String findSourceURL(const String& content, MagicCommentType commentType)
+String findSourceURL(const String& content, MagicCommentType commentType, bool* deprecated)
{
- return findMagicComment(content, "sourceURL", commentType);
+ return findMagicComment(content, "sourceURL", commentType, deprecated);
}
-String findSourceMapURL(const String& content, MagicCommentType commentType)
+String findSourceMapURL(const String& content, MagicCommentType commentType, bool* deprecated)
{
- return findMagicComment(content, "sourceMappingURL", commentType);
+ return findMagicComment(content, "sourceMappingURL", commentType, deprecated);
}
} // namespace ContentSearchUtils

Powered by Google App Engine
This is Rietveld 408576698