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

Unified Diff: sky/engine/bindings/dart_event_listener.cc

Issue 937443002: Throw exception for null listener in addEventListener (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/bindings/dart_event_listener.h ('k') | sky/engine/tonic/dart_exception_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/bindings/dart_event_listener.cc
diff --git a/sky/engine/bindings/dart_event_listener.cc b/sky/engine/bindings/dart_event_listener.cc
index 8f3835a09933605ef4222362411a4c9ddc911905..2c16f656c8efe62938fc3b3b3985d2cbf725984c 100644
--- a/sky/engine/bindings/dart_event_listener.cc
+++ b/sky/engine/bindings/dart_event_listener.cc
@@ -8,6 +8,7 @@
#include "sky/engine/core/events/Event.h"
#include "sky/engine/tonic/dart_api_scope.h"
#include "sky/engine/tonic/dart_error.h"
+#include "sky/engine/tonic/dart_exception_factory.h"
#include "sky/engine/tonic/dart_gc_visitor.h"
#include "sky/engine/tonic/dart_isolate_scope.h"
@@ -66,4 +67,18 @@ void DartEventListener::Finalize(void* isolate_callback_data,
listener->deref(); // Balances ref in DartEventListener::DartEventListener
}
+PassRefPtr<EventListener>
+DartConverter<EventListener*>::FromArgumentsWithNullCheck(
+ Dart_NativeArguments args,
+ int index,
+ Dart_Handle& exception) {
+ Dart_Handle handle = Dart_GetNativeArgument(args, index);
+ if (Dart_IsNull(handle)) {
+ DartState* state = DartState::Current();
+ exception = state->exception_factory().CreateNullArgumentException(index);
+ return nullptr;
+ }
+ return FromDart(handle);
+}
+
} // namespace blink
« no previous file with comments | « sky/engine/bindings/dart_event_listener.h ('k') | sky/engine/tonic/dart_exception_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698