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

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

Issue 1697233003: Allow custom property variant of setProperty to find existing references (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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: third_party/WebKit/Source/core/css/StylePropertySet.cpp
diff --git a/third_party/WebKit/Source/core/css/StylePropertySet.cpp b/third_party/WebKit/Source/core/css/StylePropertySet.cpp
index 04da3ec817a457dbd5b40ff50f6c7899b34ec82f..15112186434f8676acf77d592c89fa94afa9c394 100644
--- a/third_party/WebKit/Source/core/css/StylePropertySet.cpp
+++ b/third_party/WebKit/Source/core/css/StylePropertySet.cpp
@@ -342,7 +342,9 @@ void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, PassRefPtrWi
bool MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProperty* slot)
{
if (!removeShorthandProperty(property.id())) {
- CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id());
+ const AtomicString& name = (property.id() == CSSPropertyVariable) ?
+ toCSSCustomPropertyDeclaration(property.value())->name() : nullAtom;
+ CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id(), name);
if (toReplace && *toReplace == property)
return false;
if (toReplace) {
@@ -455,15 +457,17 @@ bool MutableStylePropertySet::removePropertiesInSet(const CSSPropertyID* set, un
return false;
}
-CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(CSSPropertyID propertyID)
+CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(CSSPropertyID propertyID, const AtomicString& customPropertyName)
{
- // TODO(leviw): Calling this with a custom property should probably assert, or this
- // method should alternatively take a string used for custom properties and check it
- // in that case.
- if (propertyID == CSSPropertyVariable)
- return nullptr;
-
- int foundPropertyIndex = findPropertyIndex(propertyID);
+ int foundPropertyIndex = -1;
+ if (propertyID == CSSPropertyVariable) {
+ ASSERT(customPropertyName != nullAtom);
Timothy Loh 2016/02/16 23:49:39 !x.isNull() maybe
shans 2016/02/17 02:41:35 Done.
+ foundPropertyIndex = findPropertyIndex(customPropertyName);
+ // TODO(shanestephens): fix call sites so we always have a customPropertyName
+ // here.
+ } else if (customPropertyName != nullAtom) {
Timothy Loh 2016/02/16 23:49:39 Isn't this backwards - when we have a regular prop
shans 2016/02/17 02:41:35 uh .. yeah.
+ foundPropertyIndex = findPropertyIndex(propertyID);
+ }
if (foundPropertyIndex == -1)
return nullptr;
return &m_propertyVector.at(foundPropertyIndex);

Powered by Google App Engine
This is Rietveld 408576698