diff --git a/Userland/Libraries/LibWeb/CSS/FontFaceSet.cpp b/Userland/Libraries/LibWeb/CSS/FontFaceSet.cpp index c82678c0145..281f744eb52 100644 --- a/Userland/Libraries/LibWeb/CSS/FontFaceSet.cpp +++ b/Userland/Libraries/LibWeb/CSS/FontFaceSet.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2024, Andrew Kaster + * Copyright (c) 2024, Jamie Mansfield * * SPDX-License-Identifier: BSD-2-Clause */ @@ -11,6 +12,7 @@ #include #include #include +#include #include namespace Web::CSS { @@ -83,6 +85,18 @@ void FontFaceSet::clear() m_set_entries->set_clear(); } +// https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-onloading +void FontFaceSet::set_onloading(WebIDL::CallbackType* event_handler) +{ + set_event_handler_attribute(HTML::EventNames::loading, event_handler); +} + +// https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-onloading +WebIDL::CallbackType* FontFaceSet::onloading() +{ + return event_handler_attribute(HTML::EventNames::loading); +} + // https://drafts.csswg.org/css-font-loading/#dom-fontfaceset-load JS::ThrowCompletionOr> FontFaceSet::load(String const&, String const&) { diff --git a/Userland/Libraries/LibWeb/CSS/FontFaceSet.h b/Userland/Libraries/LibWeb/CSS/FontFaceSet.h index 4a4e7dc7b6f..db385a9a14a 100644 --- a/Userland/Libraries/LibWeb/CSS/FontFaceSet.h +++ b/Userland/Libraries/LibWeb/CSS/FontFaceSet.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2024, Andrew Kaster + * Copyright (c) 2024, Jamie Mansfield * * SPDX-License-Identifier: BSD-2-Clause */ @@ -29,6 +30,10 @@ public: JS::NonnullGCPtr add(JS::Handle); bool delete_(JS::Handle); void clear(); + + void set_onloading(WebIDL::CallbackType*); + WebIDL::CallbackType* onloading(); + JS::ThrowCompletionOr> load(String const& font, String const& text); JS::NonnullGCPtr ready() const; diff --git a/Userland/Libraries/LibWeb/CSS/FontFaceSet.idl b/Userland/Libraries/LibWeb/CSS/FontFaceSet.idl index 3a379bf2f47..36c703f4354 100644 --- a/Userland/Libraries/LibWeb/CSS/FontFaceSet.idl +++ b/Userland/Libraries/LibWeb/CSS/FontFaceSet.idl @@ -25,7 +25,7 @@ interface FontFaceSet : EventTarget { undefined clear(); // events for when loading state changes - [FIXME] attribute EventHandler onloading; + attribute EventHandler onloading; [FIXME] attribute EventHandler onloadingdone; [FIXME] attribute EventHandler onloadingerror; diff --git a/Userland/Libraries/LibWeb/HTML/EventNames.h b/Userland/Libraries/LibWeb/HTML/EventNames.h index 40ebc6e7bac..3255dac5687 100644 --- a/Userland/Libraries/LibWeb/HTML/EventNames.h +++ b/Userland/Libraries/LibWeb/HTML/EventNames.h @@ -65,6 +65,7 @@ namespace Web::HTML::EventNames { __ENUMERATE_HTML_EVENT(loadend) \ __ENUMERATE_HTML_EVENT(loadeddata) \ __ENUMERATE_HTML_EVENT(loadedmetadata) \ + __ENUMERATE_HTML_EVENT(loading) \ __ENUMERATE_HTML_EVENT(loadstart) \ __ENUMERATE_HTML_EVENT(message) \ __ENUMERATE_HTML_EVENT(messageerror) \