From 1017f8e6879b02ecb3d64c4760b8e6030522f2e0 Mon Sep 17 00:00:00 2001 From: yaakovschectman <109111084+yaakovschectman@users.noreply.github.com> Date: Wed, 13 Sep 2023 16:17:48 -0400 Subject: [PATCH 1/3] Use `start` instead of `extent` for Windows IME cursor position (#45667) When composing with the IME in a text edit, we should add the `start` of the composition range to the in-composition `cursor_pos` rather than its `extent`. When using `extent`, the cursor position would always be outside of the composition range, resulting in the linked bug. Add a test to check cursor position. https://github.com/flutter/flutter/issues/123749 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [x] I updated/added relevant documentation (doc comments with `///`). - [ ] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat --- shell/platform/windows/text_input_plugin.cc | 2 +- .../windows/text_input_plugin_unittest.cc | 63 ++++++++++++++++++- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/shell/platform/windows/text_input_plugin.cc b/shell/platform/windows/text_input_plugin.cc index 340092e3edb79..08c0007a4d083 100644 --- a/shell/platform/windows/text_input_plugin.cc +++ b/shell/platform/windows/text_input_plugin.cc @@ -196,7 +196,7 @@ void TextInputPlugin::ComposeChangeHook(const std::u16string& text, std::string text_before_change = active_model_->GetText(); TextRange composing_before_change = active_model_->composing_range(); active_model_->AddText(text); - cursor_pos += active_model_->composing_range().extent(); + cursor_pos += active_model_->composing_range().start(); active_model_->UpdateComposingText(text); active_model_->SetSelection(TextRange(cursor_pos, cursor_pos)); std::string text_after_change = active_model_->GetText(); diff --git a/shell/platform/windows/text_input_plugin_unittest.cc b/shell/platform/windows/text_input_plugin_unittest.cc index 7d4705096441d..a99e0149aa286 100644 --- a/shell/platform/windows/text_input_plugin_unittest.cc +++ b/shell/platform/windows/text_input_plugin_unittest.cc @@ -36,6 +36,8 @@ static constexpr char kSelectionAffinityKey[] = "selectionAffinity"; static constexpr char kSelectionIsDirectionalKey[] = "selectionIsDirectional"; static constexpr char kComposingBaseKey[] = "composingBase"; static constexpr char kComposingExtentKey[] = "composingExtent"; +static constexpr char kUpdateEditingStateMethod[] = + "TextInputClient.updateEditingState"; static std::unique_ptr> CreateResponse(bool handled) { auto response_doc = @@ -243,7 +245,7 @@ TEST(TextInputPluginTest, VerifyInputActionNewlineInsertNewLine) { // Editing state should have been updated. auto encoded_arguments = EncodedEditingState("\n", TextRange(1)); auto update_state_message = codec.EncodeMethodCall( - {"TextInputClient.updateEditingState", std::move(encoded_arguments)}); + {kUpdateEditingStateMethod, std::move(encoded_arguments)}); EXPECT_TRUE(std::equal(update_state_message->begin(), update_state_message->end(), @@ -366,6 +368,65 @@ TEST(TextInputPluginTest, TextEditingWorksWithDeltaModel) { // Passes if it did not crash } +// Regression test for https://github.com/flutter/flutter/issues/123749 +TEST(TextInputPluginTest, CompositionCursorPos) { + int selection_base = -1; + TestBinaryMessenger messenger([&](const std::string& channel, + const uint8_t* message, size_t size, + BinaryReply reply) { + auto method = JsonMethodCodec::GetInstance().DecodeMethodCall( + std::vector(message, message + size)); + if (method->method_name() == kUpdateEditingStateMethod) { + const auto& args = *method->arguments(); + const auto& editing_state = args[1]; + auto base = editing_state.FindMember(kSelectionBaseKey); + auto extent = editing_state.FindMember(kSelectionExtentKey); + ASSERT_NE(base, editing_state.MemberEnd()); + ASSERT_TRUE(base->value.IsInt()); + ASSERT_NE(extent, editing_state.MemberEnd()); + ASSERT_TRUE(extent->value.IsInt()); + selection_base = base->value.GetInt(); + EXPECT_EQ(extent->value.GetInt(), selection_base); + } + }); + MockTextInputPluginDelegate delegate; + + TextInputPlugin plugin(&messenger, &delegate); + + auto args = std::make_unique(rapidjson::kArrayType); + auto& allocator = args->GetAllocator(); + args->PushBack(123, allocator); // client_id + rapidjson::Value client_config(rapidjson::kObjectType); + args->PushBack(client_config, allocator); + auto encoded = JsonMethodCodec::GetInstance().EncodeMethodCall( + MethodCall(kSetClientMethod, std::move(args))); + EXPECT_TRUE(messenger.SimulateEngineMessage( + kChannelName, encoded->data(), encoded->size(), + [](const uint8_t* reply, size_t reply_size) {})); + + plugin.ComposeBeginHook(); + EXPECT_EQ(selection_base, 0); + plugin.ComposeChangeHook(u"abc", 3); + EXPECT_EQ(selection_base, 3); + + plugin.ComposeCommitHook(); + plugin.ComposeEndHook(); + EXPECT_EQ(selection_base, 3); + + plugin.ComposeBeginHook(); + plugin.ComposeChangeHook(u"1", 1); + EXPECT_EQ(selection_base, 4); + + plugin.ComposeChangeHook(u"12", 2); + EXPECT_EQ(selection_base, 5); + + plugin.ComposeChangeHook(u"12", 1); + EXPECT_EQ(selection_base, 4); + + plugin.ComposeChangeHook(u"12", 2); + EXPECT_EQ(selection_base, 5); +} + TEST(TextInputPluginTest, TransformCursorRect) { // A position of `EditableText`. double view_x = 100; From f6161c4bae2a71dfb44e6d3d27112498b4d79d60 Mon Sep 17 00:00:00 2001 From: skia-flutter-autoroll Date: Wed, 13 Sep 2023 16:23:22 -0400 Subject: [PATCH 2/3] Roll Skia from e39cf360ea93 to b38989859b81 (4 revisions) (#45787) https://skia.googlesource.com/skia.git/+log/e39cf360ea93..b38989859b81 2023-09-13 johnstiles@google.com Fix GCC warning about missing function. 2023-09-13 johnstiles@google.com Fix redundant-move warning from GCC. 2023-09-13 egdaniel@google.com Add support for Vulkan 10x6 format. 2023-09-13 johnstiles@google.com Fix -Wclass-memaccess warning when bit-casting SkRects. If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/skia-flutter-autoroll Please CC bdero@google.com,brianosman@google.com,jmbetancourt@google.com,rmistry@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Skia: https://bugs.chromium.org/p/skia/issues/entry To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md --- DEPS | 2 +- ci/licenses_golden/licenses_skia | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DEPS b/DEPS index b3193f8abbdc6..8f814d4028cc8 100644 --- a/DEPS +++ b/DEPS @@ -18,7 +18,7 @@ vars = { 'llvm_git': 'https://llvm.googlesource.com', # OCMock is for testing only so there is no google clone 'ocmock_git': 'https://github.com/erikdoe/ocmock.git', - 'skia_revision': 'e39cf360ea93daeb8e0997908a44f8d298730ce8', + 'skia_revision': 'b38989859b81cba40dc7e83d99333dd51bef8c1b', # WARNING: DO NOT EDIT canvaskit_cipd_instance MANUALLY # See `lib/web_ui/README.md` for how to roll CanvasKit to a new version. diff --git a/ci/licenses_golden/licenses_skia b/ci/licenses_golden/licenses_skia index 6fb15209df5f1..5ecc4480c063d 100644 --- a/ci/licenses_golden/licenses_skia +++ b/ci/licenses_golden/licenses_skia @@ -1,4 +1,4 @@ -Signature: 8ef10e4ab0d396fd7a4dde6d2a3971dc +Signature: 5e75d16bc1041d3acb02a6c33a916dba ==================================================================================================== LIBRARY: etc1 From cd90cc8469fbc789e0b44adc79f330f8d4d2744c Mon Sep 17 00:00:00 2001 From: godofredoc Date: Wed, 13 Sep 2023 13:31:08 -0700 Subject: [PATCH 3/3] Update dependabot.yml (#45788) Remove pubspec.yaml portion of directory. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5010e1b1b248a..9688ddae25af1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -16,7 +16,7 @@ updates: - dependency-name: "github/codeql-action" update-types: ["version-update:semver-minor"] - package-ecosystem: "pub" - directory: "/lib/web_ui/pubspec.yaml" + directory: "/lib/web_ui" schedule: interval: "daily" labels: