Bug 1432528 - part 2: Make EditorBase treat TextInputListener directly and make TextInputListener not derived from nsIEditorObserver r=m_kato
Now, EditorBase can store TextInputListener directly instead of as nsIEditorObserver. And then, EditorBase can call its EditAction() method directly. Therefore, we can make TextInputListener not derived from nsIEditorObserver. MozReview-Commit-ID: 4qPnnvReLKy
This commit is contained in:
@@ -805,11 +805,18 @@ TextInputListener::TextInputListener(nsITextControlElement* aTxtCtrlElement)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(TextInputListener,
|
||||
nsISelectionListener,
|
||||
nsIEditorObserver,
|
||||
nsISupportsWeakReference,
|
||||
nsIDOMEventListener)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(TextInputListener)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(TextInputListener)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(TextInputListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISelectionListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISelectionListener)
|
||||
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(TextInputListener)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_0(TextInputListener)
|
||||
|
||||
// BEGIN nsIDOMSelectionListener
|
||||
|
||||
@@ -968,15 +975,13 @@ TextInputListener::HandleEvent(nsIDOMEvent* aEvent)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// BEGIN nsIEditorObserver
|
||||
|
||||
NS_IMETHODIMP
|
||||
TextInputListener::EditAction()
|
||||
void
|
||||
TextInputListener::OnEditActionHandled()
|
||||
{
|
||||
if (!mFrame) {
|
||||
// We've been disconnected from the nsTextEditorState object, nothing to do
|
||||
// here.
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
AutoWeakFrame weakFrame = mFrame;
|
||||
@@ -1002,12 +1007,10 @@ TextInputListener::EditAction()
|
||||
}
|
||||
|
||||
if (!weakFrame.IsAlive()) {
|
||||
return NS_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
HandleValueChanged(frame);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1030,21 +1033,6 @@ TextInputListener::HandleValueChanged(nsTextControlFrame* aFrame)
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TextInputListener::BeforeEditAction()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TextInputListener::CancelEditAction()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// END nsIEditorObserver
|
||||
|
||||
|
||||
nsresult
|
||||
TextInputListener::UpdateTextInputCommands(const nsAString& aCommandsToUpdate,
|
||||
nsISelection* aSelection,
|
||||
@@ -1548,7 +1536,7 @@ nsTextEditorState::PrepareEditor(const nsAString *aValue)
|
||||
}
|
||||
|
||||
if (mTextListener) {
|
||||
newTextEditor->AddEditorObserver(mTextListener);
|
||||
newTextEditor->SetTextInputListener(mTextListener);
|
||||
}
|
||||
|
||||
// Restore our selection after being bound to a new frame
|
||||
@@ -2018,9 +2006,6 @@ nsTextEditorState::DestroyEditor()
|
||||
{
|
||||
// notify the editor that we are going away
|
||||
if (mEditorInitialized) {
|
||||
if (mTextListener) {
|
||||
mTextEditor->RemoveEditorObserver(mTextListener);
|
||||
}
|
||||
mTextEditor->PreDestroy(true);
|
||||
mEditorInitialized = false;
|
||||
}
|
||||
@@ -2040,7 +2025,7 @@ nsTextEditorState::UnbindFromFrame(nsTextControlFrame* aFrame)
|
||||
// before EditAction() is called if selection listener causes flushing layout.
|
||||
if (mTextListener && mTextEditor && mEditorInitialized &&
|
||||
mTextEditor->IsInEditAction()) {
|
||||
mTextListener->EditAction();
|
||||
mTextListener->OnEditActionHandled();
|
||||
}
|
||||
|
||||
// We need to start storing the value outside of the editor if we're not
|
||||
|
||||
Reference in New Issue
Block a user