From 9c7c34b3eeb4e9a6f5fe97e49be31f5f578ebd4e Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Thu, 29 Sep 2011 15:24:13 -0400 Subject: [PATCH] Bug 674770 - contenteditable breaks middle-click to open links when middlemouse.paste=true; r=roc --- .../libeditor/base/nsEditorEventListener.cpp | 10 +++ editor/libeditor/html/tests/Makefile.in | 2 + .../libeditor/html/tests/file_bug674770.html | 5 ++ .../libeditor/html/tests/test_bug674770.html | 69 +++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 editor/libeditor/html/tests/file_bug674770.html create mode 100644 editor/libeditor/html/tests/test_bug674770.html diff --git a/editor/libeditor/base/nsEditorEventListener.cpp b/editor/libeditor/base/nsEditorEventListener.cpp index 9a78a1a76d0..ae39e31781c 100644 --- a/editor/libeditor/base/nsEditorEventListener.cpp +++ b/editor/libeditor/base/nsEditorEventListener.cpp @@ -522,6 +522,16 @@ nsEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent) return NS_OK; } + nsCOMPtr target; + aMouseEvent->GetTarget(getter_AddRefs(target)); + nsCOMPtr node = do_QueryInterface(target); + NS_ENSURE_TRUE(node, NS_ERROR_FAILURE); + + if (!mEditor->IsModifiableNode(node)) { + // We shouldn't handle the event for non-editable content. + return NS_OK; + } + bool preventDefault; nsresult rv = nsevent->GetPreventDefault(&preventDefault); if (NS_FAILED(rv) || preventDefault) { diff --git a/editor/libeditor/html/tests/Makefile.in b/editor/libeditor/html/tests/Makefile.in index c702714eafd..f68691ae01d 100644 --- a/editor/libeditor/html/tests/Makefile.in +++ b/editor/libeditor/html/tests/Makefile.in @@ -85,6 +85,8 @@ _TEST_FILES = \ test_bug629845.html \ test_bug640321.html \ test_bug668599.html \ + test_bug674770.html \ + file_bug674770.html \ test_bug674861.html \ test_bug676401.html \ test_bug677752.html \ diff --git a/editor/libeditor/html/tests/file_bug674770.html b/editor/libeditor/html/tests/file_bug674770.html new file mode 100644 index 00000000000..6750bb87894 --- /dev/null +++ b/editor/libeditor/html/tests/file_bug674770.html @@ -0,0 +1,5 @@ + + diff --git a/editor/libeditor/html/tests/test_bug674770.html b/editor/libeditor/html/tests/test_bug674770.html new file mode 100644 index 00000000000..911d7861d27 --- /dev/null +++ b/editor/libeditor/html/tests/test_bug674770.html @@ -0,0 +1,69 @@ + + + + + Test for Bug 674770 + + + + + + +Mozilla Bug 674770 +

+
+test +
+test +
+
+
+
+
+ +