Bug 516880, use the right presshell when getting frames during mouse capture, r=roc

This commit is contained in:
Neil Deakin 2009-09-17 12:59:42 -04:00
parent 83ddb4fd22
commit ec320a0efd
2 changed files with 27 additions and 5 deletions

View File

@ -4412,9 +4412,18 @@ PresShell::ClearMouseCapture(nsIView* aView)
{
if (gCaptureInfo.mContent) {
if (aView) {
// if a view was specified, ensure that the captured content
// is within this view
nsIFrame* frame = GetPrimaryFrameFor(gCaptureInfo.mContent);
// if a view was specified, ensure that the captured content is within
// this view. Get the frame for the captured content from the right
// presshell first.
nsIFrame* frame = nsnull;
nsIDocument* doc = gCaptureInfo.mContent->GetCurrentDoc();
if (doc) {
nsIPresShell *shell = doc->GetPrimaryShell();
if (shell) {
frame = shell->GetPrimaryFrameFor(gCaptureInfo.mContent);
}
}
if (frame) {
nsIView* view = frame->GetClosestView();
while (view) {
@ -6038,7 +6047,9 @@ PresShell::HandleEvent(nsIView *aView,
// if a node is capturing the mouse, get the frame for the capturing
// content and use that instead. However, if the content has no parent,
// such as the root frame, get the parent canvas frame instead. This
// ensures that positioned frames are included when hit-testing.
// ensures that positioned frames are included when hit-testing. Note
// that a check was already done above to ensure that capturingContent
// is in this presshell.
nsIContent* capturingContent = gCaptureInfo.mContent;
frame = GetPrimaryFrameFor(capturingContent);
if (frame) {

View File

@ -3,7 +3,6 @@
<?xml-stylesheet href="/tests/SimpleTest/test.css" type="text/css"?>
<window title="Mouse Capture Tests" align="start"
onload="setTimeout(runTests, 0);"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="/MochiKit/packed.js"></script>
@ -135,6 +134,12 @@ function runCaptureTest(element, callback)
if (expectedTarget == $("custom5spacer") && !captureRetargetMode)
expectedTarget = $("custom5inner");
if (element.id == "b") {
var tooltip = document.getElementById("tooltip");
tooltip.openPopup();
tooltip.hidePopup();
}
synthesizeMouse(element, basepoint + 25, basepoint + 25, { type: "mousemove" }, win);
if (callback)
callback(25);
@ -156,9 +161,15 @@ function runCaptureTest(element, callback)
win.removeEventListener("mousemove", mouseMoved, false);
}
SimpleTest.waitForFocus(runTests);
]]>
</script>
<tooltip id="tooltip">
<label value="Test"/>
</tooltip>
<hbox id="splitterbox" style="margin-top: 5px;" onmousedown="this.setCapture()">
<hbox id="leftbox" width="100" flex="1"/>
<splitter id="splitter" height="5"/>