From 1ffd44b70b60c74bcec1a2e4d246684b42bb6334 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Mon, 15 Feb 2021 11:32:18 -0800 Subject: [PATCH] Add missing header guard, namespace TextRange was missing a namespace declaration and header guards. --- shell/platform/common/text_range.h | 9 +++++++++ shell/platform/linux/fl_text_input_plugin.cc | 10 ++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/shell/platform/common/text_range.h b/shell/platform/common/text_range.h index d951c45f98e6e..f1168942b0b70 100644 --- a/shell/platform/common/text_range.h +++ b/shell/platform/common/text_range.h @@ -2,10 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#ifndef FLUTTER_SHELL_PLATFORM_COMMON_TEXT_RANGE_H_ +#define FLUTTER_SHELL_PLATFORM_COMMON_TEXT_RANGE_H_ + #include #include "flutter/fml/logging.h" +namespace flutter { + // A directional range of text. // // A |TextRange| describes a range of text with |base| and |extent| positions. @@ -92,3 +97,7 @@ class TextRange { size_t base_; size_t extent_; }; + +} // namespace flutter + +#endif // FLUTTER_SHELL_PLATFORM_COMMON_TEXT_RANGE_H_ diff --git a/shell/platform/linux/fl_text_input_plugin.cc b/shell/platform/linux/fl_text_input_plugin.cc index 9a568a6cfbaac..2e71dfb66c701 100644 --- a/shell/platform/linux/fl_text_input_plugin.cc +++ b/shell/platform/linux/fl_text_input_plugin.cc @@ -113,7 +113,7 @@ static void update_editing_state(FlTextInputPlugin* self) { fl_value_append_take(args, fl_value_new_int(priv->client_id)); g_autoptr(FlValue) value = fl_value_new_map(); - TextRange selection = priv->text_model->selection(); + flutter::TextRange selection = priv->text_model->selection(); fl_value_set_string_take( value, kTextKey, fl_value_new_string(priv->text_model->GetText().c_str())); @@ -195,7 +195,8 @@ static void im_preedit_changed_cb(FlTextInputPlugin* self) { &cursor_offset); cursor_offset += priv->text_model->composing_range().base(); priv->text_model->UpdateComposingText(buf); - priv->text_model->SetSelection(TextRange(cursor_offset, cursor_offset)); + priv->text_model->SetSelection( + flutter::TextRange(cursor_offset, cursor_offset)); update_editing_state(self); } @@ -311,7 +312,8 @@ static FlMethodResponse* set_editing_state(FlTextInputPlugin* self, } priv->text_model->SetText(text); - priv->text_model->SetSelection(TextRange(selection_base, selection_extent)); + priv->text_model->SetSelection( + flutter::TextRange(selection_base, selection_extent)); int64_t composing_base = fl_value_get_int(fl_value_lookup_string(args, kComposingBaseKey)); @@ -323,7 +325,7 @@ static FlMethodResponse* set_editing_state(FlTextInputPlugin* self, size_t composing_start = std::min(composing_base, composing_extent); size_t cursor_offset = selection_base - composing_start; priv->text_model->SetComposingRange( - TextRange(composing_base, composing_extent), cursor_offset); + flutter::TextRange(composing_base, composing_extent), cursor_offset); } return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));