diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp
index 01f93439e3..26412944fa 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Window.cpp
@@ -596,11 +596,6 @@ Page const* Window::page() const
return associated_document().page();
}
-CSS::CSSStyleDeclaration* Window::get_computed_style_impl(DOM::Element& element) const
-{
- return CSS::ResolvedCSSStyleDeclaration::create(element).release_value_but_fixme_should_propagate_errors().ptr();
-}
-
Optional Window::query_media_feature(CSS::MediaFeatureID media_feature) const
{
// FIXME: Many of these should be dependent on the hardware
@@ -964,7 +959,6 @@ WebIDL::ExceptionOr Window::initialize_web_interfaces(Badge, JS::Value> Window::event() const
return JS::js_undefined();
}
+// https://w3c.github.io/csswg-drafts/cssom/#dom-window-getcomputedstyle
+WebIDL::ExceptionOr> Window::get_computed_style(DOM::Element& element, Optional const& pseudo_element) const
+{
+ // FIXME: Make this fully spec compliant.
+ (void)pseudo_element;
+ return MUST_OR_THROW_OOM(heap().allocate(realm(), element));
+}
+
// https://w3c.github.io/csswg-drafts/cssom-view/#dom-window-matchmedia
WebIDL::ExceptionOr> Window::match_media(String const& query)
{
@@ -1654,16 +1656,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::location_setter)
return JS::js_undefined();
}
-JS_DEFINE_NATIVE_FUNCTION(Window::get_computed_style)
-{
- auto* impl = TRY(impl_from(vm));
- auto* object = TRY(vm.argument(0).to_object(vm));
- if (!is(object))
- return vm.throw_completion(JS::ErrorType::NotAnObjectOfType, "DOM element");
-
- return impl->get_computed_style_impl(*static_cast(object));
-}
-
// https://w3c.github.io/selection-api/#dom-window-getselection
JS_DEFINE_NATIVE_FUNCTION(Window::get_selection)
{
diff --git a/Userland/Libraries/LibWeb/HTML/Window.h b/Userland/Libraries/LibWeb/HTML/Window.h
index 099e2880ff..b95a6ef520 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.h
+++ b/Userland/Libraries/LibWeb/HTML/Window.h
@@ -108,7 +108,6 @@ public:
DOM::Event const* current_event() const { return m_current_event.ptr(); }
void set_current_event(DOM::Event* event);
- CSS::CSSStyleDeclaration* get_computed_style_impl(DOM::Element&) const;
Optional query_media_feature(CSS::MediaFeatureID) const;
void fire_a_page_transition_event(DeprecatedFlyString const& event_name, bool persisted);
@@ -159,6 +158,8 @@ public:
Variant, JS::Value> event() const;
+ WebIDL::ExceptionOr> get_computed_style(DOM::Element&, Optional const& pseudo_element) const;
+
WebIDL::ExceptionOr> match_media(String const& query);
WebIDL::ExceptionOr> screen();
@@ -257,7 +258,6 @@ private:
JS_DECLARE_NATIVE_FUNCTION(cancel_animation_frame);
JS_DECLARE_NATIVE_FUNCTION(focus);
- JS_DECLARE_NATIVE_FUNCTION(get_computed_style);
JS_DECLARE_NATIVE_FUNCTION(get_selection);
JS_DECLARE_NATIVE_FUNCTION(queue_microtask);
diff --git a/Userland/Libraries/LibWeb/HTML/Window.idl b/Userland/Libraries/LibWeb/HTML/Window.idl
index f695736078..5dcef66cfc 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.idl
+++ b/Userland/Libraries/LibWeb/HTML/Window.idl
@@ -44,6 +44,9 @@ interface Window : EventTarget {
// https://dom.spec.whatwg.org/#interface-window-extensions
[Replaceable] readonly attribute (Event or undefined) event; // legacy
+ // https://w3c.github.io/csswg-drafts/cssom/#extensions-to-the-window-interface
+ [NewObject] CSSStyleDeclaration getComputedStyle(Element elt, optional CSSOMString? pseudoElt);
+
// https://w3c.github.io/csswg-drafts/cssom-view/#extensions-to-the-window-interface
[NewObject] MediaQueryList matchMedia(CSSOMString query);
[SameObject, Replaceable] readonly attribute Screen screen;