📄 kjs_dom.cpp
字号:
else DOMNode::tryPut(exec, propertyName,value,attr);}// -------------------------------------------------------------------------const ClassInfo DOMNotation::info = { "Notation", &DOMNode::info, &DOMNotationTable, 0 };/* Source for DOMNotationTable. Use "make hashtables" to regenerate.@begin DOMNotationTable 2 publicId DOMNotation::PublicId DontDelete|ReadOnly systemId DOMNotation::SystemId DontDelete|ReadOnly@end*/Value DOMNotation::tryGet(ExecState *exec, const Identifier &propertyName) const{ return DOMObjectLookupGetValue<DOMNotation, DOMNode>(exec, propertyName, &DOMNotationTable, this);}Value DOMNotation::getValueProperty(ExecState *, int token) const{ switch (token) { case PublicId: return getStringOrNull(static_cast<DOM::Notation>(node).publicId()); case SystemId: return getStringOrNull(static_cast<DOM::Notation>(node).systemId()); default: kdWarning() << "DOMNotation::getValueProperty unhandled token " << token << endl; return Value(); }}// -------------------------------------------------------------------------const ClassInfo DOMEntity::info = { "Entity", &DOMNode::info, 0, 0 };/* Source for DOMEntityTable. Use "make hashtables" to regenerate.@begin DOMEntityTable 2 publicId DOMEntity::PublicId DontDelete|ReadOnly systemId DOMEntity::SystemId DontDelete|ReadOnly notationName DOMEntity::NotationName DontDelete|ReadOnly@end*/Value DOMEntity::tryGet(ExecState *exec, const Identifier &propertyName) const{ return DOMObjectLookupGetValue<DOMEntity, DOMNode>(exec, propertyName, &DOMEntityTable, this);}Value DOMEntity::getValueProperty(ExecState *, int token) const{ switch (token) { case PublicId: return getStringOrNull(static_cast<DOM::Entity>(node).publicId()); case SystemId: return getStringOrNull(static_cast<DOM::Entity>(node).systemId()); case NotationName: return getStringOrNull(static_cast<DOM::Entity>(node).notationName()); default: kdWarning() << "DOMEntity::getValueProperty unhandled token " << token << endl; return Value(); }}// -------------------------------------------------------------------------Value KJS::getDOMDocumentNode(ExecState *exec, const DOM::Document &n){ DOMDocument *ret = 0; ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter()); if ((ret = static_cast<DOMDocument *>(interp->getDOMObject(n.handle())))) return Value(ret); if (n.isHTMLDocument()) ret = new HTMLDocument(exec, static_cast<DOM::HTMLDocument>(n)); else ret = new DOMDocument(exec, n); Value val(ret); // Make sure the document is kept around by the window object, and works right with the // back/forward cache. if (n.view()) { static Identifier documentIdentifier("document"); Window::retrieveWindow(n.view()->part())->putDirect(documentIdentifier, ret, DontDelete|ReadOnly); } interp->putDOMObject(n.handle(), ret); return val;}bool KJS::checkNodeSecurity(ExecState *exec, const DOM::Node& n){ if (!n.handle()) return false; // Check to see if the currently executing interpreter is allowed to access the specified node KHTMLPart *part = n.handle()->getDocument()->part(); Window* win = part ? Window::retrieveWindow(part) : 0L; if ( !win || !win->isSafeScript(exec) ) return false; return true;}Value KJS::getDOMNode(ExecState *exec, const DOM::Node &n){ DOMObject *ret = 0; if (n.isNull()) return Null(); ScriptInterpreter* interp = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter()); DOM::NodeImpl *doc = n.ownerDocument().handle(); if ((ret = interp->getDOMObjectForDocument(static_cast<DOM::DocumentImpl *>(doc), n.handle()))) return Value(ret); switch (n.nodeType()) { case DOM::Node::ELEMENT_NODE: if (static_cast<DOM::Element>(n).isHTMLElement()) ret = new HTMLElement(exec, static_cast<DOM::HTMLElement>(n)); else ret = new DOMElement(exec, static_cast<DOM::Element>(n)); break; case DOM::Node::ATTRIBUTE_NODE: ret = new DOMAttr(exec, static_cast<DOM::Attr>(n)); break; case DOM::Node::TEXT_NODE: case DOM::Node::CDATA_SECTION_NODE: ret = new DOMText(exec, static_cast<DOM::Text>(n)); break; case DOM::Node::ENTITY_REFERENCE_NODE: ret = new DOMNode(exec, n); break; case DOM::Node::ENTITY_NODE: ret = new DOMEntity(exec, static_cast<DOM::Entity>(n)); break; case DOM::Node::PROCESSING_INSTRUCTION_NODE: ret = new DOMProcessingInstruction(exec, static_cast<DOM::ProcessingInstruction>(n)); break; case DOM::Node::COMMENT_NODE: ret = new DOMCharacterData(exec, static_cast<DOM::CharacterData>(n)); break; case DOM::Node::DOCUMENT_NODE: // we don't want to cache the document itself in the per-document dictionary return getDOMDocumentNode(exec, static_cast<DOM::Document>(n)); case DOM::Node::DOCUMENT_TYPE_NODE: ret = new DOMDocumentType(exec, static_cast<DOM::DocumentType>(n)); break; case DOM::Node::DOCUMENT_FRAGMENT_NODE: ret = new DOMNode(exec, n); break; case DOM::Node::NOTATION_NODE: ret = new DOMNotation(exec, static_cast<DOM::Notation>(n)); break; default: ret = new DOMNode(exec, n); } interp->putDOMObjectForDocument(static_cast<DOM::DocumentImpl *>(doc), n.handle(), ret); return Value(ret);}Value KJS::getDOMNamedNodeMap(ExecState *exec, const DOM::NamedNodeMap &m){ return Value(cacheDOMObject<DOM::NamedNodeMap, KJS::DOMNamedNodeMap>(exec, m));}Value KJS::getRuntimeObject(ExecState *exec, const DOM::Node &node){#if !KWIQ_NO_JAVA DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node); if (!node.isNull()) { if (node.handle()->id() == ID_APPLET) { DOM::HTMLAppletElementImpl *appletElement = static_cast<DOM::HTMLAppletElementImpl *>(element.handle()); if (appletElement->getAppletInstance()) { // The instance is owned by the applet element. RuntimeObjectImp *appletImp = new RuntimeObjectImp(appletElement->getAppletInstance(), false); return Value(appletImp); } } else if (node.handle()->id() == ID_EMBED) { DOM::HTMLEmbedElementImpl *embedElement = static_cast<DOM::HTMLEmbedElementImpl *>(element.handle()); if (embedElement->getEmbedInstance()) { RuntimeObjectImp *runtimeImp = new RuntimeObjectImp(embedElement->getEmbedInstance(), false); return Value(runtimeImp); } } }#endif return Undefined();}Value KJS::getDOMNodeList(ExecState *exec, const DOM::NodeList &l){ return Value(cacheDOMObject<DOM::NodeList, KJS::DOMNodeList>(exec, l));}Value KJS::getDOMDOMImplementation(ExecState *exec, const DOM::DOMImplementation &i){ return Value(cacheDOMObject<DOM::DOMImplementation, KJS::DOMDOMImplementation>(exec, i));}// -------------------------------------------------------------------------const ClassInfo NodeConstructor::info = { "NodeConstructor", 0, &NodeConstructorTable, 0 };/* Source for NodeConstructorTable. Use "make hashtables" to regenerate.@begin NodeConstructorTable 11 ELEMENT_NODE DOM::Node::ELEMENT_NODE DontDelete|ReadOnly ATTRIBUTE_NODE DOM::Node::ATTRIBUTE_NODE DontDelete|ReadOnly TEXT_NODE DOM::Node::TEXT_NODE DontDelete|ReadOnly CDATA_SECTION_NODE DOM::Node::CDATA_SECTION_NODE DontDelete|ReadOnly ENTITY_REFERENCE_NODE DOM::Node::ENTITY_REFERENCE_NODE DontDelete|ReadOnly ENTITY_NODE DOM::Node::ENTITY_NODE DontDelete|ReadOnly PROCESSING_INSTRUCTION_NODE DOM::Node::PROCESSING_INSTRUCTION_NODE DontDelete|ReadOnly COMMENT_NODE DOM::Node::COMMENT_NODE DontDelete|ReadOnly DOCUMENT_NODE DOM::Node::DOCUMENT_NODE DontDelete|ReadOnly DOCUMENT_TYPE_NODE DOM::Node::DOCUMENT_TYPE_NODE DontDelete|ReadOnly DOCUMENT_FRAGMENT_NODE DOM::Node::DOCUMENT_FRAGMENT_NODE DontDelete|ReadOnly NOTATION_NODE DOM::Node::NOTATION_NODE DontDelete|ReadOnly@end*/Value NodeConstructor::tryGet(ExecState *exec, const Identifier &propertyName) const{ return DOMObjectLookupGetValue<NodeConstructor, DOMObject>(exec, propertyName, &NodeConstructorTable, this);}Value NodeConstructor::getValueProperty(ExecState *, int token) const{ // We use the token as the value to return directly return Number((unsigned int)token);#if 0 switch (token) { case ELEMENT_NODE: return Number((unsigned int)DOM::Node::ELEMENT_NODE); case ATTRIBUTE_NODE: return Number((unsigned int)DOM::Node::ATTRIBUTE_NODE); case TEXT_NODE: return Number((unsigned int)DOM::Node::TEXT_NODE); case CDATA_SECTION_NODE: return Number((unsigned int)DOM::Node::CDATA_SECTION_NODE); case ENTITY_REFERENCE_NODE: return Number((unsigned int)DOM::Node::ENTITY_REFERENCE_NODE); case ENTITY_NODE: return Number((unsigned int)DOM::Node::ENTITY_NODE); case PROCESSING_INSTRUCTION_NODE: return Number((unsigned int)DOM::Node::PROCESSING_INSTRUCTION_NODE); case COMMENT_NODE: return Number((unsigned int)DOM::Node::COMMENT_NODE); case DOCUMENT_NODE: return Number((unsigned int)DOM::Node::DOCUMENT_NODE); case DOCUMENT_TYPE_NODE: return Number((unsigned int)DOM::Node::DOCUMENT_TYPE_NODE); case DOCUMENT_FRAGMENT_NODE: return Number((unsigned int)DOM::Node::DOCUMENT_FRAGMENT_NODE); case NOTATION_NODE: return Number((unsigned int)DOM::Node::NOTATION_NODE); default: kdWarning() << "NodeConstructor::getValueProperty unhandled token " << token << endl; return Value(); }#endif}Object KJS::getNodeConstructor(ExecState *exec){ return Object(cacheGlobalObject<NodeConstructor>(exec, "[[node.constructor]]"));}// -------------------------------------------------------------------------const ClassInfo DOMExceptionConstructor::info = { "DOMExceptionConstructor", 0, 0, 0 };/* Source for DOMExceptionConstructorTable. Use "make hashtables" to regenerate.@begin DOMExceptionConstructorTable 15 INDEX_SIZE_ERR DOM::DOMException::INDEX_SIZE_ERR DontDelete|ReadOnly DOMSTRING_SIZE_ERR DOM::DOMException::DOMSTRING_SIZE_ERR DontDelete|ReadOnly HIERARCHY_REQUEST_ERR DOM::DOMException::HIERARCHY_REQUEST_ERR DontDelete|ReadOnly WRONG_DOCUMENT_ERR DOM::DOMException::WRONG_DOCUMENT_ERR DontDelete|ReadOnly INVALID_CHARACTER_ERR DOM::DOMException::INVALID_CHARACTER_ERR DontDelete|ReadOnly NO_DATA_ALLOWED_ERR DOM::DOMException::NO_DATA_ALLOWED_ERR DontDelete|ReadOnly NO_MODIFICATION_ALLOWED_ERR DOM::DOMException::NO_MODIFICATION_ALLOWED_ERR DontDelete|ReadOnly NOT_FOUND_ERR DOM::DOMException::NOT_FOUND_ERR DontDelete|ReadOnly NOT_SUPPORTED_ERR DOM::DOMException::NOT_SUPPORTED_ERR DontDelete|ReadOnly INUSE_ATTRIBUTE_ERR DOM::DOMException::INUSE_ATTRIBUTE_ERR DontDelete|ReadOnly INVALID_STATE_ERR DOM::DOMException::INVALID_STATE_ERR DontDelete|ReadOnly SYNTAX_ERR DOM::DOMException::SYNTAX_ERR DontDelete|ReadOnly INVALID_MODIFICATION_ERR DOM::DOMException::INVALID_MODIFICATION_ERR DontDelete|ReadOnly NAMESPACE_ERR DOM::DOMException::NAMESPACE_ERR DontDelete|ReadOnly INVALID_ACCESS_ERR DOM::DOMException::INVALID_ACCESS_ERR DontDelete|ReadOnly@end*/Value DOMExceptionConstructor::tryGet(ExecState *exec, const Identifier &propertyName) const{ return DOMObjectLookupGetValue<DOMExceptionConstructor, DOMObject>(exec, propertyName, &DOMExceptionConstructorTable, this);}Value DOMExceptionConstructor::getValueProperty(ExecState *, int token) const{ // We use the token as the value to return directly return Number((unsigned int)token);#if 0 switch (token) { case INDEX_SIZE_ERR: return Number((unsigned int)DOM::DOMException::INDEX_SIZE_ERR); case DOMSTRING_SIZE_ERR: return Number((unsigned int)DOM::DOMException::DOMSTRING_SIZE_ERR); case HIERARCHY_REQUEST_ERR: return Number((unsigned int)DOM::DOMException::HIERARCHY_REQUEST_ERR); case WRONG_DOCUMENT_ERR: return Number((unsigned int)DOM::DOMException::WRONG_DOCUMENT_ERR); case INVALID_CHARACTER_ERR: return Number((unsigned int)DOM::DOMException::INVALID_CHARACTER_ERR); case NO_DATA_ALLOWED_ERR: return Number((unsigned int)DOM::DOMException::NO_DATA_ALLOWED_ERR); case NO_MODIFICATION_ALLOWED_ERR: return Number((unsigned int)DOM::DOMException::NO_MODIFICATION_ALLOWED_ERR); case NOT_FOUND_ERR: return Number((unsigned int)DOM::DOMException::NOT_FOUND_ERR); case NOT_SUPPORTED_ERR: return Number((unsigned int)DOM::DOMException::NOT_SUPPORTED_ERR); case INUSE_ATTRIBUTE_ERR: return Number((unsigned int)DOM::DOMException::INUSE_ATTRIBUTE_ERR); case INVALID_STATE_ERR: return Number((unsigned int)DOM::DOMException::INVALID_STATE_ERR); case SYNTAX_ERR: return Number((unsigned int)DOM::DOMException::SYNTAX_ERR); case INVALID_MODIFICATION_ERR: return Number((unsigned int)DOM::DOMException::INVALID_MODIFICATION_ERR); case NAMESPACE_ERR: return Number((unsigned int)DOM::DOMException::NAMESPACE_ERR); case INVALID_ACCESS_ERR: return Number((unsigned int)DOM::DOMException::INVALID_ACCESS_ERR); default: kdWarning() << "DOMExceptionConstructor::
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -