Skip to content
Browse files
Replace JSC::UString by WTF::String

Patch by Benjamin Poulain <> on 2012-08-30
Reviewed by Geoffrey Garen.


Having JSC::UString and WTF::String increase the complexity of working on WebKit, and
add useless conversions in the bindings. It also cause some code bloat.

The performance advantages of UString have been ported over in previous patches. This patch
is the last step: getting rid of UString.

In addition to the simplified code, this also reduce the binary size by 15kb on x86_64.

* API/OpaqueJSString.cpp:
* runtime/Identifier.h:
To avoid changing everything at once, the function named ustring() were kept as is. They
will be renamed in a follow up patch.

* runtime/JSString.h:
Since JSValue::toString() already exist (and return the JSString), the direct accessor is renamed
to ::toWTFString(). We may change ::string() to ::jsString() and ::toWTFString() to ::toString()
in the future.

* runtime/StringPrototype.cpp:
(JSC::substituteBackreferencesSlow): Replace the use of UString::getCharacters<>() by String::getCharactersWithUpconvert<>().


Update the code to use String instead of UString.

On x86_64, this reduces the binary size by 22kb.

Since it is no longer possible to differenciate JSC::jsString() and WebCore::jsString() by the input
types, WebCore::jsString() is renated to WebCore::jsStringWithCache().

Since the cache is using a PtrHash, JSC::jsString() is used in place of the old WebCore::jsString() when
the string is generated locally. This is because the cache can never match in those cases.


Replace UString by String.

* WebCoreSupport/ClientExtension.cpp:
* WebCoreSupport/PagePopupBlackBerry.cpp:


Replace UString by String.

* WebCoreSupport/DumpRenderTreeSupportEfl.cpp:
* ewk/ewk_frame.cpp:


Replace UString by String.

* gdom/ConvertToGCharPrivate.h:


Get rid of UString, replace it by String, and simplify the code when possible.

On x86_64, this reduces the binary size by 7kb.

* Plugins/Hosted/
* Plugins/Hosted/
* Plugins/Hosted/
* WebView/
(-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]):
(-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]):
* WebView/
(-[WebScriptCallFrame functionName]):
(-[WebScriptCallFrame evaluateWebScript:]):
* WebView/WebScriptDebugger.h:
* WebView/
* WebView/


Replace UString by String.

* Api/qwebelement.cpp:


Replace UString by String.

* WebFrame.cpp:
* WebView.cpp:


Update the #includes to use the correct types.

* WebFrame.cpp:
* WebView.cpp:


Update to code to switch from UString to String.

* WebProcess/Plugins/Netscape/JSNPMethod.cpp:
* WebProcess/Plugins/Netscape/JSNPMethod.h:
* WebProcess/Plugins/Netscape/JSNPObject.cpp:
* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:


* wtf/Platform.h: Useless edit to force a full build. This is needed for some bots for some reason.
* wtf/text/WTFString.h: Export a symbol that was exported on UString and needed in WebCore.

Add String::getCharactersWithUpconvert<>(), which is similar to String::getCharacters<>() but with the same
behaviors as UString::getCharacters<>().

String::getCharactersWithUpconvert<>() is useful when manipulating multiple strings, it allow writting code
using 16bits characters if any of the input String is not 8bit.


Get rid of UString.

* DumpRenderTree/efl/WorkQueueItemEfl.cpp:
* gdb/


Update the coding style to avoid mentioning a class that no longer exist.

* coding/coding-style.html:

Canonical link:
git-svn-id: 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Benjamin Poulain authored and BenjaminPoulain committed Aug 30, 2012
1 parent 1f61b7d commit 4965391888601fceba2b1329c55fdcf3eb372811
Showing 303 changed files with 1,348 additions and 2,132 deletions.
@@ -49,7 +49,7 @@ JSCallbackFunction::JSCallbackFunction(JSGlobalObject* globalObject, JSObjectCal

void JSCallbackFunction::finishCreation(JSGlobalData& globalData, const UString& name)
void JSCallbackFunction::finishCreation(JSGlobalData& globalData, const String& name)
Base::finishCreation(globalData, name);
@@ -34,12 +34,12 @@ namespace JSC {
class JSCallbackFunction : public InternalFunction {
JSCallbackFunction(JSGlobalObject*, JSObjectCallAsFunctionCallback);
void finishCreation(JSGlobalData&, const UString& name);
void finishCreation(JSGlobalData&, const String& name);

typedef InternalFunction Base;

static JSCallbackFunction* create(ExecState* exec, JSGlobalObject* globalObject, JSObjectCallAsFunctionCallback callback, const UString& name)
static JSCallbackFunction* create(ExecState* exec, JSGlobalObject* globalObject, JSObjectCallAsFunctionCallback callback, const String& name)
JSCallbackFunction* function = new (NotNull, allocateCell<JSCallbackFunction>(*exec->heap())) JSCallbackFunction(globalObject, callback);
function->finishCreation(exec->globalData(), name);
@@ -171,7 +171,7 @@ class JSCallbackObject : public Parent {
static const unsigned StructureFlags = ProhibitsPropertyCaching | OverridesGetOwnPropertySlot | ImplementsHasInstance | OverridesHasInstance | OverridesVisitChildren | OverridesGetPropertyNames | Parent::StructureFlags;

static UString className(const JSObject*);
static String className(const JSObject*);

static void destroy(JSCell*);

@@ -111,10 +111,10 @@ void JSCallbackObject<Parent>::init(ExecState* exec)

template <class Parent>
UString JSCallbackObject<Parent>::className(const JSObject* object)
String JSCallbackObject<Parent>::className(const JSObject* object)
const JSCallbackObject* thisObject = jsCast<const JSCallbackObject*>(object);
UString thisClassName = thisObject->classRef()->className();
String thisClassName = thisObject->classRef()->className();
if (!thisClassName.isEmpty())
return thisClassName;

@@ -42,20 +42,6 @@ using namespace WTF::Unicode;

const JSClassDefinition kJSClassDefinitionEmpty = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

static inline UString tryCreateStringFromUTF8(const char* string)
if (!string)
return UString();

size_t length = strlen(string);
Vector<UChar, 1024> buffer(length);
UChar* p =;
if (conversionOK != convertUTF8ToUTF16(&string, string + length, &p, p + length))
return UString();

return UString(, p -;

OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* protoClass)
: parentClass(definition->parentClass)
, prototypeClass(0)