Issue #2721 - Simplify CheckHandleEventForAnchorsPreconditions.

The special case check is no longer necessary after our changes in this
issue and #2732 where <A> no longer applies as a link inside image maps.
This commit is contained in:
Moonchild 2025-06-10 02:23:53 +02:00 committed by roytam1
commit 3b1fe322f7

View file

@ -585,22 +585,10 @@ nsGenericHTMLElement::CheckHandleEventForAnchorsPreconditions(EventChainVisitor&
{
NS_PRECONDITION(nsCOMPtr<Link>(do_QueryObject(this)),
"should be called only when |this| implements |Link|");
if (!aVisitor.mPresContext) {
// When not in the composed document DOM, only <a> should navigate away per
// the exception in https://html.spec.whatwg.org/#cannot-navigate
// Thanks, Google, for another ugly one. :|
return IsInComposedDoc() || IsHTMLElement(nsGkAtoms::a);
}
//Need to check if we hit an imagemap area and if so see if we're handling
//the event on that map or on a link farther up the tree. If we're on a
//link farther up, do nothing.
nsCOMPtr<nsIContent> target = aVisitor.mPresContext->EventStateManager()->
GetEventTargetContent(aVisitor.mEvent);
return !target || !target->IsHTMLElement(nsGkAtoms::area) ||
IsHTMLElement(nsGkAtoms::area);
// When not in the composed document DOM, only <a> should navigate away per
// the exception in https://html.spec.whatwg.org/#cannot-navigate
// Thanks, Google, for another ugly one. :|
return IsInComposedDoc() || IsHTMLElement(nsGkAtoms::a);
}
nsresult