Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp

Issue 1523243003: Apply inherited or initial value when custom property reference fails to resolve / parse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more better Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp b/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp
index a522dcc5fb07d0d812f1cade7946bf343588228f..b22cb6b06189b3cbcac827e7c11a614778ad57f5 100644
--- a/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp
@@ -8,6 +8,8 @@
#include "core/CSSPropertyNames.h"
#include "core/CSSValueKeywords.h"
#include "core/StyleBuilderFunctions.h"
+#include "core/StylePropertyShorthand.h"
+#include "core/css/CSSValuePool.h"
#include "core/css/CSSVariableData.h"
#include "core/css/CSSVariableReferenceValue.h"
#include "core/css/parser/CSSParserToken.h"
@@ -109,24 +111,36 @@ void CSSVariableResolver::resolveVariableReferencesFromTokens(CSSParserTokenRang
void CSSVariableResolver::resolveAndApplyVariableReferences(StyleResolverState& state, CSSPropertyID id, const CSSVariableReferenceValue& value)
{
+
// TODO(leviw): This should be a stack
CSSVariableResolver resolver(state.style()->variables());
Vector<CSSParserToken> tokens;
ResolutionState resolutionContext;
resolver.resolveVariableReferencesFromTokens(value.variableDataValue()->tokens(), tokens, resolutionContext);
- if (!resolutionContext.success)
- return;
- CSSParserContext context(HTMLStandardMode, 0);
+ if (resolutionContext.success) {
+ CSSParserContext context(HTMLStandardMode, 0);
- WillBeHeapVector<CSSProperty, 256> parsedProperties;
+ WillBeHeapVector<CSSProperty, 256> parsedProperties;
+
+ if (CSSPropertyParser::parseValue(id, false, CSSParserTokenRange(tokens), context, parsedProperties, StyleRule::Type::Style)) {
+ unsigned parsedPropertiesCount = parsedProperties.size();
+ for (unsigned i = 0; i < parsedPropertiesCount; ++i)
+ StyleBuilder::applyProperty(parsedProperties[i].id(), state, parsedProperties[i].value());
+ return;
+ }
+ }
- CSSPropertyParser::parseValue(id, false, CSSParserTokenRange(tokens), context, parsedProperties, StyleRule::Type::Style);
+ RefPtrWillBeRawPtr<CSSUnsetValue> unset = cssValuePool().createUnsetValue();
+ if (isShorthandProperty(id)) {
+ StylePropertyShorthand shorthand = shorthandForProperty(id);
+ for (unsigned i = 0; i < shorthand.length(); i++)
+ StyleBuilder::applyProperty(shorthand.properties()[i], state, unset.get());
+ return;
+ }
- unsigned parsedPropertiesCount = parsedProperties.size();
- for (unsigned i = 0; i < parsedPropertiesCount; ++i)
- StyleBuilder::applyProperty(parsedProperties[i].id(), state, parsedProperties[i].value());
+ StyleBuilder::applyProperty(id, state, unset.get());
}
void CSSVariableResolver::resolveVariableDefinitions(StyleVariableData* variables)
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698