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

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
« no previous file with comments | « third_party/WebKit/Source/core/css/StylePropertySet.h ('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/StylePropertySet.cpp
diff --git a/third_party/WebKit/Source/core/css/StylePropertySet.cpp b/third_party/WebKit/Source/core/css/StylePropertySet.cpp
index 04da3ec817a457dbd5b40ff50f6c7899b34ec82f..028481bd125fcf8cdcf9fd22bd9a1a75b0c3ba7b 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 && !customPropertyName.isNull()) {
+ // TODO(shanestephens): fix call sites so we always have a customPropertyName
+ // here.
+ foundPropertyIndex = findPropertyIndex(customPropertyName);
+ } else {
+ ASSERT(customPropertyName.isNull());
+ foundPropertyIndex = findPropertyIndex(propertyID);
+ }
if (foundPropertyIndex == -1)
return nullptr;
return &m_propertyVector.at(foundPropertyIndex);
« no previous file with comments | « third_party/WebKit/Source/core/css/StylePropertySet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698