1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

LibWeb: Rough implementation of CSS namespace rule

This provides a rough implementation of the CSS @namespace rule.
Currently we just support default namespaces, namespace prefixes
are still to come.
This commit is contained in:
Jonah 2023-07-29 11:51:15 -05:00 committed by Sam Atkins
parent 3f7d97f098
commit 60e35f2a97
18 changed files with 266 additions and 3 deletions

View file

@ -6,6 +6,7 @@
#include <LibWeb/Bindings/CSSStyleSheetPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/CSSNamespaceRule.h>
#include <LibWeb/CSS/CSSStyleSheet.h>
#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/StyleComputer.h>
@ -137,4 +138,17 @@ void CSSStyleSheet::set_style_sheet_list(Badge<StyleSheetList>, StyleSheetList*
m_style_sheet_list = list;
}
Optional<StringView> CSSStyleSheet::namespace_filter() const
{
for (JS::NonnullGCPtr<CSSRule> rule : *m_rules) {
if (rule->type() == CSSRule::Type::Namespace) {
auto& namespace_rule = verify_cast<CSSNamespaceRule>(*rule);
if (!namespace_rule.namespace_uri().is_empty() && namespace_rule.prefix().is_empty())
return namespace_rule.namespace_uri().view();
}
}
return {};
}
}