nsHtml5OwningUTF16Buffer.h (1497B)
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/. */ 4 5 #ifndef nsHtml5OwningUTF16Buffer_h 6 #define nsHtml5OwningUTF16Buffer_h 7 8 #include "nsHtml5UTF16Buffer.h" 9 #include "mozilla/Span.h" 10 11 class nsHtml5OwningUTF16Buffer : public nsHtml5UTF16Buffer { 12 public: 13 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsHtml5OwningUTF16Buffer) 14 15 private: 16 /** 17 * Passes a buffer and its length to the superclass constructor. 18 */ 19 explicit nsHtml5OwningUTF16Buffer(char16_t* aBuffer); 20 21 public: 22 /** 23 * Constructor for a parser key placeholder. (No actual buffer.) 24 * @param aKey a parser key 25 */ 26 explicit nsHtml5OwningUTF16Buffer(void* aKey); 27 28 protected: 29 /** 30 * Takes care of releasing the owned buffer. 31 */ 32 ~nsHtml5OwningUTF16Buffer(); 33 34 public: 35 /** 36 * The next buffer in a queue. 37 */ 38 RefPtr<nsHtml5OwningUTF16Buffer> next; 39 40 /** 41 * A parser key. 42 */ 43 void* key; 44 45 static already_AddRefed<nsHtml5OwningUTF16Buffer> FalliblyCreate( 46 int32_t aLength); 47 48 /** 49 * Swap start, end and buffer fields with another object. 50 */ 51 void Swap(nsHtml5OwningUTF16Buffer* aOther); 52 53 /** 54 * Return a span from `end` to `aBufferSize`. 55 */ 56 mozilla::Span<char16_t> TailAsSpan(int32_t aBufferSize); 57 58 /** 59 * Add the argument to `end`. 60 */ 61 void AdvanceEnd(int32_t aNumberOfCodeUnits); 62 }; 63 64 #endif // nsHtml5OwningUTF16Buffer_h