LibWeb: Add PopOverInvokerElement and use it in HTMLButtonElement

The popoverTargetElement seems to be one of the only cases of a
reflected Element? attribute in the HTML spec, the behaviour of which
is specified in section 2.6.1.

Buttons can't actually toggle popovers yet because showing/hiding
popovers is not implemented yet.
This commit is contained in:
Nathan van der Kamp
2024-11-23 23:06:06 +01:00
committed by Tim Ledbetter
parent 158acabd21
commit a276cf2d5e
9 changed files with 97 additions and 2 deletions

View File

@@ -0,0 +1,34 @@
/*
* Copyright (c) 2024, Nathan van der Kamp <nbvdkamp@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGC/Ptr.h>
#include <LibJS/Heap/Cell.h>
#include <LibWeb/Forward.h>
namespace Web::HTML {
class PopoverInvokerElement {
public:
PopoverInvokerElement() { }
GC::Ptr<DOM::Element> get_popover_target_element() { return m_popover_target_element; }
void set_popover_target_element(GC::Ptr<DOM::Element> value) { m_popover_target_element = value; }
protected:
void visit_edges(JS::Cell::Visitor& visitor)
{
visitor.visit(m_popover_target_element);
}
private:
GC::Ptr<DOM::Element> m_popover_target_element;
};
}