Files
mozilla45esr/parser/html/nsHtml5String.h
T
roytam1 706b4d3150 import changes from tenfourfox:
- #565: M1367219 (6f63dc2cc)
- more adblock hosts (8cf4190e2)
- #565: implement nsASCIIMask from M1358297 (41b1fc937) (with vc2013 fix by replacing constexpr to MOZ_CONSTEXPR and MOZ_CONSTEXPR_VAR)
- #565: M1358225 with fix for M1548306 applied (8eed11298) (with vc2013 fix by replacing constexpr to MOZ_CONSTEXPR and MOZ_CONSTEXPR_VAR)
- even more adblock hosts (5d005926f)
- #565: M1347737 (9ab5bb0ed)
- #565: M1358297 parts 3 and 4 (3fd15a87a)
- #521: baseline parser support for async/await, with toggle, without bytecode (passes tests) (0e5746aaf)
- #521: fix yield handling (includes M1305566 pts 4-7) (2d25f717b)
- #521: make async functions throw for compatibility when enabled (46b01b5d4)
- #569: M1204714 (c45b2e8b5)
- #568: M1560495 (adapted for 45) M1562033+M1466449 M1559715 M1564449 M1573160 (d019bd3dc)
- #568: update certs, pins, TLDs, miners (ed3129eeb)
- #570: oops (dd79a9f75)
and added -bigobj compile switch to ssl/moz.build.
2019-08-27 00:22:58 +08:00

95 lines
2.4 KiB
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsHtml5String_h
#define nsHtml5String_h
#include "nsString.h"
class nsHtml5TreeBuilder;
/**
* A pass-by-value type that combines an unsafe `nsStringBuffer*` with its
* logical length (`uint32_t`). (`nsStringBuffer` knows its capacity but not
* its logical length, i.e. how much of the capacity is in use.)
*
* Holding or passing this type is as unsafe as holding or passing
* `nsStringBuffer*`.
*
* Empty strings and null strings are distinct. Since an empty nsString does
* not have a an `nsStringBuffer`, both empty and null `nsHtml5String` have
* `nullptr` as `mBuffer`. If `mBuffer` is `nullptr`, the empty case is marked
* with `mLength` being zero and the null case with `mLength` being non-zero.
*/
class nsHtml5String final
{
public:
/**
* Default constructor.
*/
inline nsHtml5String()
: nsHtml5String(nullptr)
{
}
/**
* Constructor from nullptr.
*/
inline MOZ_IMPLICIT nsHtml5String(decltype(nullptr))
: mBuffer(nullptr)
, mLength(UINT32_MAX)
{
}
inline uint32_t Length() const { return mBuffer ? mLength : 0; }
/**
* False iff the string is logically null
*/
inline MOZ_IMPLICIT operator bool() const { return !(!mBuffer && mLength); }
void ToString(nsAString& aString);
void CopyToBuffer(char16_t* aBuffer);
bool LowerCaseEqualsASCII(const char* aLowerCaseLiteral);
bool EqualsASCII(const char* aLiteral);
bool LowerCaseStartsWithASCII(const char* aLowerCaseLiteral);
bool Equals(nsHtml5String aOther);
nsHtml5String Clone();
void Release();
static nsHtml5String FromBuffer(char16_t* aBuffer,
int32_t aLength,
nsHtml5TreeBuilder* aTreeBuilder);
static nsHtml5String FromLiteral(const char* aLiteral);
static nsHtml5String FromString(const nsAString& aString);
static nsHtml5String EmptyString();
private:
/**
* Constructor from raw parts.
*/
nsHtml5String(already_AddRefed<nsStringBuffer> aBuffer, uint32_t aLength);
/**
* nullptr if the string is logically null or logically empty
*/
nsStringBuffer* mBuffer;
/**
* The length of the string. non-zero if the string is logically null.
*/
uint32_t mLength;
};
#endif // nsHtml5String_h