summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h
diff options
context:
space:
mode:
authorAndrew Kaster <akaster@serenityos.org>2022-10-03 23:39:53 -0600
committerAndreas Kling <kling@serenityos.org>2022-10-04 22:05:14 +0200
commit636602a54e55945f7394805975a69dc40934331c (patch)
tree7c44e0bcf68c84175d18682cb722fbe4c56b13f7 /Userland/Libraries/LibWeb/HTML/HTMLInputElement.h
parentffab9fb44ed0cff0d895d0e21e52e53d85f742e5 (diff)
downloadserenity-636602a54e55945f7394805975a69dc40934331c.zip
LibWeb: Implement <input type=file> behavior
This includes punting on the actual file picker implementation all the way out to the PageClient. It's likely that some of the real details should be implemented somewhere closer, like the BrowsingContext or the Page, but we'll get there. For now, this allows https://copy.sh/v86 to load the emulation of the preselected images all the way until it hits a call to URL.createObjectURL.
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/HTMLInputElement.h')
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLInputElement.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h
index bc85bb3137..b04c6ef58c 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h
@@ -7,8 +7,10 @@
#pragma once
+#include <LibWeb/FileAPI/FileList.h>
#include <LibWeb/HTML/FormAssociatedElement.h>
#include <LibWeb/HTML/HTMLElement.h>
+#include <LibWeb/WebIDL/DOMException.h>
namespace Web::HTML {
@@ -62,7 +64,7 @@ public:
String name() const { return attribute(HTML::AttributeNames::name); }
String value() const;
- void set_value(String);
+ WebIDL::ExceptionOr<void> set_value(String);
bool checked() const { return m_checked; }
enum class ChangeSource {
@@ -76,6 +78,15 @@ public:
void did_edit_text_node(Badge<BrowsingContext>);
+ JS::GCPtr<FileAPI::FileList> files();
+ void set_files(JS::GCPtr<FileAPI::FileList>);
+
+ // NOTE: User interaction
+ // https://html.spec.whatwg.org/multipage/input.html#update-the-file-selection
+ void update_the_file_selection(JS::NonnullGCPtr<FileAPI::FileList>);
+
+ WebIDL::ExceptionOr<void> show_picker();
+
// ^EventTarget
// https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-input-element
virtual bool is_focusable() const override { return m_type != TypeAttributeState::Hidden; }
@@ -135,6 +146,9 @@ private:
bool m_before_legacy_pre_activation_behavior_checked { false };
JS::GCPtr<HTMLInputElement> m_legacy_pre_activation_behavior_checked_element_in_group;
+ // https://html.spec.whatwg.org/multipage/input.html#concept-input-type-file-selected
+ JS::GCPtr<FileAPI::FileList> m_selected_files;
+
TypeAttributeState m_type { TypeAttributeState::Text };
String m_value;
};