зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1483458 - Change HTML parser to look at .py Atom files. r=hsivonen,heycam
--HG-- extra : amend_source : 9285251fc49d4f56b67557ef77e163d6acbc2b1e
This commit is contained in:
Родитель
36fea05e0e
Коммит
580c9a51e4
|
@ -37,13 +37,13 @@ translate:: translator \
|
|||
; mkdir -p ../javasrc ; \
|
||||
java -jar translator.jar \
|
||||
htmlparser/src/nu/validator/htmlparser/impl \
|
||||
.. ../../../xpcom/ds/nsGkAtomList.h
|
||||
.. ../../../xpcom/ds/StaticAtoms.py ../../../xpcom/ds/HTMLAtoms.py
|
||||
|
||||
translate_from_snapshot:: translator \
|
||||
; mkdir -p ../javasrc ; \
|
||||
java -jar translator.jar \
|
||||
../javasrc \
|
||||
.. ../../../dom/base/nsGkAtomList.h
|
||||
.. ../../../xpcom/ds/StaticAtoms.py ../../../xpcom/ds/HTMLAtoms.py
|
||||
|
||||
named_characters:: translator \
|
||||
; java -cp translator.jar \
|
||||
|
|
|
@ -58,15 +58,12 @@ class nsHtml5AttributeName
|
|||
{
|
||||
public:
|
||||
static int32_t* ALL_NO_NS;
|
||||
|
||||
private:
|
||||
static int32_t* XMLNS_NS;
|
||||
static int32_t* XML_NS;
|
||||
static int32_t* XLINK_NS;
|
||||
|
||||
public:
|
||||
static nsAtom** ALL_NO_PREFIX;
|
||||
|
||||
private:
|
||||
static nsAtom** XMLNS_PREFIX;
|
||||
static nsAtom** XLINK_PREFIX;
|
||||
|
@ -74,7 +71,6 @@ private:
|
|||
static nsAtom** SVG_DIFFERENT(nsAtom* name, nsAtom* camel);
|
||||
static nsAtom** MATH_DIFFERENT(nsAtom* name, nsAtom* camel);
|
||||
static nsAtom** COLONIFIED_LOCAL(nsAtom* name, nsAtom* suffix);
|
||||
|
||||
public:
|
||||
static nsAtom** SAME_LOCAL(nsAtom* name);
|
||||
inline static int32_t levelOrderBinarySearch(jArray<int32_t, int32_t> data,
|
||||
|
@ -162,7 +158,6 @@ private:
|
|||
nsAtom** prefix;
|
||||
bool custom;
|
||||
nsHtml5AttributeName(int32_t* uri, nsAtom** local, nsAtom** prefix);
|
||||
|
||||
public:
|
||||
nsHtml5AttributeName();
|
||||
inline bool isInterned() { return !custom; }
|
||||
|
@ -674,11 +669,9 @@ public:
|
|||
static nsHtml5AttributeName* ATTR_FY;
|
||||
static nsHtml5AttributeName* ATTR_RY;
|
||||
static nsHtml5AttributeName* ATTR_REFY;
|
||||
|
||||
private:
|
||||
static nsHtml5AttributeName** ATTRIBUTE_NAMES;
|
||||
static staticJArray<int32_t, int32_t> ATTRIBUTE_HASHES;
|
||||
|
||||
public:
|
||||
static void initializeStatics();
|
||||
static void releaseStatics();
|
||||
|
|
|
@ -80,7 +80,6 @@ private:
|
|||
nsAtom* camelCaseName;
|
||||
mozilla::dom::HTMLContentCreatorFunction htmlCreator;
|
||||
mozilla::dom::SVGContentCreatorFunction svgCreator;
|
||||
|
||||
public:
|
||||
int32_t flags;
|
||||
inline nsAtom* getName() { return name; }
|
||||
|
@ -406,11 +405,9 @@ public:
|
|||
static nsHtml5ElementName* ELT_RUBY;
|
||||
static nsHtml5ElementName* ELT_SUMMARY;
|
||||
static nsHtml5ElementName* ELT_TBODY;
|
||||
|
||||
private:
|
||||
static nsHtml5ElementName** ELEMENT_NAMES;
|
||||
static staticJArray<int32_t, int32_t> ELEMENT_HASHES;
|
||||
|
||||
public:
|
||||
static void initializeStatics();
|
||||
static void releaseStatics();
|
||||
|
|
|
@ -120,17 +120,14 @@ private:
|
|||
|
||||
protected:
|
||||
nsHtml5ByteReadable* readable;
|
||||
|
||||
private:
|
||||
int32_t metaState;
|
||||
int32_t contentIndex;
|
||||
int32_t charsetIndex;
|
||||
int32_t httpEquivIndex;
|
||||
int32_t contentTypeIndex;
|
||||
|
||||
protected:
|
||||
int32_t stateSave;
|
||||
|
||||
private:
|
||||
int32_t strBufLen;
|
||||
autoJArray<char16_t, int32_t> strBuf;
|
||||
|
@ -138,14 +135,11 @@ private:
|
|||
nsHtml5String charset;
|
||||
int32_t httpEquivState;
|
||||
nsHtml5TreeBuilder* treeBuilder;
|
||||
|
||||
public:
|
||||
explicit nsHtml5MetaScanner(nsHtml5TreeBuilder* tb);
|
||||
~nsHtml5MetaScanner();
|
||||
|
||||
protected:
|
||||
void stateLoop(int32_t state);
|
||||
|
||||
private:
|
||||
void handleCharInAttributeValue(int32_t c);
|
||||
inline int32_t toAsciiLowerCase(int32_t c)
|
||||
|
@ -160,10 +154,8 @@ private:
|
|||
void handleAttributeValue();
|
||||
bool handleTag();
|
||||
bool handleTagInner();
|
||||
|
||||
protected:
|
||||
bool tryCharset(nsHtml5String encoding);
|
||||
|
||||
public:
|
||||
static void initializeStatics();
|
||||
static void releaseStatics();
|
||||
|
|
|
@ -66,11 +66,9 @@ public:
|
|||
int32_t ns;
|
||||
nsIContentHandle* node;
|
||||
nsHtml5HtmlAttributes* attributes;
|
||||
|
||||
private:
|
||||
int32_t refcount;
|
||||
mozilla::dom::HTMLContentCreatorFunction htmlCreator;
|
||||
|
||||
public:
|
||||
inline int32_t getFlags() { return flags; }
|
||||
|
||||
|
@ -106,7 +104,6 @@ public:
|
|||
private:
|
||||
static int32_t prepareSvgFlags(int32_t flags);
|
||||
static int32_t prepareMathFlags(int32_t flags, bool markAsIntegrationPoint);
|
||||
|
||||
public:
|
||||
~nsHtml5StackNode();
|
||||
void dropAttributes();
|
||||
|
|
|
@ -68,7 +68,6 @@ private:
|
|||
bool framesetOk;
|
||||
bool needToDropLF;
|
||||
bool quirks;
|
||||
|
||||
public:
|
||||
nsHtml5StateSnapshot(
|
||||
jArray<nsHtml5StackNode*, int32_t> stack,
|
||||
|
|
|
@ -235,19 +235,15 @@ private:
|
|||
static staticJArray<char16_t, int32_t> NOEMBED_ARR;
|
||||
static staticJArray<char16_t, int32_t> NOSCRIPT_ARR;
|
||||
static staticJArray<char16_t, int32_t> NOFRAMES_ARR;
|
||||
|
||||
protected:
|
||||
nsHtml5TreeBuilder* tokenHandler;
|
||||
nsHtml5StreamParser* encodingDeclarationHandler;
|
||||
bool lastCR;
|
||||
int32_t stateSave;
|
||||
|
||||
private:
|
||||
int32_t returnStateSave;
|
||||
|
||||
protected:
|
||||
int32_t index;
|
||||
|
||||
private:
|
||||
bool forceQuirks;
|
||||
char16_t additional;
|
||||
|
@ -257,16 +253,12 @@ private:
|
|||
int32_t hi;
|
||||
int32_t candidate;
|
||||
int32_t charRefBufMark;
|
||||
|
||||
protected:
|
||||
int32_t value;
|
||||
|
||||
private:
|
||||
bool seenDigits;
|
||||
|
||||
protected:
|
||||
int32_t cstart;
|
||||
|
||||
private:
|
||||
nsHtml5String publicId;
|
||||
nsHtml5String systemId;
|
||||
|
@ -276,24 +268,18 @@ private:
|
|||
int32_t charRefBufLen;
|
||||
autoJArray<char16_t, int32_t> bmpChar;
|
||||
autoJArray<char16_t, int32_t> astralChar;
|
||||
|
||||
protected:
|
||||
nsHtml5ElementName* endTagExpectation;
|
||||
|
||||
private:
|
||||
jArray<char16_t, int32_t> endTagExpectationAsArray;
|
||||
|
||||
protected:
|
||||
bool endTag;
|
||||
|
||||
private:
|
||||
bool containsHyphen;
|
||||
nsHtml5ElementName* tagName;
|
||||
nsHtml5ElementName* nonInternedTagName;
|
||||
|
||||
protected:
|
||||
nsHtml5AttributeName* attributeName;
|
||||
|
||||
private:
|
||||
nsHtml5AttributeName* nonInternedAttributeName;
|
||||
nsAtom* doctypeName;
|
||||
|
@ -302,16 +288,13 @@ private:
|
|||
nsHtml5HtmlAttributes* attributes;
|
||||
bool newAttributesEachTime;
|
||||
bool shouldSuspend;
|
||||
|
||||
protected:
|
||||
bool confident;
|
||||
|
||||
private:
|
||||
int32_t line;
|
||||
int32_t attributeLine;
|
||||
nsHtml5AtomTable* interner;
|
||||
bool viewingXmlSource;
|
||||
|
||||
public:
|
||||
nsHtml5Tokenizer(nsHtml5TreeBuilder* tokenHandler, bool viewingXmlSource);
|
||||
void setInterner(nsHtml5AtomTable* interner);
|
||||
|
@ -324,13 +307,11 @@ public:
|
|||
|
||||
private:
|
||||
void endTagExpectationToArray();
|
||||
|
||||
public:
|
||||
void setLineNumber(int32_t line);
|
||||
inline int32_t getLineNumber() { return line; }
|
||||
|
||||
nsHtml5HtmlAttributes* emptyAttributes();
|
||||
|
||||
private:
|
||||
inline void appendCharRefBuf(char16_t c)
|
||||
{
|
||||
|
@ -369,7 +350,6 @@ private:
|
|||
|
||||
protected:
|
||||
nsHtml5String strBufToString();
|
||||
|
||||
private:
|
||||
void strBufToDoctypeName();
|
||||
void emitStrBuf();
|
||||
|
@ -389,21 +369,17 @@ private:
|
|||
}
|
||||
|
||||
void emitComment(int32_t provisionalHyphens, int32_t pos);
|
||||
|
||||
protected:
|
||||
void flushChars(char16_t* buf, int32_t pos);
|
||||
|
||||
private:
|
||||
void strBufToElementNameString();
|
||||
int32_t emitCurrentTagToken(bool selfClosing, int32_t pos);
|
||||
void attributeNameComplete();
|
||||
void addAttributeWithoutValue();
|
||||
void addAttributeWithValue();
|
||||
|
||||
public:
|
||||
void start();
|
||||
bool tokenizeBuffer(nsHtml5UTF16Buffer* buffer);
|
||||
|
||||
private:
|
||||
template<class P>
|
||||
int32_t stateLoop(int32_t state,
|
||||
|
@ -455,23 +431,18 @@ private:
|
|||
void bogusDoctype();
|
||||
void bogusDoctypeWithoutQuirks();
|
||||
void handleNcrValue(int32_t returnState);
|
||||
|
||||
public:
|
||||
void eof();
|
||||
|
||||
private:
|
||||
void emitDoctypeToken(int32_t pos);
|
||||
|
||||
protected:
|
||||
inline char16_t checkChar(char16_t* buf, int32_t pos) { return buf[pos]; }
|
||||
|
||||
public:
|
||||
bool internalEncodingDeclaration(nsHtml5String internalCharset);
|
||||
|
||||
private:
|
||||
void emitOrAppendTwo(const char16_t* val, int32_t returnState);
|
||||
void emitOrAppendOne(const char16_t* val, int32_t returnState);
|
||||
|
||||
public:
|
||||
void end();
|
||||
void requestSuspension();
|
||||
|
|
|
@ -71,7 +71,6 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
|
|||
{
|
||||
private:
|
||||
static char16_t REPLACEMENT_CHARACTER[];
|
||||
|
||||
public:
|
||||
static const int32_t OTHER = 0;
|
||||
|
||||
|
@ -288,10 +287,8 @@ private:
|
|||
int32_t mode;
|
||||
int32_t originalMode;
|
||||
bool framesetOk;
|
||||
|
||||
protected:
|
||||
nsHtml5Tokenizer* tokenizer;
|
||||
|
||||
private:
|
||||
bool scriptingEnabled;
|
||||
bool needToDropLF;
|
||||
|
@ -311,11 +308,9 @@ private:
|
|||
nsIContentHandle* formPointer;
|
||||
nsIContentHandle* headPointer;
|
||||
nsIContentHandle* deepTreeSurrogateParent;
|
||||
|
||||
protected:
|
||||
autoJArray<char16_t, int32_t> charBuffer;
|
||||
int32_t charBufferLen;
|
||||
|
||||
private:
|
||||
bool quirks;
|
||||
bool isSrcdocDocument;
|
||||
|
@ -362,17 +357,14 @@ private:
|
|||
bool isTemplateContents();
|
||||
bool isTemplateModeStackEmpty();
|
||||
bool isSpecialParentInForeign(nsHtml5StackNode* stackNode);
|
||||
|
||||
public:
|
||||
static nsHtml5String extractCharsetFromContent(nsHtml5String attributeValue,
|
||||
nsHtml5TreeBuilder* tb);
|
||||
|
||||
private:
|
||||
void checkMetaCharset(nsHtml5HtmlAttributes* attributes);
|
||||
|
||||
public:
|
||||
void endTag(nsHtml5ElementName* elementName);
|
||||
|
||||
private:
|
||||
void endTagTemplateInHead();
|
||||
int32_t findLastInTableScopeOrRootTemplateTbodyTheadTfoot();
|
||||
|
@ -435,10 +427,8 @@ private:
|
|||
void addAttributesToHtml(nsHtml5HtmlAttributes* attributes);
|
||||
void pushHeadPointerOntoStack();
|
||||
void reconstructTheActiveFormattingElements();
|
||||
|
||||
public:
|
||||
void notifyUnusedStackNode(int32_t idxInStackNodes);
|
||||
|
||||
private:
|
||||
nsHtml5StackNode* getUnusedStackNode();
|
||||
nsHtml5StackNode* createStackNode(
|
||||
|
@ -521,7 +511,6 @@ private:
|
|||
void appendVoidInputToCurrent(nsHtml5HtmlAttributes* attributes,
|
||||
nsIContentHandle* form);
|
||||
void appendVoidFormToCurrent(nsHtml5HtmlAttributes* attributes);
|
||||
|
||||
protected:
|
||||
void accumulateCharacters(const char16_t* buf, int32_t start, int32_t length);
|
||||
void requestSuspension();
|
||||
|
@ -579,14 +568,12 @@ protected:
|
|||
nsHtml5String systemIdentifier);
|
||||
void elementPushed(int32_t ns, nsAtom* name, nsIContentHandle* node);
|
||||
void elementPopped(int32_t ns, nsAtom* name, nsIContentHandle* node);
|
||||
|
||||
public:
|
||||
inline bool cdataSectionAllowed() { return isInForeign(); }
|
||||
|
||||
private:
|
||||
bool isInForeign();
|
||||
bool isInForeignButNotHtmlOrMathTextIntegrationPoint();
|
||||
|
||||
public:
|
||||
void setFragmentContext(nsAtom* context,
|
||||
int32_t ns,
|
||||
|
@ -595,16 +582,13 @@ public:
|
|||
|
||||
protected:
|
||||
nsIContentHandle* currentNode();
|
||||
|
||||
public:
|
||||
bool isScriptingEnabled();
|
||||
void setScriptingEnabled(bool scriptingEnabled);
|
||||
void setIsSrcdocDocument(bool isSrcdocDocument);
|
||||
void flushCharacters();
|
||||
|
||||
private:
|
||||
bool charBufferContainsNonWhitespace();
|
||||
|
||||
public:
|
||||
nsAHtml5TreeBuilderState* newSnapshot();
|
||||
bool snapshotMatches(nsAHtml5TreeBuilderState* snapshot);
|
||||
|
|
|
@ -60,7 +60,6 @@ private:
|
|||
char16_t* buffer;
|
||||
int32_t start;
|
||||
int32_t end;
|
||||
|
||||
public:
|
||||
int32_t getStart();
|
||||
void setStart(int32_t start);
|
||||
|
|
|
@ -17,8 +17,13 @@ import sys
|
|||
# The first argument is the atom's identifier.
|
||||
# The second argument is the atom's string value.
|
||||
#
|
||||
# Please keep the Atom() definitions on one line as this is parsed by the
|
||||
# htmlparser: parser/html/java/htmlparser
|
||||
# Please keep "START ATOMS" and "END ATOMS" comments as the parser uses them.
|
||||
#
|
||||
# It is not possible to conditionally define static atoms with #ifdef etc.
|
||||
STATIC_ATOMS = [
|
||||
# START ATOMS
|
||||
# --------------------------------------------------------------------------
|
||||
# Generic atoms
|
||||
# --------------------------------------------------------------------------
|
||||
|
@ -75,8 +80,7 @@ STATIC_ATOMS = [
|
|||
Atom("allowpopupstoescapesandbox", "allow-popups-to-escape-sandbox"),
|
||||
Atom("allowpopups", "allow-popups"),
|
||||
Atom("allowpresentation", "allow-presentation"),
|
||||
Atom("allowstorageaccessbyuseractivatetion",
|
||||
"allow-storage-access-by-user-activation"),
|
||||
Atom("allowstorageaccessbyuseractivatetion", "allow-storage-access-by-user-activation"),
|
||||
Atom("allowsameorigin", "allow-same-origin"),
|
||||
Atom("allowscripts", "allow-scripts"),
|
||||
Atom("allowscriptstoclose", "allowscriptstoclose"),
|
||||
|
@ -2316,6 +2320,7 @@ STATIC_ATOMS = [
|
|||
InheritingAnonBoxAtom("AnonBox_mozSVGOuterSVGAnonChild", ":-moz-svg-outer-svg-anon-child"),
|
||||
InheritingAnonBoxAtom("AnonBox_mozSVGForeignContent", ":-moz-svg-foreign-content"),
|
||||
InheritingAnonBoxAtom("AnonBox_mozSVGText", ":-moz-svg-text"),
|
||||
# END ATOMS
|
||||
] + HTML_PARSER_ATOMS
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче