LibWeb/HTML: Rename popover "invoker"

Lots of renames, no behaviour differences. (Apart from the rename of the
IDL type, which does of course affect JS.)

Corresponds to:
16cb7808da
This commit is contained in:
Sam Atkins 2025-11-27 13:52:14 +00:00
parent 82dfa69e4e
commit 85478c9215
Notes: github-actions[bot] 2025-11-27 16:45:55 +00:00
16 changed files with 107 additions and 103 deletions

View file

@ -604,7 +604,7 @@ set(SOURCES
HTML/Plugin.cpp
HTML/PluginArray.cpp
HTML/PolicyContainers.cpp
HTML/PopoverInvokerElement.cpp
HTML/PopoverTargetAttributes.cpp
HTML/PopStateEvent.cpp
HTML/PotentialCORSRequest.cpp
HTML/PromiseRejectionEvent.cpp

View file

@ -735,7 +735,7 @@ class PageTransitionEvent;
class Path2D;
class Plugin;
class PluginArray;
class PopoverInvokerElement;
class PopoverTargetAttributes;
class PromiseRejectionEvent;
class RadioNodeList;
class SelectedFile;

View file

@ -101,13 +101,13 @@ void HTMLButtonElement::set_type_for_bindings(String const& type)
void HTMLButtonElement::form_associated_element_attribute_changed(FlyString const& name, Optional<String> const&, Optional<String> const& value, Optional<FlyString> const& namespace_)
{
PopoverInvokerElement::associated_attribute_changed(name, value, namespace_);
PopoverTargetAttributes::associated_attribute_changed(name, value, namespace_);
}
void HTMLButtonElement::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
PopoverInvokerElement::visit_edges(visitor);
PopoverTargetAttributes::visit_edges(visitor);
visitor.visit(m_command_for_element);
}
@ -217,9 +217,9 @@ void HTMLButtonElement::activation_behavior(DOM::Event const& event)
// 1. Assert: target's namespace is the HTML namespace.
VERIFY(target->namespace_uri() == Namespace::HTML);
// 2. If this standard does not define is valid invoker command steps for target's local name, then return.
// 3. Otherwise, if the result of running target's corresponding is valid invoker command steps given command is false, then return.
if (!target->is_valid_invoker_command(command))
// 2. If this standard does not define is valid command steps for target's local name, then return.
// 3. Otherwise, if the result of running target's corresponding is valid command steps given command is false, then return.
if (!target->is_valid_command(command))
return;
}
@ -284,16 +284,16 @@ void HTMLButtonElement::activation_behavior(DOM::Event const& event)
}
}
// 12. Otherwise, if this standard defines invoker command steps for target's local name,
// then run the corresponding invoker command steps given target, element, and command.
// 12. Otherwise, if this standard defines command steps for target's local name,
// then run the corresponding command steps given target, element, and command.
else {
target->invoker_command_steps(*this, command);
target->command_steps(*this, command);
}
}
// 6. Otherwise, run the popover target attribute activation behavior given element and event's target.
else if (event.target() && event.target()->is_dom_node())
PopoverInvokerElement::popover_target_activation_behaviour(*this, as<DOM::Node>(*event.target()));
PopoverTargetAttributes::popover_target_activation_behaviour(*this, as<DOM::Node>(*event.target()));
}
bool HTMLButtonElement::is_focusable() const

View file

@ -9,7 +9,7 @@
#include <LibWeb/ARIA/Roles.h>
#include <LibWeb/HTML/FormAssociatedElement.h>
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/HTML/PopoverInvokerElement.h>
#include <LibWeb/HTML/PopoverTargetAttributes.h>
namespace Web::HTML {
@ -22,7 +22,7 @@ namespace Web::HTML {
class HTMLButtonElement final
: public HTMLElement
, public FormAssociatedElement
, public PopoverInvokerElement {
, public PopoverTargetAttributes {
WEB_PLATFORM_OBJECT(HTMLButtonElement, HTMLElement);
GC_DECLARE_ALLOCATOR(HTMLButtonElement);
FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLButtonElement)

View file

@ -1,6 +1,6 @@
#import <HTML/HTMLElement.idl>
#import <HTML/HTMLFormElement.idl>
#import <HTML/PopoverInvokerElement.idl>
#import <HTML/PopoverTargetAttributes.idl>
#import <HTML/ValidityState.idl>
[MissingValueDefault=submit, InvalidValueDefault=submit]
@ -37,4 +37,4 @@ interface HTMLButtonElement : HTMLElement {
readonly attribute NodeList labels;
};
HTMLButtonElement includes PopoverInvokerElement;
HTMLButtonElement includes PopoverTargetAttributes;

View file

@ -484,8 +484,8 @@ void HTMLDialogElement::set_is_modal(bool is_modal)
invalidate_style(DOM::StyleInvalidationReason::HTMLDialogElementSetIsModal);
}
// https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element:is-valid-invoker-command-steps
bool HTMLDialogElement::is_valid_invoker_command(String& command)
// https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element:is-valid-command-steps
bool HTMLDialogElement::is_valid_command(String& command)
{
// 1. If command is in the Close state, the Request Close state, or the Show Modal state, then return true.
if (command == "close" || command == "request-close" || command == "show-modal")
@ -495,8 +495,8 @@ bool HTMLDialogElement::is_valid_invoker_command(String& command)
return false;
}
// https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element:invoker-command-steps
void HTMLDialogElement::invoker_command_steps(DOM::Element& invoker, String& command)
// https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element:command-steps
void HTMLDialogElement::command_steps(DOM::Element& source, String& command)
{
// 1. If element is in the popover showing state, then return.
if (popover_visibility_state() == PopoverVisibilityState::Showing) {
@ -504,22 +504,22 @@ void HTMLDialogElement::invoker_command_steps(DOM::Element& invoker, String& com
}
// 2. If command is in the Close state and element has an open attribute,
// then close the dialog given element with invoker's optional value and invoker.
// then close the dialog given element with source's optional value and source.
if (command == "close" && has_attribute(AttributeNames::open)) {
auto const optional_value = as<FormAssociatedElement>(invoker).optional_value();
close_the_dialog(optional_value, invoker);
auto const optional_value = as<FormAssociatedElement>(source).optional_value();
close_the_dialog(optional_value, source);
}
// 3. If command is in the Request Close state and element has an open attribute,
// then request to close the dialog element with invoker's optional value and invoker.
// then request to close the dialog element with source's optional value and source.
if (command == "request-close" && has_attribute(AttributeNames::open)) {
auto const optional_value = as<FormAssociatedElement>(invoker).optional_value();
request_close_the_dialog(optional_value, invoker);
auto const optional_value = as<FormAssociatedElement>(source).optional_value();
request_close_the_dialog(optional_value, source);
}
// 4. If command is the Show Modal state and element does not have an open attribute, then show a modal dialog given element and invoker.
// 4. If command is the Show Modal state and element does not have an open attribute, then show a modal dialog given element and source.
if (command == "show-modal" && !has_attribute(AttributeNames::open)) {
MUST(show_a_modal_dialog(*this, invoker));
MUST(show_a_modal_dialog(*this, source));
}
}

View file

@ -47,8 +47,8 @@ public:
bool is_modal() const { return m_is_modal; }
void set_is_modal(bool);
bool is_valid_invoker_command(String&) override;
void invoker_command_steps(DOM::Element&, String&) override;
bool is_valid_command(String&) override;
void command_steps(DOM::Element&, String&) override;
private:
HTMLDialogElement(DOM::Document&, DOM::QualifiedName);

View file

@ -35,7 +35,7 @@
#include <LibWeb/HTML/HTMLLabelElement.h>
#include <LibWeb/HTML/HTMLObjectElement.h>
#include <LibWeb/HTML/HTMLParagraphElement.h>
#include <LibWeb/HTML/PopoverInvokerElement.h>
#include <LibWeb/HTML/PopoverTargetAttributes.h>
#include <LibWeb/HTML/ToggleEvent.h>
#include <LibWeb/HTML/Window.h>
#include <LibWeb/Infra/CharacterTypes.h>
@ -73,7 +73,7 @@ void HTMLElement::visit_edges(Cell::Visitor& visitor)
HTMLOrSVGElement::visit_edges(visitor);
visitor.visit(m_labels);
visitor.visit(m_attached_internals);
visitor.visit(m_popover_invoker);
visitor.visit(m_popover_trigger);
visitor.visit(m_popover_close_watcher);
}
@ -1255,15 +1255,15 @@ WebIDL::ExceptionOr<bool> HTMLElement::check_popover_validity(ExpectedToBeShowin
// https://html.spec.whatwg.org/multipage/popover.html#dom-showpopover
WebIDL::ExceptionOr<void> HTMLElement::show_popover_for_bindings(ShowPopoverOptions const& options)
{
// 1. Let invoker be options["source"] if it exists; otherwise, null.
auto invoker = options.source;
// 2. Run show popover given this, true, and invoker.
return show_popover(ThrowExceptions::Yes, invoker);
// 1. Let source be options["source"] if it exists; otherwise, null.
auto source = options.source;
// 2. Run show popover given this, true, and source.
return show_popover(ThrowExceptions::Yes, source);
}
// https://html.spec.whatwg.org/multipage/popover.html#show-popover
// https://whatpr.org/html/9457/popover.html#show-popover
WebIDL::ExceptionOr<void> HTMLElement::show_popover(ThrowExceptions throw_exceptions, GC::Ptr<HTMLElement> invoker)
WebIDL::ExceptionOr<void> HTMLElement::show_popover(ThrowExceptions throw_exceptions, GC::Ptr<HTMLElement> source)
{
// 1. If the result of running check popover validity given element, false, throwExceptions, null and false is false, then return.
if (!TRY(check_popover_validity(ExpectedToBeShowing::No, throw_exceptions, nullptr, IgnoreDomState::No)))
@ -1272,8 +1272,8 @@ WebIDL::ExceptionOr<void> HTMLElement::show_popover(ThrowExceptions throw_except
// 2. Let document be element's node document.
auto& document = this->document();
// 3. Assert: element's popover invoker is null.
VERIFY(!m_popover_invoker);
// 3. Assert: element's popover trigger is null.
VERIFY(!m_popover_trigger);
// 4. Assert: element is not in document's top layer.
VERIFY(!in_top_layer());
@ -1294,12 +1294,12 @@ WebIDL::ExceptionOr<void> HTMLElement::show_popover(ThrowExceptions throw_except
m_popover_showing_or_hiding = false;
};
// 9. If the result of firing an event named beforetoggle, using ToggleEvent, with the cancelable attribute initialized to true, the oldState attribute initialized to "closed", the newState attribute initialized to "open" at element, and the source attribute initialized to invoker at element is false, then run cleanupShowingFlag and return.
// 9. If the result of firing an event named beforetoggle, using ToggleEvent, with the cancelable attribute initialized to true, the oldState attribute initialized to "closed", the newState attribute initialized to "open" at element, and the source attribute initialized to source at element is false, then run cleanupShowingFlag and return.
ToggleEventInit event_init {};
event_init.old_state = "closed"_string;
event_init.new_state = "open"_string;
event_init.cancelable = true;
if (!dispatch_event(ToggleEvent::create(realm(), HTML::EventNames::beforetoggle, move(event_init), invoker))) {
if (!dispatch_event(ToggleEvent::create(realm(), HTML::EventNames::beforetoggle, move(event_init), source))) {
cleanup_showing_flag();
return {};
}
@ -1324,13 +1324,15 @@ WebIDL::ExceptionOr<void> HTMLElement::show_popover(ThrowExceptions throw_except
};
StackToAppendTo stack_to_append_to = StackToAppendTo::Null;
// 16. If originalType is the auto state, then:
// NB: Steps 14 and 15 are implemented inside step 17 instead, see note below.
// 16. If originalType is the Auto state, then:
if (original_type == "auto"sv) {
// 1. Run close entire popover list given document's showing hint popover list, shouldRestoreFocus, and fireEvents.
close_entire_popover_list(document.showing_hint_popover_list(), should_restore_focus, fire_events);
// 2. Let ancestor be the result of running the topmost popover ancestor algorithm given element, document's showing auto popover list, invoker, and true.
Variant<GC::Ptr<HTMLElement>, GC::Ptr<DOM::Document>> ancestor = topmost_popover_ancestor(this, document.showing_auto_popover_list(), invoker, IsPopover::Yes);
// 2. Let ancestor be the result of running the topmost popover ancestor algorithm given element, document's showing auto popover list, source, and true.
Variant<GC::Ptr<HTMLElement>, GC::Ptr<DOM::Document>> ancestor = topmost_popover_ancestor(this, document.showing_auto_popover_list(), source, IsPopover::Yes);
// 3. If ancestor is null, then set ancestor to document.
if (!ancestor.get<GC::Ptr<HTMLElement>>())
@ -1349,10 +1351,10 @@ WebIDL::ExceptionOr<void> HTMLElement::show_popover(ThrowExceptions throw_except
// AD-HOC: Steps 14 and 15 have been moved here to avoid hitting the `popover != manual` assertion in the topmost popover ancestor algorithm.
// Spec issue: https://github.com/whatwg/html/issues/10988.
// 14. Let autoAncestor be the result of running the topmost popover ancestor algorithm given element, document's showing auto popover list, invoker, and true.
auto auto_ancestor = topmost_popover_ancestor(this, document.showing_auto_popover_list(), invoker, IsPopover::Yes);
auto auto_ancestor = topmost_popover_ancestor(this, document.showing_auto_popover_list(), source, IsPopover::Yes);
// 15. Let hintAncestor be the result of running the topmost popover ancestor algorithm given element, document's showing hint popover list, invoker, and true.
auto hint_ancestor = topmost_popover_ancestor(this, document.showing_hint_popover_list(), invoker, IsPopover::Yes);
auto hint_ancestor = topmost_popover_ancestor(this, document.showing_hint_popover_list(), source, IsPopover::Yes);
// 1. If hintAncestor is not null, then:
if (hint_ancestor) {
@ -1456,13 +1458,13 @@ WebIDL::ExceptionOr<void> HTMLElement::show_popover(ThrowExceptions throw_except
document.add_an_element_to_the_top_layer(*this);
// 22. Set element's popover visibility state to showing.
m_popover_visibility_state = PopoverVisibilityState::Showing;
// 23. Set element's popover invoker to invoker.
m_popover_invoker = invoker;
// FIXME: 24. Set element's implicit anchor element to invoker.
// 23. Set element's popover trigger to source.
m_popover_trigger = source;
// FIXME: 24. Set element's implicit anchor element to source.
// FIXME: 25. Run the popover focusing steps given element.
// FIXME: 26. If shouldRestoreFocus is true and element's popover attribute is not in the No Popover state, then set element's previously focused element to originallyFocusedElement.
// 27. Queue a popover toggle event task given element, "closed", "open", and invoker.
queue_a_popover_toggle_event_task("closed"_string, "open"_string, invoker);
// 27. Queue a popover toggle event task given element, "closed", "open", and source.
queue_a_popover_toggle_event_task("closed"_string, "open"_string, source);
// 28. Run cleanupShowingFlag.
cleanup_showing_flag();
@ -1576,8 +1578,8 @@ WebIDL::ExceptionOr<void> HTMLElement::hide_popover(FocusPreviousElement focus_p
}
}
// 11. Set element's popover invoker to null.
m_popover_invoker = nullptr;
// 11. Set element's popover trigger to null.
m_popover_trigger = nullptr;
// 12. Set element's opened in popover mode to null.
m_opened_in_popover_mode = {};
@ -1607,26 +1609,26 @@ WebIDL::ExceptionOr<bool> HTMLElement::toggle_popover(TogglePopoverOptionsOrForc
{
// 1. Let force be null.
Optional<bool> force;
GC::Ptr<HTMLElement> invoker;
GC::Ptr<HTMLElement> source;
// 2. If options is a boolean, set force to options.
options.visit(
[&force](bool forceBool) {
force = forceBool;
},
[&force, &invoker](TogglePopoverOptions options) {
[&force, &source](TogglePopoverOptions options) {
// 3. Otherwise, if options["force"] exists, set force to options["force"].
force = options.force;
// 4. Let invoker be options["source"] if it exists; otherwise, null.
invoker = options.source;
// 4. Let source be options["source"] if it exists; otherwise, null.
source = options.source;
});
// 5. If this's popover visibility state is showing, and force is null or false, then run the hide popover algorithm given this, true, true, true, false, and null.
if (popover_visibility_state() == PopoverVisibilityState::Showing && (!force.has_value() || !force.value()))
TRY(hide_popover(FocusPreviousElement::Yes, FireEvents::Yes, ThrowExceptions::Yes, IgnoreDomState::No, nullptr));
// 6. Otherwise, if force is not present or true, then run show popover given this true, and invoker.
// 6. Otherwise, if force is not present or true, then run show popover given this true, and source.
else if (!force.has_value() || force.value())
TRY(show_popover(ThrowExceptions::Yes, invoker));
TRY(show_popover(ThrowExceptions::Yes, source));
// 7. Otherwise:
else {
// 7.1 Let expectedToBeShowing be true if this's popover visibility state is showing; otherwise false.
@ -1759,9 +1761,10 @@ void HTMLElement::close_entire_popover_list(Vector<GC::Ref<HTMLElement>> const&
}
// https://html.spec.whatwg.org/multipage/popover.html#topmost-popover-ancestor
GC::Ptr<HTMLElement> HTMLElement::topmost_popover_ancestor(GC::Ptr<DOM::Node> new_popover_or_top_layer_element, Vector<GC::Ref<HTMLElement>> const& popover_list, GC::Ptr<HTMLElement> invoker, IsPopover is_popover)
GC::Ptr<HTMLElement> HTMLElement::topmost_popover_ancestor(GC::Ptr<DOM::Node> new_popover_or_top_layer_element, Vector<GC::Ref<HTMLElement>> const& popover_list, GC::Ptr<HTMLElement> source, IsPopover is_popover)
{
// To find the topmost popover ancestor, given a Node newPopoverOrTopLayerElement, a list popoverList, an HTML element or null invoker, and a boolean isPopover, perform the following steps. They return an HTML element or null.
// To find the topmost popover ancestor, given a Node newPopoverOrTopLayerElement, a list popoverList, an HTML
// element or null source, and a boolean isPopover, perform the following steps. They return an HTML element or null.
// 1. If isPopover is true:
auto* new_popover = as_if<HTML::HTMLElement>(*new_popover_or_top_layer_element);
@ -1777,8 +1780,8 @@ GC::Ptr<HTMLElement> HTMLElement::topmost_popover_ancestor(GC::Ptr<DOM::Node> ne
}
// 2. Otherwise:
else {
// 1. Assert: invoker is null.
VERIFY(!invoker);
// 1. Assert: source is null.
VERIFY(!source);
}
// 3. Let popoverPositions be an empty ordered map.
@ -1850,8 +1853,8 @@ GC::Ptr<HTMLElement> HTMLElement::topmost_popover_ancestor(GC::Ptr<DOM::Node> ne
// 10. Run checkAncestor given newPopoverOrTopLayerElement's parent node within the flat tree.
check_ancestor(new_popover_or_top_layer_element->shadow_including_first_ancestor_of_type<HTMLElement>());
// 11. Run checkAncestor given invoker.
check_ancestor(invoker.ptr());
// 11. Run checkAncestor given source.
check_ancestor(source.ptr());
// 12. Return topmostPopoverAncestor.
return topmost_popover_ancestor;
@ -1879,10 +1882,10 @@ GC::Ptr<HTMLElement> HTMLElement::nearest_inclusive_open_popover()
return {};
}
// https://html.spec.whatwg.org/multipage/popover.html#nearest-inclusive-target-popover-for-invoker
GC::Ptr<HTMLElement> HTMLElement::nearest_inclusive_target_popover_for_invoker()
// https://html.spec.whatwg.org/multipage/popover.html#nearest-inclusive-target-popover
GC::Ptr<HTMLElement> HTMLElement::nearest_inclusive_target_popover()
{
// To find the nearest inclusive target popover for invoker given a Node node:
// To find the nearest inclusive target popover given a Node node:
// 1. Let currentNode be node.
auto* current_node = this;
@ -1890,7 +1893,7 @@ GC::Ptr<HTMLElement> HTMLElement::nearest_inclusive_target_popover_for_invoker()
// 2. While currentNode is not null:
while (current_node) {
// 1. Let targetPopover be currentNode's popover target element.
auto target_popover = PopoverInvokerElement::get_the_popover_target_element(*current_node);
auto target_popover = PopoverTargetAttributes::get_the_popover_target_element(*current_node);
// 2. If targetPopover is not null and targetPopover's popover attribute is in the Auto state or the Hint state, and targetPopover's popover visibility state is showing, then return targetPopover.
if (target_popover) {
@ -2028,21 +2031,22 @@ GC::Ptr<HTMLElement> HTMLElement::topmost_clicked_popover(GC::Ptr<DOM::Node> nod
// 1. Let clickedPopover be the result of running nearest inclusive open popover given node.
auto clicked_popover = nearest_element->nearest_inclusive_open_popover();
// 2. Let invokerPopover be the result of running nearest inclusive target popover for invoker given node.
auto invoker_popover = nearest_element->nearest_inclusive_target_popover_for_invoker();
// 2. Let targetPopover be the result of running nearest inclusive target popover given node.
auto target_popover = nearest_element->nearest_inclusive_target_popover();
if (!clicked_popover)
return invoker_popover;
return target_popover;
if (!invoker_popover)
if (!target_popover)
return clicked_popover;
// 3. If the result of getting the popover stack position given clickedPopover is greater than the result of getting the popover stack position given invokerPopover, then return clickedPopover.
if (clicked_popover->popover_stack_position() > invoker_popover->popover_stack_position())
// 3. If the result of getting the popover stack position given clickedPopover is greater than the result of
// getting the popover stack position given targetPopover, then return clickedPopover.
if (clicked_popover->popover_stack_position() > target_popover->popover_stack_position())
return clicked_popover;
// 4. Return invokerPopover.
return invoker_popover;
// 4. Return targetPopover.
return target_popover;
}
void HTMLElement::did_receive_focus()

View file

@ -175,11 +175,11 @@ public:
WebIDL::ExceptionOr<bool> toggle_popover(TogglePopoverOptionsOrForceBoolean const&);
WebIDL::ExceptionOr<bool> check_popover_validity(ExpectedToBeShowing expected_to_be_showing, ThrowExceptions throw_exceptions, GC::Ptr<DOM::Document>, IgnoreDomState ignore_dom_state);
WebIDL::ExceptionOr<void> show_popover(ThrowExceptions throw_exceptions, GC::Ptr<HTMLElement> invoker);
WebIDL::ExceptionOr<void> show_popover(ThrowExceptions throw_exceptions, GC::Ptr<HTMLElement> source);
WebIDL::ExceptionOr<void> hide_popover(FocusPreviousElement focus_previous_element, FireEvents fire_events, ThrowExceptions throw_exceptions, IgnoreDomState ignore_dom_state, GC::Ptr<HTMLElement> source);
static void hide_all_popovers_until(Variant<GC::Ptr<HTMLElement>, GC::Ptr<DOM::Document>> endpoint, FocusPreviousElement focus_previous_element, FireEvents fire_events);
static GC::Ptr<HTMLElement> topmost_popover_ancestor(GC::Ptr<DOM::Node> new_popover_or_top_layer_element, Vector<GC::Ref<HTMLElement>> const& popover_list, GC::Ptr<HTMLElement> invoker, IsPopover is_popover);
static GC::Ptr<HTMLElement> topmost_popover_ancestor(GC::Ptr<DOM::Node> new_popover_or_top_layer_element, Vector<GC::Ref<HTMLElement>> const& popover_list, GC::Ptr<HTMLElement> source, IsPopover is_popover);
static void light_dismiss_open_popovers(UIEvents::PointerEvent const&, GC::Ptr<DOM::Node>);
@ -188,8 +188,8 @@ public:
bool draggable() const;
void set_draggable(bool draggable);
virtual bool is_valid_invoker_command(String&) { return false; }
virtual void invoker_command_steps(DOM::Element&, String&) { }
virtual bool is_valid_command(String&) { return false; }
virtual void command_steps(DOM::Element&, String&) { }
bool is_form_associated_custom_element();
@ -240,7 +240,7 @@ private:
static Optional<String> popover_value_to_state(Optional<String> value);
void hide_popover_stack_until(Vector<GC::Ref<HTMLElement>> const& popover_list, FocusPreviousElement focus_previous_element, FireEvents fire_events);
GC::Ptr<HTMLElement> nearest_inclusive_open_popover();
GC::Ptr<HTMLElement> nearest_inclusive_target_popover_for_invoker();
GC::Ptr<HTMLElement> nearest_inclusive_target_popover();
static void close_entire_popover_list(Vector<GC::Ref<HTMLElement>> const& popover_list, FocusPreviousElement focus_previous_element, FireEvents fire_events);
static GC::Ptr<HTMLElement> topmost_clicked_popover(GC::Ptr<DOM::Node> node);
size_t popover_stack_position();
@ -264,8 +264,8 @@ private:
// https://html.spec.whatwg.org/multipage/popover.html#popover-showing-or-hiding
bool m_popover_showing_or_hiding { false };
// https://html.spec.whatwg.org/multipage/popover.html#popover-invoker
GC::Ptr<HTMLElement> m_popover_invoker;
// https://html.spec.whatwg.org/multipage/popover.html#popover-trigger
GC::Ptr<HTMLElement> m_popover_trigger;
// https://html.spec.whatwg.org/multipage/popover.html#the-popover-attribute:toggle-task-tracker
Optional<ToggleTaskTracker> m_popover_toggle_task_tracker;

View file

@ -1414,7 +1414,7 @@ void HTMLInputElement::did_lose_focus()
void HTMLInputElement::form_associated_element_attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_)
{
PopoverInvokerElement::associated_attribute_changed(name, value, namespace_);
PopoverTargetAttributes::associated_attribute_changed(name, value, namespace_);
if (name == HTML::AttributeNames::checked) {
// https://html.spec.whatwg.org/multipage/input.html#the-input-element:concept-input-checked-dirty-2
@ -3094,7 +3094,7 @@ void HTMLInputElement::activation_behavior(DOM::Event const& event)
// 4. Run the popover target attribute activation behavior given element and event's target.
if (event.target() && event.target()->is_dom_node())
PopoverInvokerElement::popover_target_activation_behaviour(*this, as<DOM::Node>(*event.target()));
PopoverTargetAttributes::popover_target_activation_behaviour(*this, as<DOM::Node>(*event.target()));
}
bool HTMLInputElement::has_input_activation_behavior() const

View file

@ -19,7 +19,7 @@
#include <LibWeb/HTML/FileFilter.h>
#include <LibWeb/HTML/FormAssociatedElement.h>
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/HTML/PopoverInvokerElement.h>
#include <LibWeb/HTML/PopoverTargetAttributes.h>
#include <LibWeb/Layout/ImageProvider.h>
#include <LibWeb/WebIDL/DOMException.h>
#include <LibWeb/WebIDL/Types.h>
@ -55,7 +55,7 @@ class WEB_API HTMLInputElement final
: public HTMLElement
, public FormAssociatedTextControlElement
, public Layout::ImageProvider
, public PopoverInvokerElement
, public PopoverTargetAttributes
, public AutocompleteElement {
WEB_PLATFORM_OBJECT(HTMLInputElement, HTMLElement);
GC_DECLARE_ALLOCATOR(HTMLInputElement);

View file

@ -1,7 +1,7 @@
#import <HTML/HTMLDataListElement.idl>
#import <HTML/HTMLElement.idl>
#import <HTML/HTMLFormElement.idl>
#import <HTML/PopoverInvokerElement.idl>
#import <HTML/PopoverTargetAttributes.idl>
#import <HTML/ValidityState.idl>
#import <FileAPI/FileList.idl>
@ -75,4 +75,4 @@ interface HTMLInputElement : HTMLElement {
[CEReactions, Reflect] attribute DOMString align;
[CEReactions, Reflect=usemap] attribute DOMString useMap;
};
HTMLInputElement includes PopoverInvokerElement;
HTMLInputElement includes PopoverTargetAttributes;

View file

@ -10,11 +10,11 @@
#include <LibWeb/HTML/AttributeNames.h>
#include <LibWeb/HTML/FormAssociatedElement.h>
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/HTML/PopoverInvokerElement.h>
#include <LibWeb/HTML/PopoverTargetAttributes.h>
namespace Web::HTML {
void PopoverInvokerElement::associated_attribute_changed(FlyString const& name, Optional<String> const&, Optional<FlyString> const& namespace_)
void PopoverTargetAttributes::associated_attribute_changed(FlyString const& name, Optional<String> const&, Optional<FlyString> const& namespace_)
{
// From: https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributess
// For element reflected targets only: the following attribute change steps, given element, localName, oldValue, value, and namespace,
@ -28,19 +28,19 @@ void PopoverInvokerElement::associated_attribute_changed(FlyString const& name,
m_popover_target_element = nullptr;
}
void PopoverInvokerElement::visit_edges(JS::Cell::Visitor& visitor)
void PopoverTargetAttributes::visit_edges(JS::Cell::Visitor& visitor)
{
visitor.visit(m_popover_target_element);
}
// https://html.spec.whatwg.org/multipage/popover.html#popover-target-attribute-activation-behavior
// https://whatpr.org/html/9457/popover.html#popover-target-attribute-activation-behavior
void PopoverInvokerElement::popover_target_activation_behaviour(GC::Ref<DOM::Node> node, GC::Ref<DOM::Node> event_target)
void PopoverTargetAttributes::popover_target_activation_behaviour(GC::Ref<DOM::Node> node, GC::Ref<DOM::Node> event_target)
{
// To run the popover target attribute activation behavior given a Node node and a Node eventTarget:
// 1. Let popover be node's popover target element.
auto popover = PopoverInvokerElement::get_the_popover_target_element(node);
auto popover = PopoverTargetAttributes::get_the_popover_target_element(node);
// 2. If popover is null, then return.
if (!popover)
@ -74,7 +74,7 @@ void PopoverInvokerElement::popover_target_activation_behaviour(GC::Ref<DOM::Nod
}
// https://html.spec.whatwg.org/multipage/popover.html#popover-target-element
GC::Ptr<HTMLElement> PopoverInvokerElement::get_the_popover_target_element(GC::Ref<DOM::Node> node)
GC::Ptr<HTMLElement> PopoverTargetAttributes::get_the_popover_target_element(GC::Ref<DOM::Node> node)
{
// To get the popover target element given a Node node, perform the following steps. They return an HTML element or null.
@ -95,7 +95,7 @@ GC::Ptr<HTMLElement> PopoverInvokerElement::get_the_popover_target_element(GC::R
return {};
// 4. Let popoverElement be the result of running node's get the popovertarget-associated element.
auto const* popover_invoker_element = as_if<PopoverInvokerElement>(*node);
auto const* popover_invoker_element = as_if<PopoverTargetAttributes>(*node);
GC::Ptr<HTMLElement> popover_element = as<HTMLElement>(popover_invoker_element->m_popover_target_element.ptr());
if (!popover_element) {
auto target_id = as<HTMLElement>(*node).attribute("popovertarget"_fly_string);

View file

@ -12,10 +12,10 @@
namespace Web::HTML {
class PopoverInvokerElement {
class PopoverTargetAttributes {
public:
PopoverInvokerElement() { }
PopoverTargetAttributes() { }
GC::Ptr<DOM::Element> popover_target_element() { return m_popover_target_element; }

View file

@ -6,8 +6,8 @@ enum PopoverTargetActionAttribute {
"hide"
};
// https://html.spec.whatwg.org/multipage/popover.html#popoverinvokerelement
interface mixin PopoverInvokerElement {
// https://html.spec.whatwg.org/multipage/popover.html#popovertargetattributes
interface mixin PopoverTargetAttributes {
[Reflect=popovertarget, CEReactions] attribute Element? popoverTargetElement;
[Reflect=popovertargetaction, Enumerated=PopoverTargetActionAttribute, CEReactions] attribute DOMString popoverTargetAction;
};

View file

@ -951,7 +951,7 @@ interface HTMLInputElement : HTMLElement {
// also has obsolete members
};
HTMLInputElement includes PopoverInvokerElement;
HTMLInputElement includes PopoverTargetAttributes;
[Exposed=Window]
interface HTMLButtonElement : HTMLElement {
@ -979,7 +979,7 @@ interface HTMLButtonElement : HTMLElement {
readonly attribute NodeList labels;
};
HTMLButtonElement includes PopoverInvokerElement;
HTMLButtonElement includes PopoverTargetAttributes;
[Exposed=Window]
interface HTMLSelectElement : HTMLElement {
@ -1813,7 +1813,7 @@ dictionary DragEventInit : MouseEventInit {
DataTransfer? dataTransfer = null;
};
interface mixin PopoverInvokerElement {
interface mixin PopoverTargetAttributes {
[CEReactions] attribute Element? popoverTargetElement;
[CEReactions] attribute DOMString popoverTargetAction;
};