mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:37:35 +00:00
LibWeb+LibWebView+WebContent: Implement more <input type=file> behavior
We had previous implemented some plumbing for file input elements in
commit 636602a54e
.
This implements the return path for chromes to inform WebContent of the
file(s) the user selected. This patch includes a dummy implementation
for headless-browser to enable testing.
This commit is contained in:
parent
435c2c24d1
commit
108521a566
23 changed files with 307 additions and 5 deletions
|
@ -18,6 +18,7 @@
|
|||
#include <LibWeb/HTML/HTMLSelectElement.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
||||
#include <LibWeb/HTML/SelectedFile.h>
|
||||
#include <LibWeb/HTML/TraversableNavigable.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Platform/EventLoopPlugin.h>
|
||||
|
@ -343,6 +344,30 @@ void Page::color_picker_update(Optional<Color> picked_color, HTML::ColorPickerUp
|
|||
}
|
||||
}
|
||||
|
||||
void Page::did_request_file_picker(WeakPtr<HTML::HTMLInputElement> target, HTML::AllowMultipleFiles allow_multiple_files)
|
||||
{
|
||||
if (m_pending_non_blocking_dialog == PendingNonBlockingDialog::None) {
|
||||
m_pending_non_blocking_dialog = PendingNonBlockingDialog::FilePicker;
|
||||
m_pending_non_blocking_dialog_target = move(target);
|
||||
|
||||
m_client->page_did_request_file_picker(allow_multiple_files);
|
||||
}
|
||||
}
|
||||
|
||||
void Page::file_picker_closed(Span<HTML::SelectedFile> selected_files)
|
||||
{
|
||||
if (m_pending_non_blocking_dialog == PendingNonBlockingDialog::FilePicker) {
|
||||
m_pending_non_blocking_dialog = PendingNonBlockingDialog::None;
|
||||
|
||||
if (m_pending_non_blocking_dialog_target) {
|
||||
auto& input_element = verify_cast<HTML::HTMLInputElement>(*m_pending_non_blocking_dialog_target);
|
||||
input_element.did_select_files(selected_files);
|
||||
|
||||
m_pending_non_blocking_dialog_target.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Page::did_request_select_dropdown(WeakPtr<HTML::HTMLSelectElement> target, Web::CSSPixelPoint content_position, Web::CSSPixels minimum_width, Vector<Web::HTML::SelectItem> items)
|
||||
{
|
||||
if (m_pending_non_blocking_dialog == PendingNonBlockingDialog::None) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue