From ec0c0236459aa4b8062ae1ced821a82bd8dc59b2 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Tue, 2 Sep 2003 15:21:13 +0000 Subject: [PATCH] Bug 212753. Make sure mouse capture is released when combobox popup is hidden. r+sr=bryner,a=mkaply --- layout/forms/nsComboboxControlFrame.cpp | 2 +- layout/forms/nsListControlFrame.cpp | 15 ++++++++++----- layout/forms/nsListControlFrame.h | 1 - layout/html/forms/src/nsComboboxControlFrame.cpp | 2 +- layout/html/forms/src/nsListControlFrame.cpp | 15 ++++++++++----- layout/html/forms/src/nsListControlFrame.h | 1 - layout/xul/base/src/nsMenuPopupFrame.h | 1 - 7 files changed, 22 insertions(+), 15 deletions(-) diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 8d5994de43c4..89ebf8791d59 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -629,7 +629,7 @@ nsComboboxControlFrame::ShowList(nsIPresContext* aPresContext, PRBool aShowList) presShell->FlushPendingNotifications(PR_FALSE); if (widget) - widget->CaptureRollupEvents((nsIRollupListener *)this, mDroppedDown, PR_TRUE); + widget->CaptureRollupEvents((nsIRollupListener *)this, mDroppedDown, aShowList); } diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 0930c78f138c..cc7f76b55d19 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -398,7 +398,6 @@ nsListControlFrame::nsListControlFrame(nsIPresShell* aShell, mMaxWidth = 0; mMaxHeight = 0; mPresContext = nsnull; - mIsCapturingMouseEvents = PR_FALSE; mIsAllContentHere = PR_FALSE; mIsAllFramesHere = PR_FALSE; @@ -1659,18 +1658,24 @@ nsListControlFrame::CaptureMouseEvents(nsIPresContext* aPresContext, PRBool aGra // It's not clear why we don't have the widget capture mouse events here. if (aGrabMouseEvents) { viewMan->GrabMouseEvents(view, result); - mIsCapturingMouseEvents = PR_TRUE; } else { nsIView* curGrabber; viewMan->GetMouseEventGrabber(curGrabber); - if (curGrabber == view) { + PRBool dropDownIsHidden = PR_FALSE; + if (IsInDropDownMode()) { + PRBool isDroppedDown; + mComboboxFrame->IsDroppedDown(&isDroppedDown); + dropDownIsHidden = !isDroppedDown; + } + if (curGrabber == view || dropDownIsHidden) { // only unset the grabber if *we* are the ones doing the grabbing + // (or if the dropdown is hidden, in which case NO-ONE should be + // grabbing anything // it could be a scrollbar inside this listbox which is actually grabbing // This shouldn't be necessary. We should simply ensure that events targeting // scrollbars are never visible to DOM consumers. - viewMan->GrabMouseEvents(nsnull,result); + viewMan->GrabMouseEvents(nsnull, result); } - mIsCapturingMouseEvents = PR_FALSE; } } diff --git a/layout/forms/nsListControlFrame.h b/layout/forms/nsListControlFrame.h index 87392b208991..9f15d1d2fbdf 100644 --- a/layout/forms/nsListControlFrame.h +++ b/layout/forms/nsListControlFrame.h @@ -394,7 +394,6 @@ protected: PRPackedBool mButtonDown; nscoord mMaxWidth; nscoord mMaxHeight; - PRPackedBool mIsCapturingMouseEvents; PRInt32 mNumDisplayRows; PRBool mIsAllContentHere; diff --git a/layout/html/forms/src/nsComboboxControlFrame.cpp b/layout/html/forms/src/nsComboboxControlFrame.cpp index 8d5994de43c4..89ebf8791d59 100644 --- a/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -629,7 +629,7 @@ nsComboboxControlFrame::ShowList(nsIPresContext* aPresContext, PRBool aShowList) presShell->FlushPendingNotifications(PR_FALSE); if (widget) - widget->CaptureRollupEvents((nsIRollupListener *)this, mDroppedDown, PR_TRUE); + widget->CaptureRollupEvents((nsIRollupListener *)this, mDroppedDown, aShowList); } diff --git a/layout/html/forms/src/nsListControlFrame.cpp b/layout/html/forms/src/nsListControlFrame.cpp index 0930c78f138c..cc7f76b55d19 100644 --- a/layout/html/forms/src/nsListControlFrame.cpp +++ b/layout/html/forms/src/nsListControlFrame.cpp @@ -398,7 +398,6 @@ nsListControlFrame::nsListControlFrame(nsIPresShell* aShell, mMaxWidth = 0; mMaxHeight = 0; mPresContext = nsnull; - mIsCapturingMouseEvents = PR_FALSE; mIsAllContentHere = PR_FALSE; mIsAllFramesHere = PR_FALSE; @@ -1659,18 +1658,24 @@ nsListControlFrame::CaptureMouseEvents(nsIPresContext* aPresContext, PRBool aGra // It's not clear why we don't have the widget capture mouse events here. if (aGrabMouseEvents) { viewMan->GrabMouseEvents(view, result); - mIsCapturingMouseEvents = PR_TRUE; } else { nsIView* curGrabber; viewMan->GetMouseEventGrabber(curGrabber); - if (curGrabber == view) { + PRBool dropDownIsHidden = PR_FALSE; + if (IsInDropDownMode()) { + PRBool isDroppedDown; + mComboboxFrame->IsDroppedDown(&isDroppedDown); + dropDownIsHidden = !isDroppedDown; + } + if (curGrabber == view || dropDownIsHidden) { // only unset the grabber if *we* are the ones doing the grabbing + // (or if the dropdown is hidden, in which case NO-ONE should be + // grabbing anything // it could be a scrollbar inside this listbox which is actually grabbing // This shouldn't be necessary. We should simply ensure that events targeting // scrollbars are never visible to DOM consumers. - viewMan->GrabMouseEvents(nsnull,result); + viewMan->GrabMouseEvents(nsnull, result); } - mIsCapturingMouseEvents = PR_FALSE; } } diff --git a/layout/html/forms/src/nsListControlFrame.h b/layout/html/forms/src/nsListControlFrame.h index 87392b208991..9f15d1d2fbdf 100644 --- a/layout/html/forms/src/nsListControlFrame.h +++ b/layout/html/forms/src/nsListControlFrame.h @@ -394,7 +394,6 @@ protected: PRPackedBool mButtonDown; nscoord mMaxWidth; nscoord mMaxHeight; - PRPackedBool mIsCapturingMouseEvents; PRInt32 mNumDisplayRows; PRBool mIsAllContentHere; diff --git a/layout/xul/base/src/nsMenuPopupFrame.h b/layout/xul/base/src/nsMenuPopupFrame.h index 29d4a2fabcf5..4741b8180082 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.h +++ b/layout/xul/base/src/nsMenuPopupFrame.h @@ -214,7 +214,6 @@ protected: nsIMenuFrame* mCurrentMenu; // The current menu that is active. - PRBool mIsCapturingMouseEvents; // Whether or not we're grabbing the mouse events. // XXX Hack nsIPresContext* mPresContext; // weak reference