Commit 27c3c17c authored by aroben@apple.com's avatar aroben@apple.com
Browse files

Clean up InspectorController's use of JSStringRef

        All JSStringRef creation now happens through a helper function,
        jsStringRef, which takes either a const char* or a const String& and
        returns a JSRetainPtr<JSStringRef>.

        Reviewed by Mitz Pettel.

        * page/InspectorController.cpp:
        Added jsStringRef and converted all callers to
        JSStringCreateWithUTF8CString or JSStringCreateWithCharacters to use
        it.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@32213 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c9db4020
2008-04-17 Adam Roben <aroben@apple.com>
Clean up InspectorController's use of JSStringRef
All JSStringRef creation now happens through a helper function,
jsStringRef, which takes either a const char* or a const String& and
returns a JSRetainPtr<JSStringRef>.
Reviewed by Mitz Pettel.
* page/InspectorController.cpp:
Added jsStringRef and converted all callers to
JSStringCreateWithUTF8CString or JSStringCreateWithCharacters to use
it.
2008-04-17 Adam Roben <aroben@apple.com>
 
Add wrappers around InspectorClient::{show,close}Window
......@@ -78,6 +78,16 @@ using namespace std;
namespace WebCore {
static JSRetainPtr<JSStringRef> jsStringRef(const char* str)
{
return JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithUTF8CString(str));
}
static JSRetainPtr<JSStringRef> jsStringRef(const String& str)
{
return JSRetainPtr<JSStringRef>(Adopt, JSStringCreateWithCharacters(str.characters(), str.length()));
}
#define HANDLE_EXCEPTION(exception) handleException((exception), __LINE__)
JSValueRef InspectorController::callSimpleFunction(JSContextRef context, JSObjectRef thisObject, const char* functionName) const
......@@ -87,8 +97,7 @@ JSValueRef InspectorController::callSimpleFunction(JSContextRef context, JSObjec
JSValueRef exception = 0;
JSRetainPtr<JSStringRef> functionNameString(Adopt, JSStringCreateWithUTF8CString(functionName));
JSValueRef functionProperty = JSObjectGetProperty(context, thisObject, functionNameString.get(), &exception);
JSValueRef functionProperty = JSObjectGetProperty(context, thisObject, jsStringRef(functionName).get(), &exception);
if (HANDLE_EXCEPTION(exception))
return JSValueMakeUndefined(context);
......@@ -536,9 +545,8 @@ static JSValueRef search(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef
String target(JSStringGetCharactersPtr(searchString.get()), JSStringGetLength(searchString.get()));
JSObjectRef global = JSContextGetGlobalObject(ctx);
JSRetainPtr<JSStringRef> arrayString(Adopt, JSStringCreateWithUTF8CString("Array"));
JSValueRef arrayProperty = JSObjectGetProperty(ctx, global, arrayString.get(), exception);
JSValueRef arrayProperty = JSObjectGetProperty(ctx, global, jsStringRef("Array").get(), exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
......@@ -550,8 +558,7 @@ static JSValueRef search(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef
if (exception && *exception)
return JSValueMakeUndefined(ctx);
JSRetainPtr<JSStringRef> pushString(Adopt, JSStringCreateWithUTF8CString("push"));
JSValueRef pushProperty = JSObjectGetProperty(ctx, result, pushString.get(), exception);
JSValueRef pushProperty = JSObjectGetProperty(ctx, result, jsStringRef("push").get(), exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
......@@ -604,9 +611,8 @@ static JSValueRef databaseTableNames(JSContextRef ctx, JSObjectRef /*function*/,
return JSValueMakeUndefined(ctx);
JSObjectRef global = JSContextGetGlobalObject(ctx);
JSRetainPtr<JSStringRef> arrayString(Adopt, JSStringCreateWithUTF8CString("Array"));
JSValueRef arrayProperty = JSObjectGetProperty(ctx, global, arrayString.get(), exception);
JSValueRef arrayProperty = JSObjectGetProperty(ctx, global, jsStringRef("Array").get(), exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
......@@ -618,8 +624,7 @@ static JSValueRef databaseTableNames(JSContextRef ctx, JSObjectRef /*function*/,
if (exception && *exception)
return JSValueMakeUndefined(ctx);
JSRetainPtr<JSStringRef> pushString(Adopt, JSStringCreateWithUTF8CString("push"));
JSValueRef pushProperty = JSObjectGetProperty(ctx, result, pushString.get(), exception);
JSValueRef pushProperty = JSObjectGetProperty(ctx, result, jsStringRef("push").get(), exception);
if (exception && *exception)
return JSValueMakeUndefined(ctx);
......@@ -631,8 +636,7 @@ static JSValueRef databaseTableNames(JSContextRef ctx, JSObjectRef /*function*/,
unsigned length = tableNames.size();
for (unsigned i = 0; i < length; ++i) {
String tableName = tableNames[i];
JSRetainPtr<JSStringRef> tableNameString(Adopt, JSStringCreateWithCharacters(tableName.characters(), tableName.length()));
JSValueRef tableNameValue = JSValueMakeString(ctx, tableNameString.get());
JSValueRef tableNameValue = JSValueMakeString(ctx, jsStringRef(tableName).get());
JSValueRef pushArguments[] = { tableNameValue };
JSObjectCallAsFunction(ctx, pushFunction, result, 1, pushArguments, exception);
......@@ -665,8 +669,7 @@ static JSValueRef localizedStrings(JSContextRef ctx, JSObjectRef /*function*/, J
if (url.isNull())
return JSValueMakeNull(ctx);
JSRetainPtr<JSStringRef> urlString(Adopt, JSStringCreateWithCharacters(url.characters(), url.length()));
return JSValueMakeString(ctx, urlString.get());
return JSValueMakeString(ctx, jsStringRef(url).get());
}
static JSValueRef platform(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t /*argumentCount*/, const JSValueRef[] /*arguments[]*/, JSValueRef* /*exception*/)
......@@ -689,8 +692,7 @@ static JSValueRef platform(JSContextRef ctx, JSObjectRef /*function*/, JSObjectR
static const String platform = "unknown";
#endif
JSRetainPtr<JSStringRef> platformString(Adopt, JSStringCreateWithCharacters(platform.characters(), platform.length()));
JSValueRef platformValue = JSValueMakeString(ctx, platformString.get());
JSValueRef platformValue = JSValueMakeString(ctx, jsStringRef(platform).get());
return platformValue;
}
......@@ -756,8 +758,7 @@ InspectorController::~InspectorController()
JSValueRef exception = 0;
JSObjectRef global = JSContextGetGlobalObject(m_scriptContext);
JSRetainPtr<JSStringRef> controllerString(Adopt, JSStringCreateWithUTF8CString("InspectorController"));
JSValueRef controllerProperty = JSObjectGetProperty(m_scriptContext, global, controllerString.get(), &exception);
JSValueRef controllerProperty = JSObjectGetProperty(m_scriptContext, global, jsStringRef("InspectorController").get(), &exception);
if (!HANDLE_EXCEPTION(exception)) {
if (JSObjectRef controller = JSValueToObject(m_scriptContext, controllerProperty, &exception)) {
if (!HANDLE_EXCEPTION(exception))
......@@ -842,8 +843,7 @@ void InspectorController::focusNode()
JSValueRef exception = 0;
JSRetainPtr<JSStringRef> functionString(Adopt, JSStringCreateWithUTF8CString("updateFocusedNode"));
JSValueRef functionProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, functionString.get(), &exception);
JSValueRef functionProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, jsStringRef("updateFocusedNode").get(), &exception);
if (HANDLE_EXCEPTION(exception))
return;
......@@ -985,8 +985,7 @@ void InspectorController::windowScriptObjectAvailable()
m_controllerScriptObject = JSObjectMake(m_scriptContext, controllerClass, reinterpret_cast<void*>(this));
ASSERT(m_controllerScriptObject);
JSRetainPtr<JSStringRef> controllerObjectString(Adopt, JSStringCreateWithUTF8CString("InspectorController"));
JSObjectSetProperty(m_scriptContext, global, controllerObjectString.get(), m_controllerScriptObject, kJSPropertyAttributeNone, 0);
JSObjectSetProperty(m_scriptContext, global, jsStringRef("InspectorController").get(), m_controllerScriptObject, kJSPropertyAttributeNone, 0);
}
void InspectorController::scriptObjectReady()
......@@ -1000,8 +999,7 @@ void InspectorController::scriptObjectReady()
JSValueRef exception = 0;
JSRetainPtr<JSStringRef> inspectorString(Adopt, JSStringCreateWithUTF8CString("WebInspector"));
JSValueRef inspectorValue = JSObjectGetProperty(m_scriptContext, global, inspectorString.get(), &exception);
JSValueRef inspectorValue = JSObjectGetProperty(m_scriptContext, global, jsStringRef("WebInspector").get(), &exception);
if (HANDLE_EXCEPTION(exception))
return;
......@@ -1105,10 +1103,8 @@ static void addHeaders(JSContextRef context, JSObjectRef object, const HTTPHeade
HTTPHeaderMap::const_iterator end = headers.end();
for (HTTPHeaderMap::const_iterator it = headers.begin(); it != end; ++it) {
JSRetainPtr<JSStringRef> field(Adopt, JSStringCreateWithCharacters(it->first.characters(), it->first.length()));
JSRetainPtr<JSStringRef> valueString(Adopt, JSStringCreateWithCharacters(it->second.characters(), it->second.length()));
JSValueRef value = JSValueMakeString(context, valueString.get());
JSObjectSetProperty(context, object, field.get(), value, kJSPropertyAttributeNone, exception);
JSValueRef value = JSValueMakeString(context, jsStringRef(it->second).get());
JSObjectSetProperty(context, object, jsStringRef(it->first).get(), value, kJSPropertyAttributeNone, exception);
if (exception && *exception)
return;
}
......@@ -1146,8 +1142,7 @@ JSObjectRef InspectorController::addScriptResource(InspectorResource* resource)
if (!resource->scriptObject) {
JSValueRef exception = 0;
JSRetainPtr<JSStringRef> resourceString(Adopt, JSStringCreateWithUTF8CString("Resource"));
JSValueRef resourceProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, resourceString.get(), &exception);
JSValueRef resourceProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, jsStringRef("Resource").get(), &exception);
if (HANDLE_EXCEPTION(exception))
return 0;
......@@ -1155,21 +1150,10 @@ JSObjectRef InspectorController::addScriptResource(InspectorResource* resource)
if (HANDLE_EXCEPTION(exception))
return 0;
String urlString = resource->requestURL.string();
JSRetainPtr<JSStringRef> url(Adopt, JSStringCreateWithCharacters(urlString.characters(), urlString.length()));
JSValueRef urlValue = JSValueMakeString(m_scriptContext, url.get());
urlString = resource->requestURL.host();
JSRetainPtr<JSStringRef> domain(Adopt, JSStringCreateWithCharacters(urlString.characters(), urlString.length()));
JSValueRef domainValue = JSValueMakeString(m_scriptContext, domain.get());
urlString = resource->requestURL.path();
JSRetainPtr<JSStringRef> path(Adopt, JSStringCreateWithCharacters(urlString.characters(), urlString.length()));
JSValueRef pathValue = JSValueMakeString(m_scriptContext, path.get());
urlString = resource->requestURL.lastPathComponent();
JSRetainPtr<JSStringRef> lastPathComponent(Adopt, JSStringCreateWithCharacters(urlString.characters(), urlString.length()));
JSValueRef lastPathComponentValue = JSValueMakeString(m_scriptContext, lastPathComponent.get());
JSValueRef urlValue = JSValueMakeString(m_scriptContext, jsStringRef(resource->requestURL.string()).get());
JSValueRef domainValue = JSValueMakeString(m_scriptContext, jsStringRef(resource->requestURL.host()).get());
JSValueRef pathValue = JSValueMakeString(m_scriptContext, jsStringRef(resource->requestURL.path()).get());
JSValueRef lastPathComponentValue = JSValueMakeString(m_scriptContext, jsStringRef(resource->requestURL.lastPathComponent()).get());
JSValueRef identifier = JSValueMakeNumber(m_scriptContext, resource->identifier);
JSValueRef mainResource = JSValueMakeBoolean(m_scriptContext, m_mainResource == resource);
......@@ -1191,8 +1175,7 @@ JSObjectRef InspectorController::addScriptResource(InspectorResource* resource)
JSValueRef exception = 0;
JSRetainPtr<JSStringRef> addResourceString(Adopt, JSStringCreateWithUTF8CString("addResource"));
JSValueRef addResourceProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, addResourceString.get(), &exception);
JSValueRef addResourceProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, jsStringRef("addResource").get(), &exception);
if (HANDLE_EXCEPTION(exception))
return 0;
......@@ -1240,8 +1223,7 @@ void InspectorController::removeScriptResource(InspectorResource* resource)
JSValueRef exception = 0;
JSRetainPtr<JSStringRef> removeResourceString(Adopt, JSStringCreateWithUTF8CString("removeResource"));
JSValueRef removeResourceProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, removeResourceString.get(), &exception);
JSValueRef removeResourceProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, jsStringRef("removeResource").get(), &exception);
if (HANDLE_EXCEPTION(exception))
return;
......@@ -1276,43 +1258,28 @@ void InspectorController::updateScriptResourceRequest(InspectorResource* resourc
if (!resource->scriptObject || !m_scriptContext)
return;
String urlString = resource->requestURL.string();
JSRetainPtr<JSStringRef> url(Adopt, JSStringCreateWithCharacters(urlString.characters(), urlString.length()));
JSValueRef urlValue = JSValueMakeString(m_scriptContext, url.get());
urlString = resource->requestURL.host();
JSRetainPtr<JSStringRef> domain(Adopt, JSStringCreateWithCharacters(urlString.characters(), urlString.length()));
JSValueRef domainValue = JSValueMakeString(m_scriptContext, domain.get());
urlString = resource->requestURL.path();
JSRetainPtr<JSStringRef> path(Adopt, JSStringCreateWithCharacters(urlString.characters(), urlString.length()));
JSValueRef pathValue = JSValueMakeString(m_scriptContext, path.get());
urlString = resource->requestURL.lastPathComponent();
JSRetainPtr<JSStringRef> lastPathComponent(Adopt, JSStringCreateWithCharacters(urlString.characters(), urlString.length()));
JSValueRef lastPathComponentValue = JSValueMakeString(m_scriptContext, lastPathComponent.get());
JSValueRef urlValue = JSValueMakeString(m_scriptContext, jsStringRef(resource->requestURL.string()).get());
JSValueRef domainValue = JSValueMakeString(m_scriptContext, jsStringRef(resource->requestURL.host()).get());
JSValueRef pathValue = JSValueMakeString(m_scriptContext, jsStringRef(resource->requestURL.path()).get());
JSValueRef lastPathComponentValue = JSValueMakeString(m_scriptContext, jsStringRef(resource->requestURL.lastPathComponent()).get());
JSValueRef mainResourceValue = JSValueMakeBoolean(m_scriptContext, m_mainResource == resource);
JSValueRef exception = 0;
JSRetainPtr<JSStringRef> propertyName(Adopt, JSStringCreateWithUTF8CString("url"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), urlValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("url").get(), urlValue, kJSPropertyAttributeNone, &exception);
if (HANDLE_EXCEPTION(exception))
return;
propertyName.adopt(JSStringCreateWithUTF8CString("domain"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), domainValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("domain").get(), domainValue, kJSPropertyAttributeNone, &exception);
if (HANDLE_EXCEPTION(exception))
return;
propertyName.adopt(JSStringCreateWithUTF8CString("path"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), pathValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("path").get(), pathValue, kJSPropertyAttributeNone, &exception);
if (HANDLE_EXCEPTION(exception))
return;
propertyName.adopt(JSStringCreateWithUTF8CString("lastPathComponent"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), lastPathComponentValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("lastPathComponent").get(), lastPathComponentValue, kJSPropertyAttributeNone, &exception);
if (HANDLE_EXCEPTION(exception))
return;
......@@ -1320,13 +1287,11 @@ void InspectorController::updateScriptResourceRequest(InspectorResource* resourc
if (HANDLE_EXCEPTION(exception))
return;
propertyName.adopt(JSStringCreateWithUTF8CString("requestHeaders"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), scriptObject, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("requestHeaders").get(), scriptObject, kJSPropertyAttributeNone, &exception);
if (HANDLE_EXCEPTION(exception))
return;
propertyName.adopt(JSStringCreateWithUTF8CString("mainResource"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), mainResourceValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("mainResource").get(), mainResourceValue, kJSPropertyAttributeNone, &exception);
HANDLE_EXCEPTION(exception);
}
......@@ -1337,34 +1302,28 @@ void InspectorController::updateScriptResourceResponse(InspectorResource* resour
if (!resource->scriptObject || !m_scriptContext)
return;
JSRetainPtr<JSStringRef> mimeType(Adopt, JSStringCreateWithCharacters(resource->mimeType.characters(), resource->mimeType.length()));
JSValueRef mimeTypeValue = JSValueMakeString(m_scriptContext, mimeType.get());
JSValueRef mimeTypeValue = JSValueMakeString(m_scriptContext, jsStringRef(resource->mimeType).get());
JSRetainPtr<JSStringRef> suggestedFilename(Adopt, JSStringCreateWithCharacters(resource->suggestedFilename.characters(), resource->suggestedFilename.length()));
JSValueRef suggestedFilenameValue = JSValueMakeString(m_scriptContext, suggestedFilename.get());
JSValueRef suggestedFilenameValue = JSValueMakeString(m_scriptContext, jsStringRef(resource->suggestedFilename).get());
JSValueRef expectedContentLengthValue = JSValueMakeNumber(m_scriptContext, static_cast<double>(resource->expectedContentLength));
JSValueRef statusCodeValue = JSValueMakeNumber(m_scriptContext, resource->responseStatusCode);
JSValueRef exception = 0;
JSRetainPtr<JSStringRef> propertyName(Adopt, JSStringCreateWithUTF8CString("mimeType"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), mimeTypeValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("mimeType").get(), mimeTypeValue, kJSPropertyAttributeNone, &exception);
if (HANDLE_EXCEPTION(exception))
return;
propertyName.adopt(JSStringCreateWithUTF8CString("suggestedFilename"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), suggestedFilenameValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("suggestedFilename").get(), suggestedFilenameValue, kJSPropertyAttributeNone, &exception);
if (HANDLE_EXCEPTION(exception))
return;
propertyName.adopt(JSStringCreateWithUTF8CString("expectedContentLength"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), expectedContentLengthValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("expectedContentLength").get(), expectedContentLengthValue, kJSPropertyAttributeNone, &exception);
if (HANDLE_EXCEPTION(exception))
return;
propertyName.adopt(JSStringCreateWithUTF8CString("statusCode"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), statusCodeValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("statusCode").get(), statusCodeValue, kJSPropertyAttributeNone, &exception);
if (HANDLE_EXCEPTION(exception))
return;
......@@ -1372,14 +1331,12 @@ void InspectorController::updateScriptResourceResponse(InspectorResource* resour
if (HANDLE_EXCEPTION(exception))
return;
propertyName.adopt(JSStringCreateWithUTF8CString("responseHeaders"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), scriptObject, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("responseHeaders").get(), scriptObject, kJSPropertyAttributeNone, &exception);
if (HANDLE_EXCEPTION(exception))
return;
JSValueRef typeValue = JSValueMakeNumber(m_scriptContext, resource->type());
propertyName.adopt(JSStringCreateWithUTF8CString("type"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), typeValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("type").get(), typeValue, kJSPropertyAttributeNone, &exception);
HANDLE_EXCEPTION(exception);
}
......@@ -1394,8 +1351,7 @@ void InspectorController::updateScriptResource(InspectorResource* resource, int
JSValueRef exception = 0;
JSRetainPtr<JSStringRef> propertyName(Adopt, JSStringCreateWithUTF8CString("contentLength"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), lengthValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("contentLength").get(), lengthValue, kJSPropertyAttributeNone, &exception);
HANDLE_EXCEPTION(exception);
}
......@@ -1411,13 +1367,11 @@ void InspectorController::updateScriptResource(InspectorResource* resource, bool
JSValueRef exception = 0;
JSRetainPtr<JSStringRef> propertyName(Adopt, JSStringCreateWithUTF8CString("failed"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), failedValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("failed").get(), failedValue, kJSPropertyAttributeNone, &exception);
if (HANDLE_EXCEPTION(exception))
return;
propertyName.adopt(JSStringCreateWithUTF8CString("finished"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), finishedValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("finished").get(), finishedValue, kJSPropertyAttributeNone, &exception);
HANDLE_EXCEPTION(exception);
}
......@@ -1434,18 +1388,15 @@ void InspectorController::updateScriptResource(InspectorResource* resource, doub
JSValueRef exception = 0;
JSRetainPtr<JSStringRef> propertyName(Adopt, JSStringCreateWithUTF8CString("startTime"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), startTimeValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("startTime").get(), startTimeValue, kJSPropertyAttributeNone, &exception);
if (HANDLE_EXCEPTION(exception))
return;
propertyName.adopt(JSStringCreateWithUTF8CString("responseReceivedTime"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), responseReceivedTimeValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("responseReceivedTime").get(), responseReceivedTimeValue, kJSPropertyAttributeNone, &exception);
if (HANDLE_EXCEPTION(exception))
return;
propertyName.adopt(JSStringCreateWithUTF8CString("endTime"));
JSObjectSetProperty(m_scriptContext, resource->scriptObject, propertyName.get(), endTimeValue, kJSPropertyAttributeNone, &exception);
JSObjectSetProperty(m_scriptContext, resource->scriptObject, jsStringRef("endTime").get(), endTimeValue, kJSPropertyAttributeNone, &exception);
HANDLE_EXCEPTION(exception);
}
......@@ -1489,8 +1440,7 @@ JSObjectRef InspectorController::addDatabaseScriptResource(InspectorDatabaseReso
JSValueRef exception = 0;
JSRetainPtr<JSStringRef> databaseString(Adopt, JSStringCreateWithUTF8CString("Database"));
JSValueRef databaseProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, databaseString.get(), &exception);
JSValueRef databaseProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, jsStringRef("Database").get(), &exception);
if (HANDLE_EXCEPTION(exception))
return 0;
......@@ -1507,14 +1457,9 @@ JSObjectRef InspectorController::addDatabaseScriptResource(InspectorDatabaseReso
database = toRef(JSInspectedObjectWrapper::wrap(exec, toJS(exec, resource->database.get())));
}
JSRetainPtr<JSStringRef> domain(Adopt, JSStringCreateWithCharacters(resource->domain.characters(), resource->domain.length()));
JSValueRef domainValue = JSValueMakeString(m_scriptContext, domain.get());
JSRetainPtr<JSStringRef> name(Adopt, JSStringCreateWithCharacters(resource->name.characters(), resource->name.length()));
JSValueRef nameValue = JSValueMakeString(m_scriptContext, name.get());
JSRetainPtr<JSStringRef> version(Adopt, JSStringCreateWithCharacters(resource->version.characters(), resource->version.length()));
JSValueRef versionValue = JSValueMakeString(m_scriptContext, version.get());
JSValueRef domainValue = JSValueMakeString(m_scriptContext, jsStringRef(resource->domain).get());
JSValueRef nameValue = JSValueMakeString(m_scriptContext, jsStringRef(resource->name).get());
JSValueRef versionValue = JSValueMakeString(m_scriptContext, jsStringRef(resource->version).get());
JSValueRef arguments[] = { database, domainValue, nameValue, versionValue };
JSObjectRef result = JSObjectCallAsConstructor(m_scriptContext, databaseConstructor, 4, arguments, &exception);
......@@ -1523,8 +1468,7 @@ JSObjectRef InspectorController::addDatabaseScriptResource(InspectorDatabaseReso
ASSERT(result);
JSRetainPtr<JSStringRef> addDatabaseString(Adopt, JSStringCreateWithUTF8CString("addDatabase"));
JSValueRef addDatabaseProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, addDatabaseString.get(), &exception);
JSValueRef addDatabaseProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, jsStringRef("addDatabase").get(), &exception);
if (HANDLE_EXCEPTION(exception))
return 0;
......@@ -1559,8 +1503,7 @@ void InspectorController::removeDatabaseScriptResource(InspectorDatabaseResource
JSValueRef exception = 0;
JSRetainPtr<JSStringRef> removeDatabaseString(Adopt, JSStringCreateWithUTF8CString("removeDatabase"));
JSValueRef removeDatabaseProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, removeDatabaseString.get(), &exception);
JSValueRef removeDatabaseProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, jsStringRef("removeDatabase").get(), &exception);
if (HANDLE_EXCEPTION(exception))
return;
......@@ -1580,8 +1523,7 @@ void InspectorController::addScriptConsoleMessage(const ConsoleMessage* message)
JSValueRef exception = 0;
JSRetainPtr<JSStringRef> messageConstructorString(Adopt, JSStringCreateWithUTF8CString("ConsoleMessage"));
JSValueRef messageConstructorProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, messageConstructorString.get(), &exception);
JSValueRef messageConstructorProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, jsStringRef("ConsoleMessage").get(), &exception);
if (HANDLE_EXCEPTION(exception))
return;
......@@ -1589,8 +1531,7 @@ void InspectorController::addScriptConsoleMessage(const ConsoleMessage* message)
if (HANDLE_EXCEPTION(exception))
return;
JSRetainPtr<JSStringRef> addMessageString(Adopt, JSStringCreateWithUTF8CString("addMessageToConsole"));
JSValueRef addMessageProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, addMessageString.get(), &exception);
JSValueRef addMessageProperty = JSObjectGetProperty(m_scriptContext, m_scriptObject, jsStringRef("addMessageToConsole").get(), &exception);
if (HANDLE_EXCEPTION(exception))
return;
......@@ -1601,8 +1542,7 @@ void InspectorController::addScriptConsoleMessage(const ConsoleMessage* message)
JSValueRef sourceValue = JSValueMakeNumber(m_scriptContext, message->source);
JSValueRef levelValue = JSValueMakeNumber(m_scriptContext, message->level);
JSValueRef lineValue = JSValueMakeNumber(m_scriptContext, message->line);
JSRetainPtr<JSStringRef> urlString(Adopt, JSStringCreateWithCharacters(message->url.characters(), message->url.length()));
JSValueRef urlValue = JSValueMakeString(m_scriptContext, urlString.get());
JSValueRef urlValue = JSValueMakeString(m_scriptContext, jsStringRef(message->url).get());
static const unsigned maximumMessageArguments = 256;
JSValueRef arguments[maximumMessageArguments];
......@@ -1618,8 +1558,7 @@ void InspectorController::addScriptConsoleMessage(const ConsoleMessage* message)
for (unsigned i = 0; i < argumentsToAdd; ++i)
arguments[argumentCount++] = toRef(message->wrappedArguments[i]);
} else {
JSRetainPtr<JSStringRef> messageString(Adopt, JSStringCreateWithCharacters(message->message.characters(), message->message.length()));
JSValueRef messageValue = JSValueMakeString(m_scriptContext, messageString.get());
JSValueRef messageValue = JSValueMakeString(m_scriptContext, jsStringRef(message->message).get());
arguments[argumentCount++] = messageValue;
}
......
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