summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/scripts
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-02-15 12:23:52 +0000
committerSteve Block <steveblock@google.com>2010-02-16 11:48:32 +0000
commit8a0914b749bbe7da7768e07a7db5c6d4bb09472b (patch)
tree73f9065f370435d6fde32ae129d458a8c77c8dff /WebCore/bindings/scripts
parentbf14be70295513b8076f3fa47a268a7e42b2c478 (diff)
downloadexternal_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.zip
external_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.tar.gz
external_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.tar.bz2
Merge webkit.org at r54731 : Initial merge by git
Change-Id: Ia79977b6cf3b0b00c06ef39419989b28e57e4f4a
Diffstat (limited to 'WebCore/bindings/scripts')
-rw-r--r--WebCore/bindings/scripts/CodeGenerator.pm23
-rw-r--r--WebCore/bindings/scripts/CodeGeneratorJS.pm16
-rw-r--r--WebCore/bindings/scripts/CodeGeneratorObjC.pm6
-rw-r--r--WebCore/bindings/scripts/CodeGeneratorV8.pm208
4 files changed, 119 insertions, 134 deletions
diff --git a/WebCore/bindings/scripts/CodeGenerator.pm b/WebCore/bindings/scripts/CodeGenerator.pm
index dc3c7c0..506e8ea 100644
--- a/WebCore/bindings/scripts/CodeGenerator.pm
+++ b/WebCore/bindings/scripts/CodeGenerator.pm
@@ -1,26 +1,26 @@
#
# WebKit IDL parser
-#
+#
# Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.org>
# Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
# Copyright (C) 2007 Apple Inc. All rights reserved.
# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
-#
+#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
-#
+#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
-#
+#
# You should have received a copy of the GNU Library General Public License
# aint with this library; see the file COPYING.LIB. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
-#
+#
package CodeGenerator;
@@ -39,10 +39,10 @@ my $codeGenerator = 0;
my $verbose = 0;
-my %primitiveTypeHash = ("int" => 1, "short" => 1, "long" => 1, "long long" => 1,
+my %primitiveTypeHash = ("int" => 1, "short" => 1, "long" => 1, "long long" => 1,
"unsigned int" => 1, "unsigned short" => 1,
- "unsigned long" => 1, "unsigned long long" => 1,
- "float" => 1, "double" => 1,
+ "unsigned long" => 1, "unsigned long long" => 1,
+ "float" => 1, "double" => 1,
"boolean" => 1, "void" => 1,
"Date" => 1);
@@ -328,10 +328,10 @@ sub IsSVGAnimatedType
my $type = shift;
return 1 if $svgAnimatedTypeHash{$type};
- return 0;
+ return 0;
}
-# Uppercase the first letter while respecting WebKit style guidelines.
+# Uppercase the first letter while respecting WebKit style guidelines.
# E.g., xmlEncoding becomes XMLEncoding, but xmlllang becomes Xmllang.
sub WK_ucfirst
{
@@ -341,12 +341,13 @@ sub WK_ucfirst
return $ret;
}
-# Lowercase the first letter while respecting WebKit style guidelines.
+# Lowercase the first letter while respecting WebKit style guidelines.
# URL becomes url, but SetURL becomes setURL.
sub WK_lcfirst
{
my ($object, $param) = @_;
my $ret = lcfirst($param);
+ $ret =~ s/hTML/html/ if $ret =~ /^hTML/;
$ret =~ s/uRL/url/ if $ret =~ /^uRL/;
$ret =~ s/jS/js/ if $ret =~ /^jS/;
$ret =~ s/xML/xml/ if $ret =~ /^xML/;
diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm
index c774a57..94fc2b8 100644
--- a/WebCore/bindings/scripts/CodeGeneratorJS.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm
@@ -1198,7 +1198,7 @@ sub GenerateImplementation
if ($eventTarget) {
$implIncludes{"RegisteredEventListener.h"} = 1;
- push(@implContent, " impl()->invalidateEventListeners();\n");
+ push(@implContent, " impl()->invalidateJSEventListeners(this);\n");
}
if (!$dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"}) {
@@ -1218,7 +1218,7 @@ sub GenerateImplementation
push(@implContent, "void ${className}::markChildren(MarkStack& markStack)\n");
push(@implContent, "{\n");
push(@implContent, " Base::markChildren(markStack);\n");
- push(@implContent, " impl()->markEventListeners(markStack);\n");
+ push(@implContent, " impl()->markJSEventListeners(markStack);\n");
push(@implContent, "}\n\n");
}
@@ -1318,12 +1318,14 @@ sub GenerateImplementation
push(@implContent, " UNUSED_PARAM(exec);\n");
push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(castedThis->impl());\n");
push(@implContent, " if (EventListener* listener = imp->$implGetterFunctionName()) {\n");
+ push(@implContent, " if (const JSEventListener* jsListener = JSEventListener::cast(listener)) {\n");
if ($implClassName eq "Document" || $implClassName eq "WorkerContext" || $implClassName eq "SharedWorkerContext" || $implClassName eq "DedicatedWorkerContext") {
- push(@implContent, " if (JSObject* jsFunction = listener->jsFunction(imp))\n");
+ push(@implContent, " if (JSObject* jsFunction = jsListener->jsFunction(imp))\n");
} else {
- push(@implContent, " if (JSObject* jsFunction = listener->jsFunction(imp->scriptExecutionContext()))\n");
+ push(@implContent, " if (JSObject* jsFunction = jsListener->jsFunction(imp->scriptExecutionContext()))\n");
}
- push(@implContent, " return jsFunction;\n");
+ push(@implContent, " return jsFunction;\n");
+ push(@implContent, " }\n");
push(@implContent, " }\n");
push(@implContent, " return jsNull();\n");
} elsif ($attribute->signature->type =~ /Constructor$/) {
@@ -1477,7 +1479,7 @@ sub GenerateImplementation
$implIncludes{"JSEventListener.h"} = 1;
push(@implContent, " UNUSED_PARAM(exec);\n");
push(@implContent, " $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(thisObject)->impl());\n");
- push(@implContent, " imp->set$implSetterFunctionName(createJSAttributeEventListener(exec, value));\n");
+ push(@implContent, " imp->set$implSetterFunctionName(createJSAttributeEventListener(exec, value, thisObject));\n");
} elsif ($attribute->signature->type =~ /Constructor$/) {
my $constructorType = $attribute->signature->type;
$constructorType =~ s/Constructor$//;
@@ -1834,7 +1836,7 @@ my %nativeType = (
"NodeFilter" => "RefPtr<NodeFilter>",
"SVGAngle" => "SVGAngle",
"SVGLength" => "SVGLength",
- "SVGMatrix" => "TransformationMatrix",
+ "SVGMatrix" => "AffineTransform",
"SVGNumber" => "float",
"SVGPaintType" => "SVGPaint::SVGPaintType",
"SVGPreserveAspectRatio" => "SVGPreserveAspectRatio",
diff --git a/WebCore/bindings/scripts/CodeGeneratorObjC.pm b/WebCore/bindings/scripts/CodeGeneratorObjC.pm
index 698b4f5..dcb22a7 100644
--- a/WebCore/bindings/scripts/CodeGeneratorObjC.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorObjC.pm
@@ -578,7 +578,7 @@ sub AddIncludesForType
}
if ($type eq "SVGMatrix") {
- $implIncludes{"TransformationMatrix.h"} = 1;
+ $implIncludes{"AffineTransform.h"} = 1;
$implIncludes{"DOMSVGMatrixInternal.h"} = 1;
$implIncludes{"SVGException.h"} = 1;
return;
@@ -1426,8 +1426,8 @@ sub GenerateImplementation
}
# FIXME! We need [Custom] support for ObjC, to move these hacks into DOMSVGLength/MatrixCustom.mm
- my $svgMatrixRotateFromVector = ($podType and $podType eq "TransformationMatrix" and $functionName eq "rotateFromVector");
- my $svgMatrixInverse = ($podType and $podType eq "TransformationMatrix" and $functionName eq "inverse");
+ my $svgMatrixRotateFromVector = ($podType and $podType eq "AffineTransform" and $functionName eq "rotateFromVector");
+ my $svgMatrixInverse = ($podType and $podType eq "AffineTransform" and $functionName eq "inverse");
my $svgLengthConvertToSpecifiedUnits = ($podType and $podType eq "SVGLength" and $functionName eq "convertToSpecifiedUnits");
push(@parameterNames, "ec") if $raisesExceptions and !($svgMatrixRotateFromVector || $svgMatrixInverse);
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index cd70c55..2b89b54 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -272,6 +272,7 @@ sub GenerateHeader
public:
static bool HasInstance(v8::Handle<v8::Value> value);
static v8::Persistent<v8::FunctionTemplate> GetRawTemplate();
+ static v8::Persistent<v8::FunctionTemplate> GetTemplate();
static ${nativeType}* toNative(v8::Handle<v8::Object>);
static v8::Handle<v8::Object> wrap(${nativeType}*${forceNewObjectParameter});
END
@@ -302,7 +303,7 @@ END
static v8::Handle<v8::Value> constructorCallback(const v8::Arguments& args);
END
}
-
+
foreach my $attribute (@{$dataNode->attributes}) {
my $name = $attribute->signature->name;
my $attrExt = $attribute->signature->extendedAttributes;
@@ -323,11 +324,10 @@ END
}
}
- GenerateHeaderRuntimeEnablerDeclarations(@enabledAtRuntime);
GenerateHeaderNamedAndIndexedPropertyAccessors($dataNode);
GenerateHeaderCustomCall($dataNode);
GenerateHeaderCustomInternalFieldIndices($dataNode);
-
+
if ($dataNode->extendedAttributes->{"CheckDomainSecurity"}) {
push(@headerContent, <<END);
static bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8::AccessType, v8::Local<v8::Value> data);
@@ -336,11 +336,6 @@ END
}
push(@headerContent, <<END);
-
- private:
- static v8::Persistent<v8::FunctionTemplate> GetTemplate();
-
- friend class V8ClassIndex;
};
v8::Handle<v8::Value> toV8(${nativeType}*${forceNewObjectParameter});
@@ -361,7 +356,7 @@ sub GetInternalFields
{
my $dataNode = shift;
my $name = $dataNode->name;
-
+
# FIXME: I am hideous and hard-coded. Make me beautiful.
return ("cacheIndex", "implementationIndex") if ($name eq "Document") || ($name eq "SVGDocument");
return ("cacheIndex", "implementationIndex", "markerIndex", "shadowIndex") if $name eq "HTMLDocument";
@@ -417,25 +412,6 @@ END
END
}
-sub GenerateHeaderRuntimeEnablerDeclarations
-{
- my @enabledAtRuntime = @_;
-
- foreach my $runtime_attr (@enabledAtRuntime) {
- my $enabledAtRuntimeConditionalString = GenerateConditionalString($runtime_attr->signature);
- my $enabler = $codeGenerator->WK_ucfirst($runtime_attr->signature->name);
- if ($enabledAtRuntimeConditionalString) {
- push(@headerContent, "\n#if ${enabledAtRuntimeConditionalString}\n");
- }
- push(@headerContent, <<END);
- static bool ${enabler}Enabled();
-END
- if ($enabledAtRuntimeConditionalString) {
- push(@headerContent, "#endif\n");
- }
- }
-}
-
my %indexerSpecialCases = (
"Storage" => 1,
"HTMLAppletElement" => 1,
@@ -473,7 +449,7 @@ sub GenerateHeaderNamedAndIndexedPropertyAccessors
static v8::Handle<v8::Value> indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info);
END
}
-
+
if ($isIndexerSpecialCase || $hasCustomIndexedSetter) {
push(@headerContent, <<END);
static v8::Handle<v8::Value> indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
@@ -509,7 +485,7 @@ END
sub GenerateHeaderCustomCall
{
my $dataNode = shift;
-
+
if ($dataNode->extendedAttributes->{"CustomCall"}) {
push(@headerContent, " static v8::Handle<v8::Value> callAsFunctionCallback(const v8::Arguments&);\n");
}
@@ -537,22 +513,34 @@ sub GenerateSetDOMException
return $result;
}
-sub IsNodeSubType
+sub IsSubType
{
my $dataNode = shift;
- return 1 if ($dataNode->name eq "Node");
+ my $parentType = shift;
+ return 1 if ($dataNode->name eq $parentType);
foreach (@allParents) {
my $parent = $codeGenerator->StripModule($_);
- return 1 if $parent eq "Node";
+ return 1 if $parent eq $parentType;
}
return 0;
}
+sub IsNodeSubType
+{
+ my $dataNode = shift;
+ return IsSubType($dataNode, "Node");
+}
+
+sub IsEventSubType
+{
+ my $dataNode = shift;
+ return IsSubType($dataNode, "Event");
+}
+
sub GenerateDomainSafeFunctionGetter
{
my $function = shift;
my $dataNode = shift;
- my $classIndex = shift;
my $implClassName = shift;
my $className = "V8" . $dataNode->name;
@@ -570,7 +558,7 @@ sub GenerateDomainSafeFunctionGetter
INC_STATS(\"DOM.$implClassName.$funcName._get\");
static v8::Persistent<v8::FunctionTemplate> private_template =
v8::Persistent<v8::FunctionTemplate>::New($newTemplateString);
- v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::$classIndex, info.This());
+ v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(${className}::GetTemplate(), info.This());
if (holder.IsEmpty()) {
// can only reach here by 'object.__proto__.func', and it should passed
// domain security check already
@@ -611,7 +599,6 @@ END
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);
return V8DOMWrapper::getConstructor(type, V8WorkerContext::toNative(info.Holder()));
END
@@ -630,7 +617,6 @@ sub GenerateNormalAttrGetter
{
my $attribute = shift;
my $dataNode = shift;
- my $classIndex = shift;
my $implClassName = shift;
my $interfaceName = shift;
@@ -688,14 +674,14 @@ END
}
} elsif ($attrExt->{"v8OnProto"} || $attrExt->{"V8DisallowShadowing"}) {
- if ($classIndex eq "DOMWINDOW") {
+ if ($interfaceName eq "DOMWindow") {
push(@implContentDecls, <<END);
v8::Handle<v8::Object> holder = info.Holder();
END
} else {
# perform lookup first
push(@implContentDecls, <<END);
- v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::$classIndex, info.This());
+ v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8${interfaceName}::GetTemplate(), info.This());
if (holder.IsEmpty()) return v8::Handle<v8::Value>();
END
}
@@ -863,7 +849,6 @@ sub GenerateNormalAttrSetter
{
my $attribute = shift;
my $dataNode = shift;
- my $classIndex = shift;
my $implClassName = shift;
my $interfaceName = shift;
@@ -885,14 +870,14 @@ sub GenerateNormalAttrSetter
push(@implContentDecls, " $implClassName* imp = &imp_instance;\n");
} elsif ($attrExt->{"v8OnProto"}) {
- if ($classIndex eq "DOMWINDOW") {
+ if ($interfaceName eq "DOMWindow") {
push(@implContentDecls, <<END);
v8::Handle<v8::Object> holder = info.Holder();
END
} else {
# perform lookup first
push(@implContentDecls, <<END);
- v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::$classIndex, info.This());
+ v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8${interfaceName}::GetTemplate(), info.This());
if (holder.IsEmpty()) return;
END
}
@@ -999,7 +984,7 @@ sub GetFunctionTemplateCallbackName
{
$function = shift;
$dataNode = shift;
-
+
my $interfaceName = $dataNode->name;
my $name = $function->signature->name;
@@ -1067,7 +1052,7 @@ END
" return v8::Handle<v8::Value>();\n" .
" }\n");
}
-
+
my $raisesExceptions = @{$function->raisesExceptions};
if (!$raisesExceptions) {
foreach my $parameter (@{$function->parameters}) {
@@ -1152,7 +1137,7 @@ END
push(@implContentDecls, " V8Proxy::setDOMException(ec);\n");
push(@implContentDecls, " return v8::Handle<v8::Value>();\n");
}
-
+
push(@implContentDecls, " }\n\n");
}
@@ -1477,6 +1462,7 @@ sub GenerateImplementation
push(@implFixedHeader,
"#include \"config.h\"\n" .
+ "#include \"RuntimeEnabledFeatures.h\"\n" .
"#include \"V8Proxy.h\"\n" .
"#include \"V8Binding.h\"\n" .
"#include \"V8BindingState.h\"\n" .
@@ -1529,7 +1515,7 @@ sub GenerateImplementation
# Generate the accessor.
if (!($attribute->signature->extendedAttributes->{"CustomGetter"} ||
$attribute->signature->extendedAttributes->{"V8CustomGetter"})) {
- GenerateNormalAttrGetter($attribute, $dataNode, $classIndex, $implClassName, $interfaceName);
+ GenerateNormalAttrGetter($attribute, $dataNode, $implClassName, $interfaceName);
}
if (!($attribute->signature->extendedAttributes->{"CustomSetter"} ||
$attribute->signature->extendedAttributes->{"V8CustomSetter"})) {
@@ -1537,7 +1523,7 @@ sub GenerateImplementation
$dataNode->extendedAttributes->{"ExtendsDOMGlobalObject"} || die "Replaceable attribute can only be used in interface that defines ExtendsDOMGlobalObject attribute!";
# GenerateReplaceableAttrSetter($implClassName);
} elsif ($attribute->type !~ /^readonly/ && !$attribute->signature->extendedAttributes->{"V8ReadOnly"}) {
- GenerateNormalAttrSetter($attribute, $dataNode, $classIndex, $implClassName, $interfaceName);
+ GenerateNormalAttrSetter($attribute, $dataNode, $implClassName, $interfaceName);
}
}
}
@@ -1545,7 +1531,7 @@ sub GenerateImplementation
if ($hasConstructors) {
GenerateConstructorGetter($implClassName, $classIndex);
}
-
+
my $indexer;
my $namedPropertyGetter;
# Generate methods for functions.
@@ -1568,7 +1554,7 @@ sub GenerateImplementation
# generate an access getter that returns different function objects
# for different calling context.
if (($dataNode->extendedAttributes->{"CheckDomainSecurity"} || ($interfaceName eq "DOMWindow")) && $function->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) {
- GenerateDomainSafeFunctionGetter($function, $dataNode, $classIndex, $implClassName);
+ GenerateDomainSafeFunctionGetter($function, $dataNode, $implClassName);
}
}
@@ -1606,7 +1592,7 @@ sub GenerateImplementation
GenerateBatchedAttributeData($dataNode, $attributes);
push(@implContent, "};\n");
}
-
+
# Setup table of standard callback functions
$num_callbacks = 0;
$has_callbacks = 0;
@@ -1696,20 +1682,23 @@ END
}
# find the super descriptor
- my $parentClassIndex = "INVALID_CLASS_INDEX";
+ my $parentClassTemplate = "";
foreach (@{$dataNode->parents}) {
my $parent = $codeGenerator->StripModule($_);
if ($parent eq "EventTarget") { next; }
$implIncludes{"V8${parent}.h"} = 1;
- $parentClassIndex = uc($codeGenerator->StripModule($parent));
+ $parentClassTemplate = "V8" . $parent . "::GetTemplate()";
last;
}
-
+ if (!$parentClassTemplate) {
+ $parentClassTemplate = "v8::Persistent<v8::FunctionTemplate>()";
+ }
+
# Generate the template configuration method
push(@implContent, <<END);
static v8::Persistent<v8::FunctionTemplate> Configure${className}Template(v8::Persistent<v8::FunctionTemplate> desc) {
v8::Local<v8::Signature> default_signature = configureTemplate(desc, \"${interfaceName}\",
- V8ClassIndex::$parentClassIndex, V8${interfaceName}::internalFieldCount,
+ $parentClassTemplate, V8${interfaceName}::internalFieldCount,
END
# Set up our attributes if we have them
if ($has_attributes) {
@@ -1721,7 +1710,7 @@ END
NULL, 0,
END
}
-
+
if ($has_callbacks) {
push(@implContent, <<END);
${interfaceName}_callbacks, sizeof(${interfaceName}_callbacks)/sizeof(*${interfaceName}_callbacks));
@@ -1739,20 +1728,21 @@ END
}
if ($access_check or @enabledAtRuntime or @{$dataNode->functions} or $has_constants) {
- push(@implContent, <<END);
+ push(@implContent, <<END);
v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
END
}
push(@implContent, " $access_check\n");
-
+
# Setup the enable-at-runtime attrs if we have them
foreach my $runtime_attr (@enabledAtRuntime) {
- $enable_function = $interfaceName . "::" . $codeGenerator->WK_ucfirst($runtime_attr->signature->name);
+ # A function named RuntimeEnabledFeatures::{methodName}Enabled() need to be written by hand.
+ $enable_function = "RuntimeEnabledFeatures::" . $codeGenerator->WK_lcfirst($runtime_attr->signature->name) . "Enabled";
my $conditionalString = GenerateConditionalString($runtime_attr->signature);
push(@implContent, "\n#if ${conditionalString}\n") if $conditionalString;
- push(@implContent, " if (V8${enable_function}Enabled()) {\n");
+ push(@implContent, " if (${enable_function}()) {\n");
push(@implContent, " static const BatchedAttribute attrData =\\\n");
GenerateSingleBatchedAttribute($interfaceName, $runtime_attr, ";", " ");
push(@implContent, <<END);
@@ -1792,8 +1782,8 @@ END
my $conditional = "";
if ($attrExt->{"EnabledAtRuntime"}) {
# Only call Set()/SetAccessor() if this method should be enabled
- $enable_function = $interfaceName . "::" . $codeGenerator->WK_ucfirst($function->signature->name);
- $conditional = "if (V8${enable_function}Enabled())\n";
+ $enable_function = "RuntimeEnabledFeatures::" . $codeGenerator->WK_lcfirst($function->signature->name) . "Enabled";
+ $conditional = "if (${enable_function}())\n";
}
if ($attrExt->{"DoNotCheckDomainSecurity"} &&
@@ -1840,24 +1830,24 @@ END
# Normal function call is a template
my $callback = GetFunctionTemplateCallbackName($function, $dataNode);
-
+
if ($property_attributes eq "v8::DontDelete") {
$property_attributes = "";
} else {
$property_attributes = ", static_cast<v8::PropertyAttribute>($property_attributes)";
}
-
+
if ($template eq "proto" && $conditional eq "" && $signature eq "default_signature" && $property_attributes eq "") {
# Standard type of callback, already created in the batch, so skip it here.
next;
}
-
+
push(@implContent, <<END);
${conditional}$template->Set(v8::String::New("$name"), v8::FunctionTemplate::New($callback, v8::Handle<v8::Value>(), ${signature})$property_attributes);
END
$num_callbacks++;
}
-
+
die "Wrong number of callbacks generated for $interfaceName ($num_callbacks, should be $total_functions)" if $num_callbacks != $total_functions;
if ($has_constants) {
@@ -1865,11 +1855,11 @@ END
batchConfigureConstants(desc, proto, ${interfaceName}_consts, sizeof(${interfaceName}_consts)/sizeof(*${interfaceName}_consts));
END
}
-
+
# Special cases
if ($interfaceName eq "DOMWindow") {
push(@implContent, <<END);
-
+
proto->SetInternalFieldCount(V8DOMWindow::internalFieldCount);
desc->SetHiddenPrototype(true);
instance->SetInternalFieldCount(V8DOMWindow::internalFieldCount);
@@ -1881,8 +1871,8 @@ END
}
if ($interfaceName eq "Location") {
push(@implContent, <<END);
-
- // For security reasons, these functions are on the instance instead
+
+ // For security reasons, these functions are on the instance instead
// of on the prototype object to insure that they cannot be overwritten.
instance->SetAccessor(v8::String::New("reload"), V8Location::reloadAccessorGetter, 0, v8::Handle<v8::Value>(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly));
instance->SetAccessor(v8::String::New("replace"), V8Location::replaceAccessorGetter, 0, v8::Handle<v8::Value>(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly));
@@ -1895,7 +1885,7 @@ END
$nativeType = "V8SVGPODTypeWrapper<${nativeType}>";
}
push(@implContent, <<END);
-
+
// Custom toString template
desc->Set(getToStringName(), getToStringTemplate());
return desc;
@@ -1912,7 +1902,7 @@ v8::Persistent<v8::FunctionTemplate> ${className}::GetTemplate() {
}
${nativeType}* ${className}::toNative(v8::Handle<v8::Object> object) {
- return reinterpret_cast<${nativeType}*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
+ return reinterpret_cast<${nativeType}*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
}
bool ${className}::HasInstance(v8::Handle<v8::Value> value) {
@@ -1933,7 +1923,7 @@ v8::Persistent<v8::ObjectTemplate> V8DOMWindow::GetShadowObjectTemplate() {
}
END
}
-
+
GenerateToV8Converters($dataNode, $interfaceName, $className, $nativeType);
push(@implContent, <<END);
@@ -1943,24 +1933,24 @@ END
push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
}
-sub GenerateToV8Converters
+sub GenerateToV8Converters
{
my $dataNode = shift;
my $interfaceName = shift;
my $className = shift;
my $nativeType = shift;
-
+
my $wrapperType = "V8ClassIndex::" . uc($interfaceName);
my $domMapFunction = GetDomMapFunction($dataNode, $interfaceName);
my $forceNewObjectInput = IsDOMNodeType($interfaceName) ? ", bool forceNewObject" : "";
my $forceNewObjectCall = IsDOMNodeType($interfaceName) ? ", forceNewObject" : "";
-
- push(@implContent, <<END);
+
+ push(@implContent, <<END);
v8::Handle<v8::Object> ${className}::wrap(${nativeType}* impl${forceNewObjectInput}) {
v8::Handle<v8::Object> wrapper;
END
- if (!NeedsWorkerContextExecutionProxyToV8($interfaceName)) {
+ if (!MayBeInWorkerContext($dataNode, $interfaceName)) {
push(@implContent, <<END);
V8Proxy* proxy = 0;
END
@@ -2003,10 +1993,9 @@ END
END
}
- if (NeedsWorkerContextExecutionProxyToV8($interfaceName)) {
- $implIncludes{"WorkerContextExecutionProxy.h"} = 1;
+ if (MayBeInWorkerContext($dataNode, $interfaceName)) {
push(@implContent, <<END);
- wrapper = WorkerContextExecutionProxy::toV8(${wrapperType}, impl);
+ wrapper = V8DOMWrapper::instantiateV8ObjectInWorkerContext(${wrapperType}, impl);
END
} else {
push(@implContent, <<END);
@@ -2021,7 +2010,7 @@ END
context->Exit();
END
}
-
+
push(@implContent, <<END);
if (wrapper.IsEmpty())
return wrapper;
@@ -2047,7 +2036,7 @@ v8::Handle<v8::Value> toV8(PassRefPtr<${nativeType} > impl${forceNewObjectInput}
}
END
}
-
+
if (!HasCustomToV8Implementation($dataNode, $interfaceName)) {
push(@implContent, <<END);
@@ -2060,16 +2049,32 @@ END
}
}
-sub NeedsWorkerContextExecutionProxyToV8 {
+sub MayBeInWorkerContext {
# These objects can be constructed under WorkerContextExecutionProxy. They need special
# handling, since if we call V8Proxy::retrieve(), we will crash.
# FIXME: websocket?
- $interfaceName = shift;
+ my $dataNode = shift;
+ my $interfaceName = shift;
+ # FIXME: Doing the extra work to handle the WorkerContext case for all Event
+ # types is sad. We can probably be cleverer and only do the extra work for certain types.
+ return 1 if IsEventSubType($dataNode);
return 1 if $interfaceName eq "DOMCoreException";
return 1 if $interfaceName eq "EventException";
return 1 if $interfaceName eq "RangeException";
return 1 if $interfaceName eq "XMLHttpRequestException";
return 1 if $interfaceName eq "MessagePort";
+ return 1 if $interfaceName eq "DedicatedWorkerContext";
+ return 1 if $interfaceName eq "WorkerContext";
+ return 1 if $interfaceName eq "SharedWorkerContext";
+ return 1 if $interfaceName eq "WorkerLocation";
+ return 1 if $interfaceName eq "WorkerNavigator";
+ return 1 if $interfaceName eq "Notification";
+ return 1 if $interfaceName eq "NotificationCenter";
+ return 1 if $interfaceName eq "XMLHttpRequest";
+ return 1 if $interfaceName eq "WebSocket";
+ return 1 if $interfaceName eq "Worker";
+ return 1 if $interfaceName eq "SharedWorker";
+ return 1 if $interfaceName eq "EventSource";
return 0;
}
@@ -2077,7 +2082,7 @@ sub HasCustomToV8Implementation {
# FIXME: This subroutine is lame. Probably should be an .idl attribute (CustomToV8)?
$dataNode = shift;
$interfaceName = shift;
-
+
# We generate a custom converter (but JSC doesn't) for the following:
return 1 if $interfaceName eq "BarInfo";
return 1 if $interfaceName eq "CSSStyleSheet";
@@ -2094,7 +2099,7 @@ sub HasCustomToV8Implementation {
return 1 if $interfaceName eq "SVGDocument";
return 1 if $interfaceName eq "SVGElement";
return 1 if $interfaceName eq "Screen";
-
+ return 1 if $interfaceName eq "WorkerContext";
# We don't generate a custom converter (but JSC does) for the following:
return 0 if $interfaceName eq "AbstractWorker";
return 0 if $interfaceName eq "CanvasRenderingContext";
@@ -2135,7 +2140,7 @@ sub GetNativeTypeForConversions
my $type = shift;
return "FloatRect" if $type eq "SVGRect";
return "FloatPoint" if $type eq "SVGPoint";
- return "TransformationMatrix" if $type eq "SVGMatrix";
+ return "AffineTransform" if $type eq "SVGMatrix";
return "float" if $type eq "SVGNumber";
return $type;
}
@@ -2323,7 +2328,7 @@ sub GetNativeTypeFromSignature
}
$type = GetNativeType($type, $parameterIndex >= 0 ? 1 : 0);
-
+
if ($parameterIndex >= 0 && $type eq "V8Parameter") {
my $mode = "";
if ($signature->extendedAttributes->{"ConvertUndefinedOrNullToNullString"}) {
@@ -2333,7 +2338,7 @@ sub GetNativeTypeFromSignature
}
$type .= "<$mode>";
}
-
+
return $type;
}
@@ -2357,17 +2362,6 @@ sub IsRefPtrType
return 1;
}
-sub IsWorkerClassName
-{
- my $class = shift;
- return 1 if $class eq "V8Worker";
- return 1 if $class eq "V8WorkerContext";
- return 1 if $class eq "V8WorkerLocation";
- return 1 if $class eq "V8WorkerNavigator";
-
- return 0;
-}
-
sub GetNativeType
{
my $type = shift;
@@ -2389,7 +2383,7 @@ sub GetNativeType
return "Range::CompareHow" if $type eq "CompareHow";
return "FloatRect" if $type eq "SVGRect";
return "FloatPoint" if $type eq "SVGPoint";
- return "TransformationMatrix" if $type eq "SVGMatrix";
+ return "AffineTransform" if $type eq "SVGMatrix";
return "SVGTransform" if $type eq "SVGTransform";
return "SVGLength" if $type eq "SVGLength";
return "SVGAngle" if $type eq "SVGAngle";
@@ -2785,18 +2779,6 @@ sub ReturnNativeToJSValue
return "return $value->deserialize()";
}
- if ($type eq "DedicatedWorkerContext" or $type eq "WorkerContext" or $type eq "SharedWorkerContext") {
- $implIncludes{"WorkerContextExecutionProxy.h"} = 1;
- return "return WorkerContextExecutionProxy::convertWorkerContextToV8Object($value)";
- }
-
- if ($type eq "WorkerLocation" or $type eq "WorkerNavigator" or $type eq "NotificationCenter") {
- $implIncludes{"WorkerContextExecutionProxy.h"} = 1;
- my $classIndex = uc($type);
-
- return "return WorkerContextExecutionProxy::convertToV8Object(V8ClassIndex::$classIndex, $value)";
- }
-
$implIncludes{"wtf/RefCounted.h"} = 1;
$implIncludes{"wtf/RefPtr.h"} = 1;
$implIncludes{"wtf/GetPtr.h"} = 1;