diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-18 15:53:33 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2012-09-18 15:53:33 +0200 |
commit | 6bbb7fbbac94d0f511a7bd0cbd50854ab643bfb2 (patch) | |
tree | d9c68d1cca0b3e352f1e438561f3e504e641a08f /Source/WebCore/dom/SpaceSplitString.cpp | |
parent | d0424a769059c84ae20beb3c217812792ea6726b (diff) | |
download | qtwebkit-6bbb7fbbac94d0f511a7bd0cbd50854ab643bfb2.tar.gz |
Imported WebKit commit c7503cef7ecb236730d1309676ab9fc723fd061d (http://svn.webkit.org/repository/webkit/trunk@128886)
New snapshot with various build fixes
Diffstat (limited to 'Source/WebCore/dom/SpaceSplitString.cpp')
-rw-r--r-- | Source/WebCore/dom/SpaceSplitString.cpp | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/Source/WebCore/dom/SpaceSplitString.cpp b/Source/WebCore/dom/SpaceSplitString.cpp index 9cce7d95b..c301f69ed 100644 --- a/Source/WebCore/dom/SpaceSplitString.cpp +++ b/Source/WebCore/dom/SpaceSplitString.cpp @@ -31,24 +31,31 @@ using namespace WTF; namespace WebCore { -static bool hasNonASCIIOrUpper(const String& string) +template <typename CharacterType> +static inline bool hasNonASCIIOrUpper(const CharacterType* characters, unsigned length) { - const UChar* characters = string.characters(); - unsigned length = string.length(); bool hasUpper = false; - UChar ored = 0; + CharacterType ored = 0; for (unsigned i = 0; i < length; i++) { - UChar c = characters[i]; + CharacterType c = characters[i]; hasUpper |= isASCIIUpper(c); ored |= c; } return hasUpper || (ored & ~0x7F); } -void SpaceSplitStringData::createVector(const String& string) +static inline bool hasNonASCIIOrUpper(const String& string) { - const UChar* characters = string.characters(); unsigned length = string.length(); + + if (string.is8Bit()) + return hasNonASCIIOrUpper(string.characters8(), length); + return hasNonASCIIOrUpper(string.characters16(), length); +} + +template <typename CharacterType> +inline void SpaceSplitStringData::createVector(const CharacterType* characters, unsigned length) +{ unsigned start = 0; while (true) { while (start < length && isHTMLSpace(characters[start])) @@ -65,6 +72,18 @@ void SpaceSplitStringData::createVector(const String& string) } } +void SpaceSplitStringData::createVector(const String& string) +{ + unsigned length = string.length(); + + if (string.is8Bit()) { + createVector(string.characters8(), length); + return; + } + + createVector(string.characters16(), length); +} + bool SpaceSplitStringData::containsAll(SpaceSplitStringData& other) { if (this == &other) |