| OLD | NEW |
| 1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 2509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2520 case Node::DOCUMENT_FRAGMENT_NODE: | 2520 case Node::DOCUMENT_FRAGMENT_NODE: |
| 2521 type = V8ClassIndex::DOCUMENTFRAGMENT; | 2521 type = V8ClassIndex::DOCUMENTFRAGMENT; |
| 2522 break; | 2522 break; |
| 2523 case Node::ENTITY_REFERENCE_NODE: | 2523 case Node::ENTITY_REFERENCE_NODE: |
| 2524 type = V8ClassIndex::ENTITYREFERENCE; | 2524 type = V8ClassIndex::ENTITYREFERENCE; |
| 2525 break; | 2525 break; |
| 2526 default: | 2526 default: |
| 2527 type = V8ClassIndex::NODE; | 2527 type = V8ClassIndex::NODE; |
| 2528 } | 2528 } |
| 2529 | 2529 |
| 2530 // Find the context to which the node belongs and create the wrapper | |
| 2531 // in that context. If the node is not in a document, the current | |
| 2532 // context is used. | |
| 2533 v8::Local<v8::Context> context; | |
| 2534 Document* doc = node->document(); | |
| 2535 if (doc) { | |
| 2536 context = V8Proxy::GetContext(doc->frame()); | |
| 2537 } | |
| 2538 if (!context.IsEmpty()) { | |
| 2539 context->Enter(); | |
| 2540 } | |
| 2541 | |
| 2542 // Set the peer object for future access. | 2530 // Set the peer object for future access. |
| 2543 // InstantiateV8Object automatically casts node to Peerable*. | 2531 // InstantiateV8Object automatically casts node to Peerable*. |
| 2544 v8::Local<v8::Object> result = | 2532 v8::Local<v8::Object> result = |
| 2545 InstantiateV8Object(type, V8ClassIndex::NODE, node); | 2533 InstantiateV8Object(type, V8ClassIndex::NODE, node); |
| 2546 | |
| 2547 // Exit the node's context if it was entered. | |
| 2548 if (!context.IsEmpty()) { | |
| 2549 context->Exit(); | |
| 2550 } | |
| 2551 | |
| 2552 if (result.IsEmpty()) { | 2534 if (result.IsEmpty()) { |
| 2553 // If instantiation failed it's important not to add the result | 2535 // If instantiation failed it's important not to add the result |
| 2554 // to the DOM node map. Instead we return an empty handle, which | 2536 // to the DOM node map. Instead we return an empty handle, which |
| 2555 // should already be handled by callers of this function in case | 2537 // should already be handled by callers of this function in case |
| 2556 // the node is NULL. | 2538 // the node is NULL. |
| 2557 return result; | 2539 return result; |
| 2558 } | 2540 } |
| 2559 | 2541 |
| 2560 dom_node_map().set(node, v8::Persistent<v8::Object>::New(result)); | 2542 dom_node_map().set(node, v8::Persistent<v8::Object>::New(result)); |
| 2561 | 2543 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2791 global->Set(v8::String::New(name), instance); | 2773 global->Set(v8::String::New(name), instance); |
| 2792 } | 2774 } |
| 2793 | 2775 |
| 2794 | 2776 |
| 2795 void V8Proxy::ProcessConsoleMessages() { | 2777 void V8Proxy::ProcessConsoleMessages() { |
| 2796 ConsoleMessageManager::ProcessDelayedMessages(); | 2778 ConsoleMessageManager::ProcessDelayedMessages(); |
| 2797 } | 2779 } |
| 2798 | 2780 |
| 2799 | 2781 |
| 2800 } // namespace WebCore | 2782 } // namespace WebCore |
| OLD | NEW |