summaryrefslogtreecommitdiffstats
path: root/WebCore/dom/StyledElement.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-10-22 13:02:20 +0100
committerBen Murdoch <benm@google.com>2010-10-26 15:21:41 +0100
commita94275402997c11dd2e778633dacf4b7e630a35d (patch)
treee66f56c67e3b01f22c9c23cd932271ee9ac558ed /WebCore/dom/StyledElement.cpp
parent09e26c78506587b3f5d930d7bc72a23287ffbec0 (diff)
downloadexternal_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.zip
external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.gz
external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.bz2
Merge WebKit at r70209: Initial merge by Git
Change-Id: Id23a68efa36e9d1126bcce0b137872db00892c8e
Diffstat (limited to 'WebCore/dom/StyledElement.cpp')
-rw-r--r--WebCore/dom/StyledElement.cpp70
1 files changed, 17 insertions, 53 deletions
diff --git a/WebCore/dom/StyledElement.cpp b/WebCore/dom/StyledElement.cpp
index f07fda9..12744cb 100644
--- a/WebCore/dom/StyledElement.cpp
+++ b/WebCore/dom/StyledElement.cpp
@@ -31,6 +31,7 @@
#include "DOMTokenList.h"
#include "Document.h"
#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
#include <wtf/HashFunctions.h>
using namespace std;
@@ -213,7 +214,7 @@ void StyledElement::classAttributeChanged(const AtomicString& newClassString)
unsigned length = newClassString.length();
unsigned i;
for (i = 0; i < length; ++i) {
- if (!isClassWhitespace(characters[i]))
+ if (isNotHTMLSpace(characters[i]))
break;
}
bool hasClass = i < length;
@@ -401,62 +402,25 @@ void StyledElement::createMappedDecl(Attribute* attr)
decl->setStrictParsing(false); // Mapped attributes are just always quirky.
}
-// Paul Hsieh's SuperFastHash
-// http://www.azillionmonkeys.com/qed/hash.html
unsigned MappedAttributeHash::hash(const MappedAttributeKey& key)
{
- uint32_t hash = WTF::stringHashingStartValue;
- uint32_t tmp;
-
- const uint16_t* p;
-
- p = reinterpret_cast<const uint16_t*>(&key.name);
- hash += p[0];
- tmp = (p[1] << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- hash += hash >> 11;
- ASSERT(sizeof(key.name) == 4 || sizeof(key.name) == 8);
- if (sizeof(key.name) == 8) {
- p += 2;
- hash += p[0];
- tmp = (p[1] << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- hash += hash >> 11;
- }
+ COMPILE_ASSERT(sizeof(key.name) == 4 || sizeof(key.name) == 8, key_name_size);
+ COMPILE_ASSERT(sizeof(key.value) == 4 || sizeof(key.value) == 8, key_value_size);
- p = reinterpret_cast<const uint16_t*>(&key.value);
- hash += p[0];
- tmp = (p[1] << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- hash += hash >> 11;
- ASSERT(sizeof(key.value) == 4 || sizeof(key.value) == 8);
- if (sizeof(key.value) == 8) {
- p += 2;
- hash += p[0];
- tmp = (p[1] << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- hash += hash >> 11;
- }
+ WTF::StringHasher hasher;
+ const UChar* data;
+
+ data = reinterpret_cast<const UChar*>(&key.name);
+ hasher.addCharacters(data[0], data[1]);
+ if (sizeof(key.name) == 8)
+ hasher.addCharacters(data[2], data[3]);
+
+ data = reinterpret_cast<const UChar*>(&key.value);
+ hasher.addCharacters(data[0], data[1]);
+ if (sizeof(key.value) == 8)
+ hasher.addCharacters(data[2], data[3]);
- // Handle end case
- hash += key.type;
- hash ^= hash << 11;
- hash += hash >> 17;
-
- // Force "avalanching" of final 127 bits
- hash ^= hash << 3;
- hash += hash >> 5;
- hash ^= hash << 2;
- hash += hash >> 15;
- hash ^= hash << 10;
-
- // This avoids ever returning a hash code of 0, since that is used to
- // signal "hash not computed yet", using a value that is likely to be
- // effectively the same as 0 when the low bits are masked
- if (hash == 0)
- hash = 0x80000000;
-
- return hash;
+ return hasher.hash();
}
void StyledElement::copyNonAttributeProperties(const Element *sourceElement)