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

Unified Diff: sdk/lib/html/templates/html/dart2js/impl_KeyboardEvent.darttemplate

Issue 11299267: Fixed up signature for initKeyEvent vs initKeyboardEvent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: refactor Created 8 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
« no previous file with comments | « sdk/lib/html/src/KeyboardEventController.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/templates/html/dart2js/impl_KeyboardEvent.darttemplate
diff --git a/sdk/lib/html/templates/html/dart2js/impl_KeyboardEvent.darttemplate b/sdk/lib/html/templates/html/dart2js/impl_KeyboardEvent.darttemplate
index 414cc1db2959d6fb931af1d5a04de103c17888e5..16ba7beae9665f69df314c638d0480c62918a17e 100644
--- a/sdk/lib/html/templates/html/dart2js/impl_KeyboardEvent.darttemplate
+++ b/sdk/lib/html/templates/html/dart2js/impl_KeyboardEvent.darttemplate
@@ -21,13 +21,20 @@ class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
void $dom_initKeyboardEvent(String type, bool canBubble, bool cancelable,
LocalWindow view, String keyIdentifier, int keyLocation, bool ctrlKey,
bool altKey, bool shiftKey, bool metaKey, bool altGraphKey) {
- // initKeyEvent is the call in Firefox, initKeyboardEvent for all other
- // browsers.
- var function = JS('dynamic', '#.initKeyboardEvent || #.initKeyEvent', this,
- this);
- JS('void', '#(#, #, #, #, #, #, #, #, #, #, #)', function, type,
- canBubble, cancelable, view, keyIdentifier, keyLocation, ctrlKey,
- altKey, shiftKey, metaKey, altGraphKey);
+ if (JS('bool', 'typeof(#.initKeyEvent) == "function"', this)) {
+ // initKeyEvent is only in Firefox (instead of initKeyboardEvent). It has
+ // a slightly different signature, and allows you to specify keyCode and
+ // charCode as the last two arguments, but we just set them as the default
+ // since they can't be specified in other browsers.
+ JS('void', '#.initKeyEvent(#, #, #, #, #, #, #, #, 0, 0)', this,
+ type, canBubble, cancelable, view,
+ ctrlKey, altKey, shiftKey, metaKey);
+ } else {
+ // initKeyboardEvent is for all other browsers.
+ JS('void', '#.initKeyboardEvent(#, #, #, #, #, #, #, #, #, #, #)', this,
+ type, canBubble, cancelable, view, keyIdentifier, keyLocation,
+ ctrlKey, altKey, shiftKey, metaKey, altGraphKey);
+ }
}
/** @domName KeyboardEvent.keyCode */
« no previous file with comments | « sdk/lib/html/src/KeyboardEventController.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698