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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 bool ElementData::isEquivalent(const ElementData* other) const | 98 bool ElementData::isEquivalent(const ElementData* other) const |
99 { | 99 { |
100 if (!other) | 100 if (!other) |
101 return isEmpty(); | 101 return isEmpty(); |
102 | 102 |
103 unsigned length = this->length(); | 103 unsigned length = this->length(); |
104 if (length != other->length()) | 104 if (length != other->length()) |
105 return false; | 105 return false; |
106 | 106 |
107 for (unsigned i = 0; i < length; ++i) { | 107 for (unsigned i = 0; i < length; ++i) { |
108 const Attribute* attribute = attributeItem(i); | 108 const Attribute& attribute = attributeItem(i); |
109 const Attribute* otherAttr = other->getAttributeItem(attribute->name()); | 109 const Attribute* otherAttr = other->getAttributeItem(attribute.name()); |
110 if (!otherAttr || attribute->value() != otherAttr->value()) | 110 if (!otherAttr || attribute.value() != otherAttr->value()) |
111 return false; | 111 return false; |
112 } | 112 } |
113 | 113 |
114 return true; | 114 return true; |
115 } | 115 } |
116 | 116 |
117 size_t ElementData::getAttrIndex(Attr* attr) const | 117 size_t ElementData::getAttrIndex(Attr* attr) const |
118 { | 118 { |
119 // This relies on the fact that Attr's QualifiedName == the Attribute's name
. | 119 // This relies on the fact that Attr's QualifiedName == the Attribute's name
. |
120 unsigned length = this->length(); | 120 unsigned length = this->length(); |
121 for (unsigned i = 0; i < length; ++i) { | 121 for (unsigned i = 0; i < length; ++i) { |
122 if (attributeItem(i)->name() == attr->qualifiedName()) | 122 if (attributeItem(i).name() == attr->qualifiedName()) |
123 return i; | 123 return i; |
124 } | 124 } |
125 return kNotFound; | 125 return kNotFound; |
126 } | 126 } |
127 | 127 |
128 size_t ElementData::getAttributeItemIndexSlowCase(const AtomicString& name, bool
shouldIgnoreAttributeCase) const | 128 size_t ElementData::getAttributeItemIndexSlowCase(const AtomicString& name, bool
shouldIgnoreAttributeCase) const |
129 { | 129 { |
130 // Continue to checking case-insensitively and/or full namespaced names if n
ecessary: | 130 // Continue to checking case-insensitively and/or full namespaced names if n
ecessary: |
131 unsigned length = this->length(); | 131 unsigned length = this->length(); |
132 for (unsigned i = 0; i < length; ++i) { | 132 for (unsigned i = 0; i < length; ++i) { |
133 const Attribute* attribute = attributeItem(i); | 133 const Attribute& attribute = attributeItem(i); |
134 // FIXME: Why check the prefix? Namespace is all that should matter | 134 // FIXME: Why check the prefix? Namespace is all that should matter |
135 // and all HTML/SVG attributes have a null namespace! | 135 // and all HTML/SVG attributes have a null namespace! |
136 if (!attribute->name().hasPrefix()) { | 136 if (!attribute.name().hasPrefix()) { |
137 if (shouldIgnoreAttributeCase && equalIgnoringCase(name, attribute->
localName())) | 137 if (shouldIgnoreAttributeCase && equalIgnoringCase(name, attribute.l
ocalName())) |
138 return i; | 138 return i; |
139 } else { | 139 } else { |
140 // FIXME: Would be faster to do this comparison without calling toSt
ring, which | 140 // FIXME: Would be faster to do this comparison without calling toSt
ring, which |
141 // generates a temporary string by concatenation. But this branch is
only reached | 141 // generates a temporary string by concatenation. But this branch is
only reached |
142 // if the attribute name has a prefix, which is rare in HTML. | 142 // if the attribute name has a prefix, which is rare in HTML. |
143 if (equalPossiblyIgnoringCase(name, attribute->name().toString(), sh
ouldIgnoreAttributeCase)) | 143 if (equalPossiblyIgnoringCase(name, attribute.name().toString(), sho
uldIgnoreAttributeCase)) |
144 return i; | 144 return i; |
145 } | 145 } |
146 } | 146 } |
147 return kNotFound; | 147 return kNotFound; |
148 } | 148 } |
149 | 149 |
150 ShareableElementData::ShareableElementData(const Vector<Attribute>& attributes) | 150 ShareableElementData::ShareableElementData(const Vector<Attribute>& attributes) |
151 : ElementData(attributes.size()) | 151 : ElementData(attributes.size()) |
152 { | 152 { |
153 for (unsigned i = 0; i < m_arraySize; ++i) | 153 for (unsigned i = 0; i < m_arraySize; ++i) |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 { | 219 { |
220 unsigned length = this->length(); | 220 unsigned length = this->length(); |
221 for (unsigned i = 0; i < length; ++i) { | 221 for (unsigned i = 0; i < length; ++i) { |
222 if (m_attributeVector.at(i).name().matches(name)) | 222 if (m_attributeVector.at(i).name().matches(name)) |
223 return &m_attributeVector.at(i); | 223 return &m_attributeVector.at(i); |
224 } | 224 } |
225 return 0; | 225 return 0; |
226 } | 226 } |
227 | 227 |
228 } // namespace WebCore | 228 } // namespace WebCore |
OLD | NEW |