summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/v8')
-rw-r--r--WebCore/bindings/v8/ScriptCallStack.h85
-rw-r--r--WebCore/bindings/v8/ScriptCallStackFactory.cpp (renamed from WebCore/bindings/v8/ScriptCallStack.cpp)135
-rw-r--r--WebCore/bindings/v8/ScriptCallStackFactory.h (renamed from WebCore/bindings/v8/ScriptCallFrame.h)55
-rw-r--r--WebCore/bindings/v8/ScriptController.cpp3
-rw-r--r--WebCore/bindings/v8/ScriptState.h2
-rw-r--r--WebCore/bindings/v8/V8ConsoleMessage.cpp8
-rw-r--r--WebCore/bindings/v8/V8ConsoleMessage.h3
-rw-r--r--WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h2
-rw-r--r--WebCore/bindings/v8/custom/V8ConsoleCustom.cpp40
-rw-r--r--WebCore/bindings/v8/custom/V8DOMSettableTokenListCustom.cpp5
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLOutputElementCustom.cpp (renamed from WebCore/bindings/v8/ScriptCallFrame.cpp)42
-rw-r--r--WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp43
-rw-r--r--WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp4
13 files changed, 166 insertions, 261 deletions
diff --git a/WebCore/bindings/v8/ScriptCallStack.h b/WebCore/bindings/v8/ScriptCallStack.h
deleted file mode 100644
index 98e5195..0000000
--- a/WebCore/bindings/v8/ScriptCallStack.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2008, 2009 Google 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:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * 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.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 THE COPYRIGHT
- * OWNER 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 ScriptCallStack_h
-#define ScriptCallStack_h
-
-#include "ScriptCallFrame.h"
-#include "ScriptState.h"
-#include "ScriptValue.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/RefPtr.h>
-
-namespace v8 {
- class Arguments;
-}
-
-namespace WebCore {
-
-class InspectorArray;
-
-class ScriptCallStack : public Noncopyable {
-public:
- static const int maxCallStackSizeToCapture;
- static const v8::StackTrace::StackTraceOptions stackTraceOptions;
-
- static PassOwnPtr<ScriptCallStack> create(const v8::Arguments&, unsigned skipArgumentCount = 0, int framCountLimit = 1);
- static PassOwnPtr<ScriptCallStack> create(ScriptState*, v8::Handle<v8::StackTrace>);
- ~ScriptCallStack();
-
- // Returns false if there is no running JavaScript or if fetching the stack failed.
- // Sets stackTrace to be an array of stack frame objects.
- // A stack frame object looks like:
- // {
- // scriptName: <file name for the associated script resource>
- // functionName: <name of the JavaScript function>
- // lineNumber: <1 based line number>
- // column: <1 based column offset on the line>
- // }
- static bool stackTrace(int frameLimit, const RefPtr<InspectorArray>& stackTrace);
-
- const ScriptCallFrame& at(unsigned);
- unsigned size();
-
- ScriptState* state() const { return m_scriptState; }
- ScriptState* globalState() const { return m_scriptState; }
-
-private:
- ScriptCallStack(ScriptState* scriptState, PassOwnPtr<ScriptCallFrame> topFrame, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames);
- ScriptCallStack(ScriptState* scriptState, v8::Handle<v8::StackTrace> stackTrace);
-
- OwnPtr<ScriptCallFrame> m_topFrame;
- ScriptState* m_scriptState;
- Vector<OwnPtr<ScriptCallFrame> > m_scriptCallFrames;
-};
-
-} // namespace WebCore
-
-#endif // ScriptCallStack_h
diff --git a/WebCore/bindings/v8/ScriptCallStack.cpp b/WebCore/bindings/v8/ScriptCallStackFactory.cpp
index 3e29c7a..62fbeef 100644
--- a/WebCore/bindings/v8/ScriptCallStack.cpp
+++ b/WebCore/bindings/v8/ScriptCallStackFactory.cpp
@@ -1,10 +1,10 @@
/*
- * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
- *
+ * Copyright (c) 2010 Google 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:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -29,131 +29,88 @@
*/
#include "config.h"
-#include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
#include "InspectorValues.h"
-#include "ScriptController.h"
-#include "ScriptDebugServer.h"
+#include "ScriptArguments.h"
+#include "ScriptCallFrame.h"
+#include "ScriptCallStack.h"
#include "ScriptScope.h"
+#include "ScriptValue.h"
#include "V8Binding.h"
#include <v8-debug.h>
namespace WebCore {
-static void getFrameLocation(v8::Handle<v8::StackFrame> frame, String* sourceName, int* sourceLineNumber, String* functionName)
+static ScriptCallFrame toScriptCallFrame(v8::Handle<v8::StackFrame> frame)
{
- ASSERT(!frame.IsEmpty());
+ String sourceName;
v8::Local<v8::String> sourceNameValue(frame->GetScriptNameOrSourceURL());
- v8::Local<v8::String> functionNameValue(frame->GetFunctionName());
- *sourceName = sourceNameValue.IsEmpty() ? "" : toWebCoreString(sourceNameValue);
- *functionName = functionNameValue.IsEmpty() ? "" : toWebCoreString(functionNameValue);
- *sourceLineNumber = frame->GetLineNumber();
-}
-
-static void getTopFrameLocation(v8::Handle<v8::StackTrace> stackTrace, String* sourceName, int* sourceLineNumber, String* functionName)
-{
- if (stackTrace->GetFrameCount() <= 0) {
- // Successfully grabbed stack trace, but there are no frames. It may happen in case of a syntax error for example.
- // Fallback to setting lineNumber to 0, and source and function name to "undefined".
- *sourceName = "undefined";
- *sourceLineNumber = 0;
- *functionName = "undefined";
- } else {
- v8::Handle<v8::StackFrame> frame = stackTrace->GetFrame(0);
- getFrameLocation(frame, sourceName, sourceLineNumber, functionName);
- }
-}
+ if (!sourceNameValue.IsEmpty())
+ sourceName = toWebCoreString(sourceNameValue);
-static PassOwnPtr<ScriptCallFrame> toScriptCallFrame(v8::Handle<v8::StackFrame> frame)
-{
- String sourceName;
- int sourceLineNumber;
String functionName;
- getFrameLocation(frame, &sourceName, &sourceLineNumber, &functionName);
- return new ScriptCallFrame(functionName, sourceName, sourceLineNumber);
+ v8::Local<v8::String> functionNameValue(frame->GetFunctionName());
+ if (!functionNameValue.IsEmpty())
+ functionName = toWebCoreString(functionNameValue);
+
+ int sourceLineNumber = frame->GetLineNumber();
+ return ScriptCallFrame(functionName, sourceName, sourceLineNumber);
}
-static void toScriptCallFramesVector(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames)
+static void toScriptCallFramesVector(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, Vector<ScriptCallFrame>& scriptCallFrames, size_t maxStackSize)
{
+ // TODO(yurys): remove this???
v8::Context::Scope contextScope(context);
int frameCount = stackTrace->GetFrameCount();
+ if (frameCount > static_cast<int>(maxStackSize))
+ frameCount = maxStackSize;
for (int i = 0; i < frameCount; i++) {
v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i);
scriptCallFrames.append(toScriptCallFrame(stackFrame));
}
+
+ if (!frameCount) {
+ // Successfully grabbed stack trace, but there are no frames. It may happen in case of a syntax error for example.
+ // Fallback to setting lineNumber to 0, and source and function name to "undefined".
+ scriptCallFrames.append(ScriptCallFrame("undefined", "undefined", 0));
+ }
}
-const int ScriptCallStack::maxCallStackSizeToCapture = 200;
-const v8::StackTrace::StackTraceOptions ScriptCallStack::stackTraceOptions = static_cast<v8::StackTrace::StackTraceOptions>(
- v8::StackTrace::kLineNumber
- | v8::StackTrace::kColumnOffset
- | v8::StackTrace::kScriptNameOrSourceURL
- | v8::StackTrace::kFunctionName);
-
-
-PassOwnPtr<ScriptCallStack> ScriptCallStack::create(const v8::Arguments& arguments, unsigned skipArgumentCount, int framCountLimit)
+PassOwnPtr<ScriptCallStack> createScriptCallStack(v8::Local<v8::Context> context, v8::Handle<v8::StackTrace> stackTrace, size_t maxStackSize)
{
v8::HandleScope scope;
- v8::Local<v8::Context> context = v8::Context::GetCurrent();
v8::Context::Scope contextScope(context);
- v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(framCountLimit, ScriptCallStack::stackTraceOptions));
-
- if (stackTrace.IsEmpty())
- return 0;
-
- String sourceName;
- int sourceLineNumber;
- String functionName;
- getTopFrameLocation(stackTrace, &sourceName, &sourceLineNumber, &functionName);
-
- Vector<OwnPtr<ScriptCallFrame> > scriptCallFrames;
- if (framCountLimit > 1)
- toScriptCallFramesVector(context, stackTrace, scriptCallFrames);
- return new ScriptCallStack(ScriptState::forContext(context), new ScriptCallFrame(functionName, sourceName, sourceLineNumber, arguments, skipArgumentCount), scriptCallFrames);
+ Vector<ScriptCallFrame> scriptCallFrames;
+ toScriptCallFramesVector(context, stackTrace, scriptCallFrames, maxStackSize);
+ return new ScriptCallStack(scriptCallFrames);
}
-PassOwnPtr<ScriptCallStack> ScriptCallStack::create(ScriptState* state, v8::Handle<v8::StackTrace> stackTrace)
+PassOwnPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize)
{
v8::HandleScope scope;
- Vector<OwnPtr<ScriptCallFrame> > scriptCallFrames;
- toScriptCallFramesVector(state->context(), stackTrace, scriptCallFrames);
-
- String sourceName;
- int sourceLineNumber;
- String functionName;
- getTopFrameLocation(stackTrace, &sourceName, &sourceLineNumber, &functionName);
-
- return new ScriptCallStack(state, new ScriptCallFrame(functionName, sourceName, sourceLineNumber), scriptCallFrames);
-}
-
-ScriptCallStack::ScriptCallStack(ScriptState* scriptState, PassOwnPtr<ScriptCallFrame> topFrame, Vector<OwnPtr<ScriptCallFrame> >& scriptCallFrames)
- : m_topFrame(topFrame)
- , m_scriptState(scriptState)
-{
- m_scriptCallFrames.swap(scriptCallFrames);
+ v8::Local<v8::Context> context = v8::Context::GetCurrent();
+ // TODO(yurys): remove?
+ v8::Context::Scope contextScope(context);
+ v8::Handle<v8::StackTrace> stackTrace(v8::StackTrace::CurrentStackTrace(maxStackSize, stackTraceOptions));
+ return createScriptCallStack(context, stackTrace, maxStackSize);
}
-ScriptCallStack::~ScriptCallStack()
+PassOwnPtr<ScriptArguments> createScriptArguments(const v8::Arguments& v8arguments, unsigned skipArgumentCount)
{
-}
+ v8::HandleScope scope;
+ v8::Local<v8::Context> context = v8::Context::GetCurrent();
+ ScriptState* state = ScriptState::forContext(context);
-const ScriptCallFrame& ScriptCallStack::at(unsigned index)
-{
- if (!index && m_topFrame)
- return *m_topFrame;
- return *m_scriptCallFrames.at(index);
-}
+ Vector<ScriptValue> arguments;
+ for (int i = skipArgumentCount; i < v8arguments.Length(); ++i)
+ arguments.append(ScriptValue(v8arguments[i]));
-unsigned ScriptCallStack::size()
-{
- if (m_scriptCallFrames.isEmpty())
- return 1;
- return m_scriptCallFrames.size();
+ return new ScriptArguments(state, arguments);
}
-
bool ScriptCallStack::stackTrace(int frameLimit, const RefPtr<InspectorArray>& stackTrace)
{
#if ENABLE(INSPECTOR)
diff --git a/WebCore/bindings/v8/ScriptCallFrame.h b/WebCore/bindings/v8/ScriptCallStackFactory.h
index ff77d4a..613af7b 100644
--- a/WebCore/bindings/v8/ScriptCallFrame.h
+++ b/WebCore/bindings/v8/ScriptCallStackFactory.h
@@ -1,10 +1,10 @@
/*
- * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
- *
+ * Copyright (c) 2010 Google 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:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -28,46 +28,29 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef ScriptCallFrame_h
-#define ScriptCallFrame_h
-
-#include "KURL.h"
+#ifndef ScriptCallStackFactory_h
+#define ScriptCallStackFactory_h
-#include <wtf/Vector.h>
-
-namespace v8 {
- class Arguments;
-}
+#include <v8.h>
+#include <wtf/PassOwnPtr.h>
namespace WebCore {
- class ScriptValue;
-
- // FIXME: Implement retrieving line number and source URL and storing here
- // for all call frames, not just the first one.
- // See <https://bugs.webkit.org/show_bug.cgi?id=22556> and
- // <https://bugs.webkit.org/show_bug.cgi?id=21180>
- class ScriptCallFrame {
- public:
- ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber, const v8::Arguments&, unsigned skipArgumentCount);
- ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber);
- ~ScriptCallFrame();
- const String& functionName() const { return m_functionName; }
- const String& sourceURL() const { return m_sourceURL; }
- unsigned lineNumber() const { return m_lineNumber; }
+class ScriptState;
- // argument retrieval methods
- const ScriptValue& argumentAt(unsigned) const;
- unsigned argumentCount() const { return m_arguments.size(); }
+const v8::StackTrace::StackTraceOptions stackTraceOptions = static_cast<v8::StackTrace::StackTraceOptions>(
+ v8::StackTrace::kLineNumber
+ | v8::StackTrace::kColumnOffset
+ | v8::StackTrace::kScriptNameOrSourceURL
+ | v8::StackTrace::kFunctionName);
- private:
- String m_functionName;
- String m_sourceURL;
- unsigned m_lineNumber;
+class ScriptArguments;
+class ScriptCallStack;
- Vector<ScriptValue> m_arguments;
- };
+PassOwnPtr<ScriptCallStack> createScriptCallStack(v8::Local<v8::Context>, v8::Handle<v8::StackTrace>, size_t maxStackSize);
+PassOwnPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize);
+PassOwnPtr<ScriptArguments> createScriptArguments(const v8::Arguments& v8arguments, unsigned skipArgumentCount);
} // namespace WebCore
-#endif // ScriptCallFrame_h
+#endif // ScriptCallStackFactory_h
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index 913a892..648ae98 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -35,6 +35,7 @@
#include "PlatformBridge.h"
#include "Document.h"
#include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
#include "ScriptableDocumentParser.h"
#include "DOMWindow.h"
#include "Event.h"
@@ -481,7 +482,7 @@ void ScriptController::clearWindowShell(bool)
#if ENABLE(INSPECTOR)
void ScriptController::setCaptureCallStackForUncaughtExceptions(bool value)
{
- v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::maxCallStackSizeToCapture, ScriptCallStack::stackTraceOptions);
+ v8::V8::SetCaptureStackTraceForUncaughtExceptions(value, ScriptCallStack::maxCallStackSizeToCapture, stackTraceOptions);
}
#endif
diff --git a/WebCore/bindings/v8/ScriptState.h b/WebCore/bindings/v8/ScriptState.h
index ce350da..11813b0 100644
--- a/WebCore/bindings/v8/ScriptState.h
+++ b/WebCore/bindings/v8/ScriptState.h
@@ -95,7 +95,7 @@ public:
m_context.Clear();
}
}
- ScriptState* get() { return m_scriptState; }
+ ScriptState* get() const { return m_scriptState; }
private:
ScriptState* m_scriptState;
v8::Persistent<v8::Context> m_context;
diff --git a/WebCore/bindings/v8/V8ConsoleMessage.cpp b/WebCore/bindings/v8/V8ConsoleMessage.cpp
index 8b6bb17..40f9a7a 100644
--- a/WebCore/bindings/v8/V8ConsoleMessage.cpp
+++ b/WebCore/bindings/v8/V8ConsoleMessage.cpp
@@ -37,6 +37,7 @@
#include "OwnPtr.h"
#include "Page.h"
#include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
#include "V8Binding.h"
#include "V8Proxy.h"
@@ -117,18 +118,17 @@ void V8ConsoleMessage::handler(v8::Handle<v8::Message> message, v8::Handle<v8::V
// Currently stack trace is only collected when inspector is open.
if (!stackTrace.IsEmpty() && stackTrace->GetFrameCount() > 0) {
v8::Local<v8::Context> context = v8::Context::GetEntered();
- ScriptState* scriptState = ScriptState::forContext(context);
- callStack = ScriptCallStack::create(scriptState, stackTrace);
+ callStack = createScriptCallStack(context, stackTrace, ScriptCallStack::maxCallStackSizeToCapture);
}
v8::Handle<v8::Value> resourceName = message->GetScriptResourceName();
bool useURL = resourceName.IsEmpty() || !resourceName->IsString();
String resourceNameString = useURL ? frame->document()->url() : toWebCoreString(resourceName);
V8ConsoleMessage consoleMessage(errorMessage, resourceNameString, message->GetLineNumber());
- consoleMessage.dispatchNow(page, callStack.get());
+ consoleMessage.dispatchNow(page, callStack.release());
}
-void V8ConsoleMessage::dispatchNow(Page* page, ScriptCallStack* callStack)
+void V8ConsoleMessage::dispatchNow(Page* page, PassOwnPtr<ScriptCallStack> callStack)
{
ASSERT(page);
diff --git a/WebCore/bindings/v8/V8ConsoleMessage.h b/WebCore/bindings/v8/V8ConsoleMessage.h
index 387b5ee..6b892dd 100644
--- a/WebCore/bindings/v8/V8ConsoleMessage.h
+++ b/WebCore/bindings/v8/V8ConsoleMessage.h
@@ -33,6 +33,7 @@
#include "PlatformString.h"
#include <v8.h>
+#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
@@ -81,7 +82,7 @@ namespace WebCore {
const String m_sourceID;
const unsigned m_lineNumber;
- void dispatchNow(Page*, ScriptCallStack*);
+ void dispatchNow(Page*, PassOwnPtr<ScriptCallStack>);
// All delayed messages are stored in this vector. If the vector
// is 0, there are no delayed messages.
diff --git a/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h
index ffea07c..2566b67 100644
--- a/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h
+++ b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h
@@ -94,6 +94,8 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType
if (!ok)
return throwError("Could not convert argument 1 to a number");
}
+ if ((buf->byteLength() - offset) % sizeof(ElementType))
+ return throwError("ArrayBuffer length minus the byteOffset is not a multiple of the element size.", V8Proxy::RangeError);
uint32_t length = (buf->byteLength() - offset) / sizeof(ElementType);
if (argLen > 2) {
length = toUInt32(args[2], ok);
diff --git a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp b/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
index fc83b61..b17b8e9 100644
--- a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
@@ -33,9 +33,12 @@
#include "V8Console.h"
#include "Console.h"
+#include "ScriptArguments.h"
#include "ScriptCallStack.h"
+#include "ScriptCallStackFactory.h"
#include "ScriptProfile.h"
#include "V8Binding.h"
+#include "V8BindingMacros.h"
#include "V8Proxy.h"
#include "V8ScriptProfile.h"
@@ -62,11 +65,9 @@ v8::Handle<v8::Value> V8Console::traceCallback(const v8::Arguments& args)
{
INC_STATS("DOM.Console.traceCallback");
Console* imp = V8Console::toNative(args.Holder());
- v8::HandleScope handleScope;
- ScriptState* scriptState = ScriptState::current();
- v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(ScriptCallStack::maxCallStackSizeToCapture, ScriptCallStack::stackTraceOptions);
- OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(scriptState, stackTrace));
- imp->trace(callStack.get());
+ OwnPtr<ScriptCallStack> callStack(createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture));
+ OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 0));
+ imp->trace(scriptArguments.release(), callStack.release());
return v8::Handle<v8::Value>();
}
@@ -74,9 +75,34 @@ v8::Handle<v8::Value> V8Console::assertCallback(const v8::Arguments& args)
{
INC_STATS("DOM.Console.assertCallback");
Console* imp = V8Console::toNative(args.Holder());
- OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1, ScriptCallStack::maxCallStackSizeToCapture));
+ OwnPtr<ScriptCallStack> callStack(createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture));
bool condition = args[0]->BooleanValue();
- imp->assertCondition(condition, callStack.get());
+ OwnPtr<ScriptArguments> scriptArguments(createScriptArguments(args, 1));
+ imp->assertCondition(condition, scriptArguments.release(), callStack.release());
+ return v8::Handle<v8::Value>();
+}
+
+v8::Handle<v8::Value> V8Console::profileCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.Console.profile");
+ Console* imp = V8Console::toNative(args.Holder());
+ OwnPtr<ScriptCallStack> callStack(createScriptCallStack(1));
+ if (!callStack)
+ return v8::Undefined();
+ STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithUndefinedOrNullCheck>, title, args[0]);
+ imp->profile(title, ScriptState::current(), callStack.release());
+ return v8::Handle<v8::Value>();
+}
+
+v8::Handle<v8::Value> V8Console::profileEndCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.Console.profileEnd");
+ Console* imp = V8Console::toNative(args.Holder());
+ OwnPtr<ScriptCallStack> callStack(createScriptCallStack(1));
+ if (!callStack)
+ return v8::Undefined();
+ STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithUndefinedOrNullCheck>, title, args[0]);
+ imp->profileEnd(title, ScriptState::current(), callStack.release());
return v8::Handle<v8::Value>();
}
diff --git a/WebCore/bindings/v8/custom/V8DOMSettableTokenListCustom.cpp b/WebCore/bindings/v8/custom/V8DOMSettableTokenListCustom.cpp
index 4eeb1e0..e1c9be4 100644
--- a/WebCore/bindings/v8/custom/V8DOMSettableTokenListCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMSettableTokenListCustom.cpp
@@ -34,8 +34,9 @@ namespace WebCore {
v8::Handle<v8::Value> V8DOMSettableTokenList::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
{
- // FIXME: Implement this function.
- return v8String("");
+ INC_STATS("DOM.DOMSettableTokenList.IndexedPropertyGetter");
+ DOMSettableTokenList* list = V8DOMSettableTokenList::toNative(info.Holder());
+ return v8StringOrNull(list->item(index));
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/ScriptCallFrame.cpp b/WebCore/bindings/v8/custom/V8HTMLOutputElementCustom.cpp
index f0c7343..ad86dd2 100644
--- a/WebCore/bindings/v8/ScriptCallFrame.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLOutputElementCustom.cpp
@@ -1,10 +1,10 @@
/*
- * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
- *
+ * Copyright (C) 2010 Google 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:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -29,41 +29,27 @@
*/
#include "config.h"
-#include "ScriptCallFrame.h"
-
-#include <v8.h>
+#include "V8HTMLOutputElement.h"
-#include "PlatformString.h"
+#include "HTMLOutputElement.h"
#include "V8Binding.h"
+#include "V8DOMSettableTokenList.h"
#include "V8Proxy.h"
-#include "ScriptValue.h"
namespace WebCore {
-ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber, const v8::Arguments& arguments, unsigned skipArgumentCount)
- : m_functionName(functionName)
- , m_sourceURL(urlString)
- , m_lineNumber(lineNumber)
-{
- for (int i = skipArgumentCount; i < arguments.Length(); ++i)
- m_arguments.append(ScriptValue(arguments[i]));
-}
-
-ScriptCallFrame::ScriptCallFrame(const String& functionName, const String& urlString, int lineNumber)
- : m_functionName(functionName)
- , m_sourceURL(urlString)
- , m_lineNumber(lineNumber)
-{
-}
-
-ScriptCallFrame::~ScriptCallFrame()
+v8::Handle<v8::Value> V8HTMLOutputElement::htmlForAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
+ INC_STATS("DOM.HTMLOutputElement.htmlFor._get");
+ HTMLOutputElement* imp = V8HTMLOutputElement::toNative(info.Holder());
+ return toV8(imp->htmlFor());
}
-const ScriptValue& ScriptCallFrame::argumentAt(unsigned index) const
+void V8HTMLOutputElement::htmlForAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
- ASSERT(m_arguments.size() > index);
- return m_arguments[index];
+ INC_STATS("DOM.HTMLOutputElement.htmlFor._set");
+ HTMLOutputElement* imp = V8HTMLOutputElement::toNative(info.Holder());
+ imp->setFor(toWebCoreString(value));
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp b/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp
index 3582a36..ec6324d 100644
--- a/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp
@@ -35,25 +35,58 @@
#include "SVGPropertyTearOff.h"
#include "V8Binding.h"
+#include "V8BindingMacros.h"
namespace WebCore {
v8::Handle<v8::Value> V8SVGLength::valueAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
- INC_STATS("DOM.SVGLength.value");
+ INC_STATS("DOM.SVGLength.value._get");
SVGPropertyTearOff<SVGLength>* wrapper = V8SVGLength::toNative(info.Holder());
SVGLength& imp = wrapper->propertyReference();
- return v8::Number::New(imp.value(wrapper->contextElement()));
+ ExceptionCode ec = 0;
+ float value = imp.value(wrapper->contextElement(), ec);
+ if (UNLIKELY(ec)) {
+ V8Proxy::setDOMException(ec);
+ return v8::Handle<v8::Value>();
+ }
+ return v8::Number::New(value);
+}
+
+void V8SVGLength::valueAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+{
+ INC_STATS("DOM.SVGLength.value._set");
+ if (!isUndefinedOrNull(value) && !value->IsNumber() && !value->IsBoolean()) {
+ V8Proxy::throwTypeError();
+ return;
+ }
+
+ SVGPropertyTearOff<SVGLength>* wrapper = V8SVGLength::toNative(info.Holder());
+ SVGLength& imp = wrapper->propertyReference();
+ ExceptionCode ec = 0;
+ imp.setValue(static_cast<float>(value->NumberValue()), wrapper->contextElement(), ec);
+ if (UNLIKELY(ec))
+ V8Proxy::setDOMException(ec);
+ else
+ wrapper->commitChange();
}
v8::Handle<v8::Value> V8SVGLength::convertToSpecifiedUnitsCallback(const v8::Arguments& args)
{
INC_STATS("DOM.SVGLength.convertToSpecifiedUnits");
+ if (args.Length() < 1)
+ return throwError("Not enough arguments", V8Proxy::SyntaxError);
+
SVGPropertyTearOff<SVGLength>* wrapper = V8SVGLength::toNative(args.Holder());
SVGLength& imp = wrapper->propertyReference();
- imp.convertToSpecifiedUnits(toInt32(args[0]), wrapper->contextElement());
- wrapper->commitChange();
- return v8::Undefined();
+ ExceptionCode ec = 0;
+ EXCEPTION_BLOCK(int, unitType, toUInt32(args[0]));
+ imp.convertToSpecifiedUnits(unitType, wrapper->contextElement(), ec);
+ if (UNLIKELY(ec))
+ V8Proxy::setDOMException(ec);
+ else
+ wrapper->commitChange();
+ return v8::Handle<v8::Value>();
}
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
index 9346a05..b2240ed 100644
--- a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
@@ -236,10 +236,10 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getAttachedShadersCallback(const
bool succeed = context->getAttachedShaders(program, shaders, ec);
if (ec) {
V8Proxy::setDOMException(ec);
- return v8::Undefined();
+ return v8::Null();
}
if (!succeed)
- return v8::Undefined();
+ return v8::Null();
v8::Local<v8::Array> array = v8::Array::New(shaders.size());
for (size_t ii = 0; ii < shaders.size(); ++ii)
array->Set(v8::Integer::New(ii), toV8(shaders[ii]));