Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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) { |
| 462 // in that case. | 464 ASSERT(customPropertyName != nullAtom); |
|
Timothy Loh
2016/02/16 23:49:39
!x.isNull() maybe
shans
2016/02/17 02:41:35
Done.
| |
| 463 if (propertyID == CSSPropertyVariable) | 465 foundPropertyIndex = findPropertyIndex(customPropertyName); |
| 464 return nullptr; | 466 // TODO(shanestephens): fix call sites so we always have a customPropertyNam e |
| 465 | 467 // here. |
| 466 int foundPropertyIndex = findPropertyIndex(propertyID); | 468 } else if (customPropertyName != nullAtom) { |
|
Timothy Loh
2016/02/16 23:49:39
Isn't this backwards - when we have a regular prop
shans
2016/02/17 02:41:35
uh .. yeah.
| |
| 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 Loading... | |
| 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 |
| OLD | NEW |