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

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

Issue 2288633002: Recognise variable names when parsing CSS property names (Closed)
Patch Set: fix long var names Created 4 years, 3 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 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 10 matching lines...) Expand all
21 21
22 #include "core/css/PropertySetCSSStyleDeclaration.h" 22 #include "core/css/PropertySetCSSStyleDeclaration.h"
23 23
24 #include "bindings/core/v8/ExceptionState.h" 24 #include "bindings/core/v8/ExceptionState.h"
25 #include "core/HTMLNames.h" 25 #include "core/HTMLNames.h"
26 #include "core/StylePropertyShorthand.h" 26 #include "core/StylePropertyShorthand.h"
27 #include "core/css/CSSCustomPropertyDeclaration.h" 27 #include "core/css/CSSCustomPropertyDeclaration.h"
28 #include "core/css/CSSKeyframesRule.h" 28 #include "core/css/CSSKeyframesRule.h"
29 #include "core/css/CSSStyleSheet.h" 29 #include "core/css/CSSStyleSheet.h"
30 #include "core/css/StylePropertySet.h" 30 #include "core/css/StylePropertySet.h"
31 #include "core/css/parser/CSSVariableParser.h"
32 #include "core/dom/Element.h" 31 #include "core/dom/Element.h"
33 #include "core/dom/MutationObserverInterestGroup.h" 32 #include "core/dom/MutationObserverInterestGroup.h"
34 #include "core/dom/MutationRecord.h" 33 #include "core/dom/MutationRecord.h"
35 #include "core/dom/StyleChangeReason.h" 34 #include "core/dom/StyleChangeReason.h"
36 #include "core/dom/StyleEngine.h" 35 #include "core/dom/StyleEngine.h"
37 #include "core/dom/custom/CustomElement.h" 36 #include "core/dom/custom/CustomElement.h"
38 #include "core/dom/custom/CustomElementDefinition.h" 37 #include "core/dom/custom/CustomElementDefinition.h"
39 #include "core/inspector/InspectorInstrumentation.h" 38 #include "core/inspector/InspectorInstrumentation.h"
40 #include "platform/RuntimeEnabledFeatures.h" 39 #include "platform/RuntimeEnabledFeatures.h"
41 40
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 propertySet().parseDeclarationList(text, contextStyleSheet()); 178 propertySet().parseDeclarationList(text, contextStyleSheet());
180 179
181 didMutate(PropertyChanged); 180 didMutate(PropertyChanged);
182 181
183 mutationScope.enqueueMutationRecord(); 182 mutationScope.enqueueMutationRecord();
184 } 183 }
185 184
186 String AbstractPropertySetCSSStyleDeclaration::getPropertyValue(const String& pr opertyName) 185 String AbstractPropertySetCSSStyleDeclaration::getPropertyValue(const String& pr opertyName)
187 { 186 {
188 CSSPropertyID propertyID = cssPropertyID(propertyName); 187 CSSPropertyID propertyID = cssPropertyID(propertyName);
189 if (!propertyID) { 188 if (!propertyID)
190 if (!CSSVariableParser::isValidVariableName(propertyName)) 189 return String();
191 return String(); 190 if (propertyID == CSSPropertyVariable)
192 return propertySet().getPropertyValue(AtomicString(propertyName)); 191 return propertySet().getPropertyValue(AtomicString(propertyName));
193 }
194 return propertySet().getPropertyValue(propertyID); 192 return propertySet().getPropertyValue(propertyID);
195 } 193 }
196 194
197 String AbstractPropertySetCSSStyleDeclaration::getPropertyPriority(const String& propertyName) 195 String AbstractPropertySetCSSStyleDeclaration::getPropertyPriority(const String& propertyName)
198 { 196 {
197 CSSPropertyID propertyID = cssPropertyID(propertyName);
198 if (!propertyID)
199 return String();
200
199 bool important = false; 201 bool important = false;
200 CSSPropertyID propertyID = cssPropertyID(propertyName); 202 if (propertyID == CSSPropertyVariable)
201 if (!propertyID) {
202 if (!CSSVariableParser::isValidVariableName(propertyName))
203 return String();
204 important = propertySet().propertyIsImportant(AtomicString(propertyName) ); 203 important = propertySet().propertyIsImportant(AtomicString(propertyName) );
205 } else { 204 else
206 important = propertySet().propertyIsImportant(propertyID); 205 important = propertySet().propertyIsImportant(propertyID);
207 }
208 return important ? "important" : ""; 206 return important ? "important" : "";
209 } 207 }
210 208
211 String AbstractPropertySetCSSStyleDeclaration::getPropertyShorthand(const String & propertyName) 209 String AbstractPropertySetCSSStyleDeclaration::getPropertyShorthand(const String & propertyName)
212 { 210 {
213 CSSPropertyID propertyID = cssPropertyID(propertyName); 211 CSSPropertyID propertyID = cssPropertyID(propertyName);
214 212
215 // Custom properties don't have shorthands, so we can ignore them here. 213 // Custom properties don't have shorthands, so we can ignore them here.
216 if (!propertyID) 214 if (!propertyID || propertyID == CSSPropertyVariable)
217 return String(); 215 return String();
218 if (isShorthandProperty(propertyID)) 216 if (isShorthandProperty(propertyID))
219 return String(); 217 return String();
220 CSSPropertyID shorthandID = propertySet().getPropertyShorthand(propertyID); 218 CSSPropertyID shorthandID = propertySet().getPropertyShorthand(propertyID);
221 if (!shorthandID) 219 if (!shorthandID)
222 return String(); 220 return String();
223 return getPropertyNameString(shorthandID); 221 return getPropertyNameString(shorthandID);
224 } 222 }
225 223
226 bool AbstractPropertySetCSSStyleDeclaration::isPropertyImplicit(const String& pr opertyName) 224 bool AbstractPropertySetCSSStyleDeclaration::isPropertyImplicit(const String& pr opertyName)
227 { 225 {
228 CSSPropertyID propertyID = cssPropertyID(propertyName); 226 CSSPropertyID propertyID = cssPropertyID(propertyName);
229 227
230 // Custom properties don't have shorthands, so we can ignore them here. 228 // Custom properties don't have shorthands, so we can ignore them here.
231 if (!propertyID) 229 if (!propertyID || propertyID == CSSPropertyVariable)
232 return false; 230 return false;
233 return propertySet().isPropertyImplicit(propertyID); 231 return propertySet().isPropertyImplicit(propertyID);
234 } 232 }
235 233
236 void AbstractPropertySetCSSStyleDeclaration::setProperty(const String& propertyN ame, const String& value, const String& priority, ExceptionState& exceptionState ) 234 void AbstractPropertySetCSSStyleDeclaration::setProperty(const String& propertyN ame, const String& value, const String& priority, ExceptionState& exceptionState )
237 { 235 {
238 CSSPropertyID propertyID = unresolvedCSSPropertyID(propertyName); 236 CSSPropertyID propertyID = unresolvedCSSPropertyID(propertyName);
239 if (!propertyID) { 237 if (!propertyID)
240 if (!CSSVariableParser::isValidVariableName(propertyName)) 238 return;
241 return;
242 propertyID = CSSPropertyVariable;
243 }
244 239
245 bool important = equalIgnoringCase(priority, "important"); 240 bool important = equalIgnoringCase(priority, "important");
246 if (!important && !priority.isEmpty()) 241 if (!important && !priority.isEmpty())
247 return; 242 return;
248 243
249 setPropertyInternal(propertyID, propertyName, value, important, exceptionSta te); 244 setPropertyInternal(propertyID, propertyName, value, important, exceptionSta te);
250 } 245 }
251 246
252 String AbstractPropertySetCSSStyleDeclaration::removeProperty(const String& prop ertyName, ExceptionState& exceptionState) 247 String AbstractPropertySetCSSStyleDeclaration::removeProperty(const String& prop ertyName, ExceptionState& exceptionState)
253 { 248 {
254 CSSPropertyID propertyID = cssPropertyID(propertyName); 249 CSSPropertyID propertyID = cssPropertyID(propertyName);
255 if (!propertyID) { 250 if (!propertyID)
256 if (!CSSVariableParser::isValidVariableName(propertyName)) 251 return String();
257 return String();
258 propertyID = CSSPropertyVariable;
259 }
260 252
261 StyleAttributeMutationScope mutationScope(this); 253 StyleAttributeMutationScope mutationScope(this);
262 willMutate(); 254 willMutate();
263 255
264 String result; 256 String result;
265 bool changed = false; 257 bool changed = false;
266 if (propertyID == CSSPropertyVariable) 258 if (propertyID == CSSPropertyVariable)
267 changed = propertySet().removeProperty(AtomicString(propertyName), &resu lt); 259 changed = propertySet().removeProperty(AtomicString(propertyName), &resu lt);
268 else 260 else
269 changed = propertySet().removeProperty(propertyID, &result); 261 changed = propertySet().removeProperty(propertyID, &result);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 return m_parentElement ? &m_parentElement->document().elementSheet() : nullp tr; 383 return m_parentElement ? &m_parentElement->document().elementSheet() : nullp tr;
392 } 384 }
393 385
394 DEFINE_TRACE(InlineCSSStyleDeclaration) 386 DEFINE_TRACE(InlineCSSStyleDeclaration)
395 { 387 {
396 visitor->trace(m_parentElement); 388 visitor->trace(m_parentElement);
397 AbstractPropertySetCSSStyleDeclaration::trace(visitor); 389 AbstractPropertySetCSSStyleDeclaration::trace(visitor);
398 } 390 }
399 391
400 } // namespace blink 392 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/DOMWindowCSS.cpp ('k') | third_party/WebKit/Source/core/css/cssom/CSSStyleValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698