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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/StylePropertySet.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
5 * Copyright (C) 2013 Intel Corporation. All rights reserved. 5 * Copyright (C) 2013 Intel Corporation. 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 removePropertiesInSet(shorthand.properties(), shorthand.length()); 335 removePropertiesInSet(shorthand.properties(), shorthand.length());
336 336
337 RefPtrWillBeRawPtr<CSSValue> value = prpValue; 337 RefPtrWillBeRawPtr<CSSValue> value = prpValue;
338 for (unsigned i = 0; i < shorthand.length(); ++i) 338 for (unsigned i = 0; i < shorthand.length(); ++i)
339 m_propertyVector.append(CSSProperty(shorthand.properties()[i], value, im portant)); 339 m_propertyVector.append(CSSProperty(shorthand.properties()[i], value, im portant));
340 } 340 }
341 341
342 bool MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProper ty* slot) 342 bool MutableStylePropertySet::setProperty(const CSSProperty& property, CSSProper ty* slot)
343 { 343 {
344 if (!removeShorthandProperty(property.id())) { 344 if (!removeShorthandProperty(property.id())) {
345 CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id ()); 345 const AtomicString& name = (property.id() == CSSPropertyVariable) ?
346 toCSSCustomPropertyDeclaration(property.value())->name() : nullAtom;
347 CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id (), name);
346 if (toReplace && *toReplace == property) 348 if (toReplace && *toReplace == property)
347 return false; 349 return false;
348 if (toReplace) { 350 if (toReplace) {
349 *toReplace = property; 351 *toReplace = property;
350 return true; 352 return true;
351 } 353 }
352 } 354 }
353 m_propertyVector.append(property); 355 m_propertyVector.append(property);
354 return true; 356 return true;
355 } 357 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 // Modify m_propertyVector in-place since this method is performance-sen sitive. 450 // Modify m_propertyVector in-place since this method is performance-sen sitive.
449 properties[newIndex++] = properties[oldIndex]; 451 properties[newIndex++] = properties[oldIndex];
450 } 452 }
451 if (newIndex != oldSize) { 453 if (newIndex != oldSize) {
452 m_propertyVector.shrink(newIndex); 454 m_propertyVector.shrink(newIndex);
453 return true; 455 return true;
454 } 456 }
455 return false; 457 return false;
456 } 458 }
457 459
458 CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(CSSPropertyID proper tyID) 460 CSSProperty* MutableStylePropertySet::findCSSPropertyWithID(CSSPropertyID proper tyID, const AtomicString& customPropertyName)
459 { 461 {
460 // TODO(leviw): Calling this with a custom property should probably assert, or this 462 int foundPropertyIndex = -1;
461 // method should alternatively take a string used for custom properties and check it 463 if (propertyID == CSSPropertyVariable && !customPropertyName.isNull()) {
462 // in that case. 464 // TODO(shanestephens): fix call sites so we always have a customPropert yName
463 if (propertyID == CSSPropertyVariable) 465 // here.
464 return nullptr; 466 foundPropertyIndex = findPropertyIndex(customPropertyName);
465 467 } else {
466 int foundPropertyIndex = findPropertyIndex(propertyID); 468 ASSERT(customPropertyName.isNull());
469 foundPropertyIndex = findPropertyIndex(propertyID);
470 }
467 if (foundPropertyIndex == -1) 471 if (foundPropertyIndex == -1)
468 return nullptr; 472 return nullptr;
469 return &m_propertyVector.at(foundPropertyIndex); 473 return &m_propertyVector.at(foundPropertyIndex);
470 } 474 }
471 475
472 bool StylePropertySet::propertyMatches(CSSPropertyID propertyID, const CSSValue* propertyValue) const 476 bool StylePropertySet::propertyMatches(CSSPropertyID propertyID, const CSSValue* propertyValue) const
473 { 477 {
474 int foundPropertyIndex = findPropertyIndex(propertyID); 478 int foundPropertyIndex = findPropertyIndex(propertyID);
475 if (foundPropertyIndex == -1) 479 if (foundPropertyIndex == -1)
476 return false; 480 return false;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 { 588 {
585 return adoptRefWillBeNoop(new MutableStylePropertySet(cssParserMode)); 589 return adoptRefWillBeNoop(new MutableStylePropertySet(cssParserMode));
586 } 590 }
587 591
588 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create( const CSSProperty* properties, unsigned count) 592 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create( const CSSProperty* properties, unsigned count)
589 { 593 {
590 return adoptRefWillBeNoop(new MutableStylePropertySet(properties, count)); 594 return adoptRefWillBeNoop(new MutableStylePropertySet(properties, count));
591 } 595 }
592 596
593 } // namespace blink 597 } // namespace blink
OLDNEW
« 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