Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
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 "nsAutoPtr.h"
14 #include "mozilla/Attributes.h"
16 class nsHtml5Speculation MOZ_FINAL : public nsAHtml5TreeOpSink
17 {
18 public:
19 nsHtml5Speculation(nsHtml5OwningUTF16Buffer* aBuffer,
20 int32_t aStart,
21 int32_t aStartLineNumber,
22 nsAHtml5TreeBuilderState* aSnapshot);
24 ~nsHtml5Speculation();
26 nsHtml5OwningUTF16Buffer* GetBuffer()
27 {
28 return mBuffer;
29 }
31 int32_t GetStart()
32 {
33 return mStart;
34 }
36 int32_t GetStartLineNumber()
37 {
38 return mStartLineNumber;
39 }
41 nsAHtml5TreeBuilderState* GetSnapshot()
42 {
43 return mSnapshot;
44 }
46 /**
47 * Flush the operations from the tree operations from the argument
48 * queue unconditionally.
49 */
50 virtual void MoveOpsFrom(nsTArray<nsHtml5TreeOperation>& aOpQueue);
52 void FlushToSink(nsAHtml5TreeOpSink* aSink);
54 private:
55 /**
56 * The first buffer in the pending UTF-16 buffer queue
57 */
58 nsRefPtr<nsHtml5OwningUTF16Buffer> mBuffer;
60 /**
61 * The start index of this speculation in the first buffer
62 */
63 int32_t mStart;
65 /**
66 * The current line number at the start of the speculation
67 */
68 int32_t mStartLineNumber;
70 nsAutoPtr<nsAHtml5TreeBuilderState> mSnapshot;
72 nsTArray<nsHtml5TreeOperation> mOpQueue;
73 };
75 #endif // nsHtml5Speculation_h