⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kjs_dom.cpp

📁 konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版本源码包.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* Source for DOMNotationTable.@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 String(static_cast<DOM::Notation>(node).publicId());  case SystemId:    return String(static_cast<DOM::Notation>(node).systemId());  default:    kdDebug(6070) << "WARNING: DOMNotation::getValueProperty unhandled token " << token << endl;    return Value();  }}// -------------------------------------------------------------------------const ClassInfo DOMEntity::info = { "Entity", &DOMNode::info, 0, 0 };/* Source for DOMEntityTable.@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 String(static_cast<DOM::Entity>(node).publicId());  case SystemId:    return String(static_cast<DOM::Entity>(node).systemId());  case NotationName:    return String(static_cast<DOM::Entity>(node).notationName());  default:    kdDebug(6070) << "WARNING: DOMEntity::getValueProperty unhandled token " << token << endl;    return Value();  }}// -------------------------------------------------------------------------bool KJS::checkNodeSecurity(ExecState *exec, const DOM::Node& n){  // Check to see if the currently executing interpreter is allowed to access the specified node  if (n.isNull())    return true;  KHTMLView *view = n.handle()->getDocument()->view();  Window* win = view && view->part() ? Window::retrieveWindow(view->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->interpreter());  if ((ret = interp->getDOMObject(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:      if (static_cast<DOM::Document>(n).isHTMLDocument())        ret = new HTMLDocument(exec, static_cast<DOM::HTMLDocument>(n));      else        ret = new DOMDocument(exec, static_cast<DOM::Document>(n));      break;    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->putDOMObject(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::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.@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*/NodeConstructor::NodeConstructor(ExecState *exec)  : DOMObject(exec->interpreter()->builtinObjectPrototype()){}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:    kdDebug(6070) << "WARNING: 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.@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*/DOMExceptionConstructor::DOMExceptionConstructor(ExecState* exec)  : DOMObject(exec->interpreter()->builtinObjectPrototype()){}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:    kdDebug(6070) << "WARNING: DOMExceptionConstructor::getValueProperty unhandled token " << token << endl;    return Value();  }#endif}Object KJS::getDOMExceptionConstructor(ExecState *exec){  return cacheGlobalObject<DOMExceptionConstructor>(exec, "[[DOMException.constructor]]");}// -------------------------------------------------------------------------/* Source for DOMNamedNodesCollection.@begin DOMNamedNodesCollectionTable 1  length		KJS::DOMNamedNodesCollection::Length		DontDelete|ReadOnly@end*/const ClassInfo KJS::DOMNamedNodesCollection::info = { "DOMNamedNodesCollection", 0, &DOMNamedNodesCollectionTable, 0 };// Such a collection is usually very short-lived, it only exists// for constructs like document.forms.<name>[1],// so it shouldn't be a problem that it's storing all the nodes (with the same name). (David)DOMNamedNodesCollection::DOMNamedNodesCollection(ExecState *exec, const QValueList<DOM::Node>& nodes )  : DOMObject(exec->interpreter()->builtinObjectPrototype()),  m_nodes(nodes){  // Maybe we should ref (and deref in the dtor) the nodes, though ?}Value DOMNamedNodesCollection::tryGet(ExecState *exec, const Identifier &propertyName) const{  kdDebug(6070) << k_funcinfo << propertyName.ascii() << endl;  if (propertyName == lengthPropertyName)    return Number(m_nodes.count());  // index?  bool ok;  unsigned int u = propertyName.toULong(&ok);  if (ok && u < m_nodes.count()) {    DOM::Node node = m_nodes[u];    return getDOMNode(exec,node);  }  return DOMObject::tryGet(exec,propertyName);}// -------------------------------------------------------------------------const ClassInfo DOMCharacterData::info = { "CharacterImp",					  &DOMNode::info, &DOMCharacterDataTable, 0 };/*@begin DOMCharacterDataTable 2  data		DOMCharacterData::Data		DontDelete  length	DOMCharacterData::Length	DontDelete|ReadOnly@end@begi

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -