Regenerate nsHtml5*.cpp files from java htmlparser sources

This commit is contained in:
Matt A. Tobin 2020-01-16 07:28:40 -05:00 • committed by Roy Tam
commit 4baeeaa8ec
19 changed files with 100 additions and 132 deletions

View file

@ -1,6 +1,7 @@
/* /*
* Copyright (c) 2008-2011 Mozilla Foundation * Copyright (c) 2008-2011 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),

View file

@ -1,6 +1,7 @@
/* /*
* Copyright (c) 2008-2011 Mozilla Foundation * Copyright (c) 2008-2011 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),

View file

@ -1,23 +1,24 @@
/* /*
* Copyright (c) 2008-2014 Mozilla Foundation * Copyright (c) 2008-2016 Mozilla Foundation
* Copyright (c) 2020 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */

View file

@ -1,23 +1,24 @@
/* /*
* Copyright (c) 2008-2014 Mozilla Foundation * Copyright (c) 2008-2016 Mozilla Foundation
* Copyright (c) 2020 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions: * Software is furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */

View file

@ -1,7 +1,8 @@
/* /*
* Copyright (c) 2007 Henri Sivonen * Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2008-2011 Mozilla Foundation * Copyright (c) 2008-2011 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@ -59,11 +60,11 @@
nsHtml5HtmlAttributes* nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES = nullptr; nsHtml5HtmlAttributes* nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES = nullptr;
nsHtml5HtmlAttributes::nsHtml5HtmlAttributes(int32_t mode) nsHtml5HtmlAttributes::nsHtml5HtmlAttributes(int32_t mode)
: mode(mode) : mode(mode),
, length(0) length(0),
, names(jArray<nsHtml5AttributeName*, int32_t>::newJArray(8)) names(jArray<nsHtml5AttributeName*,int32_t>::newJArray(8)),
, values(jArray<nsHtml5String, int32_t>::newJArray(8)) values(jArray<nsHtml5String,int32_t>::newJArray(8)),
, lines(jArray<int32_t, int32_t>::newJArray(8)) lines(jArray<int32_t,int32_t>::newJArray(8))
{ {
MOZ_COUNT_CTOR(nsHtml5HtmlAttributes); MOZ_COUNT_CTOR(nsHtml5HtmlAttributes);
} }
@ -146,17 +147,14 @@ nsHtml5HtmlAttributes::getLineNoBoundsCheck(int32_t index)
} }
void void
nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name, nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name, nsHtml5String value, int32_t line)
nsHtml5String value,
int32_t line)
{ {
if (names.length == length) { if (names.length == length) {
int32_t newLen = length << 1; int32_t newLen = length << 1;
jArray<nsHtml5AttributeName*,int32_t> newNames = jArray<nsHtml5AttributeName*,int32_t>::newJArray(newLen); jArray<nsHtml5AttributeName*,int32_t> newNames = jArray<nsHtml5AttributeName*,int32_t>::newJArray(newLen);
nsHtml5ArrayCopy::arraycopy(names, newNames, names.length); nsHtml5ArrayCopy::arraycopy(names, newNames, names.length);
names = newNames; names = newNames;
jArray<nsHtml5String, int32_t> newValues = jArray<nsHtml5String,int32_t> newValues = jArray<nsHtml5String,int32_t>::newJArray(newLen);
jArray<nsHtml5String, int32_t>::newJArray(newLen);
nsHtml5ArrayCopy::arraycopy(values, newValues, values.length); nsHtml5ArrayCopy::arraycopy(values, newValues, values.length);
values = newValues; values = newValues;
jArray<int32_t,int32_t> newLines = jArray<int32_t,int32_t>::newJArray(newLen); jArray<int32_t,int32_t> newLines = jArray<int32_t,int32_t>::newJArray(newLen);

View file

@ -1,7 +1,8 @@
/* /*
* Copyright (c) 2007 Henri Sivonen * Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2008-2011 Mozilla Foundation * Copyright (c) 2008-2011 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@ -65,7 +66,7 @@ class nsHtml5HtmlAttributes
int32_t mode; int32_t mode;
int32_t length; int32_t length;
autoJArray<nsHtml5AttributeName*,int32_t> names; autoJArray<nsHtml5AttributeName*,int32_t> names;
autoJArray<nsHtml5String, int32_t> values; autoJArray<nsHtml5String,int32_t> values;
autoJArray<int32_t,int32_t> lines; autoJArray<int32_t,int32_t> lines;
public: public:
explicit nsHtml5HtmlAttributes(int32_t mode); explicit nsHtml5HtmlAttributes(int32_t mode);
@ -79,9 +80,7 @@ class nsHtml5HtmlAttributes
nsHtml5String getValueNoBoundsCheck(int32_t index); nsHtml5String getValueNoBoundsCheck(int32_t index);
nsHtml5AttributeName* getAttributeNameNoBoundsCheck(int32_t index); nsHtml5AttributeName* getAttributeNameNoBoundsCheck(int32_t index);
int32_t getLineNoBoundsCheck(int32_t index); int32_t getLineNoBoundsCheck(int32_t index);
void addAttribute(nsHtml5AttributeName* name, void addAttribute(nsHtml5AttributeName* name, nsHtml5String value, int32_t line);
nsHtml5String value,
int32_t line);
void clear(int32_t m); void clear(int32_t m);
void releaseValue(int32_t i); void releaseValue(int32_t i);
void clearWithoutReleasingContents(); void clearWithoutReleasingContents();

View file

@ -1,7 +1,8 @@
/* /*
* Copyright (c) 2007 Henri Sivonen * Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2008-2015 Mozilla Foundation * Copyright (c) 2008-2015 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@ -787,8 +788,7 @@ nsHtml5MetaScanner::handleTagInner()
return true; return true;
} }
if (!!content && httpEquivState == NS_HTML5META_SCANNER_HTTP_EQUIV_CONTENT_TYPE) { if (!!content && httpEquivState == NS_HTML5META_SCANNER_HTTP_EQUIV_CONTENT_TYPE) {
nsHtml5String extract = nsHtml5String extract = nsHtml5TreeBuilder::extractCharsetFromContent(content, treeBuilder);
nsHtml5TreeBuilder::extractCharsetFromContent(content, treeBuilder);
if (!extract) { if (!extract) {
return false; return false;
} }

View file

@ -1,7 +1,8 @@
/* /*
* Copyright (c) 2007 Henri Sivonen * Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2008-2015 Mozilla Foundation * Copyright (c) 2008-2015 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),

View file

@ -1,6 +1,7 @@
/* /*
* Copyright (c) 2008-2015 Mozilla Foundation * Copyright (c) 2008-2015 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@ -60,24 +61,16 @@ class nsHtml5Portability
{ {
public: public:
static nsIAtom* newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner); static nsIAtom* newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
static nsHtml5String newStringFromBuffer(char16_t* buf, static nsHtml5String newStringFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5TreeBuilder* treeBuilder);
int32_t offset,
int32_t length,
nsHtml5TreeBuilder* treeBuilder);
static nsHtml5String newEmptyString(); static nsHtml5String newEmptyString();
static nsHtml5String newStringFromLiteral(const char* literal); static nsHtml5String newStringFromLiteral(const char* literal);
static nsHtml5String newStringFromString(nsHtml5String string); static nsHtml5String newStringFromString(nsHtml5String string);
static jArray<char16_t,int32_t> newCharArrayFromLocal(nsIAtom* local); static jArray<char16_t,int32_t> newCharArrayFromLocal(nsIAtom* local);
static jArray<char16_t, int32_t> newCharArrayFromString( static jArray<char16_t,int32_t> newCharArrayFromString(nsHtml5String string);
nsHtml5String string);
static nsIAtom* newLocalFromLocal(nsIAtom* local, nsHtml5AtomTable* interner); static nsIAtom* newLocalFromLocal(nsIAtom* local, nsHtml5AtomTable* interner);
static bool localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t offset, int32_t length); static bool localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t offset, int32_t length);
static bool lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString( static bool lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsHtml5String string);
const char* lowerCaseLiteral, static bool lowerCaseLiteralEqualsIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsHtml5String string);
nsHtml5String string);
static bool lowerCaseLiteralEqualsIgnoreAsciiCaseString(
const char* lowerCaseLiteral,
nsHtml5String string);
static bool literalEqualsString(const char* literal, nsHtml5String string); static bool literalEqualsString(const char* literal, nsHtml5String string);
static bool stringEqualsString(nsHtml5String one, nsHtml5String other); static bool stringEqualsString(nsHtml5String one, nsHtml5String other);
static void initializeStatics(); static void initializeStatics();

View file

@ -1,7 +1,8 @@
/* /*
* Copyright (c) 2007 Henri Sivonen * Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2007-2011 Mozilla Foundation * Copyright (c) 2007-2011 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),

View file

@ -1,7 +1,8 @@
/* /*
* Copyright (c) 2007 Henri Sivonen * Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2007-2011 Mozilla Foundation * Copyright (c) 2007-2011 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),

View file

@ -1,6 +1,7 @@
/* /*
* Copyright (c) 2009-2010 Mozilla Foundation * Copyright (c) 2009-2010 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),

View file

@ -1,6 +1,7 @@
/* /*
* Copyright (c) 2009-2010 Mozilla Foundation * Copyright (c) 2009-2010 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),

View file

@ -1,7 +1,8 @@
/* /*
* Copyright (c) 2005-2007 Henri Sivonen * Copyright (c) 2005-2007 Henri Sivonen
* Copyright (c) 2007-2015 Mozilla Foundation * Copyright (c) 2007-2015 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* Portions of comments Copyright 2004-2010 Apple Computer, Inc., Mozilla * Portions of comments Copyright 2004-2010 Apple Computer, Inc., Mozilla
* Foundation, and Opera Software ASA. * Foundation, and Opera Software ASA.
* *
@ -114,8 +115,7 @@ nsHtml5Tokenizer::setInterner(nsHtml5AtomTable* interner)
} }
void void
nsHtml5Tokenizer::initLocation(nsHtml5String newPublicId, nsHtml5Tokenizer::initLocation(nsHtml5String newPublicId, nsHtml5String newSystemId)
nsHtml5String newSystemId)
{ {
this->systemId = newSystemId; this->systemId = newSystemId;
this->publicId = newPublicId; this->publicId = newPublicId;
@ -220,11 +220,10 @@ nsHtml5Tokenizer::emitOrAppendCharRefBuf(int32_t returnState)
} }
} }
nsHtml5String nsHtml5String
nsHtml5Tokenizer::strBufToString() nsHtml5Tokenizer::strBufToString()
{ {
nsHtml5String str = nsHtml5String str = nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen, tokenHandler);
nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen, tokenHandler);
clearStrBufAfterUse(); clearStrBufAfterUse();
return str; return str;
} }

View file

@ -1,7 +1,8 @@
/* /*
* Copyright (c) 2005-2007 Henri Sivonen * Copyright (c) 2005-2007 Henri Sivonen
* Copyright (c) 2007-2015 Mozilla Foundation * Copyright (c) 2007-2015 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* Portions of comments Copyright 2004-2010 Apple Computer, Inc., Mozilla * Portions of comments Copyright 2004-2010 Apple Computer, Inc., Mozilla
* Foundation, and Opera Software ASA. * Foundation, and Opera Software ASA.
* *

View file

@ -1,7 +1,8 @@
/* /*
* Copyright (c) 2007 Henri Sivonen * Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2007-2015 Mozilla Foundation * Copyright (c) 2007-2015 Mozilla Foundation
* Copyright (c) 2020 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* Portions of comments Copyright 2004-2008 Apple Computer, Inc., Mozilla * Portions of comments Copyright 2004-2008 Apple Computer, Inc., Mozilla
* Foundation, and Opera Software ASA. * Foundation, and Opera Software ASA.
* *
@ -131,12 +132,7 @@ nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self)
formPointer = getFormPointerForContext(contextNode); formPointer = getFormPointerForContext(contextNode);
if (nsHtml5Atoms::title == contextName || nsHtml5Atoms::textarea == contextName) { if (nsHtml5Atoms::title == contextName || nsHtml5Atoms::textarea == contextName) {
tokenizer->setState(NS_HTML5TOKENIZER_RCDATA); tokenizer->setState(NS_HTML5TOKENIZER_RCDATA);
} else if (nsHtml5Atoms::style == contextName || } else if (nsHtml5Atoms::style == contextName || nsHtml5Atoms::xmp == contextName || nsHtml5Atoms::iframe == contextName || nsHtml5Atoms::noembed == contextName || nsHtml5Atoms::noframes == contextName || (scriptingEnabled && nsHtml5Atoms::noscript == contextName)) {
nsHtml5Atoms::xmp == contextName ||
nsHtml5Atoms::iframe == contextName ||
nsHtml5Atoms::noembed == contextName ||
nsHtml5Atoms::noframes == contextName ||
(scriptingEnabled && nsHtml5Atoms::noscript == contextName)) {
tokenizer->setState(NS_HTML5TOKENIZER_RAWTEXT); tokenizer->setState(NS_HTML5TOKENIZER_RAWTEXT);
} else if (nsHtml5Atoms::plaintext == contextName) { } else if (nsHtml5Atoms::plaintext == contextName) {
tokenizer->setState(NS_HTML5TOKENIZER_PLAINTEXT); tokenizer->setState(NS_HTML5TOKENIZER_PLAINTEXT);
@ -160,10 +156,7 @@ nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self)
} }
void void
nsHtml5TreeBuilder::doctype(nsIAtom* name, nsHtml5TreeBuilder::doctype(nsIAtom* name, nsHtml5String publicIdentifier, nsHtml5String systemIdentifier, bool forceQuirks)
nsHtml5String publicIdentifier,
nsHtml5String systemIdentifier,
bool forceQuirks)
{ {
needToDropLF = false; needToDropLF = false;
if (!isInForeign() && mode == NS_HTML5TREE_BUILDER_INITIAL) { if (!isInForeign() && mode == NS_HTML5TREE_BUILDER_INITIAL) {
@ -2000,8 +1993,7 @@ nsHtml5TreeBuilder::isSpecialParentInForeign(nsHtml5StackNode* stackNode)
} }
nsHtml5String nsHtml5String
nsHtml5TreeBuilder::extractCharsetFromContent(nsHtml5String attributeValue, nsHtml5TreeBuilder::extractCharsetFromContent(nsHtml5String attributeValue, nsHtml5TreeBuilder* tb)
nsHtml5TreeBuilder* tb)
{ {
int32_t charsetState = NS_HTML5TREE_BUILDER_CHARSET_INITIAL; int32_t charsetState = NS_HTML5TREE_BUILDER_CHARSET_INITIAL;
int32_t start = -1; int32_t start = -1;
@ -2190,8 +2182,7 @@ nsHtml5TreeBuilder::extractCharsetFromContent(nsHtml5String attributeValue,
if (end == -1) { if (end == -1) {
end = buffer.length; end = buffer.length;
} }
charset = charset = nsHtml5Portability::newStringFromBuffer(buffer, start, end - start, tb);
nsHtml5Portability::newStringFromBuffer(buffer, start, end - start, tb);
} }
return charset; return charset;
} }
@ -2199,8 +2190,7 @@ nsHtml5TreeBuilder::extractCharsetFromContent(nsHtml5String attributeValue,
void void
nsHtml5TreeBuilder::checkMetaCharset(nsHtml5HtmlAttributes* attributes) nsHtml5TreeBuilder::checkMetaCharset(nsHtml5HtmlAttributes* attributes)
{ {
nsHtml5String charset = nsHtml5String charset = attributes->getValue(nsHtml5AttributeName::ATTR_CHARSET);
attributes->getValue(nsHtml5AttributeName::ATTR_CHARSET);
if (charset) { if (charset) {
if (tokenizer->internalEncodingDeclaration(charset)) { if (tokenizer->internalEncodingDeclaration(charset)) {
requestSuspension(); requestSuspension();
@ -2211,11 +2201,9 @@ nsHtml5TreeBuilder::checkMetaCharset(nsHtml5HtmlAttributes* attributes)
if (!nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("content-type", attributes->getValue(nsHtml5AttributeName::ATTR_HTTP_EQUIV))) { if (!nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("content-type", attributes->getValue(nsHtml5AttributeName::ATTR_HTTP_EQUIV))) {
return; return;
} }
nsHtml5String content = nsHtml5String content = attributes->getValue(nsHtml5AttributeName::ATTR_CONTENT);
attributes->getValue(nsHtml5AttributeName::ATTR_CONTENT);
if (content) { if (content) {
nsHtml5String extract = nsHtml5String extract = nsHtml5TreeBuilder::extractCharsetFromContent(content, this);
nsHtml5TreeBuilder::extractCharsetFromContent(content, this);
if (extract) { if (extract) {
if (tokenizer->internalEncodingDeclaration(extract)) { if (tokenizer->internalEncodingDeclaration(extract)) {
requestSuspension(); requestSuspension();
@ -3222,11 +3210,7 @@ nsHtml5TreeBuilder::isSecondOnStackBody()
} }
void void
nsHtml5TreeBuilder::documentModeInternal( nsHtml5TreeBuilder::documentModeInternal(nsHtml5DocumentMode m, nsHtml5String publicIdentifier, nsHtml5String systemIdentifier, bool html4SpecificAdditionalErrorChecks)
nsHtml5DocumentMode m,
nsHtml5String publicIdentifier,
nsHtml5String systemIdentifier,
bool html4SpecificAdditionalErrorChecks)
{ {
if (isSrcdocDocument) { if (isSrcdocDocument) {
quirks = false; quirks = false;
@ -3238,8 +3222,7 @@ nsHtml5TreeBuilder::documentModeInternal(
} }
bool bool
nsHtml5TreeBuilder::isAlmostStandards(nsHtml5String publicIdentifier, nsHtml5TreeBuilder::isAlmostStandards(nsHtml5String publicIdentifier, nsHtml5String systemIdentifier)
nsHtml5String systemIdentifier)
{ {
if (nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("-//w3c//dtd xhtml 1.0 transitional//en", publicIdentifier)) { if (nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("-//w3c//dtd xhtml 1.0 transitional//en", publicIdentifier)) {
return true; return true;
@ -3259,10 +3242,7 @@ nsHtml5TreeBuilder::isAlmostStandards(nsHtml5String publicIdentifier,
} }
bool bool
nsHtml5TreeBuilder::isQuirky(nsIAtom* name, nsHtml5TreeBuilder::isQuirky(nsIAtom* name, nsHtml5String publicIdentifier, nsHtml5String systemIdentifier, bool forceQuirks)
nsHtml5String publicIdentifier,
nsHtml5String systemIdentifier,
bool forceQuirks)
{ {
if (forceQuirks) { if (forceQuirks) {
return true; return true;
@ -4073,8 +4053,7 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5Elem
bool bool
nsHtml5TreeBuilder::annotationXmlEncodingPermitsHtml(nsHtml5HtmlAttributes* attributes) nsHtml5TreeBuilder::annotationXmlEncodingPermitsHtml(nsHtml5HtmlAttributes* attributes)
{ {
nsHtml5String encoding = nsHtml5String encoding = attributes->getValue(nsHtml5AttributeName::ATTR_ENCODING);
attributes->getValue(nsHtml5AttributeName::ATTR_ENCODING);
if (!encoding) { if (!encoding) {
return false; return false;
} }

View file

@ -1,7 +1,8 @@
/* /*
* Copyright (c) 2007 Henri Sivonen * Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2007-2015 Mozilla Foundation * Copyright (c) 2007-2015 Mozilla Foundation
* Copyright (c) 2020 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* Portions of comments Copyright 2004-2008 Apple Computer, Inc., Mozilla * Portions of comments Copyright 2004-2008 Apple Computer, Inc., Mozilla
* Foundation, and Opera Software ASA. * Foundation, and Opera Software ASA.
* *
@ -104,10 +105,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
bool isSrcdocDocument; bool isSrcdocDocument;
public: public:
void startTokenization(nsHtml5Tokenizer* self); void startTokenization(nsHtml5Tokenizer* self);
void doctype(nsIAtom* name, void doctype(nsIAtom* name, nsHtml5String publicIdentifier, nsHtml5String systemIdentifier, bool forceQuirks);
nsHtml5String publicIdentifier,
nsHtml5String systemIdentifier,
bool forceQuirks);
void comment(char16_t* buf, int32_t start, int32_t length); void comment(char16_t* buf, int32_t start, int32_t length);
void characters(const char16_t* buf, int32_t start, int32_t length); void characters(const char16_t* buf, int32_t start, int32_t length);
void zeroOriginatingReplacementCharacter(); void zeroOriginatingReplacementCharacter();
@ -123,8 +121,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
bool isTemplateModeStackEmpty(); bool isTemplateModeStackEmpty();
bool isSpecialParentInForeign(nsHtml5StackNode* stackNode); bool isSpecialParentInForeign(nsHtml5StackNode* stackNode);
public: public:
static nsHtml5String extractCharsetFromContent(nsHtml5String attributeValue, static nsHtml5String extractCharsetFromContent(nsHtml5String attributeValue, nsHtml5TreeBuilder* tb);
nsHtml5TreeBuilder* tb);
private: private:
void checkMetaCharset(nsHtml5HtmlAttributes* attributes); void checkMetaCharset(nsHtml5HtmlAttributes* attributes);
public: public:
@ -141,16 +138,9 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
void generateImpliedEndTagsExceptFor(nsIAtom* name); void generateImpliedEndTagsExceptFor(nsIAtom* name);
void generateImpliedEndTags(); void generateImpliedEndTags();
bool isSecondOnStackBody(); bool isSecondOnStackBody();
void documentModeInternal(nsHtml5DocumentMode m, void documentModeInternal(nsHtml5DocumentMode m, nsHtml5String publicIdentifier, nsHtml5String systemIdentifier, bool html4SpecificAdditionalErrorChecks);
nsHtml5String publicIdentifier, bool isAlmostStandards(nsHtml5String publicIdentifier, nsHtml5String systemIdentifier);
nsHtml5String systemIdentifier, bool isQuirky(nsIAtom* name, nsHtml5String publicIdentifier, nsHtml5String systemIdentifier, bool forceQuirks);
bool html4SpecificAdditionalErrorChecks);
bool isAlmostStandards(nsHtml5String publicIdentifier,
nsHtml5String systemIdentifier);
bool isQuirky(nsIAtom* name,
nsHtml5String publicIdentifier,
nsHtml5String systemIdentifier,
bool forceQuirks);
void closeTheCell(int32_t eltPos); void closeTheCell(int32_t eltPos);
int32_t findLastInTableScopeTdTh(); int32_t findLastInTableScopeTdTh();
void clearStackBackTo(int32_t eltPos); void clearStackBackTo(int32_t eltPos);
@ -236,9 +226,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
void markMalformedIfScript(nsIContentHandle* elt); void markMalformedIfScript(nsIContentHandle* elt);
void start(bool fragmentMode); void start(bool fragmentMode);
void end(); void end();
void appendDoctypeToDocument(nsIAtom* name, void appendDoctypeToDocument(nsIAtom* name, nsHtml5String publicIdentifier, nsHtml5String systemIdentifier);
nsHtml5String publicIdentifier,
nsHtml5String systemIdentifier);
void elementPushed(int32_t ns, nsIAtom* name, nsIContentHandle* node); void elementPushed(int32_t ns, nsIAtom* name, nsIContentHandle* node);
void elementPopped(int32_t ns, nsIAtom* name, nsIContentHandle* node); void elementPopped(int32_t ns, nsIAtom* name, nsIContentHandle* node);
public: public:

View file

@ -1,6 +1,7 @@
/* /*
* Copyright (c) 2008-2010 Mozilla Foundation * Copyright (c) 2008-2010 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),

View file

@ -1,6 +1,7 @@
/* /*
* Copyright (c) 2008-2010 Mozilla Foundation * Copyright (c) 2008-2010 Mozilla Foundation
* Copyright (c) 2019 Moonchild Productions * Copyright (c) 2018-2020 Moonchild Productions
* Copyright (c) 2020 Binary Outcast
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),