| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 ElementData::ElementData(const ElementData& other, bool isUnique) | 66 ElementData::ElementData(const ElementData& other, bool isUnique) |
| 67 : m_isUnique(isUnique) | 67 : m_isUnique(isUnique) |
| 68 , m_arraySize(isUnique ? 0 : other.attributes().size()) | 68 , m_arraySize(isUnique ? 0 : other.attributes().size()) |
| 69 , m_styleAttributeIsDirty(other.m_styleAttributeIsDirty) | 69 , m_styleAttributeIsDirty(other.m_styleAttributeIsDirty) |
| 70 , m_classNames(other.m_classNames) | 70 , m_classNames(other.m_classNames) |
| 71 , m_idForStyleResolution(other.m_idForStyleResolution) | 71 , m_idForStyleResolution(other.m_idForStyleResolution) |
| 72 { | 72 { |
| 73 // NOTE: The inline style is copied by the subclass copy constructor since w
e don't know what to do with it here. | 73 // NOTE: The inline style is copied by the subclass copy constructor since w
e don't know what to do with it here. |
| 74 } | 74 } |
| 75 | 75 |
| 76 #if ENABLE(OILPAN) | |
| 77 void ElementData::finalizeGarbageCollectedObject() | |
| 78 { | |
| 79 if (m_isUnique) | |
| 80 toUniqueElementData(this)->~UniqueElementData(); | |
| 81 else | |
| 82 toShareableElementData(this)->~ShareableElementData(); | |
| 83 } | |
| 84 #else | |
| 85 void ElementData::destroy() | 76 void ElementData::destroy() |
| 86 { | 77 { |
| 87 if (m_isUnique) | 78 if (m_isUnique) |
| 88 delete toUniqueElementData(this); | 79 delete toUniqueElementData(this); |
| 89 else | 80 else |
| 90 delete toShareableElementData(this); | 81 delete toShareableElementData(this); |
| 91 } | 82 } |
| 92 #endif | |
| 93 | 83 |
| 94 PassRefPtr<UniqueElementData> ElementData::makeUniqueCopy() const | 84 PassRefPtr<UniqueElementData> ElementData::makeUniqueCopy() const |
| 95 { | 85 { |
| 96 if (isUnique()) | 86 if (isUnique()) |
| 97 return adoptRef(new UniqueElementData(toUniqueElementData(*this))); | 87 return adoptRef(new UniqueElementData(toUniqueElementData(*this))); |
| 98 return adoptRef(new UniqueElementData(toShareableElementData(*this))); | 88 return adoptRef(new UniqueElementData(toShareableElementData(*this))); |
| 99 } | 89 } |
| 100 | 90 |
| 101 bool ElementData::isEquivalent(const ElementData* other) const | 91 bool ElementData::isEquivalent(const ElementData* other) const |
| 102 { | 92 { |
| 103 AttributeCollection attributes = this->attributes(); | 93 AttributeCollection attributes = this->attributes(); |
| 104 if (!other) | 94 if (!other) |
| 105 return attributes.isEmpty(); | 95 return attributes.isEmpty(); |
| 106 | 96 |
| 107 AttributeCollection otherAttributes = other->attributes(); | 97 AttributeCollection otherAttributes = other->attributes(); |
| 108 if (attributes.size() != otherAttributes.size()) | 98 if (attributes.size() != otherAttributes.size()) |
| 109 return false; | 99 return false; |
| 110 | 100 |
| 111 AttributeCollection::iterator end = attributes.end(); | 101 AttributeCollection::iterator end = attributes.end(); |
| 112 for (AttributeCollection::iterator it = attributes.begin(); it != end; ++it)
{ | 102 for (AttributeCollection::iterator it = attributes.begin(); it != end; ++it)
{ |
| 113 const Attribute* otherAttr = otherAttributes.find(it->name()); | 103 const Attribute* otherAttr = otherAttributes.find(it->name()); |
| 114 if (!otherAttr || it->value() != otherAttr->value()) | 104 if (!otherAttr || it->value() != otherAttr->value()) |
| 115 return false; | 105 return false; |
| 116 } | 106 } |
| 117 return true; | 107 return true; |
| 118 } | 108 } |
| 119 | 109 |
| 120 void ElementData::trace(Visitor* visitor) | |
| 121 { | |
| 122 if (m_isUnique) | |
| 123 toUniqueElementData(this)->traceAfterDispatch(visitor); | |
| 124 else | |
| 125 toShareableElementData(this)->traceAfterDispatch(visitor); | |
| 126 } | |
| 127 | |
| 128 void ElementData::traceAfterDispatch(Visitor* visitor) | |
| 129 { | |
| 130 visitor->trace(m_inlineStyle); | |
| 131 } | |
| 132 | |
| 133 ShareableElementData::ShareableElementData(const Vector<Attribute>& attributes) | 110 ShareableElementData::ShareableElementData(const Vector<Attribute>& attributes) |
| 134 : ElementData(attributes.size()) | 111 : ElementData(attributes.size()) |
| 135 { | 112 { |
| 136 for (unsigned i = 0; i < m_arraySize; ++i) | 113 for (unsigned i = 0; i < m_arraySize; ++i) |
| 137 new (&m_attributeArray[i]) Attribute(attributes[i]); | 114 new (&m_attributeArray[i]) Attribute(attributes[i]); |
| 138 } | 115 } |
| 139 | 116 |
| 140 ShareableElementData::~ShareableElementData() | 117 ShareableElementData::~ShareableElementData() |
| 141 { | 118 { |
| 142 for (unsigned i = 0; i < m_arraySize; ++i) | 119 for (unsigned i = 0; i < m_arraySize; ++i) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 { | 165 { |
| 189 return adoptRef(new UniqueElementData); | 166 return adoptRef(new UniqueElementData); |
| 190 } | 167 } |
| 191 | 168 |
| 192 PassRefPtr<ShareableElementData> UniqueElementData::makeShareableCopy() const | 169 PassRefPtr<ShareableElementData> UniqueElementData::makeShareableCopy() const |
| 193 { | 170 { |
| 194 void* slot = WTF::fastMalloc(sizeForShareableElementDataWithAttributeCount(m
_attributeVector.size())); | 171 void* slot = WTF::fastMalloc(sizeForShareableElementDataWithAttributeCount(m
_attributeVector.size())); |
| 195 return adoptRef(new (slot) ShareableElementData(*this)); | 172 return adoptRef(new (slot) ShareableElementData(*this)); |
| 196 } | 173 } |
| 197 | 174 |
| 198 void UniqueElementData::traceAfterDispatch(Visitor* visitor) | |
| 199 { | |
| 200 ElementData::traceAfterDispatch(visitor); | |
| 201 } | |
| 202 | |
| 203 } // namespace blink | 175 } // namespace blink |
| OLD | NEW |