| OLD | NEW |
| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 PassOwnPtr<V8Regex> createSearchRegex(V8DebuggerImpl* debugger, const String& qu
ery, bool caseSensitive, bool isRegex) | 129 PassOwnPtr<V8Regex> createSearchRegex(V8DebuggerImpl* debugger, const String& qu
ery, bool caseSensitive, bool isRegex) |
| 130 { | 130 { |
| 131 String regexSource = isRegex ? query : createSearchRegexSource(query); | 131 String regexSource = isRegex ? query : createSearchRegexSource(query); |
| 132 return adoptPtr(new V8Regex(debugger, regexSource, caseSensitive ? TextCaseS
ensitive : TextCaseInsensitive)); | 132 return adoptPtr(new V8Regex(debugger, regexSource, caseSensitive ? TextCaseS
ensitive : TextCaseInsensitive)); |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace | 135 } // namespace |
| 136 | 136 |
| 137 v8::Local<v8::String> toV8String(v8::Isolate* isolate, const String& string) | 137 v8::Local<v8::String> toV8String(v8::Isolate* isolate, const String& string) |
| 138 { | 138 { |
| 139 return v8::String::NewFromUtf8(isolate, string.utf8().data(), v8::NewStringT
ype::kNormal).ToLocalChecked(); | 139 if (string.isNull()) |
| 140 return v8::String::Empty(isolate); |
| 141 if (string.is8Bit()) |
| 142 return v8::String::NewFromOneByte(isolate, string.characters8(), v8::New
StringType::kNormal, string.length()).ToLocalChecked(); |
| 143 return v8::String::NewFromTwoByte(isolate, reinterpret_cast<const uint16_t*>
(string.characters16()), v8::NewStringType::kNormal, string.length()).ToLocalChe
cked(); |
| 140 } | 144 } |
| 141 | 145 |
| 142 v8::Local<v8::String> toV8StringInternalized(v8::Isolate* isolate, const String&
string) | 146 v8::Local<v8::String> toV8StringInternalized(v8::Isolate* isolate, const String&
string) |
| 143 { | 147 { |
| 144 return v8::String::NewFromUtf8(isolate, string.utf8().data(), v8::NewStringT
ype::kInternalized).ToLocalChecked(); | 148 if (string.isNull()) |
| 149 return v8::String::Empty(isolate); |
| 150 if (string.is8Bit()) |
| 151 return v8::String::NewFromOneByte(isolate, string.characters8(), v8::New
StringType::kInternalized, string.length()).ToLocalChecked(); |
| 152 return v8::String::NewFromTwoByte(isolate, reinterpret_cast<const uint16_t*>
(string.characters16()), v8::NewStringType::kInternalized, string.length()).ToLo
calChecked(); |
| 145 } | 153 } |
| 146 | 154 |
| 147 String toWTFString(v8::Local<v8::String> value) | 155 String toWTFString(v8::Local<v8::String> value) |
| 148 { | 156 { |
| 149 if (value.IsEmpty() || value->IsNull() || value->IsUndefined()) | 157 if (value.IsEmpty() || value->IsNull() || value->IsUndefined()) |
| 150 return String(); | 158 return String(); |
| 151 UChar* buffer; | 159 UChar* buffer; |
| 152 String result = String::createUninitialized(value->Length(), buffer); | 160 String result = String::createUninitialized(value->Length(), buffer); |
| 153 value->Write(reinterpret_cast<uint16_t*>(buffer), 0, value->Length()); | 161 value->Write(reinterpret_cast<uint16_t*>(buffer), 0, value->Length()); |
| 154 return result; | 162 return result; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 181 | 189 |
| 182 for (const auto& match : matches) | 190 for (const auto& match : matches) |
| 183 result->addItem(buildObjectForSearchMatch(match.first, match.second)); | 191 result->addItem(buildObjectForSearchMatch(match.first, match.second)); |
| 184 | 192 |
| 185 return result.release(); | 193 return result.release(); |
| 186 } | 194 } |
| 187 | 195 |
| 188 } // namespace V8ContentSearchUtil | 196 } // namespace V8ContentSearchUtil |
| 189 | 197 |
| 190 } // namespace blink | 198 } // namespace blink |
| OLD | NEW |