| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 if (metadataArray()[n].m_propertyID == id) { | 105 if (metadataArray()[n].m_propertyID == id) { |
| 106 // Only enabled or internal properties should be part of the style. | 106 // Only enabled or internal properties should be part of the style. |
| 107 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID) || isInter
nalProperty(propertyID)); | 107 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID) || isInter
nalProperty(propertyID)); |
| 108 return n; | 108 return n; |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 return -1; | 112 return -1; |
| 113 } | 113 } |
| 114 | 114 |
| 115 void ImmutableStylePropertySet::traceAfterDispatch(Visitor* visitor) | |
| 116 { | |
| 117 const RawPtr<CSSValue>* values = valueArray(); | |
| 118 for (unsigned i = 0; i < m_arraySize; i++) | |
| 119 visitor->trace(values[i]); | |
| 120 StylePropertySet::traceAfterDispatch(visitor); | |
| 121 } | |
| 122 | |
| 123 MutableStylePropertySet::MutableStylePropertySet(const StylePropertySet& other) | 115 MutableStylePropertySet::MutableStylePropertySet(const StylePropertySet& other) |
| 124 : StylePropertySet(other.cssParserMode()) | 116 : StylePropertySet(other.cssParserMode()) |
| 125 { | 117 { |
| 126 if (other.isMutable()) { | 118 if (other.isMutable()) { |
| 127 m_propertyVector = toMutableStylePropertySet(other).m_propertyVector; | 119 m_propertyVector = toMutableStylePropertySet(other).m_propertyVector; |
| 128 } else { | 120 } else { |
| 129 m_propertyVector.reserveInitialCapacity(other.propertyCount()); | 121 m_propertyVector.reserveInitialCapacity(other.propertyCount()); |
| 130 for (unsigned i = 0; i < other.propertyCount(); ++i) | 122 for (unsigned i = 0; i < other.propertyCount(); ++i) |
| 131 m_propertyVector.uncheckedAppend(other.propertyAt(i).toCSSProperty()
); | 123 m_propertyVector.uncheckedAppend(other.propertyAt(i).toCSSProperty()
); |
| 132 } | 124 } |
| 133 } | 125 } |
| 134 | 126 |
| 135 String StylePropertySet::getPropertyValue(CSSPropertyID propertyID) const | 127 String StylePropertySet::getPropertyValue(CSSPropertyID propertyID) const |
| 136 { | 128 { |
| 137 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID); | 129 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID); |
| 138 if (value) | 130 if (value) |
| 139 return value->cssText(); | 131 return value->cssText(); |
| 140 | 132 |
| 141 return StylePropertySerializer(*this).getPropertyValue(propertyID); | 133 return StylePropertySerializer(*this).getPropertyValue(propertyID); |
| 142 } | 134 } |
| 143 | 135 |
| 144 PassRefPtr<CSSValue> StylePropertySet::getPropertyCSSValue(CSSPropertyID propert
yID) const | 136 PassRefPtr<CSSValue> StylePropertySet::getPropertyCSSValue(CSSPropertyID propert
yID) const |
| 145 { | 137 { |
| 146 int foundPropertyIndex = findPropertyIndex(propertyID); | 138 int foundPropertyIndex = findPropertyIndex(propertyID); |
| 147 if (foundPropertyIndex == -1) | 139 if (foundPropertyIndex == -1) |
| 148 return nullptr; | 140 return nullptr; |
| 149 return propertyAt(foundPropertyIndex).value(); | 141 return propertyAt(foundPropertyIndex).value(); |
| 150 } | 142 } |
| 151 | 143 |
| 152 void StylePropertySet::trace(Visitor* visitor) | |
| 153 { | |
| 154 if (m_isMutable) | |
| 155 toMutableStylePropertySet(this)->traceAfterDispatch(visitor); | |
| 156 else | |
| 157 toImmutableStylePropertySet(this)->traceAfterDispatch(visitor); | |
| 158 } | |
| 159 | |
| 160 #if ENABLE(OILPAN) | |
| 161 void StylePropertySet::finalizeGarbageCollectedObject() | |
| 162 { | |
| 163 if (m_isMutable) | |
| 164 toMutableStylePropertySet(this)->~MutableStylePropertySet(); | |
| 165 else | |
| 166 toImmutableStylePropertySet(this)->~ImmutableStylePropertySet(); | |
| 167 } | |
| 168 #endif | |
| 169 | |
| 170 bool MutableStylePropertySet::removeShorthandProperty(CSSPropertyID propertyID) | 144 bool MutableStylePropertySet::removeShorthandProperty(CSSPropertyID propertyID) |
| 171 { | 145 { |
| 172 StylePropertyShorthand shorthand = shorthandForProperty(propertyID); | 146 StylePropertyShorthand shorthand = shorthandForProperty(propertyID); |
| 173 if (!shorthand.length()) | 147 if (!shorthand.length()) |
| 174 return false; | 148 return false; |
| 175 | 149 |
| 176 bool ret = removePropertiesInSet(shorthand.properties(), shorthand.length())
; | 150 bool ret = removePropertiesInSet(shorthand.properties(), shorthand.length())
; |
| 177 | 151 |
| 178 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propertyID); | 152 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propertyID); |
| 179 if (prefixingVariant == propertyID) | 153 if (prefixingVariant == propertyID) |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 if (properties[n].metadata().m_propertyID == id) { | 516 if (properties[n].metadata().m_propertyID == id) { |
| 543 // Only enabled or internal properties should be part of the style. | 517 // Only enabled or internal properties should be part of the style. |
| 544 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID) || isInter
nalProperty(propertyID)); | 518 ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID) || isInter
nalProperty(propertyID)); |
| 545 return n; | 519 return n; |
| 546 } | 520 } |
| 547 } | 521 } |
| 548 | 522 |
| 549 return -1; | 523 return -1; |
| 550 } | 524 } |
| 551 | 525 |
| 552 void MutableStylePropertySet::traceAfterDispatch(Visitor* visitor) | |
| 553 { | |
| 554 visitor->trace(m_cssomWrapper); | |
| 555 visitor->trace(m_propertyVector); | |
| 556 StylePropertySet::traceAfterDispatch(visitor); | |
| 557 } | |
| 558 | |
| 559 unsigned StylePropertySet::averageSizeInBytes() | 526 unsigned StylePropertySet::averageSizeInBytes() |
| 560 { | 527 { |
| 561 // Please update this if the storage scheme changes so that this longer refl
ects the actual size. | 528 // Please update this if the storage scheme changes so that this longer refl
ects the actual size. |
| 562 return sizeForImmutableStylePropertySetWithPropertyCount(4); | 529 return sizeForImmutableStylePropertySetWithPropertyCount(4); |
| 563 } | 530 } |
| 564 | 531 |
| 565 // See the function above if you need to update this. | 532 // See the function above if you need to update this. |
| 566 struct SameSizeAsStylePropertySet : public RefCounted<SameSizeAsStylePropertySet
> { | 533 struct SameSizeAsStylePropertySet : public RefCounted<SameSizeAsStylePropertySet
> { |
| 567 unsigned bitfield; | 534 unsigned bitfield; |
| 568 }; | 535 }; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 597 result.appendLiteral(": "); | 564 result.appendLiteral(": "); |
| 598 result.append(propertyValue()->cssText()); | 565 result.append(propertyValue()->cssText()); |
| 599 if (isImportant()) | 566 if (isImportant()) |
| 600 result.appendLiteral(" !important"); | 567 result.appendLiteral(" !important"); |
| 601 result.append(';'); | 568 result.append(';'); |
| 602 return result.toString(); | 569 return result.toString(); |
| 603 } | 570 } |
| 604 | 571 |
| 605 | 572 |
| 606 } // namespace blink | 573 } // namespace blink |
| OLD | NEW |