summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8/custom
diff options
context:
space:
mode:
authorTeng-Hui Zhu <ztenghui@google.com>2010-11-10 15:31:59 -0800
committerTeng-Hui Zhu <ztenghui@google.com>2010-11-17 13:35:59 -0800
commit28040489d744e0c5d475a88663056c9040ed5320 (patch)
treec463676791e4a63e452a95f0a12b2a8519730693 /WebCore/bindings/v8/custom
parenteff9be92c41913c92fb1d3b7983c071f3e718678 (diff)
downloadexternal_webkit-28040489d744e0c5d475a88663056c9040ed5320.zip
external_webkit-28040489d744e0c5d475a88663056c9040ed5320.tar.gz
external_webkit-28040489d744e0c5d475a88663056c9040ed5320.tar.bz2
Merge WebKit at r71558: Initial merge by git.
Change-Id: Ib345578fa29df7e4bc72b4f00e4a6fddcb754c4c
Diffstat (limited to 'WebCore/bindings/v8/custom')
-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.cpp55
-rw-r--r--WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp43
-rw-r--r--WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp4
6 files changed, 133 insertions, 16 deletions
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/custom/V8HTMLOutputElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLOutputElementCustom.cpp
new file mode 100644
index 0000000..ad86dd2
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8HTMLOutputElementCustom.cpp
@@ -0,0 +1,55 @@
+/*
+ * 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
+ * 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.
+ */
+
+#include "config.h"
+#include "V8HTMLOutputElement.h"
+
+#include "HTMLOutputElement.h"
+#include "V8Binding.h"
+#include "V8DOMSettableTokenList.h"
+#include "V8Proxy.h"
+
+namespace WebCore {
+
+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());
+}
+
+void V8HTMLOutputElement::htmlForAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
+{
+ 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]));