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

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 again 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..2b70616ac4e0246e6aff6539e43c58cd1b65ff6b 100644
--- a/Source/core/css/StylePropertySet.cpp
+++ b/Source/core/css/StylePropertySet.cpp
@@ -269,6 +269,16 @@ void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, PassRefPtrWi
m_propertyVector.append(CSSProperty(shorthand.properties()[i], value, important));
}
+unsigned getIndexInShorthandVector(const CSSProperty& property)
+{
+ if (!property.isSetFromShorthand())
+ return 0;
+
+ Vector<StylePropertyShorthand, 4> shorthands;
+ getMatchingShorthandsForLonghand(property.id(), &shorthands);
+ return indexOfShorthandForLonghand(property.id(), shorthands);
+}
+
bool MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot)
{
if (!removeShorthandProperty(property.id())) {
@@ -276,7 +286,12 @@ 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 (!property.isImportant() && toReplace->isImportant()) {
+ *toReplace = CSSProperty(property.id(), property.value(), false, property.isSetFromShorthand(), getIndexInShorthandVector(property), property.metadata().m_implicit);
Timothy Loh 2015/04/23 05:42:03 Isn't this just the same as the other branch?
sashab 2015/04/23 05:59:05 Oh, nice. Good point :D
+ } else {
+ *toReplace = property;
+ }
return true;
}
}
@@ -314,10 +329,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