Diff
Modified: trunk/Source/WebCore/ChangeLog (120303 => 120304)
--- trunk/Source/WebCore/ChangeLog 2012-06-14 09:56:06 UTC (rev 120303)
+++ trunk/Source/WebCore/ChangeLog 2012-06-14 09:59:20 UTC (rev 120304)
@@ -1,3 +1,29 @@
+2012-06-14 Kent Tamura <[email protected]>
+
+ [JSC/V8] Improve DOMString[] support
+ https://bugs.webkit.org/show_bug.cgi?id=89070
+
+ Reviewed by Kentaro Hara.
+
+ Tests: new test case in TestObj.idl
+
+ * bindings/js/JSDOMBinding.cpp:
+ (WebCore::jsArray): Implement jsArray() for DOMStringList.
+ * bindings/js/JSDOMBinding.h: Declare jsArray() for DOMStringList.
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (NativeToJSValue): Avoid to include JSDOMString.h and DOMString.h.
+ * bindings/scripts/CodeGeneratorV8.pm:
+ (GetNativeType): Move a check for DOMString[] because it's a RefPtr type
+ and we'd like to avoid to generate RefPtr<DOMString[]>
+ (%non_wrapper_types): DOMString[] is not a wrapper type. This is needed
+ to avoid to generate unnecessary custom function template.
+ (NativeToJSValue): Avoid to include V8DOMString.h and DOMString.h.
+
+ * bindings/scripts/test/TestObj.idl: Add non-overload function using DOMString[].
+ * bindings/scripts/test/JS/JSTestObj.cpp: Update expectation.
+ * bindings/scripts/test/JS/JSTestObj.h: ditto.
+ * bindings/scripts/test/V8/V8TestObj.cpp: ditto.
+
2012-06-14 Matt Falkenhagen <[email protected]>
LocaleToScriptMappingDefault.cpp should also do what scriptCodeForFontSelection does in LocaleToScriptMappingICU.cpp
Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp (120303 => 120304)
--- trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp 2012-06-14 09:56:06 UTC (rev 120303)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp 2012-06-14 09:59:20 UTC (rev 120304)
@@ -22,6 +22,7 @@
#include "JSDOMBinding.h"
#include "DOMObjectHashTableMap.h"
+#include "DOMStringList.h"
#include "ExceptionCode.h"
#include "ExceptionHeaders.h"
#include "ExceptionInterfaces.h"
@@ -146,6 +147,16 @@
return static_cast<DateInstance*>(value.toObject(exec))->internalNumber();
}
+JSC::JSValue jsArray(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, PassRefPtr<DOMStringList> stringList)
+{
+ if (!stringList)
+ return jsNull();
+ JSC::MarkedArgumentBuffer list;
+ for (unsigned i = 0; i < stringList->length(); ++i)
+ list.append(jsString(exec, stringList->item(i)));
+ return JSC::constructArray(exec, globalObject, list);
+}
+
void reportException(ExecState* exec, JSValue exception)
{
if (isTerminatedExecutionException(exception))
Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (120303 => 120304)
--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2012-06-14 09:56:06 UTC (rev 120303)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2012-06-14 09:59:20 UTC (rev 120304)
@@ -44,6 +44,8 @@
namespace WebCore {
+class DOMStringList;
+
enum ParameterDefaultPolicy {
DefaultIsUndefined,
DefaultIsNullString
@@ -291,6 +293,8 @@
return JSC::constructArray(exec, globalObject, list);
}
+ JSC::JSValue jsArray(JSC::ExecState*, JSDOMGlobalObject*, PassRefPtr<DOMStringList>);
+
template<>
inline JSC::JSValue jsArray(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, const Vector<String>& iterator)
{
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (120303 => 120304)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2012-06-14 09:56:06 UTC (rev 120303)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2012-06-14 09:59:20 UTC (rev 120304)
@@ -3072,7 +3072,10 @@
my $arrayType = $codeGenerator->GetArrayType($type);
if ($arrayType) {
- if (!$codeGenerator->SkipIncludeHeader($arrayType)) {
+ if ($type eq "DOMString[]") {
+ AddToImplIncludes("JSDOMStringList.h", $conditional);
+ AddToImplIncludes("DOMStringList.h", $conditional);
+ } elsif (!$codeGenerator->SkipIncludeHeader($arrayType)) {
AddToImplIncludes("JS$arrayType.h", $conditional);
AddToImplIncludes("$arrayType.h", $conditional);
}
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (120303 => 120304)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-06-14 09:56:06 UTC (rev 120303)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-06-14 09:59:20 UTC (rev 120304)
@@ -3506,6 +3506,7 @@
# necessary as resolvers could be constructed on fly.
return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver";
+ return "RefPtr<DOMStringList>" if $type eq "DOMString[]";
return "RefPtr<${type}>" if IsRefPtrType($type) and not $isParameter;
return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener";
@@ -3514,7 +3515,6 @@
return "Vector<float>" if $type eq "float[]";
return "Vector<double>" if $type eq "double[]";
return "RefPtr<DOMStringList>" if $type eq "DOMStringList";
- return "RefPtr<DOMStringList>" if $type eq "DOMString[]";
# Default, assume native type is a pointer with same type name as idl type
return "${type}*";
@@ -3746,6 +3746,7 @@
'CompareHow' => 1,
'DOMObject' => 1,
'DOMString' => 1,
+ 'DOMString[]' => 1,
'DOMTimeStamp' => 1,
'Date' => 1,
'Dictionary' => 1,
@@ -3864,7 +3865,10 @@
my $arrayType = $codeGenerator->GetArrayType($type);
if ($arrayType) {
- if (!$codeGenerator->SkipIncludeHeader($arrayType)) {
+ if ($type eq "DOMString[]") {
+ AddToImplIncludes("V8DOMStringList.h");
+ AddToImplIncludes("DOMStrignList.h");
+ } elsif (!$codeGenerator->SkipIncludeHeader($arrayType)) {
AddToImplIncludes("V8$arrayType.h");
AddToImplIncludes("$arrayType.h");
}
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (120303 => 120304)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2012-06-14 09:56:06 UTC (rev 120303)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2012-06-14 09:59:20 UTC (rev 120304)
@@ -21,6 +21,7 @@
#include "config.h"
#include "JSTestObj.h"
+#include "DOMStringList.h"
#include "Dictionary.h"
#include "Document.h"
#include "ExceptionCode.h"
@@ -302,6 +303,7 @@
#endif
{ "overloadedMethod", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadedMethod), (intptr_t)2, NoIntrinsic },
{ "methodWithUnsignedLongArray", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithUnsignedLongArray), (intptr_t)1, NoIntrinsic },
+ { "stringArrayFunction", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionStringArrayFunction), (intptr_t)1, NoIntrinsic },
{ "getSVGDocument", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionGetSVGDocument), (intptr_t)0, NoIntrinsic },
{ "convert1", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionConvert1), (intptr_t)1, NoIntrinsic },
{ "convert2", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionConvert2), (intptr_t)1, NoIntrinsic },
@@ -2250,6 +2252,26 @@
return JSValue::encode(jsUndefined());
}
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionStringArrayFunction(ExecState* exec)
+{
+ JSValue thisValue = exec->hostThisValue();
+ if (!thisValue.inherits(&JSTestObj::s_info))
+ return throwVMTypeError(exec);
+ JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(thisValue));
+ ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestObj::s_info);
+ TestObj* impl = static_cast<TestObj*>(castedThis->impl());
+ if (exec->argumentCount() < 1)
+ return throwVMError(exec, createNotEnoughArgumentsError(exec));
+ ExceptionCode ec = 0;
+ RefPtr<DOMStringList> values(toDOMStringList(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
+
+ JSC::JSValue result = jsArray(exec, castedThis->globalObject(), impl->stringArrayFunction(values, ec));
+ setDOMException(exec, ec);
+ return JSValue::encode(result);
+}
+
EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionGetSVGDocument(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h (120303 => 120304)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h 2012-06-14 09:56:06 UTC (rev 120303)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h 2012-06-14 09:59:20 UTC (rev 120304)
@@ -204,6 +204,7 @@
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionOverloadedMethod1(JSC::ExecState*);
#endif
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithUnsignedLongArray(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionStringArrayFunction(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionGetSVGDocument(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConvert1(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionConvert2(JSC::ExecState*);
Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (120303 => 120304)
--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2012-06-14 09:56:06 UTC (rev 120303)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl 2012-06-14 09:59:20 UTC (rev 120304)
@@ -201,6 +201,9 @@
#if defined(TESTING_JS)
void methodWithUnsignedLongArray(in unsigned long[] unsignedLongArray);
#endif
+#if defined(TESTING_V8) || defined(TESTING_JS)
+ DOMString[] stringArrayFunction(in DOMString[] values) raises(DOMException);
+#endif
readonly attribute [CheckSecurityForNode] Document contentDocument;
[CheckSecurityForNode] SVGDocument getSVGDocument()
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (120303 => 120304)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2012-06-14 09:56:06 UTC (rev 120303)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp 2012-06-14 09:59:20 UTC (rev 120304)
@@ -22,6 +22,7 @@
#include "V8TestObj.h"
#include "ContextFeatures.h"
+#include "DOMStrignList.h"
#include "Dictionary.h"
#include "ExceptionCode.h"
#include "HTMLNames.h"
@@ -38,6 +39,7 @@
#include "V8Binding.h"
#include "V8BindingMacros.h"
#include "V8BindingState.h"
+#include "V8DOMStringList.h"
#include "V8DOMWrapper.h"
#include "V8Document.h"
#include "V8IsolatedContext.h"
@@ -1673,6 +1675,24 @@
return v8::Handle<v8::Value>();
}
+static v8::Handle<v8::Value> stringArrayFunctionCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.TestObj.stringArrayFunction");
+ if (args.Length() < 1)
+ return V8Proxy::throwNotEnoughArgumentsError(args.GetIsolate());
+ TestObj* imp = V8TestObj::toNative(args.Holder());
+ ExceptionCode ec = 0;
+ {
+ EXCEPTION_BLOCK(RefPtr<DOMStringList>, values, v8ValueToWebCoreDOMStringList(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)));
+ RefPtr<DOMStringList> result = imp->stringArrayFunction(values, ec);
+ if (UNLIKELY(ec))
+ goto fail;
+ return v8Array(result.release(), args.GetIsolate());
+ }
+ fail:
+ return V8Proxy::setDOMException(ec, args.GetIsolate());
+}
+
static v8::Handle<v8::Value> getSVGDocumentCallback(const v8::Arguments& args)
{
INC_STATS("DOM.TestObj.getSVGDocument");
@@ -1949,6 +1969,7 @@
{"conditionalMethod3", TestObjV8Internal::conditionalMethod3Callback},
#endif
{"overloadedMethod", TestObjV8Internal::overloadedMethodCallback},
+ {"stringArrayFunction", TestObjV8Internal::stringArrayFunctionCallback},
{"getSVGDocument", TestObjV8Internal::getSVGDocumentCallback},
{"mutablePointFunction", TestObjV8Internal::mutablePointFunctionCallback},
{"immutablePointFunction", TestObjV8Internal::immutablePointFunctionCallback},