mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
LibWeb: Implement HTMLOrSVGElement.tabIndex
This commit is contained in:
parent
6c21c72492
commit
1473bc9169
22 changed files with 119 additions and 0 deletions
|
@ -731,6 +731,32 @@ void Element::serialize_pseudo_elements_as_json(JsonArraySerializer<StringBuilde
|
|||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
i32 Element::default_tab_index_value() const
|
||||
{
|
||||
// The default value is 0 if the element is an a, area, button, frame, iframe, input, object, select, textarea, or SVG a element, or is a summary element that is a summary for its parent details.
|
||||
// The default value is −1 otherwise.
|
||||
// Note: The varying default value based on element type is a historical artifact.
|
||||
// FIXME: We currently do not have the SVG a element.
|
||||
return -1;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
i32 Element::tab_index() const
|
||||
{
|
||||
// FIXME: I'm not sure if "to_int" exactly matches the specs "rules for parsing integers"
|
||||
auto maybe_table_index = attribute(HTML::AttributeNames::tabindex).to_int<i32>();
|
||||
if (!maybe_table_index.has_value())
|
||||
return default_tab_index_value();
|
||||
return maybe_table_index.value();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
void Element::set_tab_index(i32 tab_index)
|
||||
{
|
||||
MUST(set_attribute(HTML::AttributeNames::tabindex, String::number(tab_index)));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics-other.html#concept-element-disabled
|
||||
bool Element::is_actually_disabled() const
|
||||
{
|
||||
|
|
|
@ -154,6 +154,9 @@ public:
|
|||
void clear_pseudo_element_nodes(Badge<Layout::TreeBuilder>);
|
||||
void serialize_pseudo_elements_as_json(JsonArraySerializer<StringBuilder>& children_array) const;
|
||||
|
||||
i32 tab_index() const;
|
||||
void set_tab_index(i32 tab_index);
|
||||
|
||||
bool is_actually_disabled() const;
|
||||
|
||||
WebIDL::ExceptionOr<JS::GCPtr<Element>> insert_adjacent_element(String const& where, JS::NonnullGCPtr<Element> element);
|
||||
|
@ -167,6 +170,7 @@ protected:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
virtual void children_changed() override;
|
||||
virtual i32 default_tab_index_value() const;
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace AttributeNames {
|
|||
__ENUMERATE_HTML_ATTRIBUTE(alt) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(archive) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(async) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(autofocus) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(autoplay) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(axis) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(background) \
|
||||
|
@ -208,6 +209,7 @@ namespace AttributeNames {
|
|||
__ENUMERATE_HTML_ATTRIBUTE(step) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(style) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(summary) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(tabindex) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(target) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(text) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(title) \
|
||||
|
|
|
@ -77,4 +77,11 @@ void HTMLAnchorElement::run_activation_behavior(Web::DOM::Event const&)
|
|||
follow_the_hyperlink(hyperlink_suffix);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
i32 HTMLAnchorElement::default_tab_index_value() const
|
||||
{
|
||||
// See the base function for the spec comments.
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ private:
|
|||
|
||||
// ^DOM::Element
|
||||
virtual void parse_attribute(FlyString const& name, String const& value) override;
|
||||
virtual i32 default_tab_index_value() const override;
|
||||
|
||||
// ^HTML::HTMLHyperlinkElementUtils
|
||||
virtual DOM::Document& hyperlink_element_utils_document() override { return document(); }
|
||||
|
|
|
@ -35,4 +35,11 @@ void HTMLAreaElement::set_hyperlink_element_utils_href(String href)
|
|||
MUST(set_attribute(HTML::AttributeNames::href, move(href)));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
i32 HTMLAreaElement::default_tab_index_value() const
|
||||
{
|
||||
// See the base function for the spec comments.
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ private:
|
|||
|
||||
// ^DOM::Element
|
||||
virtual void parse_attribute(FlyString const& name, String const& value) override;
|
||||
virtual i32 default_tab_index_value() const override;
|
||||
|
||||
// ^HTML::HTMLHyperlinkElementUtils
|
||||
virtual DOM::Document& hyperlink_element_utils_document() override { return document(); }
|
||||
|
|
|
@ -86,4 +86,11 @@ void HTMLButtonElement::set_type(String const& type)
|
|||
MUST(set_attribute(HTML::AttributeNames::type, type));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
i32 HTMLButtonElement::default_tab_index_value() const
|
||||
{
|
||||
// See the base function for the spec comments.
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,9 @@ public:
|
|||
|
||||
private:
|
||||
HTMLButtonElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
// ^DOM::Element
|
||||
virtual i32 default_tab_index_value() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -32,4 +32,6 @@ HTMLElement includes HTMLOrSVGElement;
|
|||
|
||||
interface mixin HTMLOrSVGElement {
|
||||
[SameObject] readonly attribute DOMStringMap dataset;
|
||||
|
||||
[CEReactions] attribute long tabIndex;
|
||||
};
|
||||
|
|
|
@ -16,4 +16,12 @@ HTMLFrameElement::HTMLFrameElement(DOM::Document& document, DOM::QualifiedName q
|
|||
}
|
||||
|
||||
HTMLFrameElement::~HTMLFrameElement() = default;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
i32 HTMLFrameElement::default_tab_index_value() const
|
||||
{
|
||||
// See the base function for the spec comments.
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ public:
|
|||
|
||||
private:
|
||||
HTMLFrameElement(DOM::Document&, DOM::QualifiedName);
|
||||
// ^DOM::Element
|
||||
virtual i32 default_tab_index_value() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -164,4 +164,11 @@ void run_iframe_load_event_steps(HTML::HTMLIFrameElement& element)
|
|||
// FIXME: 6. Unset childDocument's iframe load in progress flag.
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
i32 HTMLIFrameElement::default_tab_index_value() const
|
||||
{
|
||||
// See the base function for the spec comments.
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,9 +28,11 @@ public:
|
|||
private:
|
||||
HTMLIFrameElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
// ^DOM::Element
|
||||
virtual void inserted() override;
|
||||
virtual void removed_from(Node*) override;
|
||||
virtual void parse_attribute(FlyString const& name, String const& value) override;
|
||||
virtual i32 default_tab_index_value() const override;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/iframe-embed-object.html#process-the-iframe-attributes
|
||||
void process_the_iframe_attributes(bool initial_insertion = false);
|
||||
|
|
|
@ -555,4 +555,11 @@ void HTMLInputElement::legacy_cancelled_activation_behavior_was_not_called()
|
|||
m_legacy_pre_activation_behavior_checked_element_in_group = nullptr;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
i32 HTMLInputElement::default_tab_index_value() const
|
||||
{
|
||||
// See the base function for the spec comments.
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -123,6 +123,9 @@ private:
|
|||
virtual void legacy_cancelled_activation_behavior() override;
|
||||
virtual void legacy_cancelled_activation_behavior_was_not_called() override;
|
||||
|
||||
// ^DOM::Element
|
||||
virtual i32 default_tab_index_value() const override;
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
static TypeAttributeState parse_type_attribute(StringView);
|
||||
|
|
|
@ -316,4 +316,11 @@ void HTMLObjectElement::update_layout_and_child_objects(Representation represent
|
|||
document().set_needs_layout();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
i32 HTMLObjectElement::default_tab_index_value() const
|
||||
{
|
||||
// See the base function for the spec comments.
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -62,6 +62,9 @@ private:
|
|||
virtual void resource_did_load() override;
|
||||
virtual void resource_did_fail() override;
|
||||
|
||||
// ^DOM::Element
|
||||
virtual i32 default_tab_index_value() const override;
|
||||
|
||||
Representation m_representation { Representation::Unknown };
|
||||
Optional<ImageLoader> m_image_loader;
|
||||
};
|
||||
|
|
|
@ -122,4 +122,11 @@ void HTMLSelectElement::set_selected_index(int index)
|
|||
selected_option->m_dirty = true;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
i32 HTMLSelectElement::default_tab_index_value() const
|
||||
{
|
||||
// See the base function for the spec comments.
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,6 +61,9 @@ private:
|
|||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
// ^DOM::Element
|
||||
virtual i32 default_tab_index_value() const override;
|
||||
|
||||
JS::GCPtr<HTMLOptionsCollection> m_options;
|
||||
};
|
||||
|
||||
|
|
|
@ -17,4 +17,11 @@ HTMLTextAreaElement::HTMLTextAreaElement(DOM::Document& document, DOM::Qualified
|
|||
|
||||
HTMLTextAreaElement::~HTMLTextAreaElement() = default;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
i32 HTMLTextAreaElement::default_tab_index_value() const
|
||||
{
|
||||
// See the base function for the spec comments.
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,6 +50,9 @@ public:
|
|||
|
||||
private:
|
||||
HTMLTextAreaElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
// ^DOM::Element
|
||||
virtual i32 default_tab_index_value() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue