mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 09:07:44 +00:00
LibWeb+LibWebView+WebContent: Add support for <input type="color">
This commit introduces 3 things: - Support for the color type in HTMLInputElement itself - A mechanism for handling non event loop blocking dialogs in Page - The associated plumbing up to ViewImplementation Frontends may add support for the color picker with the ViewImplementation.on_request_color_picker function
This commit is contained in:
parent
759ad905de
commit
2995a2e212
14 changed files with 110 additions and 4 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
||||
#include <LibWeb/HTML/HTMLInputElement.h>
|
||||
#include <LibWeb/HTML/HTMLMediaElement.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
||||
|
@ -286,6 +287,28 @@ void Page::accept_dialog()
|
|||
}
|
||||
}
|
||||
|
||||
void Page::did_request_color_picker(WeakPtr<HTML::HTMLInputElement> target, Color current_color)
|
||||
{
|
||||
if (m_pending_non_blocking_dialog == PendingNonBlockingDialog::None) {
|
||||
m_pending_non_blocking_dialog = PendingNonBlockingDialog::ColorPicker;
|
||||
m_pending_non_blocking_dialog_target = move(target);
|
||||
|
||||
m_client.page_did_request_color_picker(current_color);
|
||||
}
|
||||
}
|
||||
|
||||
void Page::color_picker_closed(Optional<Color> picked_color)
|
||||
{
|
||||
if (m_pending_non_blocking_dialog == PendingNonBlockingDialog::ColorPicker) {
|
||||
m_pending_non_blocking_dialog = PendingNonBlockingDialog::None;
|
||||
|
||||
if (m_pending_non_blocking_dialog_target) {
|
||||
m_pending_non_blocking_dialog_target->did_pick_color(picked_color);
|
||||
m_pending_non_blocking_dialog_target.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Page::did_request_media_context_menu(i32 media_id, CSSPixelPoint position, DeprecatedString const& target, unsigned modifiers, MediaContextMenu menu)
|
||||
{
|
||||
m_media_context_menu_element_id = media_id;
|
||||
|
|
|
@ -120,6 +120,14 @@ public:
|
|||
void dismiss_dialog();
|
||||
void accept_dialog();
|
||||
|
||||
void did_request_color_picker(WeakPtr<HTML::HTMLInputElement> target, Color current_color);
|
||||
void color_picker_closed(Optional<Color> picked_color);
|
||||
|
||||
enum class PendingNonBlockingDialog {
|
||||
None,
|
||||
ColorPicker,
|
||||
};
|
||||
|
||||
struct MediaContextMenu {
|
||||
AK::URL media_url;
|
||||
bool is_video { false };
|
||||
|
@ -168,6 +176,9 @@ private:
|
|||
Optional<bool> m_pending_confirm_response;
|
||||
Optional<Optional<String>> m_pending_prompt_response;
|
||||
|
||||
PendingNonBlockingDialog m_pending_non_blocking_dialog { PendingNonBlockingDialog::None };
|
||||
WeakPtr<HTML::HTMLInputElement> m_pending_non_blocking_dialog_target;
|
||||
|
||||
Optional<int> m_media_context_menu_element_id;
|
||||
|
||||
Optional<String> m_user_style_sheet_source;
|
||||
|
@ -241,6 +252,7 @@ public:
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#show-the-picker,-if-applicable
|
||||
virtual void page_did_request_file_picker(WeakPtr<DOM::EventTarget>, [[maybe_unused]] bool multiple) {};
|
||||
virtual void page_did_request_color_picker([[maybe_unused]] Color current_color) {};
|
||||
|
||||
virtual void page_did_finish_text_test() {};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue