Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / parser / html / nsHtml5TreeOperation.h
blob133ec8e70d84bda390ffe09d69024dfcc904fd8c
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsHtml5TreeOperation_h
6 #define nsHtml5TreeOperation_h
8 #include "nsHtml5DocumentMode.h"
9 #include "nsHtml5HtmlAttributes.h"
10 #include "mozilla/dom/FromParser.h"
11 #include "mozilla/dom/ShadowRootBinding.h"
12 #include "mozilla/NotNull.h"
13 #include "mozilla/Variant.h"
14 #include "nsCharsetSource.h"
16 class nsIContent;
17 class nsHtml5TreeOpExecutor;
18 class nsHtml5DocumentBuilder;
19 namespace mozilla {
20 class Encoding;
22 namespace dom {
23 class Text;
24 } // namespace dom
25 } // namespace mozilla
27 struct uninitialized {};
29 // main HTML5 ops
30 struct opDetach {
31 nsIContent** mElement;
33 explicit opDetach(nsIContentHandle* aElement) {
34 mElement = static_cast<nsIContent**>(aElement);
38 struct opAppend {
39 nsIContent** mChild;
40 nsIContent** mParent;
41 mozilla::dom::FromParser mFromNetwork;
43 explicit opAppend(nsIContentHandle* aChild, nsIContentHandle* aParent,
44 mozilla::dom::FromParser aFromNetwork)
45 : mFromNetwork(aFromNetwork) {
46 mChild = static_cast<nsIContent**>(aChild);
47 mParent = static_cast<nsIContent**>(aParent);
51 struct opAppendChildrenToNewParent {
52 nsIContent** mOldParent;
53 nsIContent** mNewParent;
55 explicit opAppendChildrenToNewParent(nsIContentHandle* aOldParent,
56 nsIContentHandle* aNewParent) {
57 mOldParent = static_cast<nsIContent**>(aOldParent);
58 mNewParent = static_cast<nsIContent**>(aNewParent);
62 struct opFosterParent {
63 nsIContent** mChild;
64 nsIContent** mStackParent;
65 nsIContent** mTable;
67 explicit opFosterParent(nsIContentHandle* aChild,
68 nsIContentHandle* aStackParent,
69 nsIContentHandle* aTable) {
70 mChild = static_cast<nsIContent**>(aChild);
71 mStackParent = static_cast<nsIContent**>(aStackParent);
72 mTable = static_cast<nsIContent**>(aTable);
76 struct opAppendToDocument {
77 nsIContent** mContent;
79 explicit opAppendToDocument(nsIContentHandle* aContent) {
80 mContent = static_cast<nsIContent**>(aContent);
84 struct opAddAttributes {
85 nsIContent** mElement;
86 nsHtml5HtmlAttributes* mAttributes;
88 explicit opAddAttributes(nsIContentHandle* aElement,
89 nsHtml5HtmlAttributes* aAttributes)
90 : mAttributes(aAttributes) {
91 mElement = static_cast<nsIContent**>(aElement);
95 struct opCreateHTMLElement {
96 nsIContent** mContent;
97 nsAtom* mName;
98 nsHtml5HtmlAttributes* mAttributes;
99 mozilla::dom::HTMLContentCreatorFunction mCreator;
100 nsIContent** mIntendedParent;
101 mozilla::dom::FromParser mFromNetwork;
103 explicit opCreateHTMLElement(
104 nsIContentHandle* aContent, nsAtom* aName,
105 nsHtml5HtmlAttributes* aAttributes,
106 mozilla::dom::HTMLContentCreatorFunction aCreator,
107 nsIContentHandle* aIntendedParent, mozilla::dom::FromParser mFromNetwork)
108 : mName(aName),
109 mAttributes(aAttributes),
110 mCreator(aCreator),
111 mFromNetwork(mFromNetwork) {
112 mContent = static_cast<nsIContent**>(aContent);
113 mIntendedParent = static_cast<nsIContent**>(aIntendedParent);
114 aName->AddRef();
115 if (mAttributes == nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES) {
116 mAttributes = nullptr;
121 struct opCreateSVGElement {
122 nsIContent** mContent;
123 nsAtom* mName;
124 nsHtml5HtmlAttributes* mAttributes;
125 mozilla::dom::SVGContentCreatorFunction mCreator;
126 nsIContent** mIntendedParent;
127 mozilla::dom::FromParser mFromNetwork;
129 explicit opCreateSVGElement(nsIContentHandle* aContent, nsAtom* aName,
130 nsHtml5HtmlAttributes* aAttributes,
131 mozilla::dom::SVGContentCreatorFunction aCreator,
132 nsIContentHandle* aIntendedParent,
133 mozilla::dom::FromParser mFromNetwork)
134 : mName(aName),
135 mAttributes(aAttributes),
136 mCreator(aCreator),
137 mFromNetwork(mFromNetwork) {
138 mContent = static_cast<nsIContent**>(aContent);
139 mIntendedParent = static_cast<nsIContent**>(aIntendedParent);
140 aName->AddRef();
141 if (mAttributes == nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES) {
142 mAttributes = nullptr;
147 struct opCreateMathMLElement {
148 nsIContent** mContent;
149 nsAtom* mName;
150 nsHtml5HtmlAttributes* mAttributes;
151 nsIContent** mIntendedParent;
153 explicit opCreateMathMLElement(nsIContentHandle* aContent, nsAtom* aName,
154 nsHtml5HtmlAttributes* aAttributes,
155 nsIContentHandle* aIntendedParent)
156 : mName(aName), mAttributes(aAttributes) {
157 mContent = static_cast<nsIContent**>(aContent);
158 mIntendedParent = static_cast<nsIContent**>(aIntendedParent);
159 aName->AddRef();
160 if (mAttributes == nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES) {
161 mAttributes = nullptr;
166 struct opSetFormElement {
167 nsIContent** mContent;
168 nsIContent** mFormElement;
169 nsIContent** mIntendedParent;
171 explicit opSetFormElement(nsIContentHandle* aContent,
172 nsIContentHandle* aFormElement,
173 nsIContentHandle* aIntendedParent) {
174 mContent = static_cast<nsIContent**>(aContent);
175 mFormElement = static_cast<nsIContent**>(aFormElement);
176 mIntendedParent = static_cast<nsIContent**>(aIntendedParent);
180 struct opAppendText {
181 nsIContent** mParent;
182 char16_t* mBuffer;
183 int32_t mLength;
185 explicit opAppendText(nsIContentHandle* aParent, char16_t* aBuffer,
186 int32_t aLength)
187 : mBuffer(aBuffer), mLength(aLength) {
188 mParent = static_cast<nsIContent**>(aParent);
192 struct opFosterParentText {
193 nsIContent** mStackParent;
194 char16_t* mBuffer;
195 nsIContent** mTable;
196 int32_t mLength;
198 explicit opFosterParentText(nsIContentHandle* aStackParent, char16_t* aBuffer,
199 nsIContentHandle* aTable, int32_t aLength)
200 : mBuffer(aBuffer), mLength(aLength) {
201 mStackParent = static_cast<nsIContent**>(aStackParent);
202 mTable = static_cast<nsIContent**>(aTable);
206 struct opAppendComment {
207 nsIContent** mParent;
208 char16_t* mBuffer;
209 int32_t mLength;
211 explicit opAppendComment(nsIContentHandle* aParent, char16_t* aBuffer,
212 int32_t aLength)
213 : mBuffer(aBuffer), mLength(aLength) {
214 mParent = static_cast<nsIContent**>(aParent);
218 struct opAppendCommentToDocument {
219 char16_t* mBuffer;
220 int32_t mLength;
222 explicit opAppendCommentToDocument(char16_t* aBuffer, int32_t aLength)
223 : mBuffer(aBuffer), mLength(aLength) {};
226 class nsHtml5TreeOperationStringPair {
227 private:
228 nsString mPublicId;
229 nsString mSystemId;
231 public:
232 nsHtml5TreeOperationStringPair(const nsAString& aPublicId,
233 const nsAString& aSystemId)
234 : mPublicId(aPublicId), mSystemId(aSystemId) {
235 MOZ_COUNT_CTOR(nsHtml5TreeOperationStringPair);
238 ~nsHtml5TreeOperationStringPair() {
239 MOZ_COUNT_DTOR(nsHtml5TreeOperationStringPair);
242 inline void Get(nsAString& aPublicId, nsAString& aSystemId) {
243 aPublicId.Assign(mPublicId);
244 aSystemId.Assign(mSystemId);
248 struct opAppendDoctypeToDocument {
249 nsAtom* mName;
250 nsHtml5TreeOperationStringPair* mStringPair;
252 explicit opAppendDoctypeToDocument(nsAtom* aName, const nsAString& aPublicId,
253 const nsAString& aSystemId) {
254 mName = aName;
255 aName->AddRef();
256 mStringPair = new nsHtml5TreeOperationStringPair(aPublicId, aSystemId);
260 struct opGetDocumentFragmentForTemplate {
261 nsIContent** mTemplate;
262 nsIContent** mFragHandle;
264 explicit opGetDocumentFragmentForTemplate(nsIContentHandle* aTemplate,
265 nsIContentHandle* aFragHandle) {
266 mTemplate = static_cast<nsIContent**>(aTemplate);
267 mFragHandle = static_cast<nsIContent**>(aFragHandle);
271 struct opSetDocumentFragmentForTemplate {
272 nsIContent** mTemplate;
273 nsIContent** mFragment;
275 explicit opSetDocumentFragmentForTemplate(nsIContentHandle* aTemplate,
276 nsIContentHandle* aFragment) {
277 mTemplate = static_cast<nsIContent**>(aTemplate);
278 mFragment = static_cast<nsIContent**>(aFragment);
282 struct opGetShadowRootFromHost {
283 nsIContent** mHost;
284 nsIContent** mFragHandle;
285 nsIContent** mTemplateNode;
286 mozilla::dom::ShadowRootMode mShadowRootMode;
287 bool mShadowRootIsClonable;
288 bool mShadowRootIsSerializable;
289 bool mShadowRootDelegatesFocus;
291 explicit opGetShadowRootFromHost(nsIContentHandle* aHost,
292 nsIContentHandle* aFragHandle,
293 nsIContentHandle* aTemplateNode,
294 mozilla::dom::ShadowRootMode aShadowRootMode,
295 bool aShadowRootIsClonable,
296 bool aShadowRootIsSerializable,
297 bool aShadowRootDelegatesFocus) {
298 mHost = static_cast<nsIContent**>(aHost);
299 mFragHandle = static_cast<nsIContent**>(aFragHandle);
300 mTemplateNode = static_cast<nsIContent**>(aTemplateNode);
301 mShadowRootMode = aShadowRootMode;
302 mShadowRootIsClonable = aShadowRootIsClonable;
303 mShadowRootIsSerializable = aShadowRootIsSerializable;
304 mShadowRootDelegatesFocus = aShadowRootDelegatesFocus;
308 struct opGetFosterParent {
309 nsIContent** mTable;
310 nsIContent** mStackParent;
311 nsIContent** mParentHandle;
313 explicit opGetFosterParent(nsIContentHandle* aTable,
314 nsIContentHandle* aStackParent,
315 nsIContentHandle* aParentHandle) {
316 mTable = static_cast<nsIContent**>(aTable);
317 mStackParent = static_cast<nsIContent**>(aStackParent);
318 mParentHandle = static_cast<nsIContent**>(aParentHandle);
322 // Gecko-specific on-pop ops
323 struct opMarkAsBroken {
324 nsresult mResult;
326 explicit opMarkAsBroken(nsresult aResult) : mResult(aResult) {};
329 struct opRunScriptThatMayDocumentWriteOrBlock {
330 nsIContent** mElement;
331 nsAHtml5TreeBuilderState* mBuilderState;
332 int32_t mLineNumber;
334 explicit opRunScriptThatMayDocumentWriteOrBlock(
335 nsIContentHandle* aElement, nsAHtml5TreeBuilderState* aBuilderState)
336 : mBuilderState(aBuilderState), mLineNumber(0) {
337 mElement = static_cast<nsIContent**>(aElement);
341 struct opRunScriptThatCannotDocumentWriteOrBlock {
342 nsIContent** mElement;
344 explicit opRunScriptThatCannotDocumentWriteOrBlock(
345 nsIContentHandle* aElement) {
346 mElement = static_cast<nsIContent**>(aElement);
350 struct opPreventScriptExecution {
351 nsIContent** mElement;
353 explicit opPreventScriptExecution(nsIContentHandle* aElement) {
354 mElement = static_cast<nsIContent**>(aElement);
358 struct opDoneAddingChildren {
359 nsIContent** mElement;
361 explicit opDoneAddingChildren(nsIContentHandle* aElement) {
362 mElement = static_cast<nsIContent**>(aElement);
366 struct opDoneCreatingElement {
367 nsIContent** mElement;
369 explicit opDoneCreatingElement(nsIContentHandle* aElement) {
370 mElement = static_cast<nsIContent**>(aElement);
374 struct opUpdateCharsetSource {
375 nsCharsetSource mCharsetSource;
377 explicit opUpdateCharsetSource(nsCharsetSource aCharsetSource)
378 : mCharsetSource(aCharsetSource) {};
381 struct opCharsetSwitchTo {
382 const mozilla::Encoding* mEncoding;
383 int32_t mCharsetSource;
384 int32_t mLineNumber;
386 explicit opCharsetSwitchTo(const mozilla::Encoding* aEncoding,
387 int32_t aCharsetSource, int32_t aLineNumber)
388 : mEncoding(aEncoding),
389 mCharsetSource(aCharsetSource),
390 mLineNumber(aLineNumber) {};
393 struct opUpdateStyleSheet {
394 nsIContent** mElement;
396 explicit opUpdateStyleSheet(nsIContentHandle* aElement) {
397 mElement = static_cast<nsIContent**>(aElement);
401 struct opProcessOfflineManifest {
402 char16_t* mUrl;
404 explicit opProcessOfflineManifest(char16_t* aUrl) : mUrl(aUrl) {};
407 struct opMarkMalformedIfScript {
408 nsIContent** mElement;
410 explicit opMarkMalformedIfScript(nsIContentHandle* aElement) {
411 mElement = static_cast<nsIContent**>(aElement);
415 struct opStreamEnded {};
417 struct opSetStyleLineNumber {
418 nsIContent** mContent;
419 int32_t mLineNumber;
421 explicit opSetStyleLineNumber(nsIContentHandle* aContent, int32_t aLineNumber)
422 : mLineNumber(aLineNumber) {
423 mContent = static_cast<nsIContent**>(aContent);
427 struct opSetScriptLineAndColumnNumberAndFreeze {
428 nsIContent** mContent;
429 int32_t mLineNumber;
430 int32_t mColumnNumber;
432 explicit opSetScriptLineAndColumnNumberAndFreeze(nsIContentHandle* aContent,
433 int32_t aLineNumber,
434 int32_t aColumnNumber)
435 : mLineNumber(aLineNumber), mColumnNumber(aColumnNumber) {
436 mContent = static_cast<nsIContent**>(aContent);
440 struct opSvgLoad {
441 nsIContent** mElement;
443 explicit opSvgLoad(nsIContentHandle* aElement) {
444 mElement = static_cast<nsIContent**>(aElement);
448 struct opMaybeComplainAboutCharset {
449 char* mMsgId;
450 bool mError;
451 int32_t mLineNumber;
453 explicit opMaybeComplainAboutCharset(char* aMsgId, bool aError,
454 int32_t aLineNumber)
455 : mMsgId(aMsgId), mError(aError), mLineNumber(aLineNumber) {};
458 struct opMaybeComplainAboutDeepTree {
459 int32_t mLineNumber;
461 explicit opMaybeComplainAboutDeepTree(int32_t aLineNumber)
462 : mLineNumber(aLineNumber) {};
465 struct opAddClass {
466 nsIContent** mElement;
467 char16_t* mClass;
469 explicit opAddClass(nsIContentHandle* aElement, char16_t* aClass)
470 : mClass(aClass) {
471 mElement = static_cast<nsIContent**>(aElement);
475 struct opAddViewSourceHref {
476 nsIContent** mElement;
477 char16_t* mBuffer;
478 int32_t mLength;
480 explicit opAddViewSourceHref(nsIContentHandle* aElement, char16_t* aBuffer,
481 int32_t aLength)
482 : mBuffer(aBuffer), mLength(aLength) {
483 mElement = static_cast<nsIContent**>(aElement);
487 struct opAddViewSourceBase {
488 char16_t* mBuffer;
489 int32_t mLength;
491 explicit opAddViewSourceBase(char16_t* aBuffer, int32_t aLength)
492 : mBuffer(aBuffer), mLength(aLength) {};
495 struct opAddErrorType {
496 nsIContent** mElement;
497 char* mMsgId;
498 nsAtom* mName;
499 nsAtom* mOther;
501 explicit opAddErrorType(nsIContentHandle* aElement, char* aMsgId,
502 nsAtom* aName = nullptr, nsAtom* aOther = nullptr)
503 : mMsgId(aMsgId), mName(aName), mOther(aOther) {
504 mElement = static_cast<nsIContent**>(aElement);
505 if (aName) {
506 aName->AddRef();
508 if (aOther) {
509 aOther->AddRef();
514 struct opShallowCloneInto {
515 nsIContent** mSrc;
516 nsIContent** mDst;
517 nsIContent** mIntendedParent;
518 mozilla::dom::FromParser mFromParser;
520 opShallowCloneInto(nsIContentHandle* aSrc, nsIContentHandle* aDst,
521 nsIContentHandle* aIntendedParent,
522 mozilla::dom::FromParser aFromParser)
523 : mFromParser(aFromParser) {
524 mSrc = static_cast<nsIContent**>(aSrc);
525 mDst = static_cast<nsIContent**>(aDst);
526 mIntendedParent = static_cast<nsIContent**>(aIntendedParent);
530 struct opAddLineNumberId {
531 nsIContent** mElement;
532 int32_t mLineNumber;
534 explicit opAddLineNumberId(nsIContentHandle* aElement, int32_t aLineNumber)
535 : mLineNumber(aLineNumber) {
536 mElement = static_cast<nsIContent**>(aElement);
540 struct opStartLayout {};
542 struct opEnableEncodingMenu {};
544 typedef mozilla::Variant<
545 uninitialized,
546 // main HTML5 ops
547 opAppend, opDetach, opAppendChildrenToNewParent, opFosterParent,
548 opAppendToDocument, opAddAttributes, nsHtml5DocumentMode,
549 opCreateHTMLElement, opCreateSVGElement, opCreateMathMLElement,
550 opSetFormElement, opAppendText, opFosterParentText, opAppendComment,
551 opAppendCommentToDocument, opAppendDoctypeToDocument,
552 opGetDocumentFragmentForTemplate, opSetDocumentFragmentForTemplate,
553 opGetShadowRootFromHost, opGetFosterParent,
554 // Gecko-specific on-pop ops
555 opMarkAsBroken, opRunScriptThatMayDocumentWriteOrBlock,
556 opRunScriptThatCannotDocumentWriteOrBlock, opPreventScriptExecution,
557 opDoneAddingChildren, opDoneCreatingElement, opUpdateCharsetSource,
558 opCharsetSwitchTo, opUpdateStyleSheet, opProcessOfflineManifest,
559 opMarkMalformedIfScript, opStreamEnded, opSetStyleLineNumber,
560 opSetScriptLineAndColumnNumberAndFreeze, opSvgLoad,
561 opMaybeComplainAboutCharset, opMaybeComplainAboutDeepTree, opAddClass,
562 opAddViewSourceHref, opAddViewSourceBase, opAddErrorType, opAddLineNumberId,
563 opStartLayout, opEnableEncodingMenu, opShallowCloneInto>
564 treeOperation;
566 class nsHtml5TreeOperation final {
567 template <typename T>
568 using NotNull = mozilla::NotNull<T>;
569 using Encoding = mozilla::Encoding;
571 public:
572 static nsresult AppendTextToTextNode(const char16_t* aBuffer,
573 uint32_t aLength,
574 mozilla::dom::Text* aTextNode,
575 nsHtml5DocumentBuilder* aBuilder);
577 static nsresult AppendText(const char16_t* aBuffer, uint32_t aLength,
578 nsIContent* aParent,
579 nsHtml5DocumentBuilder* aBuilder);
581 static nsresult Append(nsIContent* aNode, nsIContent* aParent,
582 nsHtml5DocumentBuilder* aBuilder);
584 static nsresult Append(nsIContent* aNode, nsIContent* aParent,
585 mozilla::dom::FromParser aFromParser,
586 nsHtml5DocumentBuilder* aBuilder);
588 static nsresult AppendToDocument(nsIContent* aNode,
589 nsHtml5DocumentBuilder* aBuilder);
591 static void Detach(nsIContent* aNode, nsHtml5DocumentBuilder* aBuilder);
593 static nsresult AppendChildrenToNewParent(nsIContent* aNode,
594 nsIContent* aParent,
595 nsHtml5DocumentBuilder* aBuilder);
597 static nsresult FosterParent(nsIContent* aNode, nsIContent* aParent,
598 nsIContent* aTable,
599 nsHtml5DocumentBuilder* aBuilder);
601 static nsresult AddAttributes(nsIContent* aNode,
602 nsHtml5HtmlAttributes* aAttributes,
603 nsHtml5DocumentBuilder* aBuilder);
605 static void SetHTMLElementAttributes(mozilla::dom::Element* aElement,
606 nsAtom* aName,
607 nsHtml5HtmlAttributes* aAttributes);
609 static nsIContent* CreateHTMLElement(
610 nsAtom* aName, nsHtml5HtmlAttributes* aAttributes,
611 mozilla::dom::FromParser aFromParser, nsNodeInfoManager* aNodeInfoManager,
612 nsHtml5DocumentBuilder* aBuilder,
613 mozilla::dom::HTMLContentCreatorFunction aCreator);
615 static nsIContent* CreateSVGElement(
616 nsAtom* aName, nsHtml5HtmlAttributes* aAttributes,
617 mozilla::dom::FromParser aFromParser, nsNodeInfoManager* aNodeInfoManager,
618 nsHtml5DocumentBuilder* aBuilder,
619 mozilla::dom::SVGContentCreatorFunction aCreator);
621 static nsIContent* CreateMathMLElement(nsAtom* aName,
622 nsHtml5HtmlAttributes* aAttributes,
623 nsNodeInfoManager* aNodeInfoManager,
624 nsHtml5DocumentBuilder* aBuilder);
626 static void SetFormElement(nsIContent* aNode, nsIContent* aForm,
627 nsIContent* aParent);
629 static nsresult AppendIsindexPrompt(nsIContent* parent,
630 nsHtml5DocumentBuilder* aBuilder);
632 static nsresult FosterParentText(nsIContent* aStackParent, char16_t* aBuffer,
633 uint32_t aLength, nsIContent* aTable,
634 nsHtml5DocumentBuilder* aBuilder);
636 static nsresult AppendComment(nsIContent* aParent, char16_t* aBuffer,
637 int32_t aLength,
638 nsHtml5DocumentBuilder* aBuilder);
640 static nsresult AppendCommentToDocument(char16_t* aBuffer, int32_t aLength,
641 nsHtml5DocumentBuilder* aBuilder);
643 static nsresult AppendDoctypeToDocument(nsAtom* aName,
644 const nsAString& aPublicId,
645 const nsAString& aSystemId,
646 nsHtml5DocumentBuilder* aBuilder);
648 static nsIContent* GetDocumentFragmentForTemplate(nsIContent* aNode);
649 static void SetDocumentFragmentForTemplate(nsIContent* aNode,
650 nsIContent* aDocumentFragment);
652 static nsIContent* GetFosterParent(nsIContent* aTable,
653 nsIContent* aStackParent);
655 static void PreventScriptExecution(nsIContent* aNode);
657 static void DoneAddingChildren(nsIContent* aNode);
659 static void DoneCreatingElement(nsIContent* aNode);
661 static void SvgLoad(nsIContent* aNode);
663 static void MarkMalformedIfScript(nsIContent* aNode);
665 nsHtml5TreeOperation();
667 ~nsHtml5TreeOperation();
669 inline void Init(const treeOperation& aOperation) {
670 NS_ASSERTION(mOperation.is<uninitialized>(),
671 "Op code must be uninitialized when initializing.");
672 mOperation = aOperation;
675 inline bool IsRunScriptThatMayDocumentWriteOrBlock() {
676 return mOperation.is<opRunScriptThatMayDocumentWriteOrBlock>();
679 inline bool IsMarkAsBroken() { return mOperation.is<opMarkAsBroken>(); }
681 inline void SetSnapshot(nsAHtml5TreeBuilderState* aSnapshot, int32_t aLine) {
682 MOZ_ASSERT(
683 IsRunScriptThatMayDocumentWriteOrBlock(),
684 "Setting a snapshot for a tree operation other than eTreeOpRunScript!");
685 MOZ_ASSERT(aSnapshot, "Initialized tree op with null snapshot.");
686 opRunScriptThatMayDocumentWriteOrBlock data =
687 mOperation.as<opRunScriptThatMayDocumentWriteOrBlock>();
688 data.mBuilderState = aSnapshot;
689 data.mLineNumber = aLine;
690 mOperation = mozilla::AsVariant(data);
693 nsresult Perform(nsHtml5TreeOpExecutor* aBuilder, nsIContent** aScriptElement,
694 bool* aInterrupted, bool* aStreamEnded);
696 private:
697 nsHtml5TreeOperation(const nsHtml5TreeOperation&) = delete;
698 nsHtml5TreeOperation& operator=(const nsHtml5TreeOperation&) = delete;
700 treeOperation mOperation;
703 #endif // nsHtml5TreeOperation_h