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

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

Side-by-side diff isn't available for this file because of its large size.
Issue 10867073: Adding polyfills for MouseEvent.offsetX and MouseEvent.offsetY so they work on FF. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding doc comments and unit test.wq Created 8 years, 3 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
Index: lib/html/dart2js/html_dart2js.dart
diff --git a/lib/html/dart2js/html_dart2js.dart b/lib/html/dart2js/html_dart2js.dart
index 078bc328e3988728cf0d4a5de934e6ba373ca5b5..9d32b79496dea32d40033f5de97bdf0fdd4e6455 100644
--- a/lib/html/dart2js/html_dart2js.dart
+++ b/lib/html/dart2js/html_dart2js.dart
@@ -9650,6 +9650,9 @@ class _ModElementImpl extends _ElementImpl implements ModElement native "*HTMLMo
String dateTime;
}
+// 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
+// BSD-style license that can be found in the LICENSE file.
class _MouseEventImpl extends _UIEventImpl implements MouseEvent native "*MouseEvent" {
@@ -9669,10 +9672,6 @@ class _MouseEventImpl extends _UIEventImpl implements MouseEvent native "*MouseE
final bool metaKey;
- final int offsetX;
-
- final int offsetY;
-
final _EventTargetImpl relatedTarget;
final int screenX;
@@ -9692,6 +9691,38 @@ class _MouseEventImpl extends _UIEventImpl implements MouseEvent native "*MouseE
final int y;
void $dom_initMouseEvent(String type, bool canBubble, bool cancelable, _WindowImpl view, int detail, int screenX, int screenY, int clientX, int clientY, bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, int button, _EventTargetImpl relatedTarget) native "initMouseEvent";
+
+
+ int get offsetX() {
+ if (JS('bool', '!!this.offsetX')) {
+ return this._offsetX;
+ } else {
+ // Firefox does not support offsetX.
+ var target = this.target;
+ if (!(target is Element)) {
+ throw const UnsupportedOperationException(
+ 'offsetX is only supported on elements');
+ }
+ return this.clientX - this.target.$dom_getBoundingClientRect().left;
+ }
+ }
+
+ int get offsetY() {
+ if (JS('bool', '!!this.offsetY')) {
+ return this._offsetY;
+ } else {
+ // Firefox does not support offsetY.
+ var target = this.target;
+ if (!(target is Element)) {
+ throw const UnsupportedOperationException(
+ 'offsetX is only supported on elements');
+ }
+ return this.clientY - this.target.$dom_getBoundingClientRect().top;
+ }
+ }
+
+ int get _offsetX() native 'return this.offsetX';
+ int get _offsetY() native 'return this.offsetY';
}
class _MutationEventImpl extends _EventImpl implements MutationEvent native "*MutationEvent" {
« no previous file with comments | « lib/dom/templates/html/dart2js/impl_MouseEvent.darttemplate ('k') | lib/html/doc/interface/MouseEvent.dartdoc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698