Skip to content

Commit

Permalink
Refactor JSNumber.toDart and Object.toJS (#43149)
Browse files Browse the repository at this point in the history
JSNumber.toDart will now be two functions: toDartDouble and toDartInt.
Note that some code that looks like `toDart.toInt()` was kept as
`toDartDouble.toInt()` instead of `toDartInt`, since `toDartInt` throws
if the value is not an integer.

Object.toJS is now Object.toJSBox. An actual box is introduced on all
backends now, and is unwrapped in JSBoxedDartObject.toDart. There are
many usages of toJSAnyShallow that we should modify, but that's for a
later CL.

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] and the [C++,
Objective-C, Java style guides].
- [X] I listed at least one issue that this PR fixes in the description
above.
- [ ] I added new tests to check the change I am making or feature I am
adding, or Hixie said the PR is test-exempt. See [testing the engine]
for instructions on writing and running engine tests.
- [X] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.
  • Loading branch information
srujzs committed Jun 26, 2023
1 parent e32f60a commit 715eff2
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 173 deletions.
144 changes: 72 additions & 72 deletions lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/web_ui/lib/src/engine/canvaskit/image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ Future<Uint8List> readChunked(HttpFetchPayload payload, int contentLength, WebOn
int position = 0;
int cumulativeBytesLoaded = 0;
await payload.read<JSUint8Array1>((JSUint8Array1 chunk) {
cumulativeBytesLoaded += chunk.length.toDart.toInt();
cumulativeBytesLoaded += chunk.length.toDartInt;
chunkCallback(cumulativeBytesLoaded, contentLength);
result.set(chunk, position.toJS);
position += chunk.length.toDart.toInt();
position += chunk.length.toDartInt;
});
return result.toDart;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ extension JsFlutterConfigurationExtension on JsFlutterConfiguration {

@JS('canvasKitMaximumSurfaces')
external JSNumber? get _canvasKitMaximumSurfaces;
double? get canvasKitMaximumSurfaces => _canvasKitMaximumSurfaces?.toDart;
double? get canvasKitMaximumSurfaces => _canvasKitMaximumSurfaces?.toDartDouble;

@JS('debugShowSemanticsNodes')
external JSBoolean? get _debugShowSemanticsNodes;
Expand Down

0 comments on commit 715eff2

Please sign in to comment.