diff --git a/sdk/lib/_internal/js_dev_runtime/private/foreign_helper.dart b/sdk/lib/_internal/js_dev_runtime/private/foreign_helper.dart index 02e5c24cd99..588d789c231 100644 --- a/sdk/lib/_internal/js_dev_runtime/private/foreign_helper.dart +++ b/sdk/lib/_internal/js_dev_runtime/private/foreign_helper.dart @@ -106,10 +106,7 @@ library dart._foreign_helper; */ // Add additional optional arguments if needed. The method is treated internally // as a variable argument method. -// TODO(vsm): Enforce that this doesn't fall back to dynamic by typing it as: -// `T JS(...)` -// once we clean up html libraries. -T JS(String typeDescription, String codeTemplate, +T JS(String typeDescription, String codeTemplate, [arg0, arg1, arg2, diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart index 5de4de4425e..8dc677d4ee4 100644 --- a/sdk/lib/html/dart2js/html_dart2js.dart +++ b/sdk/lib/html/dart2js/html_dart2js.dart @@ -13273,28 +13273,28 @@ class Element extends Node final Element offsetParent; - int get offsetHeight => JS('num', '#.offsetHeight', this).round(); + int get offsetHeight => JS('num', '#.offsetHeight', this).round(); - int get offsetLeft => JS('num', '#.offsetLeft', this).round(); + int get offsetLeft => JS('num', '#.offsetLeft', this).round(); - int get offsetTop => JS('num', '#.offsetTop', this).round(); + int get offsetTop => JS('num', '#.offsetTop', this).round(); - int get offsetWidth => JS('num', '#.offsetWidth', this).round(); + int get offsetWidth => JS('num', '#.offsetWidth', this).round(); - int get scrollHeight => JS('num', '#.scrollHeight', this).round(); - int get scrollLeft => JS('num', '#.scrollLeft', this).round(); + int get scrollHeight => JS('num', '#.scrollHeight', this).round(); + int get scrollLeft => JS('num', '#.scrollLeft', this).round(); set scrollLeft(int value) { JS("void", "#.scrollLeft = #", this, value.round()); } - int get scrollTop => JS('num', '#.scrollTop', this).round(); + int get scrollTop => JS('num', '#.scrollTop', this).round(); set scrollTop(int value) { JS("void", "#.scrollTop = #", this, value.round()); } - int get scrollWidth => JS('num', '#.scrollWidth', this).round(); + int get scrollWidth => JS('num', '#.scrollWidth', this).round(); // To suppress missing implicit constructor warnings. factory Element._() { @@ -28848,14 +28848,14 @@ class Touch extends Interceptor { // As of Chrome 37, these all changed from long to double. This code // preserves backwards compatibility for the time being. - int get __clientX => JS('num', '#.clientX', this).round(); - int get __clientY => JS('num', '#.clientY', this).round(); - int get __screenX => JS('num', '#.screenX', this).round(); - int get __screenY => JS('num', '#.screenY', this).round(); - int get __pageX => JS('num', '#.pageX', this).round(); - int get __pageY => JS('num', '#.pageY', this).round(); - int get __radiusX => JS('num', '#.radiusX', this).round(); - int get __radiusY => JS('num', '#.radiusY', this).round(); + int get __clientX => JS('num', '#.clientX', this).round(); + int get __clientY => JS('num', '#.clientY', this).round(); + int get __screenX => JS('num', '#.screenX', this).round(); + int get __screenY => JS('num', '#.screenY', this).round(); + int get __pageX => JS('num', '#.pageX', this).round(); + int get __pageY => JS('num', '#.pageY', this).round(); + int get __radiusX => JS('num', '#.radiusX', this).round(); + int get __radiusY => JS('num', '#.radiusY', this).round(); Point get client => new Point(__clientX, __clientY); @@ -30617,8 +30617,11 @@ class Window extends EventTarget void _cancelAnimationFrame(int id) native; _ensureRequestAnimationFrame() { - if (JS('bool', '!!(#.requestAnimationFrame && #.cancelAnimationFrame)', - this, this)) return; + if (JS( + 'bool', + '!!(#.requestAnimationFrame && #.cancelAnimationFrame)', + this, + this)) return; JS( 'void', @@ -32110,9 +32113,9 @@ class Window extends EventTarget return db; } - int get pageXOffset => JS('num', '#.pageXOffset', this).round(); + int get pageXOffset => JS('num', '#.pageXOffset', this).round(); - int get pageYOffset => JS('num', '#.pageYOffset', this).round(); + int get pageYOffset => JS('num', '#.pageYOffset', this).round(); /** * The distance this window has been scrolled horizontally. @@ -32124,8 +32127,8 @@ class Window extends EventTarget * * [scrollX](https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollX) * from MDN. */ - int get scrollX => JS('bool', '("scrollX" in #)', this) - ? JS('num', '#.scrollX', this).round() + int get scrollX => JS('bool', '("scrollX" in #)', this) + ? JS('num', '#.scrollX', this).round() : document.documentElement.scrollLeft; /** @@ -32138,8 +32141,8 @@ class Window extends EventTarget * * [scrollY](https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollY) * from MDN. */ - int get scrollY => JS('bool', '("scrollY" in #)', this) - ? JS('num', '#.scrollY', this).round() + int get scrollY => JS('bool', '("scrollY" in #)', this) + ? JS('num', '#.scrollY', this).round() : document.documentElement.scrollTop; } @@ -32154,7 +32157,7 @@ class _BeforeUnloadEvent extends _WrappedEvent implements BeforeUnloadEvent { _returnValue = value; // FF and IE use the value as the return value, Chrome will return this from // the event callback function. - if (JS('bool', '("returnValue" in #)', wrapped)) { + if (JS('bool', '("returnValue" in #)', wrapped)) { JS('void', '#.returnValue = #', wrapped, value); } } diff --git a/sdk/lib/html/html_common/conversions.dart b/sdk/lib/html/html_common/conversions.dart index f2373b50d90..a563c050798 100644 --- a/sdk/lib/html/html_common/conversions.dart +++ b/sdk/lib/html/html_common/conversions.dart @@ -237,9 +237,9 @@ abstract class _AcceptStructuredClone { } if (isJavaScriptArray(e)) { - var l = JS('returns:List;creates:;', '#', e); + var l = JS('returns:List;creates:;', '#', e); var slot = findSlot(l); - var copy = JS('returns:List|Null;creates:;', '#', readSlot(slot)); + var copy = JS('returns:List|Null;creates:;', '#', readSlot(slot)); if (copy != null) return copy; int length = l.length; diff --git a/tests/compiler/dart2js/analyses/api_allowed.json b/tests/compiler/dart2js/analyses/api_allowed.json index a97e98f44ef..9a02f59ef79 100644 --- a/tests/compiler/dart2js/analyses/api_allowed.json +++ b/tests/compiler/dart2js/analyses/api_allowed.json @@ -87,7 +87,6 @@ "Dynamic access of 'firstChild'.": 2, "Dynamic invocation of 'append'.": 1, "Dynamic access of 'tagName'.": 2, - "Dynamic invocation of 'round'.": 20, "Dynamic invocation of 'call'.": 1, "Dynamic invocation of 'dart.dom.html::_initKeyboardEvent'.": 1, "Dynamic access of 'attributes'.": 1, @@ -99,9 +98,7 @@ "Dynamic invocation of 'createElement'.": 1 }, "org-dartlang-sdk:///sdk/lib/html/html_common/conversions.dart": { - "Dynamic invocation of '[]='.": 2, - "Dynamic access of 'length'.": 1, - "Dynamic invocation of '[]'.": 1 + "Dynamic invocation of '[]='.": 1 }, "org-dartlang-sdk:///sdk/lib/html/html_common/filtered_element_list.dart": { "Dynamic invocation of 'remove'.": 1 diff --git a/tools/dom/templates/html/impl/impl_Element.darttemplate b/tools/dom/templates/html/impl/impl_Element.darttemplate index 2786eee3696..8783228c015 100644 --- a/tools/dom/templates/html/impl/impl_Element.darttemplate +++ b/tools/dom/templates/html/impl/impl_Element.darttemplate @@ -1492,28 +1492,28 @@ $(ANNOTATIONS)$(NATIVESPEC)class $CLASSNAME$EXTENDS$IMPLEMENTS { final Element offsetParent; - int get offsetHeight => JS('num', '#.offsetHeight', this).round(); + int get offsetHeight => JS('num', '#.offsetHeight', this).round(); - int get offsetLeft => JS('num', '#.offsetLeft', this).round(); + int get offsetLeft => JS('num', '#.offsetLeft', this).round(); - int get offsetTop => JS('num', '#.offsetTop', this).round(); + int get offsetTop => JS('num', '#.offsetTop', this).round(); - int get offsetWidth => JS('num', '#.offsetWidth', this).round(); + int get offsetWidth => JS('num', '#.offsetWidth', this).round(); - int get scrollHeight => JS('num', '#.scrollHeight', this).round(); - int get scrollLeft => JS('num', '#.scrollLeft', this).round(); + int get scrollHeight => JS('num', '#.scrollHeight', this).round(); + int get scrollLeft => JS('num', '#.scrollLeft', this).round(); set scrollLeft(int value) { JS("void", "#.scrollLeft = #", this, value.round()); } - int get scrollTop => JS('num', '#.scrollTop', this).round(); + int get scrollTop => JS('num', '#.scrollTop', this).round(); set scrollTop(int value) { JS("void", "#.scrollTop = #", this, value.round()); } - int get scrollWidth => JS('num', '#.scrollWidth', this).round(); + int get scrollWidth => JS('num', '#.scrollWidth', this).round(); $!MEMBERS } diff --git a/tools/dom/templates/html/impl/impl_Touch.darttemplate b/tools/dom/templates/html/impl/impl_Touch.darttemplate index ef3b5c29a03..2d84399b62d 100644 --- a/tools/dom/templates/html/impl/impl_Touch.darttemplate +++ b/tools/dom/templates/html/impl/impl_Touch.darttemplate @@ -9,14 +9,14 @@ $!MEMBERS // As of Chrome 37, these all changed from long to double. This code // preserves backwards compatibility for the time being. - int get __clientX => JS('num', '#.clientX', this).round(); - int get __clientY => JS('num', '#.clientY', this).round(); - int get __screenX => JS('num', '#.screenX', this).round(); - int get __screenY => JS('num', '#.screenY', this).round(); - int get __pageX => JS('num', '#.pageX', this).round(); - int get __pageY => JS('num', '#.pageY', this).round(); - int get __radiusX => JS('num', '#.radiusX', this).round(); - int get __radiusY => JS('num', '#.radiusY', this).round(); + int get __clientX => JS('num', '#.clientX', this).round(); + int get __clientY => JS('num', '#.clientY', this).round(); + int get __screenX => JS('num', '#.screenX', this).round(); + int get __screenY => JS('num', '#.screenY', this).round(); + int get __pageX => JS('num', '#.pageX', this).round(); + int get __pageY => JS('num', '#.pageY', this).round(); + int get __radiusX => JS('num', '#.radiusX', this).round(); + int get __radiusY => JS('num', '#.radiusY', this).round(); Point get client => new Point(__clientX, __clientY); diff --git a/tools/dom/templates/html/impl/impl_Window.darttemplate b/tools/dom/templates/html/impl/impl_Window.darttemplate index ec7d83cbea8..9553f4a3d2d 100644 --- a/tools/dom/templates/html/impl/impl_Window.darttemplate +++ b/tools/dom/templates/html/impl/impl_Window.darttemplate @@ -129,7 +129,7 @@ $(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS { void _cancelAnimationFrame(int id) native; _ensureRequestAnimationFrame() { - if (JS('bool', + if (JS('bool', '!!(#.requestAnimationFrame && #.cancelAnimationFrame)', this, this)) return; @@ -241,9 +241,9 @@ $!MEMBERS return db; } - int get pageXOffset => JS('num', '#.pageXOffset', this).round(); + int get pageXOffset => JS('num', '#.pageXOffset', this).round(); - int get pageYOffset => JS('num', '#.pageYOffset', this).round(); + int get pageYOffset => JS('num', '#.pageYOffset', this).round(); /** * The distance this window has been scrolled horizontally. @@ -255,8 +255,8 @@ $!MEMBERS * * [scrollX](https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollX) * from MDN. */ - int get scrollX => JS('bool', '("scrollX" in #)', this) ? - JS('num', '#.scrollX', this).round() : + int get scrollX => JS('bool', '("scrollX" in #)', this) ? + JS('num', '#.scrollX', this).round() : document.documentElement.scrollLeft; /** @@ -269,8 +269,8 @@ $!MEMBERS * * [scrollY](https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollY) * from MDN. */ - int get scrollY => JS('bool', '("scrollY" in #)', this) ? - JS('num', '#.scrollY', this).round() : + int get scrollY => JS('bool', '("scrollY" in #)', this) ? + JS('num', '#.scrollY', this).round() : document.documentElement.scrollTop; } @@ -285,7 +285,7 @@ class _BeforeUnloadEvent extends _WrappedEvent implements BeforeUnloadEvent { _returnValue = value; // FF and IE use the value as the return value, Chrome will return this from // the event callback function. - if (JS('bool', '("returnValue" in #)', wrapped)) { + if (JS('bool', '("returnValue" in #)', wrapped)) { JS('void', '#.returnValue = #', wrapped, value); } }