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

Side by Side Diff: third_party/WebKit/Source/core/css/PropertySetCSSStyleDeclaration.cpp

Issue 1455053003: Custom property CSSOM patch with templates [not for landing] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_levisPatch
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 mutationScope.enqueueMutationRecord(); 175 mutationScope.enqueueMutationRecord();
176 } 176 }
177 177
178 String AbstractPropertySetCSSStyleDeclaration::getPropertyValue(const String& pr opertyName) 178 String AbstractPropertySetCSSStyleDeclaration::getPropertyValue(const String& pr opertyName)
179 { 179 {
180 CSSPropertyID propertyID = cssPropertyID(propertyName); 180 CSSPropertyID propertyID = cssPropertyID(propertyName);
181 if (!propertyID) { 181 if (!propertyID) {
182 if (!RuntimeEnabledFeatures::cssVariablesEnabled() || !CSSVariableParser ::isValidVariableName(propertyName)) 182 if (!RuntimeEnabledFeatures::cssVariablesEnabled() || !CSSVariableParser ::isValidVariableName(propertyName))
183 return String(); 183 return String();
184 return propertySet().getCustomPropertyValue(AtomicString(propertyName)); 184 return propertySet().getPropertyValue(AtomicString(propertyName));
185 } 185 }
186 return propertySet().getPropertyValue(propertyID); 186 return propertySet().getPropertyValue(propertyID);
187 } 187 }
188 188
189 String AbstractPropertySetCSSStyleDeclaration::getPropertyPriority(const String& propertyName) 189 String AbstractPropertySetCSSStyleDeclaration::getPropertyPriority(const String& propertyName)
190 { 190 {
191 bool important = false;
191 CSSPropertyID propertyID = cssPropertyID(propertyName); 192 CSSPropertyID propertyID = cssPropertyID(propertyName);
192 if (!propertyID) { 193 if (!propertyID) {
193 if (!RuntimeEnabledFeatures::cssVariablesEnabled() || !CSSVariableParser ::isValidVariableName(propertyName)) 194 if (!RuntimeEnabledFeatures::cssVariablesEnabled() || !CSSVariableParser ::isValidVariableName(propertyName))
194 return String(); 195 return String();
195 return propertySet().customPropertyIsImportant(AtomicString(propertyName )) ? "important" : ""; 196 important = propertySet().propertyIsImportant(AtomicString(propertyName) );
197 } else {
198 important = propertySet().propertyIsImportant(propertyID);
196 } 199 }
197 return propertySet().propertyIsImportant(propertyID) ? "important" : ""; 200 return important ? "important" : "";
198 } 201 }
199 202
200 String AbstractPropertySetCSSStyleDeclaration::getPropertyShorthand(const String & propertyName) 203 String AbstractPropertySetCSSStyleDeclaration::getPropertyShorthand(const String & propertyName)
201 { 204 {
202 CSSPropertyID propertyID = cssPropertyID(propertyName); 205 CSSPropertyID propertyID = cssPropertyID(propertyName);
203 206
204 // Custom properties don't have shorthands, so we can ignore them here. 207 // Custom properties don't have shorthands, so we can ignore them here.
205 if (!propertyID) 208 if (!propertyID)
206 return String(); 209 return String();
207 CSSPropertyID shorthandID = propertySet().getPropertyShorthand(propertyID); 210 CSSPropertyID shorthandID = propertySet().getPropertyShorthand(propertyID);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 if (!propertyID) { 245 if (!propertyID) {
243 if (!RuntimeEnabledFeatures::cssVariablesEnabled() || !CSSVariableParser ::isValidVariableName(propertyName)) 246 if (!RuntimeEnabledFeatures::cssVariablesEnabled() || !CSSVariableParser ::isValidVariableName(propertyName))
244 return String(); 247 return String();
245 propertyID = CSSPropertyVariable; 248 propertyID = CSSPropertyVariable;
246 } 249 }
247 250
248 StyleAttributeMutationScope mutationScope(this); 251 StyleAttributeMutationScope mutationScope(this);
249 willMutate(); 252 willMutate();
250 253
251 String result; 254 String result;
252 bool changed = propertyID == CSSPropertyVariable ? propertySet().removeCusto mProperty(AtomicString(propertyName), &result) 255 bool changed = false;
253 : propertySet().removeProperty(propertyID, &result); 256 if (propertyID == CSSPropertyVariable)
257 changed = propertySet().removeProperty(AtomicString(propertyName), &resu lt);
258 else
259 changed = propertySet().removeProperty(propertyID, &result);
254 260
255 didMutate(changed ? PropertyChanged : NoChanges); 261 didMutate(changed ? PropertyChanged : NoChanges);
256 262
257 if (changed) 263 if (changed)
258 mutationScope.enqueueMutationRecord(); 264 mutationScope.enqueueMutationRecord();
259 return result; 265 return result;
260 } 266 }
261 267
262 PassRefPtrWillBeRawPtr<CSSValue> AbstractPropertySetCSSStyleDeclaration::getProp ertyCSSValueInternal(CSSPropertyID propertyID) 268 PassRefPtrWillBeRawPtr<CSSValue> AbstractPropertySetCSSStyleDeclaration::getProp ertyCSSValueInternal(CSSPropertyID propertyID)
263 { 269 {
264 return propertySet().getPropertyCSSValue(propertyID); 270 return propertySet().getPropertyCSSValue(propertyID);
265 } 271 }
266 272
267 String AbstractPropertySetCSSStyleDeclaration::getPropertyValueInternal(CSSPrope rtyID propertyID) 273 String AbstractPropertySetCSSStyleDeclaration::getPropertyValueInternal(CSSPrope rtyID propertyID)
268 { 274 {
269 return propertySet().getPropertyValue(propertyID); 275 return propertySet().getPropertyValue(propertyID);
270 } 276 }
271 277
272 void AbstractPropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID u nresolvedProperty, const String& propertyName, const String& value, bool importa nt, ExceptionState&) 278 void AbstractPropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID u nresolvedProperty, const String& customPropertyName, const String& value, bool i mportant, ExceptionState&)
273 { 279 {
274 StyleAttributeMutationScope mutationScope(this); 280 StyleAttributeMutationScope mutationScope(this);
275 willMutate(); 281 willMutate();
276 282
277 bool changed = unresolvedProperty == CSSPropertyVariable ? propertySet().set CustomProperty(AtomicString(propertyName), value, important, contextStyleSheet() ) 283 bool changed = false;
278 : propertySet().setProperty(unresolvedProperty, value, important, contex tStyleSheet()); 284 if (unresolvedProperty == CSSPropertyVariable)
285 changed = propertySet().setProperty(AtomicString(customPropertyName), va lue, important, contextStyleSheet());
286 else
287 changed = propertySet().setProperty(unresolvedProperty, value, important , contextStyleSheet());
279 288
280 didMutate(changed ? PropertyChanged : NoChanges); 289 didMutate(changed ? PropertyChanged : NoChanges);
281 290
282 if (!changed) 291 if (!changed)
283 return; 292 return;
284 293
285 Element* parent = parentElement(); 294 Element* parent = parentElement();
286 if (parent && parent->inActiveDocument() && parent->document().styleResolver ()) 295 if (parent && parent->inActiveDocument() && parent->document().styleResolver ())
287 parent->document().styleEngine().attributeChangedForElement(HTMLNames::s tyleAttr, *parent); 296 parent->document().styleEngine().attributeChangedForElement(HTMLNames::s tyleAttr, *parent);
288 mutationScope.enqueueMutationRecord(); 297 mutationScope.enqueueMutationRecord();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 } 417 }
409 #endif 418 #endif
410 419
411 DEFINE_TRACE(InlineCSSStyleDeclaration) 420 DEFINE_TRACE(InlineCSSStyleDeclaration)
412 { 421 {
413 visitor->trace(m_parentElement); 422 visitor->trace(m_parentElement);
414 AbstractPropertySetCSSStyleDeclaration::trace(visitor); 423 AbstractPropertySetCSSStyleDeclaration::trace(visitor);
415 } 424 }
416 425
417 } // namespace blink 426 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698