Bug 1835353 - Make TextControlState notify IMEContentObserver of setting new value during no frame r=smaug
`IMEContentObserver` can observe the value changes only while the text control has anonymous `<div>` element because it observers the DOM mutation. The anonymous `<div>` is alive (connected) only while the text control element has a frame (recreated at each reframe). Therefore, `IMEContentObserver` cannot observe the value changed during reframing. This patch makes `TextControlState` notify `IMEContentObserver` of setting new value directly only when it does not have `mBoundFrame`. Differential Revision: https://phabricator.services.mozilla.com/D179358
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
|
||||
#include "TextControlState.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/IMEContentObserver.h"
|
||||
#include "mozilla/IMEStateManager.h"
|
||||
#include "mozilla/TextInputListener.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
@@ -2948,6 +2950,12 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
// If this is called as part of user input, we need to dispatch "input"
|
||||
@@ -3040,4 +3048,12 @@ bool TextControlState::EditorHasComposition() {
|
||||
return mTextEditor && mTextEditor->IsIMEComposing();
|
||||
}
|
||||
|
||||
IMEContentObserver* TextControlState::GetIMEContentObserver() const {
|
||||
if (NS_WARN_IF(!mTextCtrlElement) ||
|
||||
mTextCtrlElement != IMEStateManager::GetFocusedElement()) {
|
||||
return nullptr;
|
||||
}
|
||||
return IMEStateManager::GetActiveContentObserver();
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
Reference in New Issue
Block a user