| 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 21 matching lines...) Expand all Loading... |
| 32 #include "bindings/v8/V8Binding.h" | 32 #include "bindings/v8/V8Binding.h" |
| 33 #include "bindings/v8/V8PerIsolateData.h" | 33 #include "bindings/v8/V8PerIsolateData.h" |
| 34 #include "bindings/v8/V8ScriptRunner.h" | 34 #include "bindings/v8/V8ScriptRunner.h" |
| 35 | 35 |
| 36 namespace WebCore { | 36 namespace WebCore { |
| 37 | 37 |
| 38 ScriptRegexp::ScriptRegexp(const String& pattern, TextCaseSensitivity caseSensit
ivity, MultilineMode multilineMode) | 38 ScriptRegexp::ScriptRegexp(const String& pattern, TextCaseSensitivity caseSensit
ivity, MultilineMode multilineMode) |
| 39 { | 39 { |
| 40 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 40 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 41 v8::HandleScope handleScope(isolate); | 41 v8::HandleScope handleScope(isolate); |
| 42 v8::Context::Scope contextScope(V8PerIsolateData::from(isolate)->ensureDomIn
JSContext()); | 42 v8::Local<v8::Context> context = V8PerIsolateData::from(isolate)->ensureDomI
nJSContext(); |
| 43 if (context.IsEmpty()) { |
| 44 // The script execution is terminated. |
| 45 return; |
| 46 } |
| 47 v8::Context::Scope contextScope(context); |
| 43 v8::TryCatch tryCatch; | 48 v8::TryCatch tryCatch; |
| 44 | 49 |
| 45 unsigned flags = v8::RegExp::kNone; | 50 unsigned flags = v8::RegExp::kNone; |
| 46 if (caseSensitivity == TextCaseInsensitive) | 51 if (caseSensitivity == TextCaseInsensitive) |
| 47 flags |= v8::RegExp::kIgnoreCase; | 52 flags |= v8::RegExp::kIgnoreCase; |
| 48 if (multilineMode == MultilineEnabled) | 53 if (multilineMode == MultilineEnabled) |
| 49 flags |= v8::RegExp::kMultiline; | 54 flags |= v8::RegExp::kMultiline; |
| 50 | 55 |
| 51 v8::Local<v8::RegExp> regex = v8::RegExp::New(v8String(isolate, pattern), st
atic_cast<v8::RegExp::Flags>(flags)); | 56 v8::Local<v8::RegExp> regex = v8::RegExp::New(v8String(isolate, pattern), st
atic_cast<v8::RegExp::Flags>(flags)); |
| 52 | 57 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 int matchOffset = result->Get(v8AtomicString(isolate, "index"))->ToInt32()->
Value(); | 96 int matchOffset = result->Get(v8AtomicString(isolate, "index"))->ToInt32()->
Value(); |
| 92 if (matchLength) { | 97 if (matchLength) { |
| 93 v8::Local<v8::String> match = result->Get(0).As<v8::String>(); | 98 v8::Local<v8::String> match = result->Get(0).As<v8::String>(); |
| 94 *matchLength = match->Length(); | 99 *matchLength = match->Length(); |
| 95 } | 100 } |
| 96 | 101 |
| 97 return matchOffset + startFrom; | 102 return matchOffset + startFrom; |
| 98 } | 103 } |
| 99 | 104 |
| 100 } // namespace WebCore | 105 } // namespace WebCore |
| OLD | NEW |