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>
Reviewed by Andreas Kling.
......@@ -34,6 +34,8 @@
#include <runtime/StringPrototype.h>
#include <wtf/ASCIICType.h>
#include <wtf/text/AtomicString.h>
#include <wtf/text/StringBuilder.h>
#include <wtf/text/StringConcatenate.h>
using namespace JSC;
using namespace WTF;
......@@ -94,8 +96,8 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo
if (!length)
return String();
Vector<UChar> name;
name.reserveInitialCapacity(length);
StringBuilder builder;
builder.reserveCapacity(length);
unsigned i = 0;
......@@ -112,25 +114,23 @@ static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPo
} else if (hasCSSPropertyNamePrefix(propertyName, "webkit")
|| hasCSSPropertyNamePrefix(propertyName, "khtml")
|| hasCSSPropertyNamePrefix(propertyName, "apple"))
name.append('-');
builder.append('-');
else {
if (isASCIIUpper(propertyName.characters()[0]))
return String();
}
name.append(toASCIILower(propertyName.characters()[i++]));
builder.append(toASCIILower(propertyName.characters()[i++]));
for (; i < length; ++i) {
UChar c = propertyName.characters()[i];
if (!isASCIIUpper(c))
name.append(c);
else {
name.append('-');
name.append(toASCIILower(c));
}
builder.append(c);
else
builder.append(makeString('-', toASCIILower(c)));
}
return String::adopt(name);
return builder.toString();
}
static bool isCSSPropertyName(const Identifier& propertyName)
......
......@@ -40,6 +40,8 @@
#include "V8Binding.h"
#include "V8Proxy.h"
#include <wtf/text/StringBuilder.h>
#include <wtf/text/StringConcatenate.h>
#include <wtf/ASCIICType.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
......@@ -107,8 +109,8 @@ static CSSPropertyInfo* cssPropertyInfo(v8::Handle<v8::String>v8PropertyName)
if (!length)
return 0;
Vector<UChar> name;
name.reserveCapacity(length);
StringBuilder builder;
builder.reserveCapacity(length);
unsigned i = 0;
......@@ -123,23 +125,21 @@ static CSSPropertyInfo* cssPropertyInfo(v8::Handle<v8::String>v8PropertyName)
} else if (hasCSSPropertyNamePrefix(propertyName, "webkit")
|| hasCSSPropertyNamePrefix(propertyName, "khtml")
|| hasCSSPropertyNamePrefix(propertyName, "apple"))
name.append('-');
builder.append('-');
else if (WTF::isASCIIUpper(propertyName[0]))
return 0;
name.append(WTF::toASCIILower(propertyName[i++]));
builder.append(WTF::toASCIILower(propertyName[i++]));
for (; i < length; ++i) {
UChar c = propertyName[i];
if (!WTF::isASCIIUpper(c))
name.append(c);
else {
name.append('-');
name.append(WTF::toASCIILower(c));
}
builder.append(c);
else
builder.append(makeString('-', toASCIILower(c)));
}
String propName = String::adopt(name);
String propName = builder.toString();
int propertyID = cssPropertyID(propName);
if (propertyID) {
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