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

📄 kjs_dom.cpp

📁 将konqueror浏览器移植到ARM9 2410中
💻 CPP
📖 第 1 页 / 共 3 页
字号:
  : implementation(impl), id(i){}Completion DOMDOMImplementationFunction::tryExecute(const List &args){  KJSO result;  switch(id) {    case HasFeature:      result = Boolean(implementation.hasFeature(args[0].toString().value().string(),args[1].toString().value().string()));      break;/*    case CreateDocumentType: // new for DOM2 - not yet in khtml    case CreateDocument: // new for DOM2 - not yet in khtml*/    case CreateCSSStyleSheet:      result = getDOMStyleSheet(implementation.createCSSStyleSheet(args[0].toString().value().string(),args[1].toString().value().string()));      break;    default:      result = Undefined();  }  return Completion(ReturnValue, result);}// -------------------------------------------------------------------------const TypeInfo DOMDocumentType::info = { "DocumentType", HostType, &DOMNode::info, 0, 0 };KJSO DOMDocumentType::tryGet(const UString &p) const{  DOM::DocumentType type = static_cast<DOM::DocumentType>(node);  if (p == "name")    return getString(type.name());  else if (p == "entities")    return getDOMNamedNodeMap(type.entities());  else if (p == "notations")    return getDOMNamedNodeMap(type.notations());//  else if (p == "publicId") // new for DOM2 - not yet in khtml//    return getString(type.publicId());//  else if (p == "systemId") // new for DOM2 - not yet in khtml//    return getString(type.systemId());//  else if (p == "internalSubset") // new for DOM2 - not yet in khtml//    return getString(type.internalSubset());  else    return DOMNode::tryGet(p);}// -------------------------------------------------------------------------const TypeInfo DOMNamedNodeMap::info = { "NamedNodeMap", HostType, 0, 0, 0 };DOMNamedNodeMap::~DOMNamedNodeMap(){  namedNodeMaps.remove(map.handle());}KJSO DOMNamedNodeMap::tryGet(const UString &p) const{  KJSO result;  if (p == "length")    return Number(map.length());  else if (p == "getNamedItem")    result = new DOMNamedNodeMapFunction(map, DOMNamedNodeMapFunction::GetNamedItem);  else if (p == "setNamedItem")    result = new DOMNamedNodeMapFunction(map, DOMNamedNodeMapFunction::SetNamedItem);  else if (p == "removeNamedItem")    result = new DOMNamedNodeMapFunction(map, DOMNamedNodeMapFunction::RemoveNamedItem);  else if (p == "item")    result = new DOMNamedNodeMapFunction(map, DOMNamedNodeMapFunction::Item);//  else if (p == "getNamedItemNS") // new for DOM2 - not yet in khtml//    result = new DOMNamedNodeMapFunction(map, DOMNamedNodeMapFunction::GetNamedItemNS);//  else if (p == "setNamedItemNS") // new for DOM2 - not yet in khtml//    result = new DOMNamedNodeMapFunction(map, DOMNamedNodeMapFunction::SetNamedItemNS);//  else if (p == "removeNamedItemNS") // new for DOM2 - not yet in khtml//    result = new DOMNamedNodeMapFunction(map, DOMNamedNodeMapFunction::RemoveNamedItemNS);  else    result = Undefined();  // array index ?  bool ok;  long unsigned int idx = p.toULong(&ok);  if (ok)    result = getDOMNode(map.item(idx));  return result;}DOMNamedNodeMapFunction::DOMNamedNodeMapFunction(DOM::NamedNodeMap m, int i)  : map(m), id(i){}Completion DOMNamedNodeMapFunction::tryExecute(const List &args){  KJSO result;  switch(id) {    case GetNamedItem:      result = getDOMNode(map.getNamedItem(args[0].toString().value().string()));      break;    case SetNamedItem:      result = getDOMNode(map.setNamedItem((new DOMNode(KJS::toNode(args[0])))->toNode()));      break;    case RemoveNamedItem:      result = getDOMNode(map.removeNamedItem(args[0].toString().value().string()));      break;    case Item:      result = getDOMNode(map.item(args[0].toNumber().intValue()));      break;/*    case GetNamedItemNS: // new for DOM2 - not yet in khtml    case SetNamedItemNS: // new for DOM2 - not yet in khtml    case RemoveNamedItemNS: // new for DOM2 - not yet in khtml*/    default:      result = Undefined();  }  return Completion(ReturnValue, result);}// -------------------------------------------------------------------------const TypeInfo DOMProcessingInstruction::info = { "ProcessingInstruction", HostType, &DOMNode::info, 0, 0 };KJSO DOMProcessingInstruction::tryGet(const UString &p) const{  if (p == "target")    return getString(static_cast<DOM::ProcessingInstruction>(node).target());  else if (p == "data")    return getString(static_cast<DOM::ProcessingInstruction>(node).data());  else if (p == "sheet")    return getDOMStyleSheet(static_cast<DOM::ProcessingInstruction>(node).sheet());  else    return DOMNode::tryGet(p);}void DOMProcessingInstruction::tryPut(const UString &p, const KJSO& v){  if (p == "data")    static_cast<DOM::ProcessingInstruction>(node).setData(v.toString().value().string());  else    DOMNode::tryPut(p,v);}// -------------------------------------------------------------------------const TypeInfo DOMNotation::info = { "Notation", HostType, &DOMNode::info, 0, 0 };KJSO DOMNotation::tryGet(const UString &p) const{  if (p == "publicId")    return getString(static_cast<DOM::Notation>(node).publicId());  else if (p == "systemId")    return getString(static_cast<DOM::Notation>(node).systemId());  else    return DOMNode::tryGet(p);}// -------------------------------------------------------------------------const TypeInfo DOMEntity::info = { "Entity", HostType, &DOMNode::info, 0, 0 };KJSO DOMEntity::tryGet(const UString &p) const{  if (p == "publicId")    return getString(static_cast<DOM::Entity>(node).publicId());  else if (p == "systemId")    return getString(static_cast<DOM::Entity>(node).systemId());  else if (p == "notationName")    return getString(static_cast<DOM::Entity>(node).notationName());  else    return DOMNode::tryGet(p);}// -------------------------------------------------------------------------KJSO KJS::getDOMNode(DOM::Node n){  DOMNode *ret = 0;  if (n.isNull())    return Null();  else if ((ret = nodes[n.handle()]))    return ret;  switch (n.nodeType()) {    case DOM::Node::ELEMENT_NODE:      if (static_cast<DOM::Element>(n).isHTMLElement())        ret = new HTMLElement(static_cast<DOM::HTMLElement>(n));      else        ret = new DOMElement(static_cast<DOM::Element>(n));      break;    case DOM::Node::ATTRIBUTE_NODE:      ret = new DOMAttr(static_cast<DOM::Attr>(n));      break;    case DOM::Node::TEXT_NODE:    case DOM::Node::CDATA_SECTION_NODE:      ret = new DOMText(static_cast<DOM::Text>(n));      break;    case DOM::Node::ENTITY_REFERENCE_NODE:      ret = new DOMNode(n);      break;    case DOM::Node::ENTITY_NODE:      ret = new DOMEntity(static_cast<DOM::Entity>(n));      break;    case DOM::Node::PROCESSING_INSTRUCTION_NODE:      ret = new DOMProcessingInstruction(static_cast<DOM::ProcessingInstruction>(n));      break;    case DOM::Node::COMMENT_NODE:      ret = new DOMCharacterData(static_cast<DOM::CharacterData>(n));      break;    case DOM::Node::DOCUMENT_NODE:      if (static_cast<DOM::Document>(n).isHTMLDocument())        ret = new HTMLDocument(static_cast<DOM::HTMLDocument>(n));      else        ret = new DOMDocument(static_cast<DOM::Document>(n));      break;    case DOM::Node::DOCUMENT_TYPE_NODE:      ret = new DOMDocumentType(static_cast<DOM::DocumentType>(n));      break;    case DOM::Node::DOCUMENT_FRAGMENT_NODE:      ret = new DOMNode(n);      break;    case DOM::Node::NOTATION_NODE:      ret = new DOMNotation(static_cast<DOM::Notation>(n));      break;    default:      ret = new DOMNode(n);  }  nodes.insert(n.handle(),ret);  return ret;}KJSO KJS::getDOMNamedNodeMap(DOM::NamedNodeMap m){  DOMNamedNodeMap *ret;  if (m.isNull())    return Null();  else if ((ret = namedNodeMaps[m.handle()]))    return ret;  else {    ret = new DOMNamedNodeMap(m);    namedNodeMaps.insert(m.handle(),ret);    return ret;  }}KJSO KJS::getDOMNodeList(DOM::NodeList l){  DOMNodeList *ret;  if (l.isNull())    return Null();  else if ((ret = nodeLists[l.handle()]))    return ret;  else {    ret = new DOMNodeList(l);    nodeLists.insert(l.handle(),ret);    return ret;  }}KJSO KJS::getDOMDOMImplementation(DOM::DOMImplementation i){  DOMDOMImplementation *ret;  if (i.isNull())    return Null();  else if ((ret = domImplementations[i.handle()]))    return ret;  else {    ret = new DOMDOMImplementation(i);    domImplementations.insert(i.handle(),ret);    return ret;  }}// -------------------------------------------------------------------------const TypeInfo NodePrototype::info = { "NodePrototype", HostType, 0, 0, 0 };KJSO NodePrototype::tryGet(const UString &p) const{  if (p == "ELEMENT_NODE")    return Number((unsigned int)DOM::Node::ELEMENT_NODE);  if (p == "ATTRIBUTE_NODE")    return Number((unsigned int)DOM::Node::ATTRIBUTE_NODE);  if (p == "TEXT_NODE")    return Number((unsigned int)DOM::Node::TEXT_NODE);  if (p == "CDATA_SECTION_NODE")    return Number((unsigned int)DOM::Node::CDATA_SECTION_NODE);  if (p == "ENTITY_REFERENCE_NODE")    return Number((unsigned int)DOM::Node::ENTITY_REFERENCE_NODE);  if (p == "ENTITY_NODE")    return Number((unsigned int)DOM::Node::ENTITY_NODE);  if (p == "PROCESSING_INSTRUCTION_NODE")    return Number((unsigned int)DOM::Node::PROCESSING_INSTRUCTION_NODE);  if (p == "COMMENT_NODE")    return Number((unsigned int)DOM::Node::COMMENT_NODE);  if (p == "DOCUMENT_NODE")    return Number((unsigned int)DOM::Node::DOCUMENT_NODE);  if (p == "DOCUMENT_TYPE_NODE")    return Number((unsigned int)DOM::Node::DOCUMENT_TYPE_NODE);  if (p == "DOCUMENT_FRAGMENT_NODE")    return Number((unsigned int)DOM::Node::DOCUMENT_FRAGMENT_NODE);  if (p == "NOTATION_NODE")    return Number((unsigned int)DOM::Node::NOTATION_NODE);  return DOMObject::tryGet(p);}KJSO KJS::getNodePrototype(){    KJSO proto = Global::current().get("[[node.prototype]]");    if (proto.isDefined())        return proto;    else    {        Object nodeProto( new NodePrototype );        Global::current().put("[[node.prototype]]", nodeProto);        return nodeProto;    }}// -------------------------------------------------------------------------const TypeInfo DOMExceptionPrototype::info = { "DOMExceptionPrototype", HostType, 0, 0, 0 };KJSO DOMExceptionPrototype::tryGet(const UString &p) const{  if (p == "INDEX_SIZE_ERR")    return Number((unsigned int)DOM::DOMException::INDEX_SIZE_ERR);  if (p == "DOMSTRING_SIZE_ERR")    return Number((unsigned int)DOM::DOMException::DOMSTRING_SIZE_ERR);  if (p == "HIERARCHY_REQUEST_ERR")    return Number((unsigned int)DOM::DOMException::HIERARCHY_REQUEST_ERR);  if (p == "WRONG_DOCUMENT_ERR")    return Number((unsigned int)DOM::DOMException::WRONG_DOCUMENT_ERR);  if (p == "INVALID_CHARACTER_ERR")    return Number((unsigned int)DOM::DOMException::INVALID_CHARACTER_ERR);  if (p == "NO_DATA_ALLOWED_ERR")    return Number((unsigned int)DOM::DOMException::NO_DATA_ALLOWED_ERR);  if (p == "NO_MODIFICATION_ALLOWED_ERR")    return Number((unsigned int)DOM::DOMException::NO_MODIFICATION_ALLOWED_ERR);  if (p == "NOT_FOUND_ERR")    return Number((unsigned int)DOM::DOMException::NOT_FOUND_ERR);  if (p == "NOT_SUPPORTED_ERR")    return Number((unsigned int)DOM::DOMException::NOT_SUPPORTED_ERR);  if (p == "INUSE_ATTRIBUTE_ERR")    return Number((unsigned int)DOM::DOMException::INUSE_ATTRIBUTE_ERR);  if (p == "INVALID_STATE_ERR")    return Number((unsigned int)DOM::DOMException::INVALID_STATE_ERR);  if (p == "SYNTAX_ERR")    return Number((unsigned int)DOM::DOMException::SYNTAX_ERR);  if (p == "INVALID_MODIFICATION_ERR")    return Number((unsigned int)DOM::DOMException::INVALID_MODIFICATION_ERR);  if (p == "NAMESPACE_ERR")    return Number((unsigned int)DOM::DOMException::NAMESPACE_ERR);  if (p == "INVALID_ACCESS_ERR")    return Number((unsigned int)DOM::DOMException::INVALID_ACCESS_ERR);  return DOMObject::tryGet(p);}KJSO KJS::getDOMExceptionPrototype(){    KJSO proto = Global::current().get("[[DOMException.prototype]]");    if (proto.isDefined())        return proto;    else    {        Object domExceptionProto( new DOMExceptionPrototype );        Global::current().put("[[DOMException.prototype]]", domExceptionProto);        return domExceptionProto;    }}

⌨️ 快捷键说明

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