Bug 1218456 - Simplify CheckHandleEventForAnchorsPreconditions. r=smaug a=pascalc
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 09 Jul 2019 16:17:56 +0000
changeset 523942 160054b48c93cf170ee5d55039b60a367a086a08
parent 523941 a7b2ca3b03c30520de5e0929fc551d22d1b48c60
child 523943 cf06c61df5b3da0957cb1fc80c91115867edb94d
push id533
push userarchaeopteryx@coole-files.de
push dateMon, 04 Nov 2019 10:45:14 +0000
treeherdermozilla-esr68@2bc9b2075e5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, pascalc
bugs1218456, 30178
milestone68.3.0
Bug 1218456 - Simplify CheckHandleEventForAnchorsPreconditions. r=smaug a=pascalc 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
dom/html/nsGenericHTMLElement.cpp
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -524,31 +524,19 @@ HTMLFormElement* nsGenericHTMLElement::F
 
   return nullptr;
 }
 
 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(
     EventChainPreVisitor& aVisitor) {
   nsGenericHTMLElementBase::GetEventTargetParent(aVisitor);
 
   if (!CheckHandleEventForAnchorsPreconditions(aVisitor)) {
     return;