Loading dom/base/Element.cpp +39 −0 Original line number Diff line number Diff line Loading @@ -4286,6 +4286,45 @@ bool Element::IsPopoverOpen() const { return htmlElement && htmlElement->PopoverOpen(); } Element* Element::GetTopmostPopoverAncestor() const { const Element* newPopover = this; nsTHashMap<nsPtrHashKey<const Element>, size_t> popoverPositions; size_t index = 0; for (Element* popover : OwnerDoc()->AutoPopoverList()) { popoverPositions.LookupOrInsert(popover, index++); } popoverPositions.LookupOrInsert(newPopover, index); Element* topmostPopoverAncestor = nullptr; auto checkAncestor = [&](const Element* candidate) { if (!candidate) { return; } Element* candidateAncestor = candidate->GetNearestInclusiveOpenPopover(); if (!candidateAncestor) { return; } size_t candidatePosition; if (popoverPositions.Get(candidateAncestor, &candidatePosition)) { size_t topmostPosition; if (!topmostPopoverAncestor || (popoverPositions.Get(topmostPopoverAncestor, &topmostPosition) && topmostPosition < candidatePosition)) { topmostPopoverAncestor = candidateAncestor; } } }; checkAncestor(newPopover->GetFlattenedTreeParentElement()); // TODO: To handle the button invokers // https://github.com/whatwg/html/issues/9160 return topmostPopoverAncestor; } ElementAnimationData& Element::CreateAnimationData() { MOZ_ASSERT(!GetAnimationData()); SetMayHaveAnimations(); Loading dom/base/Element.h +5 −0 Original line number Diff line number Diff line Loading @@ -588,6 +588,11 @@ class Element : public FragmentOrElement { bool IsAutoPopover() const; bool IsPopoverOpen() const; /** * https://html.spec.whatwg.org/multipage/popover.html#topmost-popover-ancestor */ mozilla::dom::Element* GetTopmostPopoverAncestor() const; ElementAnimationData* GetAnimationData() const { if (!MayHaveAnimations()) { return nullptr; Loading Loading
dom/base/Element.cpp +39 −0 Original line number Diff line number Diff line Loading @@ -4286,6 +4286,45 @@ bool Element::IsPopoverOpen() const { return htmlElement && htmlElement->PopoverOpen(); } Element* Element::GetTopmostPopoverAncestor() const { const Element* newPopover = this; nsTHashMap<nsPtrHashKey<const Element>, size_t> popoverPositions; size_t index = 0; for (Element* popover : OwnerDoc()->AutoPopoverList()) { popoverPositions.LookupOrInsert(popover, index++); } popoverPositions.LookupOrInsert(newPopover, index); Element* topmostPopoverAncestor = nullptr; auto checkAncestor = [&](const Element* candidate) { if (!candidate) { return; } Element* candidateAncestor = candidate->GetNearestInclusiveOpenPopover(); if (!candidateAncestor) { return; } size_t candidatePosition; if (popoverPositions.Get(candidateAncestor, &candidatePosition)) { size_t topmostPosition; if (!topmostPopoverAncestor || (popoverPositions.Get(topmostPopoverAncestor, &topmostPosition) && topmostPosition < candidatePosition)) { topmostPopoverAncestor = candidateAncestor; } } }; checkAncestor(newPopover->GetFlattenedTreeParentElement()); // TODO: To handle the button invokers // https://github.com/whatwg/html/issues/9160 return topmostPopoverAncestor; } ElementAnimationData& Element::CreateAnimationData() { MOZ_ASSERT(!GetAnimationData()); SetMayHaveAnimations(); Loading
dom/base/Element.h +5 −0 Original line number Diff line number Diff line Loading @@ -588,6 +588,11 @@ class Element : public FragmentOrElement { bool IsAutoPopover() const; bool IsPopoverOpen() const; /** * https://html.spec.whatwg.org/multipage/popover.html#topmost-popover-ancestor */ mozilla::dom::Element* GetTopmostPopoverAncestor() const; ElementAnimationData* GetAnimationData() const { if (!MayHaveAnimations()) { return nullptr; Loading