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 * Copyright (C) 2014 Samsung Electronics. All rights reserved. | 4 * Copyright (C) 2014 Samsung Electronics. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
8 * met: | 8 * met: |
9 * | 9 * |
10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 | 136 |
137 template <typename Container, typename ContainerMemberType> | 137 template <typename Container, typename ContainerMemberType> |
138 inline size_t | 138 inline size_t |
139 AttributeCollectionGeneric<Container, ContainerMemberType>::FindIndex( | 139 AttributeCollectionGeneric<Container, ContainerMemberType>::FindIndex( |
140 const QualifiedName& name, | 140 const QualifiedName& name, |
141 bool should_ignore_case) const { | 141 bool should_ignore_case) const { |
142 iterator end = this->end(); | 142 iterator end = this->end(); |
143 unsigned index = 0; | 143 unsigned index = 0; |
144 for (iterator it = begin(); it != end; ++it, ++index) { | 144 for (iterator it = begin(); it != end; ++it, ++index) { |
145 if (it->GetName().MatchesPossiblyIgnoringCase(name, should_ignore_case)) | 145 if (it->GetName().MatchesPossiblyIgnoringASCIICase(name, |
| 146 should_ignore_case)) |
146 return index; | 147 return index; |
147 } | 148 } |
148 return kNotFound; | 149 return kNotFound; |
149 } | 150 } |
150 | 151 |
151 // We use a boolean parameter instead of calling shouldIgnoreAttributeCase so | 152 // We use a boolean parameter instead of calling shouldIgnoreAttributeCase so |
152 // that the caller can tune the behavior (hasAttribute is case sensitive whereas | 153 // that the caller can tune the behavior (hasAttribute is case sensitive whereas |
153 // getAttribute is not). | 154 // getAttribute is not). |
154 template <typename Container, typename ContainerMemberType> | 155 template <typename Container, typename ContainerMemberType> |
155 inline size_t | 156 inline size_t |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 bool should_ignore_attribute_case) const { | 198 bool should_ignore_attribute_case) const { |
198 // Continue to checking case-insensitively and/or full namespaced names if | 199 // Continue to checking case-insensitively and/or full namespaced names if |
199 // necessary: | 200 // necessary: |
200 iterator end = this->end(); | 201 iterator end = this->end(); |
201 unsigned index = 0; | 202 unsigned index = 0; |
202 for (iterator it = begin(); it != end; ++it, ++index) { | 203 for (iterator it = begin(); it != end; ++it, ++index) { |
203 // FIXME: Why check the prefix? Namespace is all that should matter | 204 // FIXME: Why check the prefix? Namespace is all that should matter |
204 // and all HTML/SVG attributes have a null namespace! | 205 // and all HTML/SVG attributes have a null namespace! |
205 if (!it->GetName().HasPrefix()) { | 206 if (!it->GetName().HasPrefix()) { |
206 if (should_ignore_attribute_case && | 207 if (should_ignore_attribute_case && |
207 DeprecatedEqualIgnoringCase(name, it->LocalName())) | 208 EqualIgnoringASCIICase(name, it->LocalName())) |
208 return index; | 209 return index; |
209 } else { | 210 } else { |
210 // FIXME: Would be faster to do this comparison without calling toString, | 211 // FIXME: Would be faster to do this comparison without calling ToString, |
211 // which generates a temporary string by concatenation. But this branch is | 212 // which generates a temporary string by concatenation. But this branch is |
212 // only reached if the attribute name has a prefix, which is rare in HTML. | 213 // only reached if the attribute name has a prefix, which is rare in HTML. |
213 if (EqualPossiblyIgnoringCase(name, it->GetName().ToString(), | 214 if (EqualPossiblyIgnoringASCIICase(name, it->GetName().ToString(), |
214 should_ignore_attribute_case)) | 215 should_ignore_attribute_case)) |
215 return index; | 216 return index; |
216 } | 217 } |
217 } | 218 } |
218 return kNotFound; | 219 return kNotFound; |
219 } | 220 } |
220 | 221 |
221 } // namespace blink | 222 } // namespace blink |
222 | 223 |
223 #endif // AttributeCollection_h | 224 #endif // AttributeCollection_h |
OLD | NEW |