Commit f9d61d01 authored by Chris Nardi's avatar Chris Nardi Committed by Commit Bot

Serialize custom property names as identifiers

Custom property names are defined [1] to be "any valid identifier that
starts with two dashes." As such, they need to be serialized as
identifiers, in order to ensure that reparsing generates a valid custom
property name. Change our serialization of custom property names to use
SerializeIdentifier().

[1]: https://drafts.csswg.org/css-variables/#typedef-custom-property-name

Bug: 828272
Change-Id: Icd830b6b3b38f0414877c6d8dec69efa00318bb3
Reviewed-on: https://chromium-review.googlesource.com/991608Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Chris Nardi <cnardi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547733}
parent 045cec8b
This is a testharness.js-based test.
PASS custom property '--a'
FAIL custom property '--a;b' assert_equals: appears on specified style (after serialization/re-parsing) expected 1 but got 0
PASS custom property '---'
FAIL custom property '--\' assert_equals: appears on specified style (after serialization/re-parsing) expected 1 but got 0
PASS custom property '--ab'
PASS custom property '--0'
Harness: the test ran to completion.
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <bitset> #include <bitset>
#include "core/css/CSSCustomPropertyDeclaration.h" #include "core/css/CSSCustomPropertyDeclaration.h"
#include "core/css/CSSIdentifierValue.h" #include "core/css/CSSIdentifierValue.h"
#include "core/css/CSSMarkup.h"
#include "core/css/CSSPendingSubstitutionValue.h" #include "core/css/CSSPendingSubstitutionValue.h"
#include "core/css/CSSValuePool.h" #include "core/css/CSSValuePool.h"
#include "core/css/properties/css_property.h" #include "core/css/properties/css_property.h"
...@@ -179,7 +180,7 @@ String StylePropertySerializer::GetCustomPropertyText( ...@@ -179,7 +180,7 @@ String StylePropertySerializer::GetCustomPropertyText(
result.Append(' '); result.Append(' ');
const CSSCustomPropertyDeclaration* value = const CSSCustomPropertyDeclaration* value =
ToCSSCustomPropertyDeclaration(property.Value()); ToCSSCustomPropertyDeclaration(property.Value());
result.Append(value->GetName()); SerializeIdentifier(value->GetName(), result, is_not_first_decl);
result.Append(':'); result.Append(':');
if (!value->Value()) if (!value->Value())
result.Append(' '); result.Append(' ');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment