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

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

Issue 1094003002: CSSStyleDeclaration::setProperty should override important style (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase and added doctype to test Created 5 years, 8 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
« no previous file with comments | « LayoutTests/fast/css/important-js-override-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/StylePropertySet.cpp
diff --git a/Source/core/css/StylePropertySet.cpp b/Source/core/css/StylePropertySet.cpp
index 310c2a543c87b6d3dad8f560b3fe8410f56ad5d3..364b46a2414787fa4bd19b7174da5ab13387b3c0 100644
--- a/Source/core/css/StylePropertySet.cpp
+++ b/Source/core/css/StylePropertySet.cpp
@@ -269,6 +269,17 @@ void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, PassRefPtrWi
m_propertyVector.append(CSSProperty(shorthand.properties()[i], value, important));
}
+unsigned getIndexInShorthandVectorForPrefixingVariant(const CSSProperty& property, CSSPropertyID prefixingVariant)
sashab 2015/04/23 05:04:32 This function existed before, but has been deleted
+{
+ if (!property.isSetFromShorthand())
+ return 0;
+
+ CSSPropertyID prefixedShorthand = prefixingVariantForPropertyId(property.shorthandID());
+ Vector<StylePropertyShorthand, 4> shorthands;
+ getMatchingShorthandsForLonghand(prefixingVariant, &shorthands);
+ return indexOfShorthandForLonghand(prefixedShorthand, shorthands);
+}
+
bool MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot)
{
if (!removeShorthandProperty(property.id())) {
@@ -276,7 +287,13 @@ bool MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProper
if (toReplace && *toReplace == property)
return false;
if (toReplace) {
- *toReplace = property;
+ // Clear the important flag if the new property is not important
+ if (toReplace->isImportant() && !property.isImportant()) {
+ *toReplace = CSSProperty(property.id(), property.value(), false, property.isSetFromShorthand(), getIndexInShorthandVectorForPrefixingVariant(property, prefixingVariantForPropertyId(property.id())), property.metadata().m_implicit);
+ } else {
+ *toReplace = property;
+ }
+ setPrefixingVariantProperty(property);
return true;
}
}
@@ -314,10 +331,7 @@ bool MutableStylePropertySet::addParsedProperties(const WillBeHeapVector<CSSProp
bool MutableStylePropertySet::addParsedProperty(const CSSProperty& property)
{
- // Only add properties that have no !important counterpart present
- if (!propertyIsImportant(property.id()) || property.isImportant())
- return setProperty(property);
- return false;
+ return setProperty(property);
}
String StylePropertySet::asText() const
« no previous file with comments | « LayoutTests/fast/css/important-js-override-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698