| 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 adoptRefWillBeNoop(new (slot) ImmutableStylePropertySet(properties, c
ount, cssParserMode)); |
| 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 const AtomicString& name = (property.id() == CSSPropertyVariable) ? | 345 const AtomicString& name = (property.id() == CSSPropertyVariable) ? |
| 346 toCSSCustomPropertyDeclaration(property.value())->name() : nullAtom; | 346 toCSSCustomPropertyDeclaration(property.value())->name() : nullAtom; |
| 347 CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id
(), name); | 347 CSSProperty* toReplace = slot ? slot : findCSSPropertyWithID(property.id
(), name); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 368 | 368 |
| 369 CSSParserContext context(cssParserMode(), UseCounter::getFrom(contextStyleSh
eet)); | 369 CSSParserContext context(cssParserMode(), UseCounter::getFrom(contextStyleSh
eet)); |
| 370 if (contextStyleSheet) { | 370 if (contextStyleSheet) { |
| 371 context = contextStyleSheet->parserContext(); | 371 context = contextStyleSheet->parserContext(); |
| 372 context.setMode(cssParserMode()); | 372 context.setMode(cssParserMode()); |
| 373 } | 373 } |
| 374 | 374 |
| 375 CSSParser::parseDeclarationList(context, this, styleDeclaration); | 375 CSSParser::parseDeclarationList(context, this, styleDeclaration); |
| 376 } | 376 } |
| 377 | 377 |
| 378 bool MutableStylePropertySet::addParsedProperties(const WillBeHeapVector<CSSProp
erty, 256>& properties) | 378 bool MutableStylePropertySet::addParsedProperties(const HeapVector<CSSProperty,
256>& properties) |
| 379 { | 379 { |
| 380 bool changed = false; | 380 bool changed = false; |
| 381 m_propertyVector.reserveCapacity(m_propertyVector.size() + properties.size()
); | 381 m_propertyVector.reserveCapacity(m_propertyVector.size() + properties.size()
); |
| 382 for (unsigned i = 0; i < properties.size(); ++i) | 382 for (unsigned i = 0; i < properties.size(); ++i) |
| 383 changed |= setProperty(properties[i]); | 383 changed |= setProperty(properties[i]); |
| 384 return changed; | 384 return changed; |
| 385 } | 385 } |
| 386 | 386 |
| 387 bool MutableStylePropertySet::addRespectingCascade(const CSSProperty& property) | 387 bool MutableStylePropertySet::addRespectingCascade(const CSSProperty& property) |
| 388 { | 388 { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 for (unsigned i = 0; i < size; ++i) { | 502 for (unsigned i = 0; i < size; ++i) { |
| 503 PropertyReference property = propertyAt(i); | 503 PropertyReference property = propertyAt(i); |
| 504 if (style->cssPropertyMatches(property.id(), property.value())) | 504 if (style->cssPropertyMatches(property.id(), property.value())) |
| 505 propertiesToRemove.append(property.id()); | 505 propertiesToRemove.append(property.id()); |
| 506 } | 506 } |
| 507 // FIXME: This should use mass removal. | 507 // FIXME: This should use mass removal. |
| 508 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) | 508 for (unsigned i = 0; i < propertiesToRemove.size(); ++i) |
| 509 removeProperty(propertiesToRemove[i]); | 509 removeProperty(propertiesToRemove[i]); |
| 510 } | 510 } |
| 511 | 511 |
| 512 PassRefPtrWillBeRawPtr<MutableStylePropertySet> StylePropertySet::mutableCopy()
const | 512 RawPtr<MutableStylePropertySet> StylePropertySet::mutableCopy() const |
| 513 { | 513 { |
| 514 return adoptRefWillBeNoop(new MutableStylePropertySet(*this)); | 514 return new MutableStylePropertySet(*this); |
| 515 } | 515 } |
| 516 | 516 |
| 517 PassRefPtrWillBeRawPtr<MutableStylePropertySet> StylePropertySet::copyProperties
InSet(const Vector<CSSPropertyID>& properties) const | 517 RawPtr<MutableStylePropertySet> StylePropertySet::copyPropertiesInSet(const Vect
or<CSSPropertyID>& properties) const |
| 518 { | 518 { |
| 519 WillBeHeapVector<CSSProperty, 256> list; | 519 HeapVector<CSSProperty, 256> list; |
| 520 list.reserveInitialCapacity(properties.size()); | 520 list.reserveInitialCapacity(properties.size()); |
| 521 for (unsigned i = 0; i < properties.size(); ++i) { | 521 for (unsigned i = 0; i < properties.size(); ++i) { |
| 522 RefPtrWillBeRawPtr<CSSValue> value = getPropertyCSSValue(properties[i]); | 522 RawPtr<CSSValue> value = getPropertyCSSValue(properties[i]); |
| 523 if (value) | 523 if (value) |
| 524 list.append(CSSProperty(properties[i], value.release(), false)); | 524 list.append(CSSProperty(properties[i], value.release(), false)); |
| 525 } | 525 } |
| 526 return MutableStylePropertySet::create(list.data(), list.size()); | 526 return MutableStylePropertySet::create(list.data(), list.size()); |
| 527 } | 527 } |
| 528 | 528 |
| 529 CSSStyleDeclaration* MutableStylePropertySet::ensureCSSStyleDeclaration() | 529 CSSStyleDeclaration* MutableStylePropertySet::ensureCSSStyleDeclaration() |
| 530 { | 530 { |
| 531 // FIXME: get rid of this weirdness of a CSSStyleDeclaration inside of a | 531 // FIXME: get rid of this weirdness of a CSSStyleDeclaration inside of a |
| 532 // style property set. | 532 // style property set. |
| 533 if (m_cssomWrapper) { | 533 if (m_cssomWrapper) { |
| 534 ASSERT(!static_cast<CSSStyleDeclaration*>(m_cssomWrapper.get())->parentR
ule()); | 534 ASSERT(!static_cast<CSSStyleDeclaration*>(m_cssomWrapper.get())->parentR
ule()); |
| 535 ASSERT(!m_cssomWrapper->parentElement()); | 535 ASSERT(!m_cssomWrapper->parentElement()); |
| 536 return m_cssomWrapper.get(); | 536 return m_cssomWrapper.get(); |
| 537 } | 537 } |
| 538 m_cssomWrapper = adoptPtrWillBeNoop(new PropertySetCSSStyleDeclaration(*this
)); | 538 m_cssomWrapper = new PropertySetCSSStyleDeclaration(*this); |
| 539 return m_cssomWrapper.get(); | 539 return m_cssomWrapper.get(); |
| 540 } | 540 } |
| 541 | 541 |
| 542 template<typename T> | 542 template<typename T> |
| 543 int MutableStylePropertySet::findPropertyIndex(T property) const | 543 int MutableStylePropertySet::findPropertyIndex(T property) const |
| 544 { | 544 { |
| 545 const CSSProperty* begin = m_propertyVector.data(); | 545 const CSSProperty* begin = m_propertyVector.data(); |
| 546 const CSSProperty* end = begin + m_propertyVector.size(); | 546 const CSSProperty* end = begin + m_propertyVector.size(); |
| 547 | 547 |
| 548 uint16_t id = getConvertedCSSPropertyID(property); | 548 uint16_t id = getConvertedCSSPropertyID(property); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 565 StylePropertySet::traceAfterDispatch(visitor); | 565 StylePropertySet::traceAfterDispatch(visitor); |
| 566 } | 566 } |
| 567 | 567 |
| 568 unsigned StylePropertySet::averageSizeInBytes() | 568 unsigned StylePropertySet::averageSizeInBytes() |
| 569 { | 569 { |
| 570 // Please update this if the storage scheme changes so that this longer refl
ects the actual size. | 570 // Please update this if the storage scheme changes so that this longer refl
ects the actual size. |
| 571 return sizeForImmutableStylePropertySetWithPropertyCount(4); | 571 return sizeForImmutableStylePropertySetWithPropertyCount(4); |
| 572 } | 572 } |
| 573 | 573 |
| 574 // See the function above if you need to update this. | 574 // See the function above if you need to update this. |
| 575 struct SameSizeAsStylePropertySet : public RefCountedWillBeGarbageCollectedFinal
ized<SameSizeAsStylePropertySet> { | 575 struct SameSizeAsStylePropertySet : public GarbageCollectedFinalized<SameSizeAsS
tylePropertySet> { |
| 576 unsigned bitfield; | 576 unsigned bitfield; |
| 577 }; | 577 }; |
| 578 static_assert(sizeof(StylePropertySet) == sizeof(SameSizeAsStylePropertySet), "S
tylePropertySet should stay small"); | 578 static_assert(sizeof(StylePropertySet) == sizeof(SameSizeAsStylePropertySet), "S
tylePropertySet should stay small"); |
| 579 | 579 |
| 580 #ifndef NDEBUG | 580 #ifndef NDEBUG |
| 581 void StylePropertySet::showStyle() | 581 void StylePropertySet::showStyle() |
| 582 { | 582 { |
| 583 fprintf(stderr, "%s\n", asText().ascii().data()); | 583 fprintf(stderr, "%s\n", asText().ascii().data()); |
| 584 } | 584 } |
| 585 #endif | 585 #endif |
| 586 | 586 |
| 587 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create(
CSSParserMode cssParserMode) | 587 RawPtr<MutableStylePropertySet> MutableStylePropertySet::create(CSSParserMode cs
sParserMode) |
| 588 { | 588 { |
| 589 return adoptRefWillBeNoop(new MutableStylePropertySet(cssParserMode)); | 589 return new MutableStylePropertySet(cssParserMode); |
| 590 } | 590 } |
| 591 | 591 |
| 592 PassRefPtrWillBeRawPtr<MutableStylePropertySet> MutableStylePropertySet::create(
const CSSProperty* properties, unsigned count) | 592 RawPtr<MutableStylePropertySet> MutableStylePropertySet::create(const CSSPropert
y* properties, unsigned count) |
| 593 { | 593 { |
| 594 return adoptRefWillBeNoop(new MutableStylePropertySet(properties, count)); | 594 return new MutableStylePropertySet(properties, count); |
| 595 } | 595 } |
| 596 | 596 |
| 597 } // namespace blink | 597 } // namespace blink |
| OLD | NEW |