Commit 49a688c5 authored by barraclough@apple.com's avatar barraclough@apple.com

https://bugs.webkit.org/show_bug.cgi?id=37675

Remove casts/constructors to/from JSC::UString type from WebCore::String
        
Reviewed by Sam Weinig & Oliver Hunt.

WebCore's strings should not know about JSC::UString, this should be abstracted
away in the bindings.  Add explicit conversion methods rather than relying on
overloaded cast operators / constructors being implicitly called.

This patch only changes the class String, once this has landed StringImpl, and
hopefully AtomicString too, should follow suit.

WebCore: 

This patch adds:
    WebCore::identifierToString
    WebCore::ustringToString
    WebCore::stringToUString

- to JSDOMBindings.h, and updates code to call these methods.

* WebCore.base.exp:
* WebCore.order:
* bindings/js/CachedScriptSourceProvider.h:
(WebCore::CachedScriptSourceProvider::CachedScriptSourceProvider):
* bindings/js/JSAudioConstructor.cpp:
(WebCore::constructAudio):
* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::JSCSSStyleDeclaration::nameGetter):
* bindings/js/JSCanvasRenderingContext2DCustom.cpp:
(WebCore::toHTMLCanvasStyle):
(WebCore::JSCanvasRenderingContext2D::setFillColor):
(WebCore::JSCanvasRenderingContext2D::setStrokeColor):
(WebCore::JSCanvasRenderingContext2D::drawImageFromRect):
(WebCore::JSCanvasRenderingContext2D::setShadow):
(WebCore::JSCanvasRenderingContext2D::fillText):
(WebCore::JSCanvasRenderingContext2D::strokeText):
* bindings/js/JSClipboardCustom.cpp:
(WebCore::JSClipboard::types):
(WebCore::JSClipboard::clearData):
(WebCore::JSClipboard::getData):
(WebCore::JSClipboard::setData):
* bindings/js/JSCustomXPathNSResolver.cpp:
(WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
* bindings/js/JSDOMBinding.cpp:
(WebCore::identifierToString):
(WebCore::ustringToString):
(WebCore::stringToUString):
(WebCore::valueToStringWithNullCheck):
(WebCore::valueToStringWithUndefinedOrNullCheck):
(WebCore::reportException):
* bindings/js/JSDOMBinding.h:
* bindings/js/JSDOMFormDataCustom.cpp:
(WebCore::JSDOMFormData::append):
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::namedItemGetter):
(WebCore::JSDOMWindow::setLocation):
(WebCore::JSDOMWindow::openDatabase):
* bindings/js/JSDatabaseCustom.cpp:
(WebCore::JSDatabase::changeVersion):
* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::setLocation):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::handleEvent):
* bindings/js/JSEventSourceConstructor.cpp:
(WebCore::constructEventSource):
* bindings/js/JSHTMLAllCollectionCustom.cpp:
(WebCore::callHTMLAllCollection):
* bindings/js/JSHTMLCanvasElementCustom.cpp:
(WebCore::JSHTMLCanvasElement::getContext):
* bindings/js/JSHTMLCollectionCustom.cpp:
(WebCore::callHTMLCollection):
* bindings/js/JSHTMLDocumentCustom.cpp:
(WebCore::JSHTMLDocument::nameGetter):
(WebCore::documentWrite):
* bindings/js/JSInjectedScriptHostCustom.cpp:
(WebCore::InjectedScriptHost::createInjectedScript):
* bindings/js/JSInspectorFrontendHostCustom.cpp:
(WebCore::JSInspectorFrontendHost::showContextMenu):
* bindings/js/JSLazyEventListener.cpp:
(WebCore::JSLazyEventListener::initializeJSFunction):
* bindings/js/JSLocationCustom.cpp:
(WebCore::JSLocation::setHref):
(WebCore::JSLocation::setProtocol):
(WebCore::JSLocation::setHost):
(WebCore::JSLocation::setHostname):
(WebCore::JSLocation::setPathname):
(WebCore::JSLocation::setSearch):
(WebCore::JSLocation::setHash):
(WebCore::JSLocation::replace):
(WebCore::JSLocation::assign):
* bindings/js/JSMessageEventCustom.cpp:
(WebCore::JSMessageEvent::initMessageEvent):
* bindings/js/JSNamedNodeMapCustom.cpp:
(WebCore::JSNamedNodeMap::canGetItemsForName):
(WebCore::JSNamedNodeMap::nameGetter):
* bindings/js/JSOptionConstructor.cpp:
(WebCore::constructHTMLOptionElement):
* bindings/js/JSSQLResultSetRowListCustom.cpp:
(WebCore::JSSQLResultSetRowList::item):
* bindings/js/JSSQLTransactionCustom.cpp:
(WebCore::JSSQLTransaction::executeSql):
* bindings/js/JSSharedWorkerConstructor.cpp:
(WebCore::constructSharedWorker):
* bindings/js/JSStorageCustom.cpp:
(WebCore::JSStorage::canGetItemsForName):
(WebCore::JSStorage::nameGetter):
(WebCore::JSStorage::deleteProperty):
(WebCore::JSStorage::getOwnPropertyNames):
(WebCore::JSStorage::putDelegate):
* bindings/js/JSStyleSheetListCustom.cpp:
(WebCore::JSStyleSheetList::canGetItemsForName):
(WebCore::JSStyleSheetList::nameGetter):
* bindings/js/JSWebKitCSSMatrixConstructor.cpp:
(WebCore::constructWebKitCSSMatrix):
* bindings/js/JSWebSocketConstructor.cpp:
(WebCore::constructWebSocket):
* bindings/js/JSWebSocketCustom.cpp:
(WebCore::JSWebSocket::send):
* bindings/js/JSWorkerConstructor.cpp:
(WebCore::constructWorker):
* bindings/js/JSWorkerContextCustom.cpp:
(WebCore::JSWorkerContext::importScripts):
* bindings/js/JSXMLHttpRequestCustom.cpp:
(WebCore::JSXMLHttpRequest::open):
(WebCore::JSXMLHttpRequest::setRequestHeader):
(WebCore::JSXMLHttpRequest::send):
(WebCore::JSXMLHttpRequest::overrideMimeType):
* bindings/js/JSXSLTProcessorCustom.cpp:
(WebCore::JSXSLTProcessor::setParameter):
(WebCore::JSXSLTProcessor::getParameter):
(WebCore::JSXSLTProcessor::removeParameter):
* bindings/js/ScheduledAction.cpp:
(WebCore::ScheduledAction::create):
* bindings/js/ScriptCallFrame.cpp:
(WebCore::ScriptCallFrame::ScriptCallFrame):
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::evaluateInWorld):
* bindings/js/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::hasBreakpoint):
(WebCore::ScriptDebugServer::dispatchDidParseSource):
(WebCore::ScriptDebugServer::dispatchFailedToParseSource):
(WebCore::ScriptDebugServer::sourceParsed):
* bindings/js/ScriptEventListener.cpp:
(WebCore::getEventListenerHandlerBody):
* bindings/js/ScriptFunctionCall.cpp:
(WebCore::ScriptFunctionCall::appendArgument):
(WebCore::ScriptFunctionCall::call):
(WebCore::ScriptFunctionCall::construct):
* bindings/js/ScriptObject.cpp:
(WebCore::ScriptObject::set):
* bindings/js/ScriptProfiler.cpp:
(WebCore::ScriptProfiler::start):
(WebCore::ScriptProfiler::stop):
* bindings/js/ScriptString.h:
(WebCore::ScriptString::operator String):
(WebCore::ScriptString::ustring):
(WebCore::ScriptString::operator+=):
* bindings/js/ScriptValue.cpp:
(WebCore::ScriptValue::getString):
* bindings/js/ScriptValue.h:
(WebCore::ScriptValue::toString):
* bindings/js/SerializedScriptValue.cpp:
(WebCore::SerializedObject::set):
(WebCore::SerializingTreeWalker::convertIfTerminal):
(WebCore::DeserializingTreeWalker::putProperty):
* bindings/js/StringSourceProvider.h:
(WebCore::StringSourceProvider::StringSourceProvider):
* bindings/objc/WebScriptObject.mm:
(-[WebScriptObject callWebScriptMethod:withArguments:]):
(-[WebScriptObject setValue:forKey:]):
(-[WebScriptObject valueForKey:]):
(-[WebScriptObject removeWebScriptKey:]):
* bindings/scripts/CodeGeneratorJS.pm:
* bridge/IdentifierRep.cpp:
(WebCore::IdentifierRep::get):
* bridge/c/c_utility.cpp:
(JSC::Bindings::identifierFromNPIdentifier):
* inspector/InspectorController.cpp:
(WebCore::InspectorController::scriptImported):
(WebCore::InspectorController::addProfileFinishedMessageToConsole):
(WebCore::InspectorController::createProfileHeader):
* inspector/InspectorResource.cpp:
(WebCore::InspectorResource::sourceString):
* inspector/JavaScriptCallFrame.cpp:
(WebCore::JavaScriptCallFrame::functionName):
* platform/KURL.h:
(WebCore::KURL::operator const String&):
* platform/text/AtomicString.cpp:
(WebCore::AtomicString::operator UString):
* platform/text/AtomicString.h:
* platform/text/PlatformString.h:
* platform/text/String.cpp:

WebKit/mac: 

* Plugins/Hosted/NetscapePluginHostProxy.mm:
(identifierFromIdentifierRep):
* Plugins/Hosted/NetscapePluginInstanceProxy.mm:
(WebKit::NetscapePluginInstanceProxy::addValueToArray):
(WebKit::NetscapePluginInstanceProxy::moveGlobalExceptionToExecState):
* Plugins/Hosted/ProxyInstance.mm:
(WebKit::ProxyInstance::getPropertyNames):
* WebView/WebFrame.mm:
(-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]):
(-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]):
* WebView/WebScriptDebugDelegate.mm:
(-[WebScriptCallFrame evaluateWebScript:]):
* WebView/WebScriptDebugger.mm:
(toNSURL):
* WebView/WebView.mm:
(aeDescFromJSValue):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@57738 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 94395e1c
2010-04-15 Gavin Barraclough <barraclough@apple.com>
Reviewed by Sam Weinig & Oliver Hunt.
https://bugs.webkit.org/show_bug.cgi?id=37675
Remove casts/constructors to/from JSC::UString type from WebCore::String
WebCore's strings should not know about JSC::UString, this should be abstracted
away in the bindings. Add explicit conversion methods rather than relying on
overloaded cast operators / constructors being implicitly called.
This patch only changes the class String, once this has landed StringImpl, and
hopefully AtomicString too, should follow suit.
This patch adds:
WebCore::identifierToString
WebCore::ustringToString
WebCore::stringToUString
- to JSDOMBindings.h, and updates code to call these methods.
* WebCore.base.exp:
* WebCore.order:
* bindings/js/CachedScriptSourceProvider.h:
(WebCore::CachedScriptSourceProvider::CachedScriptSourceProvider):
* bindings/js/JSAudioConstructor.cpp:
(WebCore::constructAudio):
* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::JSCSSStyleDeclaration::nameGetter):
* bindings/js/JSCanvasRenderingContext2DCustom.cpp:
(WebCore::toHTMLCanvasStyle):
(WebCore::JSCanvasRenderingContext2D::setFillColor):
(WebCore::JSCanvasRenderingContext2D::setStrokeColor):
(WebCore::JSCanvasRenderingContext2D::drawImageFromRect):
(WebCore::JSCanvasRenderingContext2D::setShadow):
(WebCore::JSCanvasRenderingContext2D::fillText):
(WebCore::JSCanvasRenderingContext2D::strokeText):
* bindings/js/JSClipboardCustom.cpp:
(WebCore::JSClipboard::types):
(WebCore::JSClipboard::clearData):
(WebCore::JSClipboard::getData):
(WebCore::JSClipboard::setData):
* bindings/js/JSCustomXPathNSResolver.cpp:
(WebCore::JSCustomXPathNSResolver::lookupNamespaceURI):
* bindings/js/JSDOMBinding.cpp:
(WebCore::identifierToString):
(WebCore::ustringToString):
(WebCore::stringToUString):
(WebCore::valueToStringWithNullCheck):
(WebCore::valueToStringWithUndefinedOrNullCheck):
(WebCore::reportException):
* bindings/js/JSDOMBinding.h:
* bindings/js/JSDOMFormDataCustom.cpp:
(WebCore::JSDOMFormData::append):
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::namedItemGetter):
(WebCore::JSDOMWindow::setLocation):
(WebCore::JSDOMWindow::openDatabase):
* bindings/js/JSDatabaseCustom.cpp:
(WebCore::JSDatabase::changeVersion):
* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::setLocation):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::handleEvent):
* bindings/js/JSEventSourceConstructor.cpp:
(WebCore::constructEventSource):
* bindings/js/JSHTMLAllCollectionCustom.cpp:
(WebCore::callHTMLAllCollection):
* bindings/js/JSHTMLCanvasElementCustom.cpp:
(WebCore::JSHTMLCanvasElement::getContext):
* bindings/js/JSHTMLCollectionCustom.cpp:
(WebCore::callHTMLCollection):
* bindings/js/JSHTMLDocumentCustom.cpp:
(WebCore::JSHTMLDocument::nameGetter):
(WebCore::documentWrite):
* bindings/js/JSInjectedScriptHostCustom.cpp:
(WebCore::InjectedScriptHost::createInjectedScript):
* bindings/js/JSInspectorFrontendHostCustom.cpp:
(WebCore::JSInspectorFrontendHost::showContextMenu):
* bindings/js/JSLazyEventListener.cpp:
(WebCore::JSLazyEventListener::initializeJSFunction):
* bindings/js/JSLocationCustom.cpp:
(WebCore::JSLocation::setHref):
(WebCore::JSLocation::setProtocol):
(WebCore::JSLocation::setHost):
(WebCore::JSLocation::setHostname):
(WebCore::JSLocation::setPathname):
(WebCore::JSLocation::setSearch):
(WebCore::JSLocation::setHash):
(WebCore::JSLocation::replace):
(WebCore::JSLocation::assign):
* bindings/js/JSMessageEventCustom.cpp:
(WebCore::JSMessageEvent::initMessageEvent):
* bindings/js/JSNamedNodeMapCustom.cpp:
(WebCore::JSNamedNodeMap::canGetItemsForName):
(WebCore::JSNamedNodeMap::nameGetter):
* bindings/js/JSOptionConstructor.cpp:
(WebCore::constructHTMLOptionElement):
* bindings/js/JSSQLResultSetRowListCustom.cpp:
(WebCore::JSSQLResultSetRowList::item):
* bindings/js/JSSQLTransactionCustom.cpp:
(WebCore::JSSQLTransaction::executeSql):
* bindings/js/JSSharedWorkerConstructor.cpp:
(WebCore::constructSharedWorker):
* bindings/js/JSStorageCustom.cpp:
(WebCore::JSStorage::canGetItemsForName):
(WebCore::JSStorage::nameGetter):
(WebCore::JSStorage::deleteProperty):
(WebCore::JSStorage::getOwnPropertyNames):
(WebCore::JSStorage::putDelegate):
* bindings/js/JSStyleSheetListCustom.cpp:
(WebCore::JSStyleSheetList::canGetItemsForName):
(WebCore::JSStyleSheetList::nameGetter):
* bindings/js/JSWebKitCSSMatrixConstructor.cpp:
(WebCore::constructWebKitCSSMatrix):
* bindings/js/JSWebSocketConstructor.cpp:
(WebCore::constructWebSocket):
* bindings/js/JSWebSocketCustom.cpp:
(WebCore::JSWebSocket::send):
* bindings/js/JSWorkerConstructor.cpp:
(WebCore::constructWorker):
* bindings/js/JSWorkerContextCustom.cpp:
(WebCore::JSWorkerContext::importScripts):
* bindings/js/JSXMLHttpRequestCustom.cpp:
(WebCore::JSXMLHttpRequest::open):
(WebCore::JSXMLHttpRequest::setRequestHeader):
(WebCore::JSXMLHttpRequest::send):
(WebCore::JSXMLHttpRequest::overrideMimeType):
* bindings/js/JSXSLTProcessorCustom.cpp:
(WebCore::JSXSLTProcessor::setParameter):
(WebCore::JSXSLTProcessor::getParameter):
(WebCore::JSXSLTProcessor::removeParameter):
* bindings/js/ScheduledAction.cpp:
(WebCore::ScheduledAction::create):
* bindings/js/ScriptCallFrame.cpp:
(WebCore::ScriptCallFrame::ScriptCallFrame):
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::evaluateInWorld):
* bindings/js/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::hasBreakpoint):
(WebCore::ScriptDebugServer::dispatchDidParseSource):
(WebCore::ScriptDebugServer::dispatchFailedToParseSource):
(WebCore::ScriptDebugServer::sourceParsed):
* bindings/js/ScriptEventListener.cpp:
(WebCore::getEventListenerHandlerBody):
* bindings/js/ScriptFunctionCall.cpp:
(WebCore::ScriptFunctionCall::appendArgument):
(WebCore::ScriptFunctionCall::call):
(WebCore::ScriptFunctionCall::construct):
* bindings/js/ScriptObject.cpp:
(WebCore::ScriptObject::set):
* bindings/js/ScriptProfiler.cpp:
(WebCore::ScriptProfiler::start):
(WebCore::ScriptProfiler::stop):
* bindings/js/ScriptString.h:
(WebCore::ScriptString::operator String):
(WebCore::ScriptString::ustring):
(WebCore::ScriptString::operator+=):
* bindings/js/ScriptValue.cpp:
(WebCore::ScriptValue::getString):
* bindings/js/ScriptValue.h:
(WebCore::ScriptValue::toString):
* bindings/js/SerializedScriptValue.cpp:
(WebCore::SerializedObject::set):
(WebCore::SerializingTreeWalker::convertIfTerminal):
(WebCore::DeserializingTreeWalker::putProperty):
* bindings/js/StringSourceProvider.h:
(WebCore::StringSourceProvider::StringSourceProvider):
* bindings/objc/WebScriptObject.mm:
(-[WebScriptObject callWebScriptMethod:withArguments:]):
(-[WebScriptObject setValue:forKey:]):
(-[WebScriptObject valueForKey:]):
(-[WebScriptObject removeWebScriptKey:]):
* bindings/scripts/CodeGeneratorJS.pm:
* bridge/IdentifierRep.cpp:
(WebCore::IdentifierRep::get):
* bridge/c/c_utility.cpp:
(JSC::Bindings::identifierFromNPIdentifier):
* inspector/InspectorController.cpp:
(WebCore::InspectorController::scriptImported):
(WebCore::InspectorController::addProfileFinishedMessageToConsole):
(WebCore::InspectorController::createProfileHeader):
* inspector/InspectorResource.cpp:
(WebCore::InspectorResource::sourceString):
* inspector/JavaScriptCallFrame.cpp:
(WebCore::JavaScriptCallFrame::functionName):
* platform/KURL.h:
(WebCore::KURL::operator const String&):
* platform/text/AtomicString.cpp:
(WebCore::AtomicString::operator UString):
* platform/text/AtomicString.h:
* platform/text/PlatformString.h:
* platform/text/String.cpp:
2010-04-16 Anders Carlsson <andersca@apple.com>
Reviewed by David Hyatt.
......@@ -374,6 +374,8 @@ __ZN7WebCore15ScrollAlignment19alignToEdgeIfNeededE
__ZN7WebCore15StringTruncator13rightTruncateERKNS_6StringEfRKNS_4FontEb
__ZN7WebCore15StringTruncator14centerTruncateERKNS_6StringEfRKNS_4FontEb
__ZN7WebCore15StringTruncator5widthERKNS_6StringERKNS_4FontEb
__ZN7WebCore15ustringToStringERKN3JSC7UStringE
__ZN7WebCore15stringToUStringERKNS_6StringE
__ZN7WebCore15VisiblePositionC1EPNS_4NodeEiNS_9EAffinityE
__ZN7WebCore15VisiblePositionC1ERKNS_8PositionENS_9EAffinityE
__ZN7WebCore16FontPlatformDataC1EP6NSFontbb
......@@ -616,7 +618,6 @@ __ZN7WebCore6StringC1EP8NSString
__ZN7WebCore6StringC1EPK10__CFString
__ZN7WebCore6StringC1EPKc
__ZN7WebCore6StringC1EPKcj
__ZN7WebCore6StringC1ERKN3JSC7UStringE
__ZN7WebCore6Widget12setFrameRectERKNS_7IntRectE
__ZN7WebCore6Widget16removeFromParentEv
__ZN7WebCore6Widget20retainPlatformWidgetEv
......@@ -993,7 +994,6 @@ __ZNK7WebCore6String4utf8Ev
__ZNK7WebCore6String6lengthEv
__ZNK7WebCore6String7isEmptyEv
__ZNK7WebCore6String9substringEjj
__ZNK7WebCore6StringcvN3JSC7UStringEEv
__ZNK7WebCore6Widget23convertToContainingViewERKNS_7IntRectE
__ZNK7WebCore6Widget23convertToContainingViewERKNS_8IntPointE
__ZNK7WebCore6Widget25convertFromContainingViewERKNS_7IntRectE
......
......@@ -2204,7 +2204,6 @@ __ZN7WebCore13ScriptElement21finishParsingChildrenERNS_17ScriptElementDataERKNS_
__ZNK7WebCore17ScriptElementData13scriptContentEv
__ZN7WebCore15SegmentedString7prependERKS0_
__ZN7WebCore15SegmentedString7prependERKNS_18SegmentedSubstringE
__ZNK7WebCore6StringcvN3JSC7UStringEEv
__ZNK7WebCore20StringSourceProvider6lengthEv
__ZN7WebCore13HTMLTokenizer15scriptExecutionERKNS_16ScriptSourceCodeENS0_5StateE
__ZN7WebCore11FrameLoader13executeScriptERKNS_16ScriptSourceCodeE
......@@ -2280,7 +2279,6 @@ __ZN3JSC8Bindings10RootObject9gcProtectEPNS_8JSObjectE
__ZNK3WTF9HashTableIPN3JSC8JSObjectESt4pairIS3_jENS_18PairFirstExtractorIS5_EENS_7PtrHashIS3_EENS_14PairHashTraitsINS_10HashTra
__ZN3WTF7HashMapIPN3JSC8JSObjectEjNS_7PtrHashIS3_EENS_10HashTraitsIS3_EENS6_IjEEE3addERKS3_RKj
__ZN3WTF9HashTableIPN3JSC8JSObjectESt4pairIS3_jENS_18PairFirstExtractorIS5_EENS_7PtrHashIS3_EENS_14PairHashTraitsINS_10HashTrai
__ZN7WebCore6StringC1ERKN3JSC7UStringE
__ZN7WebCore6StringC2ERKN3JSC7UStringE
__ZNK7WebCore20StringSourceProvider4dataEv
__ZNK7WebCore15JSDOMWindowBase17supportsProfilingEv
......@@ -50,7 +50,7 @@ namespace WebCore {
private:
CachedScriptSourceProvider(CachedScript* cachedScript)
: ScriptSourceProvider(cachedScript->url())
: ScriptSourceProvider(stringToUString(cachedScript->url()))
, m_cachedScript(cachedScript)
{
m_cachedScript->addClient(this);
......
......@@ -64,7 +64,7 @@ static JSObject* constructAudio(ExecState* exec, JSObject* constructor, const Ar
// rather than looking at args.size.
String src;
if (args.size() > 0)
src = args.at(0).toString(exec);
src = ustringToString(args.at(0).toString(exec));
return asObject(toJS(exec, jsConstructor->globalObject(),
HTMLAudioElement::createForJSConstructor(document, src)));
}
......
......@@ -165,7 +165,7 @@ JSValue JSCSSStyleDeclaration::nameGetter(ExecState* exec, JSValue slotBase, con
// Make the SVG 'filter' attribute undetectable, to avoid confusion with the IE 'filter' attribute.
if (propertyName == "filter")
return StringObjectThatMasqueradesAsUndefined::create(exec, thisObj->impl()->getPropertyValue(prop));
return StringObjectThatMasqueradesAsUndefined::create(exec, stringToUString(thisObj->impl()->getPropertyValue(prop)));
return jsString(exec, thisObj->impl()->getPropertyValue(prop));
}
......
......@@ -54,7 +54,7 @@ static JSValue toJS(ExecState* exec, CanvasStyle* style)
static PassRefPtr<CanvasStyle> toHTMLCanvasStyle(ExecState* exec, JSValue value)
{
if (value.isString())
return CanvasStyle::create(asString(value)->value(exec));
return CanvasStyle::create(ustringToString(asString(value)->value(exec)));
if (!value.isObject())
return 0;
JSObject* object = asObject(value);
......@@ -102,13 +102,13 @@ JSValue JSCanvasRenderingContext2D::setFillColor(ExecState* exec, const ArgList&
switch (args.size()) {
case 1:
if (args.at(0).isString())
context->setFillColor(asString(args.at(0))->value(exec));
context->setFillColor(ustringToString(asString(args.at(0))->value(exec)));
else
context->setFillColor(args.at(0).toFloat(exec));
break;
case 2:
if (args.at(0).isString())
context->setFillColor(asString(args.at(0))->value(exec), args.at(1).toFloat(exec));
context->setFillColor(ustringToString(asString(args.at(0))->value(exec)), args.at(1).toFloat(exec));
else
context->setFillColor(args.at(0).toFloat(exec), args.at(1).toFloat(exec));
break;
......@@ -139,13 +139,13 @@ JSValue JSCanvasRenderingContext2D::setStrokeColor(ExecState* exec, const ArgLis
switch (args.size()) {
case 1:
if (args.at(0).isString())
context->setStrokeColor(asString(args.at(0))->value(exec));
context->setStrokeColor(ustringToString(asString(args.at(0))->value(exec)));
else
context->setStrokeColor(args.at(0).toFloat(exec));
break;
case 2:
if (args.at(0).isString())
context->setStrokeColor(asString(args.at(0))->value(exec), args.at(1).toFloat(exec));
context->setStrokeColor(ustringToString(asString(args.at(0))->value(exec)), args.at(1).toFloat(exec));
else
context->setStrokeColor(args.at(0).toFloat(exec), args.at(1).toFloat(exec));
break;
......@@ -282,7 +282,7 @@ JSValue JSCanvasRenderingContext2D::drawImageFromRect(ExecState* exec, const Arg
args.at(3).toFloat(exec), args.at(4).toFloat(exec),
args.at(5).toFloat(exec), args.at(6).toFloat(exec),
args.at(7).toFloat(exec), args.at(8).toFloat(exec),
args.at(9).toString(exec));
ustringToString(args.at(9).toString(exec)));
return jsUndefined();
}
......@@ -298,7 +298,7 @@ JSValue JSCanvasRenderingContext2D::setShadow(ExecState* exec, const ArgList& ar
case 4:
if (args.at(3).isString())
context->setShadow(args.at(0).toFloat(exec), args.at(1).toFloat(exec),
args.at(2).toFloat(exec), asString(args.at(3))->value(exec));
args.at(2).toFloat(exec), ustringToString(asString(args.at(3))->value(exec)));
else
context->setShadow(args.at(0).toFloat(exec), args.at(1).toFloat(exec),
args.at(2).toFloat(exec), args.at(3).toFloat(exec));
......@@ -306,7 +306,7 @@ JSValue JSCanvasRenderingContext2D::setShadow(ExecState* exec, const ArgList& ar
case 5:
if (args.at(3).isString())
context->setShadow(args.at(0).toFloat(exec), args.at(1).toFloat(exec),
args.at(2).toFloat(exec), asString(args.at(3))->value(exec),
args.at(2).toFloat(exec), ustringToString(asString(args.at(3))->value(exec)),
args.at(4).toFloat(exec));
else
context->setShadow(args.at(0).toFloat(exec), args.at(1).toFloat(exec),
......@@ -391,9 +391,9 @@ JSValue JSCanvasRenderingContext2D::fillText(ExecState* exec, const ArgList& arg
return throwError(exec, SyntaxError);
if (args.size() == 4)
context->fillText(args.at(0).toString(exec), args.at(1).toFloat(exec), args.at(2).toFloat(exec), args.at(3).toFloat(exec));
context->fillText(ustringToString(args.at(0).toString(exec)), args.at(1).toFloat(exec), args.at(2).toFloat(exec), args.at(3).toFloat(exec));
else
context->fillText(args.at(0).toString(exec), args.at(1).toFloat(exec), args.at(2).toFloat(exec));
context->fillText(ustringToString(args.at(0).toString(exec)), args.at(1).toFloat(exec), args.at(2).toFloat(exec));
return jsUndefined();
}
......@@ -409,9 +409,9 @@ JSValue JSCanvasRenderingContext2D::strokeText(ExecState* exec, const ArgList& a
return throwError(exec, SyntaxError);
if (args.size() == 4)
context->strokeText(args.at(0).toString(exec), args.at(1).toFloat(exec), args.at(2).toFloat(exec), args.at(3).toFloat(exec));
context->strokeText(ustringToString(args.at(0).toString(exec)), args.at(1).toFloat(exec), args.at(2).toFloat(exec), args.at(3).toFloat(exec));
else
context->strokeText(args.at(0).toString(exec), args.at(1).toFloat(exec), args.at(2).toFloat(exec));
context->strokeText(ustringToString(args.at(0).toString(exec)), args.at(1).toFloat(exec), args.at(2).toFloat(exec));
return jsUndefined();
}
......
......@@ -59,7 +59,7 @@ JSValue JSClipboard::types(ExecState* exec) const
MarkedArgumentBuffer list;
HashSet<String>::const_iterator end = types.end();
for (HashSet<String>::const_iterator it = types.begin(); it != end; ++it)
list.append(jsString(exec, UString(*it)));
list.append(jsString(exec, stringToUString(*it)));
return constructArray(exec, list);
}
......@@ -73,7 +73,7 @@ JSValue JSClipboard::clearData(ExecState* exec, const ArgList& args)
}
if (args.size() == 1) {
clipboard->clearData(args.at(0).toString(exec));
clipboard->clearData(ustringToString(args.at(0).toString(exec)));
return jsUndefined();
}
......@@ -90,7 +90,7 @@ JSValue JSClipboard::getData(ExecState* exec, const ArgList& args)
Clipboard* clipboard = impl();
bool success;
String result = clipboard->getData(args.at(0).toString(exec), success);
String result = clipboard->getData(ustringToString(args.at(0).toString(exec)), success);
if (!success)
return jsUndefined();
......@@ -105,7 +105,7 @@ JSValue JSClipboard::setData(ExecState* exec, const ArgList& args)
if (args.size() != 2)
return throwError(exec, SyntaxError, "setData: Invalid number of arguments");
return jsBoolean(clipboard->setData(args.at(0).toString(exec), args.at(1).toString(exec)));
return jsBoolean(clipboard->setData(ustringToString(args.at(0).toString(exec)), ustringToString(args.at(1).toString(exec))));
}
JSValue JSClipboard::setDragImage(ExecState* exec, const ArgList& args)
......
......@@ -98,7 +98,7 @@ String JSCustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
reportCurrentException(exec);
else {
if (!retval.isUndefinedOrNull())
result = retval.toString(exec);
result = ustringToString(retval.toString(exec));
}
Document::updateStyleForAllDocuments();
......
......@@ -492,18 +492,39 @@ JSValue jsStringOrFalse(ExecState* exec, const KURL& url)
return jsString(exec, url.string());
}
UString valueToStringWithNullCheck(ExecState* exec, JSValue value)
String identifierToString(const Identifier& i)
{
if (i.isNull())
return String();
return StringImpl::create(i.ustring());
}
String ustringToString(const UString& u)
{
if (u.isNull())
return String();
return StringImpl::create(u);
}
UString stringToUString(const String& s)
{
if (StringImpl* impl = s.impl())
return impl->ustring();
return UString();
}
String valueToStringWithNullCheck(ExecState* exec, JSValue value)
{
if (value.isNull())
return UString();
return value.toString(exec);
return String();
return ustringToString(value.toString(exec));
}
UString valueToStringWithUndefinedOrNullCheck(ExecState* exec, JSValue value)
String valueToStringWithUndefinedOrNullCheck(ExecState* exec, JSValue value)
{
if (value.isUndefinedOrNull())
return UString();
return value.toString(exec);
return String();
return ustringToString(value.toString(exec));
}
JSValue jsDateOrNull(ExecState* exec, double value)
......@@ -534,7 +555,7 @@ void reportException(ExecState* exec, JSValue exception)
exec->clearException();
if (ExceptionBase* exceptionBase = toExceptionBase(exception))
errorMessage = exceptionBase->message() + ": " + exceptionBase->description();
errorMessage = stringToUString(exceptionBase->message() + ": " + exceptionBase->description());
ScriptExecutionContext* scriptExecutionContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
ASSERT(scriptExecutionContext);
......@@ -544,7 +565,7 @@ void reportException(ExecState* exec, JSValue exception)
if (!scriptExecutionContext)
return;
scriptExecutionContext->reportException(errorMessage, lineNumber, exceptionSourceURL);
scriptExecutionContext->reportException(ustringToString(errorMessage), lineNumber, ustringToString(exceptionSourceURL));
}
void reportCurrentException(ExecState* exec)
......
......@@ -258,8 +258,12 @@ namespace WebCore {
// object, to let the engine know that collecting the JSString wrapper is unlikely to save memory.
JSC::JSValue jsOwnedStringOrNull(JSC::ExecState*, const JSC::UString&);
JSC::UString valueToStringWithNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null
JSC::UString valueToStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null or undefined
String identifierToString(const JSC::Identifier&);
String ustringToString(const JSC::UString&);
JSC::UString stringToUString(const String&);
String valueToStringWithNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null
String valueToStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null or undefined
// Returns a Date instance for the specified value, or null if the value is NaN or infinity.
JSC::JSValue jsDateOrNull(JSC::ExecState*, double);
......
......@@ -42,12 +42,12 @@ namespace WebCore {
JSValue JSDOMFormData::append(ExecState* exec, const ArgList& args)
{
if (args.size() >= 2) {
String name = args.at(0).toString(exec);
String name = ustringToString(args.at(0).toString(exec));
JSValue value = args.at(1);
if (value.inherits(&JSBlob::s_info))
impl()->append(name, toBlob(value));
else
impl()->append(name, value.toString(exec));
impl()->append(name, ustringToString(value.toString(exec)));
}
return jsUndefined();
......
......@@ -150,7 +150,7 @@ static JSValue namedItemGetter(ExecState* exec, JSValue slotBase, const Identifi
ASSERT(document);
ASSERT(document->isHTMLDocument());
RefPtr<HTMLCollection> collection = document->windowNamedItems(propertyName);
RefPtr<HTMLCollection> collection = document->windowNamedItems(identifierToString(propertyName));
if (collection->length() == 1)
return toJS(exec, collection->firstItem());
return toJS(exec, collection.get());
......@@ -506,7 +506,7 @@ void JSDOMWindow::setLocation(ExecState* exec, JSValue value)
Frame* frame = impl()->frame();
ASSERT(frame);
KURL url = completeURL(exec, value.toString(exec));
KURL url = completeURL(exec, ustringToString(value.toString(exec)));
if (url.isNull())
return;
......@@ -976,7 +976,7 @@ JSValue JSDOMWindow::openDatabase(ExecState* exec, const ArgList& args)
if ((args.size() >= 5) && args.at(4).isObject())
creationCallback = JSDatabaseCallback::create(asObject(args.at(4)), globalObject());
JSValue result = toJS(exec, globalObject(), WTF::getPtr(impl()->openDatabase(name, version, displayName, estimatedSize, creationCallback.release(), ec)));
JSValue result = toJS(exec, globalObject(), WTF::getPtr(impl()->openDatabase(ustringToString(name), ustringToString(version), ustringToString(displayName), estimatedSize, creationCallback.release(), ec)));
if (!ec && result.isNull())
ec = SECURITY_ERR;
......
......@@ -49,8 +49,8 @@ using namespace JSC;
JSValue JSDatabase::changeVersion(ExecState* exec, const ArgList& args)
{
String oldVersion = args.at(0).toString(exec);
String newVersion = args.at(1).toString(exec);
String oldVersion = ustringToString(args.at(0).toString(exec));
String newVersion = ustringToString(args.at(1).toString(exec));
JSObject* object;
if (!(object = args.at(2).getObject())) {
......
......@@ -79,7 +79,7 @@ void JSDocument::setLocation(ExecState* exec, JSValue value)
if (!frame)
return;
String str = value.toString(exec);
String str = ustringToString(value.toString(exec));
// IE and Mozilla both resolve the URL relative to the source frame,
// not the target frame.
......
......@@ -121,7 +121,7 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext
reportCurrentException(exec);
else {
if (!retval.isUndefinedOrNull() && event->storesResultAsString())
event->storeResult(retval.toString(exec));
event->storeResult(ustringToString(retval.toString(exec)));
if (m_isAttribute) {
bool retvalbool;
if (retval.getBoolean(retvalbool) && !retvalbool)
......
......@@ -71,7 +71,7 @@ static JSObject* constructEventSource(ExecState* exec, JSObject* constructor, co
return throwError(exec, ReferenceError, "EventSource constructor associated document is unavailable");
ExceptionCode ec = 0;
RefPtr<EventSource> eventSource = EventSource::create(url, context, ec);
RefPtr<EventSource> eventSource = EventSource::create(ustringToString(url), context, ec);
if (ec) {
setDOMException(exec, ec);
return 0;
......
......@@ -86,7 +86,7 @@ static JSValue JSC_HOST_CALL callHTMLAllCollection(ExecState* exec, JSObject* fu
UString string = args.at(0).toString(exec);
unsigned index = args.at(1).toString(exec).toUInt32(&ok, false);
if (ok) {
String pstr = string;
String pstr = ustringToString(string);
Node* node = collection->namedItem(pstr);
while (node) {
if (!index)
......
......@@ -78,7 +78,7 @@ JSValue JSHTMLCanvasElement::getContext(ExecState* exec, const ArgList& args)
}
}
#endif
return toJS(exec, globalObject(), WTF::getPtr(canvas->getContext(contextId, attrs.get())));
return toJS(exec, globalObject(), WTF::getPtr(canvas->getContext(ustringToString(contextId), attrs.get())));
}