LibWeb/CSS: Return 0 from CSSRule.type for non-spec types

We use the CSSRule::Type enum for identifying the type of a CSSRule, but
the spec requires that only some of these types are exposed via the
`type` attribute. For the rest, we're required to return 0, so let's do
so. :^)
This commit is contained in:
Sam Atkins 2024-10-30 14:33:46 +00:00 committed by Andreas Kling
commit 51fc87bc1b
Notes: github-actions[bot] 2024-10-30 17:46:59 +00:00
5 changed files with 50 additions and 3 deletions

View file

@ -12,6 +12,7 @@
#include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/CSS/CSSStyleDeclaration.h>
#include <LibWeb/CSS/Selector.h>
#include <LibWeb/WebIDL/Types.h>
namespace Web::CSS {
@ -22,7 +23,7 @@ public:
virtual ~CSSRule() = default;
// https://drafts.csswg.org/cssom/#dom-cssrule-type
enum class Type : u16 {
enum class Type : WebIDL::UnsignedShort {
Style = 1,
Import = 3,
Media = 4,
@ -35,10 +36,11 @@ public:
LayerBlock = 100,
LayerStatement = 101,
NestedDeclarations = 102,
Property = 103, // FIXME: This should return `0` as a type, but type is used for a lot of dispatching
Property = 103,
};
Type type() const { return m_type; }
WebIDL::UnsignedShort type_for_bindings() const;
String css_text() const;
void set_css_text(StringView);