From 909833c7aa826ad455271d52a6ae3a8728e4c1d8 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Fri, 17 Jun 2022 21:37:36 -0700 Subject: [PATCH 01/14] Eliminate use-after-move pipeline_desc is a std::optional. It's used in test expectations after (lines 320-321) the move. This passes by value like in other tests. --- impeller/renderer/renderer_unittests.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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; From f1061728c7abe7e5c5ded9ff9ceed8f5eff8c808 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Sat, 28 May 2022 17:35:25 -0700 Subject: [PATCH 02/14] [lint] Merge impeller .clang-tidy into main config Merges most (but not all) of the impeller .clang-tidy rules into the main .clang-tidy config. Merges: * readability-identifier-naming.PrivateMemberSuffix (_) * readability-identifier-naming.EnumConstantPrefix (k) * modernize-use-default-member-init.UseAssignment Does not merge: * readability-identifier-naming.PublicMethodCase (CamelCase) * readability-identifier-naming.PrivateMethodCase (CamelCase) These last two are not merged due to the non-trivial number of existing field accessors that use `field_name()` methods to directly return `field_name_`. While these are permitted by the C++ style guide, we may want to move to a single, simple rule and name everything in CamelCase. These can be enabled in a followup patch. --- .clang-tidy | 10 ++++++++-- impeller/.clang-tidy | 30 ------------------------------ 2 files changed, 8 insertions(+), 32 deletions(-) delete mode 100644 impeller/.clang-tidy diff --git a/.clang-tidy b/.clang-tidy index 958d4b0745580..00eed789209c5 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -22,5 +22,11 @@ google-objc-*,\ google-explicit-constructor" CheckOptions: - - key: readability-identifier-naming.GlobalConstantPrefix - value: k + - 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: '_' 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 -... From c33aab0955cd55a9ef8ce9fd611b13025233eeed Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Sat, 28 May 2022 18:02:08 -0700 Subject: [PATCH 03/14] Private fields end in _ --- display_list/display_list_unittests.cc | 8 ++++---- fml/synchronization/semaphore.cc | 28 +++++++++++++------------- shell/testing/tester_main.cc | 6 +++--- 3 files changed, 21 insertions(+), 21 deletions(-) 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/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/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); }; From cdacee902250339e30130c8aad512ae730db8747 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Sat, 28 May 2022 18:02:39 -0700 Subject: [PATCH 04/14] Add missing enum k prefixes --- lib/ui/painting/paint.cc | 10 +++++----- .../framework/Source/FlutterTextInputPlugin.mm | 14 +++++++------- shell/platform/linux/fl_gnome_settings.cc | 6 +++--- shell/platform/linux/fl_settings.cc | 10 +++++----- shell/platform/linux/fl_text_input_plugin.cc | 18 +++++++++--------- shell/platform/linux/fl_view.cc | 8 ++++---- 6 files changed, 33 insertions(+), 33 deletions(-) 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/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_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(), From 88b5a99b818e8679467d75eb054f21e37bfaa78b Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Sun, 29 May 2022 18:39:21 -0700 Subject: [PATCH 05/14] Enable modernize-use-default-member-init --- .clang-tidy | 3 +++ flow/surface_frame.cc | 3 +-- fml/platform/posix/mapping_posix.cc | 3 +-- impeller/archivist/archive_database.cc | 2 +- impeller/archivist/archivist_unittests.cc | 2 +- impeller/geometry/path_component.h | 2 +- impeller/renderer/backend/gles/texture_gles.cc | 2 +- impeller/renderer/backend/metal/render_pass_mtl.mm | 3 ++- runtime/dart_isolate.cc | 4 ++-- shell/common/skia_event_tracer_impl.cc | 4 ++-- shell/gpu/gpu_surface_gl_skia.cc | 2 +- 11 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 00eed789209c5..2fc487f648f35 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,\ @@ -30,3 +31,5 @@ CheckOptions: value: 'k' - key: readability-identifier-naming.PrivateMemberSuffix value: '_' + - key: modernize-use-default-member-init.UseAssignment + value: 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/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/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/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/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(); From c398877db242b67ec23308ec18e5a2b1a4c88124 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Sun, 29 May 2022 18:47:40 -0700 Subject: [PATCH 06/14] Re-order lint config alphabetically --- .clang-tidy | 10 ++++++---- ci/licenses_golden/licenses_flutter | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 2fc487f648f35..686fd62cd861b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -23,13 +23,15 @@ google-objc-*,\ google-explicit-constructor" CheckOptions: - - key: readability-identifier-naming.PrivateMemberCase - value: 'lower_case' + - 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: '_' - - key: modernize-use-default-member-init.UseAssignment - value: true 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 From e8d7a204ec7a32a3374b841993b6632d4ec2f576 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Mon, 30 May 2022 14:28:26 -0700 Subject: [PATCH 07/14] Make TestPassDelegate ctor explicit --- impeller/entity/entity_unittests.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; From 487d4286680f32d286eb20aa15473f1a10336f7b Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Mon, 30 May 2022 14:28:40 -0700 Subject: [PATCH 08/14] Ignore clang-analyzer-deadcode.DeadStores in tests Adds NOLINT annotation to a couple of dead stores used to verify locking. --- impeller/base/base_unittests.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); } From 1c801c9b379b7abd28745bdc021567a07babade7 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Mon, 30 May 2022 14:29:41 -0700 Subject: [PATCH 09/14] Ignore clang-analyzer-deadcode.DeadStores in BlobLibrary ctor This is a dead store which we may want to eliminate. We do read from this field earlier in the constructor, and the offset should conceptually be incremented here, but it's never (currently) read after the conditional + memcpy earlier in the method. I'm assuming it may have been kept intentionally as potential future-proofing in case of future use of offset later in the method. This write can safely be removed with the current code though. --- impeller/blobcat/blob_library.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From a9f40b1fe13ddd9de7083e04bf297fcd5b354a69 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Fri, 17 Jun 2022 17:56:57 -0700 Subject: [PATCH 10/14] Update two enums to kCamelCase style --- shell/platform/linux/fl_settings_portal.cc | 4 ++-- shell/platform/linux/fl_view_accessible.cc | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) 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_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 | From 1df6c1430a54748ca995c82de8938dcbaab43364 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Fri, 17 Jun 2022 18:29:19 -0700 Subject: [PATCH 11/14] Add NOLINT for inja dependency --- impeller/compiler/reflector.cc | 2 ++ 1 file changed, 2 insertions(+) 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 From c59239b272dd5ecf11c6b7678e128ad9e6e07d25 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Fri, 17 Jun 2022 20:04:43 -0700 Subject: [PATCH 12/14] Don't warn on Metal const names --- impeller/renderer/backend/metal/command_buffer_mtl.mm | 9 +++++++++ 1 file changed, 9 insertions(+) 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: From 28894a99505d58f2bd86c36935b8328be4c03746 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Sat, 18 Jun 2022 10:59:53 -0700 Subject: [PATCH 13/14] Use kKeyboardModifier enum values --- .../Source/FlutterChannelKeyResponder.mm | 93 ++++++++++--------- 1 file changed, 50 insertions(+), 43 deletions(-) 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 From 726ab40a1a62524ce7b3864f9e0c039eb28613f4 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Sat, 18 Jun 2022 17:32:10 -0700 Subject: [PATCH 14/14] iOS text input enums prefixed with k --- .../Source/FlutterTextInputPlugin.mm | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) 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) {