mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-01 08:48:49 +00:00
LibWeb: Add basic support for <input type=checkbox>
This is implemented entirely inside LibWeb, there is no GUI::CheckBox widget instantiated, unlike other input types. All input types should be moved to this new style of implementation.
This commit is contained in:
parent
d6889ecf35
commit
f2431adf47
Notes:
sideshowbarker
2024-07-19 02:45:51 +09:00
Author: https://github.com/awesomekling
Commit: f2431adf47
7 changed files with 195 additions and 1 deletions
|
@ -30,9 +30,10 @@
|
|||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/HTML/HTMLFormElement.h>
|
||||
#include <LibWeb/HTML/HTMLInputElement.h>
|
||||
#include <LibWeb/InProcessWebView.h>
|
||||
#include <LibWeb/Layout/LayoutCheckBox.h>
|
||||
#include <LibWeb/Layout/LayoutWidget.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/InProcessWebView.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -78,6 +79,8 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const CSS::StyleProperti
|
|||
const_cast<HTMLInputElement*>(this)->dispatch_event(DOM::Event::create("click"));
|
||||
};
|
||||
widget = button;
|
||||
} else if (type() == "checkbox") {
|
||||
return adopt(*new LayoutCheckBox(document(), *this, move(style)));
|
||||
} else {
|
||||
auto& text_box = page_view.add<GUI::TextBox>();
|
||||
text_box.set_text(value());
|
||||
|
@ -99,4 +102,18 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const CSS::StyleProperti
|
|||
return adopt(*new LayoutWidget(document(), *this, *widget));
|
||||
}
|
||||
|
||||
void HTMLInputElement::set_checked(bool checked)
|
||||
{
|
||||
if (m_checked == checked)
|
||||
return;
|
||||
m_checked = checked;
|
||||
if (layout_node())
|
||||
layout_node()->set_needs_display();
|
||||
}
|
||||
|
||||
bool HTMLInputElement::enabled() const
|
||||
{
|
||||
return !has_attribute(HTML::AttributeNames::disabled);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue