mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:48:10 +00:00
LibWeb: Reset form association when the element's form attribute changes
This commit is contained in:
parent
23fb1209af
commit
960dcf0e56
12 changed files with 75 additions and 40 deletions
|
@ -19,26 +19,33 @@ namespace Web::HTML {
|
|||
// HTMLElement::inserted() -> Use form_associated_element_was_inserted()
|
||||
// HTMLElement::removed_from() -> Use form_associated_element_was_removed()
|
||||
//
|
||||
#define FORM_ASSOCIATED_ELEMENT(ElementBaseClass, ElementClass) \
|
||||
private: \
|
||||
virtual HTMLElement& form_associated_element_to_html_element() override \
|
||||
{ \
|
||||
static_assert(IsBaseOf<HTMLElement, ElementClass>); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
virtual void inserted() override \
|
||||
{ \
|
||||
ElementBaseClass::inserted(); \
|
||||
form_node_was_inserted(); \
|
||||
form_associated_element_was_inserted(); \
|
||||
} \
|
||||
\
|
||||
virtual void removed_from(DOM::Node* node) override \
|
||||
{ \
|
||||
ElementBaseClass::removed_from(node); \
|
||||
form_node_was_removed(); \
|
||||
form_associated_element_was_removed(node); \
|
||||
#define FORM_ASSOCIATED_ELEMENT(ElementBaseClass, ElementClass) \
|
||||
private: \
|
||||
virtual HTMLElement& form_associated_element_to_html_element() override \
|
||||
{ \
|
||||
static_assert(IsBaseOf<HTMLElement, ElementClass>); \
|
||||
return *this; \
|
||||
} \
|
||||
\
|
||||
virtual void inserted() override \
|
||||
{ \
|
||||
ElementBaseClass::inserted(); \
|
||||
form_node_was_inserted(); \
|
||||
form_associated_element_was_inserted(); \
|
||||
} \
|
||||
\
|
||||
virtual void removed_from(DOM::Node* node) override \
|
||||
{ \
|
||||
ElementBaseClass::removed_from(node); \
|
||||
form_node_was_removed(); \
|
||||
form_associated_element_was_removed(node); \
|
||||
} \
|
||||
\
|
||||
virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override \
|
||||
{ \
|
||||
ElementBaseClass::attribute_changed(name, value); \
|
||||
form_node_attribute_changed(name, value); \
|
||||
form_associated_element_attribute_changed(name, value); \
|
||||
}
|
||||
|
||||
class FormAssociatedElement {
|
||||
|
@ -83,9 +90,11 @@ protected:
|
|||
|
||||
virtual void form_associated_element_was_inserted() { }
|
||||
virtual void form_associated_element_was_removed(DOM::Node*) { }
|
||||
virtual void form_associated_element_attribute_changed(FlyString const&, Optional<String> const&) { }
|
||||
|
||||
void form_node_was_inserted();
|
||||
void form_node_was_removed();
|
||||
void form_node_attribute_changed(FlyString const&, Optional<String> const&);
|
||||
|
||||
private:
|
||||
WeakPtr<HTMLFormElement> m_form;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue