Files
mozilla45esr/parser/html/nsHtml5Portability.cpp
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

125 lines
3.2 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/. */
#include "nsIAtom.h"
#include "nsString.h"
#include "jArray.h"
#include "nsHtml5Portability.h"
#include "nsHtml5TreeBuilder.h"
nsIAtom*
nsHtml5Portability::newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
{
NS_ASSERTION(!offset, "The offset should always be zero here.");
NS_ASSERTION(interner, "Didn't get an atom service.");
return interner->GetAtom(nsDependentSubstring(buf, buf + length));
}
nsHtml5String
nsHtml5Portability::newStringFromBuffer(char16_t* buf,
int32_t offset,
int32_t length,
nsHtml5TreeBuilder* treeBuilder)
{
return nsHtml5String::FromBuffer(buf + offset, length, treeBuilder);
}
nsHtml5String
nsHtml5Portability::newEmptyString()
{
return nsHtml5String::EmptyString();
}
nsHtml5String
nsHtml5Portability::newStringFromLiteral(const char* literal)
{
return nsHtml5String::FromLiteral(literal);
}
nsHtml5String
nsHtml5Portability::newStringFromString(nsHtml5String string)
{
return string.Clone();
}
jArray<char16_t,int32_t>
nsHtml5Portability::newCharArrayFromLocal(nsIAtom* local)
{
nsAutoString temp;
local->ToString(temp);
int32_t len = temp.Length();
jArray<char16_t,int32_t> arr = jArray<char16_t,int32_t>::newJArray(len);
memcpy(arr, temp.BeginReading(), len * sizeof(char16_t));
return arr;
}
jArray<char16_t, int32_t>
nsHtml5Portability::newCharArrayFromString(nsHtml5String string)
{
MOZ_RELEASE_ASSERT(string);
uint32_t len = string.Length();
MOZ_RELEASE_ASSERT(len < INT32_MAX);
jArray<char16_t,int32_t> arr = jArray<char16_t,int32_t>::newJArray(len);
string.CopyToBuffer(arr);
return arr;
}
nsIAtom*
nsHtml5Portability::newLocalFromLocal(nsIAtom* local, nsHtml5AtomTable* interner)
{
NS_PRECONDITION(local, "Atom was null.");
NS_PRECONDITION(interner, "Atom table was null");
if (!local->IsStaticAtom()) {
nsAutoString str;
local->ToString(str);
local = interner->GetAtom(str);
}
return local;
}
bool
nsHtml5Portability::localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t offset, int32_t length)
{
return local->Equals(nsDependentSubstring(buf + offset, buf + offset + length));
}
bool
nsHtml5Portability::lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(
const char* lowerCaseLiteral,
nsHtml5String string)
{
return string.LowerCaseStartsWithASCII(lowerCaseLiteral);
}
bool
nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString(
const char* lowerCaseLiteral,
nsHtml5String string)
{
return string.LowerCaseEqualsASCII(lowerCaseLiteral);
}
bool
nsHtml5Portability::literalEqualsString(const char* literal,
nsHtml5String string)
{
return string.EqualsASCII(literal);
}
bool
nsHtml5Portability::stringEqualsString(nsHtml5String one, nsHtml5String other)
{
return one.Equals(other);
}
void
nsHtml5Portability::initializeStatics()
{
}
void
nsHtml5Portability::releaseStatics()
{
}