[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.18-1-697-g2f78b87
japhet at chromium.org
japhet at chromium.org
Wed Jan 20 22:22:39 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit c16d92b63b85c3ae0c6987efc92a59f9cdcd472a
Author: japhet at chromium.org <japhet at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jan 13 22:10:03 2010 +0000
2010-01-13 Nate Chapin <japhet at chromium.org>
Reviewed by Dimitri Glazkov.
Generate a function in the V8 bindings to convert v8 objects
to native WebCore objects.
* bindings/scripts/CodeGeneratorV8.pm: Generate and use toNative().
* bindings/v8/V8Binding.cpp: Remove manually defined conversion helprs.
(WebCore::getElementStringAttr):
(WebCore::setElementStringAttr):
* bindings/v8/V8Binding.h: Remove manually defined conversion helprs.
* bindings/v8/V8SVGPODTypeWrapper.h: Still need a manually defined coversion helper for SVGPODTypes.
(WebCore::V8SVGPODTypeWrapper::toNative):
* bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
(WebCore::V8WebGLRenderingContext::getProgramParameterCallback):
(WebCore::V8WebGLRenderingContext::getShaderParameterCallback):
(WebCore::V8WebGLRenderingContext::getUniformCallback):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53204 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4c6b404..438e655 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-01-13 Nate Chapin <japhet at chromium.org>
+
+ Reviewed by Dimitri Glazkov.
+
+ Generate a function in the V8 bindings to convert v8 objects
+ to native WebCore objects.
+
+ * bindings/scripts/CodeGeneratorV8.pm: Generate and use toNative().
+ * bindings/v8/V8Binding.cpp: Remove manually defined conversion helprs.
+ (WebCore::getElementStringAttr):
+ (WebCore::setElementStringAttr):
+ * bindings/v8/V8Binding.h: Remove manually defined conversion helprs.
+ * bindings/v8/V8SVGPODTypeWrapper.h: Still need a manually defined coversion helper for SVGPODTypes.
+ (WebCore::V8SVGPODTypeWrapper::toNative):
+ * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
+ (WebCore::V8WebGLRenderingContext::getProgramParameterCallback):
+ (WebCore::V8WebGLRenderingContext::getShaderParameterCallback):
+ (WebCore::V8WebGLRenderingContext::getUniformCallback):
+
2010-01-13 Brian Weinstein <bweinstein at apple.com>
Reviewed by Adam Roben.
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index d325238..ff24086 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -266,13 +266,17 @@ sub GenerateHeader
push(@headerContent, "#include <wtf/HashMap.h>\n");
push(@headerContent, "#include \"StringHash.h\"\n");
push(@headerContent, "#include \"V8Index.h\"\n");
+ push(@headerContent, GetHeaderClassInclude($implClassName));
push(@headerContent, "\nnamespace WebCore {\n");
push(@headerContent, "\nclass $className {\n");
+
+ my $toNativeReturnType = GetReturnTypeForToNative($interfaceName);
push(@headerContent, <<END);
public:
static bool HasInstance(v8::Handle<v8::Value> value);
static v8::Persistent<v8::FunctionTemplate> GetRawTemplate();
+ static ${toNativeReturnType}* toNative(v8::Handle<v8::Object>);
END
if ($implClassName eq "DOMWindow") {
@@ -375,6 +379,17 @@ sub GetInternalFields
return ();
}
+sub GetHeaderClassInclude
+{
+ my $className = shift;
+ if ($className =~ /SVGPathSeg/) {
+ $className =~ s/Abs|Rel//;
+ }
+ return "" if (AvoidInclusionOfType($className));
+ return "#include \"SVGAnimatedTemplate.h\"\n" if ($codeGenerator->IsSVGAnimatedType($className));
+ return "#include \"${className}.h\"\n";
+}
+
sub GenerateHeaderCustomInternalFieldIndices
{
my $dataNode = shift;
@@ -521,26 +536,6 @@ sub IsNodeSubType
return 0;
}
-sub HolderToNative
-{
- my $dataNode = shift;
- my $implClassName = shift;
- my $classIndex = shift;
- my $holder = shift || "holder"; # optional param
-
- if (IsNodeSubType($dataNode)) {
- push(@implContentDecls, <<END);
- $implClassName* imp = v8DOMWrapperToNode<$implClassName>($holder);
-END
-
- } else {
- push(@implContentDecls, <<END);
- $implClassName* imp = v8DOMWrapperTo<$implClassName>(V8ClassIndex::$classIndex, $holder);
-END
-
- }
-}
-
sub GenerateDomainSafeFunctionGetter
{
my $function = shift;
@@ -569,14 +564,9 @@ sub GenerateDomainSafeFunctionGetter
if (holder.IsEmpty()) {
// can only reach here by 'object.__proto__.func', and it should passed
// domain security check already
-
return private_template->GetFunction();
}
-END
-
- HolderToNative($dataNode, $implClassName, $classIndex);
-
- push(@implContentDecls, <<END);
+ ${implClassName}* imp = ${className}::toNative(holder);
if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), false)) {
static v8::Persistent<v8::FunctionTemplate> shared_template =
v8::Persistent<v8::FunctionTemplate>::New($newTemplateString);
@@ -605,17 +595,15 @@ END
if ($classIndex eq "DOMWINDOW") {
push(@implContentDecls, <<END);
- DOMWindow* window = v8DOMWrapperTo<DOMWindow>(V8ClassIndex::DOMWINDOW, info.Holder());
// Get the proxy corresponding to the DOMWindow if possible to
// make sure that the constructor function is constructed in the
// context of the DOMWindow and not in the context of the caller.
- return V8DOMWrapper::getConstructor(type, window);
+ return V8DOMWrapper::getConstructor(type, V8DOMWindow::toNative(info.Holder()));
END
} elsif ($classIndex eq "DEDICATEDWORKERCONTEXT" or $classIndex eq "WORKERCONTEXT" or $classIndex eq "SHAREDWORKERCONTEXT") {
$implIncludes{"WorkerContextExecutionProxy.h"} = 1;
push(@implContentDecls, <<END);
- WorkerContext* workerContext = v8DOMWrapperTo<WorkerContext>(V8ClassIndex::WORKERCONTEXT, info.Holder());
- return V8DOMWrapper::getConstructor(type, workerContext);
+ return V8DOMWrapper::getConstructor(type, V8WorkerContext::toNative(info.Holder()));
END
} else {
push(@implContentDecls, " return v8::Handle<v8::Value>();");
@@ -681,7 +669,7 @@ END
if ($isPodType) {
push(@implContentDecls, <<END);
- V8SVGPODTypeWrapper<$implClassName>* imp_wrapper = v8DOMWrapperTo<V8SVGPODTypeWrapper<$implClassName> >(V8ClassIndex::$classIndex, info.Holder());
+ V8SVGPODTypeWrapper<$implClassName>* imp_wrapper = V8SVGPODTypeWrapper<$implClassName>::toNative(info.Holder());
$implClassName imp_instance = *imp_wrapper;
END
if ($getterStringUsesImp) {
@@ -702,7 +690,9 @@ END
if (holder.IsEmpty()) return v8::Handle<v8::Value>();
END
}
- HolderToNative($dataNode, $implClassName, $classIndex, "info");
+ push(@implContentDecls, <<END);
+ ${implClassName}* imp = V8${implClassName}::toNative(holder);
+END
} else {
my $reflect = $attribute->signature->extendedAttributes->{"Reflect"};
if ($getterStringUsesImp && $reflect && IsNodeSubType($dataNode) && $codeGenerator->IsStringType($attrType)) {
@@ -715,11 +705,9 @@ END
return;
# Skip the rest of the function!
}
-
push(@implContentDecls, <<END);
- v8::Handle<v8::Object> holder = info.Holder();
+ ${implClassName}* imp = V8${implClassName}::toNative(info.Holder());
END
- HolderToNative($dataNode, $implClassName, $classIndex, "info");
}
# Generate security checks if necessary
@@ -884,7 +872,7 @@ sub GenerateNormalAttrSetter
if ($isPodType) {
$implClassName = GetNativeType($implClassName);
$implIncludes{"V8SVGPODTypeWrapper.h"} = 1;
- push(@implContentDecls, " V8SVGPODTypeWrapper<$implClassName>* wrapper = v8DOMWrapperTo<V8SVGPODTypeWrapper<$implClassName> >(V8ClassIndex::$classIndex, info.Holder());\n");
+ push(@implContentDecls, " V8SVGPODTypeWrapper<$implClassName>* wrapper = V8SVGPODTypeWrapper<$implClassName>::toNative(info.Holder());\n");
push(@implContentDecls, " $implClassName imp_instance = *wrapper;\n");
push(@implContentDecls, " $implClassName* imp = &imp_instance;\n");
@@ -900,7 +888,9 @@ END
if (holder.IsEmpty()) return;
END
}
- HolderToNative($dataNode, $implClassName, $classIndex, "info");
+ push(@implContentDecls, <<END);
+ ${implClassName}* imp = V8${implClassName}::toNative(holder);
+END
} else {
my $attrType = GetTypeFromSignature($attribute->signature);
my $reflect = $attribute->signature->extendedAttributes->{"Reflect"};
@@ -917,9 +907,8 @@ END
}
push(@implContentDecls, <<END);
- v8::Handle<v8::Object> holder = info.Holder();
+ ${implClassName}* imp = V8${implClassName}::toNative(info.Holder());
END
- HolderToNative($dataNode, $implClassName, $classIndex, "info");
}
my $nativeType = GetNativeTypeFromSignature($attribute->signature, 0);
@@ -966,7 +955,7 @@ END
} elsif ($attribute->signature->type eq "EventListener") {
$implIncludes{"V8AbstractEventListener.h"} = 1;
$implIncludes{"V8CustomBinding.h"} = 1;
- push(@implContentDecls, " transferHiddenDependency(holder, imp->$attrName(), value, V8${interfaceName}::cacheIndex);\n");
+ push(@implContentDecls, " transferHiddenDependency(info.Holder(), imp->$attrName(), value, V8${interfaceName}::cacheIndex);\n");
push(@implContentDecls, " imp->set$implSetterFunctionName(V8DOMWrapper::getEventListener(imp, value, true, ListenerFindOrCreate)");
} else {
push(@implContentDecls, " imp->set$implSetterFunctionName($result");
@@ -1052,14 +1041,13 @@ sub GenerateFunctionCallback
if (IsPodType($implClassName)) {
my $nativeClassName = GetNativeType($implClassName);
- push(@implContentDecls, " V8SVGPODTypeWrapper<$nativeClassName>* imp_wrapper = v8DOMWrapperTo<V8SVGPODTypeWrapper<$nativeClassName> >(V8ClassIndex::$classIndex, args.Holder());\n");
+ push(@implContentDecls, " V8SVGPODTypeWrapper<$nativeClassName>* imp_wrapper = V8SVGPODTypeWrapper<$nativeClassName>::toNative(args.Holder());\n");
push(@implContentDecls, " $nativeClassName imp_instance = *imp_wrapper;\n");
push(@implContentDecls, " $nativeClassName* imp = &imp_instance;\n");
} else {
push(@implContentDecls, <<END);
- v8::Handle<v8::Object> holder = args.Holder();
+ ${implClassName}* imp = V8${implClassName}::toNative(args.Holder());
END
- HolderToNative($dataNode, $implClassName, $classIndex);
}
# Check domain security if needed
@@ -1492,7 +1480,6 @@ sub GenerateImplementation
$implIncludes{"${className}.h"} = 1;
AddIncludesForType($interfaceName);
- $implIncludes{"V8Proxy.h"} = 1;
push(@implContentDecls, "namespace WebCore {\n");
push(@implContentDecls, "namespace ${interfaceName}Internal {\n\n");
@@ -1851,6 +1838,7 @@ END
END
}
+ $toNativeReturnType = GetReturnTypeForToNative($interfaceName);
push(@implContent, <<END);
return desc;
}
@@ -1865,6 +1853,10 @@ v8::Persistent<v8::FunctionTemplate> ${className}::GetTemplate() {
return ${className}_cache_;
}
+${toNativeReturnType}* ${className}::toNative(v8::Handle<v8::Object> object) {
+ return reinterpret_cast<${toNativeReturnType}*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
+}
+
bool ${className}::HasInstance(v8::Handle<v8::Value> value) {
return GetRawTemplate()->HasInstance(value);
}
@@ -1891,6 +1883,15 @@ END
push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
}
+sub GetReturnTypeForToNative
+{
+ my $type = shift;
+ return "FloatRect" if $type eq "SVGRect";
+ return "FloatPoint" if $type eq "SVGPoint";
+ return "TransformationMatrix" if $type eq "SVGMatrix";
+ return "float" if $type eq "SVGNumber";
+ return $type;
+}
sub GenerateFunctionCallString()
{
@@ -2322,7 +2323,7 @@ sub JSValueToNative
$implIncludes{"V8Node.h"} = 1;
# EventTarget is not in DOM hierarchy, but all Nodes are EventTarget.
- return "V8Node::HasInstance($value) ? v8DOMWrapperToNode<Node>(v8::Handle<v8::Object>::Cast($value)) : 0";
+ return "V8Node::HasInstance($value) ? V8Node::toNative(v8::Handle<v8::Object>::Cast($value)) : 0";
}
if ($type eq "XPathNSResolver") {
@@ -2330,14 +2331,13 @@ sub JSValueToNative
}
AddIncludesForType($type);
- # $implIncludes{"$type.h"} = 1 unless AvoidInclusionOfType($type);
if (IsDOMNodeType($type)) {
$implIncludes{"V8${type}.h"} = 1;
# Perform type checks on the parameter, if it is expected Node type,
# return NULL.
- return "V8${type}::HasInstance($value) ? v8DOMWrapperToNode<${type}>(v8::Handle<v8::Object>::Cast($value)) : 0";
+ return "V8${type}::HasInstance($value) ? V8${type}::toNative(v8::Handle<v8::Object>::Cast($value)) : 0";
} else {
# TODO: Temporary to avoid Window name conflict.
my $classIndex = uc($type);
@@ -2356,7 +2356,7 @@ sub JSValueToNative
# Perform type checks on the parameter, if it is expected Node type,
# return NULL.
- return "V8${type}::HasInstance($value) ? v8DOMWrapperTo<${implClassName}>(V8ClassIndex::${classIndex}, v8::Handle<v8::Object>::Cast($value)) : 0";
+ return "V8${type}::HasInstance($value) ? V8${type}::toNative(v8::Handle<v8::Object>::Cast($value)) : 0";
}
}
@@ -2516,7 +2516,6 @@ sub ReturnNativeToJSValue
# V8 specific.
my $implClassName = $type;
AddIncludesForType($type);
- # $implIncludes{GetImplementationFileName($type)} = 1 unless AvoidInclusionOfType($type);
# special case for non-DOM node interfaces
if (IsDOMNodeType($type)) {
diff --git a/WebCore/bindings/v8/V8Binding.cpp b/WebCore/bindings/v8/V8Binding.cpp
index c82ebb2..566039a 100644
--- a/WebCore/bindings/v8/V8Binding.cpp
+++ b/WebCore/bindings/v8/V8Binding.cpp
@@ -41,6 +41,7 @@
#include "StringBuffer.h"
#include "StringHash.h"
#include "Threading.h"
+#include "V8Element.h"
#include "V8Proxy.h"
#include <v8.h>
@@ -126,16 +127,6 @@ private:
#endif
};
-
-void* v8DOMWrapperToNative(v8::Handle<v8::Object> object) {
- return object->GetPointerFromInternalField(v8DOMWrapperObjectIndex);
-}
-
-void* v8DOMWrapperToNative(const v8::AccessorInfo& info) {
- return info.Holder()->GetPointerFromInternalField(v8DOMWrapperObjectIndex);
-}
-
-
String v8ValueToWebCoreString(v8::Handle<v8::Value> value)
{
if (value->IsString())
@@ -486,7 +477,7 @@ void createCallback(v8::Local<v8::ObjectTemplate> proto,
v8::Handle<v8::Value> getElementStringAttr(const v8::AccessorInfo& info,
const QualifiedName& name)
{
- Element *imp = v8DOMWrapperToNode<Element>(info);
+ Element* imp = V8Element::toNative(info.Holder());
return v8ExternalString(imp->getAttribute(name));
}
@@ -494,7 +485,7 @@ void setElementStringAttr(const v8::AccessorInfo& info,
const QualifiedName& name,
v8::Local<v8::Value> value)
{
- Element* imp = v8DOMWrapperToNode<Element>(info);
+ Element* imp = V8Element::toNative(info.Holder());
AtomicString v = toAtomicWebCoreStringWithNullCheck(value);
imp->setAttribute(name, v);
}
diff --git a/WebCore/bindings/v8/V8Binding.h b/WebCore/bindings/v8/V8Binding.h
index 8ceda65..a6702e8 100644
--- a/WebCore/bindings/v8/V8Binding.h
+++ b/WebCore/bindings/v8/V8Binding.h
@@ -53,72 +53,6 @@ namespace WebCore {
typedef V8BindingDOMWindow DOMWindow;
};
typedef BindingSecurity<V8Binding> V8BindingSecurity;
-
- // A helper function extract native object pointer from a DOM wrapper
- // and cast to the specified type.
- void* v8DOMWrapperToNative(v8::Handle<v8::Object>);
-
- template <class C>
- C* v8DOMWrapperTo(v8::Handle<v8::Object> object)
- {
- ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
- return reinterpret_cast<C*>(v8DOMWrapperToNative(object));
- }
- template <class C>
- C* v8DOMWrapperToNode(v8::Handle<v8::Object> object)
- {
- ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
- ASSERT(V8DOMWrapper::domWrapperType(object) == V8ClassIndex::NODE);
- return reinterpret_cast<C*>(v8DOMWrapperToNative(object));
- }
-
- void* v8DOMWrapperToNative(const v8::AccessorInfo&);
-
- template <class C>
- C* v8DOMWrapperTo(const v8::AccessorInfo& info) {
- ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
- return reinterpret_cast<C*>(v8DOMWrapperToNative(info));
- }
- template <class C>
- C* v8DOMWrapperToNode(const v8::AccessorInfo& info) {
- ASSERT(V8DOMWrapper::domWrapperType(info.Holder()) == V8ClassIndex::NODE);
- return reinterpret_cast<C*>(v8DOMWrapperToNative(info));
- }
-
- template <class C>
- C* v8DOMWrapperTo(V8ClassIndex::V8WrapperType type, v8::Handle<v8::Object> object)
- {
- // Native event listener is per frame, it cannot be handled by this generic function.
- ASSERT(type != V8ClassIndex::EVENTLISTENER);
- ASSERT(type != V8ClassIndex::EVENTTARGET);
-
- ASSERT(V8DOMWrapper::maybeDOMWrapper(object));
-
-#ifndef NDEBUG
- const bool typeIsValid =
-#define MAKE_CASE(TYPE, NAME) (type != V8ClassIndex::TYPE) &&
- DOM_NODE_TYPES(MAKE_CASE)
-#if ENABLE(SVG)
- SVG_NODE_TYPES(MAKE_CASE)
-#endif
-#undef MAKE_CASE
- true;
- ASSERT(typeIsValid);
-#endif
-
- return v8DOMWrapperTo<C>(object);
- }
-
- template <class C>
- C* v8DOMWrapperTo(V8ClassIndex::V8WrapperType type, const v8::AccessorInfo& info)
- {
-#ifndef NDEBUG
- return v8DOMWrapperTo<C>(type, info.Holder());
-#else
- return reinterpret_cast<C*>(v8DOMWrapperToNative(info));
-#endif
- }
-
enum ExternalMode {
Externalize,
diff --git a/WebCore/bindings/v8/V8SVGPODTypeWrapper.h b/WebCore/bindings/v8/V8SVGPODTypeWrapper.h
index b6e47af..8e3b385 100644
--- a/WebCore/bindings/v8/V8SVGPODTypeWrapper.h
+++ b/WebCore/bindings/v8/V8SVGPODTypeWrapper.h
@@ -51,6 +51,11 @@ public:
virtual ~V8SVGPODTypeWrapper() { }
virtual operator PODType() = 0;
virtual void commitChange(PODType, SVGElement*) = 0;
+
+ static V8SVGPODTypeWrapper<PODType>* toNative(v8::Handle<v8::Object> object)
+ {
+ return reinterpret_cast<V8SVGPODTypeWrapper<PODType>*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
+ }
};
template<typename PODType>
diff --git a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
index 3d1c3b6..eacd16c 100644
--- a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
@@ -363,7 +363,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getProgramParameterCallback(const
ExceptionCode ec = 0;
WebGLRenderingContext* context =
V8DOMWrapper::convertDOMWrapperToNative<WebGLRenderingContext>(args.Holder());
- WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? v8DOMWrapperTo<WebGLProgram>(V8ClassIndex::WEBGLPROGRAM, v8::Handle<v8::Object>::Cast(args[0])) : 0;
+ WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
bool ok;
unsigned pname = toInt32(args[1], ok);
if (!ok) {
@@ -396,7 +396,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getShaderParameterCallback(const
ExceptionCode ec = 0;
WebGLRenderingContext* context =
V8DOMWrapper::convertDOMWrapperToNative<WebGLRenderingContext>(args.Holder());
- WebGLShader* shader = V8WebGLShader::HasInstance(args[0]) ? v8DOMWrapperTo<WebGLShader>(V8ClassIndex::WEBGLSHADER, v8::Handle<v8::Object>::Cast(args[0])) : 0;
+ WebGLShader* shader = V8WebGLShader::HasInstance(args[0]) ? V8WebGLShader::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
bool ok;
unsigned pname = toInt32(args[1], ok);
if (!ok) {
@@ -429,7 +429,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getUniformCallback(const v8::Argu
ExceptionCode ec = 0;
WebGLRenderingContext* context =
V8DOMWrapper::convertDOMWrapperToNative<WebGLRenderingContext>(args.Holder());
- WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? v8DOMWrapperTo<WebGLProgram>(V8ClassIndex::WEBGLPROGRAM, v8::Handle<v8::Object>::Cast(args[0])) : 0;
+ WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
bool ok = false;
WebGLUniformLocation* location = toWebGLUniformLocation(args[1], ok);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list