Backed out changeset bcbab342eed8 (bug 1889658) for causing wpt reftest failures...
[gecko.git] / parser / html / nsHtml5Speculation.h
blob9bd04a7c1923a9ae2a51066ea4d7bb400fd9e14e
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 nsHtml5Speculation_h
6 #define nsHtml5Speculation_h
8 #include "nsHtml5OwningUTF16Buffer.h"
9 #include "nsAHtml5TreeBuilderState.h"
10 #include "nsHtml5TreeOperation.h"
11 #include "nsAHtml5TreeOpSink.h"
12 #include "nsTArray.h"
13 #include "mozilla/Attributes.h"
14 #include "mozilla/UniquePtr.h"
16 class nsHtml5Speculation final : public nsAHtml5TreeOpSink {
17 public:
18 nsHtml5Speculation(nsHtml5OwningUTF16Buffer* aBuffer, int32_t aStart,
19 int32_t aStartLineNumber, int32_t aStartColumnNumber,
20 nsAHtml5TreeBuilderState* aSnapshot);
22 ~nsHtml5Speculation();
24 nsHtml5OwningUTF16Buffer* GetBuffer() { return mBuffer; }
26 int32_t GetStart() { return mStart; }
28 int32_t GetStartLineNumber() { return mStartLineNumber; }
30 int32_t GetStartColumnNumber() { return mStartColumnNumber; }
32 nsAHtml5TreeBuilderState* GetSnapshot() { return mSnapshot.get(); }
34 /**
35 * Flush the operations from the tree operations from the argument
36 * queue unconditionally.
38 [[nodiscard]] virtual bool MoveOpsFrom(
39 nsTArray<nsHtml5TreeOperation>& aOpQueue) override;
41 [[nodiscard]] bool FlushToSink(nsAHtml5TreeOpSink* aSink);
43 private:
44 /**
45 * The first buffer in the pending UTF-16 buffer queue
47 RefPtr<nsHtml5OwningUTF16Buffer> mBuffer;
49 /**
50 * The start index of this speculation in the first buffer
52 int32_t mStart;
54 /**
55 * The current line number at the start of the speculation
57 int32_t mStartLineNumber;
59 /**
60 * The current line number at the start of the speculation.
62 int32_t mStartColumnNumber;
64 mozilla::UniquePtr<nsAHtml5TreeBuilderState> mSnapshot;
66 nsTArray<nsHtml5TreeOperation> mOpQueue;
69 #endif // nsHtml5Speculation_h