mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 18:15:07 +00:00
LibHTML: Implement basic <form> and <input> element support
This patch adds "submit" inputs and default (text box) inputs, as well as form elements that can be submitted. Layout of input elements is implemented via a new LayoutWidget class that allows you to put an arbitrary GWidget in the layout tree. At the moment, the DOM node sets the initial size of the LayoutWidget, and then the positioning is done by the normal layout algorithm. We also now support submitting a <form method="GET">, which does a full replacing load with a URL based on the form's action + a query string built from the name/value of input elements within the submitted form. This is pretty neat! :^)
This commit is contained in:
parent
a91c17c0eb
commit
6d1c4ae5a9
11 changed files with 229 additions and 0 deletions
21
Libraries/LibHTML/DOM/HTMLInputElement.h
Normal file
21
Libraries/LibHTML/DOM/HTMLInputElement.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibHTML/DOM/HTMLElement.h>
|
||||
|
||||
class HTMLInputElement : public HTMLElement {
|
||||
public:
|
||||
HTMLInputElement(Document&, const String& tag_name);
|
||||
virtual ~HTMLInputElement() override;
|
||||
|
||||
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) const override;
|
||||
|
||||
String type() const { return attribute("type"); }
|
||||
String value() const { return attribute("value"); }
|
||||
String name() const { return attribute("name"); }
|
||||
};
|
||||
|
||||
template<>
|
||||
inline bool is<HTMLInputElement>(const Node& node)
|
||||
{
|
||||
return is<Element>(node) && to<Element>(node).tag_name().to_lowercase() == "input";
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue