Commit 22572760 authored by zimmermann@webkit.org's avatar zimmermann@webkit.org

2011-04-05 Nikolas Zimmermann <nzimmermann@rim.com>

        Reviewed by Andreas Kling.

        Switch from Vector<UChar> to StringBuilder in bindings/
        https://bugs.webkit.org/show_bug.cgi?id=57838

        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
        (WebCore::cssPropertyName):
        * bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp:
        (WebCore::cssPropertyInfo):


git-svn-id: svn://svn.chromium.org/blink/trunk@82935 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 1e88dd0b
2011-04-05 Nikolas Zimmermann <nzimmermann@rim.com>
Reviewed by Andreas Kling.
Switch from Vector<UChar> to StringBuilder in bindings/
https://bugs.webkit.org/show_bug.cgi?id=57838
* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::cssPropertyName):
* bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp:
(WebCore::cssPropertyInfo):
2011-04-05 Nikolas Zimmermann <nzimmermann@rim.com> 2011-04-05 Nikolas Zimmermann <nzimmermann@rim.com>
Reviewed by Andreas Kling. Reviewed by Andreas Kling.
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include <runtime/StringPrototype.h> #include <runtime/StringPrototype.h>
#include <wtf/ASCIICType.h> #include <wtf/ASCIICType.h>
#include <wtf/text/AtomicString.h> #include <wtf/text/AtomicString.h>
#include <wtf/text/StringBuilder.h>
#include <wtf/text/StringConcatenate.h>
using namespace JSC; using namespace JSC;
using namespace WTF; using namespace WTF;
...@@ -94,8 +96,8 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo ...@@ -94,8 +96,8 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo
if (!length) if (!length)
return String(); return String();
Vector<UChar> name; StringBuilder builder;
name.reserveInitialCapacity(length); builder.reserveCapacity(length);
unsigned i = 0; unsigned i = 0;
...@@ -112,25 +114,23 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo ...@@ -112,25 +114,23 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo
} else if (hasCSSPropertyNamePrefix(propertyName, "webkit") } else if (hasCSSPropertyNamePrefix(propertyName, "webkit")
|| hasCSSPropertyNamePrefix(propertyName, "khtml") || hasCSSPropertyNamePrefix(propertyName, "khtml")
|| hasCSSPropertyNamePrefix(propertyName, "apple")) || hasCSSPropertyNamePrefix(propertyName, "apple"))
name.append('-'); builder.append('-');
else { else {
if (isASCIIUpper(propertyName.characters()[0])) if (isASCIIUpper(propertyName.characters()[0]))
return String(); return String();
} }
name.append(toASCIILower(propertyName.characters()[i++])); builder.append(toASCIILower(propertyName.characters()[i++]));
for (; i < length; ++i) { for (; i < length; ++i) {
UChar c = propertyName.characters()[i]; UChar c = propertyName.characters()[i];
if (!isASCIIUpper(c)) if (!isASCIIUpper(c))
name.append(c); builder.append(c);
else { else
name.append('-'); builder.append(makeString('-', toASCIILower(c)));
name.append(toASCIILower(c));
}
} }
return String::adopt(name); return builder.toString();
} }
static bool isCSSPropertyName(const Identifier& propertyName) static bool isCSSPropertyName(const Identifier& propertyName)
......
...@@ -40,6 +40,8 @@ ...@@ -40,6 +40,8 @@
#include "V8Binding.h" #include "V8Binding.h"
#include "V8Proxy.h" #include "V8Proxy.h"
#include <wtf/text/StringBuilder.h>
#include <wtf/text/StringConcatenate.h>
#include <wtf/ASCIICType.h> #include <wtf/ASCIICType.h>
#include <wtf/PassRefPtr.h> #include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h> #include <wtf/RefPtr.h>
...@@ -107,8 +109,8 @@ static CSSPropertyInfo* cssPropertyInfo(v8::Handle<v8::String>v8PropertyName) ...@@ -107,8 +109,8 @@ static CSSPropertyInfo* cssPropertyInfo(v8::Handle<v8::String>v8PropertyName)
if (!length) if (!length)
return 0; return 0;
Vector<UChar> name; StringBuilder builder;
name.reserveCapacity(length); builder.reserveCapacity(length);
unsigned i = 0; unsigned i = 0;
...@@ -123,23 +125,21 @@ static CSSPropertyInfo* cssPropertyInfo(v8::Handle<v8::String>v8PropertyName) ...@@ -123,23 +125,21 @@ static CSSPropertyInfo* cssPropertyInfo(v8::Handle<v8::String>v8PropertyName)
} else if (hasCSSPropertyNamePrefix(propertyName, "webkit") } else if (hasCSSPropertyNamePrefix(propertyName, "webkit")
|| hasCSSPropertyNamePrefix(propertyName, "khtml") || hasCSSPropertyNamePrefix(propertyName, "khtml")
|| hasCSSPropertyNamePrefix(propertyName, "apple")) || hasCSSPropertyNamePrefix(propertyName, "apple"))
name.append('-'); builder.append('-');
else if (WTF::isASCIIUpper(propertyName[0])) else if (WTF::isASCIIUpper(propertyName[0]))
return 0; return 0;
name.append(WTF::toASCIILower(propertyName[i++])); builder.append(WTF::toASCIILower(propertyName[i++]));
for (; i < length; ++i) { for (; i < length; ++i) {
UChar c = propertyName[i]; UChar c = propertyName[i];
if (!WTF::isASCIIUpper(c)) if (!WTF::isASCIIUpper(c))
name.append(c); builder.append(c);
else { else
name.append('-'); builder.append(makeString('-', toASCIILower(c)));
name.append(WTF::toASCIILower(c));
}
} }
String propName = String::adopt(name); String propName = builder.toString();
int propertyID = cssPropertyID(propName); int propertyID = cssPropertyID(propName);
if (propertyID) { if (propertyID) {
propInfo = new CSSPropertyInfo(); propInfo = new CSSPropertyInfo();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment