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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8StringUtil.cpp

Issue 2235743004: [DevTools] Removed deprecatedCommentWasUsed flag from protocol scriptParsed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 years, 4 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/v8_inspector/V8StringUtil.h" 5 #include "platform/v8_inspector/V8StringUtil.h"
6 6
7 #include "platform/inspector_protocol/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/v8_inspector/V8InspectorImpl.h" 8 #include "platform/v8_inspector/V8InspectorImpl.h"
9 #include "platform/v8_inspector/V8InspectorSessionImpl.h" 9 #include "platform/v8_inspector/V8InspectorSessionImpl.h"
10 #include "platform/v8_inspector/V8Regex.h" 10 #include "platform/v8_inspector/V8Regex.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 namespace { 14 namespace {
15 15
16 String16 findMagicComment(const String16& content, const String16& name, bool mu ltiline, bool* deprecated) 16 String16 findMagicComment(const String16& content, const String16& name, bool mu ltiline)
17 { 17 {
18 DCHECK(name.find("=") == kNotFound); 18 DCHECK(name.find("=") == kNotFound);
19 if (deprecated)
20 *deprecated = false;
21
22 unsigned length = content.length(); 19 unsigned length = content.length();
23 unsigned nameLength = name.length(); 20 unsigned nameLength = name.length();
24 21
25 size_t pos = length; 22 size_t pos = length;
26 size_t equalSignPos = 0; 23 size_t equalSignPos = 0;
27 size_t closingCommentPos = 0; 24 size_t closingCommentPos = 0;
28 while (true) { 25 while (true) {
29 pos = content.reverseFind(name, pos); 26 pos = content.reverseFind(name, pos);
30 if (pos == kNotFound) 27 if (pos == kNotFound)
31 return String16(); 28 return String16();
(...skipping 16 matching lines...) Expand all
48 continue; 45 continue;
49 if (multiline) { 46 if (multiline) {
50 closingCommentPos = content.find("*/", equalSignPos + 1); 47 closingCommentPos = content.find("*/", equalSignPos + 1);
51 if (closingCommentPos == kNotFound) 48 if (closingCommentPos == kNotFound)
52 return String16(); 49 return String16();
53 } 50 }
54 51
55 break; 52 break;
56 } 53 }
57 54
58 if (deprecated && content[pos + 2] == '@')
59 *deprecated = true;
60
61 DCHECK(equalSignPos); 55 DCHECK(equalSignPos);
62 DCHECK(!multiline || closingCommentPos); 56 DCHECK(!multiline || closingCommentPos);
63 size_t urlPos = equalSignPos + 1; 57 size_t urlPos = equalSignPos + 1;
64 String16 match = multiline 58 String16 match = multiline
65 ? content.substring(urlPos, closingCommentPos - urlPos) 59 ? content.substring(urlPos, closingCommentPos - urlPos)
66 : content.substring(urlPos); 60 : content.substring(urlPos);
67 61
68 size_t newLine = match.find("\n"); 62 size_t newLine = match.find("\n");
69 if (newLine != kNotFound) 63 if (newLine != kNotFound)
70 match = match.substring(0, newLine); 64 match = match.substring(0, newLine);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 { 184 {
191 std::unique_ptr<V8Regex> regex = createSearchRegex(static_cast<V8InspectorSe ssionImpl*>(session)->inspector(), query, caseSensitive, isRegex); 185 std::unique_ptr<V8Regex> regex = createSearchRegex(static_cast<V8InspectorSe ssionImpl*>(session)->inspector(), query, caseSensitive, isRegex);
192 std::vector<std::pair<int, String16>> matches = scriptRegexpMatchesByLines(* regex.get(), text); 186 std::vector<std::pair<int, String16>> matches = scriptRegexpMatchesByLines(* regex.get(), text);
193 187
194 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> result; 188 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> result;
195 for (const auto& match : matches) 189 for (const auto& match : matches)
196 result.push_back(buildObjectForSearchMatch(match.first, match.second)); 190 result.push_back(buildObjectForSearchMatch(match.first, match.second));
197 return result; 191 return result;
198 } 192 }
199 193
200 String16 findSourceURL(const String16& content, bool multiline, bool* deprecated ) 194 String16 findSourceURL(const String16& content, bool multiline)
201 { 195 {
202 return findMagicComment(content, "sourceURL", multiline, deprecated); 196 return findMagicComment(content, "sourceURL", multiline);
203 } 197 }
204 198
205 String16 findSourceMapURL(const String16& content, bool multiline, bool* depreca ted) 199 String16 findSourceMapURL(const String16& content, bool multiline)
206 { 200 {
207 return findMagicComment(content, "sourceMappingURL", multiline, deprecated); 201 return findMagicComment(content, "sourceMappingURL", multiline);
208 } 202 }
209 203
210 std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, v8::Local<v8::Value> value, int maxDepth) 204 std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, v8::Local<v8::Value> value, int maxDepth)
211 { 205 {
212 if (value.IsEmpty()) { 206 if (value.IsEmpty()) {
213 NOTREACHED(); 207 NOTREACHED();
214 return nullptr; 208 return nullptr;
215 } 209 }
216 210
217 if (!maxDepth) 211 if (!maxDepth)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return nullptr; 268 return nullptr;
275 jsonObject->setValue(toProtocolString(propertyName), std::move(prope rtyValue)); 269 jsonObject->setValue(toProtocolString(propertyName), std::move(prope rtyValue));
276 } 270 }
277 return std::move(jsonObject); 271 return std::move(jsonObject);
278 } 272 }
279 NOTREACHED(); 273 NOTREACHED();
280 return nullptr; 274 return nullptr;
281 } 275 }
282 276
283 } // namespace blink 277 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698