Bug 460532 - Firefox leaks SelectionDetails when clicking a point included in multiple selection ranges. r+sr=roc.

HGe changed layut/genericks SelectionDetails/test/Makefile.in
This commit is contained in:
Uri Bernstein 2008-10-20 22:53:40 +02:00
parent c1978008f5
commit 9418630bcb
3 changed files with 86 additions and 23 deletions

View File

@ -2000,6 +2000,7 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
if (isSelected)
{
PRBool inSelection = PR_FALSE;
details = frameselection->LookUpSelection(offsets.content, 0,
offsets.EndOffset(), PR_FALSE);
@ -2008,33 +2009,33 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
// within any selected region of the frame.
//
if (details)
SelectionDetails *curDetail = details;
while (curDetail)
{
SelectionDetails *curDetail = details;
while (curDetail)
//
// If the user clicked inside a selection, then just
// return without doing anything. We will handle placing
// the caret later on when the mouse is released. We ignore
// the spellcheck and find selections.
//
if (curDetail->mType != nsISelectionController::SELECTION_SPELLCHECK &&
curDetail->mType != nsISelectionController::SELECTION_FIND &&
curDetail->mStart <= offsets.StartOffset() &&
offsets.EndOffset() <= curDetail->mEnd)
{
//
// If the user clicked inside a selection, then just
// return without doing anything. We will handle placing
// the caret later on when the mouse is released. We ignore
// the spellcheck and find selections.
//
if (curDetail->mType != nsISelectionController::SELECTION_SPELLCHECK &&
curDetail->mType != nsISelectionController::SELECTION_FIND &&
curDetail->mStart <= offsets.StartOffset() &&
offsets.EndOffset() <= curDetail->mEnd)
{
delete details;
fc->SetMouseDownState(PR_FALSE);
fc->SetDelayedCaretData(me);
return NS_OK;
}
curDetail = curDetail->mNext;
inSelection = PR_TRUE;
}
delete details;
SelectionDetails *nextDetail = curDetail->mNext;
delete curDetail;
curDetail = nextDetail;
}
if (inSelection) {
fc->SetMouseDownState(PR_FALSE);
fc->SetDelayedCaretData(me);
return NS_OK;
}
}

View File

@ -63,6 +63,7 @@ _TEST_FILES = test_bug288789.html \
test_bug416168.html \
test_bug421436.html \
test_bug448860.html \
test_bug460532.html \
test_character_movement.html \
test_word_movement.html \
test_backspace_delete.html \

View File

@ -0,0 +1,61 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=460532
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test for bug 460532</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=460532">Mozilla Bug 460532</a>
<p id="display"></p>
<div id="content" style="display: block">
lorem ipsum.
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
function select_460532(){
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var content = document.getElementById('content');
var node = content.firstChild;
var range = document.createRange();
range.setStart(node, 0);
range.setEnd(node, 5);
window.getSelection().addRange(range);
range = document.createRange();
range.setStart(node, 0);
range.setEnd(node, 6);
window.getSelection().addRange(range);
}
function click_460532(){
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var wu = document.defaultView.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils);
var content = document.getElementById('content');
var rect = content.getBoundingClientRect();
wu.sendMouseEvent('mousedown', rect.left+5, rect.top+5, 0, 1, 0);
ok(true, "pass");
SimpleTest.finish();
}
function boom_460532() {
select_460532();
setTimeout(click_460532, 100);
}
addLoadEvent(boom_460532);
SimpleTest.waitForExplicitFinish()
</script>
</pre>
</body>
</html>