mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 11:54:57 +00:00
LibWeb: Remove inheritance of FormAssociatedElement from HTMLElement
HTMLObjectElement will need to be both a FormAssociatedElement and a
BrowsingContextContainer. Currently, both of these classes inherit from
HTMLElement. This can work in C++, but is generally frowned upon, and
doesn't play particularly well with the rest of LibWeb.
Instead, we can essentially revert commit 3bb5c62
to remove HTMLElement
from FormAssociatedElement's hierarchy. This means that objects such as
HTMLObjectElement individually inherit from FormAssociatedElement and
HTMLElement now.
Some caveats are:
* FormAssociatedElement still needs to know when the HTMLElement is
inserted into and removed from the DOM. This hook is automatically
injected via a macro now, while still allowing classes like
HTMLInputElement to also know when the element is inserted.
* Casting from a DOM::Element to a FormAssociatedElement is now a
sideways cast, rather than directly following an inheritance chain.
This means static_cast cannot be used here; but we can safely use
dynamic_cast since the only 2 instances of this already use RTTI to
verify the cast.
This commit is contained in:
parent
f7f0195fae
commit
5608bc4eaf
21 changed files with 137 additions and 61 deletions
|
@ -21,7 +21,7 @@
|
|||
namespace Web::HTML {
|
||||
|
||||
HTMLInputElement::HTMLInputElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: FormAssociatedElement(document, move(qualified_name))
|
||||
: HTMLElement(document, move(qualified_name))
|
||||
, m_value(String::empty())
|
||||
{
|
||||
activation_behavior = [this](auto&) {
|
||||
|
@ -215,7 +215,7 @@ bool HTMLInputElement::is_focusable() const
|
|||
|
||||
void HTMLInputElement::parse_attribute(FlyString const& name, String const& value)
|
||||
{
|
||||
FormAssociatedElement::parse_attribute(name, value);
|
||||
HTMLElement::parse_attribute(name, value);
|
||||
if (name == HTML::AttributeNames::checked) {
|
||||
// When the checked content attribute is added, if the control does not have dirty checkedness,
|
||||
// the user agent must set the checkedness of the element to true
|
||||
|
@ -245,7 +245,7 @@ HTMLInputElement::TypeAttributeState HTMLInputElement::parse_type_attribute(Stri
|
|||
|
||||
void HTMLInputElement::did_remove_attribute(FlyString const& name)
|
||||
{
|
||||
FormAssociatedElement::did_remove_attribute(name);
|
||||
HTMLElement::did_remove_attribute(name);
|
||||
if (name == HTML::AttributeNames::checked) {
|
||||
// When the checked content attribute is removed, if the control does not have dirty checkedness,
|
||||
// the user agent must set the checkedness of the element to false.
|
||||
|
@ -310,7 +310,7 @@ String HTMLInputElement::value_sanitization_algorithm(String value) const
|
|||
return value;
|
||||
}
|
||||
|
||||
void HTMLInputElement::inserted()
|
||||
void HTMLInputElement::form_associated_element_was_inserted()
|
||||
{
|
||||
create_shadow_tree_if_needed();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue