| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2014 Apple Inc. All rights reserved. | 3 * Copyright (C) 2014 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 AttributeCollection attributes() const; | 65 AttributeCollection attributes() const; |
| 66 | 66 |
| 67 bool hasID() const { return !m_idForStyleResolution.isNull(); } | 67 bool hasID() const { return !m_idForStyleResolution.isNull(); } |
| 68 bool hasClass() const { return !m_classNames.isNull(); } | 68 bool hasClass() const { return !m_classNames.isNull(); } |
| 69 | 69 |
| 70 bool isEquivalent(const ElementData* other) const; | 70 bool isEquivalent(const ElementData* other) const; |
| 71 | 71 |
| 72 bool isUnique() const { return m_isUnique; } | 72 bool isUnique() const { return m_isUnique; } |
| 73 | 73 |
| 74 void traceAfterDispatch(Visitor*); | |
| 75 void trace(Visitor*); | |
| 76 | |
| 77 protected: | 74 protected: |
| 78 ElementData(); | 75 ElementData(); |
| 79 explicit ElementData(unsigned arraySize); | 76 explicit ElementData(unsigned arraySize); |
| 80 ElementData(const ElementData&, bool isUnique); | 77 ElementData(const ElementData&, bool isUnique); |
| 81 | 78 |
| 82 // Keep the type in a bitfield instead of using virtual destructors to avoid
adding a vtable. | 79 // Keep the type in a bitfield instead of using virtual destructors to avoid
adding a vtable. |
| 83 unsigned m_isUnique : 1; | 80 unsigned m_isUnique : 1; |
| 84 unsigned m_arraySize : 28; | 81 unsigned m_arraySize : 28; |
| 85 mutable unsigned m_styleAttributeIsDirty : 1; | 82 mutable unsigned m_styleAttributeIsDirty : 1; |
| 86 | 83 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 109 // is a memory optimization since it's very common for many elements to have | 106 // is a memory optimization since it's very common for many elements to have |
| 110 // duplicate sets of attributes (ex. the same classes). | 107 // duplicate sets of attributes (ex. the same classes). |
| 111 class ShareableElementData final : public ElementData { | 108 class ShareableElementData final : public ElementData { |
| 112 public: | 109 public: |
| 113 static PassRefPtr<ShareableElementData> createWithAttributes(const Vector<At
tribute>&); | 110 static PassRefPtr<ShareableElementData> createWithAttributes(const Vector<At
tribute>&); |
| 114 | 111 |
| 115 explicit ShareableElementData(const Vector<Attribute>&); | 112 explicit ShareableElementData(const Vector<Attribute>&); |
| 116 explicit ShareableElementData(const UniqueElementData&); | 113 explicit ShareableElementData(const UniqueElementData&); |
| 117 ~ShareableElementData(); | 114 ~ShareableElementData(); |
| 118 | 115 |
| 119 void traceAfterDispatch(Visitor* visitor) { ElementData::traceAfterDispatch(
visitor); } | |
| 120 | |
| 121 // Add support for placement new as ShareableElementData is not allocated | 116 // Add support for placement new as ShareableElementData is not allocated |
| 122 // with a fixed size. Instead the allocated memory size is computed based on | 117 // with a fixed size. Instead the allocated memory size is computed based on |
| 123 // the number of attributes. This requires us to use Heap::allocate directly | 118 // the number of attributes. This requires us to use Heap::allocate directly |
| 124 // with the computed size and subsequently call placement new with the | 119 // with the computed size and subsequently call placement new with the |
| 125 // allocated memory address. | 120 // allocated memory address. |
| 126 void* operator new(std::size_t, void* location) | 121 void* operator new(std::size_t, void* location) |
| 127 { | 122 { |
| 128 return location; | 123 return location; |
| 129 } | 124 } |
| 130 | 125 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 146 static PassRefPtr<UniqueElementData> create(); | 141 static PassRefPtr<UniqueElementData> create(); |
| 147 PassRefPtr<ShareableElementData> makeShareableCopy() const; | 142 PassRefPtr<ShareableElementData> makeShareableCopy() const; |
| 148 | 143 |
| 149 MutableAttributeCollection attributes(); | 144 MutableAttributeCollection attributes(); |
| 150 AttributeCollection attributes() const; | 145 AttributeCollection attributes() const; |
| 151 | 146 |
| 152 UniqueElementData(); | 147 UniqueElementData(); |
| 153 explicit UniqueElementData(const ShareableElementData&); | 148 explicit UniqueElementData(const ShareableElementData&); |
| 154 explicit UniqueElementData(const UniqueElementData&); | 149 explicit UniqueElementData(const UniqueElementData&); |
| 155 | 150 |
| 156 void traceAfterDispatch(Visitor*); | |
| 157 | |
| 158 AttributeVector m_attributeVector; | 151 AttributeVector m_attributeVector; |
| 159 }; | 152 }; |
| 160 | 153 |
| 161 DEFINE_ELEMENT_DATA_TYPE_CASTS(UniqueElementData, data->isUnique(), data.isUniqu
e()); | 154 DEFINE_ELEMENT_DATA_TYPE_CASTS(UniqueElementData, data->isUnique(), data.isUniqu
e()); |
| 162 | 155 |
| 163 #if !ENABLE(OILPAN) | 156 #if !ENABLE(OILPAN) |
| 164 inline void ElementData::deref() | 157 inline void ElementData::deref() |
| 165 { | 158 { |
| 166 if (!derefBase()) | 159 if (!derefBase()) |
| 167 return; | 160 return; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 187 } | 180 } |
| 188 | 181 |
| 189 inline MutableAttributeCollection UniqueElementData::attributes() | 182 inline MutableAttributeCollection UniqueElementData::attributes() |
| 190 { | 183 { |
| 191 return MutableAttributeCollection(m_attributeVector); | 184 return MutableAttributeCollection(m_attributeVector); |
| 192 } | 185 } |
| 193 | 186 |
| 194 } // namespace blink | 187 } // namespace blink |
| 195 | 188 |
| 196 #endif // ElementData_h | 189 #endif // ElementData_h |
| OLD | NEW |