mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 12:20:00 +01:00
LibWeb: Implement CSSImportRule.supportsText
Returns the supports condition specified by the given import at-rule.
This commit is contained in:
parent
c37a47f76f
commit
5d57723ebf
|
|
@ -171,4 +171,11 @@ void CSSImportRule::set_style_sheet(GC::Ref<CSSStyleSheet> style_sheet)
|
||||||
m_document->invalidate_style(DOM::StyleInvalidationReason::CSSImportRule);
|
m_document->invalidate_style(DOM::StyleInvalidationReason::CSSImportRule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Optional<String> CSSImportRule::supports_text() const
|
||||||
|
{
|
||||||
|
if (!m_supports)
|
||||||
|
return {};
|
||||||
|
return m_supports->to_string();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ public:
|
||||||
CSSStyleSheet const* loaded_style_sheet() const { return m_style_sheet; }
|
CSSStyleSheet const* loaded_style_sheet() const { return m_style_sheet; }
|
||||||
CSSStyleSheet* style_sheet_for_bindings() { return m_style_sheet; }
|
CSSStyleSheet* style_sheet_for_bindings() { return m_style_sheet; }
|
||||||
|
|
||||||
|
Optional<String> supports_text() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CSSImportRule(URL::URL, DOM::Document&, RefPtr<Supports>);
|
CSSImportRule(URL::URL, DOM::Document&, RefPtr<Supports>);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,5 @@ interface CSSImportRule : CSSRule {
|
||||||
// FIXME: [SameObject, PutForwards=mediaText] readonly attribute MediaList media;
|
// FIXME: [SameObject, PutForwards=mediaText] readonly attribute MediaList media;
|
||||||
[SameObject, ImplementedAs=style_sheet_for_bindings] readonly attribute CSSStyleSheet? styleSheet;
|
[SameObject, ImplementedAs=style_sheet_for_bindings] readonly attribute CSSStyleSheet? styleSheet;
|
||||||
[FIXME] readonly attribute CSSOMString? layerName;
|
[FIXME] readonly attribute CSSOMString? layerName;
|
||||||
[FIXME] readonly attribute CSSOMString? supportsText;
|
readonly attribute CSSOMString? supportsText;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -291,9 +291,11 @@ OwnPtr<BooleanExpression> Parser::parse_supports_feature(TokenStream<ComponentVa
|
||||||
// FIXME: Parsing and then converting back to a string is weird.
|
// FIXME: Parsing and then converting back to a string is weird.
|
||||||
if (auto declaration = consume_a_declaration(block_tokens); declaration.has_value()) {
|
if (auto declaration = consume_a_declaration(block_tokens); declaration.has_value()) {
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
return Supports::Declaration::create(
|
auto supports_declaration = Supports::Declaration::create(
|
||||||
declaration->to_string(),
|
declaration->to_string(),
|
||||||
convert_to_style_property(*declaration).has_value());
|
convert_to_style_property(*declaration).has_value());
|
||||||
|
|
||||||
|
return BooleanExpressionInParens::create(supports_declaration.release_nonnull<BooleanExpression>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ MatchResult Supports::Declaration::evaluate(HTML::Window const*) const
|
||||||
|
|
||||||
String Supports::Declaration::to_string() const
|
String Supports::Declaration::to_string() const
|
||||||
{
|
{
|
||||||
return MUST(String::formatted("({})", m_declaration));
|
return m_declaration;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Supports::Declaration::dump(StringBuilder& builder, int indent_levels) const
|
void Supports::Declaration::dump(StringBuilder& builder, int indent_levels) const
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
cssText: @import url("https://something.invalid/") supports(foo: bar);
|
||||||
|
supportsText: foo: bar
|
||||||
|
cssText: @import url("https://something.invalid/") supports((display: block) and (foo: bar));
|
||||||
|
supportsText: (display: block) and (foo: bar)
|
||||||
17
Tests/LibWeb/Text/input/css/CSSImportRule-supportsText.html
Normal file
17
Tests/LibWeb/Text/input/css/CSSImportRule-supportsText.html
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<style>
|
||||||
|
@import url("https://something.invalid") supports(foo: bar);
|
||||||
|
@import url("https://something.invalid") supports((display: block) and (foo: bar));
|
||||||
|
</style>
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
function printImportRule(importRule) {
|
||||||
|
println(`cssText: ${importRule.cssText}`);
|
||||||
|
println(`supportsText: ${importRule.supportsText}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
printImportRule(document.styleSheets[0].cssRules[0]);
|
||||||
|
printImportRule(document.styleSheets[0].cssRules[1]);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user