Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Come up with a way to support surrounding text for Chromium-based apps on Windows #1289

@yukawa

Description

@yukawa

Description

Spun off from the following Chromium Issue (and the discussion in Mozc).

Currently Mozc ignores surrounding text if the corresponding ITfContext is a transitory context.

void FillMozcContextForOnKey(TipTextService *text_service, ITfContext *context,
Context *mozc_context) {
FillMozcContextCommon(text_service, context, mozc_context);
TipSurroundingTextInfo info;
if (!TipSurroundingText::Get(text_service, context, &info)) {
return;
}
if (info.is_transitory) {
// Ignore transitory context as it may not contain correct
// surrounding text info.
return;
}
if (info.has_preceding_text) {
mozc_context->set_preceding_text(WideToUtf8(info.preceding_text));
}
if (info.has_following_text) {
mozc_context->set_following_text(WideToUtf8(info.following_text));
}
}

result_.is_transitory =
((status.dwStaticFlags & TF_SS_TRANSITORY) == TF_SS_TRANSITORY);

I don't fully remember why I added this check, but it seems to make some sense when Mozc is interacting with legacy Win32 APP that does not use TSF (Text Services Framework) and common controls (EditText and RichEdit), where TSF API always returns an empty preceding/following text. Apps like Hidemaru and Sakura Editor fall into this category. If we mechanically removed the above check, mozc_tip{32,64}.dll would start reporting both the preceding and following texts are empty to mozc_server.exe even if they are not.

At the same time, removing TS_SS_TRANSITORY from Chromium is known to break several existing IMEs including Keyman.

Let's try to figure out a way to support surrounding text on Chromium-based apps in the Mozc side without reporting wrong surrounding text on other IMM32-based legacy apps.

Steps to reproduce

  1. Open data:text/html,<textarea>1</textarea> with Google Chrome 136.0.7103.114.
  2. Click the text area and move the cursor to the end.
  3. Select and enable Mozc
  4. Type hiki

Expected behavior

At the step 4, "匹" is suggested.

Actual behavior

At the step 4, "引き" is suggested.

Version or commit-id

18c5945

Environment

  • OS: Windows 11 24H2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions