| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 5 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 6 $!MEMBERS | 6 $!MEMBERS |
| 7 | 7 |
| 8 int get offsetX { | 8 int get offsetX { |
| 9 if (JS('bool', '!!#.offsetX', this)) { | 9 if (JS('bool', '!!#.offsetX', this)) { |
| 10 return JS('int', '#.offsetX', this); | 10 return JS('int', '#.offsetX', this); |
| 11 } else { | 11 } else { |
| 12 // Firefox does not support offsetX. | 12 // Firefox does not support offsetX. |
| 13 var target = this.target; | 13 var target = this.target; |
| 14 if (!(target is Element)) { | 14 if (!(target is Element)) { |
| 15 throw const UnsupportedOperationException( | 15 throw new UnsupportedError( |
| 16 'offsetX is only supported on elements'); | 16 'offsetX is only supported on elements'); |
| 17 } | 17 } |
| 18 return this.clientX - this.target.getBoundingClientRect().left; | 18 return this.clientX - this.target.getBoundingClientRect().left; |
| 19 } | 19 } |
| 20 } | 20 } |
| 21 | 21 |
| 22 int get offsetY { | 22 int get offsetY { |
| 23 if (JS('bool', '!!#.offsetY', this)) { | 23 if (JS('bool', '!!#.offsetY', this)) { |
| 24 return JS('int', '#.offsetY', this); | 24 return JS('int', '#.offsetY', this); |
| 25 } else { | 25 } else { |
| 26 // Firefox does not support offsetY. | 26 // Firefox does not support offsetY. |
| 27 var target = this.target; | 27 var target = this.target; |
| 28 if (!(target is Element)) { | 28 if (!(target is Element)) { |
| 29 throw const UnsupportedOperationException( | 29 throw new UnsupportedError( |
| 30 'offsetY is only supported on elements'); | 30 'offsetY is only supported on elements'); |
| 31 } | 31 } |
| 32 return this.clientY - this.target.getBoundingClientRect().top; | 32 return this.clientY - this.target.getBoundingClientRect().top; |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 } | 35 } |
| OLD | NEW |