mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
LibWeb: Add Fullscreen API event handlers to IDL
This commit adds the event handlers for fullscreen API to Document and Element. This also adds an extremely light-weight (and stupid) policy check which is required by the fullscreen api. However, policy permission checks are not implemented yet.
This commit is contained in:
parent
65b23d9e43
commit
7a370b7ab4
6 changed files with 75 additions and 0 deletions
|
@ -4387,6 +4387,9 @@ bool Document::is_allowed_to_use_feature(PolicyControlledFeature feature) const
|
|||
case PolicyControlledFeature::FocusWithoutUserActivation:
|
||||
// FIXME: Implement allowlist for this.
|
||||
return true;
|
||||
case PolicyControlledFeature::Fullscreen:
|
||||
// FIXME: Implement the permissions policy specification
|
||||
return true;
|
||||
}
|
||||
|
||||
// 4. Return false.
|
||||
|
@ -6246,6 +6249,26 @@ void Document::append_pending_fullscreen_change(PendingFullscreenEvent::Type typ
|
|||
m_pending_fullscreen_events.append(PendingFullscreenEvent { type, element });
|
||||
}
|
||||
|
||||
WebIDL::CallbackType* Document::onfullscreenchange()
|
||||
{
|
||||
return event_handler_attribute(HTML::EventNames::fullscreenchange);
|
||||
}
|
||||
|
||||
void Document::set_onfullscreenchange(WebIDL::CallbackType* value)
|
||||
{
|
||||
set_event_handler_attribute(HTML::EventNames::fullscreenchange, value);
|
||||
}
|
||||
|
||||
WebIDL::CallbackType* Document::onfullscreenerror()
|
||||
{
|
||||
return event_handler_attribute(HTML::EventNames::fullscreenerror);
|
||||
}
|
||||
|
||||
void Document::set_onfullscreenerror(WebIDL::CallbackType* value)
|
||||
{
|
||||
set_event_handler_attribute(HTML::EventNames::fullscreenerror, value);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#document-allow-declarative-shadow-roots
|
||||
void Document::set_allow_declarative_shadow_roots(bool allow)
|
||||
{
|
||||
|
|
|
@ -154,6 +154,7 @@ struct ElementCreationOptions {
|
|||
enum class PolicyControlledFeature : u8 {
|
||||
Autoplay,
|
||||
FocusWithoutUserActivation,
|
||||
Fullscreen,
|
||||
};
|
||||
|
||||
struct PendingFullscreenEvent {
|
||||
|
@ -908,6 +909,12 @@ public:
|
|||
void run_fullscreen_steps();
|
||||
void append_pending_fullscreen_change(PendingFullscreenEvent::Type type, GC::Ref<Element> element);
|
||||
|
||||
// https://fullscreen.spec.whatwg.org/#api
|
||||
[[nodiscard]] WebIDL::CallbackType* onfullscreenchange();
|
||||
void set_onfullscreenchange(WebIDL::CallbackType*);
|
||||
[[nodiscard]] WebIDL::CallbackType* onfullscreenerror();
|
||||
void set_onfullscreenerror(WebIDL::CallbackType*);
|
||||
|
||||
protected:
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
|
|
@ -156,6 +156,10 @@ interface Document : Node {
|
|||
// special event handler IDL attributes that only apply to Document objects
|
||||
[LegacyLenientThis] attribute EventHandler onreadystatechange;
|
||||
attribute EventHandler onvisibilitychange;
|
||||
|
||||
// https://fullscreen.spec.whatwg.org/#api
|
||||
attribute EventHandler onfullscreenchange;
|
||||
attribute EventHandler onfullscreenerror;
|
||||
};
|
||||
|
||||
dictionary ElementCreationOptions {
|
||||
|
|
|
@ -1905,6 +1905,26 @@ WebIDL::ExceptionOr<void> Element::insert_adjacent_html(String const& position,
|
|||
return {};
|
||||
}
|
||||
|
||||
GC::Ptr<WebIDL::CallbackType> Element::onfullscreenchange()
|
||||
{
|
||||
return event_handler_attribute(HTML::EventNames::fullscreenchange);
|
||||
}
|
||||
|
||||
void Element::set_onfullscreenchange(GC::Ptr<WebIDL::CallbackType> event_handler)
|
||||
{
|
||||
set_event_handler_attribute(HTML::EventNames::fullscreenchange, event_handler);
|
||||
}
|
||||
|
||||
GC::Ptr<WebIDL::CallbackType> Element::onfullscreenerror()
|
||||
{
|
||||
return event_handler_attribute(HTML::EventNames::fullscreenerror);
|
||||
}
|
||||
|
||||
void Element::set_onfullscreenerror(GC::Ptr<WebIDL::CallbackType> event_handler)
|
||||
{
|
||||
set_event_handler_attribute(HTML::EventNames::fullscreenerror, event_handler);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#insert-adjacent
|
||||
WebIDL::ExceptionOr<GC::Ptr<Node>> Element::insert_adjacent(StringView where, GC::Ref<Node> node)
|
||||
{
|
||||
|
|
|
@ -232,6 +232,12 @@ public:
|
|||
|
||||
WebIDL::ExceptionOr<void> insert_adjacent_html(String const& position, String const&);
|
||||
|
||||
GC::Ptr<WebIDL::CallbackType> onfullscreenchange();
|
||||
void set_onfullscreenchange(GC::Ptr<WebIDL::CallbackType>);
|
||||
|
||||
GC::Ptr<WebIDL::CallbackType> onfullscreenerror();
|
||||
void set_onfullscreenerror(GC::Ptr<WebIDL::CallbackType>);
|
||||
|
||||
WebIDL::ExceptionOr<String> outer_html() const;
|
||||
WebIDL::ExceptionOr<void> set_outer_html(String const&);
|
||||
|
||||
|
|
|
@ -33,6 +33,17 @@ dictionary CheckVisibilityOptions {
|
|||
boolean visibilityProperty = false;
|
||||
};
|
||||
|
||||
// https://fullscreen.spec.whatwg.org/#api
|
||||
enum FullscreenNavigationUI {
|
||||
"auto",
|
||||
"show",
|
||||
"hide"
|
||||
};
|
||||
|
||||
dictionary FullscreenOptions {
|
||||
FullscreenNavigationUI navigationUI = "auto";
|
||||
};
|
||||
|
||||
// https://dom.spec.whatwg.org/#element
|
||||
[Exposed=Window]
|
||||
interface Element : Node {
|
||||
|
@ -124,6 +135,10 @@ interface Element : Node {
|
|||
undefined setPointerCapture(long pointerId);
|
||||
undefined releasePointerCapture(long pointerId);
|
||||
boolean hasPointerCapture(long pointerId);
|
||||
|
||||
// partial interface for https://fullscreen.spec.whatwg.org/#api
|
||||
attribute EventHandler onfullscreenchange;
|
||||
attribute EventHandler onfullscreenerror;
|
||||
};
|
||||
|
||||
dictionary GetHTMLOptions {
|
||||
|
|
Loading…
Add table
Reference in a new issue