summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/js
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-04-27 16:23:55 +0100
committerSteve Block <steveblock@google.com>2010-04-27 17:07:03 +0100
commit692e5dbf12901edacf14812a6fae25462920af42 (patch)
treed62802373a429e0a9dc093b6046c166b2c514285 /WebCore/bindings/js
parente24bea4efef1c414137d36a9778aa4e142e10c7d (diff)
downloadexternal_webkit-692e5dbf12901edacf14812a6fae25462920af42.zip
external_webkit-692e5dbf12901edacf14812a6fae25462920af42.tar.gz
external_webkit-692e5dbf12901edacf14812a6fae25462920af42.tar.bz2
Merge webkit.org at r55033 : Initial merge by git
Change-Id: I98a4af828067cc243ec3dc5e5826154dd88074b5
Diffstat (limited to 'WebCore/bindings/js')
-rw-r--r--WebCore/bindings/js/JSAudioConstructor.cpp35
-rw-r--r--WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp2
-rw-r--r--WebCore/bindings/js/JSDOMBinding.cpp8
-rw-r--r--WebCore/bindings/js/JSDOMBinding.h5
-rw-r--r--WebCore/bindings/js/JSDOMWindowCustom.cpp12
-rw-r--r--WebCore/bindings/js/JSImageConstructor.cpp40
-rw-r--r--WebCore/bindings/js/JSOptionConstructor.cpp23
-rw-r--r--WebCore/bindings/js/JSWorkerContextCustom.cpp8
-rw-r--r--WebCore/bindings/js/JavaScriptProfile.cpp183
-rw-r--r--WebCore/bindings/js/JavaScriptProfile.h46
-rw-r--r--WebCore/bindings/js/JavaScriptProfileNode.cpp236
-rw-r--r--WebCore/bindings/js/JavaScriptProfileNode.h48
-rw-r--r--WebCore/bindings/js/ScheduledAction.cpp2
-rw-r--r--WebCore/bindings/js/ScheduledAction.h5
14 files changed, 580 insertions, 73 deletions
diff --git a/WebCore/bindings/js/JSAudioConstructor.cpp b/WebCore/bindings/js/JSAudioConstructor.cpp
index 174cc11..77bb120 100644
--- a/WebCore/bindings/js/JSAudioConstructor.cpp
+++ b/WebCore/bindings/js/JSAudioConstructor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -20,7 +20,7 @@
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
@@ -30,10 +30,7 @@
#include "JSAudioConstructor.h"
#include "HTMLAudioElement.h"
-#include "HTMLNames.h"
#include "JSHTMLAudioElement.h"
-#include "ScriptExecutionContext.h"
-#include "Text.h"
#include <runtime/Error.h>
using namespace JSC;
@@ -46,24 +43,30 @@ JSAudioConstructor::JSAudioConstructor(ExecState* exec, JSDOMGlobalObject* globa
: DOMConstructorWithDocument(JSAudioConstructor::createStructure(globalObject->objectPrototype()), globalObject)
{
putDirect(exec->propertyNames().prototype, JSHTMLAudioElementPrototype::self(exec, globalObject), None);
- putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum);
+ putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontDelete | DontEnum);
}
static JSObject* constructAudio(ExecState* exec, JSObject* constructor, const ArgList& args)
{
- JSAudioConstructor* jsAudio = static_cast<JSAudioConstructor*>(constructor);
- // FIXME: Why doesn't this need the call toJS on the document like JSImageConstructor?
- Document* document = jsAudio->document();
+ JSAudioConstructor* jsConstructor = static_cast<JSAudioConstructor*>(constructor);
+
+ Document* document = jsConstructor->document();
if (!document)
return throwError(exec, ReferenceError, "Audio constructor associated document is unavailable");
- RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(HTMLNames::audioTag, document);
- audio->setAutobuffer(true);
- if (args.size() > 0) {
- audio->setSrc(args.at(0).toString(exec));
- audio->scheduleLoad();
- }
- return asObject(toJS(exec, jsAudio->globalObject(), audio.release()));
+ // Calling toJS on the document causes the JS document wrapper to be
+ // added to the window object. This is done to ensure that JSDocument::markChildren
+ // will be called, which will cause the audio element to be marked if necessary.
+ toJS(exec, jsConstructor->globalObject(), document);
+
+ // FIXME: This converts an undefined argument to the string "undefined", but possibly we
+ // should treat it as if no argument was passed instead, by checking the value of args.at
+ // rather than looking at args.size.
+ String src;
+ if (args.size() > 0)
+ src = args.at(0).toString(exec);
+ return asObject(toJS(exec, jsConstructor->globalObject(),
+ HTMLAudioElement::createForJSConstructor(document, src)));
}
ConstructType JSAudioConstructor::getConstructData(ConstructData& constructData)
diff --git a/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp b/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp
index 6178509..4d5de79 100644
--- a/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp
+++ b/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp
@@ -77,7 +77,7 @@ bool JSCustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction,
// Therefore an exception and returning true are the same thing - so, return true on an exception
return true;
}
- return result.toBoolean(exec);
+ return !result.isFalse();
}
}
diff --git a/WebCore/bindings/js/JSDOMBinding.cpp b/WebCore/bindings/js/JSDOMBinding.cpp
index d718cba..abba405 100644
--- a/WebCore/bindings/js/JSDOMBinding.cpp
+++ b/WebCore/bindings/js/JSDOMBinding.cpp
@@ -151,11 +151,9 @@ DOMWrapperWorld::DOMWrapperWorld(JSC::JSGlobalData* globalData, bool isNormal)
DOMWrapperWorld::~DOMWrapperWorld()
{
- if (m_globalData) {
- JSGlobalData::ClientData* clientData = m_globalData->clientData;
- ASSERT(clientData);
- static_cast<WebCoreJSClientData*>(clientData)->forgetWorld(this);
- }
+ JSGlobalData::ClientData* clientData = m_globalData->clientData;
+ ASSERT(clientData);
+ static_cast<WebCoreJSClientData*>(clientData)->forgetWorld(this);
for (HashSet<Document*>::iterator iter = documentsWithWrappers.begin(); iter != documentsWithWrappers.end(); ++iter)
forgetWorldOfDOMNodesForDocument(*iter, this);
diff --git a/WebCore/bindings/js/JSDOMBinding.h b/WebCore/bindings/js/JSDOMBinding.h
index 930f9cc..807bf82 100644
--- a/WebCore/bindings/js/JSDOMBinding.h
+++ b/WebCore/bindings/js/JSDOMBinding.h
@@ -144,7 +144,6 @@ namespace WebCore {
}
~DOMWrapperWorld();
- void detachFromGlobalData() { m_globalData = 0; }
void rememberDocument(Document* document) { documentsWithWrappers.add(document); }
void forgetDocument(Document* document) { documentsWithWrappers.remove(document); }
@@ -201,7 +200,9 @@ namespace WebCore {
{
ASSERT(m_worldSet.contains(m_normalWorld.get()));
ASSERT(m_worldSet.size() == 1);
- m_normalWorld->detachFromGlobalData();
+ ASSERT(m_normalWorld->hasOneRef());
+ m_normalWorld.clear();
+ ASSERT(m_worldSet.isEmpty());
}
DOMWrapperWorld* normalWorld() { return m_normalWorld.get(); }
diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp
index b8cd1dc..bbd4a51 100644
--- a/WebCore/bindings/js/JSDOMWindowCustom.cpp
+++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp
@@ -912,13 +912,13 @@ JSValue JSDOMWindow::postMessage(ExecState* exec, const ArgList& args)
JSValue JSDOMWindow::setTimeout(ExecState* exec, const ArgList& args)
{
- ScheduledAction* action = ScheduledAction::create(exec, args, currentWorld(exec));
+ OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, args, currentWorld(exec));
if (exec->hadException())
return jsUndefined();
int delay = args.at(1).toInt32(exec);
ExceptionCode ec = 0;
- int result = impl()->setTimeout(action, delay, ec);
+ int result = impl()->setTimeout(action.release(), delay, ec);
setDOMException(exec, ec);
return jsNumber(exec, result);
@@ -926,13 +926,13 @@ JSValue JSDOMWindow::setTimeout(ExecState* exec, const ArgList& args)
JSValue JSDOMWindow::setInterval(ExecState* exec, const ArgList& args)
{
- ScheduledAction* action = ScheduledAction::create(exec, args, currentWorld(exec));
+ OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, args, currentWorld(exec));
if (exec->hadException())
return jsUndefined();
int delay = args.at(1).toInt32(exec);
ExceptionCode ec = 0;
- int result = impl()->setInterval(action, delay, ec);
+ int result = impl()->setInterval(action.release(), delay, ec);
setDOMException(exec, ec);
return jsNumber(exec, result);
@@ -954,7 +954,7 @@ JSValue JSDOMWindow::atob(ExecState* exec, const ArgList& args)
}
Vector<char> in(s.size());
- for (int i = 0; i < s.size(); ++i)
+ for (unsigned i = 0; i < s.size(); ++i)
in[i] = static_cast<char>(s.data()[i]);
Vector<char> out;
@@ -980,7 +980,7 @@ JSValue JSDOMWindow::btoa(ExecState* exec, const ArgList& args)
}
Vector<char> in(s.size());
- for (int i = 0; i < s.size(); ++i)
+ for (unsigned i = 0; i < s.size(); ++i)
in[i] = static_cast<char>(s.data()[i]);
Vector<char> out;
diff --git a/WebCore/bindings/js/JSImageConstructor.cpp b/WebCore/bindings/js/JSImageConstructor.cpp
index 0f4a991..a574326 100644
--- a/WebCore/bindings/js/JSImageConstructor.cpp
+++ b/WebCore/bindings/js/JSImageConstructor.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -24,7 +24,6 @@
#include "HTMLNames.h"
#include "JSHTMLImageElement.h"
#include "JSNode.h"
-#include "ScriptExecutionContext.h"
#include <runtime/Error.h>
using namespace JSC;
@@ -43,35 +42,30 @@ JSImageConstructor::JSImageConstructor(ExecState* exec, JSDOMGlobalObject* globa
static JSObject* constructImage(ExecState* exec, JSObject* constructor, const ArgList& args)
{
- bool widthSet = false;
- bool heightSet = false;
- int width = 0;
- int height = 0;
- if (args.size() > 0) {
- widthSet = true;
- width = args.at(0).toInt32(exec);
- }
- if (args.size() > 1) {
- heightSet = true;
- height = args.at(1).toInt32(exec);
- }
-
JSImageConstructor* jsConstructor = static_cast<JSImageConstructor*>(constructor);
Document* document = jsConstructor->document();
if (!document)
return throwError(exec, ReferenceError, "Image constructor associated document is unavailable");
// Calling toJS on the document causes the JS document wrapper to be
- // added to the window object. This is done to ensure that JSDocument::mark
- // will be called (which will cause the image element to be marked if necessary).
+ // added to the window object. This is done to ensure that JSDocument::markChildren
+ // will be called, which will cause the image element to be marked if necessary.
toJS(exec, jsConstructor->globalObject(), document);
+ int width;
+ int height;
+ int* optionalWidth = 0;
+ int* optionalHeight = 0;
+ if (args.size() > 0) {
+ width = args.at(0).toInt32(exec);
+ optionalWidth = &width;
+ }
+ if (args.size() > 1) {
+ height = args.at(1).toInt32(exec);
+ optionalHeight = &height;
+ }
- RefPtr<HTMLImageElement> image = new HTMLImageElement(HTMLNames::imgTag, document);
- if (widthSet)
- image->setWidth(width);
- if (heightSet)
- image->setHeight(height);
- return asObject(toJS(exec, jsConstructor->globalObject(), image.release()));
+ return asObject(toJS(exec, jsConstructor->globalObject(),
+ HTMLImageElement::createForJSConstructor(document, optionalWidth, optionalHeight)));
}
ConstructType JSImageConstructor::getConstructData(ConstructData& constructData)
diff --git a/WebCore/bindings/js/JSOptionConstructor.cpp b/WebCore/bindings/js/JSOptionConstructor.cpp
index 7da0666..995903e 100644
--- a/WebCore/bindings/js/JSOptionConstructor.cpp
+++ b/WebCore/bindings/js/JSOptionConstructor.cpp
@@ -49,21 +49,18 @@ static JSObject* constructHTMLOptionElement(ExecState* exec, JSObject* construct
if (!document)
return throwError(exec, ReferenceError, "Option constructor associated document is unavailable");
- RefPtr<HTMLOptionElement> element = static_pointer_cast<HTMLOptionElement>(document->createElement(HTMLNames::optionTag, false));
-
- ExceptionCode ec = 0;
- RefPtr<Text> text = document->createTextNode("");
+ String data;
if (!args.at(0).isUndefined())
- text->setData(args.at(0).toString(exec), ec);
- if (ec == 0)
- element->appendChild(text.release(), ec);
- if (ec == 0 && !args.at(1).isUndefined())
- element->setValue(args.at(1).toString(exec));
- if (ec == 0)
- element->setDefaultSelected(args.at(2).toBoolean(exec));
- if (ec == 0)
- element->setSelected(args.at(3).toBoolean(exec));
+ data = args.at(0).toString(exec);
+ String value;
+ if (!args.at(1).isUndefined())
+ value = args.at(1).toString(exec);
+ bool defaultSelected = args.at(2).toBoolean(exec);
+ bool selected = args.at(3).toBoolean(exec);
+
+ ExceptionCode ec = 0;
+ RefPtr<HTMLOptionElement> element = HTMLOptionElement::createForJSConstructor(document, data, value, defaultSelected, selected, ec);
if (ec) {
setDOMException(exec, ec);
return 0;
diff --git a/WebCore/bindings/js/JSWorkerContextCustom.cpp b/WebCore/bindings/js/JSWorkerContextCustom.cpp
index d6c8dbd..bf9409c 100644
--- a/WebCore/bindings/js/JSWorkerContextCustom.cpp
+++ b/WebCore/bindings/js/JSWorkerContextCustom.cpp
@@ -143,20 +143,20 @@ JSValue JSWorkerContext::removeEventListener(ExecState* exec, const ArgList& arg
JSValue JSWorkerContext::setTimeout(ExecState* exec, const ArgList& args)
{
- ScheduledAction* action = ScheduledAction::create(exec, args, currentWorld(exec));
+ OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, args, currentWorld(exec));
if (exec->hadException())
return jsUndefined();
int delay = args.at(1).toInt32(exec);
- return jsNumber(exec, impl()->setTimeout(action, delay));
+ return jsNumber(exec, impl()->setTimeout(action.release(), delay));
}
JSValue JSWorkerContext::setInterval(ExecState* exec, const ArgList& args)
{
- ScheduledAction* action = ScheduledAction::create(exec, args, currentWorld(exec));
+ OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, args, currentWorld(exec));
if (exec->hadException())
return jsUndefined();
int delay = args.at(1).toInt32(exec);
- return jsNumber(exec, impl()->setInterval(action, delay));
+ return jsNumber(exec, impl()->setInterval(action.release(), delay));
}
diff --git a/WebCore/bindings/js/JavaScriptProfile.cpp b/WebCore/bindings/js/JavaScriptProfile.cpp
new file mode 100644
index 0000000..8e56ed8
--- /dev/null
+++ b/WebCore/bindings/js/JavaScriptProfile.cpp
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JavaScriptProfile.h"
+
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+
+#include "JavaScriptProfileNode.h"
+#include <JavaScriptCore/APICast.h>
+#include <JavaScriptCore/JSObjectRef.h>
+#include <JavaScriptCore/JSStringRef.h>
+#include <JavaScriptCore/OpaqueJSString.h>
+#include <profiler/Profile.h>
+#include <runtime/JSObject.h>
+#include <runtime/JSValue.h>
+#include <wtf/StdLibExtras.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+// Cache
+
+typedef HashMap<Profile*, JSObject*> ProfileMap;
+
+static ProfileMap& profileCache()
+{
+ DEFINE_STATIC_LOCAL(ProfileMap, staticProfiles, ());
+ return staticProfiles;
+}
+
+// Static Values
+
+static JSClassRef ProfileClass();
+
+static JSValueRef getTitleCallback(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
+{
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileClass()))
+ return JSValueMakeUndefined(ctx);
+
+ Profile* profile = static_cast<Profile*>(JSObjectGetPrivate(thisObject));
+ return JSValueMakeString(ctx, OpaqueJSString::create(profile->title()).get());
+}
+
+static JSValueRef getHeadCallback(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
+{
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileClass()))
+ return JSValueMakeUndefined(ctx);
+
+ ExecState* exec = toJS(ctx);
+ Profile* profile = static_cast<Profile*>(JSObjectGetPrivate(thisObject));
+ return toRef(exec, toJS(exec, profile->head()));
+}
+
+static JSValueRef getUniqueIdCallback(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
+{
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileClass()))
+ return JSValueMakeUndefined(ctx);
+
+ Profile* profile = static_cast<Profile*>(JSObjectGetPrivate(thisObject));
+ return JSValueMakeNumber(ctx, profile->uid());
+}
+
+// Static Functions
+
+static JSValueRef focus(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* /*exception*/)
+{
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileClass()))
+ return JSValueMakeUndefined(ctx);
+
+ if (argumentCount < 1)
+ return JSValueMakeUndefined(ctx);
+
+ if (!JSValueIsObjectOfClass(ctx, arguments[0], ProfileNodeClass()))
+ return JSValueMakeUndefined(ctx);
+
+ Profile* profile = static_cast<Profile*>(JSObjectGetPrivate(thisObject));
+ profile->focus(static_cast<ProfileNode*>(JSObjectGetPrivate(const_cast<JSObjectRef>(arguments[0]))));
+
+ return JSValueMakeUndefined(ctx);
+}
+
+static JSValueRef exclude(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* /*exception*/)
+{
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileClass()))
+ return JSValueMakeUndefined(ctx);
+
+ if (argumentCount < 1)
+ return JSValueMakeUndefined(ctx);
+
+ if (!JSValueIsObjectOfClass(ctx, arguments[0], ProfileNodeClass()))
+ return JSValueMakeUndefined(ctx);
+
+ Profile* profile = static_cast<Profile*>(JSObjectGetPrivate(thisObject));
+ profile->exclude(static_cast<ProfileNode*>(JSObjectGetPrivate(const_cast<JSObjectRef>(arguments[0]))));
+
+ return JSValueMakeUndefined(ctx);
+}
+
+static JSValueRef restoreAll(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t /*argumentCount*/, const JSValueRef[] /*arguments*/, JSValueRef* /*exception*/)
+{
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileClass()))
+ return JSValueMakeUndefined(ctx);
+
+ Profile* profile = static_cast<Profile*>(JSObjectGetPrivate(thisObject));
+ profile->restoreAll();
+
+ return JSValueMakeUndefined(ctx);
+}
+
+static void finalize(JSObjectRef object)
+{
+ Profile* profile = static_cast<Profile*>(JSObjectGetPrivate(object));
+ profileCache().remove(profile);
+ profile->deref();
+}
+
+JSClassRef ProfileClass()
+{
+ static JSStaticValue staticValues[] = {
+ { "title", getTitleCallback, 0, kJSPropertyAttributeNone },
+ { "head", getHeadCallback, 0, kJSPropertyAttributeNone },
+ { "uid", getUniqueIdCallback, 0, kJSPropertyAttributeNone },
+ { 0, 0, 0, 0 }
+ };
+
+ static JSStaticFunction staticFunctions[] = {
+ { "focus", focus, kJSPropertyAttributeNone },
+ { "exclude", exclude, kJSPropertyAttributeNone },
+ { "restoreAll", restoreAll, kJSPropertyAttributeNone },
+ { 0, 0, 0 }
+ };
+
+ static JSClassDefinition classDefinition = {
+ 0, kJSClassAttributeNone, "Profile", 0, staticValues, staticFunctions,
+ 0, finalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+
+ static JSClassRef profileClass = JSClassCreate(&classDefinition);
+ return profileClass;
+}
+
+JSValue toJS(ExecState* exec, Profile* profile)
+{
+ if (!profile)
+ return jsNull();
+
+ JSObject* profileWrapper = profileCache().get(profile);
+ if (profileWrapper)
+ return profileWrapper;
+
+ profile->ref();
+ profileWrapper = toJS(JSObjectMake(toRef(exec), ProfileClass(), static_cast<void*>(profile)));
+ profileCache().set(profile, profileWrapper);
+ return profileWrapper;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(JAVASCRIPT_DEBUGGER)
diff --git a/WebCore/bindings/js/JavaScriptProfile.h b/WebCore/bindings/js/JavaScriptProfile.h
new file mode 100644
index 0000000..7b75b97
--- /dev/null
+++ b/WebCore/bindings/js/JavaScriptProfile.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JavaScriptProfile_h
+#define JavaScriptProfile_h
+
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+
+#include <runtime/JSValue.h>
+
+namespace JSC {
+class ExecState;
+class Profile;
+}
+
+namespace WebCore {
+
+JSC::JSValue toJS(JSC::ExecState*, JSC::Profile*);
+
+} // namespace WebCore
+
+#endif // ENABLE(JAVASCRIPT_DEBUGGER)
+
+#endif
diff --git a/WebCore/bindings/js/JavaScriptProfileNode.cpp b/WebCore/bindings/js/JavaScriptProfileNode.cpp
new file mode 100644
index 0000000..7d60b24
--- /dev/null
+++ b/WebCore/bindings/js/JavaScriptProfileNode.cpp
@@ -0,0 +1,236 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JavaScriptProfileNode.h"
+
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+
+#include "JSDOMBinding.h"
+#include <JavaScriptCore/APICast.h>
+#include <JavaScriptCore/JSContextRef.h>
+#include <JavaScriptCore/JSObjectRef.h>
+#include <JavaScriptCore/JSRetainPtr.h>
+#include <JavaScriptCore/JSStringRef.h>
+#include <profiler/ProfileNode.h>
+#include <runtime/JSLock.h>
+#include <runtime/JSValue.h>
+#include <wtf/StdLibExtras.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+// Cache
+
+typedef HashMap<ProfileNode*, JSObject*> ProfileNodeMap;
+
+static ProfileNodeMap& profileNodeCache()
+{
+ DEFINE_STATIC_LOCAL(ProfileNodeMap, staticProfileNodes, ());
+ return staticProfileNodes;
+}
+
+static JSValueRef getFunctionName(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
+{
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+ return JSValueMakeUndefined(ctx);
+
+ ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+ JSRetainPtr<JSStringRef> functionNameString(Adopt, JSStringCreateWithCharacters(profileNode->functionName().data(), profileNode->functionName().size()));
+ return JSValueMakeString(ctx, functionNameString.get());
+}
+
+static JSValueRef getURL(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
+{
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+ return JSValueMakeUndefined(ctx);
+
+ ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+ JSRetainPtr<JSStringRef> urlString(Adopt, JSStringCreateWithCharacters(profileNode->url().data(), profileNode->url().size()));
+ return JSValueMakeString(ctx, urlString.get());
+}
+
+static JSValueRef getLineNumber(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
+{
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+ return JSValueMakeUndefined(ctx);
+
+ ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+ return JSValueMakeNumber(ctx, profileNode->lineNumber());
+}
+
+static JSValueRef getTotalTime(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
+{
+ JSC::JSLock lock(SilenceAssertionsOnly);
+
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+ return JSValueMakeUndefined(ctx);
+
+ ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+ return JSValueMakeNumber(ctx, profileNode->totalTime());
+}
+
+static JSValueRef getSelfTime(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
+{
+ JSC::JSLock lock(SilenceAssertionsOnly);
+
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+ return JSValueMakeUndefined(ctx);
+
+ ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+ return JSValueMakeNumber(ctx, profileNode->selfTime());
+}
+
+static JSValueRef getNumberOfCalls(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
+{
+ JSC::JSLock lock(SilenceAssertionsOnly);
+
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+ return JSValueMakeUndefined(ctx);
+
+ ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+ return JSValueMakeNumber(ctx, profileNode->numberOfCalls());
+}
+
+static JSValueRef getChildren(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef* exception)
+{
+ JSC::JSLock lock(SilenceAssertionsOnly);
+
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+ return JSValueMakeUndefined(ctx);
+
+ ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+ const Vector<RefPtr<ProfileNode> >& children = profileNode->children();
+
+ JSObjectRef global = JSContextGetGlobalObject(ctx);
+
+ JSRetainPtr<JSStringRef> arrayString(Adopt, JSStringCreateWithUTF8CString("Array"));
+
+ JSValueRef arrayProperty = JSObjectGetProperty(ctx, global, arrayString.get(), exception);
+ if (exception && *exception)
+ return JSValueMakeUndefined(ctx);
+
+ JSObjectRef arrayConstructor = JSValueToObject(ctx, arrayProperty, exception);
+ if (exception && *exception)
+ return JSValueMakeUndefined(ctx);
+
+ JSObjectRef result = JSObjectCallAsConstructor(ctx, arrayConstructor, 0, 0, exception);
+ if (exception && *exception)
+ return JSValueMakeUndefined(ctx);
+
+ JSRetainPtr<JSStringRef> pushString(Adopt, JSStringCreateWithUTF8CString("push"));
+
+ JSValueRef pushProperty = JSObjectGetProperty(ctx, result, pushString.get(), exception);
+ if (exception && *exception)
+ return JSValueMakeUndefined(ctx);
+
+ JSObjectRef pushFunction = JSValueToObject(ctx, pushProperty, exception);
+ if (exception && *exception)
+ return JSValueMakeUndefined(ctx);
+
+ ExecState* exec = toJS(ctx);
+ for (Vector<RefPtr<ProfileNode> >::const_iterator it = children.begin(); it != children.end(); ++it) {
+ JSValueRef arg0 = toRef(exec, toJS(exec, (*it).get() ));
+ JSObjectCallAsFunction(ctx, pushFunction, result, 1, &arg0, exception);
+ if (exception && *exception)
+ return JSValueMakeUndefined(ctx);
+ }
+
+ return result;
+}
+
+static JSValueRef getVisible(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
+{
+ JSC::JSLock lock(SilenceAssertionsOnly);
+
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+ return JSValueMakeUndefined(ctx);
+
+ ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+ return JSValueMakeBoolean(ctx, profileNode->visible());
+}
+
+static JSValueRef getCallUID(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
+{
+ JSC::JSLock lock(SilenceAssertionsOnly);
+
+ if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileNodeClass()))
+ return JSValueMakeUndefined(ctx);
+
+ ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(thisObject));
+ return JSValueMakeNumber(ctx, profileNode->callIdentifier().hash());
+}
+
+static void finalize(JSObjectRef object)
+{
+ ProfileNode* profileNode = static_cast<ProfileNode*>(JSObjectGetPrivate(object));
+ profileNodeCache().remove(profileNode);
+ profileNode->deref();
+}
+
+JSClassRef ProfileNodeClass()
+{
+ static JSStaticValue staticValues[] = {
+ { "functionName", getFunctionName, 0, kJSPropertyAttributeNone },
+ { "url", getURL, 0, kJSPropertyAttributeNone },
+ { "lineNumber", getLineNumber, 0, kJSPropertyAttributeNone },
+ { "totalTime", getTotalTime, 0, kJSPropertyAttributeNone },
+ { "selfTime", getSelfTime, 0, kJSPropertyAttributeNone },
+ { "numberOfCalls", getNumberOfCalls, 0, kJSPropertyAttributeNone },
+ { "children", getChildren, 0, kJSPropertyAttributeNone },
+ { "visible", getVisible, 0, kJSPropertyAttributeNone },
+ { "callUID", getCallUID, 0, kJSPropertyAttributeNone },
+ { 0, 0, 0, 0 }
+ };
+
+ static JSClassDefinition classDefinition = {
+ 0, kJSClassAttributeNone, "ProfileNode", 0, staticValues, 0,
+ 0, finalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+
+ static JSClassRef profileNodeClass = JSClassCreate(&classDefinition);
+ return profileNodeClass;
+}
+
+JSValue toJS(ExecState* exec, ProfileNode* profileNode)
+{
+ if (!profileNode)
+ return jsNull();
+
+ JSObject* profileNodeWrapper = profileNodeCache().get(profileNode);
+ if (profileNodeWrapper)
+ return profileNodeWrapper;
+
+ profileNode->ref();
+
+ profileNodeWrapper = toJS(JSObjectMake(toRef(exec), ProfileNodeClass(), static_cast<void*>(profileNode)));
+ profileNodeCache().set(profileNode, profileNodeWrapper);
+ return profileNodeWrapper;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(JAVASCRIPT_DEBUGGER)
diff --git a/WebCore/bindings/js/JavaScriptProfileNode.h b/WebCore/bindings/js/JavaScriptProfileNode.h
new file mode 100644
index 0000000..f01be19
--- /dev/null
+++ b/WebCore/bindings/js/JavaScriptProfileNode.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JavaScriptProfileNode_h
+#define JavaScriptProfileNode_h
+
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+
+#include <JavaScriptCore/JSBase.h>
+#include <runtime/JSValue.h>
+
+namespace JSC {
+class ExecState;
+class ProfileNode;
+}
+
+namespace WebCore {
+
+JSClassRef ProfileNodeClass();
+JSC::JSValue toJS(JSC::ExecState*, JSC::ProfileNode*);
+
+} // namespace WebCore
+
+#endif // ENABLE(JAVASCRIPT_DEBUGGER)
+
+#endif
diff --git a/WebCore/bindings/js/ScheduledAction.cpp b/WebCore/bindings/js/ScheduledAction.cpp
index be90125..be62bb8 100644
--- a/WebCore/bindings/js/ScheduledAction.cpp
+++ b/WebCore/bindings/js/ScheduledAction.cpp
@@ -47,7 +47,7 @@ using namespace JSC;
namespace WebCore {
-ScheduledAction* ScheduledAction::create(ExecState* exec, const ArgList& args, DOMWrapperWorld* isolatedWorld)
+PassOwnPtr<ScheduledAction> ScheduledAction::create(ExecState* exec, const ArgList& args, DOMWrapperWorld* isolatedWorld)
{
JSValue v = args.at(0);
CallData callData;
diff --git a/WebCore/bindings/js/ScheduledAction.h b/WebCore/bindings/js/ScheduledAction.h
index dd13ab1..3b7e001 100644
--- a/WebCore/bindings/js/ScheduledAction.h
+++ b/WebCore/bindings/js/ScheduledAction.h
@@ -24,6 +24,7 @@
#include <JSDOMBinding.h>
#include <runtime/JSCell.h>
#include <runtime/Protect.h>
+#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
namespace JSC {
@@ -42,7 +43,7 @@ namespace WebCore {
*/
class ScheduledAction : public Noncopyable {
public:
- static ScheduledAction* create(JSC::ExecState*, const JSC::ArgList&, DOMWrapperWorld* isolatedWorld);
+ static PassOwnPtr<ScheduledAction> create(JSC::ExecState*, const JSC::ArgList&, DOMWrapperWorld* isolatedWorld);
void execute(ScriptExecutionContext*);
@@ -56,7 +57,7 @@ namespace WebCore {
void executeFunctionInContext(JSC::JSGlobalObject*, JSC::JSValue thisValue);
void execute(Document*);
-#if ENABLE(WORKERS)
+#if ENABLE(WORKERS)
void execute(WorkerContext*);
#endif