summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/HTMLEditorEventListener.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-06-26 13:55:33 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-06-26 13:55:33 +0200
commit6aa47456c3d5d1952212ff3e970f617e5f6f3617 (patch)
tree2f64682d3e1b84c0fa924c3c4238a4d8421f5b03 /editor/libeditor/HTMLEditorEventListener.cpp
parenta7bc62dcfe5495c8b53532c1b585af07171b4403 (diff)
downloadUXP-6aa47456c3d5d1952212ff3e970f617e5f6f3617.tar
UXP-6aa47456c3d5d1952212ff3e970f617e5f6f3617.tar.gz
UXP-6aa47456c3d5d1952212ff3e970f617e5f6f3617.tar.lz
UXP-6aa47456c3d5d1952212ff3e970f617e5f6f3617.tar.xz
UXP-6aa47456c3d5d1952212ff3e970f617e5f6f3617.zip
Issue #12 Part 3: EditorEventListener should check if it's removed during a call of editor's method.
EditorEventListener doesn't check if mEditorBase is available even after it's removed from the editor. If it becomes nullptr, i.e., it's detached from editor, it shouldn't continue to handle event. This patch changes some methods' nsIDOM*Event argument to WidgetEvent since it's simpler.
Diffstat (limited to 'editor/libeditor/HTMLEditorEventListener.cpp')
-rw-r--r--editor/libeditor/HTMLEditorEventListener.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/editor/libeditor/HTMLEditorEventListener.cpp b/editor/libeditor/HTMLEditorEventListener.cpp
index c4d857908..a22188483 100644
--- a/editor/libeditor/HTMLEditorEventListener.cpp
+++ b/editor/libeditor/HTMLEditorEventListener.cpp
@@ -53,6 +53,12 @@ HTMLEditorEventListener::GetHTMLEditor()
nsresult
HTMLEditorEventListener::MouseUp(nsIDOMMouseEvent* aMouseEvent)
{
+ if (DetachedFromEditor()) {
+ return NS_OK;
+ }
+
+ // FYI: We need to notify HTML editor of mouseup even if it's consumed
+ // because HTML editor always needs to release grabbing resizer.
HTMLEditor* htmlEditor = GetHTMLEditor();
nsCOMPtr<nsIDOMEventTarget> target;
@@ -72,6 +78,10 @@ HTMLEditorEventListener::MouseUp(nsIDOMMouseEvent* aMouseEvent)
nsresult
HTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
{
+ if (NS_WARN_IF(!aMouseEvent) || DetachedFromEditor()) {
+ return NS_OK;
+ }
+
WidgetMouseEvent* mousedownEvent =
aMouseEvent->AsEvent()->WidgetEventPtr()->AsMouseEvent();
@@ -86,6 +96,9 @@ HTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
return EditorEventListener::MouseDown(aMouseEvent);
}
+ // XXX This method may change selection. So, we need to commit composition
+ // here, first.
+
// Detect only "context menu" click
// XXX This should be easier to do!
// But eDOMEvents_contextmenu and eContextMenu is not exposed in any event
@@ -179,6 +192,9 @@ HTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
} else {
htmlEditor->SelectElement(element);
}
+ if (DetachedFromEditor()) {
+ return NS_OK;
+ }
}
}
// HACK !!! Context click places the caret but the context menu consumes