mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:07:35 +00:00
LibWeb: Add serialization code for CSS{Media,Supports}Rule
The `CSSMediaRule::serialized()` code is to spec. The `CSSSupportsRule::serialized()` code has no spec right now, but I'm fairly confident it will be almost identical to media's, so I copied that for now.
This commit is contained in:
parent
46bba44f8b
commit
0f88a47e58
6 changed files with 53 additions and 8 deletions
|
@ -31,4 +31,27 @@ void CSSSupportsRule::set_condition_text(String text)
|
|||
m_supports = new_supports.release_nonnull();
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/cssom-1/#serialize-a-css-rule
|
||||
String CSSSupportsRule::serialized() const
|
||||
{
|
||||
// Note: The spec doesn't cover this yet, so I'm roughly following the spec for the @media rule.
|
||||
// It should be pretty close!
|
||||
|
||||
StringBuilder builder;
|
||||
|
||||
builder.append("@supports ");
|
||||
builder.append(condition_text());
|
||||
builder.append(" {\n");
|
||||
for (size_t i = 0; i < css_rules().length(); i++) {
|
||||
auto rule = css_rules().item(i);
|
||||
if (i != 0)
|
||||
builder.append("\n");
|
||||
builder.append(" ");
|
||||
builder.append(rule->css_text());
|
||||
}
|
||||
builder.append("\n}");
|
||||
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue