diff --git a/Tests/LibWeb/Text/expected/HTML/form-image-submission.txt b/Tests/LibWeb/Text/expected/HTML/form-image-submission.txt
index dc5af2eb605ad2dcdbd688f3cdccc4c878031a72..5feee74756a504985c19b7f0f0d3866f750e5bc0 100644
--- a/Tests/LibWeb/Text/expected/HTML/form-image-submission.txt
+++ b/Tests/LibWeb/Text/expected/HTML/form-image-submission.txt
@@ -1 +1 @@
- 56,20
+ 10,20
diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
index c0288aa1bc2d12f0f9a232a964c1233256c6d2c5..4942f76400e9f0d13aec3d2091966463bf0ee2b2 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
@@ -2250,6 +2250,9 @@ RefPtr StyleComputer::compute_style_impl(DOM::Element& element,
// 7. Resolve effective overflow values
resolve_effective_overflow_values(style);
+ // 8. Let the element adjust computed style
+ element.adjust_computed_style(style);
+
return style;
}
diff --git a/Userland/Libraries/LibWeb/DOM/Element.h b/Userland/Libraries/LibWeb/DOM/Element.h
index d1b62b5003488d99471b312b4fe56a6e93f67c27..884e6c700199b01e28da855599501271e069ede0 100644
--- a/Userland/Libraries/LibWeb/DOM/Element.h
+++ b/Userland/Libraries/LibWeb/DOM/Element.h
@@ -212,6 +212,7 @@ public:
JS::NonnullGCPtr get_client_rects() const;
virtual JS::GCPtr create_layout_node(NonnullRefPtr);
+ virtual void adjust_computed_style(CSS::StyleProperties&) { }
virtual void did_receive_focus() { }
virtual void did_lose_focus() { }
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
index f2dd03203c5d124daba1fddeec6f7477aabcb276..be5db5361e58a8a12654f0e5d7f21d852c0cf981 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp
@@ -97,17 +97,23 @@ JS::GCPtr HTMLInputElement::create_layout_node(NonnullRefPtr(document(), *this, move(style));
+ return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
+}
+
+void HTMLInputElement::adjust_computed_style(CSS::StyleProperties& style)
+{
+ if (type_state() == TypeAttributeState::Hidden || type_state() == TypeAttributeState::SubmitButton || type_state() == TypeAttributeState::Button || type_state() == TypeAttributeState::ResetButton || type_state() == TypeAttributeState::ImageButton || type_state() == TypeAttributeState::Checkbox || type_state() == TypeAttributeState::RadioButton)
+ return;
+
// AD-HOC: We rewrite `display: inline` to `display: inline-block`.
// This is required for the internal shadow tree to work correctly in layout.
- 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 (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)));
+ 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);
}
void HTMLInputElement::set_checked(bool checked, ChangeSource change_source)
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h
index 0f87ecbfc94f96c4e16462946e13317115bee397..c7bf365b3b0ae2419b89dc842540b1661e72fe0a 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h
@@ -58,6 +58,7 @@ public:
virtual ~HTMLInputElement() override;
virtual JS::GCPtr create_layout_node(NonnullRefPtr) override;
+ virtual void adjust_computed_style(CSS::StyleProperties&) override;
enum class TypeAttributeState {
#define __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(_, state) state,
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
index c64d5265c21c97f64d7762e3f4ceb31df5c615f7..4bc8958cf21f0d55f7f371dbae2d8ea73f7fdb1b 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.cpp
@@ -48,14 +48,12 @@ void HTMLSelectElement::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_chevron_icon_element);
}
-JS::GCPtr HTMLSelectElement::create_layout_node(NonnullRefPtr style)
+void HTMLSelectElement::adjust_computed_style(CSS::StyleProperties& style)
{
// AD-HOC: We rewrite `display: inline` to `display: inline-block`.
// This is required for the internal shadow tree to work correctly in layout.
- 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)));
-
- return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
+ 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)));
}
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-select-options
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h
index ecdbe9e37ffc979f6642b9c1f2dd89f8177a363d..b1e4805600fcffbaed8ea9b93e2842486b7c583c 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLSelectElement.h
@@ -25,7 +25,7 @@ class HTMLSelectElement final
public:
virtual ~HTMLSelectElement() override;
- virtual JS::GCPtr create_layout_node(NonnullRefPtr) override;
+ virtual void adjust_computed_style(CSS::StyleProperties&) override;
JS::GCPtr const& options();
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp
index 4e15f7b2eb10a4b3f9326cd6f124c44264692453..680073b435f732f533dbb7ce25ad13e899ce37da 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp
@@ -31,19 +31,17 @@ HTMLTextAreaElement::HTMLTextAreaElement(DOM::Document& document, DOM::Qualified
HTMLTextAreaElement::~HTMLTextAreaElement() = default;
-JS::GCPtr HTMLTextAreaElement::create_layout_node(NonnullRefPtr style)
+void HTMLTextAreaElement::adjust_computed_style(CSS::StyleProperties& style)
{
// AD-HOC: We rewrite `display: inline` to `display: inline-block`.
// This is required for the internal shadow tree to work correctly in layout.
- 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 (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 (style->property(CSS::PropertyID::Width)->has_auto())
- style->set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length(cols(), CSS::Length::Type::Ch)));
- if (style->property(CSS::PropertyID::Height)->has_auto())
- style->set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length(rows(), CSS::Length::Type::Lh)));
-
- return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
+ if (style.property(CSS::PropertyID::Width)->has_auto())
+ style.set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length(cols(), CSS::Length::Type::Ch)));
+ if (style.property(CSS::PropertyID::Height)->has_auto())
+ style.set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length(rows(), CSS::Length::Type::Lh)));
}
void HTMLTextAreaElement::initialize(JS::Realm& realm)
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h
index c13475168c93b758052827e4c3f1d6629c7ff9b8..6fe152e2d2ccdaf8d38731dc978994b63e667aaf 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h
@@ -28,7 +28,7 @@ class HTMLTextAreaElement final
public:
virtual ~HTMLTextAreaElement() override;
- virtual JS::GCPtr create_layout_node(NonnullRefPtr) override;
+ virtual void adjust_computed_style(CSS::StyleProperties&) override;
String const& type() const
{