LibWeb: Stub out an "open" state on <select> elements

The CSS Selectors-4 spec suggests that `:open` and `:closed` should
apply to `<select>` elements, so let's add a way of storing and
exposing that state. We don't yet actually generate any layout for
`<select>` elements, so they will always report that they are closed.
This commit is contained in:
Sam Atkins 2023-09-13 17:15:27 +01:00 committed by Andreas Kling
parent b1632c58bf
commit 29bb0f0ae6
Notes: sideshowbarker 2024-07-17 09:37:30 +09:00
2 changed files with 13 additions and 0 deletions

View file

@ -175,4 +175,13 @@ Optional<ARIA::Role> HTMLSelectElement::default_role() const
return ARIA::Role::combobox;
}
void HTMLSelectElement::set_is_open(bool open)
{
if (open == m_is_open)
return;
m_is_open = open;
invalidate_style();
}
}

View file

@ -33,6 +33,9 @@ public:
int selected_index() const;
void set_selected_index(int);
bool is_open() const { return m_is_open; }
void set_is_open(bool);
Vector<JS::Handle<HTMLOptionElement>> list_of_options() const;
// ^EventTarget
@ -72,6 +75,7 @@ private:
virtual i32 default_tab_index_value() const override;
JS::GCPtr<HTMLOptionsCollection> m_options;
bool m_is_open { false };
};
}