Commit f7c67226 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

[@property] Serialize property name as an identifier

The serialization must follow the "serialize an identifier" algorithm,
otherwise characters like U+0009 CHARACTER TABULATION will not be
escaped correctly.

Bug: 973830
Change-Id: I2dc943a74900adaf147e1615070c152a78cb5767
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2238117Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/master@{#777302}
parent 1b28cf3e
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/core/css/css_property_rule.h" #include "third_party/blink/renderer/core/css/css_property_rule.h"
#include "third_party/blink/renderer/core/css/css_identifier_value.h" #include "third_party/blink/renderer/core/css/css_identifier_value.h"
#include "third_party/blink/renderer/core/css/css_markup.h"
#include "third_party/blink/renderer/core/css/css_property_value_set.h" #include "third_party/blink/renderer/core/css/css_property_value_set.h"
#include "third_party/blink/renderer/core/css/css_string_value.h" #include "third_party/blink/renderer/core/css/css_string_value.h"
#include "third_party/blink/renderer/core/css/style_rule.h" #include "third_party/blink/renderer/core/css/style_rule.h"
...@@ -24,7 +25,7 @@ String CSSPropertyRule::cssText() const { ...@@ -24,7 +25,7 @@ String CSSPropertyRule::cssText() const {
// https://drafts.css-houdini.org/css-properties-values-api-1/#serialize-a-csspropertyrule // https://drafts.css-houdini.org/css-properties-values-api-1/#serialize-a-csspropertyrule
StringBuilder builder; StringBuilder builder;
builder.Append("@property "); builder.Append("@property ");
builder.Append(property_rule_->GetName()); SerializeIdentifier(property_rule_->GetName(), builder);
builder.Append(" { "); builder.Append(" { ");
if (const CSSValue* syntax = property_rule_->GetSyntax()) { if (const CSSValue* syntax = property_rule_->GetSyntax()) {
DCHECK(syntax->IsStringValue()); DCHECK(syntax->IsStringValue());
......
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
@property --initial-value-only { @property --initial-value-only {
initial-value: red; initial-value: red;
} }
/* U+0009 CHARACTER TABULATION */
@property --tab\9 tab { }
</style> </style>
<script> <script>
...@@ -119,6 +121,7 @@ test_css_text('--no-initial-value', '@property --no-initial-value { syntax: "<co ...@@ -119,6 +121,7 @@ test_css_text('--no-initial-value', '@property --no-initial-value { syntax: "<co
test_css_text('--syntax-only', '@property --syntax-only { syntax: "<color> | none"; }'); test_css_text('--syntax-only', '@property --syntax-only { syntax: "<color> | none"; }');
test_css_text('--inherits-only', '@property --inherits-only { inherits: true; }'); test_css_text('--inherits-only', '@property --inherits-only { inherits: true; }');
test_css_text('--initial-value-only', '@property --initial-value-only { initial-value: red; }'); test_css_text('--initial-value-only', '@property --initial-value-only { initial-value: red; }');
test_css_text('--tab\ttab', '@property --tab\\9 tab { }');
// CSSRule.type // CSSRule.type
......
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