mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 552982, Part 4: change nsXULPopupManager::GetVisiblePopups to also return noautohide panels, r=mats
This commit is contained in:
parent
4a99c182d8
commit
8522fc0f13
@ -1074,6 +1074,18 @@ nsDOMWindowUtils::SendQueryContentEvent(PRUint32 aType,
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(mWindow, NS_ERROR_FAILURE);
|
||||
|
||||
nsIDocShell *docShell = mWindow->GetDocShell();
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
docShell->GetPresShell(getter_AddRefs(presShell));
|
||||
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
||||
|
||||
nsPresContext* presContext = presShell->GetPresContext();
|
||||
NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
|
||||
|
||||
// get the widget to send the event to
|
||||
nsCOMPtr<nsIWidget> widget = GetWidget();
|
||||
if (!widget) {
|
||||
@ -1097,7 +1109,7 @@ nsDOMWindowUtils::SendQueryContentEvent(PRUint32 aType,
|
||||
nsQueryContentEvent dummyEvent(PR_TRUE, NS_QUERY_CONTENT_STATE, widget);
|
||||
InitEvent(dummyEvent, &pt);
|
||||
nsIFrame* popupFrame =
|
||||
nsLayoutUtils::GetPopupFrameForEventCoordinates(&dummyEvent);
|
||||
nsLayoutUtils::GetPopupFrameForEventCoordinates(presContext->GetRootPresContext(), &dummyEvent);
|
||||
|
||||
nsIntRect widgetBounds;
|
||||
nsresult rv = widget->GetClientBounds(widgetBounds);
|
||||
|
@ -819,7 +819,8 @@ nsLayoutUtils::GetEventCoordinatesRelativeTo(const nsEvent* aEvent, nsIFrame* aF
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
nsLayoutUtils::GetPopupFrameForEventCoordinates(const nsEvent* aEvent)
|
||||
nsLayoutUtils::GetPopupFrameForEventCoordinates(nsPresContext* aPresContext,
|
||||
const nsEvent* aEvent)
|
||||
{
|
||||
#ifdef MOZ_XUL
|
||||
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
||||
@ -831,7 +832,8 @@ nsLayoutUtils::GetPopupFrameForEventCoordinates(const nsEvent* aEvent)
|
||||
// Search from top to bottom
|
||||
for (i = 0; i < popups.Length(); i++) {
|
||||
nsIFrame* popup = popups[i];
|
||||
if (popup->GetOverflowRect().Contains(
|
||||
if (popup->PresContext()->GetRootPresContext() == aPresContext &&
|
||||
popup->GetOverflowRect().Contains(
|
||||
GetEventCoordinatesRelativeTo(aEvent, popup))) {
|
||||
return popup;
|
||||
}
|
||||
|
@ -406,11 +406,13 @@ public:
|
||||
|
||||
/**
|
||||
* Get the popup frame of a given native mouse event.
|
||||
* @param aPresContext only check popups within aPresContext or a descendant
|
||||
* @param aEvent the event.
|
||||
* @return Null, if there is no popup frame at the point, otherwise,
|
||||
* returns top-most popup frame at the point.
|
||||
*/
|
||||
static nsIFrame* GetPopupFrameForEventCoordinates(const nsEvent* aEvent);
|
||||
static nsIFrame* GetPopupFrameForEventCoordinates(nsPresContext* aPresContext,
|
||||
const nsEvent* aEvent);
|
||||
|
||||
/**
|
||||
* Translate from widget coordinates to the view's coordinates
|
||||
|
@ -6284,7 +6284,7 @@ PresShell::HandleEvent(nsIView *aView,
|
||||
if (framePresContext == rootPresContext &&
|
||||
frame == FrameManager()->GetRootFrame()) {
|
||||
nsIFrame* popupFrame =
|
||||
nsLayoutUtils::GetPopupFrameForEventCoordinates(aEvent);
|
||||
nsLayoutUtils::GetPopupFrameForEventCoordinates(rootPresContext, aEvent);
|
||||
// If the popupFrame is an ancestor of the 'frame', the frame should
|
||||
// handle the event, otherwise, the popup should handle it.
|
||||
if (popupFrame &&
|
||||
|
@ -1272,6 +1272,13 @@ nsXULPopupManager::GetVisiblePopups()
|
||||
item = item->GetParent();
|
||||
}
|
||||
|
||||
item = mNoHidePanels;
|
||||
while (item) {
|
||||
if (item->Frame()->PopupState() == ePopupOpenAndVisible)
|
||||
popups.AppendElement(static_cast<nsIFrame*>(item->Frame()));
|
||||
item = item->GetParent();
|
||||
}
|
||||
|
||||
return popups;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user