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

Side by Side Diff: Source/core/inspector/ContentSearchUtils.cpp

Issue 23464095: WTF::notFound looks too much like a local variable. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/html/track/WebVTTParser.cpp ('k') | Source/core/inspector/DOMPatchSupport.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 10 *
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // This should be kept the same as the one in front-end/utilities.js 42 // This should be kept the same as the one in front-end/utilities.js
43 static const char regexSpecialCharacters[] = "[](){}+-*.,?\\^$|"; 43 static const char regexSpecialCharacters[] = "[](){}+-*.,?\\^$|";
44 } 44 }
45 45
46 static String createSearchRegexSource(const String& text) 46 static String createSearchRegexSource(const String& text)
47 { 47 {
48 StringBuilder result; 48 StringBuilder result;
49 String specials(regexSpecialCharacters); 49 String specials(regexSpecialCharacters);
50 50
51 for (unsigned i = 0; i < text.length(); i++) { 51 for (unsigned i = 0; i < text.length(); i++) {
52 if (specials.find(text[i]) != notFound) 52 if (specials.find(text[i]) != kNotFound)
53 result.append("\\"); 53 result.append("\\");
54 result.append(text[i]); 54 result.append(text[i]);
55 } 55 }
56 56
57 return result.toString(); 57 return result.toString();
58 } 58 }
59 59
60 static Vector<pair<int, String> > getRegularExpressionMatchesByLines(const Regul arExpression* regex, const String& text) 60 static Vector<pair<int, String> > getRegularExpressionMatchesByLines(const Regul arExpression* regex, const String& text)
61 { 61 {
62 Vector<pair<int, String> > result; 62 Vector<pair<int, String> > result;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 Vector<pair<int, String> > matches = getRegularExpressionMatchesByLines(rege x.get(), text); 122 Vector<pair<int, String> > matches = getRegularExpressionMatchesByLines(rege x.get(), text);
123 123
124 for (Vector<pair<int, String> >::const_iterator it = matches.begin(); it != matches.end(); ++it) 124 for (Vector<pair<int, String> >::const_iterator it = matches.begin(); it != matches.end(); ++it)
125 result->addItem(buildObjectForSearchMatch(it->first, it->second)); 125 result->addItem(buildObjectForSearchMatch(it->first, it->second));
126 126
127 return result; 127 return result;
128 } 128 }
129 129
130 static String findMagicComment(const String& content, const String& name, MagicC ommentType commentType, bool* deprecated = 0) 130 static String findMagicComment(const String& content, const String& name, MagicC ommentType commentType, bool* deprecated = 0)
131 { 131 {
132 ASSERT(name.find("=") == notFound); 132 ASSERT(name.find("=") == kNotFound);
133 if (deprecated) 133 if (deprecated)
134 *deprecated = false; 134 *deprecated = false;
135 String pattern; 135 String pattern;
136 String deprecatedPattern; 136 String deprecatedPattern;
137 switch (commentType) { 137 switch (commentType) {
138 case JavaScriptMagicComment: 138 case JavaScriptMagicComment:
139 pattern = "//#[\040\t]" + createSearchRegexSource(name) + "=[\040\t]*([^ \\s\'\"]*)[\040\t]*$"; 139 pattern = "//#[\040\t]" + createSearchRegexSource(name) + "=[\040\t]*([^ \\s\'\"]*)[\040\t]*$";
140 deprecatedPattern = "//@[\040\t]" + createSearchRegexSource(name) + "=[\ 040\t]*([^\\s\'\"]*)[\040\t]*$"; 140 deprecatedPattern = "//@[\040\t]" + createSearchRegexSource(name) + "=[\ 040\t]*([^\\s\'\"]*)[\040\t]*$";
141 break; 141 break;
142 case CSSMagicComment: 142 case CSSMagicComment:
(...skipping 12 matching lines...) Expand all
155 if (offset == -1) { 155 if (offset == -1) {
156 offset = deprecatedRegex.match(content, 0, &matchLength); 156 offset = deprecatedRegex.match(content, 0, &matchLength);
157 if (offset != -1 && deprecated) 157 if (offset != -1 && deprecated)
158 *deprecated = true; 158 *deprecated = true;
159 } 159 }
160 if (offset == -1) 160 if (offset == -1)
161 return String(); 161 return String();
162 162
163 String match = content.substring(offset, matchLength); 163 String match = content.substring(offset, matchLength);
164 size_t separator = match.find("="); 164 size_t separator = match.find("=");
165 ASSERT(separator != notFound); 165 ASSERT(separator != kNotFound);
166 match = match.substring(separator + 1); 166 match = match.substring(separator + 1);
167 167
168 switch (commentType) { 168 switch (commentType) {
169 case JavaScriptMagicComment: 169 case JavaScriptMagicComment:
170 return match.stripWhiteSpace(); 170 return match.stripWhiteSpace();
171 case CSSMagicComment: { 171 case CSSMagicComment: {
172 size_t lastStarIndex = match.reverseFind('*'); 172 size_t lastStarIndex = match.reverseFind('*');
173 ASSERT(lastStarIndex != notFound); 173 ASSERT(lastStarIndex != kNotFound);
174 return match.substring(0, lastStarIndex).stripWhiteSpace(); 174 return match.substring(0, lastStarIndex).stripWhiteSpace();
175 } 175 }
176 default: 176 default:
177 ASSERT_NOT_REACHED(); 177 ASSERT_NOT_REACHED();
178 return String(); 178 return String();
179 } 179 }
180 } 180 }
181 181
182 String findSourceURL(const String& content, MagicCommentType commentType, bool* deprecated) 182 String findSourceURL(const String& content, MagicCommentType commentType, bool* deprecated)
183 { 183 {
184 return findMagicComment(content, "sourceURL", commentType, deprecated); 184 return findMagicComment(content, "sourceURL", commentType, deprecated);
185 } 185 }
186 186
187 String findSourceMapURL(const String& content, MagicCommentType commentType, boo l* deprecated) 187 String findSourceMapURL(const String& content, MagicCommentType commentType, boo l* deprecated)
188 { 188 {
189 return findMagicComment(content, "sourceMappingURL", commentType, deprecated ); 189 return findMagicComment(content, "sourceMappingURL", commentType, deprecated );
190 } 190 }
191 191
192 } // namespace ContentSearchUtils 192 } // namespace ContentSearchUtils
193 } // namespace WebCore 193 } // namespace WebCore
194 194
OLDNEW
« no previous file with comments | « Source/core/html/track/WebVTTParser.cpp ('k') | Source/core/inspector/DOMPatchSupport.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698