From cc106fa8847e48bc6ba60a4ea64f3b177b5fc854 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Thu, 1 Jun 2023 00:34:59 +0000 Subject: [PATCH] Bug 1833570 - Change popover invoker type from boolean to Element. r=emilio The invoker type is currently implemented as boolean as suggested at https://github.com/whatwg/html/issues/9168. This issue is now closed and has been fixed at https://github.com/whatwg/html/pull/9171. This patch is to be follow above discussions and implement popover invoker type as element. Differential Revision: https://phabricator.services.mozilla.com/D178287 UltraBlame original commit: 1e825b150a60ac26b0f652679eca1b223354fb64 --- dom/base/Document.cpp | 31 +++++++- dom/base/Element.cpp | 108 ++++++-------------------- dom/base/Element.h | 35 --------- dom/base/PopoverData.h | 122 ++++++++++++++++++++++-------- dom/html/nsGenericHTMLElement.cpp | 9 ++- 5 files changed, 148 insertions(+), 157 deletions(-) diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index e60c7f5d559fb..c8345d4802f0d 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -93952,11 +93952,34 @@ list ; } } -aPopover -. -SetHasPopoverInvoker +auto +* +data += +popoverHTMLEl +- +> +GetPopoverData ( -false +) +; +MOZ_ASSERT +( +data +" +Should +have +popover +data +" +) +; +data +- +> +SetInvoker +( +nullptr ) ; / diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index dda63493e989e..de5a6287658fb 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -28142,82 +28142,6 @@ bool Element : : -HasPopoverInvoker -( -) -const -{ -auto -* -popoverData -= -GetPopoverData -( -) -; -return -popoverData -& -& -popoverData -- -> -HasPopoverInvoker -( -) -; -} -void -Element -: -: -SetHasPopoverInvoker -( -bool -aHasInvoker -) -{ -if -( -aHasInvoker -) -{ -EnsurePopoverData -( -) -. -SetHasPopoverInvoker -( -true -) -; -} -else -if -( -auto -* -popoverData -= -GetPopoverData -( -) -) -{ -popoverData -- -> -SetHasPopoverInvoker -( -false -) -; -} -} -bool -Element -: -: IsAutoPopover ( ) @@ -28465,15 +28389,6 @@ GetFlattenedTreeParentElement ; / / -TODO -: -To -handle -the -button -invokers -/ -/ https : / @@ -28489,6 +28404,29 @@ html issues / 9160 +RefPtr +< +Element +> +invoker += +newPopover +- +> +GetPopoverData +( +) +- +> +GetInvoker +( +) +; +checkAncestor +( +invoker +) +; return topmostPopoverAncestor ; diff --git a/dom/base/Element.h b/dom/base/Element.h index 7e155f3748c7e..706f6595f1645 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -3123,41 +3123,6 @@ CreatePopoverData ) ; } -/ -/ -https -: -/ -/ -html -. -spec -. -whatwg -. -org -/ -multipage -/ -popover -. -html -# -popover -- -invoker -bool -HasPopoverInvoker -( -) -const -; -void -SetHasPopoverInvoker -( -bool -) -; bool IsAutoPopover ( diff --git a/dom/base/PopoverData.h b/dom/base/PopoverData.h index a9d93baf00139..dc97b0d3e524b 100644 --- a/dom/base/PopoverData.h +++ b/dom/base/PopoverData.h @@ -123,21 +123,21 @@ mozilla_dom_PopoverData_h # include " -nsStringFwd +Element . h " # include " -nsIRunnable +nsINode . h " # include " -nsThreadUtils +nsIRunnable . h " @@ -148,6 +148,20 @@ nsIWeakReferenceUtils . h " +# +include +" +nsStringFwd +. +h +" +# +include +" +nsThreadUtils +. +h +" namespace mozilla : @@ -386,26 +400,43 @@ mPreviouslyFocusedElement aPreviouslyFocusedElement ; } -bool -HasPopoverInvoker +RefPtr +< +Element +> +GetInvoker ( ) const { return -mHasPopoverInvoker +do_QueryReferent +( +mInvokerElement +) ; } void -SetHasPopoverInvoker +SetInvoker ( -bool -aHasPopoverInvoker +Element +* +aInvokerElement ) { -mHasPopoverInvoker +mInvokerElement = -aHasPopoverInvoker +do_GetWeakReference +( +static_cast +< +nsINode +* +> +( +aInvokerElement +) +) ; } PopoverToggleEventTask @@ -542,39 +573,68 @@ whatwg . org / -multipage -/ -popover -. -html # popover - invoker -also / / -see -https -: +Since +having +a +popover +invoker +only +makes +a +difference +if +the +invoker / / -github -. -com +is +in +the +document +( +in +another +open +popover +to +be +precise +) +we +can +make / -whatwg / -html +this +a +weak +reference +as +if +the +element +goes +away +it +' +s +necessarily +not / -issues / -9168 +connected +to +our +document . -bool -mHasPopoverInvoker -= -false +nsWeakPtr +mInvokerElement ; bool mIsHiding diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index c3129f4825179..ca1aa012b8bba 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -19129,9 +19129,14 @@ IsPopoverOpen target - > -SetHasPopoverInvoker +GetPopoverData ( -true +) +- +> +SetInvoker +( +this ) ; target