Skip to content

Commit c2485e1

Browse files
authored
backport fix allow ime insert zero length composition string. (electron#24055)
1 parent cb71ab3 commit c2485e1

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

patches/chromium/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,4 @@ cherry-pick-86c02c5dcd37.patch
124124
fix_hunspell_crash.patch
125125
introduce_a_mutex_for_the_rendering_loop_in_baseaudiocontext.patch
126126
fix_default_to_ntlm_v2_in_network_service.patch
127+
fix_allow_ime_to_insert_zero-length_composition_string.patch
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Peng Lyu <penn.lv@gmail.com>
3+
Date: Tue, 9 Jun 2020 21:49:37 -0700
4+
Subject: Fix: allow IME to insert zero-length composition string
5+
6+
Backport: https://chromium.googlesource.com/chromium/src.git/+/c20afc96e36f572d10c65d97f4313ba50a58280f%5E%21/#F0
7+
8+
diff --git a/ui/base/ime/win/tsf_text_store.cc b/ui/base/ime/win/tsf_text_store.cc
9+
index 069a7caf54f4bd9027d8c473eec9315e6f14d8ff..73188e73bd5fd0f162a9b23b045b8927d6536ad4 100644
10+
--- a/ui/base/ime/win/tsf_text_store.cc
11+
+++ b/ui/base/ime/win/tsf_text_store.cc
12+
@@ -610,9 +610,7 @@ STDMETHODIMP TSFTextStore::RequestLock(DWORD lock_flags, HRESULT* result) {
13+
// 3. User commits current composition text.
14+
if (((new_composition_start > last_composition_start &&
15+
text_input_client_->HasCompositionText()) ||
16+
- (wparam_keydown_fired_ == 0 && !has_composition_range_ &&
17+
- !text_input_client_->HasCompositionText()) ||
18+
- (wparam_keydown_fired_ != 0 && !has_composition_range_)) &&
19+
+ !has_composition_range_) &&
20+
text_input_client_) {
21+
CommitTextAndEndCompositionIfAny(last_composition_start,
22+
new_composition_start);
23+
@@ -1295,8 +1293,11 @@ void TSFTextStore::CommitTextAndEndCompositionIfAny(size_t old_size,
24+
: new_committed_string_size);
25+
// TODO(crbug.com/978678): Unify the behavior of
26+
// |TextInputClient::InsertText(text)| for the empty text.
27+
- if (!new_committed_string.empty())
28+
+ if (!new_committed_string.empty()) {
29+
text_input_client_->InsertText(new_committed_string);
30+
+ } else {
31+
+ text_input_client_->ClearCompositionText();
32+
+ }
33+
// Notify accessibility about this committed composition
34+
text_input_client_->SetActiveCompositionForAccessibility(
35+
replace_text_range_, new_committed_string,

0 commit comments

Comments
 (0)