From c3db21ff3446ac6bbb2d785c2441d0e5d5824bf5 Mon Sep 17 00:00:00 2001 From: "ager@google.com" Date: Fri, 3 Oct 2008 10:49:10 +0000 Subject: Let's try this again. The regressions were caused by an incorrect use of the current context instead of last entered context. Create node wrappers in the context to which the nodes belong instead of the context of the code accessing them. This fixes the issue where the prototype library does not work if the JavaScript console is open. Review URL: http://codereview.chromium.org/6442 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2826 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/port/bindings/v8/v8_proxy.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'webkit/port/bindings/v8/v8_proxy.cpp') diff --git a/webkit/port/bindings/v8/v8_proxy.cpp b/webkit/port/bindings/v8/v8_proxy.cpp index a30231a..0857184 100644 --- a/webkit/port/bindings/v8/v8_proxy.cpp +++ b/webkit/port/bindings/v8/v8_proxy.cpp @@ -2390,10 +2390,28 @@ v8::Handle V8Proxy::NodeToV8Object(Node* node) { type = V8ClassIndex::NODE; } + // Find the context to which the node belongs and create the wrapper + // in that context. If the node is not in a document, the current + // context is used. + v8::Local context; + Document* doc = node->document(); + if (doc) { + context = V8Proxy::GetContext(doc->frame()); + } + if (!context.IsEmpty()) { + context->Enter(); + } + // Set the peer object for future access. // InstantiateV8Object automatically casts node to Peerable*. v8::Local result = InstantiateV8Object(type, V8ClassIndex::NODE, node); + + // Exit the node's context if it was entered. + if (!context.IsEmpty()) { + context->Exit(); + } + if (result.IsEmpty()) { // If instantiation failed it's important not to add the result // to the DOM node map. Instead we return an empty handle, which -- cgit v1.1