Bug 1400618 part 3 - Don't let <area>s mess up the frame's IsPrimaryFrame bit, since the frame is actually owned by the <img>. r=bz
authorMats Palmgren <mats@mozilla.com>
Tue, 07 Nov 2017 01:20:34 +0100
changeset 434935 50c2aba68909c45c8136fd5ba20865e9c0309b87
parent 434934 9a72b179c10dc970bd708ebfa551c8010e26d921
child 434936 82659642e0583a8e493bea4f0a7bfb75dc48accd
push id117
push userfmarier@mozilla.com
push dateTue, 28 Nov 2017 20:17:16 +0000
reviewersbz
bugs1400618
milestone58.0a1
Bug 1400618 part 3 - Don't let <area>s mess up the frame's IsPrimaryFrame bit, since the frame is actually owned by the <img>. r=bz MozReview-Commit-ID: 7afxM9sWmiA
dom/base/nsIContentInlines.h
--- a/dom/base/nsIContentInlines.h
+++ b/dom/base/nsIContentInlines.h
@@ -29,19 +29,25 @@ nsIContent::IsInChromeDocument() const
 inline void
 nsIContent::SetPrimaryFrame(nsIFrame* aFrame)
 {
   MOZ_ASSERT(IsInUncomposedDoc() || IsInShadowTree(), "This will end badly!");
   NS_PRECONDITION(!aFrame || !mPrimaryFrame || aFrame == mPrimaryFrame,
                   "Losing track of existing primary frame");
 
   if (aFrame) {
-    aFrame->SetIsPrimaryFrame(true);
+    if (MOZ_LIKELY(!IsHTMLElement(nsGkAtoms::area)) ||
+        aFrame->GetContent() == this) {
+      aFrame->SetIsPrimaryFrame(true);
+    }
   } else if (nsIFrame* currentPrimaryFrame = GetPrimaryFrame()) {
-    currentPrimaryFrame->SetIsPrimaryFrame(false);
+    if (MOZ_LIKELY(!IsHTMLElement(nsGkAtoms::area)) ||
+        currentPrimaryFrame->GetContent() == this) {
+      currentPrimaryFrame->SetIsPrimaryFrame(false);
+    }
   }
 
   mPrimaryFrame = aFrame;
 }
 
 inline mozilla::dom::ShadowRoot* nsIContent::GetShadowRoot() const
 {
   if (!IsElement()) {