mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:07:46 +00:00
LibWeb: Support CSSRule.type
We already had the CSSRule::Type enum, but the values were not aligned with the CSSOM spec. This patch takes care of that, and then exposes the type of a CSSRule to JavaScript via the "type" attribute.
This commit is contained in:
parent
a0ba49a50a
commit
f4f850aaf2
4 changed files with 19 additions and 13 deletions
|
@ -24,13 +24,13 @@ public:
|
||||||
|
|
||||||
virtual ~CSSRule() = default;
|
virtual ~CSSRule() = default;
|
||||||
|
|
||||||
enum class Type : u32 {
|
// https://drafts.csswg.org/cssom/#dom-cssrule-type
|
||||||
Style,
|
enum class Type : u16 {
|
||||||
Import,
|
Style = 1,
|
||||||
Media,
|
Import = 3,
|
||||||
Supports,
|
Media = 4,
|
||||||
FontFace,
|
FontFace = 5,
|
||||||
__Count,
|
Supports = 12,
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual StringView class_name() const = 0;
|
virtual StringView class_name() const = 0;
|
||||||
|
|
|
@ -2,4 +2,16 @@ interface CSSRule {
|
||||||
|
|
||||||
attribute CSSOMString cssText;
|
attribute CSSOMString cssText;
|
||||||
|
|
||||||
|
readonly attribute unsigned short type;
|
||||||
|
|
||||||
|
const unsigned short STYLE_RULE = 1;
|
||||||
|
const unsigned short CHARSET_RULE = 2;
|
||||||
|
const unsigned short IMPORT_RULE = 3;
|
||||||
|
const unsigned short MEDIA_RULE = 4;
|
||||||
|
const unsigned short FONT_FACE_RULE = 5;
|
||||||
|
const unsigned short PAGE_RULE = 6;
|
||||||
|
const unsigned short MARGIN_RULE = 9;
|
||||||
|
const unsigned short NAMESPACE_RULE = 10;
|
||||||
|
const unsigned short SUPPORTS_RULE = 12;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -95,8 +95,6 @@ void CSSRuleList::for_each_effective_style_rule(Function<void(CSSStyleRule const
|
||||||
case CSSRule::Type::Supports:
|
case CSSRule::Type::Supports:
|
||||||
static_cast<CSSSupportsRule const&>(rule).for_each_effective_style_rule(callback);
|
static_cast<CSSSupportsRule const&>(rule).for_each_effective_style_rule(callback);
|
||||||
break;
|
break;
|
||||||
case CSSRule::Type::__Count:
|
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,8 +131,6 @@ bool CSSRuleList::evaluate_media_queries(HTML::Window const& window)
|
||||||
any_media_queries_changed_match_state = true;
|
any_media_queries_changed_match_state = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CSSRule::Type::__Count:
|
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -563,8 +563,6 @@ void dump_rule(StringBuilder& builder, CSS::CSSRule const& rule, int indent_leve
|
||||||
case CSS::CSSRule::Type::Supports:
|
case CSS::CSSRule::Type::Supports:
|
||||||
dump_supports_rule(builder, verify_cast<CSS::CSSSupportsRule const>(rule), indent_levels);
|
dump_supports_rule(builder, verify_cast<CSS::CSSSupportsRule const>(rule), indent_levels);
|
||||||
break;
|
break;
|
||||||
case CSS::CSSRule::Type::__Count:
|
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue