Bug 1821732 - implement nearest invlusive target popover for invoker alg, r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D173539
This commit is contained in:
Alexander Surkov 2023-03-27 16:12:53 +00:00
Родитель 9105cd4fac
Коммит 430e56024c
3 изменённых файлов: 25 добавлений и 1 удалений

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

@ -3182,6 +3182,18 @@ Element* nsINode::GetNearestInclusiveOpenPopover() {
return nullptr;
}
Element* nsINode::GetNearestInclusiveTargetPopoverForInvoker() {
for (auto* el : InclusiveFlatTreeAncestorsOfType<
nsGenericHTMLFormControlElementWithState>()) {
if (auto* popover = el->GetPopoverTargetElement()) {
if (popover->IsAutoPopover() && popover->IsPopoverOpen()) {
return popover;
}
}
}
return nullptr;
}
void nsINode::AddAnimationObserver(nsIAnimationObserver* aAnimationObserver) {
AddMutationObserver(aAnimationObserver);
OwnerDoc()->SetMayHaveAnimationObservers();

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

@ -502,12 +502,17 @@ class nsINode : public mozilla::dom::EventTarget {
MOZ_CAN_RUN_SCRIPT mozilla::dom::Element* GetParentFlexElement();
/*
/**
* Returns the nearest inclusive open popover for a given node, see
* https://html.spec.whatwg.org/multipage/popover.html#nearest-inclusive-open-popover
*/
mozilla::dom::Element* GetNearestInclusiveOpenPopover();
/**
* https://html.spec.whatwg.org/multipage/popover.html#nearest-inclusive-target-popover-for-invoker
*/
mozilla::dom::Element* GetNearestInclusiveTargetPopoverForInvoker();
bool IsNode() const final { return true; }
NS_IMPL_FROMEVENTTARGET_HELPER(nsINode, IsNode())
@ -518,6 +523,9 @@ class nsINode : public mozilla::dom::EventTarget {
bool IsElement() const { return GetBoolFlag(NodeIsElement); }
virtual bool IsTextControlElement() const { return false; }
virtual bool IsGenericHTMLFormControlElementWithState() const {
return false;
}
// Returns non-null if this element subclasses `LinkStyle`.
virtual const mozilla::dom::LinkStyle* AsLinkStyle() const { return nullptr; }

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

@ -1224,6 +1224,10 @@ class nsGenericHTMLFormControlElementWithState
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
mozilla::dom::FromParser aFromParser, FormControlType);
bool IsGenericHTMLFormControlElementWithState() const final { return true; }
NS_IMPL_FROMNODE_HELPER(nsGenericHTMLFormControlElementWithState,
IsGenericHTMLFormControlElementWithState())
// nsIContent
bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,