1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-29 01:42:11 +00:00

LibWeb: Start implementing <input type=text> using a shadow DOM

Text <input> fields will now generate a basic shadow DOM and attach it
to the input element.

The shadow DOM contains a <div> with some inline style, and an always-
editable text node inside it. Accessing the "value" attribute on such
an input element will get/set the value from that text node.

This is really cool, although not super stable since HTML editing is
not super stable. But it's a start! :^)
This commit is contained in:
Andreas Kling 2021-02-10 18:26:07 +01:00
parent e4e325ff61
commit 29a2aac89a
4 changed files with 58 additions and 3 deletions

View file

@ -40,9 +40,12 @@ public:
virtual RefPtr<Layout::Node> create_layout_node() override;
String type() const { return attribute(HTML::AttributeNames::type); }
String value() const { return attribute(HTML::AttributeNames::value); }
String default_value() const { return attribute(HTML::AttributeNames::value); }
String name() const { return attribute(HTML::AttributeNames::name); }
String value() const;
void set_value(String);
bool checked() const { return m_checked; }
void set_checked(bool);
@ -51,6 +54,9 @@ public:
void did_click_button(Badge<Layout::ButtonBox>);
private:
void create_shadow_tree_if_needed();
RefPtr<DOM::Text> m_text_node;
bool m_checked { false };
};