| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 #ifndef NDEBUG | 36 #ifndef NDEBUG |
| 37 #include "wtf/text/CString.h" | 37 #include "wtf/text/CString.h" |
| 38 #include <stdio.h> | 38 #include <stdio.h> |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 static size_t sizeForImmutableStylePropertySetWithPropertyCount(unsigned count) | 43 static size_t sizeForImmutableStylePropertySetWithPropertyCount(unsigned count) |
| 44 { | 44 { |
| 45 return sizeof(ImmutableStylePropertySet) - sizeof(void*) + sizeof(RawPtrWill
BeMember<CSSValue>) * count + sizeof(StylePropertyMetadata) * count; | 45 return sizeof(ImmutableStylePropertySet) - sizeof(void*) + sizeof(Member<CSS
Value>) * count + sizeof(StylePropertyMetadata) * count; |
| 46 } | 46 } |
| 47 | 47 |
| 48 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> ImmutableStylePropertySet::cre
ate(const CSSProperty* properties, unsigned count, CSSParserMode cssParserMode) | 48 RawPtr<ImmutableStylePropertySet> ImmutableStylePropertySet::create(const CSSPro
perty* properties, unsigned count, CSSParserMode cssParserMode) |
| 49 { | 49 { |
| 50 ASSERT(count <= MaxArraySize); | 50 ASSERT(count <= MaxArraySize); |
| 51 #if ENABLE(OILPAN) | 51 #if ENABLE(OILPAN) |
| 52 void* slot = Heap::allocate<StylePropertySet>(sizeForImmutableStylePropertyS
etWithPropertyCount(count)); | 52 void* slot = Heap::allocate<StylePropertySet>(sizeForImmutableStylePropertyS
etWithPropertyCount(count)); |
| 53 #else | 53 #else |
| 54 void* slot = WTF::Partitions::fastMalloc(sizeForImmutableStylePropertySetWit
hPropertyCount(count), "blink::ImmutableStylePropertySet"); | 54 void* slot = WTF::Partitions::fastMalloc(sizeForImmutableStylePropertySetWit
hPropertyCount(count), "blink::ImmutableStylePropertySet"); |
| 55 #endif // ENABLE(OILPAN) | 55 #endif // ENABLE(OILPAN) |
| 56 return adoptRefWillBeNoop(new (slot) ImmutableStylePropertySet(properties, c
ount, cssParserMode)); | 56 return (new (slot) ImmutableStylePropertySet(properties, count, cssParserMod
e)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 PassRefPtrWillBeRawPtr<ImmutableStylePropertySet> StylePropertySet::immutableCop
yIfNeeded() const | 59 RawPtr<ImmutableStylePropertySet> StylePropertySet::immutableCopyIfNeeded() cons
t |
| 60 { | 60 { |
| 61 if (!isMutable()) | 61 if (!isMutable()) |
| 62 return toImmutableStylePropertySet(const_cast<StylePropertySet*>(this)); | 62 return toImmutableStylePropertySet(const_cast<StylePropertySet*>(this)); |
| 63 const MutableStylePropertySet* mutableThis = toMutableStylePropertySet(this)
; | 63 const MutableStylePropertySet* mutableThis = toMutableStylePropertySet(this)
; |
| 64 return ImmutableStylePropertySet::create(mutableThis->m_propertyVector.data(
), mutableThis->m_propertyVector.size(), cssParserMode()); | 64 return ImmutableStylePropertySet::create(mutableThis->m_propertyVector.data(
), mutableThis->m_propertyVector.size(), cssParserMode()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 MutableStylePropertySet::MutableStylePropertySet(CSSParserMode cssParserMode) | 67 MutableStylePropertySet::MutableStylePropertySet(CSSParserMode cssParserMode) |
| 68 : StylePropertySet(cssParserMode) | 68 : StylePropertySet(cssParserMode) |
| 69 { | 69 { |
| 70 } | 70 } |
| 71 | 71 |
| 72 MutableStylePropertySet::MutableStylePropertySet(const CSSProperty* properties,
unsigned length) | 72 MutableStylePropertySet::MutableStylePropertySet(const CSSProperty* properties,
unsigned length) |
| 73 : StylePropertySet(HTMLStandardMode) | 73 : StylePropertySet(HTMLStandardMode) |
| 74 { | 74 { |
| 75 m_propertyVector.reserveInitialCapacity(length); | 75 m_propertyVector.reserveInitialCapacity(length); |
| 76 for (unsigned i = 0; i < length; ++i) | 76 for (unsigned i = 0; i < length; ++i) |
| 77 m_propertyVector.uncheckedAppend(properties[i]); | 77 m_propertyVector.uncheckedAppend(properties[i]); |
| 78 } | 78 } |
| 79 | 79 |
| 80 ImmutableStylePropertySet::ImmutableStylePropertySet(const CSSProperty* properti
es, unsigned length, CSSParserMode cssParserMode) | 80 ImmutableStylePropertySet::ImmutableStylePropertySet(const CSSProperty* properti
es, unsigned length, CSSParserMode cssParserMode) |
| 81 : StylePropertySet(cssParserMode, length) | 81 : StylePropertySet(cssParserMode, length) |
| 82 { | 82 { |
| 83 StylePropertyMetadata* metadataArray = const_cast<StylePropertyMetadata*>(th
is->metadataArray()); | 83 StylePropertyMetadata* metadataArray = const_cast<StylePropertyMetadata*>(th
is->metadataArray()); |
| 84 RawPtrWillBeMember<CSSValue>* valueArray = const_cast<RawPtrWillBeMember<CSS
Value>*>(this->valueArray()); | 84 Member<CSSValue>* valueArray = const_cast<Member<CSSValue>*>(this->valueArra
y()); |
| 85 for (unsigned i = 0; i < m_arraySize; ++i) { | 85 for (unsigned i = 0; i < m_arraySize; ++i) { |
| 86 metadataArray[i] = properties[i].metadata(); | 86 metadataArray[i] = properties[i].metadata(); |
| 87 valueArray[i] = properties[i].value(); | 87 valueArray[i] = properties[i].value(); |
| 88 #if !ENABLE(OILPAN) | 88 #if !ENABLE(OILPAN) |
| 89 valueArray[i]->ref(); | 89 valueArray[i]->ref(); |
| 90 #endif | 90 #endif |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 ImmutableStylePropertySet::~ImmutableStylePropertySet() | 94 ImmutableStylePropertySet::~ImmutableStylePropertySet() |
| 95 { | 95 { |
| 96 #if !ENABLE(OILPAN) | 96 #if !ENABLE(OILPAN) |
| 97 RawPtrWillBeMember<CSSValue>* valueArray = const_cast<RawPtrWillBeMember<CSS
Value>*>(this->valueArray()); | 97 Member<CSSValue>* valueArray = const_cast<Member<CSSValue>*>(this->valueArra
y()); |
| 98 for (unsigned i = 0; i < m_arraySize; ++i) { | 98 for (unsigned i = 0; i < m_arraySize; ++i) { |
| 99 // Checking for nullptr here is a workaround to prevent crashing. http:
//crbug.com/449032 | 99 // Checking for nullptr here is a workaround to prevent crashing. http:
//crbug.com/449032 |
| 100 if (valueArray[i]) | 100 if (valueArray[i]) |
| 101 valueArray[i]->deref(); | 101 valueArray[i]->deref(); |
| 102 } | 102 } |
| 103 #endif | 103 #endif |
| 104 } | 104 } |
| 105 | 105 |
| 106 // Convert property into an uint16_t for comparison with metadata's m_propertyID
to avoid | 106 // Convert property into an uint16_t for comparison with metadata's m_propertyID
to avoid |
| 107 // the compiler converting it to an int multiple times in a loop. | 107 // the compiler converting it to an int multiple times in a loop. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 return n; | 140 return n; |
| 141 } | 141 } |
| 142 | 142 |
| 143 return -1; | 143 return -1; |
| 144 } | 144 } |
| 145 template CORE_EXPORT int ImmutableStylePropertySet::findPropertyIndex(CSSPropert
yID) const; | 145 template CORE_EXPORT int ImmutableStylePropertySet::findPropertyIndex(CSSPropert
yID) const; |
| 146 template CORE_EXPORT int ImmutableStylePropertySet::findPropertyIndex(AtomicStri
ng) const; | 146 template CORE_EXPORT int ImmutableStylePropertySet::findPropertyIndex(AtomicStri
ng) const; |
| 147 | 147 |
| 148 DEFINE_TRACE_AFTER_DISPATCH(ImmutableStylePropertySet) | 148 DEFINE_TRACE_AFTER_DISPATCH(ImmutableStylePropertySet) |
| 149 { | 149 { |
| 150 const RawPtrWillBeMember<CSSValue>* values = valueArray(); | 150 const Member<CSSValue>* values = valueArray(); |
| 151 for (unsigned i = 0; i < m_arraySize; i++) | 151 for (unsigned i = 0; i < m_arraySize; i++) |
| 152 visitor->trace(values[i]); | 152 visitor->trace(values[i]); |
| 153 StylePropertySet::traceAfterDispatch(visitor); | 153 StylePropertySet::traceAfterDispatch(visitor); |
| 154 } | 154 } |
| 155 | 155 |
| 156 MutableStylePropertySet::MutableStylePropertySet(const StylePropertySet& other) | 156 MutableStylePropertySet::MutableStylePropertySet(const StylePropertySet& other) |
| 157 : StylePropertySet(other.cssParserMode()) | 157 : StylePropertySet(other.cssParserMode()) |
| 158 { | 158 { |
| 159 if (other.isMutable()) { | 159 if (other.isMutable()) { |
| 160 m_propertyVector = toMutableStylePropertySet(other).m_propertyVector; | 160 m_propertyVector = toMutableStylePropertySet(other).m_propertyVector; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 172 | 172 |
| 173 static String serializeShorthand(const StylePropertySet&, const AtomicString& cu
stomPropertyName) | 173 static String serializeShorthand(const StylePropertySet&, const AtomicString& cu
stomPropertyName) |
| 174 { | 174 { |
| 175 // Custom properties are never shorthands. | 175 // Custom properties are never shorthands. |
| 176 return ""; | 176 return ""; |
| 177 } | 177 } |
| 178 | 178 |
| 179 template<typename T> | 179 template<typename T> |
| 180 String StylePropertySet::getPropertyValue(T property) const | 180 String StylePropertySet::getPropertyValue(T property) const |
| 181 { | 181 { |
| 182 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(property); | 182 RawPtr<CSSValue> value = getPropertyCSSValue(property); |
| 183 if (value) | 183 if (value) |
| 184 return value->cssText(); | 184 return value->cssText(); |
| 185 return serializeShorthand(*this, property); | 185 return serializeShorthand(*this, property); |
| 186 } | 186 } |
| 187 template CORE_EXPORT String StylePropertySet::getPropertyValue<CSSPropertyID>(CS
SPropertyID) const; | 187 template CORE_EXPORT String StylePropertySet::getPropertyValue<CSSPropertyID>(CS
SPropertyID) const; |
| 188 template CORE_EXPORT String StylePropertySet::getPropertyValue<AtomicString>(Ato
micString) const; | 188 template CORE_EXPORT String StylePropertySet::getPropertyValue<AtomicString>(Ato
micString) const; |
| 189 | 189 |
| 190 template<typename T> | 190 template<typename T> |
| 191 PassRefPtrWillBeRawPtr<CSSValue> StylePropertySet::getPropertyCSSValue(T propert
y) const | 191 RawPtr<CSSValue> StylePropertySet::getPropertyCSSValue(T property) const |
| 192 { | 192 { |
| 193 int foundPropertyIndex = findPropertyIndex(property); | 193 int foundPropertyIndex = findPropertyIndex(property); |
| 194 if (foundPropertyIndex == -1) | 194 if (foundPropertyIndex == -1) |
| 195 return nullptr; | 195 return nullptr; |
| 196 return propertyAt(foundPropertyIndex).value(); | 196 return propertyAt(foundPropertyIndex).value(); |
| 197 } | 197 } |
| 198 template CORE_EXPORT PassRefPtrWillBeRawPtr<CSSValue> StylePropertySet::getPrope
rtyCSSValue<CSSPropertyID>(CSSPropertyID) const; | 198 template CORE_EXPORT RawPtr<CSSValue> StylePropertySet::getPropertyCSSValue<CSSP
ropertyID>(CSSPropertyID) const; |
| 199 template CORE_EXPORT PassRefPtrWillBeRawPtr<CSSValue> StylePropertySet::getPrope
rtyCSSValue<AtomicString>(AtomicString) const; | 199 template CORE_EXPORT RawPtr<CSSValue> StylePropertySet::getPropertyCSSValue<Atom
icString>(AtomicString) const; |
| 200 | 200 |
| 201 DEFINE_TRACE(StylePropertySet) | 201 DEFINE_TRACE(StylePropertySet) |
| 202 { | 202 { |
| 203 if (m_isMutable) | 203 if (m_isMutable) |
| 204 toMutableStylePropertySet(this)->traceAfterDispatch(visitor); | 204 toMutableStylePropertySet(this)->traceAfterDispatch(visitor); |
| 205 else | 205 else |
| 206 toImmutableStylePropertySet(this)->traceAfterDispatch(visitor); | 206 toImmutableStylePropertySet(this)->traceAfterDispatch(visitor); |
| 207 } | 207 } |
| 208 | 208 |
| 209 #if ENABLE(OILPAN) | 209 #if ENABLE(OILPAN) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 return CSSParser::parseValue(this, unresolvedProperty, value, important, con
textStyleSheet); | 317 return CSSParser::parseValue(this, unresolvedProperty, value, important, con
textStyleSheet); |
| 318 } | 318 } |
| 319 | 319 |
| 320 bool MutableStylePropertySet::setProperty(const AtomicString& customPropertyName
, const String& value, bool important, StyleSheetContents* contextStyleSheet) | 320 bool MutableStylePropertySet::setProperty(const AtomicString& customPropertyName
, const String& value, bool important, StyleSheetContents* contextStyleSheet) |
| 321 { | 321 { |
| 322 if (value.isEmpty()) | 322 if (value.isEmpty()) |
| 323 return removeProperty(customPropertyName); | 323 return removeProperty(customPropertyName); |
| 324 return CSSParser::parseValueForCustomProperty(this, customPropertyName, valu
e, important, contextStyleSheet); | 324 return CSSParser::parseValueForCustomProperty(this, customPropertyName, valu
e, important, contextStyleSheet); |
| 325 } | 325 } |
| 326 | 326 |
| 327 void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, PassRefPtrWi
llBeRawPtr<CSSValue> prpValue, bool important) | 327 void MutableStylePropertySet::setProperty(CSSPropertyID propertyID, RawPtr<CSSVa
lue> prpValue, bool important) |
| 328 { | 328 { |
| 329 StylePropertyShorthand shorthand = shorthandForProperty(propertyID); | 329 StylePropertyShorthand shorthand = shorthandForProperty(propertyID); |
| 330 if (!shorthand.length()) { | 330 if (!shorthand.length()) { |
| 331 setProperty(CSSProperty(propertyID, prpValue, important)); | 331 setProperty(CSSProperty(propertyID, prpValue, important)); |
| 332 return; | 332 return; |
| 333 } | 333 } |
| 334 | 334 |
| 335 removePropertiesInSet(shorthand.properties(), shorthand.length()); | 335 removePropertiesInSet(shorthand.properties(), shorthand.length()); |
| 336 | 336 |
| 337 RefPtrWillBeRawPtr<CSSValue> value = prpValue; | 337 RawPtr<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 CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id
()); |
| 346 if (toReplace && *toReplace == property) | 346 if (toReplace && *toReplace == property) |
| 347 return false; | 347 return false; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 366 | 366 |
| 367 CSSParserContext context(cssParserMode(), UseCounter::getFrom(contextStyleSh
eet)); | 367 CSSParserContext context(cssParserMode(), UseCounter::getFrom(contextStyleSh
eet)); |
| 368 if (contextStyleSheet) { | 368 if (contextStyleSheet) { |
| 369 context = contextStyleSheet->parserContext(); | 369 context = contextStyleSheet->parserContext(); |
| 370 context.setMode(cssParserMode()); | 370 context.setMode(cssParserMode()); |
| 371 } | 371 } |
| 372 | 372 |
| 373 CSSParser::parseDeclarationList(context, this, styleDeclaration); | 373 CSSParser::parseDeclarationList(context, this, styleDeclaration); |
| 374 } | 374 } |
| 375 | 375 |
| 376 bool MutableStylePropertySet::addParsedProperties(const WillBeHeapVector<CSSProp
erty, 256>& properties) | 376 bool MutableStylePropertySet::addParsedProperties(const HeapVector<CSSProperty,
256>& properties) |
| 377 { | 377 { |
| 378 bool changed = false; | 378 bool changed = false; |
| 379 m_propertyVector.reserveCapacity(m_propertyVector.size() + properties.size()
); | 379 m_propertyVector.reserveCapacity(m_propertyVector.size() + properties.size()
); |
| 380 for (unsigned i = 0; i < properties.size(); ++i) | 380 for (unsigned i = 0; i < properties.size(); ++i) |
| 381 changed |= setProperty(properties[i]); | 381 changed |= setProperty(properties[i]); |
| 382 return changed; | 382 return changed; |
| 383 } | 383 } |
| 384 | 384 |
| 385 bool MutableStylePropertySet::addRespectingCascade(const CSSProperty& property) | 385 bool MutableStylePropertySet::addRespectingCascade(const CSSProperty& property) |
| 386 { | 386 { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 for (unsigned i = 0; i < size; ++i) { | 498 for (unsigned i = 0; i < size; ++i) { |
| 499 PropertyReference property = propertyAt(i); | 499 PropertyReference property = propertyAt(i); |
| 500 if (style->cssPropertyMatches(property.id(), property.value())) | 500 if (style->cssPropertyMatches(property.id(), property.value())) |
| 501 propertiesToRemove.append(property.id()); | 501 propertiesToRemove.append(property.id()); |
| 502 } | 502 } |
| 503 // FIXME: This should use mass removal. | 503 // FIXME: This should use mass removal. |
| 504 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) | 504 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) |
| 505 removeProperty(propertiesToRemove[i]); | 505 removeProperty(propertiesToRemove[i]); |
| 506 } | 506 } |
| 507 | 507 |
| 508 PassRefPtrWillBeRawPtr<MutableStylePropertySet> StylePropertySet::mutableCopy()
const | 508 RawPtr<MutableStylePropertySet> StylePropertySet::mutableCopy() const |
| 509 { | 509 { |
| 510 return adoptRefWillBeNoop(new MutableStylePropertySet(*this)); | 510 return (new MutableStylePropertySet(*this)); |
| 511 } | 511 } |
| 512 | 512 |
| 513 PassRefPtrWillBeRawPtr<MutableStylePropertySet> StylePropertySet::copyProperties
InSet(const Vector<CSSPropertyID>& properties) const | 513 RawPtr<MutableStylePropertySet> StylePropertySet::copyPropertiesInSet(const Vect
or<CSSPropertyID>& properties) const |
| 514 { | 514 { |
| 515 WillBeHeapVector<CSSProperty, 256> list; | 515 HeapVector<CSSProperty, 256> list; |
| 516 list.reserveInitialCapacity(properties.size()); | 516 list.reserveInitialCapacity(properties.size()); |
| 517 for (unsigned i = 0; i < properties.size(); ++i) { | 517 for (unsigned i = 0; i < properties.size(); ++i) { |
| 518 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(properties[i]); | 518 RawPtr<CSSValue> value = getPropertyCSSValue(properties[i]); |
| 519 if (value) | 519 if (value) |
| 520 list.append(CSSProperty(properties[i], value.release(), false)); | 520 list.append(CSSProperty(properties[i], value.release(), false)); |
| 521 } | 521 } |
| 522 return MutableStylePropertySet::create(list.data(), list.size()); | 522 return MutableStylePropertySet::create(list.data(), list.size()); |
| 523 } | 523 } |
| 524 | 524 |
| 525 CSSStyleDeclaration* MutableStylePropertySet::ensureCSSStyleDeclaration() | 525 CSSStyleDeclaration* MutableStylePropertySet::ensureCSSStyleDeclaration() |
| 526 { | 526 { |
| 527 // FIXME: get rid of this weirdness of a CSSStyleDeclaration inside of a | 527 // FIXME: get rid of this weirdness of a CSSStyleDeclaration inside of a |
| 528 // style property set. | 528 // style property set. |
| 529 if (m_cssomWrapper) { | 529 if (m_cssomWrapper) { |
| 530 ASSERT(!static_cast<CSSStyleDeclaration*>(m_cssomWrapper.get())->parentR
ule()); | 530 ASSERT(!static_cast<CSSStyleDeclaration*>(m_cssomWrapper.get())->parentR
ule()); |
| 531 ASSERT(!m_cssomWrapper->parentElement()); | 531 ASSERT(!m_cssomWrapper->parentElement()); |
| 532 return m_cssomWrapper.get(); | 532 return m_cssomWrapper.get(); |
| 533 } | 533 } |
| 534 m_cssomWrapper = adoptPtrWillBeNoop(new PropertySetCSSStyleDeclaration(*this
)); | 534 m_cssomWrapper = (new PropertySetCSSStyleDeclaration(*this)); |
| 535 return m_cssomWrapper.get(); | 535 return m_cssomWrapper.get(); |
| 536 } | 536 } |
| 537 | 537 |
| 538 template<typename T> | 538 template<typename T> |
| 539 int MutableStylePropertySet::findPropertyIndex(T property) const | 539 int MutableStylePropertySet::findPropertyIndex(T property) const |
| 540 { | 540 { |
| 541 const CSSProperty* begin = m_propertyVector.data(); | 541 const CSSProperty* begin = m_propertyVector.data(); |
| 542 const CSSProperty* end = begin + m_propertyVector.size(); | 542 const CSSProperty* end = begin + m_propertyVector.size(); |
| 543 | 543 |
| 544 uint16_t id = getConvertedCSSPropertyID(property); | 544 uint16_t id = getConvertedCSSPropertyID(property); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 561 StylePropertySet::traceAfterDispatch(visitor); | 561 StylePropertySet::traceAfterDispatch(visitor); |
| 562 } | 562 } |
| 563 | 563 |
| 564 unsigned StylePropertySet::averageSizeInBytes() | 564 unsigned StylePropertySet::averageSizeInBytes() |
| 565 { | 565 { |
| 566 // Please update this if the storage scheme changes so that this longer refl
ects the actual size. | 566 // Please update this if the storage scheme changes so that this longer refl
ects the actual size. |
| 567 return sizeForImmutableStylePropertySetWithPropertyCount(4); | 567 return sizeForImmutableStylePropertySetWithPropertyCount(4); |
| 568 } | 568 } |
| 569 | 569 |
| 570 // See the function above if you need to update this. | 570 // See the function above if you need to update this. |
| 571 struct SameSizeAsStylePropertySet : public RefCountedWillBeGarbageCollectedFinal
ized<SameSizeAsStylePropertySet> { | 571 struct SameSizeAsStylePropertySet : public GarbageCollectedFinalized<SameSizeAsS
tylePropertySet> { |
| 572 unsigned bitfield; | 572 unsigned bitfield; |
| 573 }; | 573 }; |
| 574 static_assert(sizeof(StylePropertySet) == sizeof(SameSizeAsStylePropertySet), "S
tylePropertySet should stay small"); | 574 static_assert(sizeof(StylePropertySet) == sizeof(SameSizeAsStylePropertySet), "S
tylePropertySet should stay small"); |
| 575 | 575 |
| 576 #ifndef NDEBUG | 576 #ifndef NDEBUG |
| 577 void StylePropertySet::showStyle() | 577 void StylePropertySet::showStyle() |
| 578 { | 578 { |
| 579 fprintf(stderr, "%s\n", asText().ascii().data()); | 579 fprintf(stderr, "%s\n", asText().ascii().data()); |
| 580 } | 580 } |
| 581 #endif | 581 #endif |
| 582 | 582 |
| 583 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create(
CSSParserMode cssParserMode) | 583 RawPtr<MutableStylePropertySet> MutableStylePropertySet::create(CSSParserMode cs
sParserMode) |
| 584 { | 584 { |
| 585 return adoptRefWillBeNoop(new MutableStylePropertySet(cssParserMode)); | 585 return (new MutableStylePropertySet(cssParserMode)); |
| 586 } | 586 } |
| 587 | 587 |
| 588 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create(
const CSSProperty* properties, unsigned count) | 588 RawPtr<MutableStylePropertySet> MutableStylePropertySet::create(const CSSPropert
y* properties, unsigned count) |
| 589 { | 589 { |
| 590 return adoptRefWillBeNoop(new MutableStylePropertySet(properties, count)); | 590 return (new MutableStylePropertySet(properties, count)); |
| 591 } | 591 } |
| 592 | 592 |
| 593 } // namespace blink | 593 } // namespace blink |
| OLD | NEW |