diff options
author | ager@google.com <ager@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-03 10:49:10 +0000 |
---|---|---|
committer | ager@google.com <ager@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-03 10:49:10 +0000 |
commit | c3db21ff3446ac6bbb2d785c2441d0e5d5824bf5 (patch) | |
tree | 6bbd2100a39909cd94aa0a7f0e9fa43c6ca6ab05 /webkit/port/bindings/v8/v8_proxy.cpp | |
parent | 0eef7609fbb2c488aa821d60ac006d65fd359d68 (diff) | |
download | chromium_src-c3db21ff3446ac6bbb2d785c2441d0e5d5824bf5.zip chromium_src-c3db21ff3446ac6bbb2d785c2441d0e5d5824bf5.tar.gz chromium_src-c3db21ff3446ac6bbb2d785c2441d0e5d5824bf5.tar.bz2 |
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
Diffstat (limited to 'webkit/port/bindings/v8/v8_proxy.cpp')
-rw-r--r-- | webkit/port/bindings/v8/v8_proxy.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
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<v8::Value> 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<v8::Context> 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<v8::Object> 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 |