浏览代码

LibWeb: Don't create HTMLInputElement's UA shadow tree for buttons

We don't need an internal editable text node inside buttons. :^)
Andreas Kling 3 年之前
父节点
当前提交
06ccc45157
共有 1 个文件被更改,包括 13 次插入1 次删除
  1. 13 1
      Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp

+ 13 - 1
Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp

@@ -159,7 +159,19 @@ void HTMLInputElement::create_shadow_tree_if_needed()
     if (shadow_root())
     if (shadow_root())
         return;
         return;
 
 
-    // FIXME: This assumes that we want a text box. Is that always true?
+    // FIXME: This could be better factored. Everything except the below types becomes a text input.
+    switch (type_state()) {
+    case TypeAttributeState::RadioButton:
+    case TypeAttributeState::Checkbox:
+    case TypeAttributeState::Button:
+    case TypeAttributeState::SubmitButton:
+    case TypeAttributeState::ResetButton:
+    case TypeAttributeState::ImageButton:
+        return;
+    default:
+        break;
+    }
+
     auto shadow_root = adopt_ref(*new DOM::ShadowRoot(document(), *this));
     auto shadow_root = adopt_ref(*new DOM::ShadowRoot(document(), *this));
     auto initial_value = attribute(HTML::AttributeNames::value);
     auto initial_value = attribute(HTML::AttributeNames::value);
     if (initial_value.is_null())
     if (initial_value.is_null())