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

Unified Diff: Source/core/css/CSSParser.cpp

Issue 16161005: Reduce CSSProperty's StylePropertyMetadata memory footprint by half when used inside a ImmutableSty… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 months 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
Index: Source/core/css/CSSParser.cpp
diff --git a/Source/core/css/CSSParser.cpp b/Source/core/css/CSSParser.cpp
index 431d6c3fb9d44d839c7e62002fbc49ce1104cd74..82502e5e1f7a32dc43138a4621c1e349486bb67f 100644
--- a/Source/core/css/CSSParser.cpp
+++ b/Source/core/css/CSSParser.cpp
@@ -1415,12 +1415,32 @@ void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr
CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId);
if (prefixingVariant == propId)
return;
- addProperty(prefixingVariant, val.release(), important, implicit);
+
+ if (m_currentShorthand) {
+ // We can't use ShorthandScope here as we can already be inside one (e.g we are parsing CSSTransition).
+ m_currentShorthand = prefixingVariantForPropertyId(m_currentShorthand);
+ addProperty(prefixingVariant, val.release(), important, implicit);
+ m_currentShorthand = prefixingVariantForPropertyId(m_currentShorthand);
Julien - ping for review 2013/06/10 23:29:57 Do we really need to reset m_currentShorthand befo
+ } else {
+ addProperty(prefixingVariant, val.release(), important, implicit);
+ }
}
void CSSParser::addProperty(CSSPropertyID propId, PassRefPtr<CSSValue> value, bool important, bool implicit)
{
- m_parsedProperties.append(CSSProperty(propId, value, important, m_currentShorthand, m_implicitShorthand || implicit));
+ CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimitiveValue(value.get()) : 0;
+ // This property doesn't belong to a shorthand or is a CSS variable (which will be resolved later).
+ if (!m_currentShorthand || (primitiveValue && primitiveValue->isVariableName())) {
+ m_parsedProperties.append(CSSProperty(propId, value, important, false, CSSPropertyInvalid, m_implicitShorthand || implicit));
+ return;
+ }
+
+ const Vector<StylePropertyShorthand> shorthands = matchingShorthandsForLonghand(propId);
+ // The longhand does not belong to multiple shorthands.
+ if (shorthands.size() == 1)
+ m_parsedProperties.append(CSSProperty(propId, value, important, true, CSSPropertyInvalid, m_implicitShorthand || implicit));
+ else
+ m_parsedProperties.append(CSSProperty(propId, value, important, true, indexOfShorthandForLonghand(m_currentShorthand, shorthands), m_implicitShorthand || implicit));
}
void CSSParser::rollbackLastProperties(int num)

Powered by Google App Engine
This is Rietveld 408576698