diff --git a/Meta/gn/secondary/Userland/Libraries/LibWeb/Layout/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibWeb/Layout/BUILD.gn index ca29ca8ef3d..0d3283e0321 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWeb/Layout/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/Layout/BUILD.gn @@ -12,7 +12,6 @@ source_set("Layout") { "Box.cpp", "BoxModelMetrics.cpp", "BreakNode.cpp", - "ButtonBox.cpp", "CanvasBox.cpp", "CheckBox.cpp", "FlexFormattingContext.cpp", diff --git a/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn index b8fe5999df1..16f953bd6cb 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn @@ -12,7 +12,6 @@ source_set("Painting") { "BorderRadiiData.cpp", "BorderRadiusCornerClipper.cpp", "BordersData.cpp", - "ButtonPaintable.cpp", "CanvasPaintable.cpp", "CheckBoxPaintable.cpp", "ClippableAndScrollable.cpp", diff --git a/Tests/LibWeb/Text/expected/HTML/form-implicit-submission.txt b/Tests/LibWeb/Text/expected/HTML/form-implicit-submission.txt index 0a16d9b3268..71125fe4ac3 100644 --- a/Tests/LibWeb/Text/expected/HTML/form-implicit-submission.txt +++ b/Tests/LibWeb/Text/expected/HTML/form-implicit-submission.txt @@ -1,4 +1,4 @@ - wfh :^) PASS wfh :^) wfh :^) FAIL PASS FAIL wfh :^) FAIL FAIL PASS PASS wfh :^) wfh :^) PASS PASSwfh :^) FAIL wfh :^) FAIL wfh :^) wfh :^) FAIL wfh :^) wfh :^) defaultButton: click button=PASS + wfh :^) PASS wfh :^) PASS wfh :^) FAIL PASS FAIL wfh :^) FAIL FAIL PASS PASS wfh :^) wfh :^) PASS PASSwfh :^) FAIL wfh :^) FAIL wfh :^) wfh :^) FAIL wfh :^) wfh :^) defaultButton: click button=PASS defaultButton: submit defaultButton: handledEvent=true defaultButtonAsInput: click button=PASS diff --git a/Tests/LibWeb/Text/expected/input-value.txt b/Tests/LibWeb/Text/expected/input-value.txt index 9e5b2e23c2c..17d2525c4a4 100644 --- a/Tests/LibWeb/Text/expected/input-value.txt +++ b/Tests/LibWeb/Text/expected/input-value.txt @@ -1,4 +1,4 @@ -pass Select file...No file selected. text: "pass" +pass pass Select file...No file selected. text: "pass" hidden: "pass" button: "pass" checkbox: "pass" diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index a72ef85f302..41a1af0916d 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -471,7 +471,6 @@ set(SOURCES Layout/Box.cpp Layout/BoxModelMetrics.cpp Layout/BreakNode.cpp - Layout/ButtonBox.cpp Layout/CanvasBox.cpp Layout/CheckBox.cpp Layout/FlexFormattingContext.cpp @@ -537,7 +536,6 @@ set(SOURCES Painting/BorderPainting.cpp Painting/BorderRadiusCornerClipper.cpp Painting/BordersData.cpp - Painting/ButtonPaintable.cpp Painting/CanvasPaintable.cpp Painting/Command.cpp Painting/CommandExecutorCPU.cpp diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 88ba3acc5ea..d7e5f12c12e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -27,17 +27,16 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include #include -#include #include #include #include @@ -100,7 +99,7 @@ JS::GCPtr HTMLInputElement::create_layout_node(NonnullRefPtr(document(), *this, move(style)); + return heap().allocate_without_realm(document(), this, move(style)); if (type_state() == TypeAttributeState::ImageButton) return heap().allocate_without_realm(document(), *this, move(style), *this); @@ -740,9 +739,12 @@ void HTMLInputElement::create_shadow_tree_if_needed() case TypeAttributeState::Hidden: case TypeAttributeState::RadioButton: case TypeAttributeState::Checkbox: + break; case TypeAttributeState::Button: case TypeAttributeState::SubmitButton: case TypeAttributeState::ResetButton: + create_button_input_shadow_tree(); + break; case TypeAttributeState::ImageButton: break; case TypeAttributeState::Color: @@ -779,6 +781,15 @@ void HTMLInputElement::update_shadow_tree() } } +void HTMLInputElement::create_button_input_shadow_tree() +{ + auto shadow_root = heap().allocate(realm(), document(), *this, Bindings::ShadowRootMode::Closed); + set_shadow_root(shadow_root); + + m_text_node = heap().allocate(realm(), document(), value()); + MUST(shadow_root->append_child(*m_text_node)); +} + void HTMLInputElement::create_text_input_shadow_tree() { auto shadow_root = heap().allocate(realm(), document(), *this, Bindings::ShadowRootMode::Closed); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index 96bd516ca04..9ae84128f7d 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -243,6 +243,7 @@ private: static TypeAttributeState parse_type_attribute(StringView); void create_shadow_tree_if_needed(); void update_shadow_tree(); + void create_button_input_shadow_tree(); void create_text_input_shadow_tree(); void create_color_input_shadow_tree(); void create_file_input_shadow_tree(); diff --git a/Userland/Libraries/LibWeb/Layout/ButtonBox.cpp b/Userland/Libraries/LibWeb/Layout/ButtonBox.cpp deleted file mode 100644 index 4f6369d001c..00000000000 --- a/Userland/Libraries/LibWeb/Layout/ButtonBox.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020, Andreas Kling - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include -#include -#include -#include - -namespace Web::Layout { - -JS_DEFINE_ALLOCATOR(ButtonBox); - -ButtonBox::ButtonBox(DOM::Document& document, HTML::HTMLInputElement& element, NonnullRefPtr style) - : FormAssociatedLabelableNode(document, element, move(style)) -{ -} - -ButtonBox::~ButtonBox() = default; - -void ButtonBox::prepare_for_replaced_layout() -{ - // For and , the contents of - // the button does not appear as the contents of the element but as the - // value attribute. This is not the case with