OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2008, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Collabora Ltd. | 3 * Copyright (C) 2008 Collabora Ltd. |
4 * Copyright (C) 2011 Peter Varga (pvarga@webkit.org), University of Szeged | 4 * Copyright (C) 2011 Peter Varga (pvarga@webkit.org), University of Szeged |
5 * Copyright (C) 2013 Google Inc. All rights reserved. | 5 * Copyright (C) 2013 Google Inc. All rights reserved. |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 15 matching lines...) Expand all Loading... | |
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #include "config.h" | 29 #include "config.h" |
30 #include "bindings/core/v8/ScriptRegexp.h" | 30 #include "bindings/core/v8/ScriptRegexp.h" |
31 | 31 |
32 #include "bindings/core/v8/V8Binding.h" | 32 #include "bindings/core/v8/V8Binding.h" |
33 #include "bindings/core/v8/V8PerIsolateData.h" | 33 #include "bindings/core/v8/V8PerIsolateData.h" |
34 #include "bindings/core/v8/V8ScriptRunner.h" | 34 #include "bindings/core/v8/V8ScriptRunner.h" |
35 #include "platform/ScriptForbiddenScope.h" | 35 #include "platform/ScriptForbiddenScope.h" |
36 #include "wtf/Optional.h" | |
36 | 37 |
37 namespace blink { | 38 namespace blink { |
38 | 39 |
39 ScriptRegexp::ScriptRegexp(const String& pattern, TextCaseSensitivity caseSensit ivity, MultilineMode multilineMode) | 40 ScriptRegexp::ScriptRegexp(const String& pattern, TextCaseSensitivity caseSensit ivity, MultilineMode multilineMode) |
40 { | 41 { |
41 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 42 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
42 v8::HandleScope handleScope(isolate); | 43 v8::HandleScope handleScope(isolate); |
43 v8::Local<v8::Context> context = V8PerIsolateData::from(isolate)->ensureScri ptRegexpContext(); | 44 v8::Local<v8::Context> context = V8PerIsolateData::from(isolate)->ensureScri ptRegexpContext(); |
44 v8::Context::Scope contextScope(context); | 45 v8::Context::Scope contextScope(context); |
45 v8::TryCatch tryCatch; | 46 v8::TryCatch tryCatch; |
(...skipping 14 matching lines...) Expand all Loading... | |
60 if (matchLength) | 61 if (matchLength) |
61 *matchLength = 0; | 62 *matchLength = 0; |
62 | 63 |
63 if (m_regex.isEmpty() || string.isNull()) | 64 if (m_regex.isEmpty() || string.isNull()) |
64 return -1; | 65 return -1; |
65 | 66 |
66 // v8 strings are limited to int. | 67 // v8 strings are limited to int. |
67 if (string.length() > INT_MAX) | 68 if (string.length() > INT_MAX) |
68 return -1; | 69 return -1; |
69 | 70 |
70 ScriptForbiddenScope::AllowUserAgentScript allowScript; | 71 Optional<ScriptForbiddenScope::AllowUserAgentScript> allowScript; |
72 if (isMainThread()) | |
73 allowScript.emplace(); | |
haraken
2015/08/27 23:46:40
Would it make sense to move the Optional into Allo
yurys
2015/08/27 23:56:49
Done. I'm not sure what was the reason to have all
| |
71 | 74 |
72 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 75 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
73 v8::HandleScope handleScope(isolate); | 76 v8::HandleScope handleScope(isolate); |
74 v8::Local<v8::Context> context = V8PerIsolateData::from(isolate)->ensureScri ptRegexpContext(); | 77 v8::Local<v8::Context> context = V8PerIsolateData::from(isolate)->ensureScri ptRegexpContext(); |
75 v8::Context::Scope contextScope(context); | 78 v8::Context::Scope contextScope(context); |
76 v8::TryCatch tryCatch; | 79 v8::TryCatch tryCatch; |
77 | 80 |
78 v8::Local<v8::RegExp> regex = m_regex.newLocal(isolate); | 81 v8::Local<v8::RegExp> regex = m_regex.newLocal(isolate); |
79 v8::Local<v8::Value> exec; | 82 v8::Local<v8::Value> exec; |
80 if (!regex->Get(context, v8AtomicString(isolate, "exec")).ToLocal(&exec)) | 83 if (!regex->Get(context, v8AtomicString(isolate, "exec")).ToLocal(&exec)) |
(...skipping 22 matching lines...) Expand all Loading... | |
103 v8::Local<v8::Value> match; | 106 v8::Local<v8::Value> match; |
104 if (!result->Get(context, 0).ToLocal(&match)) | 107 if (!result->Get(context, 0).ToLocal(&match)) |
105 return -1; | 108 return -1; |
106 *matchLength = match.As<v8::String>()->Length(); | 109 *matchLength = match.As<v8::String>()->Length(); |
107 } | 110 } |
108 | 111 |
109 return matchOffset.As<v8::Int32>()->Value() + startFrom; | 112 return matchOffset.As<v8::Int32>()->Value() + startFrom; |
110 } | 113 } |
111 | 114 |
112 } // namespace blink | 115 } // namespace blink |
OLD | NEW |