mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:57:35 +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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue