void JSNodeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) { JSNode* jsNode = jsCast<JSNode*>(handle.get().asCell()); DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context); uncacheWrapper(world, jsNode->impl(), jsNode); jsNode->releaseImpl(); }
void markDOMNodesForDocument(Document* doc) { // If a node's JS wrapper holds custom properties, those properties must // persist every time the node is fetched from the DOM. So, we keep JS // wrappers like that from being garbage collected. JSWrapperCache& nodeDict = doc->wrapperCache(); JSWrapperCache::iterator nodeEnd = nodeDict.end(); for (JSWrapperCache::iterator nodeIt = nodeDict.begin(); nodeIt != nodeEnd; ++nodeIt) { JSNode* jsNode = nodeIt->second; Node* node = jsNode->impl(); if (jsNode->marked()) continue; // No need to preserve a wrapper that has no custom properties or is no // longer fetchable through the DOM. if (!jsNode->hasCustomProperties() || !node->inDocument()) { //... unless the wrapper wraps a loading image, since the "new Image" // syntax allows an orphan image wrapper to be the last reference // to a loading image, whose load event might have important side-effects. if (!node->hasTagName(imgTag) || static_cast<HTMLImageElement*>(node)->haveFiredLoadEvent()) continue; } jsNode->mark(); } }
JSValue* jsNodePrototypeFunctionNormalize(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast<JSNode*>(thisValue); Node* imp = static_cast<Node*>(castedThisObj->impl()); imp->normalize(); return jsUndefined(); }
JSValue* jsNodePrototypeFunctionHasAttributes(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast<JSNode*>(thisValue); Node* imp = static_cast<Node*>(castedThisObj->impl()); KJS::JSValue* result = jsBoolean(imp->hasAttributes()); return result; }
JSValue JSXSLTProcessor::importStylesheet(ExecState* exec) { JSValue nodeVal = exec->argument(0); if (nodeVal.inherits(&JSNode::s_info)) { JSNode* node = static_cast<JSNode*>(asObject(nodeVal)); impl()->importStylesheet(node->impl()); return jsUndefined(); } // Throw exception? return jsUndefined(); }
JSValue* jsNodePrototypeFunctionLookupNamespaceURI(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast<JSNode*>(thisValue); Node* imp = static_cast<Node*>(castedThisObj->impl()); const UString& prefix = valueToStringWithNullCheck(exec, args[0]); KJS::JSValue* result = jsStringOrNull(exec, imp->lookupNamespaceURI(prefix)); return result; }
JSValue* jsNodePrototypeFunctionIsDefaultNamespace(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast<JSNode*>(thisValue); Node* imp = static_cast<Node*>(castedThisObj->impl()); const UString& namespaceURI = valueToStringWithNullCheck(exec, args[0]); KJS::JSValue* result = jsBoolean(imp->isDefaultNamespace(namespaceURI)); return result; }
JSValue* jsNodePrototypeFunctionCloneNode(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast<JSNode*>(thisValue); Node* imp = static_cast<Node*>(castedThisObj->impl()); bool deep = args[0]->toBoolean(exec); KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->cloneNode(deep))); return result; }
JSValue* jsNodePrototypeFunctionIsSupported(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast<JSNode*>(thisValue); Node* imp = static_cast<Node*>(castedThisObj->impl()); const UString& feature = args[0]->toString(exec); const UString& version = valueToStringWithNullCheck(exec, args[1]); KJS::JSValue* result = jsBoolean(imp->isSupported(feature, version)); return result; }
void JSNode::visitChildren(JSCell* cell, SlotVisitor& visitor) { JSNode* thisObject = jsCast<JSNode*>(cell); ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag); ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren()); Base::visitChildren(thisObject, visitor); Node* node = thisObject->impl(); node->visitJSEventListeners(visitor); visitor.addOpaqueRoot(root(node)); }
JSValue JSXSLTProcessor::transformToDocument(ExecState* exec) { JSValue nodeVal = exec->argument(0); if (nodeVal.inherits(&JSNode::s_info)) { JSNode* node = static_cast<JSNode*>(asObject(nodeVal)); RefPtr<Document> resultDocument = impl()->transformToDocument(node->impl()); if (resultDocument) return toJS(exec, globalObject(), resultDocument.get()); return jsUndefined(); } // Throw exception? return jsUndefined(); }
bool JSNodeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) { JSNode* jsNode = jsCast<JSNode*>(handle.get().asCell()); return isReachableFromDOM(jsNode, jsNode->impl(), visitor); }