parser/html/nsHtml5TreeOperation.h

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef nsHtml5TreeOperation_h
michael@0 6 #define nsHtml5TreeOperation_h
michael@0 7
michael@0 8 #include "nsHtml5DocumentMode.h"
michael@0 9 #include "nsHtml5HtmlAttributes.h"
michael@0 10 #include "nsXPCOMStrings.h"
michael@0 11 #include "mozilla/dom/FromParser.h"
michael@0 12
michael@0 13 class nsIContent;
michael@0 14 class nsHtml5TreeOpExecutor;
michael@0 15 class nsHtml5StateSnapshot;
michael@0 16 class nsHtml5DocumentBuilder;
michael@0 17
michael@0 18 enum eHtml5TreeOperation {
michael@0 19 #ifdef DEBUG
michael@0 20 eTreeOpUninitialized,
michael@0 21 #endif
michael@0 22 // main HTML5 ops
michael@0 23 eTreeOpAppend,
michael@0 24 eTreeOpDetach,
michael@0 25 eTreeOpAppendChildrenToNewParent,
michael@0 26 eTreeOpFosterParent,
michael@0 27 eTreeOpAppendToDocument,
michael@0 28 eTreeOpAddAttributes,
michael@0 29 eTreeOpDocumentMode,
michael@0 30 eTreeOpCreateElementNetwork,
michael@0 31 eTreeOpCreateElementNotNetwork,
michael@0 32 eTreeOpSetFormElement,
michael@0 33 eTreeOpAppendText,
michael@0 34 eTreeOpAppendIsindexPrompt,
michael@0 35 eTreeOpFosterParentText,
michael@0 36 eTreeOpAppendComment,
michael@0 37 eTreeOpAppendCommentToDocument,
michael@0 38 eTreeOpAppendDoctypeToDocument,
michael@0 39 eTreeOpGetDocumentFragmentForTemplate,
michael@0 40 // Gecko-specific on-pop ops
michael@0 41 eTreeOpMarkAsBroken,
michael@0 42 eTreeOpRunScript,
michael@0 43 eTreeOpRunScriptAsyncDefer,
michael@0 44 eTreeOpPreventScriptExecution,
michael@0 45 eTreeOpDoneAddingChildren,
michael@0 46 eTreeOpDoneCreatingElement,
michael@0 47 eTreeOpFlushPendingAppendNotifications,
michael@0 48 eTreeOpSetDocumentCharset,
michael@0 49 eTreeOpNeedsCharsetSwitchTo,
michael@0 50 eTreeOpUpdateStyleSheet,
michael@0 51 eTreeOpProcessMeta,
michael@0 52 eTreeOpProcessOfflineManifest,
michael@0 53 eTreeOpMarkMalformedIfScript,
michael@0 54 eTreeOpStreamEnded,
michael@0 55 eTreeOpSetStyleLineNumber,
michael@0 56 eTreeOpSetScriptLineNumberAndFreeze,
michael@0 57 eTreeOpSvgLoad,
michael@0 58 eTreeOpMaybeComplainAboutCharset,
michael@0 59 eTreeOpAddClass,
michael@0 60 eTreeOpAddViewSourceHref,
michael@0 61 eTreeOpAddError,
michael@0 62 eTreeOpAddLineNumberId,
michael@0 63 eTreeOpAddErrorAtom,
michael@0 64 eTreeOpAddErrorTwoAtoms,
michael@0 65 eTreeOpStartLayout
michael@0 66 };
michael@0 67
michael@0 68 class nsHtml5TreeOperationStringPair {
michael@0 69 private:
michael@0 70 nsString mPublicId;
michael@0 71 nsString mSystemId;
michael@0 72 public:
michael@0 73 nsHtml5TreeOperationStringPair(const nsAString& aPublicId,
michael@0 74 const nsAString& aSystemId)
michael@0 75 : mPublicId(aPublicId)
michael@0 76 , mSystemId(aSystemId)
michael@0 77 {
michael@0 78 MOZ_COUNT_CTOR(nsHtml5TreeOperationStringPair);
michael@0 79 }
michael@0 80
michael@0 81 ~nsHtml5TreeOperationStringPair()
michael@0 82 {
michael@0 83 MOZ_COUNT_DTOR(nsHtml5TreeOperationStringPair);
michael@0 84 }
michael@0 85
michael@0 86 inline void Get(nsAString& aPublicId, nsAString& aSystemId)
michael@0 87 {
michael@0 88 aPublicId.Assign(mPublicId);
michael@0 89 aSystemId.Assign(mSystemId);
michael@0 90 }
michael@0 91 };
michael@0 92
michael@0 93 class nsHtml5TreeOperation {
michael@0 94
michael@0 95 public:
michael@0 96 /**
michael@0 97 * Atom is used inside the parser core are either static atoms that are
michael@0 98 * the same as Gecko-wide static atoms or they are dynamic atoms scoped by
michael@0 99 * both thread and parser to a particular nsHtml5AtomTable. In order to
michael@0 100 * such scoped atoms coming into contact with the rest of Gecko, atoms
michael@0 101 * that are about to exit the parser must go through this method which
michael@0 102 * reobtains dynamic atoms from the Gecko-global atom table.
michael@0 103 *
michael@0 104 * @param aAtom a potentially parser-scoped atom
michael@0 105 * @return an nsIAtom that's pointer comparable on the main thread with
michael@0 106 * other not-parser atoms.
michael@0 107 */
michael@0 108 static inline already_AddRefed<nsIAtom> Reget(nsIAtom* aAtom)
michael@0 109 {
michael@0 110 if (!aAtom || aAtom->IsStaticAtom()) {
michael@0 111 return dont_AddRef(aAtom);
michael@0 112 }
michael@0 113 nsAutoString str;
michael@0 114 aAtom->ToString(str);
michael@0 115 return do_GetAtom(str);
michael@0 116 }
michael@0 117
michael@0 118 static nsresult AppendTextToTextNode(const char16_t* aBuffer,
michael@0 119 uint32_t aLength,
michael@0 120 nsIContent* aTextNode,
michael@0 121 nsHtml5DocumentBuilder* aBuilder);
michael@0 122
michael@0 123 static nsresult AppendText(const char16_t* aBuffer,
michael@0 124 uint32_t aLength,
michael@0 125 nsIContent* aParent,
michael@0 126 nsHtml5DocumentBuilder* aBuilder);
michael@0 127
michael@0 128 static nsresult Append(nsIContent* aNode,
michael@0 129 nsIContent* aParent,
michael@0 130 nsHtml5DocumentBuilder* aBuilder);
michael@0 131
michael@0 132 static nsresult AppendToDocument(nsIContent* aNode,
michael@0 133 nsHtml5DocumentBuilder* aBuilder);
michael@0 134
michael@0 135 static void Detach(nsIContent* aNode, nsHtml5DocumentBuilder* aBuilder);
michael@0 136
michael@0 137 static nsresult AppendChildrenToNewParent(nsIContent* aNode,
michael@0 138 nsIContent* aParent,
michael@0 139 nsHtml5DocumentBuilder* aBuilder);
michael@0 140
michael@0 141 static nsresult FosterParent(nsIContent* aNode,
michael@0 142 nsIContent* aParent,
michael@0 143 nsIContent* aTable,
michael@0 144 nsHtml5DocumentBuilder* aBuilder);
michael@0 145
michael@0 146 static nsresult AddAttributes(nsIContent* aNode,
michael@0 147 nsHtml5HtmlAttributes* aAttributes,
michael@0 148 nsHtml5DocumentBuilder* aBuilder);
michael@0 149
michael@0 150 static nsIContent* CreateElement(int32_t aNs,
michael@0 151 nsIAtom* aName,
michael@0 152 nsHtml5HtmlAttributes* aAttributes,
michael@0 153 mozilla::dom::FromParser aFromParser,
michael@0 154 nsHtml5DocumentBuilder* aBuilder);
michael@0 155
michael@0 156 static void SetFormElement(nsIContent* aNode, nsIContent* aParent);
michael@0 157
michael@0 158 static nsresult AppendIsindexPrompt(nsIContent* parent,
michael@0 159 nsHtml5DocumentBuilder* aBuilder);
michael@0 160
michael@0 161 static nsresult FosterParentText(nsIContent* aStackParent,
michael@0 162 char16_t* aBuffer,
michael@0 163 uint32_t aLength,
michael@0 164 nsIContent* aTable,
michael@0 165 nsHtml5DocumentBuilder* aBuilder);
michael@0 166
michael@0 167 static nsresult AppendComment(nsIContent* aParent,
michael@0 168 char16_t* aBuffer,
michael@0 169 int32_t aLength,
michael@0 170 nsHtml5DocumentBuilder* aBuilder);
michael@0 171
michael@0 172 static nsresult AppendCommentToDocument(char16_t* aBuffer,
michael@0 173 int32_t aLength,
michael@0 174 nsHtml5DocumentBuilder* aBuilder);
michael@0 175
michael@0 176 static nsresult AppendDoctypeToDocument(nsIAtom* aName,
michael@0 177 const nsAString& aPublicId,
michael@0 178 const nsAString& aSystemId,
michael@0 179 nsHtml5DocumentBuilder* aBuilder);
michael@0 180
michael@0 181 static nsIContent* GetDocumentFragmentForTemplate(nsIContent* aNode);
michael@0 182
michael@0 183 static void PreventScriptExecution(nsIContent* aNode);
michael@0 184
michael@0 185 static void DoneAddingChildren(nsIContent* aNode,
michael@0 186 nsHtml5DocumentBuilder* aBuilder);
michael@0 187
michael@0 188 static void DoneCreatingElement(nsIContent* aNode);
michael@0 189
michael@0 190 static void SvgLoad(nsIContent* aNode);
michael@0 191
michael@0 192 static void MarkMalformedIfScript(nsIContent* aNode);
michael@0 193
michael@0 194 nsHtml5TreeOperation();
michael@0 195
michael@0 196 ~nsHtml5TreeOperation();
michael@0 197
michael@0 198 inline void Init(eHtml5TreeOperation aOpCode)
michael@0 199 {
michael@0 200 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 201 "Op code must be uninitialized when initializing.");
michael@0 202 mOpCode = aOpCode;
michael@0 203 }
michael@0 204
michael@0 205 inline void Init(eHtml5TreeOperation aOpCode, nsIContentHandle* aNode)
michael@0 206 {
michael@0 207 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 208 "Op code must be uninitialized when initializing.");
michael@0 209 NS_PRECONDITION(aNode, "Initialized tree op with null node.");
michael@0 210 mOpCode = aOpCode;
michael@0 211 mOne.node = static_cast<nsIContent**>(aNode);
michael@0 212 }
michael@0 213
michael@0 214 inline void Init(eHtml5TreeOperation aOpCode,
michael@0 215 nsIContentHandle* aNode,
michael@0 216 nsIContentHandle* aParent)
michael@0 217 {
michael@0 218 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 219 "Op code must be uninitialized when initializing.");
michael@0 220 NS_PRECONDITION(aNode, "Initialized tree op with null node.");
michael@0 221 NS_PRECONDITION(aParent, "Initialized tree op with null parent.");
michael@0 222 mOpCode = aOpCode;
michael@0 223 mOne.node = static_cast<nsIContent**>(aNode);
michael@0 224 mTwo.node = static_cast<nsIContent**>(aParent);
michael@0 225 }
michael@0 226
michael@0 227 inline void Init(eHtml5TreeOperation aOpCode,
michael@0 228 const nsACString& aString,
michael@0 229 int32_t aInt32)
michael@0 230 {
michael@0 231 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 232 "Op code must be uninitialized when initializing.");
michael@0 233
michael@0 234 int32_t len = aString.Length();
michael@0 235 char* str = new char[len + 1];
michael@0 236 const char* start = aString.BeginReading();
michael@0 237 for (int32_t i = 0; i < len; ++i) {
michael@0 238 str[i] = start[i];
michael@0 239 }
michael@0 240 str[len] = '\0';
michael@0 241
michael@0 242 mOpCode = aOpCode;
michael@0 243 mOne.charPtr = str;
michael@0 244 mFour.integer = aInt32;
michael@0 245 }
michael@0 246
michael@0 247 inline void Init(eHtml5TreeOperation aOpCode,
michael@0 248 const nsACString& aString,
michael@0 249 int32_t aInt32,
michael@0 250 int32_t aLineNumber)
michael@0 251 {
michael@0 252 Init(aOpCode, aString, aInt32);
michael@0 253 mTwo.integer = aLineNumber;
michael@0 254 }
michael@0 255
michael@0 256 inline void Init(eHtml5TreeOperation aOpCode,
michael@0 257 nsIContentHandle* aNode,
michael@0 258 nsIContentHandle* aParent,
michael@0 259 nsIContentHandle* aTable)
michael@0 260 {
michael@0 261 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 262 "Op code must be uninitialized when initializing.");
michael@0 263 NS_PRECONDITION(aNode, "Initialized tree op with null node.");
michael@0 264 NS_PRECONDITION(aParent, "Initialized tree op with null parent.");
michael@0 265 NS_PRECONDITION(aTable, "Initialized tree op with null table.");
michael@0 266 mOpCode = aOpCode;
michael@0 267 mOne.node = static_cast<nsIContent**>(aNode);
michael@0 268 mTwo.node = static_cast<nsIContent**>(aParent);
michael@0 269 mThree.node = static_cast<nsIContent**>(aTable);
michael@0 270 }
michael@0 271
michael@0 272 inline void Init(nsHtml5DocumentMode aMode)
michael@0 273 {
michael@0 274 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 275 "Op code must be uninitialized when initializing.");
michael@0 276 mOpCode = eTreeOpDocumentMode;
michael@0 277 mOne.mode = aMode;
michael@0 278 }
michael@0 279
michael@0 280 inline void InitScript(nsIContentHandle* aNode)
michael@0 281 {
michael@0 282 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 283 "Op code must be uninitialized when initializing.");
michael@0 284 NS_PRECONDITION(aNode, "Initialized tree op with null node.");
michael@0 285 mOpCode = eTreeOpRunScript;
michael@0 286 mOne.node = static_cast<nsIContent**>(aNode);
michael@0 287 mTwo.state = nullptr;
michael@0 288 }
michael@0 289
michael@0 290 inline void Init(int32_t aNamespace,
michael@0 291 nsIAtom* aName,
michael@0 292 nsHtml5HtmlAttributes* aAttributes,
michael@0 293 nsIContentHandle* aTarget,
michael@0 294 bool aFromNetwork)
michael@0 295 {
michael@0 296 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 297 "Op code must be uninitialized when initializing.");
michael@0 298 NS_PRECONDITION(aName, "Initialized tree op with null name.");
michael@0 299 NS_PRECONDITION(aTarget, "Initialized tree op with null target node.");
michael@0 300 mOpCode = aFromNetwork ?
michael@0 301 eTreeOpCreateElementNetwork :
michael@0 302 eTreeOpCreateElementNotNetwork;
michael@0 303 mFour.integer = aNamespace;
michael@0 304 mOne.node = static_cast<nsIContent**>(aTarget);
michael@0 305 mTwo.atom = aName;
michael@0 306 if (aAttributes == nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES) {
michael@0 307 mThree.attributes = nullptr;
michael@0 308 } else {
michael@0 309 mThree.attributes = aAttributes;
michael@0 310 }
michael@0 311 }
michael@0 312
michael@0 313 inline void Init(eHtml5TreeOperation aOpCode,
michael@0 314 char16_t* aBuffer,
michael@0 315 int32_t aLength,
michael@0 316 nsIContentHandle* aStackParent,
michael@0 317 nsIContentHandle* aTable)
michael@0 318 {
michael@0 319 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 320 "Op code must be uninitialized when initializing.");
michael@0 321 NS_PRECONDITION(aBuffer, "Initialized tree op with null buffer.");
michael@0 322 mOpCode = aOpCode;
michael@0 323 mOne.node = static_cast<nsIContent**>(aStackParent);
michael@0 324 mTwo.unicharPtr = aBuffer;
michael@0 325 mThree.node = static_cast<nsIContent**>(aTable);
michael@0 326 mFour.integer = aLength;
michael@0 327 }
michael@0 328
michael@0 329 inline void Init(eHtml5TreeOperation aOpCode,
michael@0 330 char16_t* aBuffer,
michael@0 331 int32_t aLength,
michael@0 332 nsIContentHandle* aParent)
michael@0 333 {
michael@0 334 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 335 "Op code must be uninitialized when initializing.");
michael@0 336 NS_PRECONDITION(aBuffer, "Initialized tree op with null buffer.");
michael@0 337 mOpCode = aOpCode;
michael@0 338 mOne.node = static_cast<nsIContent**>(aParent);
michael@0 339 mTwo.unicharPtr = aBuffer;
michael@0 340 mFour.integer = aLength;
michael@0 341 }
michael@0 342
michael@0 343 inline void Init(eHtml5TreeOperation aOpCode,
michael@0 344 char16_t* aBuffer,
michael@0 345 int32_t aLength)
michael@0 346 {
michael@0 347 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 348 "Op code must be uninitialized when initializing.");
michael@0 349 NS_PRECONDITION(aBuffer, "Initialized tree op with null buffer.");
michael@0 350 mOpCode = aOpCode;
michael@0 351 mTwo.unicharPtr = aBuffer;
michael@0 352 mFour.integer = aLength;
michael@0 353 }
michael@0 354
michael@0 355 inline void Init(nsIContentHandle* aElement,
michael@0 356 nsHtml5HtmlAttributes* aAttributes)
michael@0 357 {
michael@0 358 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 359 "Op code must be uninitialized when initializing.");
michael@0 360 NS_PRECONDITION(aElement, "Initialized tree op with null element.");
michael@0 361 mOpCode = eTreeOpAddAttributes;
michael@0 362 mOne.node = static_cast<nsIContent**>(aElement);
michael@0 363 mTwo.attributes = aAttributes;
michael@0 364 }
michael@0 365
michael@0 366 inline void Init(nsIAtom* aName,
michael@0 367 const nsAString& aPublicId,
michael@0 368 const nsAString& aSystemId)
michael@0 369 {
michael@0 370 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 371 "Op code must be uninitialized when initializing.");
michael@0 372 mOpCode = eTreeOpAppendDoctypeToDocument;
michael@0 373 mOne.atom = aName;
michael@0 374 mTwo.stringPair = new nsHtml5TreeOperationStringPair(aPublicId, aSystemId);
michael@0 375 }
michael@0 376
michael@0 377 inline void Init(nsIContentHandle* aElement,
michael@0 378 const char* aMsgId,
michael@0 379 nsIAtom* aAtom,
michael@0 380 nsIAtom* aOtherAtom)
michael@0 381 {
michael@0 382 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 383 "Op code must be uninitialized when initializing.");
michael@0 384 mOpCode = eTreeOpAddError;
michael@0 385 mOne.node = static_cast<nsIContent**>(aElement);
michael@0 386 mTwo.charPtr = (char*)aMsgId;
michael@0 387 mThree.atom = aAtom;
michael@0 388 mFour.atom = aOtherAtom;
michael@0 389 }
michael@0 390
michael@0 391 inline void Init(nsIContentHandle* aElement,
michael@0 392 const char* aMsgId,
michael@0 393 nsIAtom* aAtom)
michael@0 394 {
michael@0 395 Init(aElement, aMsgId, aAtom, nullptr);
michael@0 396 }
michael@0 397
michael@0 398 inline void Init(nsIContentHandle* aElement,
michael@0 399 const char* aMsgId)
michael@0 400 {
michael@0 401 Init(aElement, aMsgId, nullptr, nullptr);
michael@0 402 }
michael@0 403
michael@0 404 inline void Init(const char* aMsgId,
michael@0 405 bool aError,
michael@0 406 int32_t aLineNumber)
michael@0 407 {
michael@0 408 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 409 "Op code must be uninitialized when initializing.");
michael@0 410 mOpCode = eTreeOpMaybeComplainAboutCharset;
michael@0 411 mOne.charPtr = const_cast<char*>(aMsgId);
michael@0 412 mTwo.integer = aError;
michael@0 413 mThree.integer = aLineNumber;
michael@0 414 }
michael@0 415
michael@0 416 inline void Init(eHtml5TreeOperation aOpCode, const nsAString& aString)
michael@0 417 {
michael@0 418 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 419 "Op code must be uninitialized when initializing.");
michael@0 420
michael@0 421 char16_t* str = NS_StringCloneData(aString);
michael@0 422 mOpCode = aOpCode;
michael@0 423 mOne.unicharPtr = str;
michael@0 424 }
michael@0 425
michael@0 426 inline void Init(eHtml5TreeOperation aOpCode,
michael@0 427 nsIContentHandle* aNode,
michael@0 428 int32_t aInt)
michael@0 429 {
michael@0 430 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 431 "Op code must be uninitialized when initializing.");
michael@0 432 NS_PRECONDITION(aNode, "Initialized tree op with null node.");
michael@0 433 mOpCode = aOpCode;
michael@0 434 mOne.node = static_cast<nsIContent**>(aNode);
michael@0 435 mFour.integer = aInt;
michael@0 436 }
michael@0 437
michael@0 438 inline void Init(nsresult aRv)
michael@0 439 {
michael@0 440 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 441 "Op code must be uninitialized when initializing.");
michael@0 442 NS_PRECONDITION(NS_FAILED(aRv), "Initialized tree op with non-failure.");
michael@0 443 mOpCode = eTreeOpMarkAsBroken;
michael@0 444 mOne.result = aRv;
michael@0 445 }
michael@0 446
michael@0 447 inline void InitAddClass(nsIContentHandle* aNode, const char16_t* aClass)
michael@0 448 {
michael@0 449 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 450 "Op code must be uninitialized when initializing.");
michael@0 451 NS_PRECONDITION(aNode, "Initialized tree op with null node.");
michael@0 452 NS_PRECONDITION(aClass, "Initialized tree op with null string.");
michael@0 453 // aClass must be a literal string that does not need freeing
michael@0 454 mOpCode = eTreeOpAddClass;
michael@0 455 mOne.node = static_cast<nsIContent**>(aNode);
michael@0 456 mTwo.unicharPtr = (char16_t*)aClass;
michael@0 457 }
michael@0 458
michael@0 459 inline void InitAddLineNumberId(nsIContentHandle* aNode,
michael@0 460 const int32_t aLineNumber)
michael@0 461 {
michael@0 462 NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
michael@0 463 "Op code must be uninitialized when initializing.");
michael@0 464 NS_PRECONDITION(aNode, "Initialized tree op with null node.");
michael@0 465 NS_PRECONDITION(aLineNumber > 0, "Initialized tree op with line number.");
michael@0 466 // aClass must be a literal string that does not need freeing
michael@0 467 mOpCode = eTreeOpAddLineNumberId;
michael@0 468 mOne.node = static_cast<nsIContent**>(aNode);
michael@0 469 mFour.integer = aLineNumber;
michael@0 470 }
michael@0 471
michael@0 472 inline bool IsRunScript()
michael@0 473 {
michael@0 474 return mOpCode == eTreeOpRunScript;
michael@0 475 }
michael@0 476
michael@0 477 inline void SetSnapshot(nsAHtml5TreeBuilderState* aSnapshot, int32_t aLine)
michael@0 478 {
michael@0 479 NS_ASSERTION(IsRunScript(),
michael@0 480 "Setting a snapshot for a tree operation other than eTreeOpRunScript!");
michael@0 481 NS_PRECONDITION(aSnapshot, "Initialized tree op with null snapshot.");
michael@0 482 mTwo.state = aSnapshot;
michael@0 483 mFour.integer = aLine;
michael@0 484 }
michael@0 485
michael@0 486 nsresult Perform(nsHtml5TreeOpExecutor* aBuilder,
michael@0 487 nsIContent** aScriptElement);
michael@0 488
michael@0 489 private:
michael@0 490 // possible optimization:
michael@0 491 // Make the queue take items the size of pointer and make the op code
michael@0 492 // decide how many operands it dequeues after it.
michael@0 493 eHtml5TreeOperation mOpCode;
michael@0 494 union {
michael@0 495 nsIContent** node;
michael@0 496 nsIAtom* atom;
michael@0 497 nsHtml5HtmlAttributes* attributes;
michael@0 498 nsHtml5DocumentMode mode;
michael@0 499 char16_t* unicharPtr;
michael@0 500 char* charPtr;
michael@0 501 nsHtml5TreeOperationStringPair* stringPair;
michael@0 502 nsAHtml5TreeBuilderState* state;
michael@0 503 int32_t integer;
michael@0 504 nsresult result;
michael@0 505 } mOne, mTwo, mThree, mFour;
michael@0 506 };
michael@0 507
michael@0 508 #endif // nsHtml5TreeOperation_h

mercurial