📄 htmlparser.cpp
字号:
n = new HTMLFrameElementImpl(document); break; case ID_FRAMESET: popBlock(ID_HEAD); if ( inBody && !haveFrameSet && !haveContent && !haveBody) { popBlock( ID_BODY ); // ### actually for IE document.body returns the now hidden "body" element // we can't implement that behavior now because it could cause too many // regressions and the headaches are not worth the work as long as there is // no site actually relying on that detail (Dirk) if (static_cast<HTMLDocumentImpl*>(document->document())->body()) static_cast<HTMLDocumentImpl*>(document->document())->body() ->addCSSProperty(CSS_PROP_DISPLAY, CSS_VAL_NONE); inBody = false; } if ( (haveBody || haveContent || haveFrameSet) && current->id() == ID_HTML) break; n = new HTMLFrameSetElementImpl(document); haveFrameSet = true; startBody(); break; // a bit a special case, since the frame is inlined... case ID_IFRAME: n = new HTMLIFrameElementImpl(document); if (!t->flat) discard_until = ID_IFRAME+ID_CLOSE_TAG; break;// form elements case ID_FORM: // thou shall not nest <form> - NS/IE quirk if (form) break; n = form = new HTMLFormElementImpl(document, false); break; case ID_BUTTON: n = new HTMLButtonElementImpl(document, form); break; case ID_FIELDSET: n = new HTMLFieldSetElementImpl(document, form); break; case ID_INPUT: if ( t->attrs && KHTMLFactory::defaultHTMLSettings()->isAdFilterEnabled() && KHTMLFactory::defaultHTMLSettings()->isHideAdsEnabled() && !strcasecmp( t->attrs->getValue( ATTR_TYPE ), "image" ) ) { if (KHTMLFactory::defaultHTMLSettings()->isAdFiltered( doc()->completeURL( khtml::parseURL(t->attrs->getValue(ATTR_SRC)).string() ) )) return 0; } n = new HTMLInputElementImpl(document, form); break; case ID_ISINDEX: n = handleIsindex(t); if( !inBody ) { isindex = n; n = 0; } else t->flat = true; break; case ID_KEYGEN: n = new HTMLKeygenElementImpl(document, form); break; case ID_LABEL: n = new HTMLLabelElementImpl(document); break; case ID_LEGEND: n = new HTMLLegendElementImpl(document, form); break; case ID_OPTGROUP: n = new HTMLOptGroupElementImpl(document, form); break; case ID_OPTION: n = new HTMLOptionElementImpl(document, form); break; case ID_SELECT: inSelect = true; n = new HTMLSelectElementImpl(document, form); break; case ID_TEXTAREA: n = new HTMLTextAreaElementImpl(document, form); break;// lists case ID_DL: n = new HTMLDListElementImpl(document); break; case ID_DD: n = new HTMLGenericElementImpl(document, t->tid); popBlock(ID_DT); popBlock(ID_DD); break; case ID_DT: n = new HTMLGenericElementImpl(document, t->tid); popBlock(ID_DD); popBlock(ID_DT); break; case ID_UL: { n = new HTMLUListElementImpl(document); break; } case ID_OL: { 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); n = new HTMLLIElementImpl(document); break;// formatting elements (block) case ID_BLOCKQUOTE: n = new HTMLGenericElementImpl(document, t->tid); break; case ID_LAYER: case ID_ILAYER: n = new HTMLLayerElementImpl(document, t->tid); break; case ID_P: case ID_DIV: n = new HTMLDivElementImpl(document, t->tid); break; case ID_H1: case ID_H2: case ID_H3: case ID_H4: case ID_H5: case ID_H6: n = new HTMLGenericElementImpl(document, t->tid); break; case ID_HR: n = new HTMLHRElementImpl(document); break; case ID_PRE: case ID_XMP: case ID_PLAINTEXT: n = new HTMLPreElementImpl(document, t->tid); 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 HTMLGenericElementImpl(document, t->tid); break;// anchor case ID_A: popBlock(ID_A); n = new HTMLAnchorElementImpl(document); break;// images case ID_IMG: if (t->attrs&& KHTMLFactory::defaultHTMLSettings()->isAdFilterEnabled()&& KHTMLFactory::defaultHTMLSettings()->isHideAdsEnabled()) { QString url = doc()->completeURL( khtml::parseURL(t->attrs->getValue(ATTR_SRC)).string() ); if (KHTMLFactory::defaultHTMLSettings()->isAdFiltered(url)) return 0; } n = new HTMLImageElementImpl(document, form); 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: { HTMLScriptElementImpl *scriptElement = new HTMLScriptElementImpl(document); scriptElement->setCreatedByParser(true); n = scriptElement; 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->tid); 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->tid); break; case ID_TBODY: case ID_THEAD: case ID_TFOOT: popBlock( ID_THEAD ); popBlock( ID_TBODY ); popBlock( ID_TFOOT ); n = new HTMLTableSectionElementImpl(document, t->tid, false); break;// inline elements case ID_BR: n = new HTMLBRElementImpl(document); break; case ID_Q: n = new HTMLGenericElementImpl(document, t->tid); break;// elements with no special representation in the DOM// block: case ID_ADDRESS: case ID_CENTER: n = new HTMLGenericElementImpl(document, t->tid); 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: case ID_WBR: case ID_NOBR: if ( t->tid == ID_NOBR || t->tid == ID_WBR ) popBlock( t->tid ); case ID_BDO: n = new HTMLGenericElementImpl(document, t->tid); break; // these are special, and normally not rendered case ID_NOEMBED: if (!t->flat) { n = new HTMLGenericElementImpl(document, t->tid); discard_until = ID_NOEMBED + ID_CLOSE_TAG; } return n; case ID_NOFRAMES: if (!t->flat) { n = new HTMLGenericElementImpl(document, t->tid); discard_until = ID_NOFRAMES + ID_CLOSE_TAG; } return n; case ID_NOSCRIPT: if (!t->flat) { n = new HTMLGenericElementImpl(document, t->tid); if(HTMLWidget && HTMLWidget->part()->jScriptEnabled()) discard_until = ID_NOSCRIPT + ID_CLOSE_TAG; } return n; case ID_NOLAYER:// discard_until = ID_NOLAYER + ID_CLOSE_TAG; return 0; break; case ID_MARQUEE: n = new HTMLMarqueeElementImpl(document); break;// text case ID_TEXT:// kdDebug(6035) << "ID_TEXT: \"" << DOMString(t->text).string() << "\"" << endl; n = new TextImpl(document, t->text); break; case ID_COMMENT:#ifdef COMMENTS_IN_DOM n = new CommentImpl(document, t->text);#endif break; default: kdDebug( 6035 ) << "Unknown tag " << t->tid << "!" << endl; } return n;}void KHTMLParser::processCloseTag(Token *t){ // support for really broken html. Can't believe I'm supporting such crap (lars) switch(t->tid) { case ID_HTML+ID_CLOSE_TAG: case ID_BODY+ID_CLOSE_TAG: case ID_DT+ID_CLOSE_TAG: case ID_DD+ID_CLOSE_TAG: // we never trust those close tags, since stupid webpages close // them prematurely 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_SELECT+ID_CLOSE_TAG: inSelect = false; break; case ID_TITLE+ID_CLOSE_TAG: // Set haveTitle only if <title> isn't empty if ( current->firstChild() ) haveTitle = true; break; default: break; }#ifdef PARSER_DEBUG kdDebug( 6035 ) << "added the following children to " << current->nodeName().string() << endl; NodeImpl *child = current->firstChild(); while(child != 0) { kdDebug( 6035 ) << " " << child->nodeName().string() << endl; child = child->nextSibling(); }#endif popBlock(t->tid-ID_CLOSE_TAG);#ifdef PARSER_DEBUG kdDebug( 6035 ) << "closeTag --> current = " << current->nodeName().string() << endl;#endif}bool KHTMLParser::isResidualStyleTag(int _id){ switch (_id) { case ID_A: case ID_FONT: case ID_TT: case ID_U: case ID_B: case ID_I: case ID_S: case ID_STRIKE: case ID_BIG: case ID_SMALL: case ID_EM: case ID_STRONG: case ID_DFN: case ID_CODE: case ID_SAMP: case ID_KBD: case ID_VAR: case ID_DEL: case ID_INS: return true; default: return false; }}bool KHTMLParser::isAffectedByResidualStyle(int _id){ if (isResidualStyleTag(_id)) return true; switch (_id) { case ID_P: case ID_DIV: case ID_BLOCKQUOTE: case ID_ADDRESS: case ID_H1: case ID_H2: case ID_H3: case ID_H4: case ID_H5: case ID_H6: case ID_CENTER: case ID_UL:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -