| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 static bool isValidPropertyName(const String& name) | 100 static bool isValidPropertyName(const String& name) |
| 101 { | 101 { |
| 102 unsigned length = name.length(); | 102 unsigned length = name.length(); |
| 103 for (unsigned i = 0; i < length; ++i) { | 103 for (unsigned i = 0; i < length; ++i) { |
| 104 if (name[i] == '-' && (i + 1 < length) && isASCIILower(name[i + 1])) | 104 if (name[i] == '-' && (i + 1 < length) && isASCIILower(name[i + 1])) |
| 105 return false; | 105 return false; |
| 106 } | 106 } |
| 107 return true; | 107 return true; |
| 108 } | 108 } |
| 109 | 109 |
| 110 static String convertPropertyNameToAttributeName(const String& name) | 110 static AtomicString convertPropertyNameToAttributeName(const String& name) |
| 111 { | 111 { |
| 112 StringBuilder builder; | 112 StringBuilder builder; |
| 113 builder.append("data-"); | 113 builder.append("data-"); |
| 114 | 114 |
| 115 unsigned length = name.length(); | 115 unsigned length = name.length(); |
| 116 for (unsigned i = 0; i < length; ++i) { | 116 for (unsigned i = 0; i < length; ++i) { |
| 117 UChar character = name[i]; | 117 UChar character = name[i]; |
| 118 if (isASCIIUpper(character)) { | 118 if (isASCIIUpper(character)) { |
| 119 builder.append('-'); | 119 builder.append('-'); |
| 120 builder.append(toASCIILower(character)); | 120 builder.append(toASCIILower(character)); |
| 121 } else | 121 } else |
| 122 builder.append(character); | 122 builder.append(character); |
| 123 } | 123 } |
| 124 | 124 |
| 125 return builder.toString(); | 125 return builder.toAtomicString(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void DatasetDOMStringMap::ref() | 128 void DatasetDOMStringMap::ref() |
| 129 { | 129 { |
| 130 m_element->ref(); | 130 m_element->ref(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void DatasetDOMStringMap::deref() | 133 void DatasetDOMStringMap::deref() |
| 134 { | 134 { |
| 135 m_element->deref(); | 135 m_element->deref(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 return false; | 178 return false; |
| 179 } | 179 } |
| 180 | 180 |
| 181 void DatasetDOMStringMap::setItem(const String& name, const String& value, Excep
tionState& exceptionState) | 181 void DatasetDOMStringMap::setItem(const String& name, const String& value, Excep
tionState& exceptionState) |
| 182 { | 182 { |
| 183 if (!isValidPropertyName(name)) { | 183 if (!isValidPropertyName(name)) { |
| 184 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::failedT
oSet(name, "DOMStringMap", "'" + name + "' is not a valid property name.")); | 184 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::failedT
oSet(name, "DOMStringMap", "'" + name + "' is not a valid property name.")); |
| 185 return; | 185 return; |
| 186 } | 186 } |
| 187 | 187 |
| 188 m_element->setAttribute(convertPropertyNameToAttributeName(name), value, exc
eptionState); | 188 m_element->setAttribute(convertPropertyNameToAttributeName(name), AtomicStri
ng(value), exceptionState); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void DatasetDOMStringMap::deleteItem(const String& name, ExceptionState& excepti
onState) | 191 void DatasetDOMStringMap::deleteItem(const String& name, ExceptionState& excepti
onState) |
| 192 { | 192 { |
| 193 if (!isValidPropertyName(name)) { | 193 if (!isValidPropertyName(name)) { |
| 194 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::failedT
oDelete(name, "DOMStringMap", "'" + name + "' is not a valid property name.")); | 194 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::failedT
oDelete(name, "DOMStringMap", "'" + name + "' is not a valid property name.")); |
| 195 return; | 195 return; |
| 196 } | 196 } |
| 197 | 197 |
| 198 m_element->removeAttribute(convertPropertyNameToAttributeName(name)); | 198 m_element->removeAttribute(convertPropertyNameToAttributeName(name)); |
| 199 } | 199 } |
| 200 | 200 |
| 201 } // namespace WebCore | 201 } // namespace WebCore |
| OLD | NEW |