From 9c4e80a3eca8329e5fd9e9fe75eac816b5666069 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Wed, 14 Aug 2024 18:45:18 +0100 Subject: [PATCH] LibWeb/SVG: Implement default_tab_index_value for a element Another FIXME bites the dust :^) --- .../Text/expected/HTML/tabIndex-attribute.txt | 12 ++++++ .../Text/input/HTML/tabIndex-attribute.html | 41 +++++++++++++++++++ Userland/Libraries/LibWeb/DOM/Element.cpp | 1 - Userland/Libraries/LibWeb/SVG/SVGAElement.cpp | 7 ++++ Userland/Libraries/LibWeb/SVG/SVGAElement.h | 1 + 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/HTML/tabIndex-attribute.txt create mode 100644 Tests/LibWeb/Text/input/HTML/tabIndex-attribute.html diff --git a/Tests/LibWeb/Text/expected/HTML/tabIndex-attribute.txt b/Tests/LibWeb/Text/expected/HTML/tabIndex-attribute.txt new file mode 100644 index 00000000000..62f01e64956 --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/tabIndex-attribute.txt @@ -0,0 +1,12 @@ +p.tabIndex initial value: -1 +h1.tabIndex initial value: -1 +a.tabIndex initial value: 0 +area.tabIndex initial value: 0 +button.tabIndex initial value: 0 +frame.tabIndex initial value: 0 +iframe.tabIndex initial value: 0 +input.tabIndex initial value: 0 +object.tabIndex initial value: 0 +select.tabIndex initial value: 0 +textarea.tabIndex initial value: 0 +svg.a.tabIndex initial value: 0 diff --git a/Tests/LibWeb/Text/input/HTML/tabIndex-attribute.html b/Tests/LibWeb/Text/input/HTML/tabIndex-attribute.html new file mode 100644 index 00000000000..2a5771ec910 --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/tabIndex-attribute.html @@ -0,0 +1,41 @@ + + + diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index 326957a5ed0..1d53c883e43 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -1184,7 +1184,6 @@ 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; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGAElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGAElement.cpp index f12de94a1a0..33962d19cf7 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGAElement.cpp @@ -43,6 +43,13 @@ void SVGAElement::attribute_changed(FlyString const& name, Optional cons } } +// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex +i32 SVGAElement::default_tab_index_value() const +{ + // See the base function for the spec comments. + return 0; +} + // https://svgwg.org/svg2-draft/linking.html#__svg__SVGAElement__relList JS::NonnullGCPtr SVGAElement::rel_list() { diff --git a/Userland/Libraries/LibWeb/SVG/SVGAElement.h b/Userland/Libraries/LibWeb/SVG/SVGAElement.h index 4aff634a7cc..486f4e206f7 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGAElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGAElement.h @@ -33,6 +33,7 @@ private: // ^DOM::Element virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value) override; + virtual i32 default_tab_index_value() const override; JS::GCPtr m_rel_list; };