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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 } | 279 } |
280 | 280 |
281 bool MutableStylePropertySet::setVariableValue(const AtomicString& name, const S
tring& value, bool important) | 281 bool MutableStylePropertySet::setVariableValue(const AtomicString& name, const S
tring& value, bool important) |
282 { | 282 { |
283 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); | 283 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); |
284 if (value.isEmpty()) | 284 if (value.isEmpty()) |
285 return removeVariable(name); | 285 return removeVariable(name); |
286 | 286 |
287 size_t index = findVariableIndex(name); | 287 size_t index = findVariableIndex(name); |
288 if (index != kNotFound) { | 288 if (index != kNotFound) { |
289 CSSValue* cssValue = m_propertyVector.at(index).value(); | 289 const CSSValue* cssValue = m_propertyVector.at(index).value(); |
290 if (toCSSVariableValue(cssValue)->value() == value) | 290 if (toCSSVariableValue(cssValue)->value() == value) |
291 return false; | 291 return false; |
292 } | 292 } |
293 | 293 |
294 CSSProperty property(CSSPropertyVariable, CSSVariableValue::create(name, val
ue), important); | 294 CSSProperty property(CSSPropertyVariable, CSSVariableValue::create(name, val
ue), important); |
295 if (index == kNotFound) | 295 if (index == kNotFound) { |
296 m_propertyVector.append(property); | 296 m_propertyVector.append(property); |
297 else | 297 return true; |
298 m_propertyVector.at(index) = property; | 298 } |
299 return true; | 299 m_propertyVector.at(index) = property; |
| 300 return false; |
300 } | 301 } |
301 | 302 |
302 void MutableStylePropertySet::appendPrefixingVariantProperty(const CSSProperty&
property) | 303 void MutableStylePropertySet::appendPrefixingVariantProperty(const CSSProperty&
property) |
303 { | 304 { |
304 m_propertyVector.append(property); | 305 m_propertyVector.append(property); |
305 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id()
); | 306 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(property.id()
); |
306 if (prefixingVariant == property.id()) | 307 if (prefixingVariant == property.id()) |
307 return; | 308 return; |
308 | 309 |
309 m_propertyVector.append(CSSProperty(prefixingVariant, property.value(), prop
erty.isImportant(), property.isSetFromShorthand(), getIndexInShorthandVectorForP
refixingVariant(property, prefixingVariant), property.metadata().m_implicit)); | 310 m_propertyVector.append(CSSProperty(prefixingVariant, property.value(), prop
erty.isImportant(), property.isSetFromShorthand(), getIndexInShorthandVectorForP
refixingVariant(property, prefixingVariant), property.metadata().m_implicit)); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 return true; | 557 return true; |
557 } | 558 } |
558 | 559 |
559 bool MutableStylePropertySet::clearVariables() | 560 bool MutableStylePropertySet::clearVariables() |
560 { | 561 { |
561 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); | 562 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); |
562 CSSPropertyID variablesId = CSSPropertyVariable; | 563 CSSPropertyID variablesId = CSSPropertyVariable; |
563 return removePropertiesInSet(&variablesId, 1); | 564 return removePropertiesInSet(&variablesId, 1); |
564 } | 565 } |
565 | 566 |
| 567 PassRefPtr<MutableStylePropertySet::VariablesIterator> MutableStylePropertySet::
VariablesIterator::create(MutableStylePropertySet* propertySet) |
| 568 { |
| 569 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled()); |
| 570 const size_t propertyCount = propertySet->propertyCount(); |
| 571 size_t variableCount = 0; |
| 572 Vector<AtomicString> remainingNames(propertyCount); |
| 573 for (int i = propertyCount; i--; ) { |
| 574 const PropertyReference& property = propertySet->propertyAt(i); |
| 575 if (property.id() == CSSPropertyVariable) |
| 576 remainingNames[variableCount++] = toCSSVariableValue(property.value(
))->name(); |
| 577 } |
| 578 remainingNames.shrink(variableCount); |
| 579 |
| 580 RefPtr<VariablesIterator> iterator = adoptRef(new VariablesIterator(property
Set)); |
| 581 // FIXME: Make use of the Vector move constructor when rvalues are supported
on all platforms. |
| 582 iterator->takeRemainingNames(remainingNames); |
| 583 return iterator.release(); |
| 584 } |
| 585 |
| 586 void MutableStylePropertySet::VariablesIterator::addedVariable(const AtomicStrin
g& name) |
| 587 { |
| 588 ASSERT(!m_remainingNames.contains(name)); |
| 589 ASSERT(!m_newNames.contains(name)); |
| 590 m_newNames.append(name); |
| 591 } |
| 592 |
| 593 void MutableStylePropertySet::VariablesIterator::removedVariable(const AtomicStr
ing& name) |
| 594 { |
| 595 size_t index = m_remainingNames.find(name); |
| 596 if (index != kNotFound) |
| 597 m_remainingNames.remove(index); |
| 598 index = m_newNames.find(name); |
| 599 if (index != kNotFound) |
| 600 m_newNames.remove(index); |
| 601 } |
| 602 |
| 603 void MutableStylePropertySet::VariablesIterator::clearedVariables() |
| 604 { |
| 605 m_remainingNames.clear(); |
| 606 m_newNames.clear(); |
| 607 } |
| 608 |
| 609 void MutableStylePropertySet::VariablesIterator::advance() |
| 610 { |
| 611 if (!atEnd()) |
| 612 m_remainingNames.removeLast(); |
| 613 if (!m_newNames.isEmpty()) { |
| 614 m_remainingNames.appendVector(m_newNames); |
| 615 m_newNames.clear(); |
| 616 } |
| 617 } |
| 618 |
566 PassRefPtr<MutableStylePropertySet> StylePropertySet::mutableCopy() const | 619 PassRefPtr<MutableStylePropertySet> StylePropertySet::mutableCopy() const |
567 { | 620 { |
568 return adoptRef(new MutableStylePropertySet(*this)); | 621 return adoptRef(new MutableStylePropertySet(*this)); |
569 } | 622 } |
570 | 623 |
571 PassRefPtr<MutableStylePropertySet> StylePropertySet::copyPropertiesInSet(const
Vector<CSSPropertyID>& properties) const | 624 PassRefPtr<MutableStylePropertySet> StylePropertySet::copyPropertiesInSet(const
Vector<CSSPropertyID>& properties) const |
572 { | 625 { |
573 Vector<CSSProperty, 256> list; | 626 Vector<CSSProperty, 256> list; |
574 list.reserveInitialCapacity(properties.size()); | 627 list.reserveInitialCapacity(properties.size()); |
575 for (unsigned i = 0; i < properties.size(); ++i) { | 628 for (unsigned i = 0; i < properties.size(); ++i) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 result.appendLiteral(": "); | 705 result.appendLiteral(": "); |
653 result.append(propertyValue()->cssText()); | 706 result.append(propertyValue()->cssText()); |
654 if (isImportant()) | 707 if (isImportant()) |
655 result.appendLiteral(" !important"); | 708 result.appendLiteral(" !important"); |
656 result.append(';'); | 709 result.append(';'); |
657 return result.toString(); | 710 return result.toString(); |
658 } | 711 } |
659 | 712 |
660 | 713 |
661 } // namespace WebCore | 714 } // namespace WebCore |
OLD | NEW |