1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 18:35:09 +00:00

LibWeb: Add form associated element categories

This commit is contained in:
Luke Wilde 2022-03-01 21:03:30 +00:00 committed by Andreas Kling
parent d2e18175ef
commit 432d496ed6
11 changed files with 117 additions and 0 deletions

View file

@ -21,6 +21,18 @@ public:
bool enabled() const; bool enabled() const;
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
virtual bool is_listed() const { return false; }
// https://html.spec.whatwg.org/multipage/forms.html#category-submit
virtual bool is_submittable() const { return false; }
// https://html.spec.whatwg.org/multipage/forms.html#category-reset
virtual bool is_resettable() const { return false; }
// https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
virtual bool is_auto_capitalize_inheriting() const { return false; }
protected: protected:
FormAssociatedElement(DOM::Document& document, DOM::QualifiedName qualified_name) FormAssociatedElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name)) : HTMLElement(document, move(qualified_name))

View file

@ -16,6 +16,20 @@ public:
HTMLButtonElement(DOM::Document&, DOM::QualifiedName); HTMLButtonElement(DOM::Document&, DOM::QualifiedName);
virtual ~HTMLButtonElement() override; virtual ~HTMLButtonElement() override;
// ^FormAssociatedElement
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
virtual bool is_listed() const override { return true; }
// https://html.spec.whatwg.org/multipage/forms.html#category-submit
virtual bool is_submittable() const override { return true; }
// https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
virtual bool is_auto_capitalize_inheriting() const override { return true; }
// ^HTMLElement
// https://html.spec.whatwg.org/multipage/forms.html#category-label
virtual bool is_labelable() const override { return true; }
}; };
} }

View file

@ -46,6 +46,9 @@ public:
bool fire_a_synthetic_pointer_event(FlyString const& type, DOM::Element& target, bool not_trusted); bool fire_a_synthetic_pointer_event(FlyString const& type, DOM::Element& target, bool not_trusted);
// https://html.spec.whatwg.org/multipage/forms.html#category-label
virtual bool is_labelable() const { return false; }
protected: protected:
virtual void parse_attribute(const FlyString& name, const String& value) override; virtual void parse_attribute(const FlyString& name, const String& value) override;

View file

@ -22,6 +22,13 @@ public:
static String fieldset = "fieldset"; static String fieldset = "fieldset";
return fieldset; return fieldset;
} }
// ^FormAssociatedElement
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
virtual bool is_listed() const override { return true; }
// https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
virtual bool is_auto_capitalize_inheriting() const override { return true; }
}; };
} }

View file

@ -83,6 +83,23 @@ public:
virtual void parse_attribute(FlyString const&, String const&) override; virtual void parse_attribute(FlyString const&, String const&) override;
virtual void did_remove_attribute(FlyString const&) override; virtual void did_remove_attribute(FlyString const&) override;
// ^FormAssociatedElement
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
virtual bool is_listed() const override { return true; }
// https://html.spec.whatwg.org/multipage/forms.html#category-submit
virtual bool is_submittable() const override { return true; }
// https://html.spec.whatwg.org/multipage/forms.html#category-reset
virtual bool is_resettable() const override { return true; }
// https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
virtual bool is_auto_capitalize_inheriting() const override { return true; }
// ^HTMLElement
// https://html.spec.whatwg.org/multipage/forms.html#category-label
virtual bool is_labelable() const override { return type_state() != TypeAttributeState::Hidden; }
private: private:
// ^DOM::Node // ^DOM::Node
virtual void inserted() override; virtual void inserted() override;

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2020, the SerenityOS developers. * Copyright (c) 2020, the SerenityOS developers.
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
@ -16,6 +17,10 @@ public:
HTMLMeterElement(DOM::Document&, DOM::QualifiedName); HTMLMeterElement(DOM::Document&, DOM::QualifiedName);
virtual ~HTMLMeterElement() override; virtual ~HTMLMeterElement() override;
// ^HTMLElement
// https://html.spec.whatwg.org/multipage/forms.html#category-label
virtual bool is_labelable() const override { return true; }
}; };
} }

View file

@ -25,6 +25,10 @@ public:
String data() const { return attribute(HTML::AttributeNames::data); } String data() const { return attribute(HTML::AttributeNames::data); }
String type() const { return attribute(HTML::AttributeNames::type); } String type() const { return attribute(HTML::AttributeNames::type); }
// ^FormAssociatedElement
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
virtual bool is_listed() const override { return true; }
private: private:
virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2020, the SerenityOS developers. * Copyright (c) 2020, the SerenityOS developers.
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
@ -22,6 +23,20 @@ public:
static String output = "output"; static String output = "output";
return output; return output;
} }
// ^FormAssociatedElement
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
virtual bool is_listed() const override { return true; }
// https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
virtual bool is_resettable() const override { return true; }
// https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
virtual bool is_auto_capitalize_inheriting() const override { return true; }
// ^HTMLElement
// https://html.spec.whatwg.org/multipage/forms.html#category-label
virtual bool is_labelable() const override { return true; }
}; };
} }

View file

@ -27,6 +27,10 @@ public:
double position() const; double position() const;
// ^HTMLElement
// https://html.spec.whatwg.org/multipage/forms.html#category-label
virtual bool is_labelable() const override { return true; }
private: private:
bool is_determinate() const { return has_attribute(HTML::AttributeNames::value); } bool is_determinate() const { return has_attribute(HTML::AttributeNames::value); }
}; };

View file

@ -1,6 +1,7 @@
/* /*
* Copyright (c) 2020, the SerenityOS developers. * Copyright (c) 2020, the SerenityOS developers.
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org> * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
@ -19,6 +20,23 @@ public:
HTMLSelectElement(DOM::Document&, DOM::QualifiedName); HTMLSelectElement(DOM::Document&, DOM::QualifiedName);
virtual ~HTMLSelectElement() override; virtual ~HTMLSelectElement() override;
// ^FormAssociatedElement
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
virtual bool is_listed() const override { return true; }
// https://html.spec.whatwg.org/multipage/forms.html#category-submit
virtual bool is_submittable() const override { return true; }
// https://html.spec.whatwg.org/multipage/forms.html#category-reset
virtual bool is_resettable() const override { return true; }
// https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
virtual bool is_auto_capitalize_inheriting() const override { return true; }
// ^HTMLElement
// https://html.spec.whatwg.org/multipage/forms.html#category-label
virtual bool is_labelable() const override { return true; }
private: private:
// ^DOM::Node // ^DOM::Node
virtual void inserted() override; virtual void inserted() override;

View file

@ -1,5 +1,6 @@
/* /*
* Copyright (c) 2020, the SerenityOS developers. * Copyright (c) 2020, the SerenityOS developers.
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
@ -22,6 +23,23 @@ public:
static String textarea = "textarea"; static String textarea = "textarea";
return textarea; return textarea;
} }
// ^FormAssociatedElement
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
virtual bool is_listed() const override { return true; }
// https://html.spec.whatwg.org/multipage/forms.html#category-submit
virtual bool is_submittable() const override { return true; }
// https://html.spec.whatwg.org/multipage/forms.html#category-reset
virtual bool is_resettable() const override { return true; }
// https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
virtual bool is_auto_capitalize_inheriting() const override { return true; }
// ^HTMLElement
// https://html.spec.whatwg.org/multipage/forms.html#category-label
virtual bool is_labelable() const override { return true; }
}; };
} }