New issue
Advanced search Search tips

Issue 824659 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: May 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

KeyboardController::OnTextInputStateChanged is being called before TextInputManager::SelectionBoundsChanged

Project Member Reported by shend@chromium.org, Mar 22 2018

Issue description

I'm trying to get the caret/selection bounds for a text field in KeyboardController. In KeyboardController::OnTextInputStateChanged, there's a TextInputClient which I can use to get the caret bounds. The TextInputClient grabs the bounds from a cached map in TextInputManager::GetSelectionRegion. However, from some logging, it appears that this cached map is getting updated (in TextInputManager::SelectionBoundsChanged) -after- I query the bounds in KeyboardController::OnTextInputStateChanged. So the values I'm getting are stale & inconsistent.

For example, I went to a website and:
1. Clicked on a textbox
2. Clicked somewhere else to defocus the textbox
3. Clicked on the same textbox again.

I got two wildly different values for the caret bounds in step 1 & 3. Here's a trace: https://pastebin.com/qxQHF4aa

For the trace:
- "** got caret bound" is where I log the result of getting the caret bound, and it's a different value the second time.
- "Changing selection region map" happens after "** got caret bound".

So it seems like the focus event is being triggered before the selection update. Is this intentional? If so, is it possible to change this behaviour so that the selection region is updated before it's queried? Are there any other workarounds?
 

Comment 1 by shend@chromium.org, Mar 22 2018

Owner: dtapu...@chromium.org
Status: Assigned (was: Available)
Hi dtapuska@, do you happen to know anything about this? Thanks!
Cc: dtapu...@chromium.org
Owner: yosin@chromium.org
These fields are replicated from the Blink editing logic. Sorry I don't have any ideas immediately off the top of my head. Over to yosin@ as this is more related to editing than input.

Comment 3 by yosin@chromium.org, Apr 18 2018

Components: -Blink>Editing>Selection UI>Input>Text>IME
Owner: ----
Status: Untriaged (was: Assigned)
Sorry for late response.

>the focus event is being triggered before the selection update. Is this intentional?
Yes. Focus event handler moves selection to text box 

>If so, is it possible to change this behaviour so that the selection region is updated before it's queried? 
It is not possible since focus event handler moves selection.

>Are there any other workarounds?
I'm not sure since I'm not familiar with KeyboardController code.

It seems this is content layer issue:
- RenderWidget::WillBeginCompositorFrame() calls UpdateTextInputState() then UpdateSelectionBounds()
- RenderWidget::OnImeEventGuardFinish() calls UpdateSelectionBounds() then UpdateTextInputState()


Comment 4 by shend@chromium.org, May 3 2018

Status: WontFix (was: Untriaged)
Thanks for digging into this. Sorry for the belated reply, but we'll try and figure out a workaround.

Sign in to add a comment