Bug 436663. Work around ATSUI crasher caused by long Hebrew sequence. r=roc, sr=vlad
[wine-gecko.git] / parser / htmlparser / src / nsElementTable.h
blob5665d26c1f4fad07b483d136e4c86a96d6f85118
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 /**
40 * MODULE NOTES:
41 * @update gess 4/1/98
47 #ifndef _NSELEMENTABLE
48 #define _NSELEMENTABLE
50 #include "nsHTMLTokens.h"
51 #include "nsDTDUtils.h"
54 //*********************************************************************************************
55 // The following ints define the standard groups of HTML elements...
56 //*********************************************************************************************
58 static const int kNone= 0x0;
60 static const int kHTMLContent = 0x0001; // HEAD, (FRAMESET | BODY)
61 static const int kHeadContent = 0x0002; // Elements that *must* be in the head.
62 static const int kHeadMisc = 0x0004; // Elements that *can* be in the head.
64 static const int kSpecial = 0x0008; // A, IMG, APPLET, OBJECT, FONT, BASEFONT, BR, SCRIPT,
65 // MAP, Q, SUB, SUP, SPAN, BDO, IFRAME
67 static const int kFormControl = 0x0010; // INPUT SELECT TEXTAREA LABEL BUTTON
68 static const int kPreformatted = 0x0020; // PRE
69 static const int kPreExclusion = 0x0040; // IMG, OBJECT, APPLET, BIG, SMALL, SUB, SUP, FONT, BASEFONT
70 static const int kFontStyle = 0x0080; // TT, I, B, U, S, STRIKE, BIG, SMALL, BLINK
71 static const int kPhrase = 0x0100; // EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ABBR, ACRONYM
72 static const int kHeading = 0x0200; // H1..H6
73 static const int kBlockMisc = 0x0400; // OBJECT, SCRIPT
74 static const int kBlock = 0x0800; // ADDRESS, BLOCKQUOTE, CENTER, DIV, DL, FIELDSET, FORM,
75 // ISINDEX, HR, NOSCRIPT, NOFRAMES, P, TABLE
76 static const int kList = 0x1000; // UL, OL, DIR, MENU
77 static const int kPCDATA = 0x2000; // plain text and entities...
78 static const int kSelf = 0x4000; // whatever THIS tag is...
79 static const int kExtensions = 0x8000; // BGSOUND, WBR, NOBR
80 static const int kTable = 0x10000;// TR,TD,THEAD,TBODY,TFOOT,CAPTION,TH
81 static const int kDLChild = 0x20000;// DL, DT
82 static const int kCDATA = 0x40000;// just plain text...
84 static const int kInlineEntity = (kPCDATA|kFontStyle|kPhrase|kSpecial|kFormControl|kExtensions); // #PCDATA, %fontstyle, %phrase, %special, %formctrl
85 static const int kBlockEntity = (kHeading|kList|kPreformatted|kBlock); // %heading, %list, %preformatted, %block
86 static const int kFlowEntity = (kBlockEntity|kInlineEntity); // %blockentity, %inlineentity
87 static const int kAllTags = 0xffffff;
90 //*********************************************************************************************
91 // The following ints define the standard groups of HTML elements...
92 //*********************************************************************************************
95 #ifdef NS_DEBUG
96 extern void CheckElementTable();
97 #endif
99 typedef PRBool (*ContainFunc)(eHTMLTags aTag,nsDTDContext &aContext);
103 * We're asking the question: is aTest a member of bitset.
105 * @update gess 01/04/99
106 * @param
107 * @return TRUE or FALSE
109 inline PRBool TestBits(int aBitset,int aTest) {
110 if(aTest) {
111 PRInt32 result=(aBitset & aTest);
112 return PRBool(result==aTest);
114 return PR_FALSE;
120 * @update gess 01/04/99
121 * @param
122 * @return
124 struct nsHTMLElement {
126 #ifdef DEBUG
127 static void DebugDumpMembership(const char* aFilename);
128 static void DebugDumpContainment(const char* aFilename,const char* aTitle);
129 static void DebugDumpContainType(const char* aFilename);
130 #endif
132 static PRBool IsInlineEntity(eHTMLTags aTag);
133 static PRBool IsFlowEntity(eHTMLTags aTag);
134 static PRBool IsBlockCloser(eHTMLTags aTag);
136 inline PRBool IsBlock(void) const {
137 if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
138 return TestBits(mParentBits,kBlock);
140 return PR_FALSE;
143 inline PRBool IsBlockEntity(void) const {
144 if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
145 return TestBits(mParentBits,kBlockEntity);
147 return PR_FALSE;
150 inline PRBool IsSpecialEntity(void) const {
151 if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
152 return TestBits(mParentBits,kSpecial);
154 return PR_FALSE;
157 inline PRBool IsPhraseEntity(void) const {
158 if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
159 return TestBits(mParentBits,kPhrase);
161 return PR_FALSE;
164 inline PRBool IsFontStyleEntity(void) const {
165 if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
166 return TestBits(mParentBits,kFontStyle);
168 return PR_FALSE;
171 inline PRBool IsTableElement(void) const { //return yes if it's a table or child of a table...
172 PRBool result=PR_FALSE;
174 switch(mTagID) {
175 case eHTMLTag_table:
176 case eHTMLTag_thead:
177 case eHTMLTag_tbody:
178 case eHTMLTag_tfoot:
179 case eHTMLTag_caption:
180 case eHTMLTag_tr:
181 case eHTMLTag_td:
182 case eHTMLTag_th:
183 case eHTMLTag_col:
184 case eHTMLTag_colgroup:
185 result=PR_TRUE;
186 break;
187 default:
188 result=PR_FALSE;
190 return result;
194 static PRInt32 GetIndexOfChildOrSynonym(nsDTDContext& aContext,eHTMLTags aChildTag);
196 const TagList* GetSynonymousTags(void) const {return mSynonymousTags;}
197 const TagList* GetRootTags(void) const {return mRootNodes;}
198 const TagList* GetEndRootTags(void) const {return mEndRootNodes;}
199 const TagList* GetAutoCloseStartTags(void) const {return mAutocloseStart;}
200 const TagList* GetAutoCloseEndTags(void) const {return mAutocloseEnd;}
201 eHTMLTags GetCloseTargetForEndTag(nsDTDContext& aContext,PRInt32 anIndex,nsDTDMode aMode) const;
203 const TagList* GetSpecialChildren(void) const {return mSpecialKids;}
204 const TagList* GetSpecialParents(void) const {return mSpecialParents;}
206 PRBool IsMemberOf(PRInt32 aType) const;
207 PRBool ContainsSet(PRInt32 aType) const;
208 PRBool CanContainType(PRInt32 aType) const;
210 eHTMLTags GetTag(void) const {return mTagID;}
211 PRBool CanContain(eHTMLTags aChild,nsDTDMode aMode) const;
212 PRBool CanExclude(eHTMLTags aChild) const;
213 PRBool CanOmitStartTag(eHTMLTags aChild) const;
214 PRBool CanOmitEndTag(void) const;
215 PRBool CanContainSelf(void) const;
216 PRBool CanAutoCloseTag(nsDTDContext& aContext,PRInt32 aIndex,eHTMLTags aTag) const;
217 PRBool HasSpecialProperty(PRInt32 aProperty) const;
218 PRBool IsSpecialParent(eHTMLTags aTag) const;
219 PRBool IsExcludableParent(eHTMLTags aParent) const;
220 PRBool SectionContains(eHTMLTags aTag,PRBool allowDepthSearch) const;
221 PRBool ShouldVerifyHierarchy() const;
223 PRBool CanBeContained(eHTMLTags aParentTag,nsDTDContext &aContext) const; //default version
225 static PRBool CanContain(eHTMLTags aParent,eHTMLTags aChild,nsDTDMode aMode);
226 static PRBool IsContainer(eHTMLTags aTag) ;
227 static PRBool IsResidualStyleTag(eHTMLTags aTag) ;
228 static PRBool IsTextTag(eHTMLTags aTag);
229 static PRBool IsWhitespaceTag(eHTMLTags aTag);
231 static PRBool IsBlockParent(eHTMLTags aTag);
232 static PRBool IsInlineParent(eHTMLTags aTag);
233 static PRBool IsFlowParent(eHTMLTags aTag);
234 static PRBool IsSectionTag(eHTMLTags aTag);
235 static PRBool IsChildOfHead(eHTMLTags aTag,PRBool& aExclusively) ;
237 eHTMLTags mTagID;
238 eHTMLTags mRequiredAncestor;
239 eHTMLTags mExcludingAncestor; //If set, the presence of the excl-ancestor prevents this from opening.
240 const TagList* mRootNodes; //These are the tags above which you many not autoclose a START tag
241 const TagList* mEndRootNodes; //These are the tags above which you many not autoclose an END tag
242 const TagList* mAutocloseStart; //these are the start tags that you can automatically close with this START tag
243 const TagList* mAutocloseEnd; //these are the start tags that you can automatically close with this END tag
244 const TagList* mSynonymousTags; //These are morally equivalent; an end tag for one can close a start tag for another (like <Hn>)
245 const TagList* mExcludableParents; //These are the TAGS that cannot contain you
246 int mParentBits; //defines groups that can contain this element
247 int mInclusionBits; //defines parental and containment rules
248 int mExclusionBits; //defines things you CANNOT contain
249 int mSpecialProperties; //used for various special purposes...
250 PRUint32 mPropagateRange; //tells us how far a parent is willing to prop. badly formed children
251 const TagList* mSpecialParents; //These are the special tags that contain this tag (directly)
252 const TagList* mSpecialKids; //These are the extra things you can contain
253 eHTMLTags mSkipTarget; //If set, then we skip all content until this tag is seen
254 ContainFunc mCanBeContained;
257 extern const nsHTMLElement gHTMLElements[];
259 //special property bits...
260 static const int kPreferBody = 0x0001; //this kHeadMisc tag prefers to be in the body if there isn't an explicit <head>
261 static const int kOmitEndTag = 0x0002; //safely ignore end tag
262 static const int kLegalOpen = 0x0004; //Lets BODY, TITLE, SCRIPT to reopen
263 static const int kNoPropagate = 0x0008; //If set, this tag won't propagate as a child
264 static const int kBadContentWatch = 0x0010;
266 static const int kNoStyleLeaksIn = 0x0020;
267 static const int kNoStyleLeaksOut = 0x0040;
269 static const int kMustCloseSelf = 0x0080;
270 static const int kSaveMisplaced = 0x0100; //If set, then children this tag can't contain are pushed onto the misplaced stack
271 static const int kNonContainer = 0x0200; //If set, then this tag is not a container.
272 static const int kHandleStrayTag = 0x0400; //If set, we automatically open a start tag
273 static const int kRequiresBody = 0x0800; //If set, then in case of no BODY one will be opened up immediately.
274 static const int kVerifyHierarchy = 0x1000; //If set, check to see if the tag is a child or a sibling..
275 static const int kPreferHead = 0x2000; //This kHeadMisc tag prefers to be in the head if there isn't an explicit <body>
277 #endif