summaryrefslogtreecommitdiffstats
path: root/editor
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-06-26 13:26:07 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-06-26 13:26:07 +0200
commit783f57d74b0caf84cec01a0ae43a2a8cb8697673 (patch)
tree4f553014261185615fb198cdeb270f2437b22d48 /editor
parent5a559eb6c9c9cf05206506b0ea62fe9337834b9c (diff)
downloadUXP-783f57d74b0caf84cec01a0ae43a2a8cb8697673.tar
UXP-783f57d74b0caf84cec01a0ae43a2a8cb8697673.tar.gz
UXP-783f57d74b0caf84cec01a0ae43a2a8cb8697673.tar.lz
UXP-783f57d74b0caf84cec01a0ae43a2a8cb8697673.tar.xz
UXP-783f57d74b0caf84cec01a0ae43a2a8cb8697673.zip
Issue #12 Part 1: Stop using nsIDOMEvent in UpdateIMEComposition.
Diffstat (limited to 'editor')
-rw-r--r--editor/libeditor/EditorBase.h3
-rw-r--r--editor/libeditor/EditorEventListener.cpp6
-rw-r--r--editor/libeditor/TextEditor.cpp24
-rw-r--r--editor/libeditor/TextEditor.h3
4 files changed, 22 insertions, 14 deletions
diff --git a/editor/libeditor/EditorBase.h b/editor/libeditor/EditorBase.h
index dd4b9695e..86be780c0 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 f90458d3e..69833ce84 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 8fe824e11..d21585597 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 872cd91d3..31c551f85 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;