summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/dom/DatasetDOMStringMap.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-25 19:08:45 +0100
committerSteve Block <steveblock@google.com>2011-06-08 13:51:31 +0100
commit2bde8e466a4451c7319e3a072d118917957d6554 (patch)
tree28f4a1b869a513e565c7760d0e6a06e7cf1fe95a /Source/WebCore/dom/DatasetDOMStringMap.cpp
parent6939c99b71d9372d14a0c74a772108052e8c48c8 (diff)
downloadexternal_webkit-2bde8e466a4451c7319e3a072d118917957d6554.zip
external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.gz
external_webkit-2bde8e466a4451c7319e3a072d118917957d6554.tar.bz2
Merge WebKit at r82507: Initial merge by git
Change-Id: I60ce9d780725b58b45e54165733a8ffee23b683e
Diffstat (limited to 'Source/WebCore/dom/DatasetDOMStringMap.cpp')
-rw-r--r--Source/WebCore/dom/DatasetDOMStringMap.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/Source/WebCore/dom/DatasetDOMStringMap.cpp b/Source/WebCore/dom/DatasetDOMStringMap.cpp
index 6359d55..a143743 100644
--- a/Source/WebCore/dom/DatasetDOMStringMap.cpp
+++ b/Source/WebCore/dom/DatasetDOMStringMap.cpp
@@ -72,13 +72,30 @@ static String convertAttributeNameToPropertyName(const String& name)
static bool propertyNameMatchesAttributeName(const String& propertyName, const String& attributeName)
{
- // FIXME: This should be able to match without creating a new string.
-
- if (!isValidAttributeName(attributeName))
+ if (!attributeName.startsWith("data-"))
return false;
- String convertedName = convertAttributeNameToPropertyName(attributeName);
- return (convertedName == propertyName);
+ const UChar* property = propertyName.characters();
+ const UChar* attribute = attributeName.characters();
+ unsigned propertyLength = propertyName.length();
+ unsigned attributeLength = attributeName.length();
+
+ unsigned a = 5;
+ unsigned p = 0;
+ bool wordBoundary = false;
+ while (a < attributeLength && p < propertyLength) {
+ if (attribute[a] == '-' && a + 1 < attributeLength && attribute[a + 1] != '-')
+ wordBoundary = true;
+ else {
+ if ((wordBoundary ? toASCIIUpper(attribute[a]) : attribute[a]) != property[p])
+ return false;
+ p++;
+ wordBoundary = false;
+ }
+ a++;
+ }
+
+ return (a == attributeLength && p == propertyLength);
}
static bool isValidPropertyName(const String& name)