Commit 9d45b94d authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez Committed by Commit Bot

[cssom] Make CSSOM APIs always append to the declaration block.

...instead of replacing if the property is already set.

This matches the spec[1] which was changed as a resolution from[2].

Intent thread: https://groups.google.com/a/chromium.org/d/msg/blink-dev/lzBoa1EAQpI/strfpNczAwAJ

[1]: https://drafts.csswg.org/cssom/#set-a-css-declaration
[2]: https://github.com/w3c/csswg-drafts/issues/1898

Bug: 782407
Change-Id: I4b72c0207a4cf734fc2e415bd62c7863103ec309
Reviewed-on: https://chromium-review.googlesource.com/1054867
Commit-Queue: Emilio Cobos Álvarez <emilio@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560180}
parent ec82e04d
......@@ -2934,7 +2934,6 @@ crbug.com/626703 external/wpt/mediacapture-streams/MediaStream-MediaElement-prel
crbug.com/626703 virtual/feature-policy-permissions/external/wpt/mediacapture-streams/MediaStream-MediaElement-preload-none-manual.https.html [ Skip ]
crbug.com/626703 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-flex-basis-content-003a.html [ Failure ]
crbug.com/626703 external/wpt/css/vendor-imports/mozilla/mozilla-central-reftests/flexbox/flexbox-flex-basis-content-004a.html [ Failure ]
crbug.com/626703 external/wpt/css/cssom/cssstyledeclaration-mutationrecord-001.html [ Timeout ]
crbug.com/626703 external/wpt/css/css-shapes/shape-outside/shape-image/gradients/shape-outside-linear-gradient-008.html [ Failure ]
crbug.com/626703 [ Mac10.11 ] virtual/webrtc-wpt-unified-plan/external/wpt/webrtc/RTCPeerConnection-track-stats.https.html [ Timeout ]
crbug.com/626703 external/wpt/css/css-shapes/shape-outside/shape-image/gradients/shape-outside-linear-gradient-006.html [ Failure ]
......@@ -4386,9 +4385,6 @@ crbug.com/778745 http/tests/inspector-protocol/cachestorage/read-cached-response
# Sheriff failures 2017-10-24
crbug.com/773122 crbug.com/777813 [ Win ] fast/text/font-ascent-mac.html [ Failure Pass ]
# Sheriff failures 2017-11-07
crbug.com/782067 [ Mac10.10 Mac10.11 ] fast/css/no-recalc-on-no-op-inline-style-changes.html [ Pass Failure ]
# Sheriff failures 2017-11-13
crbug.com/783800 imagecapture/MediaStreamTrack-applyConstraints.html [ Pass Failure ]
crbug.com/783800 imagecapture/MediaStreamTrack-applyConstraints-getSettings.html [ Pass Failure ]
......
......@@ -9,7 +9,7 @@ Drag the link. Link
Test ID: selectionTest
text/plain: Select some text in this box and drag it.
text/url:
text/html: <span style="color: rgb(0, 0, 0); font-family: serif; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Select some text in this box and drag it.</span>
text/html: <span style="color: rgb(0, 0, 0); font-family: serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; font-size: medium; display: inline !important; float: none;">Select some text in this box and drag it.</span>
Test ID: imageTest
text/plain:
text/url:
......
CONSOLE MESSAGE: line 21: text/plain: This test verifies that we can get text/html from the clipboard during an onpaste event.
CONSOLE MESSAGE: line 23: text/html: <span style="color: rgb(0, 0, 0); font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">This test verifies that we can get text/html from the clipboard during an onpaste event.<span> </span></span>
CONSOLE MESSAGE: line 23: text/html: <span style="color: rgb(0, 0, 0); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; font-size: medium; display: inline !important; float: none;">This test verifies that we can get text/html from the clipboard during an onpaste event.<span> </span></span>
This test verifies that we can get text/html from the clipboard during an onpaste event. This test requires DRT.
Paste content in this div.This test verifies that we can get text/html from the clipboard during an onpaste event. 
PASS
......
This is a testharness.js-based test.
FAIL setProperty with existing longhand should change order assert_array_equals: Property order should match after setting existing property property 0, expected "bottom" but got "top"
FAIL invoke property setter with existing longhand should change order assert_array_equals: Property order should match after setting existing property property 0, expected "bottom" but got "top"
FAIL setProperty with existing shorthand should change order assert_array_equals: Property order should match after setting an existing shorthand property 0, expected "top" but got "margin-top"
FAIL invoke property setter with existing shorthand should change order assert_array_equals: Property order should match after setting an existing shorthand property 0, expected "top" but got "margin-top"
Harness: the test ran to completion.
<!DOCTYPE html>
<div id="element"></div>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
test(function () {
if (!window.internals)
assert_unreached('This test requires window.internals.');
assert_greater_than(internals.updateStyleAndReturnAffectedElementCount(), 1);
element.style.top = "0px";
assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 1);
for (var i = 0; i < 100; i ++) {
element.style.top = "0px";
assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 0);
}
}, "Check that a no-op inline style change doesn't result in a recalc");
</script>
......@@ -173,7 +173,7 @@ PASS mutations[0].attributeName is "style"
PASS mutations[0].oldValue is "color: yellow; width: 100px;"
PASS mutations[1].type is "attributes"
PASS mutations[1].attributeName is "style"
PASS mutations[1].oldValue is "color: red; width: 100px;"
PASS mutations[1].oldValue is "width: 100px; color: red;"
PASS mutations[2].type is "attributes"
PASS mutations[2].attributeName is "style"
PASS mutations[2].oldValue is "color: red; width: 200px;"
......
......@@ -715,7 +715,7 @@ function testStyleAttributePropertyAccessOldValue() {
shouldBe('mutations[0].oldValue', '"color: yellow; width: 100px;"');
shouldBe('mutations[1].type', '"attributes"');
shouldBe('mutations[1].attributeName', '"style"');
shouldBe('mutations[1].oldValue', '"color: red; width: 100px;"');
shouldBe('mutations[1].oldValue', '"width: 100px; color: red;"');
shouldBe('mutations[2].type', '"attributes"');
shouldBe('mutations[2].attributeName', '"style"');
shouldBe('mutations[2].oldValue', '"color: red; width: 200px;"');
......
......@@ -6,11 +6,11 @@ It is OK if the order of properties changes from the expected results - IE 6 and
This is the test element.
Successfully set display to "block"; cssText is now: "top: 0px; display: block; bottom: 1px;".
Successfully set display to "block"; cssText is now: "top: 0px; bottom: 1px; display: block;".
Successfully set display to "foobar"; cssText is now: "top: 0px; display: none; bottom: 1px;".
Successfully set display to ""; cssText is now: "top: 0px; bottom: 1px;".
Successfully set display to null; cssText is now: "top: 0px; bottom: 1px;".
Successfully set display to "block" with setProperty; cssText is now: "top: 0px; display: block; bottom: 1px;".
Successfully set display to "block" with setProperty; cssText is now: "top: 0px; bottom: 1px; display: block;".
Successfully set display to "foobar" with setProperty; cssText is now: "top: 0px; display: none; bottom: 1px;".
Successfully set display to "" with setProperty; cssText is now: "top: 0px; bottom: 1px;".
Successfully set display to null with setProperty; cssText is now: "top: 0px; bottom: 1px;".
CONSOLE MESSAGE: line 21: text/plain: This test verifies that we can get text/html from the drag object during an ondrop event.
CONSOLE MESSAGE: line 23: text/html: <span style="color: rgb(0, 0, 0); font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">This test verifies that we can get text/html from the drag object during an ondrop event.<span> </span></span>
CONSOLE MESSAGE: line 23: text/html: <span style="color: rgb(0, 0, 0); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial; font-size: medium; display: inline !important; float: none;">This test verifies that we can get text/html from the drag object during an ondrop event.<span> </span></span>
This test verifies that we can get text/html from the drag object during an ondrop event. This test requires DRT.
PASS
......@@ -360,10 +360,11 @@ MutableCSSPropertyValueSet::SetResult MutableCSSPropertyValueSet::SetProperty(
}
// When replacing an existing property value, this moves the property to the
// end of the list. Firefox preserves the position, and MSIE moves the
// property to the beginning.
return CSSParser::ParseValue(this, unresolved_property, value, important,
secure_context_mode, context_style_sheet);
// end of the list.
bool parsed_and_changed =
CSSParser::ParseValue(this, unresolved_property, value, important,
secure_context_mode, context_style_sheet);
return SetResult{parsed_and_changed, parsed_and_changed};
}
MutableCSSPropertyValueSet::SetResult MutableCSSPropertyValueSet::SetProperty(
......@@ -377,11 +378,12 @@ MutableCSSPropertyValueSet::SetResult MutableCSSPropertyValueSet::SetProperty(
if (value.IsEmpty()) {
bool did_parse = true;
bool did_change = RemoveProperty(custom_property_name);
return MutableCSSPropertyValueSet::SetResult{did_parse, did_change};
return SetResult{did_parse, did_change};
}
return CSSParser::ParseValueForCustomProperty(
bool parsed_and_changed = CSSParser::ParseValueForCustomProperty(
this, custom_property_name, registry, value, important,
secure_context_mode, context_style_sheet, is_animation_tainted);
return SetResult{parsed_and_changed, parsed_and_changed};
}
void MutableCSSPropertyValueSet::SetProperty(CSSPropertyID property_id,
......@@ -402,31 +404,22 @@ void MutableCSSPropertyValueSet::SetProperty(CSSPropertyID property_id,
}
}
bool MutableCSSPropertyValueSet::SetProperty(const CSSPropertyValue& property,
void MutableCSSPropertyValueSet::SetProperty(const CSSPropertyValue& property,
CSSPropertyValue* slot) {
const AtomicString& name =
(property.Id() == CSSPropertyVariable)
? ToCSSCustomPropertyDeclaration(property.Value())->GetName()
: g_null_atom;
CSSPropertyValue* to_replace =
slot ? slot : FindCSSPropertyWithID(property.Id(), name);
if (to_replace && *to_replace == property)
return false;
if (to_replace) {
*to_replace = property;
return true;
if (property.Id() == CSSPropertyVariable) {
RemoveProperty(ToCSSCustomPropertyDeclaration(property.Value())->GetName());
} else {
RemoveProperty(property.Id());
}
property_vector_.push_back(property);
return true;
}
bool MutableCSSPropertyValueSet::SetProperty(CSSPropertyID property_id,
void MutableCSSPropertyValueSet::SetProperty(CSSPropertyID property_id,
CSSValueID identifier,
bool important) {
SetProperty(CSSPropertyValue(CSSProperty::Get(property_id),
*CSSIdentifierValue::Create(identifier),
important));
return true;
}
void MutableCSSPropertyValueSet::ParseDeclarationList(
......@@ -447,21 +440,20 @@ void MutableCSSPropertyValueSet::ParseDeclarationList(
CSSParser::ParseDeclarationList(context, this, style_declaration);
}
bool MutableCSSPropertyValueSet::AddParsedProperties(
void MutableCSSPropertyValueSet::AddParsedProperties(
const HeapVector<CSSPropertyValue, 256>& properties) {
bool changed = false;
property_vector_.ReserveCapacity(property_vector_.size() + properties.size());
for (unsigned i = 0; i < properties.size(); ++i)
changed |= SetProperty(properties[i]);
return changed;
SetProperty(properties[i]);
}
bool MutableCSSPropertyValueSet::AddRespectingCascade(
const CSSPropertyValue& property) {
// Only add properties that have no !important counterpart present
if (!PropertyIsImportant(property.Id()) || property.IsImportant())
return SetProperty(property);
return false;
if (PropertyIsImportant(property.Id()) && !property.IsImportant())
return false;
SetProperty(property);
return true;
}
String CSSPropertyValueSet::AsText() const {
......
......@@ -227,7 +227,7 @@ class CORE_EXPORT MutableCSSPropertyValueSet : public CSSPropertyValueSet {
unsigned PropertyCount() const { return property_vector_.size(); }
// Returns whether this style set was changed.
bool AddParsedProperties(const HeapVector<CSSPropertyValue, 256>&);
void AddParsedProperties(const HeapVector<CSSPropertyValue, 256>&);
bool AddRespectingCascade(const CSSPropertyValue&);
struct SetResult {
......@@ -250,10 +250,10 @@ class CORE_EXPORT MutableCSSPropertyValueSet : public CSSPropertyValueSet {
void SetProperty(CSSPropertyID, const CSSValue&, bool important = false);
// These do not. FIXME: This is too messy, we can do better.
bool SetProperty(CSSPropertyID,
void SetProperty(CSSPropertyID,
CSSValueID identifier,
bool important = false);
bool SetProperty(const CSSPropertyValue&, CSSPropertyValue* slot = nullptr);
void SetProperty(const CSSPropertyValue&, CSSPropertyValue* slot = nullptr);
template <typename T> // CSSPropertyID or AtomicString
bool RemoveProperty(T property, String* return_text = nullptr);
......
......@@ -50,10 +50,9 @@ bool DOMWindowCSS::supports(const ExecutionContext* execution_context,
MutableCSSPropertyValueSet::Create(kHTMLStandardMode);
bool is_animation_tainted = false;
return CSSParser::ParseValueForCustomProperty(
dummy_style, "--valid", nullptr, value, false,
execution_context->GetSecureContextMode(), nullptr,
is_animation_tainted)
.did_parse;
dummy_style, "--valid", nullptr, value, false,
execution_context->GetSecureContextMode(), nullptr,
is_animation_tainted);
}
#if DCHECK_IS_ON()
......@@ -65,8 +64,7 @@ bool DOMWindowCSS::supports(const ExecutionContext* execution_context,
MutableCSSPropertyValueSet* dummy_style =
MutableCSSPropertyValueSet::Create(kHTMLStandardMode);
return CSSParser::ParseValue(dummy_style, unresolved_property, value, false,
execution_context->GetSecureContextMode())
.did_parse;
execution_context->GetSecureContextMode());
}
bool DOMWindowCSS::supports(const ExecutionContext* execution_context,
......
......@@ -81,28 +81,24 @@ void CSSParser::ParseSheetForInspector(const CSSParserContext* context,
observer);
}
MutableCSSPropertyValueSet::SetResult CSSParser::ParseValue(
MutableCSSPropertyValueSet* declaration,
CSSPropertyID unresolved_property,
const String& string,
bool important,
SecureContextMode secure_context_mode) {
bool CSSParser::ParseValue(MutableCSSPropertyValueSet* declaration,
CSSPropertyID unresolved_property,
const String& string,
bool important,
SecureContextMode secure_context_mode) {
return ParseValue(declaration, unresolved_property, string, important,
secure_context_mode,
static_cast<StyleSheetContents*>(nullptr));
}
MutableCSSPropertyValueSet::SetResult CSSParser::ParseValue(
MutableCSSPropertyValueSet* declaration,
CSSPropertyID unresolved_property,
const String& string,
bool important,
SecureContextMode secure_context_mode,
StyleSheetContents* style_sheet) {
bool CSSParser::ParseValue(MutableCSSPropertyValueSet* declaration,
CSSPropertyID unresolved_property,
const String& string,
bool important,
SecureContextMode secure_context_mode,
StyleSheetContents* style_sheet) {
if (string.IsEmpty()) {
bool did_parse = false;
bool did_change = false;
return MutableCSSPropertyValueSet::SetResult{did_parse, did_change};
return false;
}
CSSPropertyID resolved_property = resolveCSSPropertyID(unresolved_property);
......@@ -110,10 +106,9 @@ MutableCSSPropertyValueSet::SetResult CSSParser::ParseValue(
CSSValue* value = CSSParserFastPaths::MaybeParseValue(resolved_property,
string, parser_mode);
if (value) {
bool did_parse = true;
bool did_change = declaration->SetProperty(CSSPropertyValue(
declaration->SetProperty(CSSPropertyValue(
CSSProperty::Get(resolved_property), *value, important));
return MutableCSSPropertyValueSet::SetResult{did_parse, did_change};
return true;
}
CSSParserContext* context;
if (style_sheet) {
......@@ -126,7 +121,7 @@ MutableCSSPropertyValueSet::SetResult CSSParser::ParseValue(
context);
}
MutableCSSPropertyValueSet::SetResult CSSParser::ParseValueForCustomProperty(
bool CSSParser::ParseValueForCustomProperty(
MutableCSSPropertyValueSet* declaration,
const AtomicString& property_name,
const PropertyRegistry* registry,
......@@ -137,9 +132,7 @@ MutableCSSPropertyValueSet::SetResult CSSParser::ParseValueForCustomProperty(
bool is_animation_tainted) {
DCHECK(CSSVariableParser::IsValidVariableName(property_name));
if (value.IsEmpty()) {
bool did_parse = false;
bool did_change = false;
return MutableCSSPropertyValueSet::SetResult{did_parse, did_change};
return false;
}
CSSParserMode parser_mode = declaration->CssParserMode();
CSSParserContext* context;
......@@ -154,12 +147,11 @@ MutableCSSPropertyValueSet::SetResult CSSParser::ParseValueForCustomProperty(
is_animation_tainted);
}
MutableCSSPropertyValueSet::SetResult CSSParser::ParseValue(
MutableCSSPropertyValueSet* declaration,
CSSPropertyID unresolved_property,
const String& string,
bool important,
const CSSParserContext* context) {
bool CSSParser::ParseValue(MutableCSSPropertyValueSet* declaration,
CSSPropertyID unresolved_property,
const String& string,
bool important,
const CSSParserContext* context) {
return CSSParserImpl::ParseValue(declaration, unresolved_property, string,
important, context);
}
......
......@@ -47,29 +47,26 @@ class CORE_EXPORT CSSParser {
MutableCSSPropertyValueSet*,
const String&);
static MutableCSSPropertyValueSet::SetResult ParseValue(
MutableCSSPropertyValueSet*,
CSSPropertyID unresolved_property,
const String&,
bool important,
SecureContextMode);
static MutableCSSPropertyValueSet::SetResult ParseValue(
MutableCSSPropertyValueSet*,
CSSPropertyID unresolved_property,
const String&,
bool important,
SecureContextMode,
StyleSheetContents*);
static MutableCSSPropertyValueSet::SetResult ParseValueForCustomProperty(
MutableCSSPropertyValueSet*,
const AtomicString& property_name,
const PropertyRegistry*,
const String& value,
bool important,
SecureContextMode,
StyleSheetContents*,
bool is_animation_tainted);
static bool ParseValue(MutableCSSPropertyValueSet*,
CSSPropertyID unresolved_property,
const String&,
bool important,
SecureContextMode);
static bool ParseValue(MutableCSSPropertyValueSet*,
CSSPropertyID unresolved_property,
const String&,
bool important,
SecureContextMode,
StyleSheetContents*);
static bool ParseValueForCustomProperty(MutableCSSPropertyValueSet*,
const AtomicString& property_name,
const PropertyRegistry*,
const String& value,
bool important,
SecureContextMode,
StyleSheetContents*,
bool is_animation_tainted);
// This is for non-shorthands only
static const CSSValue* ParseSingleValue(CSSPropertyID,
......@@ -104,12 +101,11 @@ class CORE_EXPORT CSSParser {
CSSParserObserver&);
private:
static MutableCSSPropertyValueSet::SetResult ParseValue(
MutableCSSPropertyValueSet*,
CSSPropertyID unresolved_property,
const String&,
bool important,
const CSSParserContext*);
static bool ParseValue(MutableCSSPropertyValueSet*,
CSSPropertyID unresolved_property,
const String&,
bool important,
const CSSParserContext*);
};
} // namespace blink
......
......@@ -65,12 +65,11 @@ CSSParserImpl::CSSParserImpl(const CSSParserContext* context,
StyleSheetContents* style_sheet)
: context_(context), style_sheet_(style_sheet), observer_(nullptr) {}
MutableCSSPropertyValueSet::SetResult CSSParserImpl::ParseValue(
MutableCSSPropertyValueSet* declaration,
CSSPropertyID unresolved_property,
const String& string,
bool important,
const CSSParserContext* context) {
bool CSSParserImpl::ParseValue(MutableCSSPropertyValueSet* declaration,
CSSPropertyID unresolved_property,
const String& string,
bool important,
const CSSParserContext* context) {
CSSParserImpl parser(context);
StyleRule::RuleType rule_type = StyleRule::kStyle;
if (declaration->CssParserMode() == kCSSViewportRuleMode)
......@@ -81,23 +80,20 @@ MutableCSSPropertyValueSet::SetResult CSSParserImpl::ParseValue(
// TODO(crbug.com/661854): Use streams instead of ranges
parser.ConsumeDeclarationValue(CSSParserTokenRange(tokenizer.TokenizeToEOF()),
unresolved_property, important, rule_type);
bool did_parse = false;
bool did_change = false;
if (!parser.parsed_properties_.IsEmpty()) {
did_parse = true;
did_change = declaration->AddParsedProperties(parser.parsed_properties_);
if (parser.parsed_properties_.IsEmpty()) {
return false;
}
return MutableCSSPropertyValueSet::SetResult{did_parse, did_change};
declaration->AddParsedProperties(parser.parsed_properties_);
return true;
}
MutableCSSPropertyValueSet::SetResult CSSParserImpl::ParseVariableValue(
MutableCSSPropertyValueSet* declaration,
const AtomicString& property_name,
const PropertyRegistry* registry,
const String& value,
bool important,
const CSSParserContext* context,
bool is_animation_tainted) {
bool CSSParserImpl::ParseVariableValue(MutableCSSPropertyValueSet* declaration,
const AtomicString& property_name,
const PropertyRegistry* registry,
const String& value,
bool important,
const CSSParserContext* context,
bool is_animation_tainted) {
CSSParserImpl parser(context);
CSSTokenizer tokenizer(value);
// TODO(crbug.com/661854): Use streams instead of ranges
......@@ -105,25 +101,23 @@ MutableCSSPropertyValueSet::SetResult CSSParserImpl::ParseVariableValue(
const CSSParserTokenRange range(tokens);
parser.ConsumeVariableValue(range, property_name, important,
is_animation_tainted);
bool did_parse = false;
bool did_change = false;
if (!parser.parsed_properties_.IsEmpty()) {
const CSSCustomPropertyDeclaration* parsed_declaration =
ToCSSCustomPropertyDeclaration(parser.parsed_properties_[0].Value());
if (parsed_declaration->Value() && registry) {
const PropertyRegistration* registration =
registry->Registration(property_name);
// TODO(timloh): This is a bit wasteful, we parse the registered property
// to validate but throw away the result.
if (registration &&
!registration->Syntax().Parse(range, context, is_animation_tainted)) {
return MutableCSSPropertyValueSet::SetResult{did_parse, did_change};
}
if (parser.parsed_properties_.IsEmpty())
return false;
const CSSCustomPropertyDeclaration* parsed_declaration =
ToCSSCustomPropertyDeclaration(parser.parsed_properties_[0].Value());
if (parsed_declaration->Value() && registry) {
const PropertyRegistration* registration =
registry->Registration(property_name);
// TODO(timloh): This is a bit wasteful, we parse the registered property
// to validate but throw away the result.
if (registration &&
!registration->Syntax().Parse(range, context, is_animation_tainted)) {
return false;
}
did_parse = true;
did_change = declaration->AddParsedProperties(parser.parsed_properties_);
}
return MutableCSSPropertyValueSet::SetResult{did_parse, did_change};
declaration->AddParsedProperties(parser.parsed_properties_);
return true;
}
static inline void FilterProperties(
......@@ -216,7 +210,8 @@ bool CSSParserImpl::ParseDeclarationList(
seen_properties, seen_custom_properties);
if (unused_entries)
results.EraseAt(0, unused_entries);
return declaration->AddParsedProperties(results);
declaration->AddParsedProperties(results);
return true;
}
StyleRuleBase* CSSParserImpl::ParseRule(const String& string,
......
......@@ -71,20 +71,18 @@ class CSSParserImpl {
static RangeOffset Ignore() { return {0, 0}; }
};
static MutableCSSPropertyValueSet::SetResult ParseValue(
MutableCSSPropertyValueSet*,
CSSPropertyID,
const String&,
bool important,
const CSSParserContext*);
static MutableCSSPropertyValueSet::SetResult ParseVariableValue(
MutableCSSPropertyValueSet*,
const AtomicString& property_name,
const PropertyRegistry*,
const String&,
bool important,
const CSSParserContext*,
bool is_animation_tainted);
static bool ParseValue(MutableCSSPropertyValueSet*,
CSSPropertyID,
const String&,
bool important,
const CSSParserContext*);
static bool ParseVariableValue(MutableCSSPropertyValueSet*,
const AtomicString& property_name,
const PropertyRegistry*,
const String&,
bool important,
const CSSParserContext*,
bool is_animation_tainted);
static ImmutableCSSPropertyValueSet* ParseInlineStyleDeclaration(
const String&,
Element*);
......
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