Bug 1836806 - Make TextControlState::SetValueWithoutTextEditor() notify IMEContentObserver of value changes even if it has a bounding frame r=smaug

This is an edge case which couldn't be fixed in bug 1835353.

In the testcase, `TextControlState` has new frame for the new
`<input type="number">` when its `stepUp()` is called.  However, its
`TextEditor` has not been recreated yet because it's not safe yet.  Therefore,
`SetValueWithoutTextEditor()` is called, but I added the new path notifying
`IMEContentObserver` of the value changes does not run if `mBoundFrame` is not
`nullptr`.  I don't remember why I did so (probably for avoiding performance
regressions as far as possible), but it does not make sense not to notify
`IMEContentObserver` if only `mTextEditor` has not been recreated because
`IMEStateManager` has not been reinitialized `IMEContentObserver` with new
anonymous `<div>`s yet because it requires new `TextEditor` instance.

Differential Revision: https://phabricator.services.mozilla.com/D180767
This commit is contained in:
Masayuki Nakano
2023-06-14 01:26:33 +00:00
parent a385baf40d
commit df1a0740c5
4 changed files with 32 additions and 7 deletions

View File

@@ -2950,11 +2950,13 @@ bool TextControlState::SetValueWithoutTextEditor(
if (mBoundFrame) {
mBoundFrame->UpdateValueDisplay(true);
}
// If the text control element has focus, IMEContentObserver is not
// observing the content changes due to no bound frame. Therefore,
// we need to let IMEContentObserver know all values are being replaced.
else if (IMEContentObserver* observer = GetIMEContentObserver()) {
observer->OnTextControlValueChangedDuringNoFrame(mValue);
// observing the content changes due to no bound frame or no TextEditor.
// Therefore, we need to let IMEContentObserver know all values are being
// replaced.
if (IMEContentObserver* observer = GetIMEContentObserver()) {
observer->OnTextControlValueChangedWhileNotObservable(mValue);
}
}