diff options
Diffstat (limited to 'editor/libeditor')
-rw-r--r-- | editor/libeditor/EditorBase.h | 3 | ||||
-rw-r--r-- | editor/libeditor/EditorEventListener.cpp | 6 | ||||
-rw-r--r-- | editor/libeditor/TextEditor.cpp | 24 | ||||
-rw-r--r-- | editor/libeditor/TextEditor.h | 3 |
4 files changed, 22 insertions, 14 deletions
diff --git a/editor/libeditor/EditorBase.h b/editor/libeditor/EditorBase.h index dd4b9695e6..86be780c09 100644 --- a/editor/libeditor/EditorBase.h +++ b/editor/libeditor/EditorBase.h @@ -247,7 +247,8 @@ public: * IME event handlers. */ virtual nsresult BeginIMEComposition(WidgetCompositionEvent* aEvent); - virtual nsresult UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent) = 0; + virtual nsresult UpdateIMEComposition( + WidgetCompositionEvent* aCompositionChangeEvent) = 0; void EndIMEComposition(); void SwitchTextDirectionTo(uint32_t aDirection); diff --git a/editor/libeditor/EditorEventListener.cpp b/editor/libeditor/EditorEventListener.cpp index f90458d3ed..69833ce843 100644 --- a/editor/libeditor/EditorEventListener.cpp +++ b/editor/libeditor/EditorEventListener.cpp @@ -791,7 +791,11 @@ EditorEventListener::HandleText(nsIDOMEvent* aTextEvent) return NS_OK; } - return mEditorBase->UpdateIMEComposition(aTextEvent); + // AsCompositionEvent() should always return non-nullptr. Anyway, it'll be + // checked in TextEditor::UpdateIMEComposition(). + WidgetCompositionEvent* compositionChangeEvent = + aTextEvent->WidgetEventPtr()->AsCompositionEvent(); + return mEditorBase->UpdateIMEComposition(compositionChangeEvent); } /** diff --git a/editor/libeditor/TextEditor.cpp b/editor/libeditor/TextEditor.cpp index 8fe824e112..d215855977 100644 --- a/editor/libeditor/TextEditor.cpp +++ b/editor/libeditor/TextEditor.cpp @@ -834,17 +834,19 @@ TextEditor::BeginIMEComposition(WidgetCompositionEvent* aEvent) } nsresult -TextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent) +TextEditor::UpdateIMEComposition(WidgetCompositionEvent* aCompositionChangeEvent) { - MOZ_ASSERT(aDOMTextEvent, "aDOMTextEvent must not be nullptr"); + MOZ_ASSERT(aCompsitionChangeEvent, + "aCompositionChangeEvent must not be nullptr"); - WidgetCompositionEvent* compositionChangeEvent = - aDOMTextEvent->WidgetEventPtr()->AsCompositionEvent(); - NS_ENSURE_TRUE(compositionChangeEvent, NS_ERROR_INVALID_ARG); - MOZ_ASSERT(compositionChangeEvent->mMessage == eCompositionChange, - "The internal event should be eCompositionChange"); + if (NS_WARN_IF(!aCompositionChangeEvent)) { + return NS_ERROR_INVALID_ARG; + } + + MOZ_ASSERT(aCompositionChangeEvent->mMessage == eCompositionChange, + "The event should be eCompositionChange"); - if (!EnsureComposition(compositionChangeEvent)) { + if (!EnsureComposition(aCompositionChangeEvent)) { return NS_OK; } @@ -865,7 +867,7 @@ TextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent) MOZ_ASSERT(!mPlaceHolderBatch, "UpdateIMEComposition() must be called without place holder batch"); TextComposition::CompositionChangeEventHandlingMarker - compositionChangeEventHandlingMarker(mComposition, compositionChangeEvent); + compositionChangeEventHandlingMarker(mComposition, aCompositionChangeEvent); NotifyEditorObservers(eNotifyEditorObserversOfBefore); @@ -875,7 +877,7 @@ TextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent) { AutoPlaceHolderBatch batch(this, nsGkAtoms::IMETxnName); - rv = InsertText(compositionChangeEvent->mData); + rv = InsertText(aCompositionChangeEvent->mData); if (caretP) { caretP->SetSelection(selection); @@ -887,7 +889,7 @@ TextEditor::UpdateIMEComposition(nsIDOMEvent* aDOMTextEvent) // compositionend event, we don't need to notify editor observes of this // change. // NOTE: We must notify after the auto batch will be gone. - if (!compositionChangeEvent->IsFollowedByCompositionEnd()) { + if (!aCompositionChangeEvent->IsFollowedByCompositionEnd()) { NotifyEditorObservers(eNotifyEditorObserversOfEnd); } diff --git a/editor/libeditor/TextEditor.h b/editor/libeditor/TextEditor.h index 872cd91d3d..31c551f852 100644 --- a/editor/libeditor/TextEditor.h +++ b/editor/libeditor/TextEditor.h @@ -130,7 +130,8 @@ public: virtual already_AddRefed<dom::EventTarget> GetDOMEventTarget() override; virtual nsresult BeginIMEComposition(WidgetCompositionEvent* aEvent) override; - virtual nsresult UpdateIMEComposition(nsIDOMEvent* aTextEvent) override; + virtual nsresult UpdateIMEComposition( + WidgetCompositionEvent* aCompositionChangeEvent) override; virtual already_AddRefed<nsIContent> GetInputEventTargetContent() override; |