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/V8Regex.h" | 5 #include "platform/v8_inspector/V8Regex.h" |
6 | 6 |
7 #include "platform/v8_inspector/V8DebuggerImpl.h" | 7 #include "platform/v8_inspector/V8DebuggerImpl.h" |
8 #include "platform/v8_inspector/V8StringUtil.h" | 8 #include "platform/v8_inspector/V8StringUtil.h" |
9 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 9 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 v8::Local<v8::RegExp> regex; | 28 v8::Local<v8::RegExp> regex; |
29 if (v8::RegExp::New(context, toV8String(isolate, pattern), static_cast<v8::R
egExp::Flags>(flags)).ToLocal(®ex)) | 29 if (v8::RegExp::New(context, toV8String(isolate, pattern), static_cast<v8::R
egExp::Flags>(flags)).ToLocal(®ex)) |
30 m_regex.Reset(isolate, regex); | 30 m_regex.Reset(isolate, regex); |
31 } | 31 } |
32 | 32 |
33 int V8Regex::match(const String16& string, int startFrom, int* matchLength) cons
t | 33 int V8Regex::match(const String16& string, int startFrom, int* matchLength) cons
t |
34 { | 34 { |
35 if (matchLength) | 35 if (matchLength) |
36 *matchLength = 0; | 36 *matchLength = 0; |
37 | 37 |
38 if (m_regex.IsEmpty() || string.isNull()) | 38 if (m_regex.IsEmpty() || string.isEmpty()) |
39 return -1; | 39 return -1; |
40 | 40 |
41 // v8 strings are limited to int. | 41 // v8 strings are limited to int. |
42 if (string.length() > INT_MAX) | 42 if (string.length() > INT_MAX) |
43 return -1; | 43 return -1; |
44 | 44 |
45 v8::Isolate* isolate = m_debugger->isolate(); | 45 v8::Isolate* isolate = m_debugger->isolate(); |
46 v8::HandleScope handleScope(isolate); | 46 v8::HandleScope handleScope(isolate); |
47 v8::Local<v8::Context> context = m_debugger->regexContext(); | 47 v8::Local<v8::Context> context = m_debugger->regexContext(); |
48 v8::Context::Scope contextScope(context); | 48 v8::Context::Scope contextScope(context); |
(...skipping 27 matching lines...) Expand all Loading... |
76 v8::Local<v8::Value> match; | 76 v8::Local<v8::Value> match; |
77 if (!result->Get(context, 0).ToLocal(&match)) | 77 if (!result->Get(context, 0).ToLocal(&match)) |
78 return -1; | 78 return -1; |
79 *matchLength = match.As<v8::String>()->Length(); | 79 *matchLength = match.As<v8::String>()->Length(); |
80 } | 80 } |
81 | 81 |
82 return matchOffset.As<v8::Int32>()->Value() + startFrom; | 82 return matchOffset.As<v8::Int32>()->Value() + startFrom; |
83 } | 83 } |
84 | 84 |
85 } // namespace blink | 85 } // namespace blink |
OLD | NEW |