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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 , m_classNames(other.m_classNames) | 76 , m_classNames(other.m_classNames) |
77 , m_idForStyleResolution(other.m_idForStyleResolution) | 77 , m_idForStyleResolution(other.m_idForStyleResolution) |
78 { | 78 { |
79 // NOTE: The inline style is copied by the subclass copy constructor since w
e don't know what to do with it here. | 79 // NOTE: The inline style is copied by the subclass copy constructor since w
e don't know what to do with it here. |
80 } | 80 } |
81 | 81 |
82 #if ENABLE(OILPAN) | 82 #if ENABLE(OILPAN) |
83 void ElementData::finalizeGarbageCollectedObject() | 83 void ElementData::finalizeGarbageCollectedObject() |
84 { | 84 { |
85 if (m_isUnique) | 85 if (m_isUnique) |
86 static_cast<UniqueElementData*>(this)->~UniqueElementData(); | 86 toUniqueElementData(this)->~UniqueElementData(); |
87 else | 87 else |
88 static_cast<ShareableElementData*>(this)->~ShareableElementData(); | 88 toShareableElementData(this)->~ShareableElementData(); |
89 } | 89 } |
90 #else | 90 #else |
91 void ElementData::destroy() | 91 void ElementData::destroy() |
92 { | 92 { |
93 if (m_isUnique) | 93 if (m_isUnique) |
94 delete static_cast<UniqueElementData*>(this); | 94 delete toUniqueElementData(this); |
95 else | 95 else |
96 delete static_cast<ShareableElementData*>(this); | 96 delete toShareableElementData(this); |
97 } | 97 } |
98 #endif | 98 #endif |
99 | 99 |
100 PassRefPtrWillBeRawPtr<UniqueElementData> ElementData::makeUniqueCopy() const | 100 PassRefPtrWillBeRawPtr<UniqueElementData> ElementData::makeUniqueCopy() const |
101 { | 101 { |
102 if (isUnique()) | 102 if (isUnique()) |
103 return adoptRefWillBeNoop(new UniqueElementData(static_cast<const Unique
ElementData&>(*this))); | 103 return adoptRefWillBeNoop(new UniqueElementData(toUniqueElementData(*thi
s))); |
104 return adoptRefWillBeNoop(new UniqueElementData(static_cast<const ShareableE
lementData&>(*this))); | 104 return adoptRefWillBeNoop(new UniqueElementData(toShareableElementData(*this
))); |
105 } | 105 } |
106 | 106 |
107 bool ElementData::isEquivalent(const ElementData* other) const | 107 bool ElementData::isEquivalent(const ElementData* other) const |
108 { | 108 { |
109 AttributeCollection attributes = this->attributes(); | 109 AttributeCollection attributes = this->attributes(); |
110 if (!other) | 110 if (!other) |
111 return attributes.isEmpty(); | 111 return attributes.isEmpty(); |
112 | 112 |
113 AttributeCollection otherAttributes = other->attributes(); | 113 AttributeCollection otherAttributes = other->attributes(); |
114 if (attributes.size() != otherAttributes.size()) | 114 if (attributes.size() != otherAttributes.size()) |
115 return false; | 115 return false; |
116 | 116 |
117 AttributeCollection::const_iterator end = attributes.end(); | 117 AttributeCollection::const_iterator end = attributes.end(); |
118 for (AttributeCollection::const_iterator it = attributes.begin(); it != end;
++it) { | 118 for (AttributeCollection::const_iterator it = attributes.begin(); it != end;
++it) { |
119 const Attribute* otherAttr = otherAttributes.find(it->name()); | 119 const Attribute* otherAttr = otherAttributes.find(it->name()); |
120 if (!otherAttr || it->value() != otherAttr->value()) | 120 if (!otherAttr || it->value() != otherAttr->value()) |
121 return false; | 121 return false; |
122 } | 122 } |
123 return true; | 123 return true; |
124 } | 124 } |
125 | 125 |
126 void ElementData::trace(Visitor* visitor) | 126 void ElementData::trace(Visitor* visitor) |
127 { | 127 { |
128 if (m_isUnique) | 128 if (m_isUnique) |
129 static_cast<UniqueElementData*>(this)->traceAfterDispatch(visitor); | 129 toUniqueElementData(this)->traceAfterDispatch(visitor); |
130 else | 130 else |
131 static_cast<ShareableElementData*>(this)->traceAfterDispatch(visitor); | 131 toShareableElementData(this)->traceAfterDispatch(visitor); |
132 } | 132 } |
133 | 133 |
134 void ElementData::traceAfterDispatch(Visitor* visitor) | 134 void ElementData::traceAfterDispatch(Visitor* visitor) |
135 { | 135 { |
136 visitor->trace(m_inlineStyle); | 136 visitor->trace(m_inlineStyle); |
137 } | 137 } |
138 | 138 |
139 ShareableElementData::ShareableElementData(const Vector<Attribute>& attributes) | 139 ShareableElementData::ShareableElementData(const Vector<Attribute>& attributes) |
140 : ElementData(attributes.size()) | 140 : ElementData(attributes.size()) |
141 { | 141 { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 return 0; | 222 return 0; |
223 } | 223 } |
224 | 224 |
225 void UniqueElementData::traceAfterDispatch(Visitor* visitor) | 225 void UniqueElementData::traceAfterDispatch(Visitor* visitor) |
226 { | 226 { |
227 visitor->trace(m_presentationAttributeStyle); | 227 visitor->trace(m_presentationAttributeStyle); |
228 ElementData::traceAfterDispatch(visitor); | 228 ElementData::traceAfterDispatch(visitor); |
229 } | 229 } |
230 | 230 |
231 } // namespace blink | 231 } // namespace blink |
OLD | NEW |