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: 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 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;