diff --git a/.clang-tidy b/.clang-tidy index 958d4b0745580..686fd62cd861b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -2,6 +2,7 @@ Checks: "google-*,\ clang-analyzer-*,\ clang-diagnostic-*,\ +modernize-use-default-member-init,\ readability-identifier-naming,\ -google-objc-global-variable-declaration,\ -google-objc-avoid-throwing-exception,\ @@ -22,5 +23,15 @@ google-objc-*,\ google-explicit-constructor" CheckOptions: - - key: readability-identifier-naming.GlobalConstantPrefix - value: k + - key: modernize-use-default-member-init.UseAssignment + value: true + - key: readability-identifier-naming.EnumConstantCase + value: 'CamelCase' + - key: readability-identifier-naming.EnumConstantPrefix + value: 'k' + - key: readability-identifier-naming.GlobalConstantPrefix + value: 'k' + - key: readability-identifier-naming.PrivateMemberCase + value: 'lower_case' + - key: readability-identifier-naming.PrivateMemberSuffix + value: '_' diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index b4162f0f439ea..a7b4b6aed9801 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -397,7 +397,6 @@ FILE: ../../../flutter/fml/unique_fd.cc FILE: ../../../flutter/fml/unique_fd.h FILE: ../../../flutter/fml/unique_object.h FILE: ../../../flutter/fml/wakeable.h -FILE: ../../../flutter/impeller/.clang-tidy FILE: ../../../flutter/impeller/aiks/aiks_context.cc FILE: ../../../flutter/impeller/aiks/aiks_context.h FILE: ../../../flutter/impeller/aiks/aiks_playground.cc diff --git a/display_list/display_list_unittests.cc b/display_list/display_list_unittests.cc index d9d44c6d8adbe..e16e84d390330 100644 --- a/display_list/display_list_unittests.cc +++ b/display_list/display_list_unittests.cc @@ -1360,15 +1360,15 @@ TEST(DisplayList, DisplayListBlenderRefHandling) { class BlenderRefTester : public virtual AttributeRefTester { public: void setRefToPaint(SkPaint& paint) const override { - paint.setBlender(blender); + paint.setBlender(blender_); } void setRefToDisplayList(DisplayListBuilder& builder) const override { - builder.setBlender(blender); + builder.setBlender(blender_); } - bool ref_is_unique() const override { return blender->unique(); } + bool ref_is_unique() const override { return blender_->unique(); } private: - sk_sp blender = + sk_sp blender_ = SkBlenders::Arithmetic(0.25, 0.25, 0.25, 0.25, true); }; diff --git a/flow/surface_frame.cc b/flow/surface_frame.cc index 3be9d1b8f69f0..c8a6bbf6bc3c1 100644 --- a/flow/surface_frame.cc +++ b/flow/surface_frame.cc @@ -17,8 +17,7 @@ SurfaceFrame::SurfaceFrame(sk_sp surface, const SubmitCallback& submit_callback, std::unique_ptr context_result, bool display_list_fallback) - : submitted_(false), - surface_(surface), + : surface_(surface), framebuffer_info_(std::move(framebuffer_info)), submit_callback_(submit_callback), context_result_(std::move(context_result)) { diff --git a/fml/platform/posix/mapping_posix.cc b/fml/platform/posix/mapping_posix.cc index aff3d645d3a5b..02351a00d629a 100644 --- a/fml/platform/posix/mapping_posix.cc +++ b/fml/platform/posix/mapping_posix.cc @@ -51,8 +51,7 @@ Mapping::Mapping() = default; Mapping::~Mapping() = default; FileMapping::FileMapping(const fml::UniqueFD& handle, - std::initializer_list protection) - : size_(0), mapping_(nullptr) { + std::initializer_list protection) { if (!handle.is_valid()) { return; } diff --git a/fml/synchronization/semaphore.cc b/fml/synchronization/semaphore.cc index 34e271b15a0fd..8ffaab76cac29 100644 --- a/fml/synchronization/semaphore.cc +++ b/fml/synchronization/semaphore.cc @@ -15,44 +15,44 @@ namespace fml { class PlatformSemaphore { public: explicit PlatformSemaphore(uint32_t count) - : _sem(dispatch_semaphore_create(count)), _initial(count) {} + : sem_(dispatch_semaphore_create(count)), initial_(count) {} ~PlatformSemaphore() { - for (uint32_t i = 0; i < _initial; ++i) { + for (uint32_t i = 0; i < initial_; ++i) { Signal(); } - if (_sem != nullptr) { - dispatch_release(reinterpret_cast(_sem)); - _sem = nullptr; + if (sem_ != nullptr) { + dispatch_release(reinterpret_cast(sem_)); + sem_ = nullptr; } } - bool IsValid() const { return _sem != nullptr; } + bool IsValid() const { return sem_ != nullptr; } bool Wait() { - if (_sem == nullptr) { + if (sem_ == nullptr) { return false; } - return dispatch_semaphore_wait(_sem, DISPATCH_TIME_FOREVER) == 0; + return dispatch_semaphore_wait(sem_, DISPATCH_TIME_FOREVER) == 0; } bool TryWait() { - if (_sem == nullptr) { + if (sem_ == nullptr) { return false; } - return dispatch_semaphore_wait(_sem, DISPATCH_TIME_NOW) == 0; + return dispatch_semaphore_wait(sem_, DISPATCH_TIME_NOW) == 0; } void Signal() { - if (_sem != nullptr) { - dispatch_semaphore_signal(_sem); + if (sem_ != nullptr) { + dispatch_semaphore_signal(sem_); } } private: - dispatch_semaphore_t _sem; - const uint32_t _initial; + dispatch_semaphore_t sem_; + const uint32_t initial_; FML_DISALLOW_COPY_AND_ASSIGN(PlatformSemaphore); }; diff --git a/impeller/.clang-tidy b/impeller/.clang-tidy deleted file mode 100644 index 35447af3e89dd..0000000000000 --- a/impeller/.clang-tidy +++ /dev/null @@ -1,30 +0,0 @@ ---- -Checks: 'clang-diagnostic-*,\ -clang-analyzer-*,\ -google-*,\ -readability-identifier-naming,\ --google-explicit-constructor,\ -modernize-use-default-member-init' - -WarningsAsErrors: '' -HeaderFilterRegex: '' -AnalyzeTemporaryDtors: false -FormatStyle: none -CheckOptions: - - key: readability-identifier-naming.PrivateMemberCase - value: 'lower_case' - - key: readability-identifier-naming.EnumConstantCase - value: 'CamelCase' - - key: readability-identifier-naming.EnumConstantPrefix - value: 'k' - - key: readability-identifier-naming.PrivateMemberSuffix - value: '_' - - key: readability-identifier-naming.PublicMethodCase - value: 'CamelCase' - - key: readability-identifier-naming.PrivateMethodCase - value: 'CamelCase' - - key: cppcoreguidelines-prefer-member-initializer.UseAssignment - value: true - - key: modernize-use-default-member-init.UseAssignment - value: true -... diff --git a/impeller/archivist/archive_database.cc b/impeller/archivist/archive_database.cc index 06f6bf0624928..07c9d7f10bf91 100644 --- a/impeller/archivist/archive_database.cc +++ b/impeller/archivist/archive_database.cc @@ -17,7 +17,7 @@ namespace impeller { struct ArchiveDatabase::Handle { - Handle(const std::string& filename) { + explicit Handle(const std::string& filename) { if (::sqlite3_initialize() != SQLITE_OK) { VALIDATION_LOG << "Could not initialize sqlite."; return; diff --git a/impeller/archivist/archivist_unittests.cc b/impeller/archivist/archivist_unittests.cc index d789034c3fde7..dbd210afa0ff4 100644 --- a/impeller/archivist/archivist_unittests.cc +++ b/impeller/archivist/archivist_unittests.cc @@ -18,7 +18,7 @@ static int64_t LastSample = 0; class Sample : public Archivable { public: - Sample(uint64_t count = 42) : some_data_(count) {} + explicit Sample(uint64_t count = 42) : some_data_(count) {} Sample(Sample&&) = default; diff --git a/impeller/base/base_unittests.cc b/impeller/base/base_unittests.cc index 4dbff57fb2bab..181401fca52ec 100644 --- a/impeller/base/base_unittests.cc +++ b/impeller/base/base_unittests.cc @@ -44,7 +44,7 @@ TEST(ThreadTest, CanCreateRWMutex) { f.mtx.UnlockWriter(); // int b = f.a; <--- Static analysis error. f.mtx.LockReader(); - int b = f.a; + int b = f.a; // NOLINT(clang-analyzer-deadcode.DeadStores) FML_ALLOW_UNUSED_LOCAL(b); f.mtx.UnlockReader(); } @@ -61,7 +61,7 @@ TEST(ThreadTest, CanCreateRWMutexLock) { // int b = f.a; <--- Static analysis error. { auto read_lock = ReaderLock(f.mtx); - int b = f.a; + int b = f.a; // NOLINT(clang-analyzer-deadcode.DeadStores) FML_ALLOW_UNUSED_LOCAL(b); } diff --git a/impeller/blobcat/blob_library.cc b/impeller/blobcat/blob_library.cc index f61c2df1d0b97..94af2799f9252 100644 --- a/impeller/blobcat/blob_library.cc +++ b/impeller/blobcat/blob_library.cc @@ -42,7 +42,7 @@ BlobLibrary::BlobLibrary(std::shared_ptr mapping) { const size_t read_size = sizeof(Blob) * header.blob_count; ::memcpy(blobs.data(), mapping_->GetMapping() + offset, read_size); - offset += read_size; + offset += read_size; // NOLINT(clang-analyzer-deadcode.DeadStores) } // Read the blobs. diff --git a/impeller/compiler/reflector.cc b/impeller/compiler/reflector.cc index 3576990dbbfba..0693ef34d68b7 100644 --- a/impeller/compiler/reflector.cc +++ b/impeller/compiler/reflector.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// FLUTTER_NOLINT: https://github.com/flutter/flutter/issues/105732 + #include "impeller/compiler/reflector.h" #include diff --git a/impeller/entity/entity_unittests.cc b/impeller/entity/entity_unittests.cc index 5552c39c39679..d2b7c04759826 100644 --- a/impeller/entity/entity_unittests.cc +++ b/impeller/entity/entity_unittests.cc @@ -38,7 +38,8 @@ TEST_P(EntityTest, CanCreateEntity) { class TestPassDelegate final : public EntityPassDelegate { public: - TestPassDelegate(std::optional coverage) : coverage_(coverage) {} + explicit TestPassDelegate(std::optional coverage) + : coverage_(coverage) {} // |EntityPassDelegate| ~TestPassDelegate() override = default; diff --git a/impeller/geometry/path_component.h b/impeller/geometry/path_component.h index 4fd513370cd2c..d1cdf3a0b0907 100644 --- a/impeller/geometry/path_component.h +++ b/impeller/geometry/path_component.h @@ -130,7 +130,7 @@ struct CubicPathComponent { struct ContourComponent { Point destination; - bool is_closed; + bool is_closed = false; ContourComponent() {} diff --git a/impeller/renderer/backend/gles/texture_gles.cc b/impeller/renderer/backend/gles/texture_gles.cc index b85d16aa9ad58..752d80c854bfe 100644 --- a/impeller/renderer/backend/gles/texture_gles.cc +++ b/impeller/renderer/backend/gles/texture_gles.cc @@ -90,7 +90,7 @@ struct TexImage2DData { GLenum type = GL_NONE; std::shared_ptr data; - TexImage2DData(PixelFormat pixel_format) { + explicit TexImage2DData(PixelFormat pixel_format) { switch (pixel_format) { case PixelFormat::kA8UNormInt: internal_format = GL_ALPHA; diff --git a/impeller/renderer/backend/metal/command_buffer_mtl.mm b/impeller/renderer/backend/metal/command_buffer_mtl.mm index 1d0f8a2fdb329..5c3e62bf76dc4 100644 --- a/impeller/renderer/backend/metal/command_buffer_mtl.mm +++ b/impeller/renderer/backend/metal/command_buffer_mtl.mm @@ -8,6 +8,9 @@ namespace impeller { namespace { + +// NOLINTBEGIN(readability-identifier-naming) + // TODO(dnfield): remove this declaration when we no longer need to build on // machines with lower SDK versions than 11.0. #if !defined(MAC_OS_VERSION_11_0) || \ @@ -21,6 +24,8 @@ typedef NS_ENUM(NSInteger, MTLCommandEncoderErrorState) { } API_AVAILABLE(macos(11.0), ios(14.0)); #endif +// NOLINTEND(readability-identifier-naming) + API_AVAILABLE(ios(14.0), macos(11.0)) NSString* MTLCommandEncoderErrorStateToString( MTLCommandEncoderErrorState state) { @@ -39,6 +44,8 @@ typedef NS_ENUM(NSInteger, MTLCommandEncoderErrorState) { return @"unknown"; } +// NOLINTBEGIN(readability-identifier-naming) + // TODO(dnfield): This can be removed when all bots have been sufficiently // upgraded for MAC_OS_VERSION_12_0. #if !defined(MAC_OS_VERSION_12_0) || \ @@ -47,6 +54,8 @@ typedef NS_ENUM(NSInteger, MTLCommandEncoderErrorState) { constexpr int MTLCommandBufferErrorStackOverflow = 12; #endif +// NOLINTEND(readability-identifier-naming) + static NSString* MTLCommandBufferErrorToString(MTLCommandBufferError code) { switch (code) { case MTLCommandBufferErrorNone: diff --git a/impeller/renderer/backend/metal/render_pass_mtl.mm b/impeller/renderer/backend/metal/render_pass_mtl.mm index b1131159b5602..2d0876dcbdf76 100644 --- a/impeller/renderer/backend/metal/render_pass_mtl.mm +++ b/impeller/renderer/backend/metal/render_pass_mtl.mm @@ -186,7 +186,8 @@ static bool ConfigureStencilAttachment( /// absent. /// struct PassBindingsCache { - PassBindingsCache(id encoder) : encoder_(encoder) {} + explicit PassBindingsCache(id encoder) + : encoder_(encoder) {} PassBindingsCache(const PassBindingsCache&) = delete; diff --git a/impeller/renderer/renderer_unittests.cc b/impeller/renderer/renderer_unittests.cc index 8f350d10bd1f0..539637d047f91 100644 --- a/impeller/renderer/renderer_unittests.cc +++ b/impeller/renderer/renderer_unittests.cc @@ -285,9 +285,8 @@ TEST_P(RendererTest, CanRenderToTexture) { auto pipeline_desc = BoxPipelineBuilder::MakeDefaultPipelineDescriptor(*context); ASSERT_TRUE(pipeline_desc.has_value()); - auto box_pipeline = context->GetPipelineLibrary() - ->GetRenderPipeline(std::move(pipeline_desc)) - .get(); + auto box_pipeline = + context->GetPipelineLibrary()->GetRenderPipeline(pipeline_desc).get(); ASSERT_TRUE(box_pipeline); VertexBufferBuilder vertex_builder; diff --git a/lib/ui/painting/paint.cc b/lib/ui/painting/paint.cc index 4795a366eb1e1..23b07b25d51bb 100644 --- a/lib/ui/painting/paint.cc +++ b/lib/ui/painting/paint.cc @@ -64,7 +64,7 @@ constexpr float kInvertColors[20] = { // clang-format on // Must be kept in sync with the MaskFilter private constants in painting.dart. -enum MaskFilterType { Null, Blur }; +enum MaskFilterType { kNull, kBlur }; Paint::Paint(Dart_Handle paint_objects, Dart_Handle paint_data) : paint_objects_(paint_objects), paint_data_(paint_data) {} @@ -169,9 +169,9 @@ const SkPaint* Paint::paint(SkPaint& paint) const { } switch (uint_data[kMaskFilterIndex]) { - case Null: + case kNull: break; - case Blur: + case kBlur: SkBlurStyle blur_style = static_cast(uint_data[kMaskFilterBlurStyleIndex]); double sigma = float_data[kMaskFilterSigmaIndex]; @@ -300,10 +300,10 @@ bool Paint::sync_to(DisplayListBuilder* builder, if (flags.applies_mask_filter()) { switch (uint_data[kMaskFilterIndex]) { - case Null: + case kNull: builder->setMaskFilter(nullptr); break; - case Blur: + case kBlur: SkBlurStyle blur_style = static_cast(uint_data[kMaskFilterBlurStyleIndex]); double sigma = float_data[kMaskFilterSigmaIndex]; diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index 4bdae5a701911..50593813dbb6c 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -42,7 +42,7 @@ constexpr std::string_view kFileUriPrefix = "file://"; class DartErrorString { public: - DartErrorString() : str_(nullptr) {} + DartErrorString() {} ~DartErrorString() { if (str_) { ::free(str_); @@ -54,7 +54,7 @@ class DartErrorString { private: FML_DISALLOW_COPY_AND_ASSIGN(DartErrorString); - char* str_; + char* str_ = nullptr; }; } // anonymous namespace diff --git a/shell/common/skia_event_tracer_impl.cc b/shell/common/skia_event_tracer_impl.cc index 0f625a001ec97..83a620dc9c5b0 100644 --- a/shell/common/skia_event_tracer_impl.cc +++ b/shell/common/skia_event_tracer_impl.cc @@ -81,7 +81,7 @@ class FlutterEventTracer : public SkEventTracer { FlutterEventTracer(bool enabled, const std::optional>& allowlist) - : enabled_(enabled ? kYes : kNo), shaders_category_flag_(nullptr) { + : enabled_(enabled ? kYes : kNo) { if (allowlist.has_value()) { allowlist_.emplace(); for (const std::string& category : *allowlist) { @@ -311,7 +311,7 @@ class FlutterEventTracer : public SkEventTracer { std::mutex flag_map_mutex_; std::map category_flag_map_; std::map reverse_flag_map_; - const uint8_t* shaders_category_flag_; + const uint8_t* shaders_category_flag_ = nullptr; FML_DISALLOW_COPY_AND_ASSIGN(FlutterEventTracer); }; diff --git a/shell/gpu/gpu_surface_gl_skia.cc b/shell/gpu/gpu_surface_gl_skia.cc index 60acb9d8b901e..66bb6636d95d8 100644 --- a/shell/gpu/gpu_surface_gl_skia.cc +++ b/shell/gpu/gpu_surface_gl_skia.cc @@ -73,7 +73,7 @@ GPUSurfaceGLSkia::GPUSurfaceGLSkia(sk_sp gr_context, bool render_to_surface) : delegate_(delegate), context_(gr_context), - context_owner_(false), + render_to_surface_(render_to_surface), weak_factory_(this) { auto context_switch = delegate_->GLContextMakeCurrent(); diff --git a/shell/platform/darwin/ios/framework/Source/FlutterChannelKeyResponder.mm b/shell/platform/darwin/ios/framework/Source/FlutterChannelKeyResponder.mm index 4e9131711bc31..16138b5316c30 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterChannelKeyResponder.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterChannelKeyResponder.mm @@ -20,28 +20,35 @@ // framework code expects certain values, and has additional values (like the // sided modifier values below), we translate the iOS values to the framework // values, and add a mask for all the possible values. -typedef NS_OPTIONS(NSInteger, KeyboardModifier) { - KeyboardModifierAlphaShift = 0x10000, - KeyboardModifierShift = 0x20000, - KeyboardModifierLeftShift = 0x02, - KeyboardModifierRightShift = 0x04, - KeyboardModifierControl = 0x40000, - KeyboardModifierLeftControl = 0x01, - KeyboardModifierRightControl = 0x2000, - KeyboardModifierOption = 0x80000, - KeyboardModifierLeftOption = 0x20, - KeyboardModifierRightOption = 0x40, - KeyboardModifierCommand = 0x100000, - KeyboardModifierLeftCommand = 0x08, - KeyboardModifierRightCommand = 0x10, - KeyboardModifierNumericPad = 0x200000, - KeyboardModifierMask = KeyboardModifierAlphaShift | KeyboardModifierShift | - KeyboardModifierLeftShift | KeyboardModifierRightShift | - KeyboardModifierControl | KeyboardModifierLeftControl | - KeyboardModifierRightControl | KeyboardModifierOption | - KeyboardModifierLeftOption | KeyboardModifierRightOption | - KeyboardModifierCommand | KeyboardModifierLeftCommand | - KeyboardModifierRightCommand | KeyboardModifierNumericPad, +typedef NS_OPTIONS(NSInteger, kKeyboardModifier) { + kKeyboardModifierAlphaShift = 0x10000, + kKeyboardModifierShift = 0x20000, + kKeyboardModifierLeftShift = 0x02, + kKeyboardModifierRightShift = 0x04, + kKeyboardModifierControl = 0x40000, + kKeyboardModifierLeftControl = 0x01, + kKeyboardModifierRightControl = 0x2000, + kKeyboardModifierOption = 0x80000, + kKeyboardModifierLeftOption = 0x20, + kKeyboardModifierRightOption = 0x40, + kKeyboardModifierCommand = 0x100000, + kKeyboardModifierLeftCommand = 0x08, + kKeyboardModifierRightCommand = 0x10, + kKeyboardModifierNumericPad = 0x200000, + kKeyboardModifierMask = kKeyboardModifierAlphaShift | // + kKeyboardModifierShift | // + kKeyboardModifierLeftShift | // + kKeyboardModifierRightShift | // + kKeyboardModifierControl | // + kKeyboardModifierLeftControl | // + kKeyboardModifierRightControl | // + kKeyboardModifierOption | // + kKeyboardModifierLeftOption | // + kKeyboardModifierRightOption | // + kKeyboardModifierCommand | // + kKeyboardModifierLeftCommand | // + kKeyboardModifierRightCommand | // + kKeyboardModifierNumericPad, }; /** @@ -83,7 +90,7 @@ @interface FlutterChannelKeyResponder () - (NSInteger)adjustModifiers:(nonnull FlutterUIPressProxy*)press API_AVAILABLE(ios(13.4)); - (void)updatePressedModifiers:(nonnull FlutterUIPressProxy*)press API_AVAILABLE(ios(13.4)); -@property(nonatomic) KeyboardModifier pressedModifiers; +@property(nonatomic) kKeyboardModifier pressedModifiers; @end @implementation FlutterChannelKeyResponder @@ -174,7 +181,7 @@ - (void)updatePressedModifiers:(nonnull FlutterUIPressProxy*)press API_AVAILABLE break; } - void (^update)(KeyboardModifier, bool) = ^(KeyboardModifier mod, bool isOn) { + void (^update)(kKeyboardModifier, bool) = ^(kKeyboardModifier mod, bool isOn) { if (isOn) { _pressedModifiers |= mod; } else { @@ -183,48 +190,48 @@ - (void)updatePressedModifiers:(nonnull FlutterUIPressProxy*)press API_AVAILABLE }; switch (press.key.keyCode) { case UIKeyboardHIDUsageKeyboardCapsLock: - update(KeyboardModifierAlphaShift, isKeyDown); + update(kKeyboardModifierAlphaShift, isKeyDown); break; case UIKeyboardHIDUsageKeypadNumLock: - update(KeyboardModifierNumericPad, isKeyDown); + update(kKeyboardModifierNumericPad, isKeyDown); break; case UIKeyboardHIDUsageKeyboardLeftShift: - update(KeyboardModifierLeftShift, isKeyDown); + update(kKeyboardModifierLeftShift, isKeyDown); break; case UIKeyboardHIDUsageKeyboardRightShift: - update(KeyboardModifierRightShift, isKeyDown); + update(kKeyboardModifierRightShift, isKeyDown); break; case UIKeyboardHIDUsageKeyboardLeftControl: - update(KeyboardModifierLeftControl, isKeyDown); + update(kKeyboardModifierLeftControl, isKeyDown); break; case UIKeyboardHIDUsageKeyboardRightControl: - update(KeyboardModifierRightControl, isKeyDown); + update(kKeyboardModifierRightControl, isKeyDown); break; case UIKeyboardHIDUsageKeyboardLeftAlt: - update(KeyboardModifierLeftOption, isKeyDown); + update(kKeyboardModifierLeftOption, isKeyDown); break; case UIKeyboardHIDUsageKeyboardRightAlt: - update(KeyboardModifierRightOption, isKeyDown); + update(kKeyboardModifierRightOption, isKeyDown); break; case UIKeyboardHIDUsageKeyboardLeftGUI: - update(KeyboardModifierLeftCommand, isKeyDown); + update(kKeyboardModifierLeftCommand, isKeyDown); break; case UIKeyboardHIDUsageKeyboardRightGUI: - update(KeyboardModifierRightCommand, isKeyDown); + update(kKeyboardModifierRightCommand, isKeyDown); break; default: // If we didn't update any of the modifiers above, we're done. return; } // Update the non-sided modifier flags to match the content of the sided ones. - update(KeyboardModifierShift, - _pressedModifiers & (KeyboardModifierRightShift | KeyboardModifierLeftShift)); - update(KeyboardModifierControl, - _pressedModifiers & (KeyboardModifierRightControl | KeyboardModifierLeftControl)); - update(KeyboardModifierOption, - _pressedModifiers & (KeyboardModifierRightOption | KeyboardModifierLeftOption)); - update(KeyboardModifierCommand, - _pressedModifiers & (KeyboardModifierRightCommand | KeyboardModifierLeftCommand)); + update(kKeyboardModifierShift, + _pressedModifiers & (kKeyboardModifierRightShift | kKeyboardModifierLeftShift)); + update(kKeyboardModifierControl, + _pressedModifiers & (kKeyboardModifierRightControl | kKeyboardModifierLeftControl)); + update(kKeyboardModifierOption, + _pressedModifiers & (kKeyboardModifierRightOption | kKeyboardModifierLeftOption)); + update(kKeyboardModifierCommand, + _pressedModifiers & (kKeyboardModifierRightCommand | kKeyboardModifierLeftCommand)); } // Because iOS differs from macOS in that the modifier flags still contain the @@ -239,7 +246,7 @@ - (NSInteger)adjustModifiers:(nonnull FlutterUIPressProxy*)press API_AVAILABLE(i [self updatePressedModifiers:press]; // Replace the supplied modifier flags with our computed ones. - return _pressedModifiers | (press.key.modifierFlags & ~KeyboardModifierMask); + return _pressedModifiers | (press.key.modifierFlags & ~kKeyboardModifierMask); } @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 7363ba30bdee2..0e2c656a32fe5 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -345,30 +345,30 @@ static UITextContentType ToUITextContentType(NSArray* hints) { // The text input plugin then tries to determine which kind of autofill the text // field needs. If the AutofillGroup the text field belongs to contains an // autofillable text field that's password related, this text 's autofill type -// will be FlutterAutofillTypePassword. If autofill is disabled for a text field, -// then its type will be FlutterAutofillTypeNone. Otherwise the text field will -// have an autofill type of FlutterAutofillTypeRegular. +// will be kFlutterAutofillTypePassword. If autofill is disabled for a text field, +// then its type will be kFlutterAutofillTypeNone. Otherwise the text field will +// have an autofill type of kFlutterAutofillTypeRegular. // -// The text input plugin creates a new UIView for every FlutterAutofillTypeNone +// The text input plugin creates a new UIView for every kFlutterAutofillTypeNone // text field. The UIView instance is never reused for other flutter text fields // since the software keyboard often uses the identity of a UIView to distinguish // different views and provides the same predictive text suggestions or restore // the composing region if a UIView is reused for a different flutter text field. // // The text input plugin creates a new "autofill context" if the text field has -// the type of FlutterAutofillTypePassword, to represent the AutofillGroup of +// the type of kFlutterAutofillTypePassword, to represent the AutofillGroup of // the text field, and creates one FlutterTextInputView for every text field in // the AutofillGroup. // // The text input plugin will try to reuse a UIView if a flutter text field's -// type is FlutterAutofillTypeRegular, and has the same autofill id. +// type is kFlutterAutofillTypeRegular, and has the same autofill id. typedef NS_ENUM(NSInteger, FlutterAutofillType) { // The field does not have autofillable content. Additionally if // the field is currently in the autofill context, it will be // removed from the context without triggering autofill save. - FlutterAutofillTypeNone, - FlutterAutofillTypeRegular, - FlutterAutofillTypePassword, + kFlutterAutofillTypeNone, + kFlutterAutofillTypeRegular, + kFlutterAutofillTypePassword, }; static BOOL IsFieldPasswordRelated(NSDictionary* configuration) { @@ -405,22 +405,22 @@ static BOOL IsFieldPasswordRelated(NSDictionary* configuration) { static FlutterAutofillType AutofillTypeOf(NSDictionary* configuration) { for (NSDictionary* field in configuration[kAssociatedAutofillFields]) { if (IsFieldPasswordRelated(field)) { - return FlutterAutofillTypePassword; + return kFlutterAutofillTypePassword; } } if (IsFieldPasswordRelated(configuration)) { - return FlutterAutofillTypePassword; + return kFlutterAutofillTypePassword; } if (@available(iOS 10.0, *)) { NSDictionary* autofill = configuration[kAutofillProperties]; UITextContentType contentType = ToUITextContentType(autofill[kAutofillHints]); - return !autofill || [contentType isEqualToString:@""] ? FlutterAutofillTypeNone - : FlutterAutofillTypeRegular; + return !autofill || [contentType isEqualToString:@""] ? kFlutterAutofillTypeNone + : kFlutterAutofillTypeRegular; } - return FlutterAutofillTypeNone; + return kFlutterAutofillTypeNone; } static BOOL IsApproximatelyEqual(float x, float y, float delta) { @@ -2218,17 +2218,17 @@ - (void)setTextInputClient:(int)client withConfiguration:(NSDictionary*)configur // Update the current active view. switch (AutofillTypeOf(configuration)) { - case FlutterAutofillTypeNone: + case kFlutterAutofillTypeNone: self.activeView = [self createInputViewWith:configuration]; break; - case FlutterAutofillTypeRegular: + case kFlutterAutofillTypeRegular: // If the group does not involve password autofill, only install the // input view that's being focused. self.activeView = [self updateAndShowAutofillViews:nil focusedField:configuration isPasswordRelated:NO]; break; - case FlutterAutofillTypePassword: + case kFlutterAutofillTypePassword: self.activeView = [self updateAndShowAutofillViews:configuration[kAssociatedAutofillFields] focusedField:configuration isPasswordRelated:YES]; @@ -2266,7 +2266,7 @@ - (FlutterTextInputView*)createInputViewWith:(NSDictionary*)configuration { for (NSDictionary* field in configuration[kAssociatedAutofillFields]) { NSString* autofillId = AutofillIdFromDictionary(field); - if (autofillId && AutofillTypeOf(field) == FlutterAutofillTypeNone) { + if (autofillId && AutofillTypeOf(field) == kFlutterAutofillTypeNone) { [_autofillContext removeObjectForKey:autofillId]; } } @@ -2291,7 +2291,7 @@ - (FlutterTextInputView*)updateAndShowAutofillViews:(NSArray*)fields NSString* autofillId = AutofillIdFromDictionary(field); NSAssert(autofillId, @"autofillId must not be null for field: %@", field); - BOOL hasHints = AutofillTypeOf(field) != FlutterAutofillTypeNone; + BOOL hasHints = AutofillTypeOf(field) != kFlutterAutofillTypeNone; BOOL isFocused = [focusedId isEqualToString:autofillId]; if (isFocused) { diff --git a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm index 9e9f93dad4252..c64f41fed913a 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm @@ -57,8 +57,8 @@ * or at the beginning of the next (downstream). */ typedef NS_ENUM(NSUInteger, FlutterTextAffinity) { - FlutterTextAffinityUpstream, - FlutterTextAffinityDownstream + kFlutterTextAffinityUpstream, + kFlutterTextAffinityDownstream }; /* @@ -267,7 +267,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { _enableDeltaModel = [config[kEnableDeltaModel] boolValue]; NSDictionary* inputTypeInfo = config[kTextInputType]; _inputType = inputTypeInfo[kTextInputTypeName]; - self.textAffinity = FlutterTextAffinityUpstream; + self.textAffinity = kFlutterTextAffinityUpstream; _activeModel = std::make_unique(); } @@ -361,8 +361,8 @@ - (void)setEditingState:(NSDictionary*)state { NSString* selectionAffinity = state[kSelectionAffinityKey]; if (selectionAffinity != nil) { _textAffinity = [selectionAffinity isEqualToString:kTextAffinityUpstream] - ? FlutterTextAffinityUpstream - : FlutterTextAffinityDownstream; + ? kFlutterTextAffinityUpstream + : kFlutterTextAffinityDownstream; } NSString* text = state[kTextKey]; @@ -464,8 +464,8 @@ - (void)updateTextAndSelection { } - (NSString*)textAffinityString { - return (self.textAffinity == FlutterTextAffinityUpstream) ? kTextAffinityUpstream - : kTextAffinityDownstream; + return (self.textAffinity == kFlutterTextAffinityUpstream) ? kTextAffinityUpstream + : kTextAffinityDownstream; } - (BOOL)isComposing { diff --git a/shell/platform/linux/fl_gnome_settings.cc b/shell/platform/linux/fl_gnome_settings.cc index 977c4c47b780a..c0ece9ed59eb8 100644 --- a/shell/platform/linux/fl_gnome_settings.cc +++ b/shell/platform/linux/fl_gnome_settings.cc @@ -22,7 +22,7 @@ struct _FlGnomeSettings { GSettings* interface_settings; }; -enum { PROP_0, PROP_INTERFACE_SETTINGS, PROP_LAST }; +enum { kProp0, kPropInterfaceSettings, kPropLast }; static void fl_gnome_settings_iface_init(FlSettingsInterface* iface); @@ -98,7 +98,7 @@ static void fl_gnome_settings_set_property(GObject* object, GParamSpec* pspec) { FlGnomeSettings* self = FL_GNOME_SETTINGS(object); switch (prop_id) { - case PROP_INTERFACE_SETTINGS: + case kPropInterfaceSettings: fl_gnome_settings_set_interface_settings( self, G_SETTINGS(g_value_get_object(value))); break; @@ -122,7 +122,7 @@ static void fl_gnome_settings_class_init(FlGnomeSettingsClass* klass) { object_class->set_property = fl_gnome_settings_set_property; g_object_class_install_property( - object_class, PROP_INTERFACE_SETTINGS, + object_class, kPropInterfaceSettings, g_param_spec_object( kInterfaceSettings, kInterfaceSettings, kDesktopInterfaceSchema, g_settings_get_type(), diff --git a/shell/platform/linux/fl_settings.cc b/shell/platform/linux/fl_settings.cc index e464c46354951..225a5971d5194 100644 --- a/shell/platform/linux/fl_settings.cc +++ b/shell/platform/linux/fl_settings.cc @@ -9,11 +9,11 @@ G_DEFINE_INTERFACE(FlSettings, fl_settings, G_TYPE_OBJECT) enum { - SIGNAL_CHANGED, - SIGNAL_LAST_SIGNAL, + kSignalChanged, + kSignalLastSignal, }; -static guint signals[SIGNAL_LAST_SIGNAL]; +static guint signals[kSignalLastSignal]; static void fl_settings_default_init(FlSettingsInterface* iface) { /** @@ -22,7 +22,7 @@ static void fl_settings_default_init(FlSettingsInterface* iface) { * * This signal is emitted after the settings have been changed. */ - signals[SIGNAL_CHANGED] = + signals[kSignalChanged] = g_signal_new("changed", G_TYPE_FROM_INTERFACE(iface), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0); } @@ -41,7 +41,7 @@ gdouble fl_settings_get_text_scaling_factor(FlSettings* self) { void fl_settings_emit_changed(FlSettings* self) { g_return_if_fail(FL_IS_SETTINGS(self)); - g_signal_emit(self, signals[SIGNAL_CHANGED], 0); + g_signal_emit(self, signals[kSignalChanged], 0); } FlSettings* fl_settings_new() { diff --git a/shell/platform/linux/fl_settings_portal.cc b/shell/platform/linux/fl_settings_portal.cc index ee39c1bae40f6..cf842b0250166 100644 --- a/shell/platform/linux/fl_settings_portal.cc +++ b/shell/platform/linux/fl_settings_portal.cc @@ -51,7 +51,7 @@ static const FlSetting kAllSettings[] = { static constexpr char kClockFormat12Hour[] = "12h"; static constexpr char kGtkThemeDarkSuffix[] = "-dark"; -typedef enum { DEFAULT, PREFER_DARK, PREFER_LIGHT } ColorScheme; +typedef enum { kDefault, kPreferDark, kPreferLight } ColorScheme; struct _FlSettingsPortal { GObject parent_instance; @@ -172,7 +172,7 @@ static FlColorScheme fl_settings_portal_get_color_scheme(FlSettings* settings) { g_autoptr(GVariant) value = nullptr; if (get_value(self, &kColorScheme, &value)) { - if (g_variant_get_uint32(value) == PREFER_DARK) { + if (g_variant_get_uint32(value) == kPreferDark) { color_scheme = FL_COLOR_SCHEME_DARK; } } else if (get_value(self, &kGtkTheme, &value)) { diff --git a/shell/platform/linux/fl_text_input_plugin.cc b/shell/platform/linux/fl_text_input_plugin.cc index 7fb34602e4b5d..b4974c27101f7 100644 --- a/shell/platform/linux/fl_text_input_plugin.cc +++ b/shell/platform/linux/fl_text_input_plugin.cc @@ -50,11 +50,11 @@ static constexpr char kNoneInputType[] = "TextInputType.none"; static constexpr int64_t kClientIdUnset = -1; typedef enum { - FL_TEXT_INPUT_TYPE_TEXT, + kFlTextInputTypeText, // Send newline when multi-line and enter is pressed. - FL_TEXT_INPUT_TYPE_MULTILINE, + kFlTextInputTypeMultiline, // The input method is not shown at all. - FL_TEXT_INPUT_TYPE_NONE, + kFlTextInputTypeNone, } FlTextInputType; struct FlTextInputPluginPrivate { @@ -373,7 +373,7 @@ static FlMethodResponse* set_client(FlTextInputPlugin* self, FlValue* args) { priv->enable_delta_model = enable_delta_model; // Reset the input type, then set only if appropriate. - priv->input_type = FL_TEXT_INPUT_TYPE_TEXT; + priv->input_type = kFlTextInputTypeText; FlValue* input_type_value = fl_value_lookup_string(config_value, kTextInputTypeKey); if (fl_value_get_type(input_type_value) == FL_VALUE_TYPE_MAP) { @@ -382,9 +382,9 @@ static FlMethodResponse* set_client(FlTextInputPlugin* self, FlValue* args) { if (fl_value_get_type(input_type_name) == FL_VALUE_TYPE_STRING) { const gchar* input_type = fl_value_get_string(input_type_name); if (g_strcmp0(input_type, kMultilineInputType) == 0) { - priv->input_type = FL_TEXT_INPUT_TYPE_MULTILINE; + priv->input_type = kFlTextInputTypeMultiline; } else if (g_strcmp0(input_type, kNoneInputType) == 0) { - priv->input_type = FL_TEXT_INPUT_TYPE_NONE; + priv->input_type = kFlTextInputTypeNone; } } } @@ -405,7 +405,7 @@ static FlMethodResponse* hide(FlTextInputPlugin* self) { static FlMethodResponse* show(FlTextInputPlugin* self) { FlTextInputPluginPrivate* priv = static_cast( fl_text_input_plugin_get_instance_private(self)); - if (priv->input_type == FL_TEXT_INPUT_TYPE_NONE) { + if (priv->input_type == kFlTextInputTypeNone) { return hide(self); } @@ -630,7 +630,7 @@ static gboolean fl_text_input_plugin_filter_keypress_default( case GDK_KEY_Return: case GDK_KEY_KP_Enter: case GDK_KEY_ISO_Enter: - if (priv->input_type == FL_TEXT_INPUT_TYPE_MULTILINE) { + if (priv->input_type == kFlTextInputTypeMultiline) { priv->text_model->AddCodePoint('\n'); text = "\n"; changed = TRUE; @@ -686,7 +686,7 @@ static void fl_text_input_plugin_init(FlTextInputPlugin* self) { fl_text_input_plugin_get_instance_private(self)); priv->client_id = kClientIdUnset; - priv->input_type = FL_TEXT_INPUT_TYPE_TEXT; + priv->input_type = kFlTextInputTypeText; priv->text_model = new flutter::TextInputModel(); } diff --git a/shell/platform/linux/fl_view.cc b/shell/platform/linux/fl_view.cc index c423c0a000fae..533ed0b916ce0 100644 --- a/shell/platform/linux/fl_view.cc +++ b/shell/platform/linux/fl_view.cc @@ -70,7 +70,7 @@ typedef struct _FlViewChild { GdkRectangle geometry; } FlViewChild; -enum { PROP_FLUTTER_PROJECT = 1, PROP_LAST }; +enum { kPropFlutterProject = 1, kPropLast }; static void fl_view_plugin_registry_iface_init( FlPluginRegistryInterface* iface); @@ -531,7 +531,7 @@ static void fl_view_set_property(GObject* object, FlView* self = FL_VIEW(object); switch (prop_id) { - case PROP_FLUTTER_PROJECT: + case kPropFlutterProject: g_set_object(&self->project, static_cast(g_value_get_object(value))); break; @@ -548,7 +548,7 @@ static void fl_view_get_property(GObject* object, FlView* self = FL_VIEW(object); switch (prop_id) { - case PROP_FLUTTER_PROJECT: + case kPropFlutterProject: g_value_set_object(value, self->project); break; default: @@ -876,7 +876,7 @@ static void fl_view_class_init(FlViewClass* klass) { container_class->get_child_property = fl_view_get_child_property; g_object_class_install_property( - G_OBJECT_CLASS(klass), PROP_FLUTTER_PROJECT, + G_OBJECT_CLASS(klass), kPropFlutterProject, g_param_spec_object( "flutter-project", "flutter-project", "Flutter project in use", fl_dart_project_get_type(), diff --git a/shell/platform/linux/fl_view_accessible.cc b/shell/platform/linux/fl_view_accessible.cc index 0bc0e44f489c6..fc17063ef335c 100644 --- a/shell/platform/linux/fl_view_accessible.cc +++ b/shell/platform/linux/fl_view_accessible.cc @@ -15,7 +15,7 @@ struct _FlViewAccessible { GHashTable* semantics_nodes_by_id; }; -enum { PROP_0, PROP_ENGINE, PROP_LAST }; +enum { kProp0, kPropEngine, kPropLast }; G_DEFINE_TYPE(FlViewAccessible, fl_view_accessible, @@ -85,7 +85,7 @@ static void fl_view_accessible_set_property(GObject* object, GParamSpec* pspec) { FlViewAccessible* self = FL_VIEW_ACCESSIBLE(object); switch (prop_id) { - case PROP_ENGINE: + case kPropEngine: init_engine(self, FL_ENGINE(g_value_get_object(value))); break; default: @@ -115,7 +115,7 @@ static void fl_view_accessible_class_init(FlViewAccessibleClass* klass) { G_OBJECT_CLASS(klass)->set_property = fl_view_accessible_set_property; g_object_class_install_property( - G_OBJECT_CLASS(klass), PROP_ENGINE, + G_OBJECT_CLASS(klass), kPropEngine, g_param_spec_object( "engine", "engine", "Flutter engine", fl_engine_get_type(), static_cast(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | diff --git a/shell/testing/tester_main.cc b/shell/testing/tester_main.cc index 8594a6084987f..aad510f4025ba 100644 --- a/shell/testing/tester_main.cc +++ b/shell/testing/tester_main.cc @@ -155,9 +155,9 @@ class ScriptCompletionTaskObserver { return; } - if (!has_terminated) { + if (!has_terminated_) { // Only try to terminate the loop once. - has_terminated = true; + has_terminated_ = true; fml::TaskRunner::RunNowOrPostTask(main_task_runner_, []() { fml::MessageLoop::GetCurrent().Terminate(); }); @@ -169,7 +169,7 @@ class ScriptCompletionTaskObserver { fml::RefPtr main_task_runner_; bool run_forever_ = false; std::optional last_error_; - bool has_terminated = false; + bool has_terminated_ = false; FML_DISALLOW_COPY_AND_ASSIGN(ScriptCompletionTaskObserver); };