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