mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:07:45 +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
|
@ -250,6 +250,11 @@ void ViewImplementation::color_picker_update(Optional<Color> picked_color, Web::
|
|||
client().async_color_picker_update(page_id(), picked_color, state);
|
||||
}
|
||||
|
||||
void ViewImplementation::file_picker_closed(Vector<Web::HTML::SelectedFile> selected_files)
|
||||
{
|
||||
client().async_file_picker_closed(page_id(), move(selected_files));
|
||||
}
|
||||
|
||||
void ViewImplementation::select_dropdown_closed(Optional<String> value)
|
||||
{
|
||||
client().async_select_dropdown_closed(page_id(), value);
|
||||
|
|
|
@ -86,6 +86,7 @@ public:
|
|||
void confirm_closed(bool accepted);
|
||||
void prompt_closed(Optional<String> response);
|
||||
void color_picker_update(Optional<Color> picked_color, Web::HTML::ColorPickerUpdateState state);
|
||||
void file_picker_closed(Vector<Web::HTML::SelectedFile> selected_files);
|
||||
void select_dropdown_closed(Optional<String> value);
|
||||
|
||||
void toggle_media_play_state();
|
||||
|
@ -164,6 +165,7 @@ public:
|
|||
Function<Gfx::IntRect()> on_minimize_window;
|
||||
Function<Gfx::IntRect()> on_fullscreen_window;
|
||||
Function<void(Color current_color)> on_request_color_picker;
|
||||
Function<void(Web::HTML::AllowMultipleFiles)> on_request_file_picker;
|
||||
Function<void(Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> items)> on_request_select_dropdown;
|
||||
Function<void(bool)> on_finish_handling_input_event;
|
||||
Function<void()> on_text_test_finish;
|
||||
|
|
|
@ -806,6 +806,19 @@ void WebContentClient::did_request_color_picker(u64 page_id, Color const& curren
|
|||
view.on_request_color_picker(current_color);
|
||||
}
|
||||
|
||||
void WebContentClient::did_request_file_picker(u64 page_id, Web::HTML::AllowMultipleFiles allow_multiple_files)
|
||||
{
|
||||
auto maybe_view = m_views.get(page_id);
|
||||
if (!maybe_view.has_value()) {
|
||||
dbgln("Received request file picker for unknown page ID {}", page_id);
|
||||
return;
|
||||
}
|
||||
auto& view = *maybe_view.value();
|
||||
|
||||
if (view.on_request_file_picker)
|
||||
view.on_request_file_picker(allow_multiple_files);
|
||||
}
|
||||
|
||||
void WebContentClient::did_request_select_dropdown(u64 page_id, Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> const& items)
|
||||
{
|
||||
auto maybe_view = m_views.get(page_id);
|
||||
|
|
|
@ -89,6 +89,7 @@ private:
|
|||
virtual Messages::WebContentClient::DidRequestFullscreenWindowResponse did_request_fullscreen_window(u64 page_id) override;
|
||||
virtual void did_request_file(u64 page_id, ByteString const& path, i32) override;
|
||||
virtual void did_request_color_picker(u64 page_id, Color const& current_color) override;
|
||||
virtual void did_request_file_picker(u64 page_id, Web::HTML::AllowMultipleFiles) override;
|
||||
virtual void did_request_select_dropdown(u64 page_id, Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> const& items) override;
|
||||
virtual void did_finish_handling_input_event(u64 page_id, bool event_was_accepted) override;
|
||||
virtual void did_finish_text_test(u64 page_id) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue