Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 9594b57

Browse files
committed
int migrate
1 parent 057c53a commit 9594b57

File tree

8 files changed

+246
-76
lines changed

8 files changed

+246
-76
lines changed

lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart

Lines changed: 170 additions & 56 deletions
Large diffs are not rendered by default.

lib/web_ui/lib/src/engine/configuration.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,9 @@ class JsFlutterConfiguration {}
251251
extension JsFlutterConfigurationExtension on JsFlutterConfiguration {
252252
external String? get canvasKitBaseUrl;
253253
external bool? get canvasKitForceCpuOnly;
254-
external int? get canvasKitMaximumSurfaces;
254+
@JS('canvasKitMaximumSurfaces')
255+
external double? get _canvasKitMaximumSurfaces;
256+
int? get canvasKitMaximumSurfaces => _canvasKitMaximumSurfaces?.toInt();
255257
external bool? get debugShowSemanticsNodes;
256258
external DomElement? get hostElement;
257259
external String? get renderer;

lib/web_ui/lib/src/engine/dom.dart

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,12 @@ extension DomHTMLTextAreaElementExtension on DomHTMLTextAreaElement {
900900
external void select();
901901
external set placeholder(String? value);
902902
external set name(String value);
903-
external int? get selectionStart;
904-
external int? get selectionEnd;
903+
@JS('selectionStart')
904+
external double? get _selectionStart;
905+
@JS('selectionEnd')
906+
external double? get _selectionEnd;
907+
int? get selectionStart => _selectionStart?.toInt();
908+
int? get selectionEnd => _selectionEnd?.toInt();
905909
external set selectionStart(int? value);
906910
external set selectionEnd(int? value);
907911
external String? get value;
@@ -1681,9 +1685,15 @@ class DomV8BreakIterator {}
16811685

16821686
extension DomV8BreakIteratorExtension on DomV8BreakIterator {
16831687
external void adoptText(String text);
1684-
external int first();
1685-
external int next();
1686-
external int current();
1688+
@JS('first')
1689+
external double _first();
1690+
int first() => _first().toInt();
1691+
@JS('next')
1692+
external double _next();
1693+
int next() => _next().toInt();
1694+
@JS('current')
1695+
external double _current();
1696+
int current() => _current().toInt();
16871697
external String breakType();
16881698
}
16891699

lib/web_ui/lib/src/engine/navigation/js_url_strategy.dart

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ typedef _StateOperation = void Function(
2323

2424
typedef _HistoryMove = Future<void> Function(int count);
2525

26+
typedef _HistoryMoveInternal = Future<void> Function(double count);
27+
2628
/// The JavaScript representation of a URL strategy.
2729
///
2830
/// This is used to pass URL strategy implementations across a JS-interop
@@ -33,15 +35,33 @@ typedef _HistoryMove = Future<void> Function(int count);
3335
abstract class JsUrlStrategy {
3436
/// Creates an instance of [JsUrlStrategy] from a bag of URL strategy
3537
/// functions.
36-
external factory JsUrlStrategy({
38+
external factory JsUrlStrategy._({
3739
required _PathGetter getPath,
3840
required _StateGetter getState,
3941
required _AddPopStateListener addPopStateListener,
4042
required _StringToString prepareExternalUrl,
4143
required _StateOperation pushState,
4244
required _StateOperation replaceState,
43-
required _HistoryMove go,
45+
required _HistoryMoveInternal go,
4446
});
47+
48+
factory JsUrlStrategy({
49+
required _PathGetter getPath,
50+
required _StateGetter getState,
51+
required _AddPopStateListener addPopStateListener,
52+
required _StringToString prepareExternalUrl,
53+
required _StateOperation pushState,
54+
required _StateOperation replaceState,
55+
required _HistoryMove go,
56+
}) => JsUrlStrategy._(
57+
getPath: getPath,
58+
getState: getState,
59+
addPopStateListener: allowInterop((DomEventListener event) =>
60+
allowInterop(addPopStateListener(event))),
61+
prepareExternalUrl: prepareExternalUrl,
62+
pushState: pushState,
63+
replaceState: replaceState,
64+
go: allowInterop((double count) => go(count.toInt())));
4565
}
4666

4767
extension JsUrlStrategyExtension on JsUrlStrategy {
@@ -82,5 +102,5 @@ extension JsUrlStrategyExtension on JsUrlStrategy {
82102
/// * `go(3)` moves forward 3 steps in hisotry.
83103
///
84104
/// See: https://developer.mozilla.org/en-US/docs/Web/API/History/go
85-
external Future<void> go(int count);
105+
external Future<void> go(double count);
86106
}

lib/web_ui/lib/src/engine/navigation/url_strategy.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class CustomUrlStrategy extends UrlStrategy {
179179
delegate.replaceState(state, title, url);
180180

181181
@override
182-
Future<void> go(int count) => delegate.go(count);
182+
Future<void> go(int count) => delegate.go(count.toDouble());
183183
}
184184

185185
/// Encapsulates all calls to DOM apis, which allows the [UrlStrategy] classes

lib/web_ui/lib/src/engine/safe_browser_api.dart

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,26 @@ class DecodeOptions {
336336
class VideoFrame implements DomCanvasImageSource {}
337337

338338
extension VideoFrameExtension on VideoFrame {
339-
external int allocationSize();
339+
@JS('allocationSize')
340+
external double _allocationSize();
341+
int allocationSize() => _allocationSize().toInt();
340342
external JsPromise copyTo(Uint8List destination);
341343
external String? get format;
342-
external int get codedWidth;
343-
external int get codedHeight;
344-
external int get displayWidth;
345-
external int get displayHeight;
346-
external int? get duration;
344+
@JS('codedWidth')
345+
external double get _codedWidth;
346+
int get codedWidth => _codedWidth.toInt();
347+
@JS('codedHeight')
348+
external double get _codedHeight;
349+
int get codedHeight => _codedHeight.toInt();
350+
@JS('displayWidth')
351+
external double get _displayWidth;
352+
int get displayWidth => _displayWidth.toInt();
353+
@JS('displayHeight')
354+
external double get _displayHeight;
355+
int get displayHeight => _displayHeight.toInt();
356+
@JS('duration')
357+
external double? get _duration;
358+
int? get duration => _duration?.toInt();
347359
external VideoFrame clone();
348360
external void close();
349361
}
@@ -374,8 +386,12 @@ extension ImageTrackListExtension on ImageTrackList {
374386
class ImageTrack {}
375387

376388
extension ImageTrackExtension on ImageTrack {
377-
external int get repetitionCount;
378-
external int get frameCount;
389+
@JS('repetitionCount')
390+
external double get _repetitionCount;
391+
int get repetitionCount => _repetitionCount.toInt();
392+
@JS('frameCount')
393+
external double get _frameCount;
394+
int get frameCount =>_frameCount.toInt();
379395
}
380396

381397
void scaleCanvas2D(Object context2d, num x, num y) {

lib/web_ui/pubspec.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ publish_to: none
55
environment:
66
sdk: ">=2.17.0-0 <3.0.0"
77

8+
dependency_overrides:
9+
test:
10+
path: /usr/local/google/home/joshualitt/f/test/pkgs/test
11+
test_api:
12+
path: /usr/local/google/home/joshualitt/f/test/pkgs/test_api
13+
test_core:
14+
path: /usr/local/google/home/joshualitt/f/test/pkgs/test_core
15+
816
dependencies:
917
js: 0.6.4
1018
meta: ^1.7.0
@@ -26,7 +34,7 @@ dev_dependencies:
2634
shelf_static: any
2735
shelf_web_socket: any
2836
stack_trace: any
29-
stream_channel: any
37+
stream_channel: 2.1.1
3038
test: 1.22.0
3139
test_api: any
3240
test_core: any

web_sdk/web_engine_tester/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ environment:
66

77
dependencies:
88
js: 0.6.4
9-
stream_channel: 2.1.0
9+
stream_channel: 2.1.1
1010
test: 1.22.0
1111
webkit_inspection_protocol: 1.0.0
1212
stack_trace: 1.10.0

0 commit comments

Comments
 (0)