Selaa lähdekoodia

LibWeb: Move input size attr width from css to create_layout_node

Bastiaan van der Plaat 1 vuosi sitten
vanhempi
commit
7e76358a99

+ 1 - 1
Tests/LibWeb/Text/expected/HTML/form-image-submission.txt

@@ -1 +1 @@
-   10,20
+   56,20

+ 0 - 1
Userland/Libraries/LibWeb/CSS/Default.css

@@ -29,7 +29,6 @@ label {
 input:not([type=submit], input[type=button], input[type=image], input[type=reset], input[type=color], input[type=checkbox], input[type=file], input[type=radio], input[type=range]), textarea {
     border: 1px solid ButtonBorder;
     min-height: 16px;
-    width: attr(size ch, 20ch);
     cursor: text;
     overflow: hidden;
 }

+ 6 - 0
Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp

@@ -12,6 +12,7 @@
 #include <LibJS/Runtime/NativeFunction.h>
 #include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
 #include <LibWeb/CSS/StyleValues/IdentifierStyleValue.h>
+#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
 #include <LibWeb/DOM/Document.h>
 #include <LibWeb/DOM/ElementFactory.h>
 #include <LibWeb/DOM/Event.h>
@@ -101,6 +102,11 @@ JS::GCPtr<Layout::Node> HTMLInputElement::create_layout_node(NonnullRefPtr<CSS::
     if (style->display().is_inline_outside() && style->display().is_flow_inside())
         style->set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::InlineBlock)));
 
+    if (type_state() != TypeAttributeState::FileUpload) {
+        if (style->property(CSS::PropertyID::Width)->has_auto())
+            style->set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length(size(), CSS::Length::Type::Ch)));
+    }
+
     return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
 }