📄 dtd.cpp
字号:
/** * This file is part of the DOM implementation for KDE. * * (C) 1999 Lars Knoll (knoll@kde.org) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * $Id: dtd.cpp,v 1.1.1.1 2002/01/16 10:39:55 ymwei Exp $ */#include "dtd.h"#include "htmlhashes.h"using namespace DOM;#include <kdebug.h>static const ushort tag_list_0[] = { ID_TEXT, ID_TT, ID_I, ID_B, ID_U, ID_S, ID_STRIKE, ID_BIG, ID_SMALL, ID_EM, ID_STRONG, ID_DFN, ID_CODE, ID_SAMP, ID_KBD, ID_VAR, ID_CITE, ID_ABBR, ID_ACRONYM, ID_A, ID_IMG, ID_APPLET, ID_OBJECT, ID_EMBED, ID_FONT, ID_BASEFONT, ID_BR, ID_SCRIPT, ID_MAP, ID_Q, ID_SUB, ID_SUP, ID_SPAN, ID_BDO, ID_IFRAME, ID_INPUT, ID_SELECT, ID_TEXTAREA, ID_LABEL, ID_BUTTON, ID_COMMENT, 0};static const ushort tag_list_1[] = { ID_P, ID_H1, ID_H2, ID_H3, ID_H4, ID_H5, ID_H6, ID_UL, ID_OL, ID_DIR, ID_MENU, ID_PRE, ID_DL, ID_DIV, ID_CENTER, ID_NOSCRIPT, ID_NOFRAMES, ID_BLOCKQUOTE, ID_FORM, ID_ISINDEX, ID_HR, ID_TABLE, ID_FIELDSET, ID_ADDRESS, ID_TEXT, ID_TT, ID_I, ID_B, ID_U, ID_S, ID_STRIKE, ID_BIG, ID_SMALL, ID_EM, ID_STRONG, ID_DFN, ID_CODE, ID_SAMP, ID_KBD, ID_VAR, ID_CITE, ID_ABBR, ID_ACRONYM, ID_A, ID_IMG, ID_APPLET, ID_OBJECT, ID_EMBED, ID_FONT, ID_BASEFONT, ID_BR, ID_SCRIPT, ID_MAP, ID_Q, ID_SUB, ID_SUP, ID_SPAN, ID_BDO, ID_IFRAME, ID_INPUT, ID_SELECT, ID_TEXTAREA, ID_LABEL, ID_BUTTON, ID_COMMENT, ID_LI, 0};static const ushort tag_list_2[] = { ID_INS, ID_DEL, ID_COMMENT, 0};static const ushort tag_list_3[] = { ID_P, ID_H1, ID_H2, ID_H3, ID_H4, ID_H5, ID_H6, ID_UL, ID_OL, ID_DIR, ID_MENU, ID_PRE, ID_DL, ID_DIV, ID_CENTER, ID_NOSCRIPT, ID_NOFRAMES, ID_BLOCKQUOTE, ID_FORM, ID_ISINDEX, ID_HR, ID_TABLE, ID_FIELDSET, ID_ADDRESS, ID_COMMENT, ID_LI, 0};static const ushort tag_list_4[] = { ID_PARAM, ID_P, ID_H1, ID_H2, ID_H3, ID_H4, ID_H5, ID_H6, ID_UL, ID_OL, ID_DIR, ID_MENU, ID_PRE, ID_DL, ID_DIV, ID_CENTER, ID_NOSCRIPT, ID_NOFRAMES, ID_BLOCKQUOTE, ID_FORM, ID_ISINDEX, ID_HR, ID_TABLE, ID_FIELDSET, ID_ADDRESS, ID_TEXT, ID_TT, ID_I, ID_B, ID_U, ID_S, ID_STRIKE, ID_BIG, ID_SMALL, ID_EM, ID_STRONG, ID_DFN, ID_CODE, ID_SAMP, ID_KBD, ID_VAR, ID_CITE, ID_ABBR, ID_ACRONYM, ID_A, ID_IMG, ID_APPLET, ID_OBJECT, ID_EMBED, ID_FONT, ID_BASEFONT, ID_BR, ID_SCRIPT, ID_MAP, ID_Q, ID_SUB, ID_SUP, ID_SPAN, ID_BDO, ID_IFRAME, ID_INPUT, ID_SELECT, ID_TEXTAREA, ID_LABEL, ID_BUTTON, ID_COMMENT, ID_LI, 0};static const ushort tag_list_6[] = { ID_DT, ID_DD, ID_COMMENT, 0};static const ushort tag_list_7[] = { ID_OPTGROUP, ID_OPTION, ID_COMMENT, ID_SCRIPT, 0};static const ushort tag_list_9[] = { ID_TH, ID_TD, ID_COMMENT, 0};static const ushort tag_list_10[] = { ID_FRAMESET, ID_FRAME, ID_COMMENT, 0};static const ushort tag_list_11[] = { ID_SCRIPT, ID_STYLE, ID_META, ID_LINK, ID_OBJECT, ID_EMBED, ID_COMMENT, 0};bool check_array(ushort child, const ushort *tagList){ int i = 0; while(tagList[i] != 0) { if(tagList[i] == child) return true; i++; } return false;}bool DOM::checkChild(ushort tagID, ushort childID){ //kdDebug( 6030 ) << "checkChild: " << tagID << "/" << childID << endl; // ### allow comments inside ANY node that can contain children switch(tagID) { case ID_TT: case ID_I: case ID_B: case ID_U: 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_CITE: case ID_ABBR: case ID_ACRONYM: case ID_SUB: case ID_SUP: case ID_SPAN: case ID_BDO: case ID_FONT: case ID_P: case ID_H1: case ID_H2: case ID_H3: case ID_H4: case ID_H5: case ID_H6: case ID_Q: case ID_LEGEND: case ID_CAPTION: // _0 * return check_array(childID, tag_list_0); case ID_BASEFONT: case ID_BR: case ID_AREA: case ID_LINK: case ID_IMG: case ID_PARAM: case ID_HR: case ID_INPUT: case ID_COL: case ID_FRAME: case ID_ISINDEX: case ID_BASE: case ID_META: case ID_COMMENT: // BASEFONT: EMPTY return false; case ID_BODY: // BODY: _1 * + _2 if( check_array(childID, tag_list_1) ) return true; return check_array(childID, tag_list_2); case ID_ADDRESS: // ADDRESS: ( _0 | P ) * if( check_array(childID, tag_list_0) ) return true; return (childID == ID_P); case ID_LI: case ID_DT: case ID_DIV: case ID_CENTER: case ID_BLOCKQUOTE: case ID_INS: case ID_DEL: case ID_DD: case ID_TH: case ID_TD: case ID_IFRAME: case ID_NOFRAMES: case ID_NOSCRIPT: //case ID_FONT: // DIV: _1 * return check_array(childID, tag_list_1); case ID_A: // A: _0 * - A if( check_array(childID, tag_list_0) ) return true; if( check_array(childID, tag_list_3) ) return true; if( childID == ID_ADDRESS ) return true; return false; case ID_MAP: // MAP: ( _3 + | AREA + ) if( check_array(childID, tag_list_3) ) return true; return (childID == ID_AREA); case ID_OBJECT: case ID_EMBED: case ID_APPLET: // OBJECT: _4 * return check_array(childID, tag_list_4); case ID_PRE: // PRE: _0 * - _5 return check_array(childID, tag_list_1); case ID_DL: // DL: _6 +
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -