LibWeb: Implement popover beforetoggle and toggle events

This commit is contained in:
Luke Warlow 2024-12-06 23:10:03 +00:00 committed by Andrew Kaster
commit fcf6cc27f2
Notes: github-actions[bot] 2024-12-12 22:11:32 +00:00
7 changed files with 371 additions and 11 deletions

View file

@ -6,10 +6,12 @@
#pragma once
#include <AK/Optional.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/HTML/GlobalEventHandlers.h>
#include <LibWeb/HTML/HTMLOrSVGElement.h>
#include <LibWeb/HTML/ToggleTaskTracker.h>
#include <LibWeb/HTML/TokenizedFeatures.h>
namespace Web::HTML {
@ -127,8 +129,6 @@ public:
WebIDL::ExceptionOr<void> show_popover(ThrowExceptions throw_exceptions, GC::Ptr<HTMLElement> invoker);
WebIDL::ExceptionOr<void> hide_popover(FocusPreviousElement focus_previous_element, FireEvents fire_events, ThrowExceptions throw_exceptions);
WebIDL::ExceptionOr<bool> check_popover_validity(ExpectedToBeShowing expected_to_be_showing, ThrowExceptions throw_exceptions, GC::Ptr<DOM::Document>);
protected:
HTMLElement(DOM::Document&, DOM::QualifiedName);
@ -155,6 +155,10 @@ private:
GC::Ptr<DOM::NodeList> m_labels;
WebIDL::ExceptionOr<bool> check_popover_validity(ExpectedToBeShowing expected_to_be_showing, ThrowExceptions throw_exceptions, GC::Ptr<DOM::Document>);
void queue_a_popover_toggle_event_task(String old_state, String new_state);
// https://html.spec.whatwg.org/multipage/custom-elements.html#attached-internals
GC::Ptr<ElementInternals> m_attached_internals;
@ -174,6 +178,9 @@ 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#the-popover-attribute:toggle-task-tracker
Optional<ToggleTaskTracker> m_popover_toggle_task_tracker;
};
}