1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:38:11 +00:00

LibWeb: Implement CSSRule and CSSStyleDeclaration serialization

There are a handful of FIXME's here, but this seems generally good.
Note that CSS *values* don't get serialized in a spec-compliant way
since we currently rely on StyleValue::to_string() which is ad-hoc.
This commit is contained in:
Andreas Kling 2021-10-01 19:57:45 +02:00
parent c953103d2f
commit 3db847c64a
14 changed files with 461 additions and 9 deletions

View file

@ -19,4 +19,27 @@ CSSImportRule::~CSSImportRule()
{
}
// https://drafts.csswg.org/cssom/#serialize-a-css-rule
String CSSImportRule::serialized() const
{
StringBuilder builder;
// The result of concatenating the following:
// 1. The string "@import" followed by a single SPACE (U+0020).
builder.append("@import "sv);
// 2. The result of performing serialize a URL on the rules location.
// FIXME: Look into the correctness of this serialization
builder.append("url("sv);
builder.append(m_url.to_string());
builder.append(')');
// FIXME: 3. If the rules associated media list is not empty, a single SPACE (U+0020) followed by the result of performing serialize a media query list on the media list.
// 4. The string ";", i.e., SEMICOLON (U+003B).
builder.append(';');
return builder.to_string();
}
}