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

Side by Side Diff: Source/bindings/v8/ScriptRegexp.cpp

Issue 319753004: Enqueue Blink microtasks using V8's C++ API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Created 6 years, 6 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 | Source/bindings/v8/V8PerIsolateData.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 22 matching lines...) Expand all
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 #include "core/dom/ScriptForbiddenScope.h" 35 #include "core/dom/ScriptForbiddenScope.h"
36 36
37 namespace WebCore { 37 namespace WebCore {
38 38
39 ScriptRegexp::ScriptRegexp(const String& pattern, TextCaseSensitivity caseSensit ivity, MultilineMode multilineMode) 39 ScriptRegexp::ScriptRegexp(const String& pattern, TextCaseSensitivity caseSensit ivity, MultilineMode multilineMode)
40 { 40 {
41 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 41 v8::Isolate* isolate = v8::Isolate::GetCurrent();
42 v8::HandleScope handleScope(isolate); 42 v8::HandleScope handleScope(isolate);
43 v8::Context::Scope contextScope(V8PerIsolateData::from(isolate)->ensureDomIn JSContext()); 43 v8::Context::Scope contextScope(V8PerIsolateData::from(isolate)->ensureScrip tRegexpContext());
44 v8::TryCatch tryCatch; 44 v8::TryCatch tryCatch;
45 45
46 unsigned flags = v8::RegExp::kNone; 46 unsigned flags = v8::RegExp::kNone;
47 if (caseSensitivity == TextCaseInsensitive) 47 if (caseSensitivity == TextCaseInsensitive)
48 flags |= v8::RegExp::kIgnoreCase; 48 flags |= v8::RegExp::kIgnoreCase;
49 if (multilineMode == MultilineEnabled) 49 if (multilineMode == MultilineEnabled)
50 flags |= v8::RegExp::kMultiline; 50 flags |= v8::RegExp::kMultiline;
51 51
52 v8::Local<v8::RegExp> regex = v8::RegExp::New(v8String(isolate, pattern), st atic_cast<v8::RegExp::Flags>(flags)); 52 v8::Local<v8::RegExp> regex = v8::RegExp::New(v8String(isolate, pattern), st atic_cast<v8::RegExp::Flags>(flags));
53 53
(...skipping 11 matching lines...) Expand all
65 return -1; 65 return -1;
66 66
67 // v8 strings are limited to int. 67 // v8 strings are limited to int.
68 if (string.length() > INT_MAX) 68 if (string.length() > INT_MAX)
69 return -1; 69 return -1;
70 70
71 ScriptForbiddenScope::AllowUserAgentScript allowScript; 71 ScriptForbiddenScope::AllowUserAgentScript allowScript;
72 72
73 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 73 v8::Isolate* isolate = v8::Isolate::GetCurrent();
74 v8::HandleScope handleScope(isolate); 74 v8::HandleScope handleScope(isolate);
75 v8::Context::Scope contextScope(V8PerIsolateData::from(isolate)->ensureDomIn JSContext()); 75 v8::Context::Scope contextScope(V8PerIsolateData::from(isolate)->ensureScrip tRegexpContext());
76 v8::TryCatch tryCatch; 76 v8::TryCatch tryCatch;
77 77
78 v8::Local<v8::RegExp> regex = m_regex.newLocal(isolate); 78 v8::Local<v8::RegExp> regex = m_regex.newLocal(isolate);
79 v8::Local<v8::Function> exec = regex->Get(v8AtomicString(isolate, "exec")).A s<v8::Function>(); 79 v8::Local<v8::Function> exec = regex->Get(v8AtomicString(isolate, "exec")).A s<v8::Function>();
80 v8::Handle<v8::Value> argv[] = { v8String(isolate, string.substring(startFro m)) }; 80 v8::Handle<v8::Value> argv[] = { v8String(isolate, string.substring(startFro m)) };
81 v8::Local<v8::Value> returnValue = V8ScriptRunner::callInternalFunction(exec , regex, WTF_ARRAY_LENGTH(argv), argv, isolate); 81 v8::Local<v8::Value> returnValue = V8ScriptRunner::callInternalFunction(exec , regex, WTF_ARRAY_LENGTH(argv), argv, isolate);
82 82
83 if (tryCatch.HasCaught()) 83 if (tryCatch.HasCaught())
84 return -1; 84 return -1;
85 85
(...skipping 12 matching lines...) Expand all
98 int matchOffset = result->Get(v8AtomicString(isolate, "index"))->ToInt32()-> Value(); 98 int matchOffset = result->Get(v8AtomicString(isolate, "index"))->ToInt32()-> Value();
99 if (matchLength) { 99 if (matchLength) {
100 v8::Local<v8::String> match = result->Get(0).As<v8::String>(); 100 v8::Local<v8::String> match = result->Get(0).As<v8::String>();
101 *matchLength = match->Length(); 101 *matchLength = match->Length();
102 } 102 }
103 103
104 return matchOffset + startFrom; 104 return matchOffset + startFrom;
105 } 105 }
106 106
107 } // namespace WebCore 107 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/v8/V8PerIsolateData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698