| 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. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. |
| 4 * All rights reserved. | 4 * All 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 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 6 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 bool important) { | 340 bool important) { |
| 341 StylePropertyShorthand shorthand = shorthandForProperty(propertyID); | 341 StylePropertyShorthand shorthand = shorthandForProperty(propertyID); |
| 342 if (!shorthand.length()) { | 342 if (!shorthand.length()) { |
| 343 setProperty(CSSProperty(propertyID, value, important)); | 343 setProperty(CSSProperty(propertyID, value, important)); |
| 344 return; | 344 return; |
| 345 } | 345 } |
| 346 | 346 |
| 347 removePropertiesInSet(shorthand.properties(), shorthand.length()); | 347 removePropertiesInSet(shorthand.properties(), shorthand.length()); |
| 348 | 348 |
| 349 for (unsigned i = 0; i < shorthand.length(); ++i) | 349 for (unsigned i = 0; i < shorthand.length(); ++i) |
| 350 m_propertyVector.append( | 350 m_propertyVector.push_back( |
| 351 CSSProperty(shorthand.properties()[i], value, important)); | 351 CSSProperty(shorthand.properties()[i], value, important)); |
| 352 } | 352 } |
| 353 | 353 |
| 354 bool MutableStylePropertySet::setProperty(const CSSProperty& property, | 354 bool MutableStylePropertySet::setProperty(const CSSProperty& property, |
| 355 CSSProperty* slot) { | 355 CSSProperty* slot) { |
| 356 const AtomicString& name = | 356 const AtomicString& name = |
| 357 (property.id() == CSSPropertyVariable) | 357 (property.id() == CSSPropertyVariable) |
| 358 ? toCSSCustomPropertyDeclaration(property.value())->name() | 358 ? toCSSCustomPropertyDeclaration(property.value())->name() |
| 359 : nullAtom; | 359 : nullAtom; |
| 360 CSSProperty* toReplace = | 360 CSSProperty* toReplace = |
| 361 slot ? slot : findCSSPropertyWithID(property.id(), name); | 361 slot ? slot : findCSSPropertyWithID(property.id(), name); |
| 362 if (toReplace && *toReplace == property) | 362 if (toReplace && *toReplace == property) |
| 363 return false; | 363 return false; |
| 364 if (toReplace) { | 364 if (toReplace) { |
| 365 *toReplace = property; | 365 *toReplace = property; |
| 366 return true; | 366 return true; |
| 367 } | 367 } |
| 368 m_propertyVector.append(property); | 368 m_propertyVector.push_back(property); |
| 369 return true; | 369 return true; |
| 370 } | 370 } |
| 371 | 371 |
| 372 bool MutableStylePropertySet::setProperty(CSSPropertyID propertyID, | 372 bool MutableStylePropertySet::setProperty(CSSPropertyID propertyID, |
| 373 CSSValueID identifier, | 373 CSSValueID identifier, |
| 374 bool important) { | 374 bool important) { |
| 375 setProperty(CSSProperty(propertyID, *CSSIdentifierValue::create(identifier), | 375 setProperty(CSSProperty(propertyID, *CSSIdentifierValue::create(identifier), |
| 376 important)); | 376 important)); |
| 377 return true; | 377 return true; |
| 378 } | 378 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 void MutableStylePropertySet::mergeAndOverrideOnConflict( | 416 void MutableStylePropertySet::mergeAndOverrideOnConflict( |
| 417 const StylePropertySet* other) { | 417 const StylePropertySet* other) { |
| 418 unsigned size = other->propertyCount(); | 418 unsigned size = other->propertyCount(); |
| 419 for (unsigned n = 0; n < size; ++n) { | 419 for (unsigned n = 0; n < size; ++n) { |
| 420 PropertyReference toMerge = other->propertyAt(n); | 420 PropertyReference toMerge = other->propertyAt(n); |
| 421 // TODO(leviw): This probably doesn't work correctly with Custom Properties | 421 // TODO(leviw): This probably doesn't work correctly with Custom Properties |
| 422 CSSProperty* old = findCSSPropertyWithID(toMerge.id()); | 422 CSSProperty* old = findCSSPropertyWithID(toMerge.id()); |
| 423 if (old) | 423 if (old) |
| 424 setProperty(toMerge.toCSSProperty(), old); | 424 setProperty(toMerge.toCSSProperty(), old); |
| 425 else | 425 else |
| 426 m_propertyVector.append(toMerge.toCSSProperty()); | 426 m_propertyVector.push_back(toMerge.toCSSProperty()); |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 | 429 |
| 430 bool StylePropertySet::hasFailedOrCanceledSubresources() const { | 430 bool StylePropertySet::hasFailedOrCanceledSubresources() const { |
| 431 unsigned size = propertyCount(); | 431 unsigned size = propertyCount(); |
| 432 for (unsigned i = 0; i < size; ++i) { | 432 for (unsigned i = 0; i < size; ++i) { |
| 433 if (propertyAt(i).value().hasFailedOrCanceledSubresources()) | 433 if (propertyAt(i).value().hasFailedOrCanceledSubresources()) |
| 434 return true; | 434 return true; |
| 435 } | 435 } |
| 436 return false; | 436 return false; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 return propertyAt(foundPropertyIndex).value().equals(propertyValue); | 498 return propertyAt(foundPropertyIndex).value().equals(propertyValue); |
| 499 } | 499 } |
| 500 | 500 |
| 501 void MutableStylePropertySet::removeEquivalentProperties( | 501 void MutableStylePropertySet::removeEquivalentProperties( |
| 502 const StylePropertySet* style) { | 502 const StylePropertySet* style) { |
| 503 Vector<CSSPropertyID> propertiesToRemove; | 503 Vector<CSSPropertyID> propertiesToRemove; |
| 504 unsigned size = m_propertyVector.size(); | 504 unsigned size = m_propertyVector.size(); |
| 505 for (unsigned i = 0; i < size; ++i) { | 505 for (unsigned i = 0; i < size; ++i) { |
| 506 PropertyReference property = propertyAt(i); | 506 PropertyReference property = propertyAt(i); |
| 507 if (style->propertyMatches(property.id(), property.value())) | 507 if (style->propertyMatches(property.id(), property.value())) |
| 508 propertiesToRemove.append(property.id()); | 508 propertiesToRemove.push_back(property.id()); |
| 509 } | 509 } |
| 510 // FIXME: This should use mass removal. | 510 // FIXME: This should use mass removal. |
| 511 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) | 511 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) |
| 512 removeProperty(propertiesToRemove[i]); | 512 removeProperty(propertiesToRemove[i]); |
| 513 } | 513 } |
| 514 | 514 |
| 515 void MutableStylePropertySet::removeEquivalentProperties( | 515 void MutableStylePropertySet::removeEquivalentProperties( |
| 516 const CSSStyleDeclaration* style) { | 516 const CSSStyleDeclaration* style) { |
| 517 Vector<CSSPropertyID> propertiesToRemove; | 517 Vector<CSSPropertyID> propertiesToRemove; |
| 518 unsigned size = m_propertyVector.size(); | 518 unsigned size = m_propertyVector.size(); |
| 519 for (unsigned i = 0; i < size; ++i) { | 519 for (unsigned i = 0; i < size; ++i) { |
| 520 PropertyReference property = propertyAt(i); | 520 PropertyReference property = propertyAt(i); |
| 521 if (style->cssPropertyMatches(property.id(), &property.value())) | 521 if (style->cssPropertyMatches(property.id(), &property.value())) |
| 522 propertiesToRemove.append(property.id()); | 522 propertiesToRemove.push_back(property.id()); |
| 523 } | 523 } |
| 524 // FIXME: This should use mass removal. | 524 // FIXME: This should use mass removal. |
| 525 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) | 525 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) |
| 526 removeProperty(propertiesToRemove[i]); | 526 removeProperty(propertiesToRemove[i]); |
| 527 } | 527 } |
| 528 | 528 |
| 529 MutableStylePropertySet* StylePropertySet::mutableCopy() const { | 529 MutableStylePropertySet* StylePropertySet::mutableCopy() const { |
| 530 return new MutableStylePropertySet(*this); | 530 return new MutableStylePropertySet(*this); |
| 531 } | 531 } |
| 532 | 532 |
| 533 MutableStylePropertySet* StylePropertySet::copyPropertiesInSet( | 533 MutableStylePropertySet* StylePropertySet::copyPropertiesInSet( |
| 534 const Vector<CSSPropertyID>& properties) const { | 534 const Vector<CSSPropertyID>& properties) const { |
| 535 HeapVector<CSSProperty, 256> list; | 535 HeapVector<CSSProperty, 256> list; |
| 536 list.reserveInitialCapacity(properties.size()); | 536 list.reserveInitialCapacity(properties.size()); |
| 537 for (unsigned i = 0; i < properties.size(); ++i) { | 537 for (unsigned i = 0; i < properties.size(); ++i) { |
| 538 const CSSValue* value = getPropertyCSSValue(properties[i]); | 538 const CSSValue* value = getPropertyCSSValue(properties[i]); |
| 539 if (value) | 539 if (value) |
| 540 list.append(CSSProperty(properties[i], *value, false)); | 540 list.push_back(CSSProperty(properties[i], *value, false)); |
| 541 } | 541 } |
| 542 return MutableStylePropertySet::create(list.data(), list.size()); | 542 return MutableStylePropertySet::create(list.data(), list.size()); |
| 543 } | 543 } |
| 544 | 544 |
| 545 CSSStyleDeclaration* MutableStylePropertySet::ensureCSSStyleDeclaration() { | 545 CSSStyleDeclaration* MutableStylePropertySet::ensureCSSStyleDeclaration() { |
| 546 // FIXME: get rid of this weirdness of a CSSStyleDeclaration inside of a | 546 // FIXME: get rid of this weirdness of a CSSStyleDeclaration inside of a |
| 547 // style property set. | 547 // style property set. |
| 548 if (m_cssomWrapper) { | 548 if (m_cssomWrapper) { |
| 549 ASSERT( | 549 ASSERT( |
| 550 !static_cast<CSSStyleDeclaration*>(m_cssomWrapper.get())->parentRule()); | 550 !static_cast<CSSStyleDeclaration*>(m_cssomWrapper.get())->parentRule()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 | 608 |
| 609 MutableStylePropertySet* MutableStylePropertySet::create( | 609 MutableStylePropertySet* MutableStylePropertySet::create( |
| 610 const CSSProperty* properties, | 610 const CSSProperty* properties, |
| 611 unsigned count) { | 611 unsigned count) { |
| 612 return new MutableStylePropertySet(properties, count); | 612 return new MutableStylePropertySet(properties, count); |
| 613 } | 613 } |
| 614 | 614 |
| 615 DEFINE_TRACE(CSSLazyPropertyParser) {} | 615 DEFINE_TRACE(CSSLazyPropertyParser) {} |
| 616 | 616 |
| 617 } // namespace blink | 617 } // namespace blink |
| OLD | NEW |