mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:17:35 +00:00
Ladybird+LibWeb+WebContent: Generalize video context menus for all media
The data we want to send out of the WebContent process is identical for audio and video elements. Rather than just duplicating all of this for audio, generalize the names used for this IPC for all media elements. This also encapsulates that data into a struct. This makes adding new fields to be sent much easier (such as an upcoming field for muting the element).
This commit is contained in:
parent
e81abbde7b
commit
14ca04de25
17 changed files with 198 additions and 147 deletions
|
@ -21,6 +21,7 @@
|
|||
#include <LibGfx/Rect.h>
|
||||
#include <LibGfx/Size.h>
|
||||
#include <LibGfx/StandardCursor.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibWeb/CSS/PreferredColorScheme.h>
|
||||
#include <LibWeb/Cookie/Cookie.h>
|
||||
|
@ -120,15 +121,22 @@ public:
|
|||
void dismiss_dialog();
|
||||
void accept_dialog();
|
||||
|
||||
void did_request_video_context_menu(i32 video_id, CSSPixelPoint, AK::URL const&, DeprecatedString const& target, unsigned modifiers, bool is_playing, bool has_user_agent_controls, bool is_looping);
|
||||
WebIDL::ExceptionOr<void> toggle_video_play_state();
|
||||
WebIDL::ExceptionOr<void> toggle_video_loop_state();
|
||||
WebIDL::ExceptionOr<void> toggle_video_controls_state();
|
||||
struct MediaContextMenu {
|
||||
AK::URL media_url;
|
||||
bool is_video { false };
|
||||
bool is_playing { false };
|
||||
bool has_user_agent_controls { false };
|
||||
bool is_looping { false };
|
||||
};
|
||||
void did_request_media_context_menu(i32 media_id, CSSPixelPoint, DeprecatedString const& target, unsigned modifiers, MediaContextMenu);
|
||||
WebIDL::ExceptionOr<void> toggle_media_play_state();
|
||||
WebIDL::ExceptionOr<void> toggle_media_loop_state();
|
||||
WebIDL::ExceptionOr<void> toggle_media_controls_state();
|
||||
|
||||
bool pdf_viewer_supported() const { return m_pdf_viewer_supported; }
|
||||
|
||||
private:
|
||||
JS::GCPtr<HTML::HTMLVideoElement> video_context_menu_element();
|
||||
JS::GCPtr<HTML::HTMLMediaElement> media_context_menu_element();
|
||||
|
||||
PageClient& m_client;
|
||||
|
||||
|
@ -155,7 +163,7 @@ private:
|
|||
Optional<bool> m_pending_confirm_response;
|
||||
Optional<Optional<String>> m_pending_prompt_response;
|
||||
|
||||
Optional<int> m_video_context_menu_element_id;
|
||||
Optional<int> m_media_context_menu_element_id;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/system-state.html#pdf-viewer-supported
|
||||
// Each user agent has a PDF viewer supported boolean, whose value is implementation-defined (and might vary according to user preferences).
|
||||
|
@ -192,7 +200,7 @@ public:
|
|||
virtual void page_did_request_context_menu(CSSPixelPoint) { }
|
||||
virtual void page_did_request_link_context_menu(CSSPixelPoint, AK::URL const&, [[maybe_unused]] DeprecatedString const& target, [[maybe_unused]] unsigned modifiers) { }
|
||||
virtual void page_did_request_image_context_menu(CSSPixelPoint, AK::URL const&, [[maybe_unused]] DeprecatedString const& target, [[maybe_unused]] unsigned modifiers, Gfx::Bitmap const*) { }
|
||||
virtual void page_did_request_video_context_menu(CSSPixelPoint, AK::URL const&, [[maybe_unused]] DeprecatedString const& target, [[maybe_unused]] unsigned modifiers, [[maybe_unused]] bool is_playing, [[maybe_unused]] bool has_user_agent_controls, [[maybe_unused]] bool is_looping) { }
|
||||
virtual void page_did_request_media_context_menu(CSSPixelPoint, [[maybe_unused]] DeprecatedString const& target, [[maybe_unused]] unsigned modifiers, Page::MediaContextMenu) { }
|
||||
virtual void page_did_click_link(const AK::URL&, [[maybe_unused]] DeprecatedString const& target, [[maybe_unused]] unsigned modifiers) { }
|
||||
virtual void page_did_middle_click_link(const AK::URL&, [[maybe_unused]] DeprecatedString const& target, [[maybe_unused]] unsigned modifiers) { }
|
||||
virtual void page_did_enter_tooltip_area(CSSPixelPoint, DeprecatedString const&) { }
|
||||
|
@ -231,3 +239,13 @@ protected:
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
namespace IPC {
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder&, Web::Page::MediaContextMenu const&);
|
||||
|
||||
template<>
|
||||
ErrorOr<Web::Page::MediaContextMenu> decode(Decoder&);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue