Refactor JSNumber.toDart and Object.toJS (#129436)
JSNumber.toDart will now be two functions: toDartDouble and toDartInt.
There was code that did an Object.toJS. This has been changed to
use Function.toJS as well to make it consistent with the code
in flutter/packages:
0ef393811d/packages/web_benchmarks/lib/src/recorder.dart (L1223)
This is to help land this CL:
https://dart-review.googlesource.com/c/sdk/+/309082
https://dart-review.googlesource.com/c/sdk/+/309081 is the CL that added
the new methods.
## Pre-launch Checklist
- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [X] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [X] I signed the [CLA].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.
This commit is contained in:
parent
a189d95ac2
commit
ab39bff282
@ -1336,9 +1336,7 @@ void registerEngineBenchmarkValueListener(String name, EngineBenchmarkValueListe
|
|||||||
if (_engineBenchmarkListeners.isEmpty) {
|
if (_engineBenchmarkListeners.isEmpty) {
|
||||||
// The first listener is being registered. Register the global listener.
|
// The first listener is being registered. Register the global listener.
|
||||||
web.window['_flutter_internal_on_benchmark'.toJS] =
|
web.window['_flutter_internal_on_benchmark'.toJS] =
|
||||||
// Upcast to [Object] to export.
|
_dispatchEngineBenchmarkValue.toJS;
|
||||||
// ignore: unnecessary_cast
|
|
||||||
(_dispatchEngineBenchmarkValue as Object).toJS;
|
|
||||||
}
|
}
|
||||||
_engineBenchmarkListeners[name] = listener;
|
_engineBenchmarkListeners[name] = listener;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ extension DomXMLHttpRequestExtension on DomXMLHttpRequest {
|
|||||||
external JSNumber? get _status;
|
external JSNumber? get _status;
|
||||||
|
|
||||||
/// Gets the status.
|
/// Gets the status.
|
||||||
int? get status => _status?.toDart.toInt();
|
int? get status => _status?.toDartInt;
|
||||||
|
|
||||||
@JS('responseType')
|
@JS('responseType')
|
||||||
external set _responseType(JSString value);
|
external set _responseType(JSString value);
|
||||||
@ -184,13 +184,13 @@ extension DomProgressEventExtension on DomProgressEvent {
|
|||||||
external JSNumber? get _loaded;
|
external JSNumber? get _loaded;
|
||||||
|
|
||||||
/// Amount of work done.
|
/// Amount of work done.
|
||||||
int? get loaded => _loaded?.toDart.toInt();
|
int? get loaded => _loaded?.toDartInt;
|
||||||
|
|
||||||
@JS('total')
|
@JS('total')
|
||||||
external JSNumber? get _total;
|
external JSNumber? get _total;
|
||||||
|
|
||||||
/// Total amount of work.
|
/// Total amount of work.
|
||||||
int? get total => _total?.toDart.toInt();
|
int? get total => _total?.toDartInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The underlying DOM document.
|
/// The underlying DOM document.
|
||||||
@ -291,19 +291,19 @@ extension DomMouseEventExtension on DomMouseEvent {
|
|||||||
external JSNumber get _offsetX;
|
external JSNumber get _offsetX;
|
||||||
|
|
||||||
/// Returns the current x offset.
|
/// Returns the current x offset.
|
||||||
num get offsetX => _offsetX.toDart;
|
num get offsetX => _offsetX.toDartDouble;
|
||||||
|
|
||||||
@JS('offsetY')
|
@JS('offsetY')
|
||||||
external JSNumber get _offsetY;
|
external JSNumber get _offsetY;
|
||||||
|
|
||||||
/// Returns the current y offset.
|
/// Returns the current y offset.
|
||||||
num get offsetY => _offsetY.toDart;
|
num get offsetY => _offsetY.toDartDouble;
|
||||||
|
|
||||||
@JS('button')
|
@JS('button')
|
||||||
external JSNumber get _button;
|
external JSNumber get _button;
|
||||||
|
|
||||||
/// Returns the current button.
|
/// Returns the current button.
|
||||||
int get button => _button.toDart.toInt();
|
int get button => _button.toDartInt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A DOM selection.
|
/// A DOM selection.
|
||||||
@ -394,9 +394,9 @@ extension DomCSSStyleSheetExtension on DomCSSStyleSheet {
|
|||||||
/// Inserts a rule into this style sheet.
|
/// Inserts a rule into this style sheet.
|
||||||
int insertRule(String rule, [int? index]) {
|
int insertRule(String rule, [int? index]) {
|
||||||
if (index == null) {
|
if (index == null) {
|
||||||
return _insertRule1(rule.toJS).toDart.toInt();
|
return _insertRule1(rule.toJS).toDartInt;
|
||||||
} else {
|
} else {
|
||||||
return _insertRule2(rule.toJS, index.toDouble().toJS).toDart.toInt();
|
return _insertRule2(rule.toJS, index.toJS).toDartInt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,6 @@ class TestHttpRequest {
|
|||||||
setRequestHeader: setRequestHeader.toJS,
|
setRequestHeader: setRequestHeader.toJS,
|
||||||
addEventListener: addEventListener.toJS,
|
addEventListener: addEventListener.toJS,
|
||||||
);
|
);
|
||||||
// TODO(srujzs): This is needed for when we reify JS types. Right now, JSAny
|
|
||||||
// is a typedef for Object?, but when we reify, it'll be its own type.
|
|
||||||
final JSAny mock = _mock as JSAny;
|
final JSAny mock = _mock as JSAny;
|
||||||
createGetter(mock, 'headers', () => headers.jsify());
|
createGetter(mock, 'headers', () => headers.jsify());
|
||||||
createGetter(mock,
|
createGetter(mock,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user