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

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 12047020: Adding supported checks to media events (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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:
Download patch
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 6276aa70662e848dcf08f2e26ffed8a334f8b82f..bae41db443dca3963761172b3b30db0834e7b873 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -10199,6 +10199,18 @@ class Event native "*Event" {
@DomName('Event.stopPropagation')
void stopPropagation() native;
+
+ /**
+ * Checks to see if the event class is supported by the current platform.
+ */
+ static bool _isTypeSupported(String eventType) {
+ // Browsers throw for unsupported event names.
+ try {
+ var e = document.$dom_createEvent(eventType);
+ return e is Event;
+ } catch (_) { }
+ return false;
+ }
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
@@ -15826,6 +15838,9 @@ class MediaStreamEvents extends Events {
@DomName('MediaStreamEvent')
class MediaStreamEvent extends Event native "*MediaStreamEvent" {
+ /// Checks if this type is supported on the current platform.
+ static bool get supported => Event._isTypeSupported('MediaStreamEvent');
+
@DocsEditable
@DomName('MediaStreamEvent.stream')
final MediaStream stream;
@@ -15935,6 +15950,9 @@ class MediaStreamTrackEvents extends Events {
@DomName('MediaStreamTrackEvent')
class MediaStreamTrackEvent extends Event native "*MediaStreamTrackEvent" {
+ /// Checks if this type is supported on the current platform.
+ static bool get supported => Event._isTypeSupported('MediaStreamTrackEvent');
+
@DocsEditable
@DomName('MediaStreamTrackEvent.track')
final MediaStreamTrack track;
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698