--- a/layout/xul/nsXULPopupManager.cpp
+++ b/layout/xul/nsXULPopupManager.cpp
@@ -766,17 +766,17 @@ nsXULPopupManager::ShowMenu(nsIContent *
new nsXULPopupShowingEvent(popupFrame->GetContent(),
parentIsContextMenu, aSelectFirstItem);
aMenu->OwnerDoc()->Dispatch("nsXULPopupShowingEvent",
TaskCategory::Other,
event.forget());
}
else {
nsCOMPtr<nsIContent> popupContent = popupFrame->GetContent();
- FirePopupShowingEvent(popupContent, parentIsContextMenu, aSelectFirstItem);
+ FirePopupShowingEvent(popupContent, parentIsContextMenu, aSelectFirstItem, nullptr);
}
}
void
nsXULPopupManager::ShowPopup(nsIContent* aPopup,
nsIContent* aAnchorContent,
const nsAString& aPosition,
int32_t aXPos, int32_t aYPos,
@@ -790,34 +790,34 @@ nsXULPopupManager::ShowPopup(nsIContent*
return;
nsCOMPtr<nsIContent> triggerContent;
InitTriggerEvent(aTriggerEvent, aPopup, getter_AddRefs(triggerContent));
popupFrame->InitializePopup(aAnchorContent, triggerContent, aPosition,
aXPos, aYPos, MenuPopupAnchorType_Node, aAttributesOverride);
- FirePopupShowingEvent(aPopup, aIsContextMenu, aSelectFirstItem);
+ FirePopupShowingEvent(aPopup, aIsContextMenu, aSelectFirstItem, aTriggerEvent);
}
void
nsXULPopupManager::ShowPopupAtScreen(nsIContent* aPopup,
int32_t aXPos, int32_t aYPos,
bool aIsContextMenu,
nsIDOMEvent* aTriggerEvent)
{
nsMenuPopupFrame* popupFrame = GetPopupFrameForContent(aPopup, true);
if (!popupFrame || !MayShowPopup(popupFrame))
return;
nsCOMPtr<nsIContent> triggerContent;
InitTriggerEvent(aTriggerEvent, aPopup, getter_AddRefs(triggerContent));
popupFrame->InitializePopupAtScreen(triggerContent, aXPos, aYPos, aIsContextMenu);
- FirePopupShowingEvent(aPopup, aIsContextMenu, false);
+ FirePopupShowingEvent(aPopup, aIsContextMenu, false, aTriggerEvent);
}
void
nsXULPopupManager::ShowPopupAtScreenRect(nsIContent* aPopup,
const nsAString& aPosition,
const nsIntRect& aRect,
bool aIsContextMenu,
bool aAttributesOverride,
@@ -828,17 +828,17 @@ nsXULPopupManager::ShowPopupAtScreenRect
return;
nsCOMPtr<nsIContent> triggerContent;
InitTriggerEvent(aTriggerEvent, aPopup, getter_AddRefs(triggerContent));
popupFrame->InitializePopupAtRect(triggerContent, aPosition,
aRect, aAttributesOverride);
- FirePopupShowingEvent(aPopup, aIsContextMenu, false);
+ FirePopupShowingEvent(aPopup, aIsContextMenu, false, aTriggerEvent);
}
void
nsXULPopupManager::ShowTooltipAtScreen(nsIContent* aPopup,
nsIContent* aTriggerContent,
int32_t aXPos, int32_t aYPos)
{
nsMenuPopupFrame* popupFrame = GetPopupFrameForContent(aPopup, true);
@@ -857,17 +857,17 @@ nsXULPopupManager::ShowTooltipAtScreen(n
nsIWidget *rootWidget = rootPresContext->GetRootWidget();
if (rootWidget) {
mCachedMousePoint -= rootWidget->WidgetToScreenOffset();
}
}
popupFrame->InitializePopupAtScreen(aTriggerContent, aXPos, aYPos, false);
- FirePopupShowingEvent(aPopup, false, false);
+ FirePopupShowingEvent(aPopup, false, false, nullptr);
}
void
nsXULPopupManager::ShowPopupWithAnchorAlign(nsIContent* aPopup,
nsIContent* aAnchorContent,
nsAString& aAnchor,
nsAString& aAlign,
int32_t aXPos, int32_t aYPos,
@@ -876,17 +876,17 @@ nsXULPopupManager::ShowPopupWithAnchorAl
nsMenuPopupFrame* popupFrame = GetPopupFrameForContent(aPopup, true);
if (!popupFrame || !MayShowPopup(popupFrame))
return;
InitTriggerEvent(nullptr, nullptr, nullptr);
popupFrame->InitializePopupWithAnchorAlign(aAnchorContent, aAnchor,
aAlign, aXPos, aYPos);
- FirePopupShowingEvent(aPopup, aIsContextMenu, false);
+ FirePopupShowingEvent(aPopup, aIsContextMenu, false, nullptr);
}
static void
CheckCaretDrawingState()
{
// There is 1 caret per document, we need to find the focused
// document and erase its caret.
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
@@ -1424,17 +1424,18 @@ nsXULPopupManager::ExecuteMenu(nsIConten
aMenu->OwnerDoc()->Dispatch("nsXULMenuCommandEvent",
TaskCategory::Other,
event.forget());
}
void
nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup,
bool aIsContextMenu,
- bool aSelectFirstItem)
+ bool aSelectFirstItem,
+ nsIDOMEvent* aTriggerEvent)
{
nsCOMPtr<nsIContent> popup = aPopup; // keep a strong reference to the popup
nsMenuPopupFrame* popupFrame = do_QueryFrame(aPopup->GetPrimaryFrame());
if (!popupFrame)
return;
nsPresContext *presContext = popupFrame->PresContext();
@@ -1470,16 +1471,24 @@ nsXULPopupManager::FirePopupShowingEvent
if (rootPresContext) {
rootPresContext->PresShell()->GetViewManager()->
GetRootWidget(getter_AddRefs(event.mWidget));
}
else {
event.mWidget = nullptr;
}
+ if (aTriggerEvent) {
+ WidgetMouseEventBase* mouseEvent =
+ aTriggerEvent->WidgetEventPtr()->AsMouseEventBase();
+ if (mouseEvent) {
+ event.inputSource = mouseEvent->inputSource;
+ }
+ }
+
event.mRefPoint = mCachedMousePoint;
event.mModifiers = mCachedModifiers;
EventDispatcher::Dispatch(popup, presContext, &event, nullptr, &status);
mCachedMousePoint = LayoutDeviceIntPoint(0, 0);
mOpeningPopup = nullptr;
mCachedModifiers = 0;
@@ -2735,17 +2744,17 @@ nsXULPopupManager::KeyPress(nsIDOMKeyEve
return NS_OK; // I am consuming event
}
NS_IMETHODIMP
nsXULPopupShowingEvent::Run()
{
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm) {
- pm->FirePopupShowingEvent(mPopup, mIsContextMenu, mSelectFirstItem);
+ pm->FirePopupShowingEvent(mPopup, mIsContextMenu, mSelectFirstItem, nullptr);
}
return NS_OK;
}
NS_IMETHODIMP
nsXULPopupHidingEvent::Run()
{