Bug 877669 - nsXULPopupListener shouldn't prevent default if there are no attributes, r=neil

This commit is contained in:
Gijs Kruitbosch 2013-05-31 11:49:26 +02:00
parent f3e50a82b2
commit 6d9aab9154

View File

@ -201,10 +201,9 @@ nsXULPopupListener::HandleEvent(nsIDOMEvent* aEvent)
return NS_OK;
}
// Open the popup and cancel the default handling of the event.
// Open the popup. LaunchPopup will call StopPropagation and PreventDefault
// in the right situations.
LaunchPopup(aEvent, targetContent);
aEvent->StopPropagation();
aEvent->PreventDefault();
return NS_OK;
}
@ -328,21 +327,24 @@ nsXULPopupListener::LaunchPopup(nsIDOMEvent* aEvent, nsIContent* aTargetContent)
{
nsresult rv = NS_OK;
nsIAtom* type = mIsContext ? nsGkAtoms::context : nsGkAtoms::popup;
nsAutoString identifier;
mElement->GetAttr(kNameSpaceID_None, type, identifier);
nsIAtom* type = mIsContext ? nsGkAtoms::context : nsGkAtoms::popup;
bool hasPopupAttr = mElement->GetAttr(kNameSpaceID_None, type, identifier);
if (identifier.IsEmpty()) {
if (type == nsGkAtoms::popup) {
mElement->GetAttr(kNameSpaceID_None, nsGkAtoms::menu, identifier);
} else {
mElement->GetAttr(kNameSpaceID_None, nsGkAtoms::contextmenu, identifier);
}
if (identifier.IsEmpty())
return rv;
hasPopupAttr = mElement->GetAttr(kNameSpaceID_None,
mIsContext ? nsGkAtoms::contextmenu : nsGkAtoms::menu,
identifier) || hasPopupAttr;
}
if (hasPopupAttr) {
aEvent->StopPropagation();
aEvent->PreventDefault();
}
if (identifier.IsEmpty())
return rv;
// Try to find the popup content and the document.
nsCOMPtr<nsIDocument> document = mElement->GetDocument();
if (!document) {