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

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

Issue 12045033: Adding supported checks & test for SpeechRecognition APIs. (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 d433cbf83736b7a432d4d421767c053c747b93ff..9125cdc5754baccbc9435d68c38a9ed9d94f9e39 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -10086,8 +10086,25 @@ class Event native "*Event" {
//
// Contrary to JS, we default canBubble and cancelable to true, since that's
// what people want most of the time anyway.
- factory Event(String type, [bool canBubble = true, bool cancelable = true]) =>
- _EventFactoryProvider.createEvent(type, canBubble, cancelable);
+ factory Event(String type,
+ [bool canBubble = true, bool cancelable = true]) {
+ return new Event.eventType('Event', type, canBubble, cancelable);
+ }
+
+ /**
+ * Creates a new Event object of the specified type.
+ *
+ * This is analogous to document.createEvent.
+ * Normally events should be created via their constructors, if available.
+ *
+ * var e = new Event.type('MouseEvent', 'mousedown', true, true);
+ */
+ factory Event.eventType(String type, String name, [bool canBubble = true,
+ bool cancelable = true]) {
+ final Event e = document.$dom_createEvent(type);
+ e.$dom_initEvent(name, canBubble, cancelable);
+ return e;
+ }
static const int AT_TARGET = 2;
@@ -20361,14 +20378,15 @@ class SpeechInputResult native "*SpeechInputResult" {
@DomName('SpeechInputResult.utterance')
final String utterance;
}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-
@DocsEditable
@DomName('SpeechRecognition')
+@SupportedBrowser(SupportedBrowser.CHROME, '25')
+@Experimental()
class SpeechRecognition extends EventTarget native "*SpeechRecognition" {
@DocsEditable
@@ -20417,7 +20435,9 @@ class SpeechRecognition extends EventTarget native "*SpeechRecognition" {
@DocsEditable
factory SpeechRecognition() => SpeechRecognition._create();
- static SpeechRecognition _create() => JS('SpeechRecognition', 'new SpeechRecognition()');
+
+ /// Checks if this type is supported on the current platform.
+ static bool get supported => JS('bool', '!!(window.SpeechRecognition || window.webkitSpeechRecognition)');
@DocsEditable
@DomName('EventTarget.addEventListener, EventTarget.removeEventListener, EventTarget.dispatchEvent')
@@ -20514,6 +20534,11 @@ class SpeechRecognition extends EventTarget native "*SpeechRecognition" {
@DocsEditable
@DomName('SpeechRecognition.start')
Stream<Event> get onStart => startEvent.forTarget(this);
+
+ static SpeechRecognition _create() {
+ return JS('SpeechRecognition',
+ 'new (window.SpeechRecognition || window.webkitSpeechRecognition)()');
+ }
}
@DocsEditable
@@ -20562,6 +20587,8 @@ class SpeechRecognitionEvents extends Events {
@DocsEditable
@DomName('SpeechRecognitionAlternative')
+@SupportedBrowser(SupportedBrowser.CHROME, '25')
+@Experimental()
class SpeechRecognitionAlternative native "*SpeechRecognitionAlternative" {
@DocsEditable
@@ -20580,6 +20607,8 @@ class SpeechRecognitionAlternative native "*SpeechRecognitionAlternative" {
@DocsEditable
@DomName('SpeechRecognitionError')
+@SupportedBrowser(SupportedBrowser.CHROME, '25')
+@Experimental()
class SpeechRecognitionError extends Event native "*SpeechRecognitionError" {
@DocsEditable
@@ -20598,6 +20627,8 @@ class SpeechRecognitionError extends Event native "*SpeechRecognitionError" {
@DocsEditable
@DomName('SpeechRecognitionEvent')
+@SupportedBrowser(SupportedBrowser.CHROME, '25')
+@Experimental()
class SpeechRecognitionEvent extends Event native "*SpeechRecognitionEvent" {
@DocsEditable
@@ -20628,6 +20659,8 @@ class SpeechRecognitionEvent extends Event native "*SpeechRecognitionEvent" {
@DocsEditable
@DomName('SpeechRecognitionResult')
+@SupportedBrowser(SupportedBrowser.CHROME, '25')
+@Experimental()
class SpeechRecognitionResult native "*SpeechRecognitionResult" {
@DocsEditable
« 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