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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-07-09 16:17:56 +00:00
Родитель 23a7cb7a68
Коммит 16bfd6e375
1 изменённых файлов: 3 добавлений и 15 удалений

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

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