diff --git a/.clang-tidy b/.clang-tidy index b15f3a3ea67dd..88ea45f5938b8 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -45,10 +45,19 @@ CheckOptions: - key: readability-identifier-naming.PrivateMemberSuffix value: "_" -# Lint headers within paths that contain "/flutter/" but not: -# - gen (generated code, the fact it compiles is good enoughâ„¢) -# - third_party (we didn't author most of the code, and can't fix the lints) +# Intended to include (lint) all headers except: +# ... those in ../../gen (generated files don't need to follow clang tidy) +# ... those in flutter/third_party (we didn't author this code, it's a dep) # -# Note this is because of our buildroot setup, so the full path of a lint is: -# "../../flutter/impeller/core/runtime_types.h:1:1" as reported. -HeaderFilterRegex: "(!third_party/)(!gen/).*/flutter/.*" +# Unfortunately Clang Tidy uses an ancient version of regular expressions +# without lookaheads, so the next best thing is to write out every directory +# except third_party. +# +# If we ever add a new root directory, we'll have to update this expression. +# +# See the test in ./tools/clang_tidy/test/header_filter_regex_test.dart which +# should theoretically catch if new directories are added but this regex is not +# updated. +# +# tl;dr: I'm sorry. +HeaderFilterRegex: "[..\/]+\/flutter\/(assets|benchmarking|build|ci|common|display_list|docs|examples|flow|flutter_frontend_server|flutter_vma|fml|impeller|lib|runtime|shell|skia|sky|testing|tools|vulkan|wasm|web_sdk)\/.*" diff --git a/impeller/renderer/vertex_buffer_builder.h b/impeller/renderer/vertex_buffer_builder.h index 6617820403d9c..b70e8a700389a 100644 --- a/impeller/renderer/vertex_buffer_builder.h +++ b/impeller/renderer/vertex_buffer_builder.h @@ -42,7 +42,7 @@ class VertexBufferBuilder { return impeller::IndexType::kUnknown; } - void SetLabel(std::string label) { label_ = std::move(label); } + void SetLabel(const std::string& label) { label_ = label; } void Reserve(size_t count) { return vertices_.reserve(count); } diff --git a/shell/common/shell_test_platform_view_metal.mm b/shell/common/shell_test_platform_view_metal.mm index 4e96c6d1b3aa6..93cf262e4a810 100644 --- a/shell/common/shell_test_platform_view_metal.mm +++ b/shell/common/shell_test_platform_view_metal.mm @@ -31,12 +31,13 @@ // non-Objective-C TUs. class DarwinContextMetal { public: - explicit DarwinContextMetal(bool impeller, - std::shared_ptr is_gpu_disabled_sync_switch) + explicit DarwinContextMetal( + bool impeller, + const std::shared_ptr& is_gpu_disabled_sync_switch) : context_(impeller ? nil : [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice]), - impeller_context_(impeller ? [[FlutterDarwinContextMetalImpeller alloc] - init:std::move(is_gpu_disabled_sync_switch)] - : nil), + impeller_context_( + impeller ? [[FlutterDarwinContextMetalImpeller alloc] init:is_gpu_disabled_sync_switch] + : nil), offscreen_texture_(CreateOffscreenTexture( impeller ? [impeller_context_ context]->GetMTLDevice() : [context_ device])) {} diff --git a/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.h b/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.h index 94c843a256f8e..e4f75d8cb52bf 100644 --- a/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.h +++ b/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.h @@ -54,6 +54,8 @@ typedef enum { // NOLINTEND(readability-identifier-naming) } FlutterStandardCodecObjcType; +// NOLINTBEGIN(google-objc-function-naming) + /////////////////////////////////////////////////////////////////////////////// ///\name Reader Helpers ///@{ @@ -111,6 +113,7 @@ bool FlutterStandardCodecHelperWriteNumber(CFMutableDataRef data, ///@} +// NOLINTEND(google-objc-function-naming) // NOLINTEND(google-runtime-int) #if defined(__cplusplus) diff --git a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h index 549723de64679..874fb3239c622 100644 --- a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h +++ b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.h @@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Initializes a FlutterDarwinContextMetalImpeller. */ -- (instancetype)init:(std::shared_ptr)is_gpu_disabled_sync_switch; +- (instancetype)init:(const std::shared_ptr&)is_gpu_disabled_sync_switch; /** * Creates an external texture with the specified ID and contents. diff --git a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm index fab938f1a600b..b7b4a3d6b7b6f 100644 --- a/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm +++ b/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm @@ -20,21 +20,21 @@ FLUTTER_ASSERT_ARC static std::shared_ptr CreateImpellerContext( - std::shared_ptr is_gpu_disabled_sync_switch) { + const std::shared_ptr& is_gpu_disabled_sync_switch) { std::vector> shader_mappings = { - std::make_shared(impeller_entity_shaders_data, - impeller_entity_shaders_length), + std::make_shared(impeller_entity_shaders_data, + impeller_entity_shaders_length), #if IMPELLER_ENABLE_3D - std::make_shared(impeller_scene_shaders_data, - impeller_scene_shaders_length), + std::make_shared(impeller_scene_shaders_data, + impeller_scene_shaders_length), #endif // IMPELLER_ENABLE_3D - std::make_shared(impeller_modern_shaders_data, - impeller_modern_shaders_length), - std::make_shared(impeller_framebuffer_blend_shaders_data, - impeller_framebuffer_blend_shaders_length), + std::make_shared(impeller_modern_shaders_data, + impeller_modern_shaders_length), + std::make_shared(impeller_framebuffer_blend_shaders_data, + impeller_framebuffer_blend_shaders_length), }; - auto context = impeller::ContextMTL::Create( - shader_mappings, std::move(is_gpu_disabled_sync_switch), "Impeller Library"); + auto context = impeller::ContextMTL::Create(shader_mappings, is_gpu_disabled_sync_switch, + "Impeller Library"); if (!context) { FML_LOG(ERROR) << "Could not create Metal Impeller Context."; return nullptr; @@ -46,10 +46,10 @@ @implementation FlutterDarwinContextMetalImpeller -- (instancetype)init:(std::shared_ptr)is_gpu_disabled_sync_switch { +- (instancetype)init:(const std::shared_ptr&)is_gpu_disabled_sync_switch { self = [super init]; if (self != nil) { - _context = CreateImpellerContext(std::move(is_gpu_disabled_sync_switch)); + _context = CreateImpellerContext(is_gpu_disabled_sync_switch); id device = _context->GetMTLDevice(); if (!device) { FML_DLOG(ERROR) << "Could not acquire Metal device."; diff --git a/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h b/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h index caf2b3dfd52a0..52d6a5b1c868f 100644 --- a/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h +++ b/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h @@ -22,11 +22,13 @@ NS_ASSUME_NONNULL_BEGIN * The dart entrypoint that is associated with `main()`. This is to be used as an argument to the * `runWithEntrypoint*` methods. */ +// NOLINTNEXTLINE(readability-identifier-naming) extern NSString* const FlutterDefaultDartEntrypoint; /** * The default Flutter initial route ("/"). */ +// NOLINTNEXTLINE(readability-identifier-naming) extern NSString* const FlutterDefaultInitialRoute; /** diff --git a/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h b/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h index 524e68293c95a..803e2c40fd595 100644 --- a/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h +++ b/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h @@ -250,6 +250,7 @@ typedef void (*FlutterPluginRegistrantCallback)(NSObject* * Flutter Framework (e.g. When an interact-able widget is covering the platform view). */ typedef enum { + // NOLINTBEGIN(readability-identifier-naming) /** * Flutter blocks all the UIGestureRecognizers on the platform view as soon as it * decides they should be blocked. @@ -266,6 +267,7 @@ typedef enum { * but never recognizing the gesture (and never invoking actions). */ FlutterPlatformViewGestureRecognizersBlockingPolicyWaitUntilTouchesEnded, + // NOLINTEND(readability-identifier-naming) } FlutterPlatformViewGestureRecognizersBlockingPolicy; #pragma mark - diff --git a/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h b/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h index d33d989370d43..d3c513ea8dab4 100644 --- a/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h +++ b/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h @@ -26,6 +26,7 @@ NS_ASSUME_NONNULL_BEGIN * with the update. */ FLUTTER_DARWIN_EXPORT +// NOLINTNEXTLINE(readability-identifier-naming) extern NSNotificationName const FlutterSemanticsUpdateNotification; /** diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.h b/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.h index 43bed3b6566a0..81eb81ea125d4 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.h @@ -7,19 +7,16 @@ #import #import + #include "fml/memory/weak_ptr.h" #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyPrimaryResponder.h" #import "flutter/shell/platform/embedder/embedder.h" -namespace { -typedef void* _VoidPtr; -} - typedef void (^FlutterSendKeyEvent)(const FlutterKeyEvent& /* event */, _Nullable FlutterKeyEventCallback /* callback */, - _Nullable _VoidPtr /* user_data */); + void* _Nullable /* user_data */); /** * A primary responder of |FlutterKeyboardManager| that handles events by diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponderTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponderTest.mm index 5e0ebab0ca624..fb9c102bc54fe 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponderTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponderTest.mm @@ -27,10 +27,10 @@ @interface TestKeyEvent : NSObject @property(nonatomic) FlutterKeyEvent* data; @property(nonatomic) FlutterKeyEventCallback callback; -@property(nonatomic) _VoidPtr userData; +@property(nonatomic) void* _Nullable userData; - (nonnull instancetype)initWithEvent:(const FlutterKeyEvent*)event callback:(nullable FlutterKeyEventCallback)callback - userData:(nullable _VoidPtr)userData; + userData:(void* _Nullable)userData; - (BOOL)hasCallback; - (void)respond:(BOOL)handled; @end @@ -38,7 +38,7 @@ - (void)respond:(BOOL)handled; @implementation TestKeyEvent - (instancetype)initWithEvent:(const FlutterKeyEvent*)event callback:(nullable FlutterKeyEventCallback)callback - userData:(nullable _VoidPtr)userData { + userData:(void* _Nullable)userData { self = [super init]; _data = new FlutterKeyEvent(*event); if (event->character != nullptr) { @@ -132,7 +132,7 @@ - (void)testBasicKeyEvent API_AVAILABLE(ios(13.4)) { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -192,7 +192,7 @@ - (void)testIosKeyPlane API_AVAILABLE(ios(13.4)) { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -251,7 +251,7 @@ - (void)testOutOfOrderModifiers API_AVAILABLE(ios(13.4)) { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -350,7 +350,7 @@ - (void)testIgnoreDuplicateDownEvent API_AVAILABLE(ios(13.4)) { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -420,7 +420,7 @@ - (void)testIgnoreAbruptUpEvent API_AVAILABLE(ios(13.4)) { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -453,7 +453,7 @@ - (void)testToggleModifiersDuringKeyTap API_AVAILABLE(ios(13.4)) { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -541,7 +541,7 @@ - (void)testSpecialModiferFlags API_AVAILABLE(ios(13.4)) { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -734,7 +734,7 @@ - (void)testIdentifyLeftAndRightModifiers API_AVAILABLE(ios(13.4)) { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -816,7 +816,7 @@ - (void)testSynchronizeCapsLockStateOnCapsLock API_AVAILABLE(ios(13.4)) { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -940,7 +940,7 @@ - (void)testSynchronizeCapsLockStateOnNormalKey API_AVAILABLE(ios(13.4)) { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -995,7 +995,7 @@ - (void)testCommandPeriodKey API_AVAILABLE(ios(13.4)) { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:nil userData:nil]]; callback(true, user_data); }]; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index dc8904ea2a061..7e8246538231a 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -244,7 +244,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, FlutterTouchInterceptingView* touch_interceptor = [[[FlutterTouchInterceptingView alloc] initWithEmbeddedView:platform_view platformViewsController:GetWeakPtr() - gestureRecognizersBlockingPolicy:gesture_recognizers_blocking_policies[viewType]] + gestureRecognizersBlockingPolicy:gesture_recognizers_blocking_policies_[viewType]] autorelease]; touch_interceptors_[viewId] = @@ -317,7 +317,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, FML_CHECK(factories_.count(idString) == 0); factories_[idString] = fml::scoped_nsobject>([factory retain]); - gesture_recognizers_blocking_policies[idString] = gestureRecognizerBlockingPolicy; + gesture_recognizers_blocking_policies_[idString] = gestureRecognizerBlockingPolicy; } void FlutterPlatformViewsController::BeginFrame(SkISize frame_size) { diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index 677941421ca9e..bf964dbcfa115 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -395,7 +395,7 @@ class FlutterPlatformViewsController { // The FlutterPlatformViewGestureRecognizersBlockingPolicy for each type of platform view. std::map - gesture_recognizers_blocking_policies; + gesture_recognizers_blocking_policies_; bool catransaction_added_ = false; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h b/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h index cea4dd88daed6..7793e616cc88f 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h @@ -11,6 +11,7 @@ @class FlutterTextInputView; typedef NS_ENUM(NSInteger, FlutterTextInputAction) { + // NOLINTBEGIN(readability-identifier-naming) FlutterTextInputActionUnspecified, FlutterTextInputActionDone, FlutterTextInputActionGo, @@ -22,12 +23,15 @@ typedef NS_ENUM(NSInteger, FlutterTextInputAction) { FlutterTextInputActionRoute, FlutterTextInputActionEmergencyCall, FlutterTextInputActionNewline, + // NOLINTEND(readability-identifier-naming) }; typedef NS_ENUM(NSInteger, FlutterFloatingCursorDragState) { + // NOLINTBEGIN(readability-identifier-naming) FlutterFloatingCursorDragStateStart, FlutterFloatingCursorDragStateUpdate, FlutterFloatingCursorDragStateEnd, + // NOLINTEND(readability-identifier-naming) }; @protocol FlutterTextInputDelegate diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h index fe26c40c4fca5..0304842c91d10 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h @@ -15,15 +15,19 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewResponder.h" typedef NS_ENUM(NSInteger, FlutterScribbleFocusStatus) { + // NOLINTBEGIN(readability-identifier-naming) FlutterScribbleFocusStatusUnfocused, FlutterScribbleFocusStatusFocusing, FlutterScribbleFocusStatusFocused, + // NOLINTEND(readability-identifier-naming) }; typedef NS_ENUM(NSInteger, FlutterScribbleInteractionStatus) { + // NOLINTBEGIN(readability-identifier-naming) FlutterScribbleInteractionStatusNone, FlutterScribbleInteractionStatusStarted, FlutterScribbleInteractionStatusEnding, + // NOLINTEND(readability-identifier-naming) }; @interface FlutterTextInputPlugin diff --git a/shell/platform/darwin/ios/framework/Source/FlutterUndoManagerDelegate.h b/shell/platform/darwin/ios/framework/Source/FlutterUndoManagerDelegate.h index 2157820c85e72..3e428c7ab0d9e 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterUndoManagerDelegate.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterUndoManagerDelegate.h @@ -10,8 +10,10 @@ NS_ASSUME_NONNULL_BEGIN typedef NS_ENUM(NSInteger, FlutterUndoRedoDirection) { + // NOLINTBEGIN(readability-identifier-naming) FlutterUndoRedoDirectionUndo, FlutterUndoRedoDirectionRedo, + // NOLINTEND(readability-identifier-naming) }; @class FlutterUndoManagerPlugin; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h index 66ed0d1afeea2..ed99a3339b617 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h @@ -20,18 +20,23 @@ class FlutterPlatformViewsController; } FLUTTER_DARWIN_EXPORT +// NOLINTNEXTLINE(readability-identifier-naming) extern NSNotificationName const FlutterViewControllerWillDealloc; FLUTTER_DARWIN_EXPORT +// NOLINTNEXTLINE(readability-identifier-naming) extern NSNotificationName const FlutterViewControllerHideHomeIndicator; FLUTTER_DARWIN_EXPORT +// NOLINTNEXTLINE(readability-identifier-naming) extern NSNotificationName const FlutterViewControllerShowHomeIndicator; typedef NS_ENUM(NSInteger, FlutterKeyboardMode) { + // NOLINTBEGIN(readability-identifier-naming) FlutterKeyboardModeHidden = 0, FlutterKeyboardModeDocked = 1, FlutterKeyboardModeFloating = 2, + // NOLINTEND(readability-identifier-naming) }; typedef void (^FlutterKeyboardAnimationCallback)(fml::TimePoint); diff --git a/shell/platform/darwin/ios/framework/Source/KeyCodeMap_Internal.h b/shell/platform/darwin/ios/framework/Source/KeyCodeMap_Internal.h index f6e98dd4d84f2..79edd9673699f 100644 --- a/shell/platform/darwin/ios/framework/Source/KeyCodeMap_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/KeyCodeMap_Internal.h @@ -15,6 +15,7 @@ * MacOS doesn't provide a scan code, but a virtual keycode to represent a * physical key. */ +// NOLINTNEXTLINE(readability-identifier-naming) extern const std::map keyCodeToPhysicalKey; /** @@ -23,6 +24,7 @@ extern const std::map keyCodeToPhysicalKey; * This is used to derive logical keys that can't or shouldn't be derived from * |charactersIgnoringModifiers|. */ +// NOLINTNEXTLINE(readability-identifier-naming) extern const std::map keyCodeToLogicalKey; /** @@ -96,29 +98,34 @@ constexpr uint32_t kModifierFlagSidedMask = kModifierFlagControlLeft | kModifier /** * Map |UIKey.keyCode| to the matching sided modifier in UIEventModifierFlags. */ +// NOLINTNEXTLINE(readability-identifier-naming) extern const std::map keyCodeToModifierFlag; /** * Map a bit of bitmask of sided modifiers in UIEventModifierFlags to their * corresponding |UIKey.keyCode|. */ +// NOLINTNEXTLINE(readability-identifier-naming) extern const std::map modifierFlagToKeyCode; /** * Maps a sided modifier key to the corresponding flag matching either side of * that type of modifier. */ +// NOLINTNEXTLINE(readability-identifier-naming) extern const std::map sidedModifierToAny; /** * Maps a non-sided modifier key to the corresponding flag matching the left key * of that type of modifier. */ +// NOLINTNEXTLINE(readability-identifier-naming) extern const std::map anyModifierToLeft; /** * A set of keycodes corresponding to function keys. */ +// NOLINTNEXTLINE(readability-identifier-naming) extern const std::set functionKeyCodes; #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_KEY_CODE_MAP_INTERNAL_H_ diff --git a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm index c0e90db785559..e064e9168c9d3 100644 --- a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm +++ b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm @@ -20,7 +20,7 @@ @implementation SemanticsObjectTest - (void)testCreate { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); SemanticsObject* object = [[SemanticsObject alloc] initWithBridge:bridge uid:0]; XCTAssertNotNil(object); @@ -28,7 +28,7 @@ - (void)testCreate { - (void)testSetChildren { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); SemanticsObject* parent = [[SemanticsObject alloc] initWithBridge:bridge uid:0]; SemanticsObject* child = [[SemanticsObject alloc] initWithBridge:bridge uid:1]; @@ -40,7 +40,7 @@ - (void)testSetChildren { - (void)testAccessibilityHitTestFocusAtLeaf { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); SemanticsObject* object0 = [[SemanticsObject alloc] initWithBridge:bridge uid:0]; SemanticsObject* object1 = [[SemanticsObject alloc] initWithBridge:bridge uid:1]; @@ -84,7 +84,7 @@ - (void)testAccessibilityHitTestFocusAtLeaf { - (void)testAccessibilityHitTestNoFocusableItem { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); SemanticsObject* object0 = [[SemanticsObject alloc] initWithBridge:bridge uid:0]; SemanticsObject* object1 = [[SemanticsObject alloc] initWithBridge:bridge uid:1]; @@ -122,9 +122,9 @@ - (void)testAccessibilityHitTestNoFocusableItem { } - (void)testAccessibilityScrollToVisible { - fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); - fml::WeakPtr bridge = factory.GetWeakPtr(); + fml::WeakPtrFactory factory( + new flutter::testing::MockAccessibilityBridge()); + fml::WeakPtr bridge = factory.GetWeakPtr(); SemanticsObject* object3 = [[SemanticsObject alloc] initWithBridge:bridge uid:3]; flutter::SemanticsNode node3; @@ -140,9 +140,9 @@ - (void)testAccessibilityScrollToVisible { } - (void)testAccessibilityScrollToVisibleWithChild { - fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); - fml::WeakPtr bridge = factory.GetWeakPtr(); + fml::WeakPtrFactory factory( + new flutter::testing::MockAccessibilityBridge()); + fml::WeakPtr bridge = factory.GetWeakPtr(); SemanticsObject* object3 = [[SemanticsObject alloc] initWithBridge:bridge uid:3]; flutter::SemanticsNode node3; @@ -159,7 +159,7 @@ - (void)testAccessibilityScrollToVisibleWithChild { - (void)testAccessibilityHitTestOutOfRect { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); SemanticsObject* object0 = [[SemanticsObject alloc] initWithBridge:bridge uid:0]; SemanticsObject* object1 = [[SemanticsObject alloc] initWithBridge:bridge uid:1]; @@ -202,7 +202,7 @@ - (void)testAccessibilityHitTestOutOfRect { - (void)testReplaceChildAtIndex { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); SemanticsObject* parent = [[SemanticsObject alloc] initWithBridge:bridge uid:0]; SemanticsObject* child1 = [[SemanticsObject alloc] initWithBridge:bridge uid:1]; @@ -216,7 +216,7 @@ - (void)testReplaceChildAtIndex { - (void)testPlainSemanticsObjectWithLabelHasStaticTextTrait { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); flutter::SemanticsNode node; node.label = "foo"; @@ -227,7 +227,7 @@ - (void)testPlainSemanticsObjectWithLabelHasStaticTextTrait { - (void)testNodeWithImplicitScrollIsAnAccessibilityElementWhenItisHidden { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); flutter::SemanticsNode node; node.flags = static_cast(flutter::SemanticsFlags::kHasImplicitScrolling) | @@ -239,7 +239,7 @@ - (void)testNodeWithImplicitScrollIsAnAccessibilityElementWhenItisHidden { - (void)testNodeWithImplicitScrollIsNotAnAccessibilityElementWhenItisNotHidden { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); flutter::SemanticsNode node; node.flags = static_cast(flutter::SemanticsFlags::kHasImplicitScrolling); @@ -250,7 +250,7 @@ - (void)testNodeWithImplicitScrollIsNotAnAccessibilityElementWhenItisNotHidden { - (void)testIntresetingSemanticsObjectWithLabelHasStaticTextTrait { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); flutter::SemanticsNode node; node.label = "foo"; @@ -263,7 +263,7 @@ - (void)testIntresetingSemanticsObjectWithLabelHasStaticTextTrait { - (void)testIntresetingSemanticsObjectWithLabelHasStaticTextTrait1 { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); flutter::SemanticsNode node; node.label = "foo"; @@ -275,7 +275,7 @@ - (void)testIntresetingSemanticsObjectWithLabelHasStaticTextTrait1 { - (void)testIntresetingSemanticsObjectWithLabelHasStaticTextTrait2 { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); flutter::SemanticsNode node; node.label = "foo"; @@ -287,7 +287,7 @@ - (void)testIntresetingSemanticsObjectWithLabelHasStaticTextTrait2 { - (void)testVerticalFlutterScrollableSemanticsObject { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); float transformScale = 0.5f; @@ -325,7 +325,7 @@ - (void)testVerticalFlutterScrollableSemanticsObject { - (void)testVerticalFlutterScrollableSemanticsObjectNoWindowDoesNotCrash { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridgeNoWindow()); + new flutter::testing::MockAccessibilityBridgeNoWindow()); fml::WeakPtr bridge = factory.GetWeakPtr(); float transformScale = 0.5f; @@ -353,7 +353,7 @@ - (void)testVerticalFlutterScrollableSemanticsObjectNoWindowDoesNotCrash { - (void)testHorizontalFlutterScrollableSemanticsObject { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); float transformScale = 0.5f; @@ -391,7 +391,7 @@ - (void)testHorizontalFlutterScrollableSemanticsObject { - (void)testCanHandleInfiniteScrollExtent { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); float transformScale = 0.5f; @@ -430,7 +430,7 @@ - (void)testCanHandleInfiniteScrollExtent { - (void)testCanHandleNaNScrollExtentAndScrollPoisition { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); float transformScale = 0.5f; @@ -467,7 +467,7 @@ - (void)testCanHandleNaNScrollExtentAndScrollPoisition { - (void)testFlutterScrollableSemanticsObjectIsNotHittestable { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); flutter::SemanticsNode node; @@ -486,7 +486,7 @@ - (void)testFlutterScrollableSemanticsObjectIsNotHittestable { } - (void)testFlutterScrollableSemanticsObjectIsHiddenWhenVoiceOverIsRunning { - flutter::MockAccessibilityBridge* mock = new flutter::MockAccessibilityBridge(); + flutter::testing::MockAccessibilityBridge* mock = new flutter::testing::MockAccessibilityBridge(); mock->isVoiceOverRunningValue = false; fml::WeakPtrFactory factory(mock); fml::WeakPtr bridge = factory.GetWeakPtr(); @@ -509,7 +509,7 @@ - (void)testFlutterScrollableSemanticsObjectIsHiddenWhenVoiceOverIsRunning { } - (void)testFlutterScrollableSemanticsObjectWithLabelValueHintIsNotHiddenWhenVoiceOverIsRunning { - flutter::MockAccessibilityBridge* mock = new flutter::MockAccessibilityBridge(); + flutter::testing::MockAccessibilityBridge* mock = new flutter::testing::MockAccessibilityBridge(); mock->isVoiceOverRunningValue = true; fml::WeakPtrFactory factory(mock); fml::WeakPtr bridge = factory.GetWeakPtr(); @@ -538,7 +538,7 @@ - (void)testFlutterScrollableSemanticsObjectWithLabelValueHintIsNotHiddenWhenVoi } - (void)testFlutterSemanticsObjectMergeTooltipToLabel { - flutter::MockAccessibilityBridge* mock = new flutter::MockAccessibilityBridge(); + flutter::testing::MockAccessibilityBridge* mock = new flutter::testing::MockAccessibilityBridge(); mock->isVoiceOverRunningValue = true; fml::WeakPtrFactory factory(mock); fml::WeakPtr bridge = factory.GetWeakPtr(); @@ -554,7 +554,7 @@ - (void)testFlutterSemanticsObjectMergeTooltipToLabel { } - (void)testFlutterSemanticsObjectAttributedStringsDoNotCrashWhenEmpty { - flutter::MockAccessibilityBridge* mock = new flutter::MockAccessibilityBridge(); + flutter::testing::MockAccessibilityBridge* mock = new flutter::testing::MockAccessibilityBridge(); mock->isVoiceOverRunningValue = true; fml::WeakPtrFactory factory(mock); fml::WeakPtr bridge = factory.GetWeakPtr(); @@ -567,7 +567,7 @@ - (void)testFlutterSemanticsObjectAttributedStringsDoNotCrashWhenEmpty { } - (void)testFlutterScrollableSemanticsObjectReturnsParentContainerIfNoChildren { - flutter::MockAccessibilityBridge* mock = new flutter::MockAccessibilityBridge(); + flutter::testing::MockAccessibilityBridge* mock = new flutter::testing::MockAccessibilityBridge(); mock->isVoiceOverRunningValue = true; fml::WeakPtrFactory factory(mock); fml::WeakPtr bridge = factory.GetWeakPtr(); @@ -611,7 +611,7 @@ - (void)testFlutterScrollableSemanticsObjectReturnsParentContainerIfNoChildren { - (void)testFlutterScrollableSemanticsObjectHidesScrollBar { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); flutter::SemanticsNode node; @@ -633,7 +633,7 @@ - (void)testFlutterScrollableSemanticsObjectHidesScrollBar { - (void)testSemanticsObjectBuildsAttributedString { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); flutter::SemanticsNode node; node.label = "label"; @@ -689,7 +689,7 @@ - (void)testSemanticsObjectBuildsAttributedString { - (void)testShouldTriggerAnnouncement { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); SemanticsObject* object = [[SemanticsObject alloc] initWithBridge:bridge uid:0]; @@ -726,9 +726,9 @@ - (void)testShouldTriggerAnnouncement { } - (void)testShouldDispatchShowOnScreenActionForHeader { - fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); - fml::WeakPtr bridge = factory.GetWeakPtr(); + fml::WeakPtrFactory factory( + new flutter::testing::MockAccessibilityBridge()); + fml::WeakPtr bridge = factory.GetWeakPtr(); SemanticsObject* object = [[SemanticsObject alloc] initWithBridge:bridge uid:1]; // Handle initial setting of node with header. @@ -747,9 +747,9 @@ - (void)testShouldDispatchShowOnScreenActionForHeader { } - (void)testShouldDispatchShowOnScreenActionForHidden { - fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); - fml::WeakPtr bridge = factory.GetWeakPtr(); + fml::WeakPtrFactory factory( + new flutter::testing::MockAccessibilityBridge()); + fml::WeakPtr bridge = factory.GetWeakPtr(); SemanticsObject* object = [[SemanticsObject alloc] initWithBridge:bridge uid:1]; // Handle initial setting of node with hidden. @@ -768,9 +768,9 @@ - (void)testShouldDispatchShowOnScreenActionForHidden { } - (void)testFlutterSwitchSemanticsObjectMatchesUISwitch { - fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); - fml::WeakPtr bridge = factory.GetWeakPtr(); + fml::WeakPtrFactory factory( + new flutter::testing::MockAccessibilityBridge()); + fml::WeakPtr bridge = factory.GetWeakPtr(); FlutterSwitchSemanticsObject* object = [[FlutterSwitchSemanticsObject alloc] initWithBridge:bridge uid:1]; @@ -802,9 +802,9 @@ - (void)testFlutterSwitchSemanticsObjectMatchesUISwitch { } - (void)testFlutterSemanticsObjectOfRadioButton { - fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); - fml::WeakPtr bridge = factory.GetWeakPtr(); + fml::WeakPtrFactory factory( + new flutter::testing::MockAccessibilityBridge()); + fml::WeakPtr bridge = factory.GetWeakPtr(); FlutterSemanticsObject* object = [[FlutterSemanticsObject alloc] initWithBridge:bridge uid:0]; // Handle initial setting of node with header. @@ -820,9 +820,9 @@ - (void)testFlutterSemanticsObjectOfRadioButton { } - (void)testFlutterSwitchSemanticsObjectMatchesUISwitchDisabled { - fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); - fml::WeakPtr bridge = factory.GetWeakPtr(); + fml::WeakPtrFactory factory( + new flutter::testing::MockAccessibilityBridge()); + fml::WeakPtr bridge = factory.GetWeakPtr(); FlutterSwitchSemanticsObject* object = [[FlutterSwitchSemanticsObject alloc] initWithBridge:bridge uid:1]; @@ -843,7 +843,7 @@ - (void)testFlutterSwitchSemanticsObjectMatchesUISwitchDisabled { - (void)testSemanticsObjectDeallocated { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); SemanticsObject* parent = [[SemanticsObject alloc] initWithBridge:bridge uid:0]; SemanticsObject* child = [[SemanticsObject alloc] initWithBridge:bridge uid:1]; @@ -890,7 +890,8 @@ - (void)testFlutterSemanticsObjectReturnsNilContainerWhenBridgeIsNotAlive { parent.childrenInTraversalOrder.push_back(2); { - flutter::MockAccessibilityBridge* mock = new flutter::MockAccessibilityBridge(); + flutter::testing::MockAccessibilityBridge* mock = + new flutter::testing::MockAccessibilityBridge(); mock->isVoiceOverRunningValue = true; fml::WeakPtrFactory factory(mock); fml::WeakPtr bridge = factory.GetWeakPtr(); @@ -926,7 +927,7 @@ - (void)testFlutterSemanticsObjectReturnsNilContainerWhenBridgeIsNotAlive { - (void)testAccessibilityHitTestSearchCanReturnPlatformView { fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); + new flutter::testing::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); SemanticsObject* object0 = [[SemanticsObject alloc] initWithBridge:bridge uid:0]; SemanticsObject* object1 = [[SemanticsObject alloc] initWithBridge:bridge uid:1]; @@ -974,9 +975,9 @@ - (void)testAccessibilityHitTestSearchCanReturnPlatformView { } - (void)testFlutterPlatformViewSemanticsContainer { - fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); - fml::WeakPtr bridge = factory.GetWeakPtr(); + fml::WeakPtrFactory factory( + new flutter::testing::MockAccessibilityBridge()); + fml::WeakPtr bridge = factory.GetWeakPtr(); __weak FlutterTouchInterceptingView* weakPlatformView; @autoreleasepool { FlutterTouchInterceptingView* platformView = [[FlutterTouchInterceptingView alloc] init]; diff --git a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h index 0f0c0303d4a98..8d06239288ec6 100644 --- a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h +++ b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h @@ -10,7 +10,7 @@ const CGRect kScreenSize = CGRectMake(0, 0, 600, 800); namespace flutter { -namespace { +namespace testing { class SemanticsActionObservation { public: @@ -83,7 +83,7 @@ class MockAccessibilityBridgeNoWindow : public AccessibilityBridgeIos { private: UIView* view_; }; -} // namespace +} // namespace testing } // namespace flutter @interface SemanticsObject (Tests) diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h index 451dbce83db42..b2e8de42fc296 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h @@ -99,7 +99,7 @@ class AccessibilityBridge final : public AccessibilityBridgeIos { int32_t last_focused_semantics_object_id_; fml::scoped_nsobject> objects_; fml::scoped_nsprotocol accessibility_channel_; - int32_t previous_route_id_; + int32_t previous_route_id_ = 0; std::unordered_map actions_; std::vector previous_routes_; std::unique_ptr ios_delegate_; diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm index 8402779efd854..54f5dd4ff7acf 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm @@ -49,7 +49,6 @@ void PostAccessibilityNotification(UIAccessibilityNotifications notification, platform_views_controller_(std::move(platform_views_controller)), last_focused_semantics_object_id_(kSemanticObjectIdInvalid), objects_([[NSMutableDictionary alloc] init]), - previous_route_id_(0), previous_routes_({}), ios_delegate_(ios_delegate ? std::move(ios_delegate) : std::make_unique()), diff --git a/shell/platform/darwin/ios/ios_context.h b/shell/platform/darwin/ios/ios_context.h index 9a4049b581826..121c7aeaa14e9 100644 --- a/shell/platform/darwin/ios/ios_context.h +++ b/shell/platform/darwin/ios/ios_context.h @@ -60,7 +60,7 @@ class IOSContext { IOSRenderingAPI api, IOSRenderingBackend backend, MsaaSampleCount msaa_samples, - std::shared_ptr is_gpu_disabled_sync_switch); + const std::shared_ptr& is_gpu_disabled_sync_switch); //---------------------------------------------------------------------------- /// @brief Collects the context object. This must happen on the thread on diff --git a/shell/platform/darwin/ios/ios_context.mm b/shell/platform/darwin/ios/ios_context.mm index 2f58ebb7479a0..0f74ded917fe4 100644 --- a/shell/platform/darwin/ios/ios_context.mm +++ b/shell/platform/darwin/ios/ios_context.mm @@ -23,7 +23,7 @@ IOSRenderingAPI api, IOSRenderingBackend backend, MsaaSampleCount msaa_samples, - std::shared_ptr is_gpu_disabled_sync_switch) { + const std::shared_ptr& is_gpu_disabled_sync_switch) { switch (api) { case IOSRenderingAPI::kSoftware: FML_CHECK(backend != IOSRenderingBackend::kImpeller) @@ -38,7 +38,7 @@ case IOSRenderingBackend::kSkia: return std::make_unique(msaa_samples); case IOSRenderingBackend::kImpeller: - return std::make_unique(std::move(is_gpu_disabled_sync_switch)); + return std::make_unique(is_gpu_disabled_sync_switch); } #endif // SHELL_ENABLE_METAL default: diff --git a/shell/platform/darwin/ios/ios_context_metal_impeller.h b/shell/platform/darwin/ios/ios_context_metal_impeller.h index 1647b3745c97a..5eaf6104fb2f6 100644 --- a/shell/platform/darwin/ios/ios_context_metal_impeller.h +++ b/shell/platform/darwin/ios/ios_context_metal_impeller.h @@ -20,7 +20,8 @@ namespace flutter { class IOSContextMetalImpeller final : public IOSContext { public: - IOSContextMetalImpeller(std::shared_ptr is_gpu_disabled_sync_switch); + explicit IOSContextMetalImpeller( + const std::shared_ptr& is_gpu_disabled_sync_switch); ~IOSContextMetalImpeller(); diff --git a/shell/platform/darwin/ios/ios_context_metal_impeller.mm b/shell/platform/darwin/ios/ios_context_metal_impeller.mm index d6187221a7436..6d4cfdddb76e4 100644 --- a/shell/platform/darwin/ios/ios_context_metal_impeller.mm +++ b/shell/platform/darwin/ios/ios_context_metal_impeller.mm @@ -9,11 +9,10 @@ namespace flutter { IOSContextMetalImpeller::IOSContextMetalImpeller( - std::shared_ptr is_gpu_disabled_sync_switch) + const std::shared_ptr& is_gpu_disabled_sync_switch) : IOSContext(MsaaSampleCount::kFour), darwin_context_metal_impeller_(fml::scoped_nsobject{ - [[FlutterDarwinContextMetalImpeller alloc] - init:std::move(is_gpu_disabled_sync_switch)]}) {} + [[FlutterDarwinContextMetalImpeller alloc] init:is_gpu_disabled_sync_switch]}) {} IOSContextMetalImpeller::~IOSContextMetalImpeller() = default; diff --git a/shell/platform/darwin/ios/platform_message_handler_ios.h b/shell/platform/darwin/ios/platform_message_handler_ios.h index 6bd2af143785c..bfc649ca7864a 100644 --- a/shell/platform/darwin/ios/platform_message_handler_ios.h +++ b/shell/platform/darwin/ios/platform_message_handler_ios.h @@ -20,7 +20,7 @@ class PlatformMessageHandlerIos : public PlatformMessageHandler { public: static NSObject* MakeBackgroundTaskQueue(); - PlatformMessageHandlerIos(fml::RefPtr platform_task_runner); + explicit PlatformMessageHandlerIos(fml::RefPtr platform_task_runner); void HandlePlatformMessage(std::unique_ptr message) override; diff --git a/shell/platform/darwin/ios/platform_view_ios.h b/shell/platform/darwin/ios/platform_view_ios.h index 5002c00fefbd6..6be7d4a499122 100644 --- a/shell/platform/darwin/ios/platform_view_ios.h +++ b/shell/platform/darwin/ios/platform_view_ios.h @@ -51,7 +51,7 @@ class PlatformViewIOS final : public PlatformView { const std::shared_ptr& platform_views_controller, const flutter::TaskRunners& task_runners, const std::shared_ptr& worker_task_runner, - std::shared_ptr is_gpu_disabled_sync_switch); + const std::shared_ptr& is_gpu_disabled_sync_switch); ~PlatformViewIOS() override; @@ -112,7 +112,7 @@ class PlatformViewIOS final : public PlatformView { ScopedObserver& operator=(const ScopedObserver&) = delete; private: - id observer_; + id observer_ = nil; }; /// Wrapper that guarantees we communicate clearing Accessibility @@ -142,7 +142,6 @@ class PlatformViewIOS final : public PlatformView { const std::shared_ptr& platform_views_controller_; AccessibilityBridgeManager accessibility_bridge_; fml::scoped_nsprotocol text_input_plugin_; - fml::closure firstFrameCallback_; ScopedObserver dealloc_view_controller_observer_; std::vector platform_resolved_locale_; std::shared_ptr platform_message_handler_; diff --git a/shell/platform/darwin/ios/platform_view_ios.mm b/shell/platform/darwin/ios/platform_view_ios.mm index d4de687a2f2cc..262df21d3c07e 100644 --- a/shell/platform/darwin/ios/platform_view_ios.mm +++ b/shell/platform/darwin/ios/platform_view_ios.mm @@ -57,7 +57,7 @@ new PlatformMessageHandlerIos(task_runners.GetPlatformTaskRunner())) {} const std::shared_ptr& platform_views_controller, const flutter::TaskRunners& task_runners, const std::shared_ptr& worker_task_runner, - std::shared_ptr is_gpu_disabled_sync_switch) + const std::shared_ptr& is_gpu_disabled_sync_switch) : PlatformViewIOS( delegate, IOSContext::Create( @@ -65,7 +65,7 @@ new PlatformMessageHandlerIos(task_runners.GetPlatformTaskRunner())) {} delegate.OnPlatformViewGetSettings().enable_impeller ? IOSRenderingBackend::kImpeller : IOSRenderingBackend::kSkia, static_cast(delegate.OnPlatformViewGetSettings().msaa_samples), - std::move(is_gpu_disabled_sync_switch)), + is_gpu_disabled_sync_switch), platform_views_controller, task_runners) {} @@ -250,7 +250,7 @@ new PlatformMessageHandlerIos(task_runners.GetPlatformTaskRunner())) {} return out; } -PlatformViewIOS::ScopedObserver::ScopedObserver() : observer_(nil) {} +PlatformViewIOS::ScopedObserver::ScopedObserver() {} PlatformViewIOS::ScopedObserver::~ScopedObserver() { if (observer_) { diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponder.h b/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponder.h index 117b8c3113696..f786bc25bebd0 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponder.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponder.h @@ -7,13 +7,9 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterKeyPrimaryResponder.h" #include "flutter/shell/platform/embedder/embedder.h" -namespace { -typedef void* _VoidPtr; -} - typedef void (^FlutterSendEmbedderKeyEvent)(const FlutterKeyEvent& /* event */, _Nullable FlutterKeyEventCallback /* callback */, - _Nullable _VoidPtr /* user_data */); + void* _Nullable /* user_data */); /** * A primary responder of |FlutterKeyboardManager| that handles events by diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponderTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponderTest.mm index e59837db37429..60724af146baa 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponderTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEmbedderKeyResponderTest.mm @@ -13,10 +13,10 @@ @interface TestKeyEvent : NSObject @property(nonatomic) FlutterKeyEvent* data; @property(nonatomic) FlutterKeyEventCallback callback; -@property(nonatomic) _VoidPtr userData; +@property(nonatomic) void* userData; - (nonnull instancetype)initWithEvent:(const FlutterKeyEvent*)event callback:(nullable FlutterKeyEventCallback)callback - userData:(nullable _VoidPtr)userData; + userData:(nullable void*)userData; - (BOOL)hasCallback; - (void)respond:(BOOL)handled; @end @@ -24,7 +24,7 @@ - (void)respond:(BOOL)handled; @implementation TestKeyEvent - (instancetype)initWithEvent:(const FlutterKeyEvent*)event callback:(nullable FlutterKeyEventCallback)callback - userData:(nullable _VoidPtr)userData { + userData:(nullable void*)userData { self = [super init]; _data = new FlutterKeyEvent(*event); if (event->character != nullptr) { @@ -122,7 +122,7 @@ - (void)dealloc { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -200,7 +200,7 @@ - (void)dealloc { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -270,7 +270,7 @@ - (void)dealloc { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -312,7 +312,7 @@ - (void)dealloc { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -371,7 +371,7 @@ - (void)dealloc { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -401,7 +401,7 @@ - (void)dealloc { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -437,7 +437,7 @@ - (void)dealloc { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -547,7 +547,7 @@ - (void)dealloc { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -695,7 +695,7 @@ - (void)dealloc { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -781,7 +781,7 @@ - (void)dealloc { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -985,7 +985,7 @@ - (void)dealloc { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -1059,7 +1059,7 @@ - (void)dealloc { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -1138,7 +1138,7 @@ - (void)dealloc { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; @@ -1172,7 +1172,7 @@ - (void)dealloc { FlutterEmbedderKeyResponder* responder = [[FlutterEmbedderKeyResponder alloc] initWithSendEvent:^(const FlutterKeyEvent& event, _Nullable FlutterKeyEventCallback callback, - _Nullable _VoidPtr user_data) { + void* _Nullable user_data) { [events addObject:[[TestKeyEvent alloc] initWithEvent:&event callback:callback userData:user_data]]; diff --git a/tools/clang_tidy/pubspec.yaml b/tools/clang_tidy/pubspec.yaml index 2a54bebae0154..7e7e987a61404 100644 --- a/tools/clang_tidy/pubspec.yaml +++ b/tools/clang_tidy/pubspec.yaml @@ -31,6 +31,7 @@ dev_dependencies: litetest: any process_fakes: any smith: any + yaml: any dependency_overrides: args: @@ -63,5 +64,13 @@ dependency_overrides: path: ../pkg/process_fakes process_runner: path: ../../third_party/pkg/process_runner + source_span: + path: ../../../third_party/dart/third_party/pkg/source_span smith: path: ../../../third_party/dart/pkg/smith + string_scanner: + path: ../../../third_party/dart/third_party/pkg/string_scanner + term_glyph: + path: ../../../third_party/dart/third_party/pkg/term_glyph + yaml: + path: ../../../third_party/dart/third_party/pkg/yaml diff --git a/tools/clang_tidy/test/header_filter_regex_test.dart b/tools/clang_tidy/test/header_filter_regex_test.dart new file mode 100644 index 0000000000000..a39cacf4ccf9b --- /dev/null +++ b/tools/clang_tidy/test/header_filter_regex_test.dart @@ -0,0 +1,68 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:io'; + +import 'package:engine_repo_tools/engine_repo_tools.dart'; +import 'package:litetest/litetest.dart'; +import 'package:path/path.dart' as path; +import 'package:yaml/yaml.dart' as yaml; + +/// Tests that `HeaderFilterRegex` works as expected in `.clang_tidy`. +void main() { + // Find the root of the repo. + final Engine engine = Engine.findWithin(path.dirname(Platform.script.path)); + + // Find the `.clang_tidy` file and "parse" it (it's YAML). + final yaml.YamlDocument dotClangTidy = yaml.loadYamlDocument( + File(path.join(engine.flutterDir.path, '.clang-tidy')).readAsStringSync(), + ); + + // Find the `HeaderFilterRegex` entry. + if (dotClangTidy.contents is! yaml.YamlMap) { + stderr.writeln('Expected .clang-tidy to be a YAML map.'); + exit(1); + } + final yaml.YamlMap nodes = dotClangTidy.contents as yaml.YamlMap; + final yaml.YamlNode? headerFilterRegex = nodes.nodes['HeaderFilterRegex']; + if (headerFilterRegex == null) { + stderr.writeln('Expected .clang-tidy to have a HeaderFilterRegex entry.'); + exit(1); + } + + final RegExp regexValue = RegExp(headerFilterRegex.value.toString()); + + test('contains every root directory in the regex', () { + // These are a list of directories that should _not_ be included. + const Set intentionallyOmitted = { + '.git', + '.github', + 'prebuilts', + 'third_party', + }; + + // Find all the directories in the repo root aside from the ones above. + final Set rootDirs = {}; + for (final FileSystemEntity entity in engine.flutterDir.listSync()) { + if (entity is! Directory) { + continue; + } + final String name = path.basename(entity.path); + if (intentionallyOmitted.contains(name)) { + continue; + } + rootDirs.add(name); + } + + // Create a fake file in that path, and assert that it matches the regex. + for (final String rootDir in rootDirs) { + final String file = path.join('..', '..', 'flutter', rootDir, 'foo'); + if (!regexValue.hasMatch(file)) { + // This is because reason: ... doesn't work in pkg/litetest. + stderr.writeln('Expected "$file" to be caught by HeaderFilterRegex (${regexValue.pattern}).'); + } + expect(regexValue.hasMatch(file), isTrue); + } + }); +}