From debfef5f2ec3ecab8761e64ef45c58cf872f5dda Mon Sep 17 00:00:00 2001 From: Stephen Adams Date: Wed, 4 Apr 2018 20:14:35 +0000 Subject: [PATCH] strong-mode cleanup of swarm TBR=sigmund@google.com Change-Id: Id0c197b99e2c82f04329217cbda13ef35c50ce48 Reviewed-on: https://dart-review.googlesource.com/49543 Reviewed-by: Stephen Adams Reviewed-by: Sigmund Cherem Commit-Queue: Stephen Adams --- samples-dev/swarm/App.dart | 2 +- samples-dev/swarm/SwarmViews.dart | 2 +- samples-dev/swarm/Views.dart | 4 ++-- .../swarm/swarm_ui_lib/observable/observable.dart | 14 +++++++------- samples-dev/swarm/swarm_ui_lib/touch/Momentum.dart | 2 +- .../swarm/swarm_ui_lib/touch/TouchUtil.dart | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/samples-dev/swarm/App.dart b/samples-dev/swarm/App.dart index 06b5fad24f4..301021b7c6e 100644 --- a/samples-dev/swarm/App.dart +++ b/samples-dev/swarm/App.dart @@ -34,7 +34,7 @@ class App { // TODO(sigmund): Consider eliminating the call to "wrap", for // instance, modify event listeners to always wrap, or extend DOM code // to intercept the beginning & end of each event loop - EventBatch.wrap((Event event) => onLoad())); + EventBatch.wrap((event) => onLoad())); } } diff --git a/samples-dev/swarm/SwarmViews.dart b/samples-dev/swarm/SwarmViews.dart index 003e544a36c..9896317f17b 100644 --- a/samples-dev/swarm/SwarmViews.dart +++ b/samples-dev/swarm/SwarmViews.dart @@ -821,7 +821,7 @@ class ArticleView extends View { new CanvasElement(height: img.height, width: img.width); final CanvasRenderingContext2D ctx = canvas.getContext("2d"); - ctx.drawImage(img, 0, 0, img.width, img.height); + ctx.drawImageScaled(img, 0, 0, img.width, img.height); return canvas.toDataUrl("image/png"); } diff --git a/samples-dev/swarm/Views.dart b/samples-dev/swarm/Views.dart index 7bedbfafc4a..3bd25cc2f96 100644 --- a/samples-dev/swarm/Views.dart +++ b/samples-dev/swarm/Views.dart @@ -686,7 +686,7 @@ class FixedSizeListViewLayout implements ListViewLayout { return getPageLength(viewLength) ~/ _itemLength * page; } - int getSnapIndex(num offset, int viewLength) { + int getSnapIndex(num offset, num viewLength) { int index = (-offset / _itemLength).round(); if (_paginate) { index = getPageStartIndex(getPage(index, viewLength), viewLength); @@ -863,7 +863,7 @@ class VariableSizeListViewLayout implements ListViewLayout { throw 'Not implemented'; } - int getSnapIndex(num offset, int viewLength) { + int getSnapIndex(num offset, num viewLength) { for (int i = 1; i < _data.length; i++) { if (getOffset(i) + getOffset(i - 1) > -offset * 2) { return i - 1; diff --git a/samples-dev/swarm/swarm_ui_lib/observable/observable.dart b/samples-dev/swarm/swarm_ui_lib/observable/observable.dart index 373e3504a30..e9d32f8c027 100644 --- a/samples-dev/swarm/swarm_ui_lib/observable/observable.dart +++ b/samples-dev/swarm/swarm_ui_lib/observable/observable.dart @@ -174,8 +174,8 @@ class ObservableList extends AbstractObservable Iterable get reversed => _internal.reversed; - void sort([int compare(var a, var b)]) { - if (compare == null) compare = Comparable.compare; + void sort([int compare(T a, T b)]) { + //if (compare == null) compare = (u, v) => Comparable.compare(u, v); _internal.sort(compare); recordGlobalChange(); } @@ -296,11 +296,11 @@ class ObservableList extends AbstractObservable throw new UnimplementedError(); } - List sublist(int start, [int end]) { + List sublist(int start, [int end]) { throw new UnimplementedError(); } - Iterable getRange(int start, int end) { + Iterable getRange(int start, int end) { throw new UnimplementedError(); } @@ -331,16 +331,16 @@ class ObservableList extends AbstractObservable } String join([String separator = ""]) => _internal.join(separator); - dynamic firstWhere(bool test(T value), {Object orElse()}) { + T firstWhere(bool test(T value), {T orElse()}) { return _internal.firstWhere(test, orElse: orElse); } - dynamic lastWhere(bool test(T value), {Object orElse()}) { + T lastWhere(bool test(T value), {T orElse()}) { return _internal.lastWhere(test, orElse: orElse); } void shuffle([random]) => throw new UnimplementedError(); - bool remove(T element) => throw new UnimplementedError(); + bool remove(Object element) => throw new UnimplementedError(); void removeWhere(bool test(T element)) => throw new UnimplementedError(); void retainWhere(bool test(T element)) => throw new UnimplementedError(); List toList({bool growable: true}) => throw new UnimplementedError(); diff --git a/samples-dev/swarm/swarm_ui_lib/touch/Momentum.dart b/samples-dev/swarm/swarm_ui_lib/touch/Momentum.dart index 05adab5cbf6..eea39a03d8d 100644 --- a/samples-dev/swarm/swarm_ui_lib/touch/Momentum.dart +++ b/samples-dev/swarm/swarm_ui_lib/touch/Momentum.dart @@ -112,7 +112,7 @@ class _Move { * class at all. */ class Solver { - static num solve(num fn(num), num targetY, num startX, + static num solve(num Function(num) fn, num targetY, num startX, [int maxIterations = 50]) { num lastX = 0; num lastY = fn(lastX); diff --git a/samples-dev/swarm/swarm_ui_lib/touch/TouchUtil.dart b/samples-dev/swarm/swarm_ui_lib/touch/TouchUtil.dart index 60ed6e4545f..0a841b753b2 100644 --- a/samples-dev/swarm/swarm_ui_lib/touch/TouchUtil.dart +++ b/samples-dev/swarm/swarm_ui_lib/touch/TouchUtil.dart @@ -10,7 +10,7 @@ part of touch; * touch events are created from the actual mouse events. */ EventListener mouseToTouchCallback(EventListener callback) { - return (MouseEvent e) { + return (Event e) { var touches = []; var targetTouches = []; var changedTouches = []; @@ -240,7 +240,7 @@ class MockTouch implements Touch { } class MockTouchEvent implements TouchEvent { - MouseEvent wrapped; + dynamic /*MouseEvent*/ wrapped; // TODO(jacobr): these are currently Lists instead of a TouchList. final List touches; final List targetTouches; @@ -340,7 +340,7 @@ class MockTouchEvent implements TouchEvent { throw new UnimplementedError(); } - List get path { + List get path { throw new UnimplementedError(); }