Bug 671319 Should abort drag for selection at resetting capture r=smaug

This commit is contained in:
Masayuki Nakano 2011-07-21 09:29:32 +09:00
parent a7982d5d95
commit 7d481573dc
4 changed files with 74 additions and 2 deletions

View File

@ -6179,6 +6179,14 @@ PresShell::Paint(nsIView* aViewToPaint,
void
nsIPresShell::SetCapturingContent(nsIContent* aContent, PRUint8 aFlags)
{
// If SetCapturingContent() is called during dragging mouse for selection,
// we should abort current transaction.
nsRefPtr<nsFrameSelection> fs =
nsFrameSelection::GetMouseDownFrameSelection();
if (fs) {
fs->AbortDragForSelection();
}
NS_IF_RELEASE(gCaptureInfo.mContent);
// only set capturing content if allowed or the CAPTURE_IGNOREALLOWED flag

View File

@ -2186,6 +2186,8 @@ nsFrame::HandlePress(nsPresContext* aPresContext,
nsEventStatus* aEventStatus)
{
NS_ENSURE_ARG_POINTER(aEventStatus);
NS_ASSERTION(aPresContext == PresContext(),
"HandlePress called with different presContext");
if (nsEventStatus_eConsumeNoDefault == *aEventStatus) {
return NS_OK;
}
@ -2563,6 +2565,9 @@ nsFrame::HandleDrag(nsPresContext* aPresContext,
return NS_OK; // not selecting now
}
NS_ASSERTION(target->PresContext()->PresShell() == fs->GetShell(),
"A different presShell received mouse move event during drag");
// Stop auto scrolling, first.
fs->StopAutoScrollTimer();
@ -2585,8 +2590,11 @@ nsFrame::ExpandSelectionByMouseMove(nsFrameSelection* aFrameSelection,
#ifdef DEBUG
nsFrameSelection* draggingFrameSelection =
nsFrameSelection::GetMouseDownFrameSelection();
NS_ASSERTION(draggingFrameSelection &&
draggingFrameSelection == GetConstFrameSelection(),
nsFrameSelection* selectionFrameForSelectingByMouse =
GetFrameSelectionForSelectingByMouse();
NS_ASSERTION(draggingFrameSelection,
"dragging FrameSelection must not be NULL");
NS_ASSERTION(draggingFrameSelection == selectionFrameForSelectingByMouse,
"aFrameSelection must be handling current drag for selection");
#endif

View File

@ -139,6 +139,7 @@ _CHROME_FILES = \
window_selection_scrolling.html \
test_bug670058.html \
test_bug670508.html \
test_bug671319.html \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -0,0 +1,55 @@
<!DOCTYPE>
<html>
<head>
<title>test for bug 671319</title>
<script type="text/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="text/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
</head>
<body>
<iframe id="iframe1"
src="data:text/html,&lt;input id='childInput' style='width: 100px; height: 20px;'&gt;"
style="margin: 10px; width: 150px; height: 40px;"></iframe><br>
<iframe id="iframe2"
src="data:text/html,&lt;input id='childInput' style='width: 100px; height: 20px;'&gt;"
style="margin: 10px; width: 150px; height: 40px;"></iframe>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
function doTest() {
var iframe1 = document.getElementById("iframe1");
var childInput1 = iframe1.contentDocument.getElementById("childInput");
var childWindow1 = iframe1.contentWindow;
var iframe2 = document.getElementById("iframe2");
var childInput2 = iframe2.contentDocument.getElementById("childInput");
childInput2.onmousedown = function (aEvent) {
aEvent.preventDefault();
};
childInput2.onmousemove = function (aEvent) {
childInput2.setCapture();
};
var childWindow2 = iframe2.contentWindow;
synthesizeMouse(childInput1, 10, 10, { type: "mousedown", button: 0 }, childWindow1);
iframe1.contentDocument.releaseCapture();
synthesizeMouse(childInput2, 10, 10, { type: "mousedown", button: 0 }, childWindow2);
synthesizeMouse(childInput2, 20, 10, { type: "mousemove" }, childWindow2);
ok(true, "not crashed");
SimpleTest.finish();
}
SimpleTest.waitForFocus(doTest, window);
</script>
</pre>
</body>
</html>