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

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

Issue 2607403002: Disallow setting invalid values for registered properties via CSSOM (Closed)
Patch Set: fix comments Created 3 years, 11 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 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All
4 * rights reserved. 4 * rights reserved.
5 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. 5 * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 const String& propertyName) { 228 const String& propertyName) {
229 CSSPropertyID propertyID = cssPropertyID(propertyName); 229 CSSPropertyID propertyID = cssPropertyID(propertyName);
230 230
231 // Custom properties don't have shorthands, so we can ignore them here. 231 // Custom properties don't have shorthands, so we can ignore them here.
232 if (!propertyID || propertyID == CSSPropertyVariable) 232 if (!propertyID || propertyID == CSSPropertyVariable)
233 return false; 233 return false;
234 return propertySet().isPropertyImplicit(propertyID); 234 return propertySet().isPropertyImplicit(propertyID);
235 } 235 }
236 236
237 void AbstractPropertySetCSSStyleDeclaration::setProperty( 237 void AbstractPropertySetCSSStyleDeclaration::setProperty(
238 const ExecutionContext* executionContext,
238 const String& propertyName, 239 const String& propertyName,
239 const String& value, 240 const String& value,
240 const String& priority, 241 const String& priority,
241 ExceptionState& exceptionState) { 242 ExceptionState& exceptionState) {
242 CSSPropertyID propertyID = unresolvedCSSPropertyID(propertyName); 243 CSSPropertyID propertyID = unresolvedCSSPropertyID(propertyName);
243 if (!propertyID) 244 if (!propertyID)
244 return; 245 return;
245 246
246 bool important = equalIgnoringCase(priority, "important"); 247 bool important = equalIgnoringCase(priority, "important");
247 if (!important && !priority.isEmpty()) 248 if (!important && !priority.isEmpty())
248 return; 249 return;
249 250
250 setPropertyInternal(propertyID, propertyName, value, important, 251 setPropertyInternal(propertyID, propertyName, value, important,
251 exceptionState); 252 executionContext, exceptionState);
252 } 253 }
253 254
254 String AbstractPropertySetCSSStyleDeclaration::removeProperty( 255 String AbstractPropertySetCSSStyleDeclaration::removeProperty(
255 const String& propertyName, 256 const String& propertyName,
256 ExceptionState& exceptionState) { 257 ExceptionState& exceptionState) {
257 CSSPropertyID propertyID = cssPropertyID(propertyName); 258 CSSPropertyID propertyID = cssPropertyID(propertyName);
258 if (!propertyID) 259 if (!propertyID)
259 return String(); 260 return String();
260 261
261 StyleAttributeMutationScope mutationScope(this); 262 StyleAttributeMutationScope mutationScope(this);
(...skipping 29 matching lines...) Expand all
291 CSSPropertyID propertyID) { 292 CSSPropertyID propertyID) {
292 return propertySet().getPropertyValue(propertyID); 293 return propertySet().getPropertyValue(propertyID);
293 } 294 }
294 295
295 DISABLE_CFI_PERF 296 DISABLE_CFI_PERF
296 void AbstractPropertySetCSSStyleDeclaration::setPropertyInternal( 297 void AbstractPropertySetCSSStyleDeclaration::setPropertyInternal(
297 CSSPropertyID unresolvedProperty, 298 CSSPropertyID unresolvedProperty,
298 const String& customPropertyName, 299 const String& customPropertyName,
299 const String& value, 300 const String& value,
300 bool important, 301 bool important,
302 const ExecutionContext* executionContext,
301 ExceptionState&) { 303 ExceptionState&) {
302 StyleAttributeMutationScope mutationScope(this); 304 StyleAttributeMutationScope mutationScope(this);
303 willMutate(); 305 willMutate();
304 306
305 bool didChange = false; 307 bool didChange = false;
306 if (unresolvedProperty == CSSPropertyVariable) { 308 if (unresolvedProperty == CSSPropertyVariable) {
309 AtomicString atomicName(customPropertyName);
310
311 DCHECK(executionContext);
312 const PropertyRegistry* registry =
313 toDocument(executionContext)->propertyRegistry();
314
307 bool isAnimationTainted = isKeyframeStyle(); 315 bool isAnimationTainted = isKeyframeStyle();
308 didChange = 316 didChange = propertySet()
309 propertySet() 317 .setProperty(atomicName, registry, value, important,
310 .setProperty(AtomicString(customPropertyName), value, important, 318 contextStyleSheet(), isAnimationTainted)
311 contextStyleSheet(), isAnimationTainted) 319 .didChange;
312 .didChange;
313 } else { 320 } else {
314 didChange = propertySet() 321 didChange = propertySet()
315 .setProperty(unresolvedProperty, value, important, 322 .setProperty(unresolvedProperty, value, important,
316 contextStyleSheet()) 323 contextStyleSheet())
317 .didChange; 324 .didChange;
318 } 325 }
319 326
320 didMutate(didChange ? PropertyChanged : NoChanges); 327 didMutate(didChange ? PropertyChanged : NoChanges);
321 328
322 if (!didChange) 329 if (!didChange)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return m_parentElement ? &m_parentElement->document().elementSheet() 410 return m_parentElement ? &m_parentElement->document().elementSheet()
404 : nullptr; 411 : nullptr;
405 } 412 }
406 413
407 DEFINE_TRACE(InlineCSSStyleDeclaration) { 414 DEFINE_TRACE(InlineCSSStyleDeclaration) {
408 visitor->trace(m_parentElement); 415 visitor->trace(m_parentElement);
409 AbstractPropertySetCSSStyleDeclaration::trace(visitor); 416 AbstractPropertySetCSSStyleDeclaration::trace(visitor);
410 } 417 }
411 418
412 } // namespace blink 419 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698