v8::Handle<v8::Object> V8SVGFEFuncAElement::wrap(SVGFEFuncAElement* impl) { v8::Handle<v8::Object> wrapper; V8Proxy* proxy = 0; if (impl->document()) { proxy = V8Proxy::retrieve(impl->document()->frame()); if (proxy && static_cast<Node*>(impl->document()) == static_cast<Node*>(impl)) proxy->windowShell()->initContextIfNeeded(); } wrapper = V8DOMWrapper::getWrapper(impl); if (!wrapper.IsEmpty()) return wrapper; v8::Handle<v8::Context> context; if (proxy) context = proxy->context(); // Enter the node's context and create the wrapper in that context. if (!context.IsEmpty()) context->Enter(); wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); // Exit the node's context if it was entered. if (!context.IsEmpty()) context->Exit(); if (wrapper.IsEmpty()) return wrapper; impl->ref(); getDOMNodeMap().set(impl, v8::Persistent<v8::Object>::New(wrapper)); return wrapper; }
static void removeAllDOMObjectsInCurrentThreadHelper() { v8::HandleScope scope; // Deref all objects in the delayed queue. DOMData::getCurrent()->derefDelayedObjects(); // The DOM objects with the following types only exist on the main thread. if (WTF::isMainThread()) { // Remove all DOM nodes. DOMData::removeObjectsFromWrapperMap<Node>(getDOMNodeMap()); #if ENABLE(SVG) // Remove all SVG element instances in the wrapper map. DOMData::removeObjectsFromWrapperMap<SVGElementInstance>(getDOMSVGElementInstanceMap()); // Remove all SVG objects with context in the wrapper map. DOMData::removeObjectsFromWrapperMap<void>(getDOMSVGObjectWithContextMap()); #endif } // Remove all DOM objects in the wrapper map. DOMData::removeObjectsFromWrapperMap<void>(getDOMObjectMap()); // Remove all active DOM objects in the wrapper map. DOMData::removeObjectsFromWrapperMap<void>(getActiveDOMObjectMap()); }
v8::Handle<v8::Object> V8EntityReference::wrap(EntityReference* impl, bool forceNewObject) { v8::Handle<v8::Object> wrapper; V8Proxy* proxy = 0; if (impl->document()) { proxy = V8Proxy::retrieve(impl->document()->frame()); if (proxy && static_cast<Node*>(impl->document()) == static_cast<Node*>(impl)) proxy->windowShell()->initContextIfNeeded(); } if (!forceNewObject) { wrapper = V8DOMWrapper::getWrapper(impl); if (!wrapper.IsEmpty()) return wrapper; } v8::Handle<v8::Context> context; if (proxy) context = proxy->context(); // Enter the node's context and create the wrapper in that context. if (!context.IsEmpty()) context->Enter(); wrapper = V8DOMWrapper::instantiateV8Object(proxy, V8ClassIndex::ENTITYREFERENCE, impl); // Exit the node's context if it was entered. if (!context.IsEmpty()) context->Exit(); if (wrapper.IsEmpty()) return wrapper; impl->ref(); getDOMNodeMap().set(impl, v8::Persistent<v8::Object>::New(wrapper)); return wrapper; }
v8::Persistent<v8::Object> V8DOMWrapper::setJSWrapperForDOMNode(PassRefPtr<Node> node, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate) { v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); ASSERT(maybeDOMWrapper(wrapperHandle)); wrapperHandle.SetWrapperClassId(v8DOMSubtreeClassId); getDOMNodeMap(isolate).set(node.leakRef(), wrapperHandle); return wrapperHandle; }
// The caller must have increased node's ref count. void V8DOMWrapper::setJSWrapperForDOMNode(Node* node, v8::Persistent<v8::Object> wrapper) { ASSERT(V8DOMWrapper::maybeDOMWrapper(wrapper)); if (node->isActiveNode()) getActiveDOMNodeMap().set(node, wrapper); else getDOMNodeMap().set(node, wrapper); }
v8::Handle<v8::Object> V8SVGFontFaceElement::wrapSlow(SVGFontFaceElement* impl) { v8::Handle<v8::Object> wrapper; V8Proxy* proxy = 0; if (impl->document()) { proxy = V8Proxy::retrieve(impl->document()->frame()); if (proxy && static_cast<Node*>(impl->document()) == static_cast<Node*>(impl)) { if (proxy->windowShell()->initContextIfNeeded()) { // initContextIfNeeded may have created a wrapper for the object, retry from the start. return V8SVGFontFaceElement::wrap(impl); } } } v8::Handle<v8::Context> context; if (proxy) context = proxy->context(); // Enter the node's context and create the wrapper in that context. if (!context.IsEmpty()) context->Enter(); wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); // Exit the node's context if it was entered. if (!context.IsEmpty()) context->Exit(); if (wrapper.IsEmpty()) return wrapper; impl->ref(); v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper); if (!hasDependentLifetime) wrapperHandle.MarkIndependent(); wrapperHandle.SetWrapperClassId(v8DOMSubtreeClassId); getDOMNodeMap().set(impl, wrapperHandle); return wrapper; }
// The caller must have increased node's ref count. void V8DOMWrapper::setJSWrapperForDOMNode(Node* node, v8::Persistent<v8::Object> wrapper) { ASSERT(V8DOMWrapper::maybeDOMWrapper(wrapper)); getDOMNodeMap().set(node, wrapper); }
void V8DOMWrapper::setJSWrapperForDOMNode(PassRefPtr<Node> node, v8::Persistent<v8::Object> wrapper, v8::Isolate* isolate) { ASSERT(maybeDOMWrapper(wrapper)); ASSERT(!node->isActiveNode()); getDOMNodeMap(isolate).set(node.leakRef(), wrapper); }