Bug 1218456 - Simplify CheckHandleEventForAnchorsPreconditions. r=smaug

I've checked that this doesn't change behavior in the test-case for bug 30178,
which is just an imagemap inside a link.

Overall it'd be weird if we needed this for area-inside-a but not for stuff like
nested links.

Differential Revision: https://phabricator.services.mozilla.com/D37407
This commit is contained in:
Emilio Cobos Álvarez 2019-07-09 16:17:56 +00:00
Родитель c17be889ab
Коммит 84da35f59c
1 изменённых файлов: 3 добавлений и 15 удалений

Просмотреть файл

@ -523,21 +523,9 @@ bool nsGenericHTMLElement::CheckHandleEventForAnchorsPreconditions(
EventChainVisitor& aVisitor) { EventChainVisitor& aVisitor) {
MOZ_ASSERT(nsCOMPtr<Link>(do_QueryObject(this)), MOZ_ASSERT(nsCOMPtr<Link>(do_QueryObject(this)),
"should be called only when |this| implements |Link|"); "should be called only when |this| implements |Link|");
if (!aVisitor.mPresContext) { // When disconnected, only <a> should navigate away per
// When disconnected, only <a> should navigate away per // https://html.spec.whatwg.org/#cannot-navigate
// https://html.spec.whatwg.org/#cannot-navigate return IsInComposedDoc() || IsHTMLElement(nsGkAtoms::a);
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);
} }
void nsGenericHTMLElement::GetEventTargetParentForAnchors( void nsGenericHTMLElement::GetEventTargetParentForAnchors(