1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/parser/html/nsHtml5TreeBuilderHSupplement.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,226 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#define NS_HTML5_TREE_BUILDER_HANDLE_ARRAY_LENGTH 512 1.9 + 1.10 + private: 1.11 + nsHtml5OplessBuilder* mBuilder; 1.12 + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1.13 + // If mBuilder is not null, the tree op machinery is not in use and 1.14 + // the fields below aren't in use, either. 1.15 + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1.16 + nsHtml5Highlighter* mViewSource; 1.17 + nsTArray<nsHtml5TreeOperation> mOpQueue; 1.18 + nsTArray<nsHtml5SpeculativeLoad> mSpeculativeLoadQueue; 1.19 + nsAHtml5TreeOpSink* mOpSink; 1.20 + nsAutoArrayPtr<nsIContent*> mHandles; 1.21 + int32_t mHandlesUsed; 1.22 + nsTArray<nsAutoArrayPtr<nsIContent*> > mOldHandles; 1.23 + nsHtml5TreeOpStage* mSpeculativeLoadStage; 1.24 + bool mCurrentHtmlScriptIsAsyncOrDefer; 1.25 + bool mPreventScriptExecution; 1.26 +#ifdef DEBUG 1.27 + bool mActive; 1.28 +#endif 1.29 + 1.30 + // DocumentModeHandler 1.31 + /** 1.32 + * Tree builder uses this to report quirkiness of the document 1.33 + */ 1.34 + void documentMode(nsHtml5DocumentMode m); 1.35 + 1.36 + nsIContentHandle* getDocumentFragmentForTemplate(nsIContentHandle* aTemplate); 1.37 + 1.38 + nsIContentHandle* getFormPointerForContext(nsIContentHandle* aContext); 1.39 + 1.40 + /** 1.41 + * Using nsIContent** instead of nsIContent* is the parser deals with DOM 1.42 + * nodes in a way that works off the main thread. Non-main-thread code 1.43 + * can't refcount or otherwise touch nsIContent objects in any way. 1.44 + * Yet, the off-the-main-thread code needs to have a way to hold onto a 1.45 + * particular node and repeatedly operate on the same node. 1.46 + * 1.47 + * The way this works is that the off-the-main-thread code has an 1.48 + * nsIContent** for each DOM node and a given nsIContent** is only ever 1.49 + * actually dereferenced into an actual nsIContent* on the main thread. 1.50 + * When the off-the-main-thread code requests a new node, it gets an 1.51 + * nsIContent** immediately and a tree op is enqueued for later allocating 1.52 + * an actual nsIContent object and writing a pointer to it into the memory 1.53 + * location pointed to by the nsIContent**. 1.54 + * 1.55 + * Since tree ops are in a queue, the node creating tree op will always 1.56 + * run before tree ops that try to further operate on the node that the 1.57 + * nsIContent** is a handle to. 1.58 + * 1.59 + * On-the-main-thread parts of the parser use nsIContent* instead of 1.60 + * nsIContent**. Since both cases share the same parser core, the parser 1.61 + * core casts both to nsIContentHandle*. 1.62 + */ 1.63 + nsIContentHandle* AllocateContentHandle(); 1.64 + 1.65 + void accumulateCharactersForced(const char16_t* aBuf, int32_t aStart, int32_t aLength) 1.66 + { 1.67 + accumulateCharacters(aBuf, aStart, aLength); 1.68 + } 1.69 + 1.70 + void MarkAsBrokenAndRequestSuspension(nsresult aRv) 1.71 + { 1.72 + mBuilder->MarkAsBroken(aRv); 1.73 + requestSuspension(); 1.74 + } 1.75 + 1.76 + public: 1.77 + 1.78 + nsHtml5TreeBuilder(nsHtml5OplessBuilder* aBuilder); 1.79 + 1.80 + nsHtml5TreeBuilder(nsAHtml5TreeOpSink* aOpSink, 1.81 + nsHtml5TreeOpStage* aStage); 1.82 + 1.83 + ~nsHtml5TreeBuilder(); 1.84 + 1.85 + void StartPlainTextViewSource(const nsAutoString& aTitle); 1.86 + 1.87 + void StartPlainText(); 1.88 + 1.89 + void StartPlainTextBody(); 1.90 + 1.91 + bool HasScript(); 1.92 + 1.93 + void SetOpSink(nsAHtml5TreeOpSink* aOpSink) 1.94 + { 1.95 + mOpSink = aOpSink; 1.96 + } 1.97 + 1.98 + void ClearOps() 1.99 + { 1.100 + mOpQueue.Clear(); 1.101 + } 1.102 + 1.103 + bool Flush(bool aDiscretionary = false); 1.104 + 1.105 + void FlushLoads(); 1.106 + 1.107 + void SetDocumentCharset(nsACString& aCharset, int32_t aCharsetSource); 1.108 + 1.109 + void StreamEnded(); 1.110 + 1.111 + void NeedsCharsetSwitchTo(const nsACString& aEncoding, 1.112 + int32_t aSource, 1.113 + int32_t aLineNumber); 1.114 + 1.115 + void MaybeComplainAboutCharset(const char* aMsgId, 1.116 + bool aError, 1.117 + int32_t aLineNumber); 1.118 + 1.119 + void AddSnapshotToScript(nsAHtml5TreeBuilderState* aSnapshot, int32_t aLine); 1.120 + 1.121 + void DropHandles(); 1.122 + 1.123 + void SetPreventScriptExecution(bool aPrevent) 1.124 + { 1.125 + mPreventScriptExecution = aPrevent; 1.126 + } 1.127 + 1.128 + bool HasBuilder() 1.129 + { 1.130 + return mBuilder; 1.131 + } 1.132 + 1.133 + void EnableViewSource(nsHtml5Highlighter* aHighlighter); 1.134 + 1.135 + void errStrayStartTag(nsIAtom* aName); 1.136 + 1.137 + void errStrayEndTag(nsIAtom* aName); 1.138 + 1.139 + void errUnclosedElements(int32_t aIndex, nsIAtom* aName); 1.140 + 1.141 + void errUnclosedElementsImplied(int32_t aIndex, nsIAtom* aName); 1.142 + 1.143 + void errUnclosedElementsCell(int32_t aIndex); 1.144 + 1.145 + void errStrayDoctype(); 1.146 + 1.147 + void errAlmostStandardsDoctype(); 1.148 + 1.149 + void errQuirkyDoctype(); 1.150 + 1.151 + void errNonSpaceInTrailer(); 1.152 + 1.153 + void errNonSpaceAfterFrameset(); 1.154 + 1.155 + void errNonSpaceInFrameset(); 1.156 + 1.157 + void errNonSpaceAfterBody(); 1.158 + 1.159 + void errNonSpaceInColgroupInFragment(); 1.160 + 1.161 + void errNonSpaceInNoscriptInHead(); 1.162 + 1.163 + void errFooBetweenHeadAndBody(nsIAtom* aName); 1.164 + 1.165 + void errStartTagWithoutDoctype(); 1.166 + 1.167 + void errNoSelectInTableScope(); 1.168 + 1.169 + void errStartSelectWhereEndSelectExpected(); 1.170 + 1.171 + void errStartTagWithSelectOpen(nsIAtom* aName); 1.172 + 1.173 + void errBadStartTagInHead(nsIAtom* aName); 1.174 + 1.175 + void errImage(); 1.176 + 1.177 + void errIsindex(); 1.178 + 1.179 + void errFooSeenWhenFooOpen(nsIAtom* aName); 1.180 + 1.181 + void errHeadingWhenHeadingOpen(); 1.182 + 1.183 + void errFramesetStart(); 1.184 + 1.185 + void errNoCellToClose(); 1.186 + 1.187 + void errStartTagInTable(nsIAtom* aName); 1.188 + 1.189 + void errFormWhenFormOpen(); 1.190 + 1.191 + void errTableSeenWhileTableOpen(); 1.192 + 1.193 + void errStartTagInTableBody(nsIAtom* aName); 1.194 + 1.195 + void errEndTagSeenWithoutDoctype(); 1.196 + 1.197 + void errEndTagAfterBody(); 1.198 + 1.199 + void errEndTagSeenWithSelectOpen(nsIAtom* aName); 1.200 + 1.201 + void errGarbageInColgroup(); 1.202 + 1.203 + void errEndTagBr(); 1.204 + 1.205 + void errNoElementToCloseButEndTagSeen(nsIAtom* aName); 1.206 + 1.207 + void errHtmlStartTagInForeignContext(nsIAtom* aName); 1.208 + 1.209 + void errTableClosedWhileCaptionOpen(); 1.210 + 1.211 + void errNoTableRowToClose(); 1.212 + 1.213 + void errNonSpaceInTable(); 1.214 + 1.215 + void errUnclosedChildrenInRuby(); 1.216 + 1.217 + void errStartTagSeenWithoutRuby(nsIAtom* aName); 1.218 + 1.219 + void errSelfClosing(); 1.220 + 1.221 + void errNoCheckUnclosedElementsOnStack(); 1.222 + 1.223 + void errEndTagDidNotMatchCurrentOpenElement(nsIAtom* aName, nsIAtom* aOther); 1.224 + 1.225 + void errEndTagViolatesNestingRules(nsIAtom* aName); 1.226 + 1.227 + void errEndWithUnclosedElements(nsIAtom* aName); 1.228 + 1.229 + void MarkAsBroken(nsresult aRv);