| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 m_element->deref(); | 150 m_element->deref(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void DatasetDOMStringMap::getNames(Vector<String>& names) | 153 void DatasetDOMStringMap::getNames(Vector<String>& names) |
| 154 { | 154 { |
| 155 if (!m_element->hasAttributes()) | 155 if (!m_element->hasAttributes()) |
| 156 return; | 156 return; |
| 157 | 157 |
| 158 unsigned length = m_element->attributeCount(); | 158 unsigned length = m_element->attributeCount(); |
| 159 for (unsigned i = 0; i < length; i++) { | 159 for (unsigned i = 0; i < length; i++) { |
| 160 const Attribute* attribute = m_element->attributeItem(i); | 160 const Attribute& attribute = m_element->attributeItem(i); |
| 161 if (isValidAttributeName(attribute->localName())) | 161 if (isValidAttributeName(attribute.localName())) |
| 162 names.append(convertAttributeNameToPropertyName(attribute->localName
())); | 162 names.append(convertAttributeNameToPropertyName(attribute.localName(
))); |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 String DatasetDOMStringMap::item(const String& name) | 166 String DatasetDOMStringMap::item(const String& name) |
| 167 { | 167 { |
| 168 if (!m_element->hasAttributes()) | 168 if (!m_element->hasAttributes()) |
| 169 return String(); | 169 return String(); |
| 170 | 170 |
| 171 unsigned length = m_element->attributeCount(); | 171 unsigned length = m_element->attributeCount(); |
| 172 for (unsigned i = 0; i < length; i++) { | 172 for (unsigned i = 0; i < length; i++) { |
| 173 const Attribute* attribute = m_element->attributeItem(i); | 173 const Attribute& attribute = m_element->attributeItem(i); |
| 174 if (propertyNameMatchesAttributeName(name, attribute->localName())) | 174 if (propertyNameMatchesAttributeName(name, attribute.localName())) |
| 175 return attribute->value(); | 175 return attribute.value(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 return String(); | 178 return String(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 bool DatasetDOMStringMap::contains(const String& name) | 181 bool DatasetDOMStringMap::contains(const String& name) |
| 182 { | 182 { |
| 183 if (!m_element->hasAttributes()) | 183 if (!m_element->hasAttributes()) |
| 184 return false; | 184 return false; |
| 185 | 185 |
| 186 unsigned length = m_element->attributeCount(); | 186 unsigned length = m_element->attributeCount(); |
| 187 for (unsigned i = 0; i < length; i++) { | 187 for (unsigned i = 0; i < length; i++) { |
| 188 const Attribute* attribute = m_element->attributeItem(i); | 188 const Attribute& attribute = m_element->attributeItem(i); |
| 189 if (propertyNameMatchesAttributeName(name, attribute->localName())) | 189 if (propertyNameMatchesAttributeName(name, attribute.localName())) |
| 190 return true; | 190 return true; |
| 191 } | 191 } |
| 192 | 192 |
| 193 return false; | 193 return false; |
| 194 } | 194 } |
| 195 | 195 |
| 196 void DatasetDOMStringMap::setItem(const String& name, const String& value, Excep
tionState& exceptionState) | 196 void DatasetDOMStringMap::setItem(const String& name, const String& value, Excep
tionState& exceptionState) |
| 197 { | 197 { |
| 198 if (!isValidPropertyName(name)) { | 198 if (!isValidPropertyName(name)) { |
| 199 exceptionState.throwDOMException(SyntaxError, "'" + name + "' is not a v
alid property name."); | 199 exceptionState.throwDOMException(SyntaxError, "'" + name + "' is not a v
alid property name."); |
| 200 return; | 200 return; |
| 201 } | 201 } |
| 202 | 202 |
| 203 m_element->setAttribute(convertPropertyNameToAttributeName(name), AtomicStri
ng(value), exceptionState); | 203 m_element->setAttribute(convertPropertyNameToAttributeName(name), AtomicStri
ng(value), exceptionState); |
| 204 } | 204 } |
| 205 | 205 |
| 206 bool DatasetDOMStringMap::deleteItem(const String& name) | 206 bool DatasetDOMStringMap::deleteItem(const String& name) |
| 207 { | 207 { |
| 208 if (isValidPropertyName(name)) { | 208 if (isValidPropertyName(name)) { |
| 209 AtomicString attributeName = convertPropertyNameToAttributeName(name); | 209 AtomicString attributeName = convertPropertyNameToAttributeName(name); |
| 210 if (m_element->hasAttribute(attributeName)) { | 210 if (m_element->hasAttribute(attributeName)) { |
| 211 m_element->removeAttribute(attributeName); | 211 m_element->removeAttribute(attributeName); |
| 212 return true; | 212 return true; |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 return false; | 215 return false; |
| 216 } | 216 } |
| 217 | 217 |
| 218 } // namespace WebCore | 218 } // namespace WebCore |
| OLD | NEW |