From 9b1ea4e2fc276a1078ed38eade303a16fd619750 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Sat, 24 Feb 2024 07:46:59 +0000 Subject: [PATCH] LibWeb: Add `CSSStyleSheet.ownerRule` attribute This returns the `CSSImportRule` corresponding to the `@import` at-rule that imported the stylesheet into the document. If the stylesheet wasn't imported then this property is null. --- Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp | 1 + Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h | 3 +++ Userland/Libraries/LibWeb/CSS/CSSStyleSheet.idl | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp index 2735778f1d..d970b6fa78 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2019-2022, Andreas Kling + * Copyright (c) 2024, Tim Ledbetter * * SPDX-License-Identifier: BSD-2-Clause */ diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h index e7760d76e5..ae1601bfc6 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2019-2021, Andreas Kling + * Copyright (c) 2024, Tim Ledbetter * * SPDX-License-Identifier: BSD-2-Clause */ @@ -28,6 +29,8 @@ public: virtual ~CSSStyleSheet() override = default; + JS::GCPtr owner_rule() const { return m_owner_css_rule; } + JS::GCPtr owner_rule() { return m_owner_css_rule; } void set_owner_css_rule(CSSRule* rule) { m_owner_css_rule = rule; } virtual String type() const override { return "text/css"_string; } diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.idl b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.idl index 265a8b08be..c71ea64852 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.idl +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.idl @@ -7,7 +7,7 @@ interface CSSStyleSheet : StyleSheet { // FIXME: constructor(optional CSSStyleSheetInit options = {}); - // FIXME: readonly attribute CSSRule? ownerRule; + readonly attribute CSSRule? ownerRule; [SameObject] readonly attribute CSSRuleList cssRules; unsigned long insertRule(CSSOMString rule, optional unsigned long index = 0); undefined deleteRule(unsigned long index);