summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLuke Wilde <lukew@serenityos.org>2021-09-29 13:03:09 +0100
committerLinus Groh <mail@linusgroh.de>2021-09-29 14:57:59 +0100
commit881e9d1341a38dc81996a549fd37bd3871078416 (patch)
tree3312c48ec319c941ab561daaecbbe516bacebf41 /Userland
parent398435277b48302ba5428b59f4c1861d07b4e461 (diff)
downloadserenity-881e9d1341a38dc81996a549fd37bd3871078416.zip
LibWeb: Make StyleSheetList.item an IDL getter
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp11
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleSheetList.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleSheetList.idl4
3 files changed, 15 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp b/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp
index 42e365df20..8337be16c3 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.cpp
@@ -18,4 +18,15 @@ StyleSheetList::StyleSheetList(DOM::Document& document)
{
}
+// https://drafts.csswg.org/cssom/#ref-for-dfn-supported-property-indices%E2%91%A1
+bool StyleSheetList::is_supported_property_index(u32 index) const
+{
+ // The object’s supported property indices are the numbers in the range zero to one less than the number of CSS style sheets represented by the collection.
+ // If there are no such CSS style sheets, then there are no supported property indices.
+ if (m_sheets.is_empty())
+ return false;
+
+ return index < m_sheets.size();
+}
+
}
diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h
index 5b52008f3a..04ccf51ebb 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.h
+++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.h
@@ -37,6 +37,8 @@ public:
size_t length() const { return m_sheets.size(); }
+ bool is_supported_property_index(u32) const;
+
private:
explicit StyleSheetList(DOM::Document&);
diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheetList.idl b/Userland/Libraries/LibWeb/CSS/StyleSheetList.idl
index 27460affa4..15dc0d41f6 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleSheetList.idl
+++ b/Userland/Libraries/LibWeb/CSS/StyleSheetList.idl
@@ -1,5 +1,5 @@
+[Exposed=Window]
interface StyleSheetList {
- // FIXME: item() should be a WebIDL "getter"
- CSSStyleSheet? item(unsigned long index);
+ getter CSSStyleSheet? item(unsigned long index);
readonly attribute unsigned long length;
};