зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1386960
- Call nsTextInputListener's callback manually after using the non-transaction based editor code path for setting values of input controls; r=bzbarsky
This commit is contained in:
Родитель
64c81d4d30
Коммит
061d437c9e
|
@ -802,10 +802,10 @@ nsTextInputSelectionImpl::CheckVisibilityContent(nsIContent* aNode,
|
|||
return shell->CheckVisibilityContent(aNode, aStartOffset, aEndOffset, aRetval);
|
||||
}
|
||||
|
||||
class nsTextInputListener : public nsISelectionListener,
|
||||
public nsIDOMEventListener,
|
||||
public nsIEditorObserver,
|
||||
public nsSupportsWeakReference
|
||||
class nsTextInputListener final : public nsISelectionListener,
|
||||
public nsIDOMEventListener,
|
||||
public nsIEditorObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
/** the default constructor
|
||||
|
@ -820,6 +820,10 @@ public:
|
|||
void SettingValue(bool aValue) { mSettingValue = aValue; }
|
||||
void SetValueChanged(bool aSetValueChanged) { mSetValueChanged = aSetValueChanged; }
|
||||
|
||||
// aFrame is an optional pointer to our frame, if not passed the method will
|
||||
// use mFrame to compute it lazily.
|
||||
void HandleValueChanged(nsTextControlFrame* aFrame = nullptr);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSISELECTIONLISTENER
|
||||
|
@ -1082,18 +1086,29 @@ nsTextInputListener::EditAction()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
HandleValueChanged(frame);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsTextInputListener::HandleValueChanged(nsTextControlFrame* aFrame)
|
||||
{
|
||||
// Make sure we know we were changed (do NOT set this to false if there are
|
||||
// no undo items; JS could change the value and we'd still need to save it)
|
||||
if (mSetValueChanged) {
|
||||
frame->SetValueChanged(true);
|
||||
if (!aFrame) {
|
||||
nsITextControlFrame* frameBase = do_QueryFrame(mFrame);
|
||||
aFrame = static_cast<nsTextControlFrame*> (frameBase);
|
||||
NS_ASSERTION(aFrame, "Where is our frame?");
|
||||
}
|
||||
aFrame->SetValueChanged(true);
|
||||
}
|
||||
|
||||
if (!mSettingValue) {
|
||||
mTxtCtrlElement->OnValueChanged(/* aNotify = */ true,
|
||||
/* aWasInteractiveUserChange = */ true);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -2684,6 +2699,11 @@ nsTextEditorState::SetValue(const nsAString& aValue, const nsAString* aOldValue,
|
|||
}
|
||||
|
||||
textEditor->SetText(newValue);
|
||||
|
||||
// Call the listener's HandleValueChanged() callback manually, since
|
||||
// we don't use the transaction manager in this path and it could be
|
||||
// that the editor would bypass calling the listener for that reason.
|
||||
mTextListener->HandleValueChanged();
|
||||
}
|
||||
|
||||
mTextListener->SetValueChanged(true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче