From e94538efb5e82f51ccc3f4d20fc46e983da4fcbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E7=84=95=E9=9A=86?= Date: Mon, 18 Apr 2022 10:41:26 +0800 Subject: [PATCH] =?UTF-8?q?flutter/BUILD.gn=E6=97=A0=E7=94=A8=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E5=88=A0=E9=99=A4=EF=BC=8C=E7=AD=89=E5=85=B6=E5=AE=83?= =?UTF-8?q?PR=E8=AF=84=E8=AE=BA=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴焕隆 --- build/external_config/flutter/BUILD.gn | 22 +---- frameworks/core/common/ime/text_compose.h | 97 ++++++++++--------- .../core/common/ime/text_editing_value.cpp | 6 +- 3 files changed, 54 insertions(+), 71 deletions(-) diff --git a/build/external_config/flutter/BUILD.gn b/build/external_config/flutter/BUILD.gn index 80270bcd..b84cb92f 100644 --- a/build/external_config/flutter/BUILD.gn +++ b/build/external_config/flutter/BUILD.gn @@ -437,8 +437,9 @@ template("flutter_engine_shell") { "$flutter_root/engine/flutter/shell/platform/ohos/platform_task_runner_adapter.cc", "$flutter_root/engine/flutter/shell/platform/ohos/platform_view_ohos.cc", ] - if ((!defined(config.disable_gpu) || !config.disable_gpu) && (!defined( - config.enable_rosen_backend) || !config.enable_rosen_backend)) { + if ((!defined(config.disable_gpu) || !config.disable_gpu) && + (!defined(config.enable_rosen_backend) || + !config.enable_rosen_backend)) { sources += [ "$flutter_root/engine/flutter/shell/platform/ohos/ohos_surface_gl.cc", ] @@ -497,8 +498,6 @@ template("flutter_engine_shell") { _flutter_framework_headers = [ "$ios_prefix/framework/Headers/Flutter.h", "$ios_prefix/framework/Headers/FlutterAppDelegate.h", - - # "$ios_prefix/framework/Headers/FlutterCallbackCache.h", "$ios_prefix/framework/Headers/FlutterDartProject.h", "$ios_prefix/framework/Headers/FlutterEngine.h", "$ios_prefix/framework/Headers/FlutterHeadlessDartRunner.h", @@ -514,21 +513,14 @@ template("flutter_engine_shell") { "$flutter_root/engine/flutter/shell/platform/darwin/common/command_line.mm", "$flutter_root/engine/flutter/shell/common/switches.cc", "$flutter_root/engine/flutter/shell/common/switches.h", - "$ios_prefix/framework/Source/FlutterAppDelegate.mm", "$ios_prefix/framework/Source/FlutterAppDelegate_Internal.h", "$ios_prefix/framework/Source/FlutterBinaryMessengerRelay.mm", - - # "$ios_prefix/framework/Source/FlutterCallbackCache.mm", - # "$ios_prefix/framework/Source/FlutterCallbackCache_Internal.h", "$ios_prefix/framework/Source/FlutterDartProject.mm", "$ios_prefix/framework/Source/FlutterDartProject_Internal.h", "$ios_prefix/framework/Source/FlutterEngine.mm", "$ios_prefix/framework/Source/FlutterEngine_Internal.h", "$ios_prefix/framework/Source/FlutterHeadlessDartRunner.mm", - - # "$ios_prefix/framework/Source/FlutterObservatoryPublisher.h", - # "$ios_prefix/framework/Source/FlutterObservatoryPublisher.mm", "$ios_prefix/framework/Source/FlutterOverlayView.h", "$ios_prefix/framework/Source/FlutterOverlayView.mm", "$ios_prefix/framework/Source/FlutterPlatformPlugin.h", @@ -538,18 +530,10 @@ template("flutter_engine_shell") { "$ios_prefix/framework/Source/FlutterPlatformViews_Internal.mm", "$ios_prefix/framework/Source/FlutterPluginAppLifeCycleDelegate.mm", "$ios_prefix/framework/Source/FlutterTextInputDelegate.h", - - # "$ios_prefix/framework/Source/FlutterTextInputPlugin.h", - # "$ios_prefix/framework/Source/FlutterTextInputPlugin.mm", "$ios_prefix/framework/Source/FlutterView.h", "$ios_prefix/framework/Source/FlutterView.mm", "$ios_prefix/framework/Source/FlutterViewController.mm", "$ios_prefix/framework/Source/FlutterViewController_Internal.h", - - # "$ios_prefix/framework/Source/accessibility_bridge.h", - # "$ios_prefix/framework/Source/accessibility_bridge.mm", - # "$ios_prefix/framework/Source/accessibility_text_entry.h", - # "$ios_prefix/framework/Source/accessibility_text_entry.mm", "$ios_prefix/framework/Source/platform_message_response_darwin.h", "$ios_prefix/framework/Source/platform_message_response_darwin.mm", "$ios_prefix/framework/Source/platform_message_router.h", diff --git a/frameworks/core/common/ime/text_compose.h b/frameworks/core/common/ime/text_compose.h index 1c237666..a7e3fd32 100644 --- a/frameworks/core/common/ime/text_compose.h +++ b/frameworks/core/common/ime/text_compose.h @@ -17,6 +17,7 @@ #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_IME_TEXT_COMPOSE_H #include + #include "core/common/ime/constant.h" namespace OHOS::Ace { @@ -24,53 +25,53 @@ namespace OHOS::Ace { * Stands for what text is selected and how the directional is. * We use base/extent to indicate the start/end position because of uncertain direction. */ - struct TextCompose { - TextCompose() = default; - TextCompose(int32_t base, int32_t extent) : baseOffset(base), extentOffset(extent) {} - void Update(int32_t base, int32_t extent) - { - baseOffset = base; - extentOffset = extent; - } - // Usually called when none is selected. - void Update(int32_t both) - { - baseOffset = both; - extentOffset = both; - } - bool operator==(const TextCompose& other) const - { - return baseOffset == other.baseOffset && extentOffset == other.extentOffset; - } - bool operator!=(const TextCompose& other) const - { - return !operator==(other); - } - /** - * @brief Get first selected character in the text. - */ - inline int32_t GetStart() const - { - return std::min(baseOffset, extentOffset); - } - /** - * @brief Get last selected character in the text. - */ - inline int32_t GetEnd() const - { - return std::max(baseOffset, extentOffset); - } - /** - * @brief Whether selection is valid. - */ - inline bool IsValid() const - { - return baseOffset > -1 && extentOffset > -1; - } - // May larger than, smaller than or equal to extentOffset. - int32_t baseOffset = -1; - // When paints caret, this is where the caret position is. - int32_t extentOffset = -1; - }; +struct TextCompose { + TextCompose() = default; + TextCompose(int32_t base, int32_t extent) : baseOffset(base), extentOffset(extent) {} + void Update(int32_t base, int32_t extent) + { + baseOffset = base; + extentOffset = extent; + } + // Usually called when none is selected. + void Update(int32_t both) + { + baseOffset = both; + extentOffset = both; + } + bool operator==(const TextCompose& other) const + { + return baseOffset == other.baseOffset && extentOffset == other.extentOffset; + } + bool operator!=(const TextCompose& other) const + { + return !operator==(other); + } + /** + * @brief Get first selected character in the text. + */ + inline int32_t GetStart() const + { + return std::min(baseOffset, extentOffset); + } + /** + * @brief Get last selected character in the text. + */ + inline int32_t GetEnd() const + { + return std::max(baseOffset, extentOffset); + } + /** + * @brief Whether selection is valid. + */ + inline bool IsValid() const + { + return baseOffset > -1 && extentOffset > -1; + } + // May larger than, smaller than or equal to extentOffset. + int32_t baseOffset = -1; + // When paints caret, this is where the caret position is. + int32_t extentOffset = -1; +}; } // namespace OHOS::Ace #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_IME_TEXT_COMPOSE_H \ No newline at end of file diff --git a/frameworks/core/common/ime/text_editing_value.cpp b/frameworks/core/common/ime/text_editing_value.cpp index 783c68f5..f33608a4 100644 --- a/frameworks/core/common/ime/text_editing_value.cpp +++ b/frameworks/core/common/ime/text_editing_value.cpp @@ -28,8 +28,6 @@ const char TEXT[] = "text"; const char HINT[] = "hint"; const char SELECTION_START[] = "selectionStart"; const char SELECTION_END[] = "selectionEnd"; -const int NEXT_CHAR_INDEX_1 = 1; -const int NEXT_CHAR_INDEX_2 = 2; } // namespace @@ -92,8 +90,8 @@ void TextEditingValue::MoveRight() int32_t nextCharIndex = selection.extentOffset; selection.Update(StringUtils::NotInUtf16Bmp(utf16Text[nextCharIndex]) - ? std::min(static_cast(utf16Text.length()), nextCharIndex + NEXT_CHAR_INDEX_2) - : nextCharIndex + NEXT_CHAR_INDEX_1); + ? std::min(static_cast(utf16Text.length()), nextCharIndex + 2) + : nextCharIndex + 1); } void TextEditingValue::MoveToPosition(int32_t position)