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

📄 dom_docimpl.cpp

📁 khtml在gtk上的移植版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
DocumentFragmentImpl *DocumentImpl::createDocumentFragment(  ){    return new DocumentFragmentImpl( docPtr() );}TextImpl *DocumentImpl::createTextNode( const DOMString &data ){    return new TextImpl( docPtr(), data);}CommentImpl *DocumentImpl::createComment ( const DOMString &data ){    return new CommentImpl( docPtr(), data );}CDATASectionImpl *DocumentImpl::createCDATASection ( const DOMString &data ){    return new CDATASectionImpl( docPtr(), data );}ProcessingInstructionImpl *DocumentImpl::createProcessingInstruction ( const DOMString &target, const DOMString &data ){    return new ProcessingInstructionImpl( docPtr(),target,data);}Attr DocumentImpl::createAttribute( NodeImpl::Id id ){    // Assume this is an HTML attribute, since createAttribute isn't namespace-aware.  There's no harm to XML    // documents if we're wrong.    return new AttrImpl(0, docPtr(), new HTMLAttributeImpl(id, DOMString("").implementation()));}EntityReferenceImpl *DocumentImpl::createEntityReference ( const DOMString &name ){    return new EntityReferenceImpl(docPtr(), name.implementation());}EditingTextImpl *DocumentImpl::createEditingTextNode(const DOMString &text){    return new EditingTextImpl(docPtr(), text);}CSSStyleDeclarationImpl *DocumentImpl::createCSSStyleDeclaration(){    QPtrList<CSSProperty> *propList = new QPtrList<CSSProperty>;    propList->setAutoDelete(true);    return new CSSStyleDeclarationImpl(0, propList);}NodeImpl *DocumentImpl::importNode(NodeImpl *importedNode, bool deep, int &exceptioncode){	NodeImpl *result = 0;	if(importedNode->nodeType() == Node::ELEMENT_NODE)	{		ElementImpl *tempElementImpl = createElementNS(getDocument()->namespaceURI(id()), importedNode->nodeName(), exceptioncode);                if (exceptioncode)                    return 0;		result = tempElementImpl;		if(static_cast<ElementImpl *>(importedNode)->attributes(true) && static_cast<ElementImpl *>(importedNode)->attributes(true)->length())		{			NamedNodeMapImpl *attr = static_cast<ElementImpl *>(importedNode)->attributes();			for(unsigned int i = 0; i < attr->length(); i++)			{				DOM::DOMString qualifiedName = attr->item(i)->nodeName();				DOM::DOMString value = attr->item(i)->nodeValue();				int colonpos = qualifiedName.find(':');				DOMString localName = qualifiedName;				if(colonpos >= 0)				{					localName.remove(0, colonpos + 1);					// ### extract and set new prefix				}				NodeImpl::Id nodeId = getDocument()->attrId(getDocument()->namespaceURI(id()), localName.implementation(), false /* allocate */);				tempElementImpl->setAttribute(nodeId, value.implementation(), exceptioncode);				if(exceptioncode != 0)					break;			}		}	}	else if(importedNode->nodeType() == Node::TEXT_NODE)	{		result = createTextNode(importedNode->nodeValue());		deep = false;	}	else if(importedNode->nodeType() == Node::CDATA_SECTION_NODE)	{		result = createCDATASection(importedNode->nodeValue());		deep = false;	}	else if(importedNode->nodeType() == Node::ENTITY_REFERENCE_NODE)		result = createEntityReference(importedNode->nodeName());	else if(importedNode->nodeType() == Node::PROCESSING_INSTRUCTION_NODE)	{		result = createProcessingInstruction(importedNode->nodeName(), importedNode->nodeValue());		deep = false;	}	else if(importedNode->nodeType() == Node::COMMENT_NODE)	{		result = createComment(importedNode->nodeValue());		deep = false;	}	else		exceptioncode = DOMException::NOT_SUPPORTED_ERR;	if(deep)	{		for(Node n = importedNode->firstChild(); !n.isNull(); n = n.nextSibling())			result->appendChild(importNode(n.handle(), true, exceptioncode), exceptioncode);	}	return result;}ElementImpl *DocumentImpl::createElementNS( const DOMString &_namespaceURI, const DOMString &_qualifiedName, int &exceptioncode){    ElementImpl *e = 0;    QString qName = _qualifiedName.string();    int colonPos = qName.find(':',0);    if ((_namespaceURI.isNull() && colonPos < 0) ||        _namespaceURI == XHTML_NAMESPACE) {        // User requested an element in the XHTML namespace - this means we create a HTML element        // (elements not in this namespace are treated as normal XML elements)        e = createHTMLElement(qName.mid(colonPos+1), exceptioncode);        if (exceptioncode)            return 0;        if (e && colonPos >= 0) {            e->setPrefix(qName.left(colonPos), exceptioncode);            if (exceptioncode) {                delete e;                return 0;            }        }    }    if (!e)        e = new XMLElementImpl( document, _qualifiedName.implementation(), _namespaceURI.implementation() );    return e;}ElementImpl *DocumentImpl::getElementById( const DOMString &elementId ) const{    if (elementId.length() == 0) {	return 0;    }    return m_elementsById.find(elementId.string());}void DocumentImpl::addElementById(const DOMString &elementId, ElementImpl *element){    QString qId = elementId.string();    if (m_elementsById.find(qId) == NULL) {	m_elementsById.insert(qId, element);        m_accessKeyDictValid = false;    }}void DocumentImpl::removeElementById(const DOMString &elementId, ElementImpl *element){    QString qId = elementId.string();    if (m_elementsById.find(qId) == element) {	m_elementsById.remove(qId);        m_accessKeyDictValid = false;    }}ElementImpl *DocumentImpl::getElementByAccessKey( const DOMString &key ){    if (key.length() == 0)	return 0;    QString k(key.string());    if (!m_accessKeyDictValid) {        m_elementsByAccessKey.clear();            const NodeImpl *n;        for (n = this; n != 0; n = n->traverseNextNode()) {            if (!n->isElementNode())                continue;            const ElementImpl *elementImpl = static_cast<const ElementImpl *>(n);            DOMString accessKey(elementImpl->getAttribute(ATTR_ACCESSKEY));            if (!accessKey.isEmpty()) {                QString ak = accessKey.string().lower();                if (m_elementsByAccessKey.find(ak) == NULL)                    m_elementsByAccessKey.insert(ak, elementImpl);            }        }        m_accessKeyDictValid = true;    }    return m_elementsByAccessKey.find(k);}void DocumentImpl::setTitle(DOMString _title){    m_title = _title;    if (!part())        return;#if APPLE_CHANGES    KWQ(part())->setTitle(_title);#else    QString titleStr = m_title.string();    for (int i = 0; i < titleStr.length(); ++i)        if (titleStr[i] < ' ')            titleStr[i] = ' ';    titleStr = titleStr.stripWhiteSpace();    titleStr.compose();    if ( !part()->parentPart() ) {	if (titleStr.isNull() || titleStr.isEmpty()) {	    // empty title... set window caption as the URL	    KURL url = m_url;	    url.setRef(QString::null);	    url.setQuery(QString::null);	    titleStr = url.url();	}	emit part()->setWindowCaption( KStringHandler::csqueeze( titleStr, 128 ) );    }#endif}DOMString DocumentImpl::nodeName() const{    return "#document";}unsigned short DocumentImpl::nodeType() const{    return Node::DOCUMENT_NODE;}ElementImpl *DocumentImpl::createHTMLElement( const DOMString &name, int &exceptioncode ){    if (!isValidName(name)) {        exceptioncode = DOMException::INVALID_CHARACTER_ERR;        return 0;    }    uint id = khtml::getTagID( name.string().lower().latin1(), name.string().length() );    ElementImpl *n = 0;    switch(id)    {    case ID_HTML:        n = new HTMLHtmlElementImpl(docPtr());        break;    case ID_HEAD:        n = new HTMLHeadElementImpl(docPtr());        break;    case ID_BODY:        n = new HTMLBodyElementImpl(docPtr());        break;// head elements    case ID_BASE:        n = new HTMLBaseElementImpl(docPtr());        break;    case ID_LINK:        n = new HTMLLinkElementImpl(docPtr());        break;    case ID_META:        n = new HTMLMetaElementImpl(docPtr());        break;    case ID_STYLE:        n = new HTMLStyleElementImpl(docPtr());        break;    case ID_TITLE:        n = new HTMLTitleElementImpl(docPtr());        break;// frames    case ID_FRAME:        n = new HTMLFrameElementImpl(docPtr());        break;    case ID_FRAMESET:        n = new HTMLFrameSetElementImpl(docPtr());        break;    case ID_IFRAME:        n = new HTMLIFrameElementImpl(docPtr());        break;// form elements// ### FIXME: we need a way to set form dependency after we have made the form elements    case ID_FORM:            n = new HTMLFormElementImpl(docPtr());        break;    case ID_BUTTON:            n = new HTMLButtonElementImpl(docPtr());        break;    case ID_FIELDSET:            n = new HTMLFieldSetElementImpl(docPtr());        break;    case ID_INPUT:            n = new HTMLInputElementImpl(docPtr());        break;    case ID_ISINDEX:            n = new HTMLIsIndexElementImpl(docPtr());        break;    case ID_LABEL:            n = new HTMLLabelElementImpl(docPtr());        break;    case ID_LEGEND:            n = new HTMLLegendElementImpl(docPtr());        break;    case ID_OPTGROUP:            n = new HTMLOptGroupElementImpl(docPtr());        break;    case ID_OPTION:            n = new HTMLOptionElementImpl(docPtr());        break;    case ID_SELECT:            n = new HTMLSelectElementImpl(docPtr());        break;    case ID_TEXTAREA:            n = new HTMLTextAreaElementImpl(docPtr());        break;// lists    case ID_DL:        n = new HTMLDListElementImpl(docPtr());        break;    case ID_DD:        n = new HTMLGenericElementImpl(docPtr(), id);        break;    case ID_DT:        n = new HTMLGenericElementImpl(docPtr(), id);        break;    case ID_UL:        n = new HTMLUListElementImpl(docPtr());        break;    case ID_OL:        n = new HTMLOListElementImpl(docPtr());        break;    case ID_DIR:        n = new HTMLDirectoryElementImpl(docPtr());        break;    case ID_MENU:        n = new HTMLMenuElementImpl(docPtr());        break;    case ID_LI:        n = new HTMLLIElementImpl(docPtr());        break;// formatting elements (block)    case ID_BLOCKQUOTE:        n = new HTMLBlockquoteElementImpl(docPtr());        break;    case ID_DIV:        n = new HTMLDivElementImpl(docPtr());        break;    case ID_H1:    case ID_H2:    case ID_H3:    case ID_H4:    case ID_H5:    case ID_H6:        n = new HTMLHeadingElementImpl(docPtr(), id);        break;    case ID_HR:        n = new HTMLHRElementImpl(docPtr());        break;    case ID_P:        n = new HTMLParagraphElementImpl(docPtr());        break;    case ID_PRE:        n = new HTMLPreElementImpl(docPtr(), id);        break;// font stuff    case ID_BASEFONT:        n = new HTMLBaseFontElementImpl(docPtr());        break;    case ID_FONT:        n = new HTMLFontElementImpl(docPtr());        break;// ins/del    case ID_DEL:    case ID_INS:        n = new HTMLGenericElementImpl(docPtr(), id);        break;// anchor    case ID_A:        n = new HTMLAnchorElementImpl(docPtr());        break;// images    case ID_IMG:        n = new HTMLImageElementImpl(docPtr());        break;    case ID_MAP:        n = new HTMLMapElementImpl(docPtr());        /*n = map;*/        break;    case ID_AREA:        n = new HTMLAreaElementImpl(docPtr());        break;// objects, applets and scripts#if !KWIQ_NO_JAVA //FIXME:KWIQ: Applet code commented out	    case ID_APPLET:        n = new HTMLAppletElementImpl(docPtr());        break;#endif	    case ID_OBJECT:        n = new HTMLObjectElementImpl(docPtr());        break;    case ID_PARAM:        n = new HTMLParamElementImpl(docPtr());        break;    case ID_SCRIPT:        n = new HTMLScriptElementImpl(docPtr());        break;// tables    case ID_TABLE:        n = new HTMLTableElementImpl(docPtr());        break;    case ID_CAPTION:        n = new HTMLTableCaptionElementImpl(docPtr());        break;    case ID_COLGROUP:    case ID_COL:        n = new HTMLTableColElementImpl(docPtr(), id);        break;    case ID_TR:        n = new HTMLTableRowElementImpl(docPtr());        break;    case ID_TD:    case ID_TH:        n = new HTMLTableCellElementImpl(docPtr(), id);        break;    case ID_THEAD:

⌨️ 快捷键说明

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