Commit abcb0ea7 authored by eric@webkit.org's avatar eric@webkit.org
Browse files

2009-10-07 Anton Muhin <antonm@chromium.org>

        Reviewed by Adam Barth.

        Fetch pointers to C++ DOM window immediately from holder
        object (do not search prototype chain for proper JS wrapper).
        https://bugs.webkit.org/show_bug.cgi?id=29031

        * bindings/scripts/CodeGeneratorV8.pm:
        * bindings/v8/V8DOMWrapper.cpp:
        (WebCore::V8DOMWrapper::getTemplate):
        * bindings/v8/V8Proxy.cpp:
        (WebCore::V8Proxy::createNewContext):
        (WebCore::V8Proxy::installDOMWindow):
        * bindings/v8/custom/V8DOMWindowCustom.cpp:
        (WebCore::ACCESSOR_GETTER):
        (WebCore::ACCESSOR_SETTER):
        (WebCore::INDEXED_PROPERTY_GETTER):
        (WebCore::NAMED_PROPERTY_GETTER):
        (WebCore::NAMED_ACCESS_CHECK):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49248 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d7603a15
2009-10-07 Anton Muhin <antonm@chromium.org>
Reviewed by Adam Barth.
Fetch pointers to C++ DOM window immediately from holder
object (do not search prototype chain for proper JS wrapper).
https://bugs.webkit.org/show_bug.cgi?id=29031
* bindings/scripts/CodeGeneratorV8.pm:
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::getTemplate):
* bindings/v8/V8Proxy.cpp:
(WebCore::V8Proxy::createNewContext):
(WebCore::V8Proxy::installDOMWindow):
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::ACCESSOR_GETTER):
(WebCore::ACCESSOR_SETTER):
(WebCore::INDEXED_PROPERTY_GETTER):
(WebCore::NAMED_PROPERTY_GETTER):
(WebCore::NAMED_ACCESS_CHECK):
(WebCore::INDEXED_ACCESS_CHECK):
2009-10-07 Adam Roben <aroben@apple.com>
 
Fix typo in PluginView::load that was causing cross-origin loads to
......@@ -516,11 +516,17 @@ END
}
} elsif ($attrExt->{"v8OnProto"} || $attrExt->{"V8DisallowShadowing"}) {
if ($classIndex 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());
if (holder.IsEmpty()) return v8::Undefined();
END
}
HolderToNative($dataNode, $implClassName, $classIndex);
} else {
push(@implContentDecls, <<END);
......@@ -692,11 +698,17 @@ sub GenerateNormalAttrSetter
push(@implContentDecls, " $implClassName* imp = &imp_instance;\n");
} elsif ($attrExt->{"v8OnProto"}) {
if ($classIndex 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());
if (holder.IsEmpty()) return;
END
}
HolderToNative($dataNode, $implClassName, $classIndex);
} else {
push(@implContentDecls, <<END);
......
......@@ -341,6 +341,7 @@ v8::Persistent<v8::FunctionTemplate> V8DOMWrapper::getTemplate(V8ClassIndex::V8W
descriptor->PrototypeTemplate()->SetNamedPropertyHandler(USE_NAMED_PROPERTY_GETTER(DOMWindow));
descriptor->PrototypeTemplate()->SetIndexedPropertyHandler(USE_INDEXED_PROPERTY_GETTER(DOMWindow));
descriptor->PrototypeTemplate()->SetInternalFieldCount(V8Custom::kDOMWindowInternalFieldCount);
descriptor->SetHiddenPrototype(true);
......
......@@ -912,6 +912,7 @@ v8::Persistent<v8::Context> V8Proxy::createNewContext(v8::Handle<v8::Object> glo
// Install a security handler with V8.
globalTemplate->SetAccessCheckCallbacks(V8Custom::v8DOMWindowNamedSecurityCheck, V8Custom::v8DOMWindowIndexedSecurityCheck, v8::Integer::New(V8ClassIndex::DOMWINDOW));
globalTemplate->SetInternalFieldCount(V8Custom::kDOMWindowInternalFieldCount);
// Used to avoid sleep calls in unload handlers.
if (!registeredExtensionWithV8(DateExtension::get()))
......@@ -953,12 +954,14 @@ bool V8Proxy::installDOMWindow(v8::Handle<v8::Context> context, DOMWindow* windo
// Wrap the window.
V8DOMWrapper::setDOMWrapper(jsWindow, V8ClassIndex::ToInt(V8ClassIndex::DOMWINDOW), window);
V8DOMWrapper::setDOMWrapper(v8::Handle<v8::Object>::Cast(jsWindow->GetPrototype()), V8ClassIndex::ToInt(V8ClassIndex::DOMWINDOW), window);
window->ref();
V8DOMWrapper::setJSWrapperForDOMObject(window, v8::Persistent<v8::Object>::New(jsWindow));
// Insert the window instance as the prototype of the shadow object.
v8::Handle<v8::Object> v8Global = context->Global();
V8DOMWrapper::setDOMWrapper(v8::Handle<v8::Object>::Cast(v8Global->GetPrototype()), V8ClassIndex::ToInt(V8ClassIndex::DOMWINDOW), window);
v8Global->Set(implicitProtoString, jsWindow);
return true;
}
......
......@@ -198,11 +198,7 @@ ACCESSOR_GETTER(DOMWindowCrypto)
ACCESSOR_SETTER(DOMWindowLocation)
{
v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This());
if (holder.IsEmpty())
return;
DOMWindow* imp = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder);
DOMWindow* imp = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, info.Holder());
WindowSetLocation(imp, toWebCoreString(value));
}
......@@ -743,11 +739,8 @@ CALLBACK_FUNC_DECL(DOMWindowOpen)
INDEXED_PROPERTY_GETTER(DOMWindow)
{
INC_STATS("DOM.DOMWindow.IndexedPropertyGetter");
v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This());
if (holder.IsEmpty())
return notHandledByInterceptor();
DOMWindow* window = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder);
DOMWindow* window = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, info.Holder());
if (!window)
return notHandledByInterceptor();
......@@ -767,11 +760,8 @@ NAMED_PROPERTY_GETTER(DOMWindow)
{
INC_STATS("DOM.DOMWindow.NamedPropertyGetter");
v8::Handle<v8::Object> holder = V8DOMWrapper::lookupDOMWrapper(V8ClassIndex::DOMWINDOW, info.This());
if (holder.IsEmpty())
return notHandledByInterceptor();
DOMWindow* window = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, holder);
// TODO(antonm): investigate what convertToNativeObject does for the case of DOMWINDOW.
DOMWindow* window = V8DOMWrapper::convertToNativeObject<DOMWindow>(V8ClassIndex::DOMWINDOW, info.Holder());
if (!window)
return notHandledByInterceptor();
......@@ -787,7 +777,7 @@ NAMED_PROPERTY_GETTER(DOMWindow)
return V8DOMWrapper::convertToV8Object(V8ClassIndex::DOMWINDOW, child->domWindow());
// Search IDL functions defined in the prototype
v8::Handle<v8::Value> result = holder->GetRealNamedPropertyInPrototypeChain(name);
v8::Handle<v8::Value> result = info.Holder()->GetRealNamedProperty(name);
if (!result.IsEmpty())
return result;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment