From f1fd0a3311c64426985b255389ca1793e8db9fcf Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Tue, 19 Sep 2023 14:13:18 -0700 Subject: [PATCH 1/4] `FlutterMouse.*` -> `kFlutterMouse.*`, so we can lint header files. (#46056) Partial work towards https://github.com/flutter/flutter/issues/134969. --------- Co-authored-by: Chris Bracken --- .../framework/Headers/FlutterViewController.h | 21 +++++++++++++++---- .../framework/Source/FlutterViewController.mm | 10 ++++----- .../Source/FlutterViewControllerTest.mm | 4 ++-- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h b/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h index b0d7a9f8bd86e..3a28e94a85631 100644 --- a/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h +++ b/shell/platform/darwin/macos/framework/Headers/FlutterViewController.h @@ -14,13 +14,26 @@ */ typedef NS_ENUM(NSInteger, FlutterMouseTrackingMode) { // Hover events will never be sent to Flutter. - FlutterMouseTrackingModeNone = 0, + kFlutterMouseTrackingModeNone = 0, + // NOLINTNEXTLINE(readability-identifier-naming) + FlutterMouseTrackingModeNone __attribute__((deprecated)) = kFlutterMouseTrackingModeNone, + // Hover events will be sent to Flutter when the view is in the key window. - FlutterMouseTrackingModeInKeyWindow, + kFlutterMouseTrackingModeInKeyWindow = 1, + // NOLINTNEXTLINE(readability-identifier-naming) + FlutterMouseTrackingModeInKeyWindow + __attribute__((deprecated)) = kFlutterMouseTrackingModeInKeyWindow, + // Hover events will be sent to Flutter when the view is in the active app. - FlutterMouseTrackingModeInActiveApp, + kFlutterMouseTrackingModeInActiveApp = 2, + // NOLINTNEXTLINE(readability-identifier-naming) + FlutterMouseTrackingModeInActiveApp + __attribute__((deprecated)) = kFlutterMouseTrackingModeInActiveApp, + // Hover events will be sent to Flutter regardless of window and app focus. - FlutterMouseTrackingModeAlways, + kFlutterMouseTrackingModeAlways = 3, + // NOLINTNEXTLINE(readability-identifier-naming) + FlutterMouseTrackingModeAlways __attribute__((deprecated)) = kFlutterMouseTrackingModeAlways, }; /** diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm index 62d81dbaa43bd..5c22fe6c01d71 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm @@ -400,7 +400,7 @@ static void CommonInit(FlutterViewController* controller, FlutterEngine* engine) @"In unit tests, this is likely because either the FlutterViewController or " @"the FlutterEngine is mocked. Please subclass these classes instead.", controller.engine, controller.viewId); - controller->_mouseTrackingMode = FlutterMouseTrackingModeInKeyWindow; + controller->_mouseTrackingMode = kFlutterMouseTrackingModeInKeyWindow; controller->_textInputPlugin = [[FlutterTextInputPlugin alloc] initWithViewController:controller]; [controller initializeKeyboard]; [controller notifySemanticsEnabledChanged]; @@ -642,17 +642,17 @@ - (void)configureTrackingArea { // the view is actually loaded. return; } - if (_mouseTrackingMode != FlutterMouseTrackingModeNone && self.flutterView) { + if (_mouseTrackingMode != kFlutterMouseTrackingModeNone && self.flutterView) { NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingInVisibleRect | NSTrackingEnabledDuringMouseDrag; switch (_mouseTrackingMode) { - case FlutterMouseTrackingModeInKeyWindow: + case kFlutterMouseTrackingModeInKeyWindow: options |= NSTrackingActiveInKeyWindow; break; - case FlutterMouseTrackingModeInActiveApp: + case kFlutterMouseTrackingModeInActiveApp: options |= NSTrackingActiveInActiveApp; break; - case FlutterMouseTrackingModeAlways: + case kFlutterMouseTrackingModeAlways: options |= NSTrackingActiveAlways; break; default: diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm index 1628aa004ef4d..eb28a5b786ad5 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm @@ -195,8 +195,8 @@ id MockGestureEvent(NSEventType type, NSEventPhase phase, double magnification, initWithAssetsPath:fixtures ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]]; FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:project]; - viewController.mouseTrackingMode = FlutterMouseTrackingModeInActiveApp; - ASSERT_EQ(viewController.mouseTrackingMode, FlutterMouseTrackingModeInActiveApp); + viewController.mouseTrackingMode = kFlutterMouseTrackingModeInActiveApp; + ASSERT_EQ(viewController.mouseTrackingMode, kFlutterMouseTrackingModeInActiveApp); } TEST(FlutterViewControllerTest, TestKeyEventsAreSentToFramework) { From 838d0a09b8557adabe4a0c8002aed32118f5bd22 Mon Sep 17 00:00:00 2001 From: Srujan Gaddam <58529443+srujzs@users.noreply.github.com> Date: Tue, 19 Sep 2023 14:14:16 -0700 Subject: [PATCH 2/4] Implement JSObject instead of extending (#46070) JSObject will have a factory constructor to create an object literal, so you can't extend it as it will no longer have a generative constructor (@staticInterop types can't have generative constructors). --- lib/web_ui/lib/src/engine/js_interop/js_loader.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/web_ui/lib/src/engine/js_interop/js_loader.dart b/lib/web_ui/lib/src/engine/js_interop/js_loader.dart index 096fb57915a15..eafb921c5135c 100644 --- a/lib/web_ui/lib/src/engine/js_interop/js_loader.dart +++ b/lib/web_ui/lib/src/engine/js_interop/js_loader.dart @@ -73,7 +73,7 @@ abstract class FlutterEngineInitializer{ @JS() @anonymous @staticInterop -abstract class FlutterAppRunner extends JSObject { +abstract class FlutterAppRunner implements JSObject { factory FlutterAppRunner({required RunAppFn runApp,}) => FlutterAppRunner._( runApp: (([RunAppFnParameters? args]) => futureToPromise(runApp(args))).toJS ); @@ -101,7 +101,7 @@ typedef RunAppFn = Future Function([RunAppFnParameters?]); @JS() @anonymous @staticInterop -abstract class FlutterApp extends JSObject { +abstract class FlutterApp implements JSObject { /// Cleans a Flutter app external factory FlutterApp(); } From a96f26faad0d99170e2fb59bbb044f9bef93f327 Mon Sep 17 00:00:00 2001 From: skia-flutter-autoroll Date: Tue, 19 Sep 2023 17:15:05 -0400 Subject: [PATCH 3/4] Roll Skia from 559a964f9f1b to fe3568162721 (5 revisions) (#46069) https://skia.googlesource.com/skia.git/+log/559a964f9f1b..fe3568162721 2023-09-19 jvanverth@google.com [graphite] Switch signed unique ID iterators to unsigned. 2023-09-19 jamesgk@google.com Add "unsafe apis" toggle for Adapter in Graphite DawnTestContext 2023-09-19 fmalita@chromium.org [skottie] Make text shaper header public 2023-09-19 jvanverth@google.com [graphite] Add option to disable cached glyph uploads. 2023-09-19 jamesgk@google.com [graphite] Use Dawn's dual-src blend coeffs when possible If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/skia-flutter-autoroll Please CC brianosman@google.com,jonahwilliams@google.com,rmistry@google.com,tdenniston@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Skia: https://bugs.chromium.org/p/skia/issues/entry To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md --- DEPS | 2 +- ci/licenses_golden/licenses_skia | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/DEPS b/DEPS index 85da328063832..dc3a636e83c2a 100644 --- a/DEPS +++ b/DEPS @@ -18,7 +18,7 @@ vars = { 'llvm_git': 'https://llvm.googlesource.com', # OCMock is for testing only so there is no google clone 'ocmock_git': 'https://github.com/erikdoe/ocmock.git', - 'skia_revision': '559a964f9f1bd6ac5ab226c791d18c9defaf025b', + 'skia_revision': 'fe35681627210de13b447ccb9b40ae6bb8e447d7', # WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY # See `lib/web_ui/README.md` for how to roll CanvasKit to a new version. diff --git a/ci/licenses_golden/licenses_skia b/ci/licenses_golden/licenses_skia index f54f2f45cb459..f331bc2e1e9b1 100644 --- a/ci/licenses_golden/licenses_skia +++ b/ci/licenses_golden/licenses_skia @@ -1,4 +1,4 @@ -Signature: 672d851f6fca7bd95c59e7a7c60503cd +Signature: 4b2d1a29398b500d5c27e9d459eb2f6d ==================================================================================================== LIBRARY: etc1 @@ -5740,6 +5740,7 @@ ORIGIN: ../../../third_party/skia/include/ports/SkCFObject.h + ../../../third_pa ORIGIN: ../../../third_party/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/include/private/gpu/ganesh/GrContext_Base.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/include/private/gpu/ganesh/GrImageContext.h + ../../../third_party/skia/LICENSE +ORIGIN: ../../../third_party/skia/modules/skottie/include/TextShaper.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/skottie/src/Composition.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/skottie/src/Composition.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/skottie/src/Layer.cpp + ../../../third_party/skia/LICENSE @@ -5768,12 +5769,12 @@ ORIGIN: ../../../third_party/skia/modules/skottie/src/layers/NullLayer.cpp + ../ ORIGIN: ../../../third_party/skia/modules/skottie/src/layers/SolidLayer.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/skottie/src/text/RangeSelector.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/skottie/src/text/RangeSelector.h + ../../../third_party/skia/LICENSE -ORIGIN: ../../../third_party/skia/modules/skottie/src/text/SkottieShaper.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/skottie/src/text/SkottieShaper.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/skottie/src/text/TextAdapter.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/skottie/src/text/TextAdapter.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/skottie/src/text/TextAnimator.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/skottie/src/text/TextAnimator.h + ../../../third_party/skia/LICENSE +ORIGIN: ../../../third_party/skia/modules/skottie/src/text/TextShaper.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/skottie/src/text/TextValue.cpp + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/skottie/src/text/TextValue.h + ../../../third_party/skia/LICENSE ORIGIN: ../../../third_party/skia/modules/sksg/include/SkSGRenderEffect.h + ../../../third_party/skia/LICENSE @@ -5858,6 +5859,7 @@ FILE: ../../../third_party/skia/include/ports/SkCFObject.h FILE: ../../../third_party/skia/include/private/chromium/GrVkSecondaryCBDrawContext.h FILE: ../../../third_party/skia/include/private/gpu/ganesh/GrContext_Base.h FILE: ../../../third_party/skia/include/private/gpu/ganesh/GrImageContext.h +FILE: ../../../third_party/skia/modules/skottie/include/TextShaper.h FILE: ../../../third_party/skia/modules/skottie/src/Composition.cpp FILE: ../../../third_party/skia/modules/skottie/src/Composition.h FILE: ../../../third_party/skia/modules/skottie/src/Layer.cpp @@ -5886,12 +5888,12 @@ FILE: ../../../third_party/skia/modules/skottie/src/layers/NullLayer.cpp FILE: ../../../third_party/skia/modules/skottie/src/layers/SolidLayer.cpp FILE: ../../../third_party/skia/modules/skottie/src/text/RangeSelector.cpp FILE: ../../../third_party/skia/modules/skottie/src/text/RangeSelector.h -FILE: ../../../third_party/skia/modules/skottie/src/text/SkottieShaper.cpp FILE: ../../../third_party/skia/modules/skottie/src/text/SkottieShaper.h FILE: ../../../third_party/skia/modules/skottie/src/text/TextAdapter.cpp FILE: ../../../third_party/skia/modules/skottie/src/text/TextAdapter.h FILE: ../../../third_party/skia/modules/skottie/src/text/TextAnimator.cpp FILE: ../../../third_party/skia/modules/skottie/src/text/TextAnimator.h +FILE: ../../../third_party/skia/modules/skottie/src/text/TextShaper.cpp FILE: ../../../third_party/skia/modules/skottie/src/text/TextValue.cpp FILE: ../../../third_party/skia/modules/skottie/src/text/TextValue.h FILE: ../../../third_party/skia/modules/sksg/include/SkSGRenderEffect.h From a7af55c56aa63cc37da4ca334737cc992e041302 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Tue, 19 Sep 2023 14:17:16 -0700 Subject: [PATCH 4/4] Enable strict-inference (#46062) Avoids that dynamic accidentally sneaks in, see https://dart.dev/tools/analysis#enabling-additional-type-checks --- analysis_options.yaml | 1 + ci/bin/format.dart | 2 +- lib/ui/hooks.dart | 3 +-- lib/web_ui/test/canvaskit/surface_test.dart | 4 ++-- lib/web_ui/test/engine/pointer_binding_test.dart | 2 +- testing/scenario_app/bin/utils/logs.dart | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index c33c15e544991..f4e9378bdf958 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -7,6 +7,7 @@ analyzer: language: strict-casts: true + strict-inference: true strict-raw-types: true errors: # allow self-reference to deprecated members (we do this because otherwise we have diff --git a/ci/bin/format.dart b/ci/bin/format.dart index 1e4de1455edfd..8e1c1b1d6b3c6 100644 --- a/ci/bin/format.dart +++ b/ci/bin/format.dart @@ -99,7 +99,7 @@ Future _runGit( return result.stdout; } -typedef MessageCallback = Function(String? message, {MessageType type}); +typedef MessageCallback = void Function(String? message, {MessageType type}); /// Base class for format checkers. /// diff --git a/lib/ui/hooks.dart b/lib/ui/hooks.dart index 5c2244d43a9ad..2d228e1bf66ba 100644 --- a/lib/ui/hooks.dart +++ b/lib/ui/hooks.dart @@ -288,8 +288,7 @@ bool _onError(Object error, StackTrace? stackTrace) { return PlatformDispatcher.instance._dispatchError(error, stackTrace ?? StackTrace.empty); } -// ignore: always_declare_return_types, prefer_generic_function_type_aliases -typedef _ListStringArgFunction(List args); +typedef _ListStringArgFunction = Object? Function(List args); @pragma('vm:entry-point') void _runMain(Function startMainIsolateFunction, diff --git a/lib/web_ui/test/canvaskit/surface_test.dart b/lib/web_ui/test/canvaskit/surface_test.dart index e31ca43bf8079..b4f55330f9ea5 100644 --- a/lib/web_ui/test/canvaskit/surface_test.dart +++ b/lib/web_ui/test/canvaskit/surface_test.dart @@ -150,7 +150,7 @@ void testMain() { 'getExtension', ['WEBGL_lose_context'], ); - js_util.callMethod(loseContextExtension, 'loseContext', const []); + js_util.callMethod(loseContextExtension, 'loseContext', const []); // Pump a timer to allow the "lose context" event to propagate. await Future.delayed(Duration.zero); @@ -160,7 +160,7 @@ void testMain() { expect(isContextLost, isTrue); // Emulate WebGL context restoration. - js_util.callMethod(loseContextExtension, 'restoreContext', const []); + js_util.callMethod(loseContextExtension, 'restoreContext', const []); // Pump a timer to allow the "restore context" event to propagate. await Future.delayed(Duration.zero); diff --git a/lib/web_ui/test/engine/pointer_binding_test.dart b/lib/web_ui/test/engine/pointer_binding_test.dart index 2f7af70ddd51a..613b247ee1391 100644 --- a/lib/web_ui/test/engine/pointer_binding_test.dart +++ b/lib/web_ui/test/engine/pointer_binding_test.dart @@ -3606,7 +3606,7 @@ mixin _ButtonedEventMixin on _BasicEventContext { }); // timeStamp can't be set in the constructor, need to override the getter. if (timeStamp != null) { - js_util.callMethod( + js_util.callMethod( objectConstructor, 'defineProperty', [ diff --git a/testing/scenario_app/bin/utils/logs.dart b/testing/scenario_app/bin/utils/logs.dart index 41800342d193f..0c7c8a6873bf3 100644 --- a/testing/scenario_app/bin/utils/logs.dart +++ b/testing/scenario_app/bin/utils/logs.dart @@ -10,7 +10,7 @@ String _red = _supportsAnsi ? '\u001b[31m' : ''; String _gray = _supportsAnsi ? '\u001b[90m' : ''; String _reset = _supportsAnsi? '\u001B[0m' : ''; -Future step(String msg, Function() fn) async { +Future step(String msg, Future Function() fn) async { stdout.writeln('-> $_green$msg$_reset'); try { await fn();