[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:25:56 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 799e0d2ffb853171beb078410a945d04ec8e53c7
Author: japhet at chromium.org <japhet at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Jan 15 18:38:20 2010 +0000
2010-01-15 Nate Chapin <japhet at chromium.org>
Reviewed by Dimitri Glazkov.
[V8] Generate more of the custom behaviors that the v8 bindings attach to v8 FunctionTemplates.
* bindings/scripts/CodeGeneratorV8.pm:
* bindings/v8/V8Binding.cpp:
(WebCore::getToStringName):
(WebCore::constructorToString):
(WebCore::getToStringTemplate):
* bindings/v8/V8Binding.h:
* bindings/v8/V8DOMWindowShell.cpp:
(WebCore::V8DOMWindowShell::createNewContext):
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::getTemplate):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53335 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8b31e9f..7bfc7e6 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,20 @@
+2010-01-15 Nate Chapin <japhet at chromium.org>
+
+ Reviewed by Dimitri Glazkov.
+
+ [V8] Generate more of the custom behaviors that the v8 bindings attach to v8 FunctionTemplates.
+
+ * bindings/scripts/CodeGeneratorV8.pm:
+ * bindings/v8/V8Binding.cpp:
+ (WebCore::getToStringName):
+ (WebCore::constructorToString):
+ (WebCore::getToStringTemplate):
+ * bindings/v8/V8Binding.h:
+ * bindings/v8/V8DOMWindowShell.cpp:
+ (WebCore::V8DOMWindowShell::createNewContext):
+ * bindings/v8/V8DOMWrapper.cpp:
+ (WebCore::V8DOMWrapper::getTemplate):
+
2010-01-15 Dimitri Glazkov <dglazkov at chromium.org>
No review, rolling out r53331.
diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm
index 0915522..6a90bb4 100644
--- a/WebCore/bindings/scripts/CodeGeneratorV8.pm
+++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm
@@ -553,8 +553,6 @@ sub GenerateDomainSafeFunctionGetter
my $newTemplateString = GenerateNewFunctionTemplate($function, $dataNode, $signature);
- $implIncludes{"V8Proxy.h"} = 1;
-
push(@implContentDecls, <<END);
static v8::Handle<v8::Value> ${funcName}AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) {
INC_STATS(\"DOM.$implClassName.$funcName._get\");
@@ -627,7 +625,6 @@ sub GenerateNormalAttrGetter
my $attrExt = $attribute->signature->extendedAttributes;
my $attrName = $attribute->signature->name;
- $implIncludes{"V8Proxy.h"} = 1;
my $attrType = GetTypeFromSignature($attribute->signature);
my $attrIsPodType = IsPodType($attrType);
@@ -834,8 +831,6 @@ sub GenerateReplaceableAttrSetter
{
my $implClassName = shift;
- $implIncludes{"V8Proxy.h"} = 1;
-
push(@implContentDecls,
" static void ${attrName}AttrSetter(v8::Local<v8::String> name," .
" v8::Local<v8::Value> value, const v8::AccessorInfo& info) {\n");
@@ -859,8 +854,6 @@ sub GenerateNormalAttrSetter
my $attrExt = $attribute->signature->extendedAttributes;
- $implIncludes{"V8Proxy.h"} = 1;
-
push(@implContentDecls,
" static void ${attrName}AttrSetter(v8::Local<v8::String> name," .
" v8::Local<v8::Value> value, const v8::AccessorInfo& info) {\n");
@@ -1667,6 +1660,10 @@ static v8::Persistent<v8::ObjectTemplate> ConfigureShadowObjectTemplate(v8::Pers
v8::Handle<v8::ObjectTemplate>(),
shadow_attrs,
sizeof(shadow_attrs)/sizeof(*shadow_attrs));
+
+ // Install a security handler with V8.
+ templ->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheck, V8DOMWindow::indexedSecurityCheck, v8::Integer::New(V8ClassIndex::DOMWINDOW));
+ templ->SetInternalFieldCount(V8DOMWindow::internalFieldCount);
return templ;
}
END
@@ -1825,7 +1822,7 @@ END
}
push(@implContent, <<END);
- ${conditional}createCallback($template, "$name", $callback, ${signature}$property_attributes);
+ ${conditional}$template->Set(v8::String::New("$name"), v8::FunctionTemplate::New($callback, v8::Handle<v8::Value>(), ${signature})$property_attributes);
END
$num_callbacks++;
}
@@ -1837,9 +1834,36 @@ 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);
+ // Set access check callbacks, but turned off initially.
+ // When a context is detached from a frame, turn on the access check.
+ // Turning on checks also invalidates inline caches of the object.
+ instance->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheck, V8DOMWindow::indexedSecurityCheck, v8::Integer::New(V8ClassIndex::DOMWINDOW), false);
+END
+ }
+ if ($interfaceName eq "Location") {
+ push(@implContent, <<END);
+
+ // 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));
+ instance->SetAccessor(v8::String::New("assign"), V8Location::assignAccessorGetter, 0, v8::Handle<v8::Value>(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly));
+END
+ }
$toNativeReturnType = GetReturnTypeForToNative($interfaceName);
push(@implContent, <<END);
+
+ // Custom toString template
+ desc->Set(getToStringName(), getToStringTemplate());
return desc;
}
@@ -2319,7 +2343,6 @@ sub JSValueToNative
}
# Default, assume autogenerated type conversion routines
- $implIncludes{"V8Proxy.h"} = 1;
if ($type eq "EventTarget") {
$implIncludes{"V8Node.h"} = 1;
diff --git a/WebCore/bindings/v8/V8Binding.cpp b/WebCore/bindings/v8/V8Binding.cpp
index 566039a..4379230 100644
--- a/WebCore/bindings/v8/V8Binding.cpp
+++ b/WebCore/bindings/v8/V8Binding.cpp
@@ -463,15 +463,36 @@ v8::Local<v8::Signature> configureTemplate(v8::Persistent<v8::FunctionTemplate>d
return defaultSignature;
}
-void createCallback(v8::Local<v8::ObjectTemplate> proto,
- const char *name,
- v8::InvocationCallback callback,
- v8::Handle<v8::Signature> signature,
- v8::PropertyAttribute attribute)
-{
- proto->Set(v8::String::New(name),
- v8::FunctionTemplate::New(callback, v8::Handle<v8::Value>(), signature),
- attribute);
+v8::Persistent<v8::String> getToStringName()
+{
+ DEFINE_STATIC_LOCAL(v8::Persistent<v8::String>, value, ());
+ if (value.IsEmpty())
+ value = v8::Persistent<v8::String>::New(v8::String::New("toString"));
+ return value;
+}
+
+static v8::Handle<v8::Value> constructorToString(const v8::Arguments& args)
+{
+ // The DOM constructors' toString functions grab the current toString
+ // for Functions by taking the toString function of itself and then
+ // calling it with the constructor as its receiver. This means that
+ // changes to the Function prototype chain or toString function are
+ // reflected when printing DOM constructors. The only wart is that
+ // changes to a DOM constructor's toString's toString will cause the
+ // toString of the DOM constructor itself to change. This is extremely
+ // obscure and unlikely to be a problem.
+ v8::Handle<v8::Value> value = args.Callee()->Get(getToStringName());
+ if (!value->IsFunction())
+ return v8::String::New("");
+ return v8::Handle<v8::Function>::Cast(value)->Call(args.This(), 0, 0);
+}
+
+v8::Persistent<v8::FunctionTemplate> getToStringTemplate()
+{
+ DEFINE_STATIC_LOCAL(v8::Persistent<v8::FunctionTemplate>, toStringTemplate, ());
+ if (toStringTemplate.IsEmpty())
+ toStringTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(constructorToString));
+ return toStringTemplate;
}
v8::Handle<v8::Value> getElementStringAttr(const v8::AccessorInfo& info,
diff --git a/WebCore/bindings/v8/V8Binding.h b/WebCore/bindings/v8/V8Binding.h
index a6702e8..1778978 100644
--- a/WebCore/bindings/v8/V8Binding.h
+++ b/WebCore/bindings/v8/V8Binding.h
@@ -163,20 +163,15 @@ namespace WebCore {
const BatchedCallback*,
size_t callbackCount);
- void createCallback(v8::Local<v8::ObjectTemplate> proto,
- const char *name,
- v8::InvocationCallback,
- v8::Handle<v8::Signature>,
- v8::PropertyAttribute attributes = v8::DontDelete);
-
v8::Handle<v8::Value> getElementStringAttr(const v8::AccessorInfo&,
const QualifiedName&);
void setElementStringAttr(const v8::AccessorInfo&,
const QualifiedName&,
v8::Local<v8::Value>);
- v8::Handle<v8::Value> getElementEventHandlerAttr(const v8::AccessorInfo&,
- const AtomicString&);
+
+ v8::Persistent<v8::String> getToStringName();
+ v8::Persistent<v8::FunctionTemplate> getToStringTemplate();
// V8Parameter is an adapter class that converts V8 values to Strings
// or AtomicStrings as appropriate, using multiple typecast operators.
diff --git a/WebCore/bindings/v8/V8DOMWindowShell.cpp b/WebCore/bindings/v8/V8DOMWindowShell.cpp
index 9a4df61..2187280 100644
--- a/WebCore/bindings/v8/V8DOMWindowShell.cpp
+++ b/WebCore/bindings/v8/V8DOMWindowShell.cpp
@@ -329,10 +329,6 @@ v8::Persistent<v8::Context> V8DOMWindowShell::createNewContext(v8::Handle<v8::Ob
if (globalTemplate.IsEmpty())
return result;
- // Install a security handler with V8.
- globalTemplate->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheck, V8DOMWindow::indexedSecurityCheck, v8::Integer::New(V8ClassIndex::DOMWINDOW));
- globalTemplate->SetInternalFieldCount(V8DOMWindow::internalFieldCount);
-
// Used to avoid sleep calls in unload handlers.
if (!V8Proxy::registeredExtensionWithV8(DateExtension::get()))
V8Proxy::registerExtension(DateExtension::get(), String());
diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp
index e6ef679..c38ab4b 100644
--- a/WebCore/bindings/v8/V8DOMWrapper.cpp
+++ b/WebCore/bindings/v8/V8DOMWrapper.cpp
@@ -80,31 +80,6 @@ namespace WebCore {
typedef HashMap<Node*, v8::Object*> DOMNodeMap;
typedef HashMap<void*, v8::Object*> DOMObjectMap;
-// Get the string 'toString'.
-static v8::Persistent<v8::String> GetToStringName()
-{
- DEFINE_STATIC_LOCAL(v8::Persistent<v8::String>, value, ());
- if (value.IsEmpty())
- value = v8::Persistent<v8::String>::New(v8::String::New("toString"));
- return value;
-}
-
-static v8::Handle<v8::Value> ConstructorToString(const v8::Arguments& args)
-{
- // The DOM constructors' toString functions grab the current toString
- // for Functions by taking the toString function of itself and then
- // calling it with the constructor as its receiver. This means that
- // changes to the Function prototype chain or toString function are
- // reflected when printing DOM constructors. The only wart is that
- // changes to a DOM constructor's toString's toString will cause the
- // toString of the DOM constructor itself to change. This is extremely
- // obscure and unlikely to be a problem.
- v8::Handle<v8::Value> value = args.Callee()->Get(GetToStringName());
- if (!value->IsFunction())
- return v8::String::New("");
- return v8::Handle<v8::Function>::Cast(value)->Call(args.This(), 0, 0);
-}
-
#if ENABLE(SVG)
static V8ClassIndex::V8WrapperType downcastSVGPathSeg(void* pathSeg)
@@ -282,42 +257,7 @@ v8::Persistent<v8::FunctionTemplate> V8DOMWrapper::getTemplate(V8ClassIndex::V8W
// Not in the cache.
FunctionTemplateFactory factory = V8ClassIndex::GetFactory(type);
v8::Persistent<v8::FunctionTemplate> descriptor = factory();
- // DOM constructors are functions and should print themselves as such.
- // However, we will later replace their prototypes with Object
- // prototypes so we need to explicitly override toString on the
- // instance itself. If we later make DOM constructors full objects
- // we can give them class names instead and Object.prototype.toString
- // will work so we can remove this code.
- DEFINE_STATIC_LOCAL(v8::Persistent<v8::FunctionTemplate>, toStringTemplate, ());
- if (toStringTemplate.IsEmpty())
- toStringTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(ConstructorToString));
- descriptor->Set(GetToStringName(), toStringTemplate);
switch (type) {
- case V8ClassIndex::DOMWINDOW: {
- descriptor->PrototypeTemplate()->SetInternalFieldCount(V8DOMWindow::internalFieldCount);
- descriptor->SetHiddenPrototype(true);
-
- // Reserve spaces for references to location, history and
- // navigator objects.
- v8::Local<v8::ObjectTemplate> instanceTemplate = descriptor->InstanceTemplate();
- instanceTemplate->SetInternalFieldCount(V8DOMWindow::internalFieldCount);
-
- // Set access check callbacks, but turned off initially.
- // When a context is detached from a frame, turn on the access check.
- // Turning on checks also invalidates inline caches of the object.
- instanceTemplate->SetAccessCheckCallbacks(V8DOMWindow::namedSecurityCheck, V8DOMWindow::indexedSecurityCheck, v8::Integer::New(V8ClassIndex::DOMWINDOW), false);
- break;
- }
- case V8ClassIndex::LOCATION: {
- // For security reasons, these functions are on the instance
- // instead of on the prototype object to insure that they cannot
- // be overwritten.
- v8::Local<v8::ObjectTemplate> instance = descriptor->InstanceTemplate();
- 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));
- instance->SetAccessor(v8::String::New("assign"), V8Location::assignAccessorGetter, 0, v8::Handle<v8::Value>(), v8::ALL_CAN_READ, static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly));
- break;
- }
case V8ClassIndex::MESSAGECHANNEL: {
descriptor->SetCallHandler(USE_CALLBACK(MessageChannelConstructor));
break;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list