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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptRegexp.cpp

Issue 1805343002: Add unicode flag to blink::ScriptRegexp, and measure incompatibility for |pattern| content attribut… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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 17 matching lines...) Expand all
28 28
29 #include "bindings/core/v8/ScriptRegexp.h" 29 #include "bindings/core/v8/ScriptRegexp.h"
30 30
31 #include "bindings/core/v8/V8Binding.h" 31 #include "bindings/core/v8/V8Binding.h"
32 #include "bindings/core/v8/V8PerIsolateData.h" 32 #include "bindings/core/v8/V8PerIsolateData.h"
33 #include "bindings/core/v8/V8ScriptRunner.h" 33 #include "bindings/core/v8/V8ScriptRunner.h"
34 #include "platform/ScriptForbiddenScope.h" 34 #include "platform/ScriptForbiddenScope.h"
35 35
36 namespace blink { 36 namespace blink {
37 37
38 ScriptRegexp::ScriptRegexp(const String& pattern, TextCaseSensitivity caseSensit ivity, MultilineMode multilineMode) 38 ScriptRegexp::ScriptRegexp(const String& pattern, TextCaseSensitivity caseSensit ivity, MultilineMode multilineMode, CharacterMode charMode)
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::Local<v8::Context> context = V8PerIsolateData::from(isolate)->ensureScri ptRegexpContext(); 42 v8::Local<v8::Context> context = V8PerIsolateData::from(isolate)->ensureScri ptRegexpContext();
43 v8::Context::Scope contextScope(context); 43 v8::Context::Scope contextScope(context);
44 v8::TryCatch tryCatch(isolate); 44 v8::TryCatch tryCatch(isolate);
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 if (charMode == UTF16)
52 flags |= v8::RegExp::kUnicode;
51 53
52 v8::Local<v8::RegExp> regex; 54 v8::Local<v8::RegExp> regex;
53 if (v8::RegExp::New(context, v8String(isolate, pattern), static_cast<v8::Reg Exp::Flags>(flags)).ToLocal(&regex)) 55 if (v8::RegExp::New(context, v8String(isolate, pattern), static_cast<v8::Reg Exp::Flags>(flags)).ToLocal(&regex))
54 m_regex.set(isolate, regex); 56 m_regex.set(isolate, regex);
55 } 57 }
56 58
57 int ScriptRegexp::match(const String& string, int startFrom, int* matchLength) c onst 59 int ScriptRegexp::match(const String& string, int startFrom, int* matchLength) c onst
58 { 60 {
59 if (matchLength) 61 if (matchLength)
60 *matchLength = 0; 62 *matchLength = 0;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 v8::Local<v8::Value> match; 104 v8::Local<v8::Value> match;
103 if (!result->Get(context, 0).ToLocal(&match)) 105 if (!result->Get(context, 0).ToLocal(&match))
104 return -1; 106 return -1;
105 *matchLength = match.As<v8::String>()->Length(); 107 *matchLength = match.As<v8::String>()->Length();
106 } 108 }
107 109
108 return matchOffset.As<v8::Int32>()->Value() + startFrom; 110 return matchOffset.As<v8::Int32>()->Value() + startFrom;
109 } 111 }
110 112
111 } // namespace blink 113 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptRegexp.h ('k') | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698