| 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 | 66 |
| 67 ElementData::ElementData(const ElementData& other, bool isUnique) | 67 ElementData::ElementData(const ElementData& other, bool isUnique) |
| 68 : m_isUnique(isUnique), | 68 : m_isUnique(isUnique), |
| 69 m_arraySize(isUnique ? 0 : other.attributes().size()), | 69 m_arraySize(isUnique ? 0 : other.attributes().size()), |
| 70 m_presentationAttributeStyleIsDirty( | 70 m_presentationAttributeStyleIsDirty( |
| 71 other.m_presentationAttributeStyleIsDirty), | 71 other.m_presentationAttributeStyleIsDirty), |
| 72 m_styleAttributeIsDirty(other.m_styleAttributeIsDirty), | 72 m_styleAttributeIsDirty(other.m_styleAttributeIsDirty), |
| 73 m_animatedSVGAttributesAreDirty(other.m_animatedSVGAttributesAreDirty), | 73 m_animatedSVGAttributesAreDirty(other.m_animatedSVGAttributesAreDirty), |
| 74 m_classNames(other.m_classNames), | 74 m_classNames(other.m_classNames), |
| 75 m_idForStyleResolution(other.m_idForStyleResolution) { | 75 m_idForStyleResolution(other.m_idForStyleResolution) { |
| 76 // NOTE: The inline style is copied by the subclass copy constructor since we
don't know what to do with it here. | 76 // NOTE: The inline style is copied by the subclass copy constructor since we |
| 77 // don't know what to do with it here. |
| 77 } | 78 } |
| 78 | 79 |
| 79 void ElementData::finalizeGarbageCollectedObject() { | 80 void ElementData::finalizeGarbageCollectedObject() { |
| 80 if (m_isUnique) | 81 if (m_isUnique) |
| 81 toUniqueElementData(this)->~UniqueElementData(); | 82 toUniqueElementData(this)->~UniqueElementData(); |
| 82 else | 83 else |
| 83 toShareableElementData(this)->~ShareableElementData(); | 84 toShareableElementData(this)->~ShareableElementData(); |
| 84 } | 85 } |
| 85 | 86 |
| 86 UniqueElementData* ElementData::makeUniqueCopy() const { | 87 UniqueElementData* ElementData::makeUniqueCopy() const { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 UniqueElementData::UniqueElementData(const UniqueElementData& other) | 153 UniqueElementData::UniqueElementData(const UniqueElementData& other) |
| 153 : ElementData(other, true), | 154 : ElementData(other, true), |
| 154 m_presentationAttributeStyle(other.m_presentationAttributeStyle), | 155 m_presentationAttributeStyle(other.m_presentationAttributeStyle), |
| 155 m_attributeVector(other.m_attributeVector) { | 156 m_attributeVector(other.m_attributeVector) { |
| 156 m_inlineStyle = | 157 m_inlineStyle = |
| 157 other.m_inlineStyle ? other.m_inlineStyle->mutableCopy() : nullptr; | 158 other.m_inlineStyle ? other.m_inlineStyle->mutableCopy() : nullptr; |
| 158 } | 159 } |
| 159 | 160 |
| 160 UniqueElementData::UniqueElementData(const ShareableElementData& other) | 161 UniqueElementData::UniqueElementData(const ShareableElementData& other) |
| 161 : ElementData(other, true) { | 162 : ElementData(other, true) { |
| 162 // An ShareableElementData should never have a mutable inline StylePropertySet
attached. | 163 // An ShareableElementData should never have a mutable inline StylePropertySet |
| 164 // attached. |
| 163 DCHECK(!other.m_inlineStyle || !other.m_inlineStyle->isMutable()); | 165 DCHECK(!other.m_inlineStyle || !other.m_inlineStyle->isMutable()); |
| 164 m_inlineStyle = other.m_inlineStyle; | 166 m_inlineStyle = other.m_inlineStyle; |
| 165 | 167 |
| 166 unsigned length = other.attributes().size(); | 168 unsigned length = other.attributes().size(); |
| 167 m_attributeVector.reserveCapacity(length); | 169 m_attributeVector.reserveCapacity(length); |
| 168 for (unsigned i = 0; i < length; ++i) | 170 for (unsigned i = 0; i < length; ++i) |
| 169 m_attributeVector.uncheckedAppend(other.m_attributeArray[i]); | 171 m_attributeVector.uncheckedAppend(other.m_attributeArray[i]); |
| 170 } | 172 } |
| 171 | 173 |
| 172 UniqueElementData* UniqueElementData::create() { | 174 UniqueElementData* UniqueElementData::create() { |
| 173 return new UniqueElementData; | 175 return new UniqueElementData; |
| 174 } | 176 } |
| 175 | 177 |
| 176 ShareableElementData* UniqueElementData::makeShareableCopy() const { | 178 ShareableElementData* UniqueElementData::makeShareableCopy() const { |
| 177 void* slot = ThreadHeap::allocate<ElementData>( | 179 void* slot = ThreadHeap::allocate<ElementData>( |
| 178 sizeForShareableElementDataWithAttributeCount(m_attributeVector.size())); | 180 sizeForShareableElementDataWithAttributeCount(m_attributeVector.size())); |
| 179 return new (slot) ShareableElementData(*this); | 181 return new (slot) ShareableElementData(*this); |
| 180 } | 182 } |
| 181 | 183 |
| 182 DEFINE_TRACE_AFTER_DISPATCH(UniqueElementData) { | 184 DEFINE_TRACE_AFTER_DISPATCH(UniqueElementData) { |
| 183 visitor->trace(m_presentationAttributeStyle); | 185 visitor->trace(m_presentationAttributeStyle); |
| 184 ElementData::traceAfterDispatch(visitor); | 186 ElementData::traceAfterDispatch(visitor); |
| 185 } | 187 } |
| 186 | 188 |
| 187 } // namespace blink | 189 } // namespace blink |
| OLD | NEW |