Chromium Code Reviews| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 inline const Attribute* ElementData::attributeBase() const | 178 inline const Attribute* ElementData::attributeBase() const |
| 179 { | 179 { |
| 180 if (m_isUnique) | 180 if (m_isUnique) |
| 181 return static_cast<const UniqueElementData*>(this)->m_attributeVector.be gin(); | 181 return static_cast<const UniqueElementData*>(this)->m_attributeVector.be gin(); |
| 182 return static_cast<const ShareableElementData*>(this)->m_attributeArray; | 182 return static_cast<const ShareableElementData*>(this)->m_attributeArray; |
| 183 } | 183 } |
| 184 | 184 |
| 185 inline size_t ElementData::getAttributeItemIndex(const QualifiedName& name, bool shouldIgnoreCase) const | 185 inline size_t ElementData::getAttributeItemIndex(const QualifiedName& name, bool shouldIgnoreCase) const |
| 186 { | 186 { |
| 187 const Attribute* begin = attributeBase(); | 187 const Attribute* begin = attributeBase(); |
| 188 for (unsigned i = 0; i < length(); ++i) { | 188 unsigned len = length(); |
| 189 for (unsigned i = 0; i < len; ++i) { | |
| 189 const Attribute& attribute = begin[i]; | 190 const Attribute& attribute = begin[i]; |
| 190 if (attribute.name().matchesPossiblyIgnoringCase(name, shouldIgnoreCase) ) | 191 if (attribute.name().matchesPossiblyIgnoringCase(name, shouldIgnoreCase) ) |
| 191 return i; | 192 return i; |
| 192 } | 193 } |
| 193 return kNotFound; | 194 return kNotFound; |
| 194 } | 195 } |
| 195 | 196 |
| 196 // We use a boolean parameter instead of calling shouldIgnoreAttributeCase so th at the caller | 197 // We use a boolean parameter instead of calling shouldIgnoreAttributeCase so th at the caller |
| 197 // can tune the behavior (hasAttribute is case sensitive whereas getAttribute is not). | 198 // can tune the behavior (hasAttribute is case sensitive whereas getAttribute is not). |
| 198 inline size_t ElementData::getAttributeItemIndex(const AtomicString& name, bool shouldIgnoreAttributeCase) const | 199 inline size_t ElementData::getAttributeItemIndex(const AtomicString& name, bool shouldIgnoreAttributeCase) const |
| 199 { | 200 { |
| 200 unsigned len = length(); | 201 unsigned len = length(); |
|
Inactive
2013/12/04 19:14:30
Note that we already cache the length in this meth
| |
| 201 bool doSlowCheck = shouldIgnoreAttributeCase; | 202 bool doSlowCheck = shouldIgnoreAttributeCase; |
| 202 | 203 |
| 203 // Optimize for the case where the attribute exists and its name exactly mat ches. | 204 // Optimize for the case where the attribute exists and its name exactly mat ches. |
| 204 const Attribute* begin = attributeBase(); | 205 const Attribute* begin = attributeBase(); |
| 205 for (unsigned i = 0; i < len; ++i) { | 206 for (unsigned i = 0; i < len; ++i) { |
| 206 const Attribute& attribute = begin[i]; | 207 const Attribute& attribute = begin[i]; |
| 207 if (!attribute.name().hasPrefix()) { | 208 if (!attribute.name().hasPrefix()) { |
| 208 if (name == attribute.localName()) | 209 if (name == attribute.localName()) |
| 209 return i; | 210 return i; |
| 210 } else { | 211 } else { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 } | 246 } |
| 246 | 247 |
| 247 inline Attribute* UniqueElementData::attributeItem(unsigned index) | 248 inline Attribute* UniqueElementData::attributeItem(unsigned index) |
| 248 { | 249 { |
| 249 return &m_attributeVector.at(index); | 250 return &m_attributeVector.at(index); |
| 250 } | 251 } |
| 251 | 252 |
| 252 } // namespace WebCore | 253 } // namespace WebCore |
| 253 | 254 |
| 254 #endif // ElementData_h | 255 #endif // ElementData_h |
| OLD | NEW |