Bug 686203 - nsHTMLEditorEventListener's MouseDown listener should disregard events outwith its editor. Also fixes bug 578771. r=ehsan a=blassey

This commit is contained in:
Graeme McCutcheon 2012-04-13 13:52:12 +01:00
parent 1bca0f5390
commit d7d8932ab4
4 changed files with 57 additions and 0 deletions

View File

@ -970,6 +970,7 @@ public:
friend class nsHTMLEditRules;
friend class nsTextEditRules;
friend class nsWSRunObject;
friend class nsHTMLEditorEventListener;
};
#endif //nsHTMLEditor_h__

View File

@ -141,6 +141,11 @@ nsHTMLEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
NS_ENSURE_TRUE(target, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
// Contenteditable should disregard mousedowns outwith it
if (element && !htmlEditor->IsNodeInActiveEditor(element)) {
return NS_OK;
}
if (isContextClick || (buttonNumber == 0 && clickCount == 2))
{
nsCOMPtr<nsISelection> selection;

View File

@ -92,6 +92,7 @@ _TEST_FILES = \
test_bug674861.html \
test_bug676401.html \
test_bug677752.html \
test_bug686203.html \
test_bug697842.html \
test_bug725069.html \
test_bug735059.html \

View File

@ -0,0 +1,50 @@
<!DOCTYPE HTML>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this file,
- You can obtain one at http://mozilla.org/MPL/2.0/. -->
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=686203
-->
<head>
<title>Test for Bug 686203</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=686203">Mozilla Bug 686203</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 686203 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var ce = document.getElementById("ce");
var input = document.getElementById("input");
ce.focus();
var eventDetails = { button : 2 };
synthesizeMouseAtCenter(input, eventDetails);
synthesizeKey("Z", {});
/* check values */
is(input.value, "Z", "input correctly focused after right-click");
is(ce.textContent, "abc", "contenteditable correctly blurred after right-click on input");
SimpleTest.finish();
});
</script>
</pre>
<input type="text" value="" id="input" />
<div id="ce" contenteditable="true">abc</div>
</body>
</html>