From 88173648e3f2a7f772fdfbaa8643fa02ce0fed50 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 14 Mar 2022 20:23:18 +0100 Subject: [PATCH] LibWeb: Create HTMLInputElement UA shadow tree when inserted into DOM Previously, we were creating a user-agent shadow tree when constructing a layout tree. This meant that we did DOM manipulation (and consequently style invalidation) during layout tree construction, which made things very hard to reason about in Layout::TreeBuilder. Simply everything by simply creating the UA shadow tree when the input element inserted into a parent node instead. --- Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp | 6 +++++- Userland/Libraries/LibWeb/HTML/HTMLInputElement.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index cf7bd2c407d..27066a9544c 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -64,7 +64,6 @@ RefPtr HTMLInputElement::create_layout_node(NonnullRefPtrset_inline(true); return layout_node; @@ -284,4 +283,9 @@ String HTMLInputElement::value_sanitization_algorithm(String value) const return value; } +void HTMLInputElement::inserted() +{ + create_shadow_tree_if_needed(); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index 7d5e6b2ec1b..1bad7acd934 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -100,6 +100,8 @@ public: // https://html.spec.whatwg.org/multipage/forms.html#category-label virtual bool is_labelable() const override { return type_state() != TypeAttributeState::Hidden; } + virtual void inserted() override; + private: // ^DOM::EventTarget virtual void did_receive_focus() override;