Skip to content

Commit

Permalink
Refactor JSNumber.toDart and Object.toJS
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.
  • Loading branch information
srujzs committed Jun 23, 2023
1 parent 060cd9c commit 1e65c25
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
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
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 1e65c25

Please sign in to comment.