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

📄 htmlparser.cpp

📁 将konqueror浏览器移植到ARM9 2410中
💻 CPP
📖 第 1 页 / 共 3 页
字号:
        n = new HTMLOListElementImpl(document);        break;    }    case ID_DIR:        n = new HTMLDirectoryElementImpl(document);        break;    case ID_MENU:        n = new HTMLMenuElementImpl(document);        break;    case ID_LI:    {        popBlock(ID_LI);        HTMLElementImpl *e = new HTMLLIElementImpl(document);        n = e;        if( current->id() != ID_UL && current->id() != ID_OL )                e->addCSSProperty(CSS_PROP_LIST_STYLE_POSITION, CSS_VAL_INSIDE);        break;    }// formatting elements (block)    case ID_BLOCKQUOTE:        n = new HTMLBlockquoteElementImpl(document);        break;    case ID_DIV:        n = new HTMLDivElementImpl(document);        break;    case ID_LAYER:        n = new HTMLLayerElementImpl(document);        break;    case ID_H1:    case ID_H2:    case ID_H3:    case ID_H4:    case ID_H5:    case ID_H6:        n = new HTMLHeadingElementImpl(document, t->id);        break;    case ID_HR:        n = new HTMLHRElementImpl(document);        break;    case ID_P:        n = new HTMLParagraphElementImpl(document);        break;    case ID_PRE:    case ID_PLAINTEXT:        n = new HTMLPreElementImpl(document);        break;// font stuff    case ID_BASEFONT:        n = new HTMLBaseFontElementImpl(document);        break;    case ID_FONT:        n = new HTMLFontElementImpl(document);        break;// ins/del    case ID_DEL:    case ID_INS:        n = new HTMLModElementImpl(document, t->id);        break;// anchor    case ID_A:        n = new HTMLAnchorElementImpl(document);        break;// images    case ID_IMG:        n = new HTMLImageElementImpl(document);        break;    case ID_MAP:        map = new HTMLMapElementImpl(document);        n = map;        break;    case ID_AREA:        n = new HTMLAreaElementImpl(document);        break;// objects, applets and scripts    case ID_APPLET:        n = new HTMLAppletElementImpl(document);        break;    case ID_EMBED:        n = new HTMLEmbedElementImpl(document);        break;    case ID_OBJECT:        n = new HTMLObjectElementImpl(document);        break;    case ID_PARAM:        n = new HTMLParamElementImpl(document);        break;    case ID_SCRIPT:        n = new HTMLScriptElementImpl(document);        break;// tables    case ID_TABLE:        n = new HTMLTableElementImpl(document);        break;    case ID_CAPTION:        n = new HTMLTableCaptionElementImpl(document);        break;    case ID_COLGROUP:    case ID_COL:        n = new HTMLTableColElementImpl(document, t->id);        break;    case ID_TR:        popBlock(ID_TR);        n = new HTMLTableRowElementImpl(document);        break;    case ID_TD:    case ID_TH:        popBlock(ID_TH);        popBlock(ID_TD);        n = new HTMLTableCellElementImpl(document, t->id);        break;    case ID_TBODY:    case ID_THEAD:    case ID_TFOOT:        popBlock( ID_THEAD );        popBlock( ID_TBODY );        popBlock( ID_TFOOT );        n = new HTMLTableSectionElementImpl(document, t->id);        break;// inline elements    case ID_BR:        n = new HTMLBRElementImpl(document);        break;    case ID_Q:        n = new HTMLQuoteElementImpl(document);        break;// elements with no special representation in the DOM// block:    case ID_ADDRESS:    case ID_CENTER:    case ID_LISTING:        n = new HTMLGenericElementImpl(document, t->id);        break;// inline        // %fontstyle    case ID_TT:    case ID_U:    case ID_B:    case ID_I:    case ID_S:    case ID_STRIKE:    case ID_BIG:    case ID_SMALL:        // %phrase    case ID_EM:    case ID_STRONG:    case ID_DFN:    case ID_CODE:    case ID_SAMP:    case ID_KBD:    case ID_VAR:    case ID_CITE:    case ID_ABBR:    case ID_ACRONYM:        // %special    case ID_SUB:    case ID_SUP:    case ID_SPAN:        n = new HTMLGenericElementImpl(document, t->id);        break;    case ID_BDO:        break;        // these are special, and normally not rendered    case ID_NOEMBED:        discard_until = ID_NOEMBED + ID_CLOSE_TAG;        return 0;    case ID_NOFRAMES:        discard_until = ID_NOFRAMES + ID_CLOSE_TAG;        return 0;    case ID_NOSCRIPT:        if(HTMLWidget && HTMLWidget->part()->jScriptEnabled())            discard_until = ID_NOSCRIPT + ID_CLOSE_TAG;        return 0;    case ID_NOLAYER://        discard_until = ID_NOLAYER + ID_CLOSE_TAG;        return 0;        break;// text    case ID_TEXT:        n = new TextImpl(document, t->text);        if (t->complexText )            n->setComplexText(true);        break;    case ID_COMMENT:#ifdef COMMENTS_IN_DOM        n = new CommentImpl(document, t->text);#endif        break;    default:        kdDebug( 6035 ) << "Unknown tag " << t->id << "!" << endl;    }    return n;}void KHTMLParser::processCloseTag(Token *t){    // support for really broken html. Can't believe I'm supporting such crap (lars)    switch(t->id)    {    case ID_HTML+ID_CLOSE_TAG:    case ID_BODY+ID_CLOSE_TAG:        // we never close the body tag, since some stupid web pages close it before the actual end of the doc.        // let's rely on the end() call to close things.        return;    case ID_FORM+ID_CLOSE_TAG:        form = 0;        // this one is to get the right style on the body element        break;    case ID_MAP+ID_CLOSE_TAG:        map = 0;        break;    case ID_HEAD+ID_CLOSE_TAG:        //inBody = true;        // don't close head neither. the creation of body will do it for us.        // fixes some sites, that define stylesheets after </head>        return;    case ID_TITLE+ID_CLOSE_TAG:        if ( current->id() == ID_TITLE )          static_cast<HTMLTitleElementImpl *>(current)->setTitle();        break;    case ID_SELECT+ID_CLOSE_TAG:        inSelect = false;        break;    default:        break;    }#ifdef PARSER_DEBUG    kdDebug( 6035 ) << "added the following childs to " << current->nodeName().string() << endl;    NodeImpl *child = current->firstChild();    while(child != 0)    {        kdDebug( 6035 ) << "    " << child->nodeName().string() << endl;        child = child->nextSibling();    }#endif    popBlock(t->id-ID_CLOSE_TAG);#ifdef PARSER_DEBUG    kdDebug( 6035 ) << "closeTag --> current = " << current->nodeName().string() << endl;#endif}void KHTMLParser::pushBlock(int _id, int _level){    HTMLStackElem *Elem = new HTMLStackElem(_id, _level, current, blockStack);    blockStack = Elem;    addForbidden(_id, forbiddenTag);}void KHTMLParser::popBlock( int _id ){    HTMLStackElem *Elem = blockStack;    int maxLevel = 0;#ifdef PARSER_DEBUG    kdDebug( 6035 ) << "popBlock(" << getTagName(_id).string() << ")" << endl;    while(Elem) {        kdDebug( 6035) << "   > " << getTagName(Elem->id).string() << endl;        Elem = Elem->next;    }    Elem = blockStack;#endif    while( Elem && (Elem->id != _id))    {        if (maxLevel < Elem->level)        {            maxLevel = Elem->level;        }        Elem = Elem->next;    }    if (!Elem || maxLevel > Elem->level)        return;    Elem = blockStack;    while (Elem)    {        if (Elem->id == _id)        {            popOneBlock();            Elem = 0;        }        else        {            popOneBlock();            Elem = blockStack;        }    }}void KHTMLParser::popOneBlock(){    HTMLStackElem *Elem = blockStack;    // we should never get here, but some bad html might cause it.#ifndef PARSER_DEBUG    if(!Elem) return;#else    kdDebug( 6035 ) << "popping block: " << getTagName(Elem->id).string() << "(" << Elem->id << ")" << endl;#endif#if SPEED_DEBUG < 1    if(Elem->node != current)        if(current->renderer()) current->renderer()->close();#endif    removeForbidden(Elem->id, forbiddenTag);    blockStack = Elem->next;    // we only set inline to false, if the element we close is a block level element.    // This helps getting cases as <p><b>bla</b> <b>bla</b> right.    if(!current->isInline())        _inline = false;    current = Elem->node;    delete Elem;}void KHTMLParser::popInlineBlocks(){    while(current->isInline() && current->id() != ID_FONT)        popOneBlock();}void KHTMLParser::freeBlock(){    while (blockStack)        popOneBlock();    blockStack = 0;}void KHTMLParser::createHead(){    if(head || !doc()->firstChild())        return;    head = new HTMLHeadElementImpl(document);    HTMLElementImpl *body = doc()->body();    int exceptioncode = 0;    doc()->firstChild()->insertBefore(head, body, exceptioncode);    if ( exceptioncode ) {#ifdef PARSER_DEBUG        kdDebug( 6035 ) << "creation of head failed!!!!" << endl;#endif        delete head;        head = 0;    }}NodeImpl *KHTMLParser::handleIsindex( Token *t ){    NodeImpl *n;    HTMLFormElementImpl *myform = form;    if ( !myform ) {        myform = new HTMLFormElementImpl(document);        n = myform;    } else        n = new HTMLDivElementImpl( document );    NodeImpl *child = new HTMLHRElementImpl( document );    n->addChild( child );    AttrImpl* a = 0;    DOMString text;    if(t->attrs)        a = t->attrs->getIdItem(ATTR_PROMPT);    if(a)        text = a->value() + " ";    else        text =  i18n("This is a searchable index. Enter search keywords: ");    child = new TextImpl(document, text);    n->addChild( child );    child = new HTMLIsIndexElementImpl(document, myform);    static_cast<ElementImpl *>(child)->setAttribute(ATTR_TYPE, "khtml_isindex");    n->addChild( child );    child = new HTMLHRElementImpl( document );    n->addChild( child );    return n;}void KHTMLParser::startBody(){    if(inBody) return;    inBody = true;    if( isindex ) {        flat = true; // don't decend into this node        insertNode( isindex );        isindex = 0;    }}

⌨️ 快捷键说明

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