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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/custom/V8EventTargetCustom.cpp

Issue 1461993002: Make addEventListener/removeEventListener arguments non-optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: drop the use counters Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/custom/V8EventTargetCustom.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8EventTargetCustom.cpp b/third_party/WebKit/Source/bindings/core/v8/custom/V8EventTargetCustom.cpp
index 5852d683bb8b00753f17cc6b1823dba7353127ca..f86d14dcfdf8d4606d48a2802c3eb1bf3b920ce7 100644
--- a/third_party/WebKit/Source/bindings/core/v8/custom/V8EventTargetCustom.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/custom/V8EventTargetCustom.cpp
@@ -41,10 +41,6 @@ namespace {
void addEventListenerMethodPrologueCustom(const v8::FunctionCallbackInfo<v8::Value>& info, EventTarget*)
{
- if (info.Length() < 2) {
- UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionContext(info.GetIsolate()),
- info.Length() == 0 ? UseCounter::AddEventListenerNoArguments : UseCounter::AddEventListenerOneArgument);
- }
if (info.Length() >= 3 && info[2]->IsObject()) {
UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionContext(info.GetIsolate()),
UseCounter::AddEventListenerThirdArgumentIsObject);
@@ -59,10 +55,6 @@ void addEventListenerMethodEpilogueCustom(const v8::FunctionCallbackInfo<v8::Val
void removeEventListenerMethodPrologueCustom(const v8::FunctionCallbackInfo<v8::Value>& info, EventTarget*)
{
- if (info.Length() < 2) {
- UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionContext(info.GetIsolate()),
- info.Length() == 0 ? UseCounter::RemoveEventListenerNoArguments : UseCounter::RemoveEventListenerOneArgument);
- }
if (info.Length() >= 3 && info[2]->IsObject()) {
UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionContext(info.GetIsolate()),
UseCounter::RemoveEventListenerThirdArgumentIsObject);
@@ -80,6 +72,11 @@ void removeEventListenerMethodEpilogueCustom(const v8::FunctionCallbackInfo<v8::
void V8EventTarget::addEventListenerMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "addEventListener", "EventTarget", info.Holder(), info.GetIsolate());
+ if (UNLIKELY(info.Length() < 2)) {
+ setMinimumArityTypeError(exceptionState, 2, info.Length());
+ exceptionState.throwIfNeeded();
+ return;
+ }
EventTarget* impl = V8EventTarget::toImpl(info.Holder());
if (LocalDOMWindow* window = impl->toDOMWindow()) {
if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), window->frame(), exceptionState)) {
@@ -89,22 +86,14 @@ void V8EventTarget::addEventListenerMethodCustom(const v8::FunctionCallbackInfo<
if (!window->document())
return;
}
- V8StringResource<TreatNullAsNullString> type;
+ V8StringResource<> type;
RefPtrWillBeRawPtr<EventListener> listener;
EventListenerOptionsOrBoolean options;
{
- if (!info[0]->IsUndefined()) {
- type = info[0];
- if (!type.prepare())
- return;
- } else {
- type = nullptr;
- }
- if (!info[1]->IsUndefined()) {
- listener = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), info[1], false, ListenerFindOrCreate);
- } else {
- listener = nullptr;
- }
+ type = info[0];
+ if (!type.prepare())
+ return;
+ listener = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), info[1], false, ListenerFindOrCreate);
// TODO(dtapuska): This custom binding code can be eliminated once
// EventListenerOptions runtime enabled feature is removed.
// http://crbug.com/545163
@@ -126,6 +115,11 @@ void V8EventTarget::addEventListenerMethodCustom(const v8::FunctionCallbackInfo<
void V8EventTarget::removeEventListenerMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "removeEventListener", "EventTarget", info.Holder(), info.GetIsolate());
+ if (UNLIKELY(info.Length() < 2)) {
+ setMinimumArityTypeError(exceptionState, 2, info.Length());
+ exceptionState.throwIfNeeded();
+ return;
+ }
EventTarget* impl = V8EventTarget::toImpl(info.Holder());
if (LocalDOMWindow* window = impl->toDOMWindow()) {
if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), callingDOMWindow(info.GetIsolate()), window->frame(), exceptionState)) {
@@ -135,22 +129,14 @@ void V8EventTarget::removeEventListenerMethodCustom(const v8::FunctionCallbackIn
if (!window->document())
return;
}
- V8StringResource<TreatNullAsNullString> type;
+ V8StringResource<> type;
RefPtrWillBeRawPtr<EventListener> listener;
EventListenerOptionsOrBoolean options;
{
- if (!info[0]->IsUndefined()) {
- type = info[0];
- if (!type.prepare())
- return;
- } else {
- type = nullptr;
- }
- if (!info[1]->IsUndefined()) {
- listener = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), info[1], false, ListenerFindOnly);
- } else {
- listener = nullptr;
- }
+ type = info[0];
+ if (!type.prepare())
+ return;
+ listener = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), info[1], false, ListenerFindOnly);
// TODO(dtapuska): This custom binding code can be eliminated once
// EventListenerOptions runtime enabled feature is removed.
// http://crbug.com/545163

Powered by Google App Engine
This is Rietveld 408576698