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

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

Issue 1767343002: DevTools: [regression] do not go back and forth via utf8 in the debugger/runtime agents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/v8_inspector/V8DebuggerImpl.h" 7 #include "platform/v8_inspector/V8DebuggerImpl.h"
8 #include "platform/v8_inspector/V8Regex.h" 8 #include "platform/v8_inspector/V8Regex.h"
9 #include "platform/v8_inspector/public/V8ContentSearchUtil.h" 9 #include "platform/v8_inspector/public/V8ContentSearchUtil.h"
10 #include "wtf/text/StringBuilder.h" 10 #include "wtf/text/StringBuilder.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 PassOwnPtr<V8Regex> createSearchRegex(V8DebuggerImpl* debugger, const String& qu ery, bool caseSensitive, bool isRegex) 146 PassOwnPtr<V8Regex> createSearchRegex(V8DebuggerImpl* debugger, const String& qu ery, bool caseSensitive, bool isRegex)
147 { 147 {
148 String regexSource = isRegex ? query : createSearchRegexSource(query); 148 String regexSource = isRegex ? query : createSearchRegexSource(query);
149 return adoptPtr(new V8Regex(debugger, regexSource, caseSensitive ? TextCaseS ensitive : TextCaseInsensitive)); 149 return adoptPtr(new V8Regex(debugger, regexSource, caseSensitive ? TextCaseS ensitive : TextCaseInsensitive));
150 } 150 }
151 151
152 } // namespace 152 } // namespace
153 153
154 v8::Local<v8::String> toV8String(v8::Isolate* isolate, const String& string) 154 v8::Local<v8::String> toV8String(v8::Isolate* isolate, const String& string)
155 { 155 {
156 return v8::String::NewFromUtf8(isolate, string.utf8().data(), v8::NewStringT ype::kNormal).ToLocalChecked(); 156 if (string.isNull())
157 return v8::String::Empty(isolate);
158 if (string.is8Bit())
159 return v8::String::NewFromOneByte(isolate, string.characters8(), v8::New StringType::kNormal, string.length()).ToLocalChecked();
160 return v8::String::NewFromTwoByte(isolate, reinterpret_cast<const uint16_t*> (string.characters16()), v8::NewStringType::kNormal, string.length()).ToLocalChe cked();
157 } 161 }
158 162
159 v8::Local<v8::String> toV8StringInternalized(v8::Isolate* isolate, const String& string) 163 v8::Local<v8::String> toV8StringInternalized(v8::Isolate* isolate, const String& string)
160 { 164 {
161 return v8::String::NewFromUtf8(isolate, string.utf8().data(), v8::NewStringT ype::kInternalized).ToLocalChecked(); 165 if (string.isNull())
166 return v8::String::Empty(isolate);
167 if (string.is8Bit())
168 return v8::String::NewFromOneByte(isolate, string.characters8(), v8::New StringType::kInternalized, string.length()).ToLocalChecked();
169 return v8::String::NewFromTwoByte(isolate, reinterpret_cast<const uint16_t*> (string.characters16()), v8::NewStringType::kInternalized, string.length()).ToLo calChecked();
162 } 170 }
163 171
164 String toWTFString(v8::Local<v8::String> value) 172 String toWTFString(v8::Local<v8::String> value)
165 { 173 {
166 if (value.IsEmpty() || value->IsNull() || value->IsUndefined()) 174 if (value.IsEmpty() || value->IsNull() || value->IsUndefined())
167 return String(); 175 return String();
168 UChar* buffer; 176 UChar* buffer;
169 String result = String::createUninitialized(value->Length(), buffer); 177 String result = String::createUninitialized(value->Length(), buffer);
170 value->Write(reinterpret_cast<uint16_t*>(buffer), 0, value->Length()); 178 value->Write(reinterpret_cast<uint16_t*>(buffer), 0, value->Length());
171 return result; 179 return result;
(...skipping 26 matching lines...) Expand all
198 206
199 for (const auto& match : matches) 207 for (const auto& match : matches)
200 result->addItem(buildObjectForSearchMatch(match.first, match.second)); 208 result->addItem(buildObjectForSearchMatch(match.first, match.second));
201 209
202 return result.release(); 210 return result.release();
203 } 211 }
204 212
205 } // namespace V8ContentSearchUtil 213 } // namespace V8ContentSearchUtil
206 214
207 } // namespace blink 215 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698