Initial attempt at HTML5 parsing in Gecko

This commit is contained in:
Henri Sivonen 2008-12-12 15:10:39 -08:00
parent 9533587227
commit 9abd1a5a22
47 changed files with 38500 additions and 82 deletions

View File

@ -779,7 +779,7 @@ nsContentSink::ProcessStyleLink(nsIContent* aElement,
nsresult
nsContentSink::ProcessMETATag(nsIContent* aContent)
{
NS_ASSERTION(aContent, "missing base-element");
NS_ASSERTION(aContent, "missing meta-element");
nsresult rv = NS_OK;
@ -795,6 +795,16 @@ nsContentSink::ProcessMETATag(nsIContent* aContent)
rv = ProcessHeaderData(fieldAtom, result, aContent);
}
}
NS_ENSURE_SUCCESS(rv, rv);
/* Look for the viewport meta tag. If we find it, process it and put the
* data into the document header. */
if (aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
nsGkAtoms::viewport, eIgnoreCase)) {
nsAutoString value;
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::content, value);
rv = nsContentUtils::ProcessViewportInfo(mDocument, value);
}
return rv;
}

View File

@ -147,6 +147,8 @@ class nsContentSink : public nsICSSLoaderObserver,
virtual void UpdateChildCounts() = 0;
PRBool IsTimeToNotify();
protected:
nsContentSink();
virtual ~nsContentSink();
@ -255,10 +257,9 @@ protected:
// Start layout. If aIgnorePendingSheets is true, this will happen even if
// we still have stylesheet loads pending. Otherwise, we'll wait until the
// stylesheets are all done loading.
public:
void StartLayout(PRBool aIgnorePendingSheets);
PRBool IsTimeToNotify();
protected:
void
FavorPerformanceHint(PRBool perfOverStarvation, PRUint32 starvationDelay);

View File

@ -42,6 +42,6 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = content document
DIRS = content document parser
include $(topsrcdir)/config/rules.mk

View File

@ -75,6 +75,7 @@ REQUIRES = xpcom \
editor \
plugin \
txtsvc \
html5 \
$(NULL)
CPPSRCS = \

View File

@ -210,8 +210,6 @@ public:
NS_IMETHOD IsEnabled(PRInt32 aTag, PRBool* aReturn);
NS_IMETHOD_(PRBool) IsFormOnStack();
virtual nsresult ProcessMETATag(nsIContent* aContent);
#ifdef DEBUG
// nsIDebugDumpContent
NS_IMETHOD DumpContentModel();
@ -2971,33 +2969,6 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
return result;
}
/*
* Extends nsContentSink::ProcessMETATag to grab the 'viewport' meta tag. This
* information is ignored by the generic content sink because it only stores
* http-equiv meta tags.
*
* Initially implemented for bug #436083
*/
nsresult
HTMLContentSink::ProcessMETATag(nsIContent *aContent) {
/* Call the superclass method. */
nsContentSink::ProcessMETATag(aContent);
nsresult rv = NS_OK;
/* Look for the viewport meta tag. If we find it, process it and put the
* data into the document header. */
if (aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
nsGkAtoms::viewport, eIgnoreCase)) {
nsAutoString value;
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::content, value);
rv = nsContentUtils::ProcessViewportInfo(mDocument, value);
}
return rv;
}
#ifdef DEBUG
void
HTMLContentSink::ForceReflow()

View File

@ -141,6 +141,7 @@
#include "nsIInlineSpellChecker.h"
#include "nsRange.h"
#include "mozAutoDocUpdate.h"
#include "nsHtml5Module.h"
#define NS_MAX_DOCUMENT_WRITE_DEPTH 20
@ -650,6 +651,11 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
PRBool aReset,
nsIContentSink* aSink)
{
PRBool loadAsHtml5 = nsContentUtils::GetBoolPref("html5.enable", PR_TRUE);
if (aSink) {
loadAsHtml5 = PR_FALSE;
}
nsCAutoString contentType;
aChannel->GetContentType(contentType);
@ -659,6 +665,11 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
mIsRegularHTML = PR_FALSE;
mCompatMode = eCompatibility_FullStandards;
loadAsHtml5 = PR_FALSE;
}
if (!(contentType.Equals("text/html") && aCommand && !nsCRT::strcmp(aCommand, "view"))) {
loadAsHtml5 = PR_FALSE;
}
#ifdef DEBUG
else {
@ -705,8 +716,12 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
}
if (needsParser) {
mParser = do_CreateInstance(kCParserCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
if (loadAsHtml5) {
mParser = nsHtml5Module::NewHtml5Parser();
} else {
mParser = do_CreateInstance(kCParserCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
}
}
PRInt32 textType = GET_BIDI_OPTION_TEXTTYPE(GetBidiOptions());
@ -921,9 +936,10 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
// create the content sink
nsCOMPtr<nsIContentSink> sink;
if (aSink)
if (aSink) {
NS_ASSERTION((!loadAsHtml5), "Panic: We are loading as HTML5 and someone tries to set an external sink!");
sink = aSink;
else {
} else {
if (IsXHTML()) {
nsCOMPtr<nsIXMLContentSink> xmlsink;
rv = NS_NewXMLContentSink(getter_AddRefs(xmlsink), this, uri,
@ -931,12 +947,17 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
sink = xmlsink;
} else {
nsCOMPtr<nsIHTMLContentSink> htmlsink;
if (loadAsHtml5) {
nsHtml5Module::Initialize(mParser, this, uri, docShell, aChannel);
sink = mParser->GetContentSink();
} else {
nsCOMPtr<nsIHTMLContentSink> htmlsink;
rv = NS_NewHTMLContentSink(getter_AddRefs(htmlsink), this, uri,
docShell, aChannel);
rv = NS_NewHTMLContentSink(getter_AddRefs(htmlsink), this, uri,
docShell, aChannel);
sink = htmlsink;
sink = htmlsink;
}
}
NS_ENSURE_SUCCESS(rv, rv);
@ -1783,6 +1804,8 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
PRBool loadAsHtml5 = nsContentUtils::GetBoolPref("html5.enable", PR_TRUE);
nsresult rv = NS_OK;
// If we already have a parser we ignore the document.open call.
@ -1929,6 +1952,23 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
}
}
if (loadAsHtml5) {
// Really zap all children (copied from nsDocument.cpp -- maybe factor into a method)
PRUint32 count = mChildren.ChildCount();
{ // Scope for update
MOZ_AUTO_DOC_UPDATE(this, UPDATE_CONTENT_MODEL, PR_TRUE);
for (PRInt32 i = PRInt32(count) - 1; i >= 0; i--) {
nsCOMPtr<nsIContent> content = mChildren.ChildAt(i);
// XXXbz this is backwards from how ContentRemoved normally works. That
// is, usually it's dispatched after the content has been removed from
// the tree.
nsNodeUtils::ContentRemoved(this, content, i);
content->UnbindFromTree();
mChildren.RemoveChildAt(i);
}
}
}
// XXX This is a nasty workaround for a scrollbar code bug
// (http://bugzilla.mozilla.org/show_bug.cgi?id=55334).
@ -1998,7 +2038,12 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
// resetting the document.
mSecurityInfo = securityInfo;
mParser = do_CreateInstance(kCParserCID, &rv);
if (loadAsHtml5) {
mParser = nsHtml5Module::NewHtml5Parser();
rv = NS_OK;
} else {
mParser = do_CreateInstance(kCParserCID, &rv);
}
// This will be propagated to the parser when someone actually calls write()
mContentType = aContentType;
@ -2006,18 +2051,22 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
mWriteState = eDocumentOpened;
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIHTMLContentSink> sink;
if (loadAsHtml5) {
nsHtml5Module::Initialize(mParser, this, uri, shell, channel);
} else {
nsCOMPtr<nsIHTMLContentSink> sink;
rv = NS_NewHTMLContentSink(getter_AddRefs(sink), this, uri, shell,
channel);
if (NS_FAILED(rv)) {
// Don't use a parser without a content sink.
mParser = nsnull;
mWriteState = eNotWriting;
return rv;
rv = NS_NewHTMLContentSink(getter_AddRefs(sink), this, uri, shell,
channel);
if (NS_FAILED(rv)) {
// Don't use a parser without a content sink.
mParser = nsnull;
mWriteState = eNotWriting;
return rv;
}
mParser->SetContentSink(sink);
}
mParser->SetContentSink(sink);
}
// Prepare the docshell and the document viewer for the impending

View File

@ -0,0 +1,52 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src
# ifdef ENABLE_TESTS
# DIRS += test
# endif
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,51 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = html5
EXPORTS = \
nsHtml5Module.h \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,52 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is HTML Parser C++ Translator code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Henri Sivonen <hsivonen@iki.fi>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsHtml5Module_h__
#define nsHtml5Module_h__
#include "nsIParser.h"
class nsHtml5Module
{
public:
static void InitializeStatics();
static void ReleaseStatics();
static already_AddRefed<nsIParser> NewHtml5Parser();
static nsresult Initialize(nsIParser* aParser, nsIDocument* aDoc, nsIURI* aURI, nsISupports* aContainer, nsIChannel* aChannel);
};
#endif // nsHtml5Module_h__

View File

@ -0,0 +1,89 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = html5
LIBRARY_NAME = html5p
LIBXUL_LIBRARY = 1
REQUIRES = \
gfx \
thebes \
locale \
js \
pref \
necko \
xpcom \
string \
htmlparser \
content \
layout \
widget \
dom \
uconv \
xpconnect \
util \
$(NULL)
CPPSRCS = \
nsHtml5Atoms.cpp \
nsHtml5Parser.cpp \
nsHtml5AttributeName.cpp \
nsHtml5ElementName.cpp \
nsHtml5HtmlAttributes.cpp \
nsHtml5StackNode.cpp \
nsHtml5UTF16Buffer.cpp \
nsHtml5NamedCharacters.cpp \
nsHtml5StringLiterals.cpp \
nsHtml5Tokenizer.cpp \
nsHtml5TreeBuilder.cpp \
nsHtml5Portability.cpp \
nsHtml5Module.cpp \
$(NULL)
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
INCLUDES += \
-I$(srcdir)/../../../base/src \
$(NULL)

View File

@ -0,0 +1,103 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is HTML Parser C++ Translator code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Henri Sivonen <hsivonen@iki.fi>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef jArray_h__
#define jArray_h__
#define J_ARRAY_STATIC(T, L, arr) \
jArray<T,L>( (arr), (sizeof(arr)/sizeof(arr[0])) )
template<class T, class L>
class jArray {
private:
T* arr;
public:
L length;
jArray(T* const a, L const len);
jArray(L const len);
jArray(const jArray<T,L>& other);
jArray();
operator T*() { return arr; }
T& operator[] (L const index) { return arr[index]; }
void release() { delete[] arr; }
L binarySearch(T const elem);
};
template<class T, class L>
jArray<T,L>::jArray(T* const a, L const len)
: arr(a), length(len)
{
}
template<class T, class L>
jArray<T,L>::jArray(L const len)
: arr(new T[len]), length(len)
{
}
template<class T, class L>
jArray<T,L>::jArray(const jArray<T,L>& other)
: arr(other.arr), length(other.length)
{
}
template<class T, class L>
jArray<T,L>::jArray()
: arr(0), length(0)
{
}
template<class T, class L>
L
jArray<T,L>::binarySearch(T const elem)
{
L lo = 0;
L hi = length - 1;
while (lo <= hi) {
L mid = (lo + hi) / 2;
if (arr[mid] > elem) {
hi = mid - 1;
} else if (arr[mid] < elem) {
lo = mid + 1;
} else {
return mid;
}
}
return -1;
}
#endif // jArray_h__

View File

@ -0,0 +1,102 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is HTML Parser C++ Translator code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Henri Sivonen <hsivonen@iki.fi>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsHtml5ArrayCopy_h__
#define nsHtml5ArrayCopy_h__
#include "prtypes.h"
class nsString;
class nsHtml5StackNode;
class nsHtml5AttributeName;
// Unfortunately, these don't work as template functions because the arguments
// would need coercion from a template class, which complicates things.
class nsHtml5ArrayCopy {
public:
static
inline
void
arraycopy(PRUnichar* source, PRInt32 sourceOffset, PRUnichar* target, PRInt32 targetOffset, PRInt32 length)
{
memcpy(&(target[targetOffset]), &(source[sourceOffset]), length * sizeof(PRUnichar));
}
static
inline
void
arraycopy(PRUnichar* source, PRUnichar* target, PRInt32 length)
{
memcpy(target, source, length * sizeof(PRUnichar));
}
static
inline
void
arraycopy(nsString** source, nsString** target, PRInt32 length)
{
memcpy(target, source, length * sizeof(nsString*));
}
static
inline
void
arraycopy(nsHtml5AttributeName** source, nsHtml5AttributeName** target, PRInt32 length)
{
memcpy(target, source, length * sizeof(nsHtml5AttributeName*));
}
static
inline
void
arraycopy(nsHtml5StackNode** source, nsHtml5StackNode** target, PRInt32 length)
{
memcpy(target, source, length * sizeof(nsHtml5StackNode*));
}
static
inline
void
arraycopy(nsHtml5StackNode** arr, PRInt32 sourceOffset, PRInt32 targetOffset, PRInt32 length)
{
memmove(&(arr[targetOffset]), &(arr[sourceOffset]), length * sizeof(nsHtml5StackNode*));
}
};
#endif // nsHtml5ArrayCopy_h__

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,62 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* This class wraps up the creation (and destruction) of the standard
* set of atoms used by gklayout; the atoms are created when gklayout
* is loaded and they are destroyed when gklayout is unloaded.
*/
#include "nsHtml5Atoms.h"
#include "nsStaticAtom.h"
// define storage for all atoms
#define HTML5_ATOM(_name, _value) nsIAtom* nsHtml5Atoms::_name;
#include "nsHtml5AtomList.h"
#undef HTML5_ATOM
static const nsStaticAtom Html5Atoms_info[] = {
#define HTML5_ATOM(name_, value_) { value_, &nsHtml5Atoms::name_ },
#include "nsHtml5AtomList.h"
#undef HTML5_ATOM
};
void nsHtml5Atoms::AddRefAtoms()
{
NS_RegisterStaticAtoms(Html5Atoms_info, NS_ARRAY_LENGTH(Html5Atoms_info));
}

View File

@ -0,0 +1,66 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* This class wraps up the creation (and destruction) of the standard
* set of atoms used by gklayout; the atoms are created when gklayout
* is loaded and they are destroyed when gklayout is unloaded.
*/
#ifndef nsHtml5Atoms_h___
#define nsHtml5Atoms_h___
#include "nsIAtom.h"
class nsHtml5Atoms {
public:
static void AddRefAtoms();
/* Declare all atoms
The atom names and values are stored in nsGkAtomList.h and
are brought to you by the magic of C preprocessing
Add new atoms to nsGkAtomList and all support logic will be auto-generated
*/
#define HTML5_ATOM(_name, _value) static nsIAtom* _name;
#include "nsHtml5AtomList.h"
#undef HTML5_ATOM
};
#endif /* nsHtml5Atoms_h___ */

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,47 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is HTML Parser C++ Translator code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Henri Sivonen <hsivonen@iki.fi>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsHtml5DocumentMode_h__
#define nsHtml5DocumentMode_h__
enum nsHtml5DocumentMode {
STANDARDS_MODE,
ALMOST_STANDARDS_MODE,
QUIRKS_MODE
};
#endif // nsHtml5DocumentMode_h__

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,878 @@
/*
* Copyright (c) 2008 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* 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
* DEALINGS IN THE SOFTWARE.
*/
/*
* THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
* Please edit ElementName.java instead and regenerate.
*/
#ifndef nsHtml5ElementName_h__
#define nsHtml5ElementName_h__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsString.h"
#include "nsINameSpaceManager.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "jArray.h"
#include "nsHtml5DocumentMode.h"
#include "nsHtml5ArrayCopy.h"
#include "nsHtml5NamedCharacters.h"
#include "nsHtml5Parser.h"
#include "nsHtml5StringLiterals.h"
#include "nsHtml5Atoms.h"
class nsHtml5Parser;
class nsHtml5Tokenizer;
class nsHtml5TreeBuilder;
class nsHtml5AttributeName;
class nsHtml5HtmlAttributes;
class nsHtml5StackNode;
class nsHtml5UTF16Buffer;
class nsHtml5Portability;
class nsHtml5ElementName
{
public:
static nsHtml5ElementName* NULL_ELEMENT_NAME;
nsIAtom* name;
nsIAtom* camelCaseName;
PRInt32 group;
PRBool special;
PRBool scoping;
PRBool fosterParenting;
static nsHtml5ElementName* elementNameByBuffer(jArray<PRUnichar,PRInt32> buf, PRInt32 offset, PRInt32 length);
private:
static PRInt32 bufToHash(jArray<PRUnichar,PRInt32> buf, PRInt32 len);
nsHtml5ElementName(nsIAtom* name, nsIAtom* camelCaseName, PRInt32 group, PRBool special, PRBool scoping, PRBool fosterParenting);
nsHtml5ElementName(nsIAtom* name);
public:
void release();
private:
void destructor();
public:
static nsHtml5ElementName* A;
static nsHtml5ElementName* B;
static nsHtml5ElementName* G;
static nsHtml5ElementName* I;
static nsHtml5ElementName* P;
static nsHtml5ElementName* Q;
static nsHtml5ElementName* S;
static nsHtml5ElementName* U;
static nsHtml5ElementName* BR;
static nsHtml5ElementName* CI;
static nsHtml5ElementName* CN;
static nsHtml5ElementName* DD;
static nsHtml5ElementName* DL;
static nsHtml5ElementName* DT;
static nsHtml5ElementName* EM;
static nsHtml5ElementName* EQ;
static nsHtml5ElementName* FN;
static nsHtml5ElementName* H1;
static nsHtml5ElementName* H2;
static nsHtml5ElementName* H3;
static nsHtml5ElementName* H4;
static nsHtml5ElementName* H5;
static nsHtml5ElementName* H6;
static nsHtml5ElementName* GT;
static nsHtml5ElementName* HR;
static nsHtml5ElementName* IN;
static nsHtml5ElementName* LI;
static nsHtml5ElementName* LN;
static nsHtml5ElementName* LT;
static nsHtml5ElementName* MI;
static nsHtml5ElementName* MN;
static nsHtml5ElementName* MO;
static nsHtml5ElementName* MS;
static nsHtml5ElementName* OL;
static nsHtml5ElementName* OR;
static nsHtml5ElementName* PI;
static nsHtml5ElementName* RP;
static nsHtml5ElementName* RT;
static nsHtml5ElementName* TD;
static nsHtml5ElementName* TH;
static nsHtml5ElementName* TR;
static nsHtml5ElementName* TT;
static nsHtml5ElementName* UL;
static nsHtml5ElementName* AND;
static nsHtml5ElementName* ARG;
static nsHtml5ElementName* ABS;
static nsHtml5ElementName* BIG;
static nsHtml5ElementName* BDO;
static nsHtml5ElementName* CSC;
static nsHtml5ElementName* COL;
static nsHtml5ElementName* COS;
static nsHtml5ElementName* COT;
static nsHtml5ElementName* DEL;
static nsHtml5ElementName* DFN;
static nsHtml5ElementName* DIR;
static nsHtml5ElementName* DIV;
static nsHtml5ElementName* EXP;
static nsHtml5ElementName* GCD;
static nsHtml5ElementName* GEQ;
static nsHtml5ElementName* IMG;
static nsHtml5ElementName* INS;
static nsHtml5ElementName* INT;
static nsHtml5ElementName* KBD;
static nsHtml5ElementName* LOG;
static nsHtml5ElementName* LCM;
static nsHtml5ElementName* LEQ;
static nsHtml5ElementName* MTD;
static nsHtml5ElementName* MIN;
static nsHtml5ElementName* MAP;
static nsHtml5ElementName* MTR;
static nsHtml5ElementName* MAX;
static nsHtml5ElementName* NEQ;
static nsHtml5ElementName* NOT;
static nsHtml5ElementName* NAV;
static nsHtml5ElementName* PRE;
static nsHtml5ElementName* REM;
static nsHtml5ElementName* SUB;
static nsHtml5ElementName* SEC;
static nsHtml5ElementName* SVG;
static nsHtml5ElementName* SUM;
static nsHtml5ElementName* SIN;
static nsHtml5ElementName* SEP;
static nsHtml5ElementName* SUP;
static nsHtml5ElementName* SET;
static nsHtml5ElementName* TAN;
static nsHtml5ElementName* USE;
static nsHtml5ElementName* VAR;
static nsHtml5ElementName* WBR;
static nsHtml5ElementName* XMP;
static nsHtml5ElementName* XOR;
static nsHtml5ElementName* AREA;
static nsHtml5ElementName* ABBR;
static nsHtml5ElementName* BASE;
static nsHtml5ElementName* BVAR;
static nsHtml5ElementName* BODY;
static nsHtml5ElementName* CARD;
static nsHtml5ElementName* CODE;
static nsHtml5ElementName* CITE;
static nsHtml5ElementName* CSCH;
static nsHtml5ElementName* COSH;
static nsHtml5ElementName* COTH;
static nsHtml5ElementName* CURL;
static nsHtml5ElementName* DESC;
static nsHtml5ElementName* DIFF;
static nsHtml5ElementName* DEFS;
static nsHtml5ElementName* FORM;
static nsHtml5ElementName* FONT;
static nsHtml5ElementName* GRAD;
static nsHtml5ElementName* HEAD;
static nsHtml5ElementName* HTML;
static nsHtml5ElementName* LINE;
static nsHtml5ElementName* LINK;
static nsHtml5ElementName* LIST;
static nsHtml5ElementName* META;
static nsHtml5ElementName* MSUB;
static nsHtml5ElementName* MODE;
static nsHtml5ElementName* MATH;
static nsHtml5ElementName* MARK;
static nsHtml5ElementName* MASK;
static nsHtml5ElementName* MEAN;
static nsHtml5ElementName* MSUP;
static nsHtml5ElementName* MENU;
static nsHtml5ElementName* MROW;
static nsHtml5ElementName* NONE;
static nsHtml5ElementName* NOBR;
static nsHtml5ElementName* NEST;
static nsHtml5ElementName* PATH;
static nsHtml5ElementName* PLUS;
static nsHtml5ElementName* RULE;
static nsHtml5ElementName* REAL;
static nsHtml5ElementName* RELN;
static nsHtml5ElementName* RECT;
static nsHtml5ElementName* ROOT;
static nsHtml5ElementName* RUBY;
static nsHtml5ElementName* SECH;
static nsHtml5ElementName* SINH;
static nsHtml5ElementName* SPAN;
static nsHtml5ElementName* SAMP;
static nsHtml5ElementName* STOP;
static nsHtml5ElementName* SDEV;
static nsHtml5ElementName* TIME;
static nsHtml5ElementName* TRUE;
static nsHtml5ElementName* TREF;
static nsHtml5ElementName* TANH;
static nsHtml5ElementName* TEXT;
static nsHtml5ElementName* VIEW;
static nsHtml5ElementName* ASIDE;
static nsHtml5ElementName* AUDIO;
static nsHtml5ElementName* APPLY;
static nsHtml5ElementName* EMBED;
static nsHtml5ElementName* FRAME;
static nsHtml5ElementName* FALSE;
static nsHtml5ElementName* FLOOR;
static nsHtml5ElementName* GLYPH;
static nsHtml5ElementName* HKERN;
static nsHtml5ElementName* IMAGE;
static nsHtml5ElementName* IDENT;
static nsHtml5ElementName* INPUT;
static nsHtml5ElementName* LABEL;
static nsHtml5ElementName* LIMIT;
static nsHtml5ElementName* MFRAC;
static nsHtml5ElementName* MPATH;
static nsHtml5ElementName* METER;
static nsHtml5ElementName* MOVER;
static nsHtml5ElementName* MINUS;
static nsHtml5ElementName* MROOT;
static nsHtml5ElementName* MSQRT;
static nsHtml5ElementName* MTEXT;
static nsHtml5ElementName* NOTIN;
static nsHtml5ElementName* PIECE;
static nsHtml5ElementName* PARAM;
static nsHtml5ElementName* POWER;
static nsHtml5ElementName* REALS;
static nsHtml5ElementName* STYLE;
static nsHtml5ElementName* SMALL;
static nsHtml5ElementName* THEAD;
static nsHtml5ElementName* TABLE;
static nsHtml5ElementName* TITLE;
static nsHtml5ElementName* TSPAN;
static nsHtml5ElementName* TIMES;
static nsHtml5ElementName* TFOOT;
static nsHtml5ElementName* TBODY;
static nsHtml5ElementName* UNION;
static nsHtml5ElementName* VKERN;
static nsHtml5ElementName* VIDEO;
static nsHtml5ElementName* ARCSEC;
static nsHtml5ElementName* ARCCSC;
static nsHtml5ElementName* ARCTAN;
static nsHtml5ElementName* ARCSIN;
static nsHtml5ElementName* ARCCOS;
static nsHtml5ElementName* APPLET;
static nsHtml5ElementName* ARCCOT;
static nsHtml5ElementName* APPROX;
static nsHtml5ElementName* BUTTON;
static nsHtml5ElementName* CIRCLE;
static nsHtml5ElementName* CENTER;
static nsHtml5ElementName* CURSOR;
static nsHtml5ElementName* CANVAS;
static nsHtml5ElementName* DIVIDE;
static nsHtml5ElementName* DEGREE;
static nsHtml5ElementName* DIALOG;
static nsHtml5ElementName* DOMAIN;
static nsHtml5ElementName* EXISTS;
static nsHtml5ElementName* FETILE;
static nsHtml5ElementName* FIGURE;
static nsHtml5ElementName* FORALL;
static nsHtml5ElementName* FILTER;
static nsHtml5ElementName* FOOTER;
static nsHtml5ElementName* HEADER;
static nsHtml5ElementName* IFRAME;
static nsHtml5ElementName* KEYGEN;
static nsHtml5ElementName* LAMBDA;
static nsHtml5ElementName* LEGEND;
static nsHtml5ElementName* MSPACE;
static nsHtml5ElementName* MTABLE;
static nsHtml5ElementName* MSTYLE;
static nsHtml5ElementName* MGLYPH;
static nsHtml5ElementName* MEDIAN;
static nsHtml5ElementName* MUNDER;
static nsHtml5ElementName* MARKER;
static nsHtml5ElementName* MERROR;
static nsHtml5ElementName* MOMENT;
static nsHtml5ElementName* MATRIX;
static nsHtml5ElementName* OPTION;
static nsHtml5ElementName* OBJECT;
static nsHtml5ElementName* OUTPUT;
static nsHtml5ElementName* PRIMES;
static nsHtml5ElementName* SOURCE;
static nsHtml5ElementName* STRIKE;
static nsHtml5ElementName* STRONG;
static nsHtml5ElementName* SWITCH;
static nsHtml5ElementName* SYMBOL;
static nsHtml5ElementName* SPACER;
static nsHtml5ElementName* SELECT;
static nsHtml5ElementName* SUBSET;
static nsHtml5ElementName* SCRIPT;
static nsHtml5ElementName* TBREAK;
static nsHtml5ElementName* VECTOR;
static nsHtml5ElementName* ARTICLE;
static nsHtml5ElementName* ANIMATE;
static nsHtml5ElementName* ARCSECH;
static nsHtml5ElementName* ARCCSCH;
static nsHtml5ElementName* ARCTANH;
static nsHtml5ElementName* ARCSINH;
static nsHtml5ElementName* ARCCOSH;
static nsHtml5ElementName* ARCCOTH;
static nsHtml5ElementName* ACRONYM;
static nsHtml5ElementName* ADDRESS;
static nsHtml5ElementName* BGSOUND;
static nsHtml5ElementName* COMMAND;
static nsHtml5ElementName* COMPOSE;
static nsHtml5ElementName* CEILING;
static nsHtml5ElementName* CSYMBOL;
static nsHtml5ElementName* CAPTION;
static nsHtml5ElementName* DISCARD;
static nsHtml5ElementName* DECLARE;
static nsHtml5ElementName* DETAILS;
static nsHtml5ElementName* ELLIPSE;
static nsHtml5ElementName* FEFUNCA;
static nsHtml5ElementName* FEFUNCB;
static nsHtml5ElementName* FEBLEND;
static nsHtml5ElementName* FEFLOOD;
static nsHtml5ElementName* FEIMAGE;
static nsHtml5ElementName* FEMERGE;
static nsHtml5ElementName* FEFUNCG;
static nsHtml5ElementName* FEFUNCR;
static nsHtml5ElementName* HANDLER;
static nsHtml5ElementName* INVERSE;
static nsHtml5ElementName* IMPLIES;
static nsHtml5ElementName* ISINDEX;
static nsHtml5ElementName* LOGBASE;
static nsHtml5ElementName* LISTING;
static nsHtml5ElementName* MFENCED;
static nsHtml5ElementName* MPADDED;
static nsHtml5ElementName* MARQUEE;
static nsHtml5ElementName* MACTION;
static nsHtml5ElementName* MSUBSUP;
static nsHtml5ElementName* NOEMBED;
static nsHtml5ElementName* POLYGON;
static nsHtml5ElementName* PATTERN;
static nsHtml5ElementName* PRODUCT;
static nsHtml5ElementName* SETDIFF;
static nsHtml5ElementName* SECTION;
static nsHtml5ElementName* TENDSTO;
static nsHtml5ElementName* UPLIMIT;
static nsHtml5ElementName* ALTGLYPH;
static nsHtml5ElementName* BASEFONT;
static nsHtml5ElementName* CLIPPATH;
static nsHtml5ElementName* CODOMAIN;
static nsHtml5ElementName* COLGROUP;
static nsHtml5ElementName* DATAGRID;
static nsHtml5ElementName* EMPTYSET;
static nsHtml5ElementName* FACTOROF;
static nsHtml5ElementName* FIELDSET;
static nsHtml5ElementName* FRAMESET;
static nsHtml5ElementName* FEOFFSET;
static nsHtml5ElementName* GLYPHREF;
static nsHtml5ElementName* INTERVAL;
static nsHtml5ElementName* INTEGERS;
static nsHtml5ElementName* INFINITY;
static nsHtml5ElementName* LISTENER;
static nsHtml5ElementName* LOWLIMIT;
static nsHtml5ElementName* METADATA;
static nsHtml5ElementName* MENCLOSE;
static nsHtml5ElementName* MPHANTOM;
static nsHtml5ElementName* NOFRAMES;
static nsHtml5ElementName* NOSCRIPT;
static nsHtml5ElementName* OPTGROUP;
static nsHtml5ElementName* POLYLINE;
static nsHtml5ElementName* PREFETCH;
static nsHtml5ElementName* PROGRESS;
static nsHtml5ElementName* PRSUBSET;
static nsHtml5ElementName* QUOTIENT;
static nsHtml5ElementName* SELECTOR;
static nsHtml5ElementName* TEXTAREA;
static nsHtml5ElementName* TEXTPATH;
static nsHtml5ElementName* VARIANCE;
static nsHtml5ElementName* ANIMATION;
static nsHtml5ElementName* CONJUGATE;
static nsHtml5ElementName* CONDITION;
static nsHtml5ElementName* COMPLEXES;
static nsHtml5ElementName* FONT_FACE;
static nsHtml5ElementName* FACTORIAL;
static nsHtml5ElementName* INTERSECT;
static nsHtml5ElementName* IMAGINARY;
static nsHtml5ElementName* LAPLACIAN;
static nsHtml5ElementName* MATRIXROW;
static nsHtml5ElementName* NOTSUBSET;
static nsHtml5ElementName* OTHERWISE;
static nsHtml5ElementName* PIECEWISE;
static nsHtml5ElementName* PLAINTEXT;
static nsHtml5ElementName* RATIONALS;
static nsHtml5ElementName* SEMANTICS;
static nsHtml5ElementName* TRANSPOSE;
static nsHtml5ElementName* ANNOTATION;
static nsHtml5ElementName* BLOCKQUOTE;
static nsHtml5ElementName* DIVERGENCE;
static nsHtml5ElementName* EULERGAMMA;
static nsHtml5ElementName* EQUIVALENT;
static nsHtml5ElementName* IMAGINARYI;
static nsHtml5ElementName* MALIGNMARK;
static nsHtml5ElementName* MUNDEROVER;
static nsHtml5ElementName* MLABELEDTR;
static nsHtml5ElementName* NOTANUMBER;
static nsHtml5ElementName* SOLIDCOLOR;
static nsHtml5ElementName* ALTGLYPHDEF;
static nsHtml5ElementName* DETERMINANT;
static nsHtml5ElementName* EVENTSOURCE;
static nsHtml5ElementName* FEMERGENODE;
static nsHtml5ElementName* FECOMPOSITE;
static nsHtml5ElementName* FESPOTLIGHT;
static nsHtml5ElementName* MALIGNGROUP;
static nsHtml5ElementName* MPRESCRIPTS;
static nsHtml5ElementName* MOMENTABOUT;
static nsHtml5ElementName* NOTPRSUBSET;
static nsHtml5ElementName* PARTIALDIFF;
static nsHtml5ElementName* ALTGLYPHITEM;
static nsHtml5ElementName* ANIMATECOLOR;
static nsHtml5ElementName* DATATEMPLATE;
static nsHtml5ElementName* EXPONENTIALE;
static nsHtml5ElementName* FETURBULENCE;
static nsHtml5ElementName* FEPOINTLIGHT;
static nsHtml5ElementName* FEMORPHOLOGY;
static nsHtml5ElementName* OUTERPRODUCT;
static nsHtml5ElementName* ANIMATEMOTION;
static nsHtml5ElementName* COLOR_PROFILE;
static nsHtml5ElementName* FONT_FACE_SRC;
static nsHtml5ElementName* FONT_FACE_URI;
static nsHtml5ElementName* FOREIGNOBJECT;
static nsHtml5ElementName* FECOLORMATRIX;
static nsHtml5ElementName* MISSING_GLYPH;
static nsHtml5ElementName* MMULTISCRIPTS;
static nsHtml5ElementName* SCALARPRODUCT;
static nsHtml5ElementName* VECTORPRODUCT;
static nsHtml5ElementName* ANNOTATION_XML;
static nsHtml5ElementName* DEFINITION_SRC;
static nsHtml5ElementName* FONT_FACE_NAME;
static nsHtml5ElementName* FEGAUSSIANBLUR;
static nsHtml5ElementName* FEDISTANTLIGHT;
static nsHtml5ElementName* LINEARGRADIENT;
static nsHtml5ElementName* NATURALNUMBERS;
static nsHtml5ElementName* RADIALGRADIENT;
static nsHtml5ElementName* ANIMATETRANSFORM;
static nsHtml5ElementName* CARTESIANPRODUCT;
static nsHtml5ElementName* FONT_FACE_FORMAT;
static nsHtml5ElementName* FECONVOLVEMATRIX;
static nsHtml5ElementName* FEDIFFUSELIGHTING;
static nsHtml5ElementName* FEDISPLACEMENTMAP;
static nsHtml5ElementName* FESPECULARLIGHTING;
static nsHtml5ElementName* DOMAINOFAPPLICATION;
static nsHtml5ElementName* FECOMPONENTTRANSFER;
private:
static nsHtml5ElementName** ELEMENT_NAMES;
#ifdef nsHtml5ElementName_cpp__
static PRInt32 ELEMENT_HASHES_DATA[];
#endif
static jArray<PRInt32,PRInt32> ELEMENT_HASHES;
public:
static void initializeStatics();
static void releaseStatics();
};
#ifdef nsHtml5ElementName_cpp__
nsHtml5ElementName* nsHtml5ElementName::NULL_ELEMENT_NAME = nsnull;
nsHtml5ElementName* nsHtml5ElementName::A = nsnull;
nsHtml5ElementName* nsHtml5ElementName::B = nsnull;
nsHtml5ElementName* nsHtml5ElementName::G = nsnull;
nsHtml5ElementName* nsHtml5ElementName::I = nsnull;
nsHtml5ElementName* nsHtml5ElementName::P = nsnull;
nsHtml5ElementName* nsHtml5ElementName::Q = nsnull;
nsHtml5ElementName* nsHtml5ElementName::S = nsnull;
nsHtml5ElementName* nsHtml5ElementName::U = nsnull;
nsHtml5ElementName* nsHtml5ElementName::BR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CI = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DD = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DL = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::EM = nsnull;
nsHtml5ElementName* nsHtml5ElementName::EQ = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::H1 = nsnull;
nsHtml5ElementName* nsHtml5ElementName::H2 = nsnull;
nsHtml5ElementName* nsHtml5ElementName::H3 = nsnull;
nsHtml5ElementName* nsHtml5ElementName::H4 = nsnull;
nsHtml5ElementName* nsHtml5ElementName::H5 = nsnull;
nsHtml5ElementName* nsHtml5ElementName::H6 = nsnull;
nsHtml5ElementName* nsHtml5ElementName::GT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::HR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::IN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LI = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MI = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MO = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::OL = nsnull;
nsHtml5ElementName* nsHtml5ElementName::OR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PI = nsnull;
nsHtml5ElementName* nsHtml5ElementName::RP = nsnull;
nsHtml5ElementName* nsHtml5ElementName::RT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TD = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::UL = nsnull;
nsHtml5ElementName* nsHtml5ElementName::AND = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ARG = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ABS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::BIG = nsnull;
nsHtml5ElementName* nsHtml5ElementName::BDO = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CSC = nsnull;
nsHtml5ElementName* nsHtml5ElementName::COL = nsnull;
nsHtml5ElementName* nsHtml5ElementName::COS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::COT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DEL = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DFN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DIR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DIV = nsnull;
nsHtml5ElementName* nsHtml5ElementName::EXP = nsnull;
nsHtml5ElementName* nsHtml5ElementName::GCD = nsnull;
nsHtml5ElementName* nsHtml5ElementName::GEQ = nsnull;
nsHtml5ElementName* nsHtml5ElementName::IMG = nsnull;
nsHtml5ElementName* nsHtml5ElementName::INS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::INT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::KBD = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LOG = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LCM = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LEQ = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MTD = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MIN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MAP = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MTR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MAX = nsnull;
nsHtml5ElementName* nsHtml5ElementName::NEQ = nsnull;
nsHtml5ElementName* nsHtml5ElementName::NOT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::NAV = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PRE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::REM = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SUB = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SEC = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SVG = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SUM = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SIN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SEP = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SUP = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SET = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TAN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::USE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::VAR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::WBR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::XMP = nsnull;
nsHtml5ElementName* nsHtml5ElementName::XOR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::AREA = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ABBR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::BASE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::BVAR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::BODY = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CARD = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CODE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CITE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CSCH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::COSH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::COTH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CURL = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DESC = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DIFF = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DEFS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FORM = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FONT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::GRAD = nsnull;
nsHtml5ElementName* nsHtml5ElementName::HEAD = nsnull;
nsHtml5ElementName* nsHtml5ElementName::HTML = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LINE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LINK = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LIST = nsnull;
nsHtml5ElementName* nsHtml5ElementName::META = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MSUB = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MODE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MATH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MARK = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MASK = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MEAN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MSUP = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MENU = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MROW = nsnull;
nsHtml5ElementName* nsHtml5ElementName::NONE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::NOBR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::NEST = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PATH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PLUS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::RULE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::REAL = nsnull;
nsHtml5ElementName* nsHtml5ElementName::RELN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::RECT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ROOT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::RUBY = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SECH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SINH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SPAN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SAMP = nsnull;
nsHtml5ElementName* nsHtml5ElementName::STOP = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SDEV = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TIME = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TRUE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TREF = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TANH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TEXT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::VIEW = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ASIDE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::AUDIO = nsnull;
nsHtml5ElementName* nsHtml5ElementName::APPLY = nsnull;
nsHtml5ElementName* nsHtml5ElementName::EMBED = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FRAME = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FALSE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FLOOR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::GLYPH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::HKERN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::IMAGE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::IDENT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::INPUT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LABEL = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LIMIT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MFRAC = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MPATH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::METER = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MOVER = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MINUS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MROOT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MSQRT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MTEXT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::NOTIN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PIECE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PARAM = nsnull;
nsHtml5ElementName* nsHtml5ElementName::POWER = nsnull;
nsHtml5ElementName* nsHtml5ElementName::REALS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::STYLE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SMALL = nsnull;
nsHtml5ElementName* nsHtml5ElementName::THEAD = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TABLE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TITLE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TSPAN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TIMES = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TFOOT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TBODY = nsnull;
nsHtml5ElementName* nsHtml5ElementName::UNION = nsnull;
nsHtml5ElementName* nsHtml5ElementName::VKERN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::VIDEO = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ARCSEC = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ARCCSC = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ARCTAN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ARCSIN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ARCCOS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::APPLET = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ARCCOT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::APPROX = nsnull;
nsHtml5ElementName* nsHtml5ElementName::BUTTON = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CIRCLE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CENTER = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CURSOR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CANVAS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DIVIDE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DEGREE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DIALOG = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DOMAIN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::EXISTS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FETILE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FIGURE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FORALL = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FILTER = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FOOTER = nsnull;
nsHtml5ElementName* nsHtml5ElementName::HEADER = nsnull;
nsHtml5ElementName* nsHtml5ElementName::IFRAME = nsnull;
nsHtml5ElementName* nsHtml5ElementName::KEYGEN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LAMBDA = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LEGEND = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MSPACE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MTABLE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MSTYLE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MGLYPH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MEDIAN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MUNDER = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MARKER = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MERROR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MOMENT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MATRIX = nsnull;
nsHtml5ElementName* nsHtml5ElementName::OPTION = nsnull;
nsHtml5ElementName* nsHtml5ElementName::OBJECT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::OUTPUT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PRIMES = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SOURCE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::STRIKE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::STRONG = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SWITCH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SYMBOL = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SPACER = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SELECT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SUBSET = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SCRIPT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TBREAK = nsnull;
nsHtml5ElementName* nsHtml5ElementName::VECTOR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ARTICLE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ANIMATE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ARCSECH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ARCCSCH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ARCTANH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ARCSINH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ARCCOSH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ARCCOTH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ACRONYM = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ADDRESS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::BGSOUND = nsnull;
nsHtml5ElementName* nsHtml5ElementName::COMMAND = nsnull;
nsHtml5ElementName* nsHtml5ElementName::COMPOSE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CEILING = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CSYMBOL = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CAPTION = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DISCARD = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DECLARE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DETAILS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ELLIPSE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEFUNCA = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEFUNCB = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEBLEND = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEFLOOD = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEIMAGE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEMERGE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEFUNCG = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEFUNCR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::HANDLER = nsnull;
nsHtml5ElementName* nsHtml5ElementName::INVERSE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::IMPLIES = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ISINDEX = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LOGBASE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LISTING = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MFENCED = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MPADDED = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MARQUEE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MACTION = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MSUBSUP = nsnull;
nsHtml5ElementName* nsHtml5ElementName::NOEMBED = nsnull;
nsHtml5ElementName* nsHtml5ElementName::POLYGON = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PATTERN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PRODUCT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SETDIFF = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SECTION = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TENDSTO = nsnull;
nsHtml5ElementName* nsHtml5ElementName::UPLIMIT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ALTGLYPH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::BASEFONT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CLIPPATH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CODOMAIN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::COLGROUP = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DATAGRID = nsnull;
nsHtml5ElementName* nsHtml5ElementName::EMPTYSET = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FACTOROF = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FIELDSET = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FRAMESET = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEOFFSET = nsnull;
nsHtml5ElementName* nsHtml5ElementName::GLYPHREF = nsnull;
nsHtml5ElementName* nsHtml5ElementName::INTERVAL = nsnull;
nsHtml5ElementName* nsHtml5ElementName::INTEGERS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::INFINITY = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LISTENER = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LOWLIMIT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::METADATA = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MENCLOSE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MPHANTOM = nsnull;
nsHtml5ElementName* nsHtml5ElementName::NOFRAMES = nsnull;
nsHtml5ElementName* nsHtml5ElementName::NOSCRIPT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::OPTGROUP = nsnull;
nsHtml5ElementName* nsHtml5ElementName::POLYLINE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PREFETCH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PROGRESS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PRSUBSET = nsnull;
nsHtml5ElementName* nsHtml5ElementName::QUOTIENT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SELECTOR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TEXTAREA = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TEXTPATH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::VARIANCE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ANIMATION = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CONJUGATE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CONDITION = nsnull;
nsHtml5ElementName* nsHtml5ElementName::COMPLEXES = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FONT_FACE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FACTORIAL = nsnull;
nsHtml5ElementName* nsHtml5ElementName::INTERSECT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::IMAGINARY = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LAPLACIAN = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MATRIXROW = nsnull;
nsHtml5ElementName* nsHtml5ElementName::NOTSUBSET = nsnull;
nsHtml5ElementName* nsHtml5ElementName::OTHERWISE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PIECEWISE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PLAINTEXT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::RATIONALS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SEMANTICS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::TRANSPOSE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ANNOTATION = nsnull;
nsHtml5ElementName* nsHtml5ElementName::BLOCKQUOTE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DIVERGENCE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::EULERGAMMA = nsnull;
nsHtml5ElementName* nsHtml5ElementName::EQUIVALENT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::IMAGINARYI = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MALIGNMARK = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MUNDEROVER = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MLABELEDTR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::NOTANUMBER = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SOLIDCOLOR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ALTGLYPHDEF = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DETERMINANT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::EVENTSOURCE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEMERGENODE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FECOMPOSITE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FESPOTLIGHT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MALIGNGROUP = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MPRESCRIPTS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MOMENTABOUT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::NOTPRSUBSET = nsnull;
nsHtml5ElementName* nsHtml5ElementName::PARTIALDIFF = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ALTGLYPHITEM = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ANIMATECOLOR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DATATEMPLATE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::EXPONENTIALE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FETURBULENCE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEPOINTLIGHT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEMORPHOLOGY = nsnull;
nsHtml5ElementName* nsHtml5ElementName::OUTERPRODUCT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ANIMATEMOTION = nsnull;
nsHtml5ElementName* nsHtml5ElementName::COLOR_PROFILE = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FONT_FACE_SRC = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FONT_FACE_URI = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FOREIGNOBJECT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FECOLORMATRIX = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MISSING_GLYPH = nsnull;
nsHtml5ElementName* nsHtml5ElementName::MMULTISCRIPTS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::SCALARPRODUCT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::VECTORPRODUCT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ANNOTATION_XML = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DEFINITION_SRC = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FONT_FACE_NAME = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEGAUSSIANBLUR = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEDISTANTLIGHT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::LINEARGRADIENT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::NATURALNUMBERS = nsnull;
nsHtml5ElementName* nsHtml5ElementName::RADIALGRADIENT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::ANIMATETRANSFORM = nsnull;
nsHtml5ElementName* nsHtml5ElementName::CARTESIANPRODUCT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FONT_FACE_FORMAT = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FECONVOLVEMATRIX = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEDIFFUSELIGHTING = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FEDISPLACEMENTMAP = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FESPECULARLIGHTING = nsnull;
nsHtml5ElementName* nsHtml5ElementName::DOMAINOFAPPLICATION = nsnull;
nsHtml5ElementName* nsHtml5ElementName::FECOMPONENTTRANSFER = nsnull;
nsHtml5ElementName** nsHtml5ElementName::ELEMENT_NAMES = nsnull;
PRInt32 nsHtml5ElementName::ELEMENT_HASHES_DATA[] = { 1057, 1090, 1255, 1321, 1552, 1585, 1651, 1717, 68162, 68899, 69059, 69764, 70020, 70276, 71077, 71205, 72134, 72232, 72264, 72296, 72328, 72360, 72392, 73351, 74312, 75209, 78124, 78284, 78476, 79149, 79309, 79341, 79469, 81295, 81487, 82224, 84498, 84626, 86164, 86292, 86612, 86676, 87445, 3183041, 3186241, 3198017, 3218722, 3226754, 3247715, 3256803, 3263971, 3264995, 3289252, 3291332, 3295524, 3299620, 3326725, 3379303, 3392679, 3448233, 3460553, 3461577, 3510347, 3546604, 3552364, 3556524, 3576461, 3586349, 3588141, 3590797, 3596333, 3622062, 3625454, 3627054, 3675728, 3749042, 3771059, 3771571, 3776211, 3782323, 3782963, 3784883, 3785395, 3788979, 3815476, 3839605, 3885110, 3917911, 3948984, 3951096, 135304769, 135858241, 136498210, 136906434, 137138658, 137512995, 137531875, 137548067, 137629283, 137645539, 137646563, 137775779, 138529956, 138615076, 139040932, 140954086, 141179366, 141690439, 142738600, 143013512, 146979116, 147175724, 147475756, 147902637, 147936877, 148017645, 148131885, 148228141, 148229165, 148309165, 148395629, 148551853, 148618829, 149076462, 149490158, 149572782, 151277616, 151639440, 153268914, 153486514, 153563314, 153750706, 153763314, 153914034, 154406067, 154417459, 154600979, 154678323, 154680979, 154866835, 155366708, 155375188, 155391572, 155465780, 155869364, 158045494, 168988979, 169321621, 169652752, 173151309, 174240818, 174247297, 174669292, 175391532, 176638123, 177380397, 177879204, 177886734, 180753473, 181020073, 181503558, 181686320, 181999237, 181999311, 182048201, 182074866, 182078003, 182083764, 182920847, 184716457, 184976961, 185145071, 187281445, 187872052, 188100653, 188875944, 188919873, 188920457, 189203987, 189371817, 189414886, 189567458, 190266670, 191318187, 191337609, 202479203, 202493027, 202835587, 202843747, 203013219, 203036048, 203045987, 203177552, 203898516, 204648562, 205067918, 205078130, 205096654, 205689142, 205690439, 205766017, 205988909, 207213161, 207794484, 207800999, 208023602, 208213644, 208213647, 210310273, 210940978, 213325049, 213946445, 214055079, 215125040, 215134273, 215135028, 215237420, 215418148, 215553166, 215553394, 215563858, 215627949, 215754324, 217529652, 217713834, 217732628, 218731945, 221417045, 221424946, 221493746, 221515401, 221658189, 221844577, 221908140, 221910626, 221921586, 222659762, 225001091, 236105833, 236113965, 236194995, 236195427, 236206132, 236206387, 236211683, 236212707, 236381647, 236571826, 237124271, 238172205, 238210544, 238270764, 238435405, 238501172, 239224867, 239257644, 239710497, 240307721, 241208789, 241241557, 241318060, 241319404, 241343533, 241344069, 241405397, 241765845, 243864964, 244502085, 244946220, 245109902, 247647266, 247707956, 248648814, 248648836, 248682161, 248986932, 249058914, 249697357, 252132601, 252135604, 252317348, 255007012, 255278388, 256365156, 257566121, 269763372, 271202790, 271863856, 272049197, 272127474, 272770631, 274339449, 274939471, 275388004, 275388005, 275388006, 275977800, 278267602, 278513831, 278712622, 281613765, 281683369, 282120228, 282250732, 282508942, 283743649, 283787570, 284710386, 285391148, 285478533, 285854898, 285873762, 286931113, 288964227, 289445441, 289689648, 291671489, 303512884, 305319975, 305610036, 305764101, 308448294, 308675890, 312085683, 312264750, 315032867, 316391000, 317331042, 317902135, 318950711, 319447220, 321499182, 322538804, 323145200, 337067316, 337826293, 339905989, 340833697, 341457068, 345302593, 349554733, 349771471, 349786245, 350819405, 356072847, 370349192, 373962798, 374509141, 375558638, 375574835, 376053993, 383276530, 383373833, 383407586, 384439906, 386079012, 404133513, 404307343, 407031852, 408072233, 409112005, 409608425, 409771500, 419040932, 437730612, 439529766, 442616365, 442813037, 443157674, 443295316, 450118444, 450482697, 456789668, 459935396, 471217869, 474073645, 476230702, 476665218, 476717289, 483014825, 485083298, 489306281, 538364390, 540675748, 543819186, 543958612, 576960820, 577242548, 610515252, 642202932, 644420819 };
jArray<PRInt32,PRInt32> nsHtml5ElementName::ELEMENT_HASHES = J_ARRAY_STATIC(PRInt32, PRInt32, ELEMENT_HASHES_DATA);
#endif
#endif

View File

@ -0,0 +1,217 @@
/*
* Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2008 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* 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
* DEALINGS IN THE SOFTWARE.
*/
/*
* THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
* Please edit HtmlAttributes.java instead and regenerate.
*/
#define nsHtml5HtmlAttributes_cpp__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsString.h"
#include "nsINameSpaceManager.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "jArray.h"
#include "nsHtml5DocumentMode.h"
#include "nsHtml5ArrayCopy.h"
#include "nsHtml5NamedCharacters.h"
#include "nsHtml5Parser.h"
#include "nsHtml5StringLiterals.h"
#include "nsHtml5Atoms.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
#include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h"
#include "nsHtml5StackNode.h"
#include "nsHtml5UTF16Buffer.h"
#include "nsHtml5Portability.h"
#include "nsHtml5HtmlAttributes.h"
nsHtml5HtmlAttributes::nsHtml5HtmlAttributes(PRInt32 mode)
: mode(mode),
length(0),
names(jArray<nsHtml5AttributeName*,PRInt32>(5)),
values(jArray<nsString*,PRInt32>(5))
{
}
void
nsHtml5HtmlAttributes::destructor()
{
clear(0);
names.release();
values.release();
}
PRInt32
nsHtml5HtmlAttributes::getIndex(nsHtml5AttributeName* name)
{
for (PRInt32 i = 0; i < length; i++) {
if (names[i] == name) {
return i;
}
}
return -1;
}
PRInt32
nsHtml5HtmlAttributes::getLength()
{
return length;
}
nsIAtom*
nsHtml5HtmlAttributes::getLocalName(PRInt32 index)
{
if (index < length && index >= 0) {
return names[index]->getLocal(mode);
} else {
return nsnull;
}
}
nsHtml5AttributeName*
nsHtml5HtmlAttributes::getAttributeName(PRInt32 index)
{
if (index < length && index >= 0) {
return names[index];
} else {
return nsnull;
}
}
PRInt32
nsHtml5HtmlAttributes::getURI(PRInt32 index)
{
if (index < length && index >= 0) {
return names[index]->getUri(mode);
} else {
return nsnull;
}
}
nsIAtom*
nsHtml5HtmlAttributes::getPrefix(PRInt32 index)
{
if (index < length && index >= 0) {
return names[index]->getPrefix(mode);
} else {
return nsnull;
}
}
nsString*
nsHtml5HtmlAttributes::getValue(PRInt32 index)
{
if (index < length && index >= 0) {
return values[index];
} else {
return nsnull;
}
}
nsString*
nsHtml5HtmlAttributes::getValue(nsHtml5AttributeName* name)
{
PRInt32 index = getIndex(name);
if (index == -1) {
return nsnull;
} else {
return getValue(index);
}
}
void
nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name, nsString* value)
{
if (names.length == length) {
PRInt32 newLen = length << 1;
jArray<nsHtml5AttributeName*,PRInt32> newNames = jArray<nsHtml5AttributeName*,PRInt32>(newLen);
nsHtml5ArrayCopy::arraycopy(names, newNames, names.length);
names.release();
names = newNames;
jArray<nsString*,PRInt32> newValues = jArray<nsString*,PRInt32>(newLen);
nsHtml5ArrayCopy::arraycopy(values, newValues, values.length);
values.release();
values = newValues;
}
names[length] = name;
values[length] = value;
length++;
}
void
nsHtml5HtmlAttributes::clear(PRInt32 m)
{
for (PRInt32 i = 0; i < length; i++) {
names[i]->release();
names[i] = nsnull;
nsHtml5Portability::releaseString(values[i]);
values[i] = nsnull;
}
length = 0;
mode = m;
}
PRBool
nsHtml5HtmlAttributes::contains(nsHtml5AttributeName* name)
{
for (PRInt32 i = 0; i < length; i++) {
if (name->equalsAnother(names[i])) {
return PR_TRUE;
}
}
return PR_FALSE;
}
void
nsHtml5HtmlAttributes::adjustForMath()
{
mode = NS_HTML5ATTRIBUTE_NAME_MATHML;
}
void
nsHtml5HtmlAttributes::adjustForSvg()
{
mode = NS_HTML5ATTRIBUTE_NAME_SVG;
}
void
nsHtml5HtmlAttributes::initializeStatics()
{
EMPTY_ATTRIBUTES = new nsHtml5HtmlAttributes(NS_HTML5ATTRIBUTE_NAME_HTML);
}
void
nsHtml5HtmlAttributes::releaseStatics()
{
delete EMPTY_ATTRIBUTES;
}

View File

@ -0,0 +1,92 @@
/*
* Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2008 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* 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
* DEALINGS IN THE SOFTWARE.
*/
/*
* THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
* Please edit HtmlAttributes.java instead and regenerate.
*/
#ifndef nsHtml5HtmlAttributes_h__
#define nsHtml5HtmlAttributes_h__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsString.h"
#include "nsINameSpaceManager.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "jArray.h"
#include "nsHtml5DocumentMode.h"
#include "nsHtml5ArrayCopy.h"
#include "nsHtml5NamedCharacters.h"
#include "nsHtml5Parser.h"
#include "nsHtml5StringLiterals.h"
#include "nsHtml5Atoms.h"
class nsHtml5Parser;
class nsHtml5Tokenizer;
class nsHtml5TreeBuilder;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5StackNode;
class nsHtml5UTF16Buffer;
class nsHtml5Portability;
class nsHtml5HtmlAttributes
{
public:
static nsHtml5HtmlAttributes* EMPTY_ATTRIBUTES;
private:
PRInt32 mode;
PRInt32 length;
jArray<nsHtml5AttributeName*,PRInt32> names;
jArray<nsString*,PRInt32> values;
public:
nsHtml5HtmlAttributes(PRInt32 mode);
void destructor();
PRInt32 getIndex(nsHtml5AttributeName* name);
PRInt32 getLength();
nsIAtom* getLocalName(PRInt32 index);
nsHtml5AttributeName* getAttributeName(PRInt32 index);
PRInt32 getURI(PRInt32 index);
nsIAtom* getPrefix(PRInt32 index);
nsString* getValue(PRInt32 index);
nsString* getValue(nsHtml5AttributeName* name);
void addAttribute(nsHtml5AttributeName* name, nsString* value);
void clear(PRInt32 m);
PRBool contains(nsHtml5AttributeName* name);
void adjustForMath();
void adjustForSvg();
static void initializeStatics();
static void releaseStatics();
};
#ifdef nsHtml5HtmlAttributes_cpp__
nsHtml5HtmlAttributes* nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES = nsnull;
#endif
#endif

View File

@ -0,0 +1,101 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is HTML Parser C++ Translator code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Henri Sivonen <hsivonen@iki.fi>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5NamedCharacters.h"
#include "nsHtml5Portability.h"
#include "nsHtml5StackNode.h"
#include "nsHtml5StringLiterals.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
#include "nsHtml5UTF16Buffer.h"
#include "nsHtml5Module.h"
// static
void
nsHtml5Module::InitializeStatics()
{
nsHtml5Atoms::AddRefAtoms();
nsHtml5AttributeName::initializeStatics();
nsHtml5ElementName::initializeStatics();
nsHtml5HtmlAttributes::initializeStatics();
nsHtml5NamedCharacters::initializeStatics();
nsHtml5Portability::initializeStatics();
nsHtml5StackNode::initializeStatics();
nsHtml5StringLiterals::initializeStatics();
nsHtml5Tokenizer::initializeStatics();
nsHtml5TreeBuilder::initializeStatics();
nsHtml5UTF16Buffer::initializeStatics();
}
// static
void
nsHtml5Module::ReleaseStatics()
{
nsHtml5AttributeName::releaseStatics();
nsHtml5ElementName::releaseStatics();
nsHtml5HtmlAttributes::releaseStatics();
nsHtml5NamedCharacters::releaseStatics();
nsHtml5Portability::releaseStatics();
nsHtml5StackNode::releaseStatics();
nsHtml5StringLiterals::releaseStatics();
nsHtml5Tokenizer::releaseStatics();
nsHtml5TreeBuilder::releaseStatics();
nsHtml5UTF16Buffer::releaseStatics();
}
// static
already_AddRefed<nsIParser>
nsHtml5Module::NewHtml5Parser()
{
nsIParser* rv = static_cast<nsIParser*> (new nsHtml5Parser());
NS_ADDREF(rv);
return rv;
}
// static
nsresult
nsHtml5Module::Initialize(nsIParser* aParser, nsIDocument* aDoc, nsIURI* aURI, nsISupports* aContainer, nsIChannel* aChannel)
{
nsHtml5Parser* parser = static_cast<nsHtml5Parser*> (aParser);
return parser->Initialize(aDoc, aURI, aContainer, aChannel);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,975 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=2 et tw=79: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
* Henri Sivonen <hsivonen@iki.fi>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsCompatibility.h"
#include "nsScriptLoader.h"
#include "nsNetUtil.h"
#include "nsIStyleSheetLinkingElement.h"
#include "nsICharsetConverterManager.h"
#include "nsHtml5DocumentMode.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5UTF16Buffer.h"
#include "nsHtml5TreeBuilder.h"
#include "nsHtml5Parser.h"
static NS_DEFINE_CID(kHtml5ParserCID, NS_HTML5_PARSER_CID);
//-------------- Begin ParseContinue Event Definition ------------------------
/*
The parser can be explicitly interrupted by passing a return value of
NS_ERROR_HTMLPARSER_INTERRUPTED from BuildModel on the DTD. This will cause
the parser to stop processing and allow the application to return to the event
loop. The data which was left at the time of interruption will be processed
the next time OnDataAvailable is called. If the parser has received its final
chunk of data then OnDataAvailable will no longer be called by the networking
module, so the parser will schedule a nsHtml5ParserContinueEvent which will call
the parser to process the remaining data after returning to the event loop.
If the parser is interrupted while processing the remaining data it will
schedule another ParseContinueEvent. The processing of data followed by
scheduling of the continue events will proceed until either:
1) All of the remaining data can be processed without interrupting
2) The parser has been cancelled.
This capability is currently used in CNavDTD and nsHTMLContentSink. The
nsHTMLContentSink is notified by CNavDTD when a chunk of tokens is going to be
processed and when each token is processed. The nsHTML content sink records
the time when the chunk has started processing and will return
NS_ERROR_HTMLPARSER_INTERRUPTED if the token processing time has exceeded a
threshold called max tokenizing processing time. This allows the content sink
to limit how much data is processed in a single chunk which in turn gates how
much time is spent away from the event loop. Processing smaller chunks of data
also reduces the time spent in subsequent reflows.
This capability is most apparent when loading large documents. If the maximum
token processing time is set small enough the application will remain
responsive during document load.
A side-effect of this capability is that document load is not complete when
the last chunk of data is passed to OnDataAvailable since the parser may have
been interrupted when the last chunk of data arrived. The document is complete
when all of the document has been tokenized and there aren't any pending
nsHtml5ParserContinueEvents. This can cause problems if the application assumes
that it can monitor the load requests to determine when the document load has
been completed. This is what happens in Mozilla. The document is considered
completely loaded when all of the load requests have been satisfied. To delay
the document load until all of the parsing has been completed the
nsHTMLContentSink adds a dummy parser load request which is not removed until
the nsHTMLContentSink's DidBuildModel is called. The CNavDTD will not call
DidBuildModel until the final chunk of data has been passed to the parser
through the OnDataAvailable and there aren't any pending
nsHtml5ParserContineEvents.
Currently the parser is ignores requests to be interrupted during the
processing of script. This is because a document.write followed by JavaScript
calls to manipulate the DOM may fail if the parser was interrupted during the
document.write.
For more details @see bugzilla bug 76722
*/
class nsHtml5ParserContinueEvent : public nsRunnable
{
public:
nsRefPtr<nsHtml5Parser> mParser;
nsHtml5ParserContinueEvent(nsHtml5Parser* aParser)
: mParser(aParser)
{}
NS_IMETHODIMP Run()
{
mParser->HandleParserContinueEvent(this);
return NS_OK;
}
};
//-------------- End ParseContinue Event Definition ------------------------
NS_IMPL_ISUPPORTS_INHERITED3(nsHtml5Parser, nsContentSink, nsIParser, nsIStreamListener, nsIContentSink)
/**
* default constructor
*/
nsHtml5Parser::nsHtml5Parser()
: mRequest(nsnull),
mObserver(nsnull),
mUnicodeDecoder(nsnull),
mFirstBuffer(new nsHtml5UTF16Buffer(NS_HTML5_PARSER_READ_BUFFER_SIZE)), // XXX allocate elsewhere for fragment parser?
mLastBuffer(mFirstBuffer),
mTreeBuilder(new nsHtml5TreeBuilder(this)),
mTokenizer(new nsHtml5Tokenizer(mTreeBuilder, this))
{
// There's a zeroing operator new for everything else
}
nsHtml5Parser::~nsHtml5Parser()
{
while (mFirstBuffer->next) {
nsHtml5UTF16Buffer* oldBuf = mFirstBuffer;
mFirstBuffer = mFirstBuffer->next;
delete oldBuf;
}
delete mFirstBuffer;
delete mTokenizer;
delete mTreeBuilder;
}
NS_IMETHODIMP_(void)
nsHtml5Parser::SetContentSink(nsIContentSink* aSink)
{
NS_ASSERTION((aSink == static_cast<nsIContentSink*> (this)), "Attempt to set a foreign sink.");
}
NS_IMETHODIMP_(nsIContentSink*)
nsHtml5Parser::GetContentSink(void)
{
return static_cast<nsIContentSink*> (this);
}
NS_IMETHODIMP_(void)
nsHtml5Parser::GetCommand(nsCString& aCommand)
{
aCommand.Assign("loadAsData");
}
NS_IMETHODIMP_(void)
nsHtml5Parser::SetCommand(const char* aCommand)
{
NS_ASSERTION((!strcmp(aCommand, "view")), "Parser command was not view");
}
NS_IMETHODIMP_(void)
nsHtml5Parser::SetCommand(eParserCommands aParserCommand)
{
NS_ASSERTION((aParserCommand == eViewNormal), "Parser command was not eViewNormal.");
}
NS_IMETHODIMP_(void)
nsHtml5Parser::SetDocumentCharset(const nsACString& aCharset, PRInt32 aCharsetSource)
{
mCharset = aCharset;
mCharsetSource = aCharsetSource;
}
NS_IMETHODIMP_(void)
nsHtml5Parser::SetParserFilter(nsIParserFilter* aFilter)
{
NS_ASSERTION(PR_TRUE, "Attempt to set a parser filter on HTML5 parser.");
}
NS_IMETHODIMP
nsHtml5Parser::GetChannel(nsIChannel** aChannel)
{
return CallQueryInterface(mRequest, aChannel);
}
NS_IMETHODIMP
nsHtml5Parser::GetDTD(nsIDTD** aDTD)
{
*aDTD = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsHtml5Parser::ContinueParsing()
{
mBlocked = PR_FALSE;
return ContinueInterruptedParsing();
}
NS_IMETHODIMP
nsHtml5Parser::ContinueInterruptedParsing()
{
// If the stream has already finished, there's a good chance
// that we might start closing things down when the parser
// is reenabled. To make sure that we're not deleted across
// the reenabling process, hold a reference to ourselves.
// XXX is this really necessary? -- hsivonen?
nsCOMPtr<nsIParser> kungFuDeathGrip(this);
// XXX Stop speculative script thread but why?
ParseUntilSuspend();
return NS_OK;
}
/**
* This method isn't really useful as a method, but it's in nsIParser.
*/
NS_IMETHODIMP_(void)
nsHtml5Parser::BlockParser()
{
NS_PRECONDITION((!mFragmentMode), "Must not block in fragment mode.");
mBlocked = PR_TRUE;
}
NS_IMETHODIMP_(void)
nsHtml5Parser::UnblockParser()
{
mBlocked = PR_FALSE;
}
NS_IMETHODIMP_(PRBool)
nsHtml5Parser::IsParserEnabled()
{
return !mBlocked;
}
NS_IMETHODIMP_(PRBool)
nsHtml5Parser::IsComplete()
{
// XXX old parser says
// return !(mFlags & NS_PARSER_FLAG_PENDING_CONTINUE_EVENT);
return (mLifeCycle == TERMINATED);
}
NS_IMETHODIMP
nsHtml5Parser::Parse(nsIURI* aURL, // legacy parameter; ignored
nsIRequestObserver* aObserver,
void* aKey,
nsDTDMode aMode) // legacy; ignored
{
mObserver = aObserver;
mRootContextKey = aKey;
NS_ASSERTION((mLifeCycle == NOT_STARTED), "Tried to start parse without initializing the parser properly.");
mTokenizer->start();
mLifeCycle = PARSING;
mParser = this;
return NS_OK;
}
NS_IMETHODIMP
nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
void* aKey,
const nsACString& aContentType, // ignored
PRBool aLastCall,
nsDTDMode aMode) // ignored
{
NS_PRECONDITION((!mFragmentMode), "Document.write called in fragment mode!");
// Return early if the parser has processed EOF
switch (mLifeCycle) {
case TERMINATED:
return NS_OK;
case NOT_STARTED:
mTokenizer->start();
mLifeCycle = PARSING;
mParser = this;
break;
default:
break;
}
if (aLastCall && aSourceBuffer.IsEmpty() && aKey == GetRootContextKey()) {
// document.close()
mLifeCycle = STREAM_ENDING;
MaybePostContinueEvent();
return NS_OK;
}
// XXX stop speculative script thread here
// Maintain a reference to ourselves so we don't go away
// till we're completely done.
// XXX is this still necessary? -- hsivonen
nsCOMPtr<nsIParser> kungFuDeathGrip(this);
if (!aSourceBuffer.IsEmpty()) {
nsHtml5UTF16Buffer* buffer = new nsHtml5UTF16Buffer(aSourceBuffer.Length());
memcpy(buffer->getBuffer(), aSourceBuffer.BeginReading(), aSourceBuffer.Length() * sizeof(PRUnichar));
buffer->setEnd(aSourceBuffer.Length());
if (!mBlocked) {
WillResumeImpl();
WillProcessTokensImpl();
while (buffer->hasMore()) {
buffer->adjust(mLastWasCR);
mLastWasCR = PR_FALSE;
if (buffer->hasMore()) {
mLastWasCR = mTokenizer->tokenizeBuffer(buffer);
if (mScriptElement) {
ExecuteScript();
}
if (mNeedsCharsetSwitch) {
// XXX setup immediate reparse
delete buffer;
WillInterruptImpl();
return NS_OK;
} else if (mBlocked) {
// XXX is the tail insertion and script exec in the wrong order?
WillInterruptImpl();
break;
} else {
// Ignore suspensions
continue;
}
}
}
}
if (buffer->hasMore()) {
nsHtml5UTF16Buffer* prevSearchBuf = nsnull;
nsHtml5UTF16Buffer* searchBuf = mFirstBuffer;
if (aKey) { // after document.open, the first level of document.write has null key
while (searchBuf != mLastBuffer) {
if (searchBuf->key == aKey) {
buffer->next = searchBuf;
if (prevSearchBuf) {
prevSearchBuf->next = buffer;
} else {
mFirstBuffer = buffer;
}
break;
}
prevSearchBuf = searchBuf;
searchBuf = searchBuf->next;
}
}
if (searchBuf == mLastBuffer || !aKey) {
// key was not found or we have a first-level write after document.open
// we'll insert to the head of the queue
nsHtml5UTF16Buffer* keyHolder = new nsHtml5UTF16Buffer(aKey);
keyHolder->next = mFirstBuffer;
buffer->next = keyHolder;
mFirstBuffer = buffer;
}
MaybePostContinueEvent();
} else {
delete buffer;
}
}
return NS_OK;
}
/**
* This magic value is passed to the previous method on document.close()
*/
NS_IMETHODIMP_(void *)
nsHtml5Parser::GetRootContextKey()
{
return mRootContextKey;
}
NS_IMETHODIMP
nsHtml5Parser::Terminate(void)
{
// We should only call DidBuildModel once, so don't do anything if this is
// the second time that Terminate has been called.
if (mTerminated) {
return NS_OK;
}
// XXX - [ until we figure out a way to break parser-sink circularity ]
// Hack - Hold a reference until we are completely done...
nsCOMPtr<nsIParser> kungFuDeathGrip(this);
// CancelParsingEvents must be called to avoid leaking the nsParser object
// @see bug 108049
CancelParsingEvents();
return DidBuildModel(); // nsIContentSink
}
NS_IMETHODIMP
nsHtml5Parser::ParseFragment(const nsAString& aSourceBuffer,
void* aKey,
nsTArray<nsString>& aTagStack,
PRBool aXMLMode,
const nsACString& aContentType,
nsDTDMode aMode)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsHtml5Parser::BuildModel(void)
{
// XXX who calls this? Should this be a no-op?
ParseUntilSuspend();
return NS_OK;
}
/**
* This method is dead code. Here only for interface compat.
*/
NS_IMETHODIMP_(nsDTDMode)
nsHtml5Parser::GetParseMode(void)
{
NS_NOTREACHED("No one is supposed to call GetParseMode!");
return eDTDMode_unknown;
}
NS_IMETHODIMP
nsHtml5Parser::CancelParsingEvents()
{
mContinueEvent = nsnull;
return NS_OK;
}
void
nsHtml5Parser::Reset()
{
NS_NOTREACHED("Can't reset.");
}
/* End nsIParser */
// nsIRequestObserver methods:
nsresult
nsHtml5Parser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
{
NS_PRECONDITION(eNone == mStreamListenerState,
"Parser's nsIStreamListener API was not setup "
"correctly in constructor.");
if (mObserver) {
mObserver->OnStartRequest(aRequest, aContext);
}
// XXX figure out
// mParserContext->mAutoDetectStatus = eUnknownDetect;
mStreamListenerState = eOnStart;
mRequest = aRequest;
nsresult rv = NS_OK;
// if (sParserDataListeners) {
// nsISupports *ctx = GetTarget();
// PRInt32 count = sParserDataListeners->Count();
//
// while (count--) {
// rv |= sParserDataListeners->ObjectAt(count)->
// OnStartRequest(request, ctx);
// }
// }
nsCOMPtr<nsICharsetConverterManager> convManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = convManager->GetUnicodeDecoder(mCharset.get(), getter_AddRefs(mUnicodeDecoder));
NS_ENSURE_SUCCESS(rv, rv);
return rv;
}
/**
* This is called by the networking library once the last block of data
* has been collected from the net.
*/
nsresult
nsHtml5Parser::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext,
nsresult status)
{
NS_ASSERTION((mRequest == aRequest), "Got Stop on wrong stream.");
nsresult rv = NS_OK;
mLifeCycle = STREAM_ENDING;
// if (eOnStart == mStreamListenerState) {
// If you're here, then OnDataAvailable() never got called. Prior
// to necko, we never dealt with this case, but the problem may
// have existed. Everybody can live with an empty input stream, so
// just resume parsing.
// ParseUntilSuspend();
// }
// mStreamStatus = status;
// if (mParserFilter)
// mParserFilter->Finish();
mStreamListenerState = eOnStop;
ParseUntilSuspend();
// If the parser isn't enabled, we don't finish parsing till
// it is reenabled.
// XXX Should we wait to notify our observers as well if the
// parser isn't yet enabled?
if (mObserver) {
mObserver->OnStopRequest(aRequest, aContext, status);
}
// if (sParserDataListeners) {
// nsISupports *ctx = GetTarget();
// PRInt32 count = sParserDataListeners->Count();
//
// while (count--) {
// rv |= sParserDataListeners->ObjectAt(count)->OnStopRequest(aRequest, ctx,
// status);
// }
// }
return rv;
}
// nsIStreamListener method:
/*
* This function is invoked as a result of a call to a stream's
* ReadSegments() method. It is called for each contiguous buffer
* of data in the underlying stream or pipe. Using ReadSegments
* allows us to avoid copying data to read out of the stream.
*/
static NS_METHOD
ParserWriteFunc(nsIInputStream* aInStream,
void* aHtml5Parser,
const char* aFromSegment,
PRUint32 aToOffset,
PRUint32 aCount,
PRUint32* aWriteCount)
{
nsHtml5Parser* parser = static_cast<nsHtml5Parser*> (aHtml5Parser);
return parser->WriteStreamBytes(aFromSegment, aCount, aWriteCount);
}
nsresult
nsHtml5Parser::OnDataAvailable(nsIRequest* aRequest,
nsISupports* aContext,
nsIInputStream* aInStream,
PRUint32 aSourceOffset,
PRUint32 aLength)
{
NS_PRECONDITION((eOnStart == mStreamListenerState ||
eOnDataAvail == mStreamListenerState),
"Error: OnStartRequest() must be called before OnDataAvailable()");
NS_ASSERTION((mRequest == aRequest), "Got data on wrong stream.");
PRUint32 totalRead;
nsresult rv = aInStream->ReadSegments(ParserWriteFunc, static_cast<void*> (this), aLength, &totalRead);
NS_ASSERTION((totalRead == aLength), "ReadSegments read the wrong number of bytes.");
ParseUntilSuspend();
return rv;
}
// EncodingDeclarationHandler
void
nsHtml5Parser::internalEncodingDeclaration(nsString* aEncoding)
{
// XXX implement
}
// DocumentModeHandler
void
nsHtml5Parser::documentMode(nsHtml5DocumentMode m)
{
#if 0
nsCompatibility mode = eCompatibility_NavQuirks;
switch (m) {
case STANDARDS_MODE:
mode = eCompatibility_FullStandards;
break;
case ALMOST_STANDARDS_MODE:
mode = eCompatibility_AlmostStandards;
break;
case QUIRKS_MODE:
mode = eCompatibility_NavQuirks;
break;
}
nsCOMPtr<nsIHTMLDocument> htmlDocument = do_QueryInterface(mDocument);
NS_ASSERTION(htmlDocument, "Document didn't QI into HTML document.");
if (htmlDocument) {
htmlDocument->SetCompatibilityMode(mode);
}
#endif
}
// nsIContentSink
NS_IMETHODIMP
nsHtml5Parser::WillTokenize()
{
NS_NOTREACHED("No one shuld call this");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsHtml5Parser::WillBuildModel()
{
NS_NOTREACHED("No one shuld call this");
return NS_ERROR_NOT_IMPLEMENTED;
}
// XXX should this live in TreeBuilder::end?
// This is called when the tree construction has ended
NS_IMETHODIMP
nsHtml5Parser::DidBuildModel()
{
NS_ASSERTION((mLifeCycle == STREAM_ENDING), "Bad life cycle.");
mTokenizer->eof();
mTokenizer->end();
mLifeCycle = TERMINATED;
// This is comes from nsXMLContentSink
DidBuildModelImpl();
mDocument->ScriptLoader()->RemoveObserver(this);
StartLayout(PR_FALSE);
ScrollToRef();
mDocument->RemoveObserver(this);
mDocument->EndLoad();
DropParserAndPerfHint();
return NS_OK;
}
NS_IMETHODIMP
nsHtml5Parser::WillInterrupt()
{
return WillInterruptImpl();
}
NS_IMETHODIMP
nsHtml5Parser::WillResume()
{
NS_NOTREACHED("No one should call this.");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsHtml5Parser::SetParser(nsIParser* aParser)
{
NS_NOTREACHED("No one should be setting a parser on the HTML5 pseudosink.");
return NS_ERROR_NOT_IMPLEMENTED;
}
void
nsHtml5Parser::FlushPendingNotifications(mozFlushType aType)
{
// Only flush tags if we're not doing the notification ourselves
// (since we aren't reentrant)
if (!mInNotification) {
mTreeBuilder->Flush();
if (aType >= Flush_Layout) {
// Make sure that layout has started so that the reflow flush
// will actually happen.
StartLayout(PR_TRUE);
}
}
}
NS_IMETHODIMP
nsHtml5Parser::SetDocumentCharset(nsACString& aCharset)
{
// XXX who calls this anyway?
// XXX keep in sync with parser???
if (mDocument) {
mDocument->SetDocumentCharacterSet(aCharset);
}
return NS_OK;
}
nsISupports*
nsHtml5Parser::GetTarget()
{
return mDocument;
}
// not from interface
void
nsHtml5Parser::HandleParserContinueEvent(nsHtml5ParserContinueEvent* ev)
{
// Ignore any revoked continue events...
if (mContinueEvent != ev)
return;
mContinueEvent = nsnull;
ContinueInterruptedParsing();
}
NS_IMETHODIMP
nsHtml5Parser::WriteStreamBytes(const char* aFromSegment,
PRUint32 aCount,
PRUint32* aWriteCount)
{
// mLastBuffer always points to a buffer of the size NS_HTML5_PARSER_READ_BUFFER_SIZE.
if (mLastBuffer->getEnd() == NS_HTML5_PARSER_READ_BUFFER_SIZE) {
mLastBuffer = (mLastBuffer->next = new nsHtml5UTF16Buffer(NS_HTML5_PARSER_READ_BUFFER_SIZE));
}
PRInt32 totalByteCount = 0;
for (;;) {
PRInt32 end = mLastBuffer->getEnd();
PRInt32 byteCount = aCount - totalByteCount;
PRInt32 utf16Count = NS_HTML5_PARSER_READ_BUFFER_SIZE - end;
nsresult convResult = mUnicodeDecoder->Convert(aFromSegment, &byteCount, mLastBuffer->getBuffer() + end, &utf16Count);
mLastBuffer->setEnd(end + utf16Count);
totalByteCount += byteCount;
aFromSegment += byteCount;
NS_ASSERTION((mLastBuffer->getEnd() <= NS_HTML5_PARSER_READ_BUFFER_SIZE), "The Unicode decoder wrote too much data.");
if (convResult == NS_PARTIAL_MORE_OUTPUT) {
mLastBuffer = (mLastBuffer->next = new nsHtml5UTF16Buffer(NS_HTML5_PARSER_READ_BUFFER_SIZE));
NS_ASSERTION(((PRUint32)totalByteCount < aCount), "The Unicode has consumed too many bytes.");
} else {
NS_ASSERTION(((PRUint32)totalByteCount == aCount), "The Unicode decoder consumed the wrong number of bytes.");
*aWriteCount = totalByteCount;
return NS_OK;
}
}
}
void
nsHtml5Parser::ParseUntilSuspend()
{
NS_PRECONDITION((!mNeedsCharsetSwitch), "ParseUntilSuspend called when charset switch needed.");
// NS_PRECONDITION((!mTerminated), "ParseUntilSuspend called when parser had been terminated.");
if (mBlocked) {
return;
}
WillResumeImpl();
WillProcessTokensImpl();
mSuspending = PR_FALSE;
for (;;) {
if (!mFirstBuffer->hasMore()) {
if (mFirstBuffer == mLastBuffer) {
switch (mLifeCycle) {
case PARSING:
// never release the last buffer. instead just zero its indeces for refill
mFirstBuffer->setStart(0);
mFirstBuffer->setEnd(0);
return; // no more data for now but expecting more
case STREAM_ENDING:
DidBuildModel();
return; // no more data and not expecting more
default:
NS_NOTREACHED("ParseUntilSuspended should only be called in PARSING and STREAM_ENDING life cycle states.");
return;
}
} else {
nsHtml5UTF16Buffer* oldBuf = mFirstBuffer;
mFirstBuffer = mFirstBuffer->next;
delete oldBuf;
continue;
}
}
// now we have a non-empty buffer
mFirstBuffer->adjust(mLastWasCR);
mLastWasCR = PR_FALSE;
if (mFirstBuffer->hasMore()) {
mLastWasCR = mTokenizer->tokenizeBuffer(mFirstBuffer);
if (mScriptElement) {
ExecuteScript();
}
if (mNeedsCharsetSwitch) {
// XXX setup immediate reparse
return;
}
if (mBlocked) {
NS_ASSERTION((!mFragmentMode), "Script blocked the parser but we are in the fragment mode.");
WillInterruptImpl();
return;
}
if (mSuspending && !mFragmentMode) {
// We never suspend in the fragment mode.
MaybePostContinueEvent();
WillInterruptImpl();
return;
}
continue;
} else {
continue;
}
}
}
/**
* This method executes a script element set by nsHtml5TreeBuilder. The reason
* why this code is here and not in the tree builder is to allow the control
* to return from the tokenizer before scripts run. This way, the tokenizer
* is not invoked re-entrantly although the parser is.
*/
void
nsHtml5Parser::ExecuteScript()
{
NS_PRECONDITION(mScriptElement, "Trying to run a script without having one!");
// Copied from nsXMLContentSink
// Now tell the script that it's ready to go. This may execute the script
// or return NS_ERROR_HTMLPARSER_BLOCK. Or neither if the script doesn't
// need executing.
nsresult rv = mScriptElement->DoneAddingChildren(PR_TRUE);
// If the act of insertion evaluated the script, we're fine.
// Else, block the parser till the script has loaded.
if (rv == NS_ERROR_HTMLPARSER_BLOCK) {
nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(mScriptElement);
mScriptElements.AppendObject(sele);
BlockParser();
}
mScriptElement = nsnull;
}
void
nsHtml5Parser::MaybePostContinueEvent()
{
NS_PRECONDITION((mLifeCycle != TERMINATED), "Tried to post continue event when the parser is done.");
if (mContinueEvent) {
return; // we already have a pending event
}
if (mStreamListenerState == eOnStart || mStreamListenerState == eOnDataAvail) {
return; // we are expecting stream events
}
// This creates a reference cycle between this and the event that is
// broken when the event fires.
nsCOMPtr<nsIRunnable> event = new nsHtml5ParserContinueEvent(this);
if (NS_FAILED(NS_DispatchToCurrentThread(event))) {
NS_WARNING("failed to dispatch parser continuation event");
} else {
mContinueEvent = event;
}
}
void
nsHtml5Parser::Suspend()
{
mSuspending = PR_TRUE;
}
void
nsHtml5Parser::Cleanup()
{
}
nsresult
nsHtml5Parser::Initialize(nsIDocument* aDoc,
nsIURI* aURI,
nsISupports* aContainer,
nsIChannel* aChannel)
{
MOZ_TIMER_DEBUGLOG(("Reset and start: nsXMLContentSink::Init(), this=%p\n",
this));
MOZ_TIMER_RESET(mWatch);
MOZ_TIMER_START(mWatch);
nsresult rv = nsContentSink::Init(aDoc, aURI, aContainer, aChannel);
NS_ENSURE_SUCCESS(rv, rv);
aDoc->AddObserver(this);
MOZ_TIMER_DEBUGLOG(("Stop: nsXMLContentSink::Init()\n"));
MOZ_TIMER_STOP(mWatch);
return NS_OK;
}
nsresult
nsHtml5Parser::ProcessBASETag(nsIContent* aContent)
{
NS_ASSERTION(aContent, "missing base-element");
nsresult rv = NS_OK;
if (mDocument) {
nsAutoString value;
if (aContent->GetAttr(kNameSpaceID_None, nsHtml5Atoms::target, value)) {
mDocument->SetBaseTarget(value);
}
if (aContent->GetAttr(kNameSpaceID_None, nsHtml5Atoms::href, value)) {
nsCOMPtr<nsIURI> baseURI;
rv = NS_NewURI(getter_AddRefs(baseURI), value);
if (NS_SUCCEEDED(rv)) {
rv = mDocument->SetBaseURI(baseURI); // The document checks if it is legal to set this base
if (NS_SUCCEEDED(rv)) {
mDocumentBaseURI = mDocument->GetBaseURI();
}
}
}
}
return rv;
}
void
nsHtml5Parser::UpdateStyleSheet(nsIContent* aElement)
{
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(aElement));
if (ssle) {
ssle->SetEnableUpdates(PR_TRUE);
PRBool willNotify;
PRBool isAlternate;
nsresult result = ssle->UpdateStyleSheet(this, &willNotify, &isAlternate);
if (NS_SUCCEEDED(result) && willNotify && !isAlternate) {
++mPendingSheetCount;
mScriptLoader->AddExecuteBlocker();
}
}
}
void
nsHtml5Parser::SetScriptElement(nsIContent* aScript)
{
mScriptElement = aScript;
}
void
nsHtml5Parser::UpdateChildCounts()
{
// No-op
}
nsresult
nsHtml5Parser::FlushTags()
{
mTreeBuilder->Flush();
return NS_OK;
}

View File

@ -0,0 +1,343 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Henri Sivonen <hsivonen@iki.fi>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef NS_HTML5_PARSER__
#define NS_HTML5_PARSER__
#include "nsTimer.h"
#include "nsIParser.h"
#include "nsDeque.h"
#include "nsIURL.h"
#include "nsParserCIID.h"
#include "nsITokenizer.h"
#include "nsThreadUtils.h"
#include "nsIContentSink.h"
#include "nsIParserFilter.h"
#include "nsIRequest.h"
#include "nsIChannel.h"
#include "nsCOMArray.h"
#include "nsContentSink.h"
#include "nsIHTMLDocument.h"
#include "nsIUnicharStreamListener.h"
#include "nsCycleCollectionParticipant.h"
#include "nsAutoPtr.h"
#include "nsIInputStream.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5UTF16Buffer.h"
#define NS_HTML5_PARSER_CID \
{0x3113adb0, 0xe56d, 0x459e, \
{0xb9, 0x5b, 0xf1, 0xf2, 0x4a, 0xba, 0x2a, 0x80}}
#define NS_HTML5_PARSER_READ_BUFFER_SIZE 1024
enum eHtml5ParserLifecycle {
NOT_STARTED = 0,
PARSING = 1,
STREAM_ENDING = 2,
TERMINATED = 3,
};
class nsHtml5Parser : public nsIParser,
public nsIStreamListener,
public nsIContentSink,
public nsContentSink {
public:
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
nsHtml5Parser();
virtual ~nsHtml5Parser();
/* Start nsIParser */
/**
* No-op for backwards compat.
*/
NS_IMETHOD_(void) SetContentSink(nsIContentSink* aSink);
/**
* Returns |this| for backwards compat.
*/
NS_IMETHOD_(nsIContentSink*) GetContentSink(void);
/**
* Methods for backwards compat.
*/
NS_IMETHOD_(void) GetCommand(nsCString& aCommand);
NS_IMETHOD_(void) SetCommand(const char* aCommand);
NS_IMETHOD_(void) SetCommand(eParserCommands aParserCommand);
/**
* Call this method once you've created a parser, and want to instruct it
* about what charset to load
*
* @update ftang 4/23/99
* @param aCharset- the charset of a document
* @param aCharsetSource- the source of the charset
* @return nada
*/
NS_IMETHOD_(void) SetDocumentCharset(const nsACString& aCharset, PRInt32 aSource);
NS_IMETHOD_(void) GetDocumentCharset(nsACString& aCharset, PRInt32& aSource)
{
aCharset = mCharset;
aSource = mCharsetSource;
}
/**
* No-op for backwards compat.
*/
NS_IMETHOD_(void) SetParserFilter(nsIParserFilter* aFilter);
/**
* Get the channel associated with this parser
* @update harishd,gagan 07/17/01
* @param aChannel out param that will contain the result
* @return NS_OK if successful
*/
NS_IMETHOD GetChannel(nsIChannel** aChannel);
/**
* Return |this| for backwards compat.
*/
NS_IMETHOD GetDTD(nsIDTD** aDTD);
NS_IMETHOD ContinueParsing();
NS_IMETHOD ContinueInterruptedParsing();
NS_IMETHOD_(void) BlockParser();
NS_IMETHOD_(void) UnblockParser();
/**
* Call this to query whether the parser is enabled or not.
*
* @update vidur 4/12/99
* @return current state
*/
NS_IMETHOD_(PRBool) IsParserEnabled();
/**
* Call this to query whether the parser thinks it's done with parsing.
*
* @update rickg 5/12/01
* @return complete state
*/
NS_IMETHOD_(PRBool) IsComplete();
/**
* Cause parser to parse input from given URL
* @update gess5/11/98
* @param aURL is a descriptor for source document
* @param aListener is a listener to forward notifications to
* @return TRUE if all went well -- FALSE otherwise
*/
NS_IMETHOD Parse(nsIURI* aURL,
nsIRequestObserver* aListener = nsnull,
void* aKey = 0,
nsDTDMode aMode = eDTDMode_autodetect);
/**
* @update gess5/11/98
* @param anHTMLString contains a string-full of real HTML
* @param appendTokens tells us whether we should insert tokens inline, or append them.
* @return TRUE if all went well -- FALSE otherwise
*/
NS_IMETHOD Parse(const nsAString& aSourceBuffer,
void* aKey,
const nsACString& aContentType,
PRBool aLastCall,
nsDTDMode aMode = eDTDMode_autodetect);
NS_IMETHOD_(void *) GetRootContextKey();
NS_IMETHOD Terminate(void);
/**
* This method needs documentation
*/
NS_IMETHOD ParseFragment(const nsAString& aSourceBuffer,
void* aKey,
nsTArray<nsString>& aTagStack,
PRBool aXMLMode,
const nsACString& aContentType,
nsDTDMode aMode = eDTDMode_autodetect);
/**
* This method gets called when the tokens have been consumed, and it's time
* to build the model via the content sink.
* @update gess5/11/98
* @return YES if model building went well -- NO otherwise.
*/
NS_IMETHOD BuildModel(void);
/**
* Retrieve the scanner from the topmost parser context
*
* @update gess 6/9/98
* @return ptr to scanner
*/
NS_IMETHOD_(nsDTDMode) GetParseMode(void);
/**
* Removes continue parsing events
* @update kmcclusk 5/18/98
*/
NS_IMETHODIMP CancelParsingEvents();
virtual void Reset();
/* End nsIParser */
//*********************************************
// These methods are callback methods used by
// net lib to let us know about our inputstream.
//*********************************************
// nsIRequestObserver methods:
NS_DECL_NSIREQUESTOBSERVER
// nsIStreamListener methods:
NS_DECL_NSISTREAMLISTENER
/**
* Fired when the continue parse event is triggered.
* @update kmcclusk 5/18/98
*/
void HandleParserContinueEvent(class nsHtml5ParserContinueEvent *);
// EncodingDeclarationHandler
void internalEncodingDeclaration(nsString* aEncoding);
// DocumentModeHandler
void documentMode(nsHtml5DocumentMode m);
// nsIContentSink
NS_IMETHOD WillTokenize();
NS_IMETHOD WillBuildModel();
NS_IMETHOD DidBuildModel();
NS_IMETHOD WillInterrupt();
NS_IMETHOD WillResume();
NS_IMETHOD SetParser(nsIParser* aParser);
virtual void FlushPendingNotifications(mozFlushType aType);
NS_IMETHOD SetDocumentCharset(nsACString& aCharset);
virtual nsISupports *GetTarget();
// Not from an external interface
public:
// nsContentSink methods
virtual nsresult Initialize(nsIDocument* aDoc,
nsIURI* aURI,
nsISupports* aContainer,
nsIChannel* aChannel);
virtual nsresult ProcessBASETag(nsIContent* aContent);
virtual void UpdateChildCounts();
virtual nsresult FlushTags();
// Non-inherited methods
NS_IMETHOD WriteStreamBytes(const char* aFromSegment,
PRUint32 aCount,
PRUint32* aWriteCount);
void Suspend();
void SetScriptElement(nsIContent* aScript);
void UpdateStyleSheet(nsIContent* aElement);
// Getters and setters for fields from nsContentSink
nsIDocument* GetDocument() {
return mDocument;
}
nsNodeInfoManager* GetNodeInfoManager() {
return mNodeInfoManager;
}
nsIDocShell* GetDocShell() {
return mDocShell;
}
private:
void ExecuteScript();
void MaybePostContinueEvent();
/**
* Parse until pending data is exhausted or tree builder suspends
*/
void ParseUntilSuspend();
void Cleanup();
private:
// State variables
PRBool mNeedsCharsetSwitch;
PRBool mLastWasCR;
PRBool mTerminated;
PRBool mLayoutStarted;
PRBool mFragmentMode;
PRBool mBlocked;
PRBool mSuspending;
eHtml5ParserLifecycle mLifeCycle;
eStreamState mStreamListenerState;
// script execution
nsCOMPtr<nsIContent> mScriptElement;
// Gecko integration
void* mRootContextKey;
nsCOMPtr<nsIRequest> mRequest;
nsCOMPtr<nsIRequestObserver> mObserver;
nsIRunnable* mContinueEvent; // weak ref
// tree-related stuff
nsIContent* mDocElement; // weak ref
// encoding-related stuff
PRInt32 mCharsetSource;
nsCString mCharset;
nsCOMPtr<nsIUnicodeDecoder> mUnicodeDecoder;
// Portable parser objects
nsHtml5UTF16Buffer* mFirstBuffer; // manually managed strong ref
nsHtml5UTF16Buffer* mLastBuffer; // weak ref; always points to
// a buffer of the size NS_HTML5_PARSER_READ_BUFFER_SIZE
nsHtml5TreeBuilder* mTreeBuilder; // manually managed strong ref
nsHtml5Tokenizer* mTokenizer; // manually managed strong ref
};
#endif

View File

@ -0,0 +1,181 @@
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsString.h"
#include "jArray.h"
#include "nsHtml5Portability.h"
nsIAtom*
nsHtml5Portability::newLocalNameFromBuffer(PRUnichar* buf, PRInt32 offset, PRInt32 length)
{
// Optimization opportunity: make buf itself null-terminated
PRUnichar* nullTerminated = new PRUnichar[length + 1];
memcpy(nullTerminated,buf, length * sizeof(PRUnichar));
nullTerminated[length] = 0;
nsIAtom* rv = NS_NewAtom(nullTerminated);
delete[] nullTerminated;
return rv;
}
nsString*
nsHtml5Portability::newStringFromBuffer(PRUnichar* buf, PRInt32 offset, PRInt32 length)
{
return new nsString(buf + offset, length);
}
nsString*
nsHtml5Portability::newEmptyString()
{
return new nsString();
}
jArray<PRUnichar,PRInt32>
nsHtml5Portability::newCharArrayFromLocal(nsIAtom* local)
{
nsAutoString temp;
local->ToString(temp);
PRInt32 len = temp.Length();
jArray<PRUnichar,PRInt32> rv = jArray<PRUnichar,PRInt32>(len);
memcpy(rv, temp.BeginReading(), len * sizeof(PRUnichar));
return rv;
}
jArray<PRUnichar,PRInt32>
nsHtml5Portability::newCharArrayFromString(nsString* string)
{
PRInt32 len = string->Length();
jArray<PRUnichar,PRInt32> rv = jArray<PRUnichar,PRInt32>(len);
memcpy(rv, string->BeginReading(), len * sizeof(PRUnichar));
return rv;
}
void
nsHtml5Portability::releaseString(nsString* str)
{
delete str;
}
void
nsHtml5Portability::releaseLocal(nsIAtom* local)
{
NS_RELEASE(local);
}
void
nsHtml5Portability::releaseElement(nsIContent* element)
{
}
PRBool
nsHtml5Portability::localEqualsBuffer(nsIAtom* local, PRUnichar* buf, PRInt32 offset, PRInt32 length)
{
nsAutoString temp = nsAutoString(buf + offset, length);
return local->Equals(temp);
}
PRBool
nsHtml5Portability::lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(nsString* lowerCaseLiteral, nsString* string)
{
if (!string) {
return PR_FALSE;
}
if (lowerCaseLiteral->Length() > string->Length()) {
return PR_FALSE;
}
const PRUnichar* litPtr = lowerCaseLiteral->BeginReading();
const PRUnichar* end = lowerCaseLiteral->EndReading();
const PRUnichar* strPtr = string->BeginReading();
while (litPtr < end) {
PRUnichar litChar = *litPtr;
PRUnichar strChar = *strPtr;
if (strChar >= 'A' && strChar <= 'Z') {
strChar += 0x20;
}
if (litChar != strChar) {
return PR_FALSE;
}
++litPtr;
++strPtr;
}
return PR_TRUE;
}
PRBool
nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString(nsString* lowerCaseLiteral, nsString* string)
{
if (!string) {
return PR_FALSE;
}
if (lowerCaseLiteral->Length() != string->Length()) {
return PR_FALSE;
}
const PRUnichar* litPtr = lowerCaseLiteral->BeginReading();
const PRUnichar* end = lowerCaseLiteral->EndReading();
const PRUnichar* strPtr = string->BeginReading();
while (litPtr < end) {
PRUnichar litChar = *litPtr;
PRUnichar strChar = *strPtr;
if (strChar >= 'A' && strChar <= 'Z') {
strChar += 0x20;
}
if (litChar != strChar) {
return PR_FALSE;
}
++litPtr;
++strPtr;
}
return PR_TRUE;
}
PRBool
nsHtml5Portability::literalEqualsString(nsString* literal, nsString* string)
{
return literal->Equals(*string);
}
jArray<PRUnichar,PRInt32>
nsHtml5Portability::isIndexPrompt()
{
// Yeah, this whole method is uncool
char* literal = "This is a searchable index. Insert your search keywords here: ";
jArray<PRUnichar,PRInt32> rv = jArray<PRUnichar,PRInt32>(62);
for (PRInt32 i = 0; i < 62; ++i) {
rv[i] = literal[i];
}
return rv;
}
PRBool
nsHtml5Portability::localEqualsHtmlIgnoreAsciiCase(nsIAtom* name)
{
const char* reference = "html";
const char* buf;
name->GetUTF8String(&buf);
for(;;) {
char refChar = *reference;
char bufChar = *buf;
if (bufChar >= 'A' && bufChar <= 'Z') {
bufChar += 0x20;
}
if (refChar != bufChar) {
return PR_FALSE;
}
if (!refChar) {
return PR_TRUE;
}
++reference;
++buf;
}
return PR_TRUE; // unreachable but keep compiler happy
}
void
nsHtml5Portability::initializeStatics()
{
}
void
nsHtml5Portability::releaseStatics()
{
}

View File

@ -0,0 +1,84 @@
/*
* Copyright (c) 2008 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* 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
* DEALINGS IN THE SOFTWARE.
*/
/*
* THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
* Please edit Portability.java instead and regenerate.
*/
#ifndef nsHtml5Portability_h__
#define nsHtml5Portability_h__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsString.h"
#include "nsINameSpaceManager.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "jArray.h"
#include "nsHtml5DocumentMode.h"
#include "nsHtml5ArrayCopy.h"
#include "nsHtml5NamedCharacters.h"
#include "nsHtml5Parser.h"
#include "nsHtml5StringLiterals.h"
#include "nsHtml5Atoms.h"
class nsHtml5Parser;
class nsHtml5Tokenizer;
class nsHtml5TreeBuilder;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5StackNode;
class nsHtml5UTF16Buffer;
class nsHtml5Portability
{
public:
static nsIAtom* newLocalNameFromBuffer(PRUnichar* buf, PRInt32 offset, PRInt32 length);
static nsString* newStringFromBuffer(PRUnichar* buf, PRInt32 offset, PRInt32 length);
static nsString* newEmptyString();
static jArray<PRUnichar,PRInt32> newCharArrayFromLocal(nsIAtom* local);
static jArray<PRUnichar,PRInt32> newCharArrayFromString(nsString* string);
static void releaseString(nsString* str);
static void retainLocal(nsIAtom* local);
static void releaseLocal(nsIAtom* local);
static void retainElement(nsIContent* elt);
static void releaseElement(nsIContent* elt);
static PRBool localEqualsBuffer(nsIAtom* local, PRUnichar* buf, PRInt32 offset, PRInt32 length);
static PRBool lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(nsString* lowerCaseLiteral, nsString* string);
static PRBool lowerCaseLiteralEqualsIgnoreAsciiCaseString(nsString* lowerCaseLiteral, nsString* string);
static PRBool literalEqualsString(nsString* literal, nsString* string);
static jArray<PRUnichar,PRInt32> isIndexPrompt();
static PRBool localEqualsHtmlIgnoreAsciiCase(nsIAtom* name);
static void initializeStatics();
static void releaseStatics();
};
#ifdef nsHtml5Portability_cpp__
#endif
#endif

View File

@ -0,0 +1,126 @@
/*
* Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2007-2008 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* 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
* DEALINGS IN THE SOFTWARE.
*/
/*
* THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
* Please edit StackNode.java instead and regenerate.
*/
#define nsHtml5StackNode_cpp__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsString.h"
#include "nsINameSpaceManager.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "jArray.h"
#include "nsHtml5DocumentMode.h"
#include "nsHtml5ArrayCopy.h"
#include "nsHtml5NamedCharacters.h"
#include "nsHtml5Parser.h"
#include "nsHtml5StringLiterals.h"
#include "nsHtml5Atoms.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
#include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5UTF16Buffer.h"
#include "nsHtml5Portability.h"
#include "nsHtml5StackNode.h"
nsHtml5StackNode::nsHtml5StackNode(PRInt32 group, PRInt32 ns, nsIAtom* name, nsIContent* node, PRBool scoping, PRBool special, PRBool fosterParenting, nsIAtom* popName)
: group(group),
name(name),
popName(popName),
ns(ns),
node(node),
scoping(scoping),
special(special),
fosterParenting(fosterParenting),
tainted(PR_FALSE)
{
}
nsHtml5StackNode::nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent* node)
: group(elementName->group),
name(elementName->name),
popName(elementName->name),
ns(ns),
node(node),
scoping(elementName->scoping),
special(elementName->special),
fosterParenting(elementName->fosterParenting),
tainted(PR_FALSE)
{
}
nsHtml5StackNode::nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent* node, nsIAtom* popName)
: group(elementName->group),
name(elementName->name),
popName(popName),
ns(ns),
node(node),
scoping(elementName->scoping),
special(elementName->special),
fosterParenting(elementName->fosterParenting),
tainted(PR_FALSE)
{
}
nsHtml5StackNode::nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent* node, nsIAtom* popName, PRBool scoping)
: group(elementName->group),
name(elementName->name),
popName(popName),
ns(ns),
node(node),
scoping(scoping),
special(PR_FALSE),
fosterParenting(PR_FALSE),
tainted(PR_FALSE)
{
}
void
nsHtml5StackNode::destructor()
{
}
void
nsHtml5StackNode::initializeStatics()
{
}
void
nsHtml5StackNode::releaseStatics()
{
}

View File

@ -0,0 +1,85 @@
/*
* Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2007-2008 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* 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
* DEALINGS IN THE SOFTWARE.
*/
/*
* THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
* Please edit StackNode.java instead and regenerate.
*/
#ifndef nsHtml5StackNode_h__
#define nsHtml5StackNode_h__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsString.h"
#include "nsINameSpaceManager.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "jArray.h"
#include "nsHtml5DocumentMode.h"
#include "nsHtml5ArrayCopy.h"
#include "nsHtml5NamedCharacters.h"
#include "nsHtml5Parser.h"
#include "nsHtml5StringLiterals.h"
#include "nsHtml5Atoms.h"
class nsHtml5Parser;
class nsHtml5Tokenizer;
class nsHtml5TreeBuilder;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5UTF16Buffer;
class nsHtml5Portability;
class nsHtml5StackNode
{
public:
PRInt32 group;
nsIAtom* name;
nsIAtom* popName;
PRInt32 ns;
nsIContent* node;
PRBool scoping;
PRBool special;
PRBool fosterParenting;
PRBool tainted;
nsHtml5StackNode(PRInt32 group, PRInt32 ns, nsIAtom* name, nsIContent* node, PRBool scoping, PRBool special, PRBool fosterParenting, nsIAtom* popName);
nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent* node);
nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent* node, nsIAtom* popName);
nsHtml5StackNode(PRInt32 ns, nsHtml5ElementName* elementName, nsIContent* node, nsIAtom* popName, PRBool scoping);
private:
void destructor();
public:
static void initializeStatics();
static void releaseStatics();
};
#ifdef nsHtml5StackNode_cpp__
#endif
#endif

View File

@ -0,0 +1,251 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is HTML Parser C++ Translator code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Henri Sivonen <hsivonen@iki.fi>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsString.h"
#include "nsLiteralString.h"
#include "nsHtml5StringLiterals.h"
nsString* nsHtml5StringLiterals::___silmaril__dtd_html_pro_v0r11_19970101__ = nsnull;
nsString* nsHtml5StringLiterals::___advasoft_ltd__dtd_html_3_0_aswedit___extensions__ = nsnull;
nsString* nsHtml5StringLiterals::___as__dtd_html_3_0_aswedit___extensions__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_2_0_level_1__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_2_0_level_2__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_2_0_strict_level_1__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_2_0_strict_level_2__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_2_0_strict__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_2_0__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_2_1e__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_3_0__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_3_2_final__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_3_2__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_3__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_level_0__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_level_1__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_level_2__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_level_3__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_strict_level_0__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_strict_level_1__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_strict_level_2__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_strict_level_3__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html_strict__ = nsnull;
nsString* nsHtml5StringLiterals::___ietf__dtd_html__ = nsnull;
nsString* nsHtml5StringLiterals::___metrius__dtd_metrius_presentational__ = nsnull;
nsString* nsHtml5StringLiterals::___microsoft__dtd_internet_explorer_2_0_html_strict__ = nsnull;
nsString* nsHtml5StringLiterals::___microsoft__dtd_internet_explorer_2_0_html__ = nsnull;
nsString* nsHtml5StringLiterals::___microsoft__dtd_internet_explorer_2_0_tables__ = nsnull;
nsString* nsHtml5StringLiterals::___microsoft__dtd_internet_explorer_3_0_html_strict__ = nsnull;
nsString* nsHtml5StringLiterals::___microsoft__dtd_internet_explorer_3_0_html__ = nsnull;
nsString* nsHtml5StringLiterals::___microsoft__dtd_internet_explorer_3_0_tables__ = nsnull;
nsString* nsHtml5StringLiterals::___netscape_comm__corp___dtd_html__ = nsnull;
nsString* nsHtml5StringLiterals::___netscape_comm__corp___dtd_strict_html__ = nsnull;
nsString* nsHtml5StringLiterals::___o_reilly_and_associates__dtd_html_2_0__ = nsnull;
nsString* nsHtml5StringLiterals::___o_reilly_and_associates__dtd_html_extended_1_0__ = nsnull;
nsString* nsHtml5StringLiterals::___o_reilly_and_associates__dtd_html_extended_relaxed_1_0__ = nsnull;
nsString* nsHtml5StringLiterals::___softquad_software__dtd_hotmetal_pro_6_0__19990601__extensions_to_html_4_0__ = nsnull;
nsString* nsHtml5StringLiterals::___softquad__dtd_hotmetal_pro_4_0__19971010__extensions_to_html_4_0__ = nsnull;
nsString* nsHtml5StringLiterals::___spyglass__dtd_html_2_0_extended__ = nsnull;
nsString* nsHtml5StringLiterals::___sq__dtd_html_2_0_hotmetal___extensions__ = nsnull;
nsString* nsHtml5StringLiterals::___sun_microsystems_corp___dtd_hotjava_html__ = nsnull;
nsString* nsHtml5StringLiterals::___sun_microsystems_corp___dtd_hotjava_strict_html__ = nsnull;
nsString* nsHtml5StringLiterals::___w3c__dtd_html_3_1995_03_24__ = nsnull;
nsString* nsHtml5StringLiterals::___w3c__dtd_html_3_2_draft__ = nsnull;
nsString* nsHtml5StringLiterals::___w3c__dtd_html_3_2_final__ = nsnull;
nsString* nsHtml5StringLiterals::___w3c__dtd_html_3_2__ = nsnull;
nsString* nsHtml5StringLiterals::___w3c__dtd_html_3_2s_draft__ = nsnull;
nsString* nsHtml5StringLiterals::___w3c__dtd_html_4_0_frameset__ = nsnull;
nsString* nsHtml5StringLiterals::___w3c__dtd_html_4_0_transitional__ = nsnull;
nsString* nsHtml5StringLiterals::___w3c__dtd_html_experimental_19960712__ = nsnull;
nsString* nsHtml5StringLiterals::___w3c__dtd_html_experimental_970421__ = nsnull;
nsString* nsHtml5StringLiterals::___w3c__dtd_w3_html__ = nsnull;
nsString* nsHtml5StringLiterals::___w3o__dtd_w3_html_3_0__ = nsnull;
nsString* nsHtml5StringLiterals::___webtechs__dtd_mozilla_html_2_0__ = nsnull;
nsString* nsHtml5StringLiterals::___webtechs__dtd_mozilla_html__ = nsnull;
nsString* nsHtml5StringLiterals::XSLT_generated = nsnull;
nsString* nsHtml5StringLiterals::___w3c__dtd_xhtml_1_0_transitional__en = nsnull;
nsString* nsHtml5StringLiterals::___w3c__dtd_xhtml_1_0_frameset__en = nsnull;
nsString* nsHtml5StringLiterals::___w3c__dtd_html_4_01_transitional__en = nsnull;
nsString* nsHtml5StringLiterals::___w3c__dtd_html_4_01_frameset__en = nsnull;
nsString* nsHtml5StringLiterals::___w3o__dtd_w3_html_strict_3_0__en__ = nsnull;
nsString* nsHtml5StringLiterals::__w3c_dtd_html_4_0_transitional_en = nsnull;
nsString* nsHtml5StringLiterals::http___www_ibm_com_data_dtd_v11_ibmxhtml1_transitional_dtd = nsnull;
nsString* nsHtml5StringLiterals::hidden = nsnull;
nsString* nsHtml5StringLiterals::isindex = nsnull;
nsString* nsHtml5StringLiterals::html = nsnull;
void
nsHtml5StringLiterals::initializeStatics()
{
(___silmaril__dtd_html_pro_v0r11_19970101__ = new nsString())->Assign(NS_LITERAL_STRING("+//silmaril//dtd html pro v0r11 19970101//"));
(___advasoft_ltd__dtd_html_3_0_aswedit___extensions__ = new nsString())->Assign(NS_LITERAL_STRING("-//advasoft ltd//dtd html 3.0 aswedit + extensions//"));
(___as__dtd_html_3_0_aswedit___extensions__ = new nsString())->Assign(NS_LITERAL_STRING("-//as//dtd html 3.0 aswedit + extensions//"));
(___ietf__dtd_html_2_0_level_1__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html 2.0 level 1//"));
(___ietf__dtd_html_2_0_level_2__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html 2.0 level 2//"));
(___ietf__dtd_html_2_0_strict_level_1__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html 2.0 strict level 1//"));
(___ietf__dtd_html_2_0_strict_level_2__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html 2.0 strict level 2//"));
(___ietf__dtd_html_2_0_strict__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html 2.0 strict//"));
(___ietf__dtd_html_2_0__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html 2.0//"));
(___ietf__dtd_html_2_1e__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html 2.1e//"));
(___ietf__dtd_html_3_0__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html 3.0//"));
(___ietf__dtd_html_3_2_final__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html 3.2 final//"));
(___ietf__dtd_html_3_2__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html 3.2//"));
(___ietf__dtd_html_3__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html 3//"));
(___ietf__dtd_html_level_0__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html level 0//"));
(___ietf__dtd_html_level_1__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html level 1//"));
(___ietf__dtd_html_level_2__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html level 2//"));
(___ietf__dtd_html_level_3__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html level 3//"));
(___ietf__dtd_html_strict_level_0__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html strict level 0//"));
(___ietf__dtd_html_strict_level_1__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html strict level 1//"));
(___ietf__dtd_html_strict_level_2__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html strict level 2//"));
(___ietf__dtd_html_strict_level_3__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html strict level 3//"));
(___ietf__dtd_html_strict__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html strict//"));
(___ietf__dtd_html__ = new nsString())->Assign(NS_LITERAL_STRING("-//ietf//dtd html//"));
(___metrius__dtd_metrius_presentational__ = new nsString())->Assign(NS_LITERAL_STRING("-//metrius//dtd metrius presentational//"));
(___microsoft__dtd_internet_explorer_2_0_html_strict__ = new nsString())->Assign(NS_LITERAL_STRING("-//microsoft//dtd internet explorer 2.0 html strict//"));
(___microsoft__dtd_internet_explorer_2_0_html__ = new nsString())->Assign(NS_LITERAL_STRING("-//microsoft//dtd internet explorer 2.0 html//"));
(___microsoft__dtd_internet_explorer_2_0_tables__ = new nsString())->Assign(NS_LITERAL_STRING("-//microsoft//dtd internet explorer 2.0 tables//"));
(___microsoft__dtd_internet_explorer_3_0_html_strict__ = new nsString())->Assign(NS_LITERAL_STRING("-//microsoft//dtd internet explorer 3.0 html strict//"));
(___microsoft__dtd_internet_explorer_3_0_html__ = new nsString())->Assign(NS_LITERAL_STRING("-//microsoft//dtd internet explorer 3.0 html//"));
(___microsoft__dtd_internet_explorer_3_0_tables__ = new nsString())->Assign(NS_LITERAL_STRING("-//microsoft//dtd internet explorer 3.0 tables//"));
(___netscape_comm__corp___dtd_html__ = new nsString())->Assign(NS_LITERAL_STRING("-//netscape comm. corp.//dtd html//"));
(___netscape_comm__corp___dtd_strict_html__ = new nsString())->Assign(NS_LITERAL_STRING("-//netscape comm. corp.//dtd strict html//"));
(___o_reilly_and_associates__dtd_html_2_0__ = new nsString())->Assign(NS_LITERAL_STRING("-//o'reilly and associates//dtd html 2.0//"));
(___o_reilly_and_associates__dtd_html_extended_1_0__ = new nsString())->Assign(NS_LITERAL_STRING("-//o'reilly and associates//dtd html extended 1.0//"));
(___o_reilly_and_associates__dtd_html_extended_relaxed_1_0__ = new nsString())->Assign(NS_LITERAL_STRING("-//o'reilly and associates//dtd html extended relaxed 1.0//"));
(___softquad_software__dtd_hotmetal_pro_6_0__19990601__extensions_to_html_4_0__ = new nsString())->Assign(NS_LITERAL_STRING("-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//"));
(___softquad__dtd_hotmetal_pro_4_0__19971010__extensions_to_html_4_0__ = new nsString())->Assign(NS_LITERAL_STRING("-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//"));
(___spyglass__dtd_html_2_0_extended__ = new nsString())->Assign(NS_LITERAL_STRING("-//spyglass//dtd html 2.0 extended//"));
(___sq__dtd_html_2_0_hotmetal___extensions__ = new nsString())->Assign(NS_LITERAL_STRING("-//sq//dtd html 2.0 hotmetal + extensions//"));
(___sun_microsystems_corp___dtd_hotjava_html__ = new nsString())->Assign(NS_LITERAL_STRING("-//sun microsystems corp.//dtd hotjava html//"));
(___sun_microsystems_corp___dtd_hotjava_strict_html__ = new nsString())->Assign(NS_LITERAL_STRING("-//sun microsystems corp.//dtd hotjava strict html//"));
(___w3c__dtd_html_3_1995_03_24__ = new nsString())->Assign(NS_LITERAL_STRING("-//w3c//dtd html 3 1995-03-24//"));
(___w3c__dtd_html_3_2_draft__ = new nsString())->Assign(NS_LITERAL_STRING("-//w3c//dtd html 3.2 draft//"));
(___w3c__dtd_html_3_2_final__ = new nsString())->Assign(NS_LITERAL_STRING("-//w3c//dtd html 3.2 final//"));
(___w3c__dtd_html_3_2__ = new nsString())->Assign(NS_LITERAL_STRING("-//w3c//dtd html 3.2//"));
(___w3c__dtd_html_3_2s_draft__ = new nsString())->Assign(NS_LITERAL_STRING("-//w3c//dtd html 3.2s draft//"));
(___w3c__dtd_html_4_0_frameset__ = new nsString())->Assign(NS_LITERAL_STRING("-//w3c//dtd html 4.0 frameset//"));
(___w3c__dtd_html_4_0_transitional__ = new nsString())->Assign(NS_LITERAL_STRING("-//w3c//dtd html 4.0 transitional//"));
(___w3c__dtd_html_experimental_19960712__ = new nsString())->Assign(NS_LITERAL_STRING("-//w3c//dtd html experimental 19960712//"));
(___w3c__dtd_html_experimental_970421__ = new nsString())->Assign(NS_LITERAL_STRING("-//w3c//dtd html experimental 970421//"));
(___w3c__dtd_w3_html__ = new nsString())->Assign(NS_LITERAL_STRING("-//w3c//dtd w3 html//"));
(___w3o__dtd_w3_html_3_0__ = new nsString())->Assign(NS_LITERAL_STRING("-//w3o//dtd w3 html 3.0//"));
(___webtechs__dtd_mozilla_html_2_0__ = new nsString())->Assign(NS_LITERAL_STRING("-//webtechs//dtd mozilla html 2.0//"));
(___webtechs__dtd_mozilla_html__ = new nsString())->Assign(NS_LITERAL_STRING("-//webtechs//dtd mozilla html//"));
(XSLT_generated = new nsString())->Assign(NS_LITERAL_STRING("XSLT-generated"));
(___w3c__dtd_xhtml_1_0_transitional__en = new nsString())->Assign(NS_LITERAL_STRING("-//w3c//dtd xhtml 1.0 transitional//en"));
(___w3c__dtd_xhtml_1_0_frameset__en = new nsString())->Assign(NS_LITERAL_STRING("-//w3c//dtd xhtml 1.0 frameset//en"));
(___w3c__dtd_html_4_01_transitional__en = new nsString())->Assign(NS_LITERAL_STRING("-//w3c//dtd html 4.01 transitional//en"));
(___w3c__dtd_html_4_01_frameset__en = new nsString())->Assign(NS_LITERAL_STRING("-//w3c//dtd html 4.01 frameset//en"));
(___w3o__dtd_w3_html_strict_3_0__en__ = new nsString())->Assign(NS_LITERAL_STRING("-//w3o//dtd w3 html strict 3.0//en//"));
(__w3c_dtd_html_4_0_transitional_en = new nsString())->Assign(NS_LITERAL_STRING("-/w3c/dtd html 4.0 transitional/en"));
(http___www_ibm_com_data_dtd_v11_ibmxhtml1_transitional_dtd = new nsString())->Assign(NS_LITERAL_STRING("http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"));
(hidden = new nsString())->Assign(NS_LITERAL_STRING("hidden"));
(isindex = new nsString())->Assign(NS_LITERAL_STRING("isindex"));
(html = new nsString())->Assign(NS_LITERAL_STRING("html"));
}
void
nsHtml5StringLiterals::releaseStatics()
{
delete ___silmaril__dtd_html_pro_v0r11_19970101__;
delete ___advasoft_ltd__dtd_html_3_0_aswedit___extensions__;
delete ___as__dtd_html_3_0_aswedit___extensions__;
delete ___ietf__dtd_html_2_0_level_1__;
delete ___ietf__dtd_html_2_0_level_2__;
delete ___ietf__dtd_html_2_0_strict_level_1__;
delete ___ietf__dtd_html_2_0_strict_level_2__;
delete ___ietf__dtd_html_2_0_strict__;
delete ___ietf__dtd_html_2_0__;
delete ___ietf__dtd_html_2_1e__;
delete ___ietf__dtd_html_3_0__;
delete ___ietf__dtd_html_3_2_final__;
delete ___ietf__dtd_html_3_2__;
delete ___ietf__dtd_html_3__;
delete ___ietf__dtd_html_level_0__;
delete ___ietf__dtd_html_level_1__;
delete ___ietf__dtd_html_level_2__;
delete ___ietf__dtd_html_level_3__;
delete ___ietf__dtd_html_strict_level_0__;
delete ___ietf__dtd_html_strict_level_1__;
delete ___ietf__dtd_html_strict_level_2__;
delete ___ietf__dtd_html_strict_level_3__;
delete ___ietf__dtd_html_strict__;
delete ___ietf__dtd_html__;
delete ___metrius__dtd_metrius_presentational__;
delete ___microsoft__dtd_internet_explorer_2_0_html_strict__;
delete ___microsoft__dtd_internet_explorer_2_0_html__;
delete ___microsoft__dtd_internet_explorer_2_0_tables__;
delete ___microsoft__dtd_internet_explorer_3_0_html_strict__;
delete ___microsoft__dtd_internet_explorer_3_0_html__;
delete ___microsoft__dtd_internet_explorer_3_0_tables__;
delete ___netscape_comm__corp___dtd_html__;
delete ___netscape_comm__corp___dtd_strict_html__;
delete ___o_reilly_and_associates__dtd_html_2_0__;
delete ___o_reilly_and_associates__dtd_html_extended_1_0__;
delete ___o_reilly_and_associates__dtd_html_extended_relaxed_1_0__;
delete ___softquad_software__dtd_hotmetal_pro_6_0__19990601__extensions_to_html_4_0__;
delete ___softquad__dtd_hotmetal_pro_4_0__19971010__extensions_to_html_4_0__;
delete ___spyglass__dtd_html_2_0_extended__;
delete ___sq__dtd_html_2_0_hotmetal___extensions__;
delete ___sun_microsystems_corp___dtd_hotjava_html__;
delete ___sun_microsystems_corp___dtd_hotjava_strict_html__;
delete ___w3c__dtd_html_3_1995_03_24__;
delete ___w3c__dtd_html_3_2_draft__;
delete ___w3c__dtd_html_3_2_final__;
delete ___w3c__dtd_html_3_2__;
delete ___w3c__dtd_html_3_2s_draft__;
delete ___w3c__dtd_html_4_0_frameset__;
delete ___w3c__dtd_html_4_0_transitional__;
delete ___w3c__dtd_html_experimental_19960712__;
delete ___w3c__dtd_html_experimental_970421__;
delete ___w3c__dtd_w3_html__;
delete ___w3o__dtd_w3_html_3_0__;
delete ___webtechs__dtd_mozilla_html_2_0__;
delete ___webtechs__dtd_mozilla_html__;
delete XSLT_generated;
delete ___w3c__dtd_xhtml_1_0_transitional__en;
delete ___w3c__dtd_xhtml_1_0_frameset__en;
delete ___w3c__dtd_html_4_01_transitional__en;
delete ___w3c__dtd_html_4_01_frameset__en;
delete ___w3o__dtd_w3_html_strict_3_0__en__;
delete __w3c_dtd_html_4_0_transitional_en;
delete http___www_ibm_com_data_dtd_v11_ibmxhtml1_transitional_dtd;
delete hidden;
delete isindex;
delete html;
}

View File

@ -0,0 +1,119 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is HTML Parser C++ Translator code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Henri Sivonen <hsivonen@iki.fi>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsHtml5StringLiterals_h__
#define nsHtml5StringLiterals_h__
#include "nsString.h"
class nsHtml5StringLiterals
{
public:
static nsString* ___silmaril__dtd_html_pro_v0r11_19970101__;
static nsString* ___advasoft_ltd__dtd_html_3_0_aswedit___extensions__;
static nsString* ___as__dtd_html_3_0_aswedit___extensions__;
static nsString* ___ietf__dtd_html_2_0_level_1__;
static nsString* ___ietf__dtd_html_2_0_level_2__;
static nsString* ___ietf__dtd_html_2_0_strict_level_1__;
static nsString* ___ietf__dtd_html_2_0_strict_level_2__;
static nsString* ___ietf__dtd_html_2_0_strict__;
static nsString* ___ietf__dtd_html_2_0__;
static nsString* ___ietf__dtd_html_2_1e__;
static nsString* ___ietf__dtd_html_3_0__;
static nsString* ___ietf__dtd_html_3_2_final__;
static nsString* ___ietf__dtd_html_3_2__;
static nsString* ___ietf__dtd_html_3__;
static nsString* ___ietf__dtd_html_level_0__;
static nsString* ___ietf__dtd_html_level_1__;
static nsString* ___ietf__dtd_html_level_2__;
static nsString* ___ietf__dtd_html_level_3__;
static nsString* ___ietf__dtd_html_strict_level_0__;
static nsString* ___ietf__dtd_html_strict_level_1__;
static nsString* ___ietf__dtd_html_strict_level_2__;
static nsString* ___ietf__dtd_html_strict_level_3__;
static nsString* ___ietf__dtd_html_strict__;
static nsString* ___ietf__dtd_html__;
static nsString* ___metrius__dtd_metrius_presentational__;
static nsString* ___microsoft__dtd_internet_explorer_2_0_html_strict__;
static nsString* ___microsoft__dtd_internet_explorer_2_0_html__;
static nsString* ___microsoft__dtd_internet_explorer_2_0_tables__;
static nsString* ___microsoft__dtd_internet_explorer_3_0_html_strict__;
static nsString* ___microsoft__dtd_internet_explorer_3_0_html__;
static nsString* ___microsoft__dtd_internet_explorer_3_0_tables__;
static nsString* ___netscape_comm__corp___dtd_html__;
static nsString* ___netscape_comm__corp___dtd_strict_html__;
static nsString* ___o_reilly_and_associates__dtd_html_2_0__;
static nsString* ___o_reilly_and_associates__dtd_html_extended_1_0__;
static nsString* ___o_reilly_and_associates__dtd_html_extended_relaxed_1_0__;
static nsString* ___softquad_software__dtd_hotmetal_pro_6_0__19990601__extensions_to_html_4_0__;
static nsString* ___softquad__dtd_hotmetal_pro_4_0__19971010__extensions_to_html_4_0__;
static nsString* ___spyglass__dtd_html_2_0_extended__;
static nsString* ___sq__dtd_html_2_0_hotmetal___extensions__;
static nsString* ___sun_microsystems_corp___dtd_hotjava_html__;
static nsString* ___sun_microsystems_corp___dtd_hotjava_strict_html__;
static nsString* ___w3c__dtd_html_3_1995_03_24__;
static nsString* ___w3c__dtd_html_3_2_draft__;
static nsString* ___w3c__dtd_html_3_2_final__;
static nsString* ___w3c__dtd_html_3_2__;
static nsString* ___w3c__dtd_html_3_2s_draft__;
static nsString* ___w3c__dtd_html_4_0_frameset__;
static nsString* ___w3c__dtd_html_4_0_transitional__;
static nsString* ___w3c__dtd_html_experimental_19960712__;
static nsString* ___w3c__dtd_html_experimental_970421__;
static nsString* ___w3c__dtd_w3_html__;
static nsString* ___w3o__dtd_w3_html_3_0__;
static nsString* ___webtechs__dtd_mozilla_html_2_0__;
static nsString* ___webtechs__dtd_mozilla_html__;
static nsString* XSLT_generated;
static nsString* ___w3c__dtd_xhtml_1_0_transitional__en;
static nsString* ___w3c__dtd_xhtml_1_0_frameset__en;
static nsString* ___w3c__dtd_html_4_01_transitional__en;
static nsString* ___w3c__dtd_html_4_01_frameset__en;
static nsString* ___w3o__dtd_w3_html_strict_3_0__en__;
static nsString* __w3c_dtd_html_4_0_transitional_en;
static nsString* http___www_ibm_com_data_dtd_v11_ibmxhtml1_transitional_dtd;
static nsString* hidden;
static nsString* isindex;
static nsString* html;
static void initializeStatics();
static void releaseStatics();
};
#endif // nsHtml5StringLiterals_h__

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,336 @@
/*
* Copyright (c) 2005, 2006, 2007 Henri Sivonen
* Copyright (c) 2007-2008 Mozilla Foundation
* Portions of comments Copyright 2004-2007 Apple Computer, Inc., Mozilla
* Foundation, and Opera Software ASA.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* 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
* DEALINGS IN THE SOFTWARE.
*/
/*
* THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
* Please edit Tokenizer.java instead and regenerate.
*/
#ifndef nsHtml5Tokenizer_h__
#define nsHtml5Tokenizer_h__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsString.h"
#include "nsINameSpaceManager.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "jArray.h"
#include "nsHtml5DocumentMode.h"
#include "nsHtml5ArrayCopy.h"
#include "nsHtml5NamedCharacters.h"
#include "nsHtml5Parser.h"
#include "nsHtml5StringLiterals.h"
#include "nsHtml5Atoms.h"
class nsHtml5Parser;
class nsHtml5TreeBuilder;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5StackNode;
class nsHtml5UTF16Buffer;
class nsHtml5Portability;
class nsHtml5Tokenizer
{
private:
static PRUnichar LT_GT[];
static PRUnichar LT_SOLIDUS[];
static PRUnichar RSQB_RSQB[];
static PRUnichar REPLACEMENT_CHARACTER[];
static PRUnichar LF[];
static PRUnichar CDATA_LSQB[];
static PRUnichar OCTYPE[];
static PRUnichar UBLIC[];
static PRUnichar YSTEM[];
#ifdef nsHtml5Tokenizer_cpp__
static PRUnichar TITLE_ARR_DATA[];
#endif
static jArray<PRUnichar,PRInt32> TITLE_ARR;
#ifdef nsHtml5Tokenizer_cpp__
static PRUnichar SCRIPT_ARR_DATA[];
#endif
static jArray<PRUnichar,PRInt32> SCRIPT_ARR;
#ifdef nsHtml5Tokenizer_cpp__
static PRUnichar STYLE_ARR_DATA[];
#endif
static jArray<PRUnichar,PRInt32> STYLE_ARR;
#ifdef nsHtml5Tokenizer_cpp__
static PRUnichar PLAINTEXT_ARR_DATA[];
#endif
static jArray<PRUnichar,PRInt32> PLAINTEXT_ARR;
#ifdef nsHtml5Tokenizer_cpp__
static PRUnichar XMP_ARR_DATA[];
#endif
static jArray<PRUnichar,PRInt32> XMP_ARR;
#ifdef nsHtml5Tokenizer_cpp__
static PRUnichar TEXTAREA_ARR_DATA[];
#endif
static jArray<PRUnichar,PRInt32> TEXTAREA_ARR;
#ifdef nsHtml5Tokenizer_cpp__
static PRUnichar IFRAME_ARR_DATA[];
#endif
static jArray<PRUnichar,PRInt32> IFRAME_ARR;
#ifdef nsHtml5Tokenizer_cpp__
static PRUnichar NOEMBED_ARR_DATA[];
#endif
static jArray<PRUnichar,PRInt32> NOEMBED_ARR;
#ifdef nsHtml5Tokenizer_cpp__
static PRUnichar NOSCRIPT_ARR_DATA[];
#endif
static jArray<PRUnichar,PRInt32> NOSCRIPT_ARR;
#ifdef nsHtml5Tokenizer_cpp__
static PRUnichar NOFRAMES_ARR_DATA[];
#endif
static jArray<PRUnichar,PRInt32> NOFRAMES_ARR;
nsHtml5TreeBuilder* tokenHandler;
nsHtml5Parser* encodingDeclarationHandler;
PRUnichar prev;
PRInt32 line;
PRInt32 linePrev;
PRInt32 col;
PRInt32 colPrev;
PRBool nextCharOnNewLine;
PRInt32 stateSave;
PRInt32 returnStateSave;
PRInt32 index;
PRBool forceQuirks;
PRUnichar additional;
PRInt32 entCol;
PRInt32 lo;
PRInt32 hi;
PRInt32 candidate;
PRInt32 strBufMark;
PRInt32 prevValue;
PRInt32 value;
PRBool seenDigits;
PRInt32 pos;
PRInt32 endPos;
PRUnichar* buf;
PRInt32 cstart;
nsString* publicId;
nsString* systemId;
jArray<PRUnichar,PRInt32> strBuf;
PRInt32 strBufLen;
jArray<PRUnichar,PRInt32> longStrBuf;
PRInt32 longStrBufLen;
nsHtml5HtmlAttributes* attributes;
jArray<PRUnichar,PRInt32> bmpChar;
jArray<PRUnichar,PRInt32> astralChar;
PRBool alreadyWarnedAboutPrivateUseCharacters;
nsHtml5ElementName* contentModelElement;
jArray<PRUnichar,PRInt32> contentModelElementNameAsArray;
PRBool endTag;
nsHtml5ElementName* tagName;
nsHtml5AttributeName* attributeName;
PRBool shouldAddAttributes;
PRBool html4;
PRBool alreadyComplainedAboutNonAscii;
PRBool metaBoundaryPassed;
nsIAtom* doctypeName;
nsString* publicIdentifier;
nsString* systemIdentifier;
PRInt32 mappingLangToXmlLang;
PRBool shouldSuspend;
PRBool confident;
public:
nsHtml5Tokenizer(nsHtml5TreeBuilder* tokenHandler, nsHtml5Parser* encodingDeclarationHandler);
void initLocation(nsString* newPublicId, nsString* newSystemId);
void destructor();
void setContentModelFlag(PRInt32 contentModelFlag, nsIAtom* contentModelElement);
void setContentModelFlag(PRInt32 contentModelFlag, nsHtml5ElementName* contentModelElement);
private:
void contentModelElementToArray();
public:
nsString* getPublicId();
nsString* getSystemId();
PRInt32 getLineNumber();
PRInt32 getColumnNumber();
void notifyAboutMetaBoundary();
nsHtml5HtmlAttributes* emptyAttributes();
private:
void detachStrBuf();
void detachLongStrBuf();
void clearStrBufAndAppendCurrentC(PRUnichar c);
void clearStrBufAndAppendForceWrite(PRUnichar c);
void clearStrBufForNextState();
void appendStrBuf(PRUnichar c);
void appendStrBufForceWrite(PRUnichar c);
nsString* strBufToString();
nsIAtom* strBufToLocal();
void emitStrBuf();
void clearLongStrBufForNextState();
void clearLongStrBuf();
void clearLongStrBufAndAppendCurrentC();
void clearLongStrBufAndAppendToComment(PRUnichar c);
void appendLongStrBuf(PRUnichar c);
void appendSecondHyphenToBogusComment();
void adjustDoubleHyphenAndAppendToLongStrBuf(PRUnichar c);
void appendLongStrBuf(jArray<PRUnichar,PRInt32> buffer, PRInt32 offset, PRInt32 length);
void appendLongStrBuf(jArray<PRUnichar,PRInt32> arr);
void appendStrBufToLongStrBuf();
nsString* longStrBufToString();
void emitComment(PRInt32 provisionalHyphens);
PRBool isPrivateUse(PRUnichar c);
PRBool isAstralPrivateUse(PRInt32 c);
PRBool isNonCharacter(PRInt32 c);
void flushChars();
void resetAttributes();
nsHtml5ElementName* strBufToElementNameString();
PRInt32 emitCurrentTagToken(PRBool selfClosing);
void attributeNameComplete();
void addAttributeWithoutValue();
void addAttributeWithValue();
public:
void start();
PRBool tokenizeBuffer(nsHtml5UTF16Buffer* buffer);
private:
void stateLoop(PRInt32 state, PRUnichar c, PRBool reconsume, PRInt32 returnState);
void rememberAmpersandLocation();
void bogusDoctype();
void bogusDoctypeWithoutQuirks();
void emitOrAppendStrBuf(PRInt32 returnState);
void handleNcrValue(PRInt32 returnState);
public:
void eof();
private:
PRUnichar read();
public:
void internalEncodingDeclaration(nsString* internalCharset);
private:
void emitOrAppend(jArray<PRUnichar,PRInt32> val, PRInt32 returnState);
void emitOrAppendOne(PRUnichar* val, PRInt32 returnState);
public:
void end();
void requestSuspension();
PRBool isAlreadyComplainedAboutNonAscii();
void becomeConfident();
PRBool isNextCharOnNewLine();
PRBool isPrevCR();
PRInt32 getLine();
PRInt32 getCol();
static void initializeStatics();
static void releaseStatics();
};
#ifdef nsHtml5Tokenizer_cpp__
PRUnichar nsHtml5Tokenizer::LT_GT[] = { '<', '>' };
PRUnichar nsHtml5Tokenizer::LT_SOLIDUS[] = { '<', '/' };
PRUnichar nsHtml5Tokenizer::RSQB_RSQB[] = { ']', ']' };
PRUnichar nsHtml5Tokenizer::REPLACEMENT_CHARACTER[] = { 0xfffd };
PRUnichar nsHtml5Tokenizer::LF[] = { '\n' };
PRUnichar nsHtml5Tokenizer::CDATA_LSQB[] = { 'C', 'D', 'A', 'T', 'A', '[' };
PRUnichar nsHtml5Tokenizer::OCTYPE[] = { 'o', 'c', 't', 'y', 'p', 'e' };
PRUnichar nsHtml5Tokenizer::UBLIC[] = { 'u', 'b', 'l', 'i', 'c' };
PRUnichar nsHtml5Tokenizer::YSTEM[] = { 'y', 's', 't', 'e', 'm' };
PRUnichar nsHtml5Tokenizer::TITLE_ARR_DATA[] = { 't', 'i', 't', 'l', 'e' };
jArray<PRUnichar,PRInt32> nsHtml5Tokenizer::TITLE_ARR = J_ARRAY_STATIC(PRUnichar, PRInt32, TITLE_ARR_DATA);
PRUnichar nsHtml5Tokenizer::SCRIPT_ARR_DATA[] = { 's', 'c', 'r', 'i', 'p', 't' };
jArray<PRUnichar,PRInt32> nsHtml5Tokenizer::SCRIPT_ARR = J_ARRAY_STATIC(PRUnichar, PRInt32, SCRIPT_ARR_DATA);
PRUnichar nsHtml5Tokenizer::STYLE_ARR_DATA[] = { 's', 't', 'y', 'l', 'e' };
jArray<PRUnichar,PRInt32> nsHtml5Tokenizer::STYLE_ARR = J_ARRAY_STATIC(PRUnichar, PRInt32, STYLE_ARR_DATA);
PRUnichar nsHtml5Tokenizer::PLAINTEXT_ARR_DATA[] = { 'p', 'l', 'a', 'i', 'n', 't', 'e', 'x', 't' };
jArray<PRUnichar,PRInt32> nsHtml5Tokenizer::PLAINTEXT_ARR = J_ARRAY_STATIC(PRUnichar, PRInt32, PLAINTEXT_ARR_DATA);
PRUnichar nsHtml5Tokenizer::XMP_ARR_DATA[] = { 'x', 'm', 'p' };
jArray<PRUnichar,PRInt32> nsHtml5Tokenizer::XMP_ARR = J_ARRAY_STATIC(PRUnichar, PRInt32, XMP_ARR_DATA);
PRUnichar nsHtml5Tokenizer::TEXTAREA_ARR_DATA[] = { 't', 'e', 'x', 't', 'a', 'r', 'e', 'a' };
jArray<PRUnichar,PRInt32> nsHtml5Tokenizer::TEXTAREA_ARR = J_ARRAY_STATIC(PRUnichar, PRInt32, TEXTAREA_ARR_DATA);
PRUnichar nsHtml5Tokenizer::IFRAME_ARR_DATA[] = { 'i', 'f', 'r', 'a', 'm', 'e' };
jArray<PRUnichar,PRInt32> nsHtml5Tokenizer::IFRAME_ARR = J_ARRAY_STATIC(PRUnichar, PRInt32, IFRAME_ARR_DATA);
PRUnichar nsHtml5Tokenizer::NOEMBED_ARR_DATA[] = { 'n', 'o', 'e', 'm', 'b', 'e', 'd' };
jArray<PRUnichar,PRInt32> nsHtml5Tokenizer::NOEMBED_ARR = J_ARRAY_STATIC(PRUnichar, PRInt32, NOEMBED_ARR_DATA);
PRUnichar nsHtml5Tokenizer::NOSCRIPT_ARR_DATA[] = { 'n', 'o', 's', 'c', 'r', 'i', 'p', 't' };
jArray<PRUnichar,PRInt32> nsHtml5Tokenizer::NOSCRIPT_ARR = J_ARRAY_STATIC(PRUnichar, PRInt32, NOSCRIPT_ARR_DATA);
PRUnichar nsHtml5Tokenizer::NOFRAMES_ARR_DATA[] = { 'n', 'o', 'f', 'r', 'a', 'm', 'e', 's' };
jArray<PRUnichar,PRInt32> nsHtml5Tokenizer::NOFRAMES_ARR = J_ARRAY_STATIC(PRUnichar, PRInt32, NOFRAMES_ARR_DATA);
#endif
#define NS_HTML5TOKENIZER_DATA 0
#define NS_HTML5TOKENIZER_RCDATA 1
#define NS_HTML5TOKENIZER_CDATA 2
#define NS_HTML5TOKENIZER_PLAINTEXT 3
#define NS_HTML5TOKENIZER_TAG_OPEN 49
#define NS_HTML5TOKENIZER_CLOSE_TAG_OPEN_PCDATA 50
#define NS_HTML5TOKENIZER_TAG_NAME 58
#define NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_NAME 4
#define NS_HTML5TOKENIZER_ATTRIBUTE_NAME 5
#define NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_NAME 6
#define NS_HTML5TOKENIZER_BEFORE_ATTRIBUTE_VALUE 7
#define NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_DOUBLE_QUOTED 8
#define NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_SINGLE_QUOTED 9
#define NS_HTML5TOKENIZER_ATTRIBUTE_VALUE_UNQUOTED 10
#define NS_HTML5TOKENIZER_AFTER_ATTRIBUTE_VALUE_QUOTED 11
#define NS_HTML5TOKENIZER_BOGUS_COMMENT 12
#define NS_HTML5TOKENIZER_MARKUP_DECLARATION_OPEN 13
#define NS_HTML5TOKENIZER_DOCTYPE 14
#define NS_HTML5TOKENIZER_BEFORE_DOCTYPE_NAME 15
#define NS_HTML5TOKENIZER_DOCTYPE_NAME 16
#define NS_HTML5TOKENIZER_AFTER_DOCTYPE_NAME 17
#define NS_HTML5TOKENIZER_BEFORE_DOCTYPE_PUBLIC_IDENTIFIER 18
#define NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED 19
#define NS_HTML5TOKENIZER_DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED 20
#define NS_HTML5TOKENIZER_AFTER_DOCTYPE_PUBLIC_IDENTIFIER 21
#define NS_HTML5TOKENIZER_BEFORE_DOCTYPE_SYSTEM_IDENTIFIER 22
#define NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED 23
#define NS_HTML5TOKENIZER_DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED 24
#define NS_HTML5TOKENIZER_AFTER_DOCTYPE_SYSTEM_IDENTIFIER 25
#define NS_HTML5TOKENIZER_BOGUS_DOCTYPE 26
#define NS_HTML5TOKENIZER_COMMENT_START 27
#define NS_HTML5TOKENIZER_COMMENT_START_DASH 28
#define NS_HTML5TOKENIZER_COMMENT 29
#define NS_HTML5TOKENIZER_COMMENT_END_DASH 30
#define NS_HTML5TOKENIZER_COMMENT_END 31
#define NS_HTML5TOKENIZER_CLOSE_TAG_OPEN_NOT_PCDATA 32
#define NS_HTML5TOKENIZER_MARKUP_DECLARATION_HYPHEN 33
#define NS_HTML5TOKENIZER_MARKUP_DECLARATION_OCTYPE 34
#define NS_HTML5TOKENIZER_DOCTYPE_UBLIC 35
#define NS_HTML5TOKENIZER_DOCTYPE_YSTEM 36
#define NS_HTML5TOKENIZER_CONSUME_CHARACTER_REFERENCE 37
#define NS_HTML5TOKENIZER_CONSUME_NCR 38
#define NS_HTML5TOKENIZER_CHARACTER_REFERENCE_LOOP 39
#define NS_HTML5TOKENIZER_HEX_NCR_LOOP 41
#define NS_HTML5TOKENIZER_DECIMAL_NRC_LOOP 42
#define NS_HTML5TOKENIZER_HANDLE_NCR_VALUE 43
#define NS_HTML5TOKENIZER_SELF_CLOSING_START_TAG 44
#define NS_HTML5TOKENIZER_CDATA_START 45
#define NS_HTML5TOKENIZER_CDATA_SECTION 46
#define NS_HTML5TOKENIZER_CDATA_RSQB 47
#define NS_HTML5TOKENIZER_CDATA_RSQB_RSQB 48
#define NS_HTML5TOKENIZER_TAG_OPEN_NON_PCDATA 51
#define NS_HTML5TOKENIZER_ESCAPE_EXCLAMATION 52
#define NS_HTML5TOKENIZER_ESCAPE_EXCLAMATION_HYPHEN 53
#define NS_HTML5TOKENIZER_ESCAPE 54
#define NS_HTML5TOKENIZER_ESCAPE_HYPHEN 55
#define NS_HTML5TOKENIZER_ESCAPE_HYPHEN_HYPHEN 56
#define NS_HTML5TOKENIZER_BOGUS_COMMENT_HYPHEN 57
#define NS_HTML5TOKENIZER_LEAD_OFFSET (0xD800 - (0x10000 >> 10))
#define NS_HTML5TOKENIZER_SURROGATE_OFFSET (0x10000 - (0xD800 << 10) - 0xDC00)
#define NS_HTML5TOKENIZER_BUFFER_GROW_BY 1024
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,305 @@
/*
* Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2007-2008 Mozilla Foundation
* Portions of comments Copyright 2004-2008 Apple Computer, Inc., Mozilla
* Foundation, and Opera Software ASA.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* 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
* DEALINGS IN THE SOFTWARE.
*/
/*
* THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
* Please edit TreeBuilder.java instead and regenerate.
*/
#ifndef nsHtml5TreeBuilder_h__
#define nsHtml5TreeBuilder_h__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsString.h"
#include "nsINameSpaceManager.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "jArray.h"
#include "nsHtml5DocumentMode.h"
#include "nsHtml5ArrayCopy.h"
#include "nsHtml5NamedCharacters.h"
#include "nsHtml5Parser.h"
#include "nsHtml5StringLiterals.h"
#include "nsHtml5Atoms.h"
class nsHtml5Parser;
class nsHtml5Tokenizer;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5StackNode;
class nsHtml5UTF16Buffer;
class nsHtml5Portability;
class nsHtml5TreeBuilder
{
private:
static jArray<PRUnichar,PRInt32> ISINDEX_PROMPT;
static jArray<nsString*,PRInt32> QUIRKY_PUBLIC_IDS;
nsHtml5StackNode* MARKER;
PRInt32 mode;
PRInt32 originalMode;
PRInt32 foreignFlag;
protected:
nsHtml5Tokenizer* tokenizer;
private:
nsHtml5Parser* documentModeHandler;
PRBool scriptingEnabled;
PRBool needToDropLF;
PRBool fragment;
nsIAtom* contextName;
PRInt32 contextNamespace;
jArray<nsHtml5StackNode*,PRInt32> stack;
PRInt32 currentPtr;
jArray<nsHtml5StackNode*,PRInt32> listOfActiveFormattingElements;
PRInt32 listPtr;
nsIContent* formPointer;
nsIContent* headPointer;
PRBool reportingDoctype;
public:
void startTokenization(nsHtml5Tokenizer* self);
void doctype(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier, PRBool forceQuirks);
void comment(PRUnichar* buf, PRInt32 start, PRInt32 length);
void characters(PRUnichar* buf, PRInt32 start, PRInt32 length);
void eof();
void endTokenization();
void startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, PRBool selfClosing);
static nsString* extractCharsetFromContent(nsString* attributeValue);
private:
void checkMetaCharset(nsHtml5HtmlAttributes* attributes);
public:
void endTag(nsHtml5ElementName* elementName);
private:
void endSelect();
PRInt32 findLastInTableScopeOrRootTbodyTheadTfoot();
PRInt32 findLast(nsIAtom* name);
PRInt32 findLastInTableScope(nsIAtom* name);
PRInt32 findLastInScope(nsIAtom* name);
PRInt32 findLastInScopeHn();
PRBool hasForeignInScope();
void generateImpliedEndTagsExceptFor(nsIAtom* name);
void generateImpliedEndTags();
PRBool isSecondOnStackBody();
void documentModeInternal(nsHtml5DocumentMode m, nsString* publicIdentifier, nsString* systemIdentifier, PRBool html4SpecificAdditionalErrorChecks);
PRBool isAlmostStandards(nsString* publicIdentifier, nsString* systemIdentifier);
PRBool isQuirky(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier, PRBool forceQuirks);
void closeTheCell(PRInt32 eltPos);
PRInt32 findLastInTableScopeTdTh();
void clearStackBackTo(PRInt32 eltPos);
void resetTheInsertionMode();
void implicitlyCloseP();
PRBool clearLastStackSlot();
PRBool clearLastListSlot();
void push(nsHtml5StackNode* node);
void append(nsHtml5StackNode* node);
void insertMarker();
void clearTheListOfActiveFormattingElementsUpToTheLastMarker();
PRBool isCurrent(nsIAtom* name);
void removeFromStack(PRInt32 pos);
void removeFromStack(nsHtml5StackNode* node);
void removeFromListOfActiveFormattingElements(PRInt32 pos);
void adoptionAgencyEndTag(nsIAtom* name);
void insertIntoStack(nsHtml5StackNode* node, PRInt32 position);
void insertIntoListOfActiveFormattingElements(nsHtml5StackNode* formattingClone, PRInt32 bookmark);
PRInt32 findInListOfActiveFormattingElements(nsHtml5StackNode* node);
PRInt32 findInListOfActiveFormattingElementsContainsBetweenEndAndLastMarker(nsIAtom* name);
PRInt32 findLastOrRoot(nsIAtom* name);
PRInt32 findLastOrRoot(PRInt32 group);
void addAttributesToBody(nsHtml5HtmlAttributes* attributes);
void pushHeadPointerOntoStack();
void reconstructTheActiveFormattingElements();
void insertIntoFosterParent(nsIContent* child);
PRBool isInStack(nsHtml5StackNode* node);
void pop();
void appendCharMayFoster(PRUnichar* buf, PRInt32 i);
PRBool isTainted();
void appendHtmlElementToDocumentAndPush(nsHtml5HtmlAttributes* attributes);
void appendHtmlElementToDocumentAndPush();
void appendToCurrentNodeAndPushHeadElement(nsHtml5HtmlAttributes* attributes);
void appendToCurrentNodeAndPushBodyElement(nsHtml5HtmlAttributes* attributes);
void appendToCurrentNodeAndPushBodyElement();
void appendToCurrentNodeAndPushFormElementMayFoster(nsHtml5HtmlAttributes* attributes);
void appendToCurrentNodeAndPushFormattingElementMayFoster(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendToCurrentNodeAndPushElement(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendToCurrentNodeAndPushElementMayFoster(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendToCurrentNodeAndPushElementMayFosterNoScoping(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendToCurrentNodeAndPushElementMayFosterCamelCase(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendToCurrentNodeAndPushElementMayFoster(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContent* form);
void appendVoidElementToCurrentMayFoster(PRInt32 ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent* form);
void appendVoidElementToCurrentMayFoster(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendVoidElementToCurrentMayFosterCamelCase(PRInt32 ns, nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendVoidElementToCurrent(PRInt32 ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent* form);
protected:
void accumulateCharacters(PRUnichar* buf, PRInt32 start, PRInt32 length);
void flushCharacters();
void requestSuspension();
nsIContent* createElement(PRInt32 ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes);
nsIContent* createElement(PRInt32 ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent* form);
nsIContent* createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* attributes);
void detachFromParent(nsIContent* element);
PRBool hasChildren(nsIContent* element);
nsIContent* shallowClone(nsIContent* element);
void appendElement(nsIContent* child, nsIContent* newParent);
void appendChildrenToNewParent(nsIContent* oldParent, nsIContent* newParent);
nsIContent* parentElementFor(nsIContent* child);
void insertBefore(nsIContent* child, nsIContent* sibling, nsIContent* parent);
void insertCharactersBefore(PRUnichar* buf, PRInt32 start, PRInt32 length, nsIContent* sibling, nsIContent* parent);
void appendCharacters(nsIContent* parent, PRUnichar* buf, PRInt32 start, PRInt32 length);
void appendComment(nsIContent* parent, PRUnichar* buf, PRInt32 start, PRInt32 length);
void appendCommentToDocument(PRUnichar* buf, PRInt32 start, PRInt32 length);
void addAttributesToElement(nsIContent* element, nsHtml5HtmlAttributes* attributes);
public:
void startCoalescing();
protected:
void start(PRBool fragment);
public:
void endCoalescing();
protected:
void end();
void appendDoctypeToDocument(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier);
void elementPushed(PRInt32 ns, nsIAtom* name, nsIContent* node);
void elementPopped(PRInt32 ns, nsIAtom* name, nsIContent* node);
nsIContent* currentNode();
public:
PRBool isScriptingEnabled();
void setScriptingEnabled(PRBool scriptingEnabled);
void setDocumentModeHandler(nsHtml5Parser* documentModeHandler);
void setReportingDoctype(PRBool reportingDoctype);
PRBool inForeign();
static void initializeStatics();
static void releaseStatics();
#include "nsHtml5TreeBuilderHSupplement.h"
};
#ifdef nsHtml5TreeBuilder_cpp__
jArray<nsString*,PRInt32> nsHtml5TreeBuilder::QUIRKY_PUBLIC_IDS = nsnull;
#endif
#define NS_HTML5TREE_BUILDER_OTHER 0
#define NS_HTML5TREE_BUILDER_A 1
#define NS_HTML5TREE_BUILDER_BASE 2
#define NS_HTML5TREE_BUILDER_BODY 3
#define NS_HTML5TREE_BUILDER_BR 4
#define NS_HTML5TREE_BUILDER_BUTTON 5
#define NS_HTML5TREE_BUILDER_CAPTION 6
#define NS_HTML5TREE_BUILDER_COL 7
#define NS_HTML5TREE_BUILDER_COLGROUP 8
#define NS_HTML5TREE_BUILDER_FORM 9
#define NS_HTML5TREE_BUILDER_FRAME 10
#define NS_HTML5TREE_BUILDER_FRAMESET 11
#define NS_HTML5TREE_BUILDER_IMAGE 12
#define NS_HTML5TREE_BUILDER_INPUT 13
#define NS_HTML5TREE_BUILDER_ISINDEX 14
#define NS_HTML5TREE_BUILDER_LI 15
#define NS_HTML5TREE_BUILDER_LINK 16
#define NS_HTML5TREE_BUILDER_MATH 17
#define NS_HTML5TREE_BUILDER_META 18
#define NS_HTML5TREE_BUILDER_SVG 19
#define NS_HTML5TREE_BUILDER_HEAD 20
#define NS_HTML5TREE_BUILDER_HR 22
#define NS_HTML5TREE_BUILDER_HTML 23
#define NS_HTML5TREE_BUILDER_NOBR 24
#define NS_HTML5TREE_BUILDER_NOFRAMES 25
#define NS_HTML5TREE_BUILDER_NOSCRIPT 26
#define NS_HTML5TREE_BUILDER_OPTGROUP 27
#define NS_HTML5TREE_BUILDER_OPTION 28
#define NS_HTML5TREE_BUILDER_P 29
#define NS_HTML5TREE_BUILDER_PLAINTEXT 30
#define NS_HTML5TREE_BUILDER_SCRIPT 31
#define NS_HTML5TREE_BUILDER_SELECT 32
#define NS_HTML5TREE_BUILDER_STYLE 33
#define NS_HTML5TREE_BUILDER_TABLE 34
#define NS_HTML5TREE_BUILDER_TEXTAREA 35
#define NS_HTML5TREE_BUILDER_TITLE 36
#define NS_HTML5TREE_BUILDER_TR 37
#define NS_HTML5TREE_BUILDER_XMP 38
#define NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT 39
#define NS_HTML5TREE_BUILDER_TD_OR_TH 40
#define NS_HTML5TREE_BUILDER_DD_OR_DT 41
#define NS_HTML5TREE_BUILDER_H1_OR_H2_OR_H3_OR_H4_OR_H5_OR_H6 42
#define NS_HTML5TREE_BUILDER_MARQUEE_OR_APPLET 43
#define NS_HTML5TREE_BUILDER_PRE_OR_LISTING 44
#define NS_HTML5TREE_BUILDER_B_OR_BIG_OR_EM_OR_FONT_OR_I_OR_S_OR_SMALL_OR_STRIKE_OR_STRONG_OR_TT_OR_U 45
#define NS_HTML5TREE_BUILDER_UL_OR_OL_OR_DL 46
#define NS_HTML5TREE_BUILDER_IFRAME 47
#define NS_HTML5TREE_BUILDER_EMBED_OR_IMG 48
#define NS_HTML5TREE_BUILDER_AREA_OR_BASEFONT_OR_BGSOUND_OR_SPACER_OR_WBR 49
#define NS_HTML5TREE_BUILDER_DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU 50
#define NS_HTML5TREE_BUILDER_ADDRESS_OR_DIR_OR_ARTICLE_OR_ASIDE_OR_DATAGRID_OR_DETAILS_OR_DIALOG_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_NAV_OR_SECTION 51
#define NS_HTML5TREE_BUILDER_CODE_OR_RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR 52
#define NS_HTML5TREE_BUILDER_RT_OR_RP 53
#define NS_HTML5TREE_BUILDER_COMMAND_OR_EVENT_SOURCE 54
#define NS_HTML5TREE_BUILDER_PARAM_OR_SOURCE 55
#define NS_HTML5TREE_BUILDER_MGLYPH_OR_MALIGNMARK 56
#define NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT 57
#define NS_HTML5TREE_BUILDER_ANNOTATION_XML 58
#define NS_HTML5TREE_BUILDER_FOREIGNOBJECT_OR_DESC 59
#define NS_HTML5TREE_BUILDER_NOEMBED 60
#define NS_HTML5TREE_BUILDER_FIELDSET 61
#define NS_HTML5TREE_BUILDER_OUTPUT_OR_LABEL 62
#define NS_HTML5TREE_BUILDER_OBJECT 63
#define NS_HTML5TREE_BUILDER_INITIAL 0
#define NS_HTML5TREE_BUILDER_BEFORE_HTML 1
#define NS_HTML5TREE_BUILDER_BEFORE_HEAD 2
#define NS_HTML5TREE_BUILDER_IN_HEAD 3
#define NS_HTML5TREE_BUILDER_IN_HEAD_NOSCRIPT 4
#define NS_HTML5TREE_BUILDER_AFTER_HEAD 5
#define NS_HTML5TREE_BUILDER_IN_BODY 6
#define NS_HTML5TREE_BUILDER_IN_TABLE 7
#define NS_HTML5TREE_BUILDER_IN_CAPTION 8
#define NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP 9
#define NS_HTML5TREE_BUILDER_IN_TABLE_BODY 10
#define NS_HTML5TREE_BUILDER_IN_ROW 11
#define NS_HTML5TREE_BUILDER_IN_CELL 12
#define NS_HTML5TREE_BUILDER_IN_SELECT 13
#define NS_HTML5TREE_BUILDER_IN_SELECT_IN_TABLE 14
#define NS_HTML5TREE_BUILDER_AFTER_BODY 15
#define NS_HTML5TREE_BUILDER_IN_FRAMESET 16
#define NS_HTML5TREE_BUILDER_AFTER_FRAMESET 17
#define NS_HTML5TREE_BUILDER_AFTER_AFTER_BODY 18
#define NS_HTML5TREE_BUILDER_AFTER_AFTER_FRAMESET 19
#define NS_HTML5TREE_BUILDER_IN_CDATA_RCDATA 20
#define NS_HTML5TREE_BUILDER_CHARSET_INITIAL 0
#define NS_HTML5TREE_BUILDER_CHARSET_C 1
#define NS_HTML5TREE_BUILDER_CHARSET_H 2
#define NS_HTML5TREE_BUILDER_CHARSET_A 3
#define NS_HTML5TREE_BUILDER_CHARSET_R 4
#define NS_HTML5TREE_BUILDER_CHARSET_S 5
#define NS_HTML5TREE_BUILDER_CHARSET_E 6
#define NS_HTML5TREE_BUILDER_CHARSET_T 7
#define NS_HTML5TREE_BUILDER_CHARSET_EQUALS 8
#define NS_HTML5TREE_BUILDER_CHARSET_SINGLE_QUOTED 9
#define NS_HTML5TREE_BUILDER_CHARSET_DOUBLE_QUOTED 10
#define NS_HTML5TREE_BUILDER_CHARSET_UNQUOTED 11
#define NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK PR_INT32_MAX
#define NS_HTML5TREE_BUILDER_IN_FOREIGN 0
#define NS_HTML5TREE_BUILDER_NOT_IN_FOREIGN 1
#endif

View File

@ -0,0 +1,482 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 sw=2 et tw=78: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
* Henri Sivonen <hsivonen@iki.fi>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsContentErrors.h"
#include "nsContentCreatorFunctions.h"
#include "nsIDOMDocumentType.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsEvent.h"
#include "nsGUIEvent.h"
#include "nsEventDispatcher.h"
#include "nsContentUtils.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIFormControl.h"
#include "nsNodeUtils.h"
#include "nsIStyleSheetLinkingElement.h"
// this really should be autogenerated...
jArray<PRUnichar,PRInt32> nsHtml5TreeBuilder::ISINDEX_PROMPT = jArray<PRUnichar,PRInt32>();
nsHtml5TreeBuilder::nsHtml5TreeBuilder(nsHtml5Parser* aParser)
: MARKER(new nsHtml5StackNode(0, nsHtml5ElementName::NULL_ELEMENT_NAME, nsnull)),
fragment(PR_FALSE),
mParser(aParser)
{
}
nsHtml5TreeBuilder::~nsHtml5TreeBuilder()
{
delete MARKER;
}
nsIContent*
nsHtml5TreeBuilder::createElement(PRInt32 aNamespace, nsIAtom* aName, nsHtml5HtmlAttributes* aAttributes)
{
// XXX recheck http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsDocument.cpp#6660
nsIContent* newContent;
nsCOMPtr<nsINodeInfo> nodeInfo = mParser->GetNodeInfoManager()->GetNodeInfo(aName, nsnull, aNamespace);
NS_ASSERTION(nodeInfo, "Got null nodeinfo.");
NS_NewElement(&newContent, nodeInfo->NamespaceID(), nodeInfo, PR_TRUE);
NS_ASSERTION(newContent, "Element creation created null pointer.");
PRInt32 len = aAttributes->getLength();
for (PRInt32 i = 0; i < len; ++i) {
newContent->SetAttr(aAttributes->getURI(i), aAttributes->getLocalName(i), aAttributes->getPrefix(i), *(aAttributes->getValue(i)), PR_FALSE);
// XXX what to do with nsresult?
}
if (aNamespace != kNameSpaceID_MathML && (aName == nsHtml5Atoms::style || (aNamespace == kNameSpaceID_XHTML && aName == nsHtml5Atoms::link))) {
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(newContent));
if (ssle) {
ssle->InitStyleLinkElement(PR_FALSE);
ssle->SetEnableUpdates(PR_FALSE);
#if 0
if (!aNodeInfo->Equals(nsGkAtoms::link, kNameSpaceID_XHTML)) {
ssle->SetLineNumber(aLineNumber);
}
#endif
}
}
return newContent;
}
nsIContent*
nsHtml5TreeBuilder::createElement(PRInt32 aNamespace, nsIAtom* aName, nsHtml5HtmlAttributes* aAttributes, nsIContent* aFormElement)
{
nsIContent* content = createElement(aNamespace, aName, aAttributes);
if (aFormElement) {
nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(content));
NS_ASSERTION(formControl, "Form-associated element did not implement nsIFormControl.");
nsCOMPtr<nsIDOMHTMLFormElement> formElement(do_QueryInterface(aFormElement));
NS_ASSERTION(formElement, "The form element doesn't implement nsIDOMHTMLFormElement.");
if (formControl) { // avoid crashing on <output>
formControl->SetForm(formElement);
}
}
return content;
}
nsIContent*
nsHtml5TreeBuilder::createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* aAttributes)
{
nsIContent* content = createElement(kNameSpaceID_XHTML, nsHtml5Atoms::html, aAttributes);
nsIDocument* doc = mParser->GetDocument();
PRUint32 childCount = doc->GetChildCount();
doc->AppendChildTo(content, PR_FALSE);
// XXX nsresult
nsNodeUtils::ContentInserted(doc, content, childCount);
return content;
}
void
nsHtml5TreeBuilder::detachFromParent(nsIContent* aElement)
{
Flush();
nsIContent* parent = aElement->GetParent();
if (parent) {
PRUint32 pos = parent->IndexOf(aElement);
NS_ASSERTION((pos >= 0), "Element not found as child of its parent");
parent->RemoveChildAt(pos, PR_FALSE);
// XXX nsresult
nsNodeUtils::ContentRemoved(parent, aElement, pos);
}
}
PRBool
nsHtml5TreeBuilder::hasChildren(nsIContent* aElement)
{
Flush();
return !!(aElement->GetChildCount());
}
nsIContent*
nsHtml5TreeBuilder::shallowClone(nsIContent* aElement)
{
nsINode* clone;
aElement->Clone(aElement->NodeInfo(), &clone);
// XXX nsresult
return static_cast<nsIContent*>(clone);
}
void
nsHtml5TreeBuilder::appendElement(nsIContent* aChild, nsIContent* aParent)
{
PRUint32 childCount = aParent->GetChildCount();
aParent->AppendChildTo(aChild, PR_FALSE);
// XXX nsresult
mParser->NotifyAppend(aParent, childCount);
}
void
nsHtml5TreeBuilder::appendChildrenToNewParent(nsIContent* aOldParent, nsIContent* aNewParent)
{
Flush();
while (aOldParent->GetChildCount()) {
nsCOMPtr<nsIContent> child = aOldParent->GetChildAt(0);
aOldParent->RemoveChildAt(0, PR_FALSE);
nsNodeUtils::ContentRemoved(aOldParent, child, 0);
PRUint32 childCount = aNewParent->GetChildCount();
aNewParent->AppendChildTo(child, PR_FALSE);
mParser->NotifyAppend(aNewParent, childCount);
}
}
nsIContent*
nsHtml5TreeBuilder::parentElementFor(nsIContent* aElement)
{
Flush();
return aElement->GetParent();
}
void
nsHtml5TreeBuilder::insertBefore(nsIContent* aNewChild, nsIContent* aReferenceSibling, nsIContent* aParent)
{
PRUint32 pos = aParent->IndexOf(aReferenceSibling);
aParent->InsertChildAt(aNewChild, pos, PR_FALSE);
// XXX nsresult
nsNodeUtils::ContentInserted(aParent, aNewChild, pos);
}
void
nsHtml5TreeBuilder::insertCharactersBefore(PRUnichar* aBuffer, PRInt32 aStart, PRInt32 aLength, nsIContent* aReferenceSibling, nsIContent* aParent)
{
// XXX this should probably coalesce
nsCOMPtr<nsIContent> text;
NS_NewTextNode(getter_AddRefs(text), mParser->GetNodeInfoManager());
// XXX nsresult and comment null check?
text->SetText(aBuffer + aStart, aLength, PR_FALSE);
// XXX nsresult
PRUint32 pos = aParent->IndexOf(aReferenceSibling);
aParent->InsertChildAt(text, pos, PR_FALSE);
// XXX nsresult
nsNodeUtils::ContentInserted(aParent, text, pos);
}
void
nsHtml5TreeBuilder::appendCharacters(nsIContent* aParent, PRUnichar* aBuffer, PRInt32 aStart, PRInt32 aLength)
{
nsCOMPtr<nsIContent> text;
NS_NewTextNode(getter_AddRefs(text), mParser->GetNodeInfoManager());
// XXX nsresult and comment null check?
text->SetText(aBuffer + aStart, aLength, PR_FALSE);
// XXX nsresult
PRUint32 childCount = aParent->GetChildCount();
aParent->AppendChildTo(text, PR_FALSE);
// XXX nsresult
mParser->NotifyAppend(aParent, childCount);
}
void
nsHtml5TreeBuilder::appendComment(nsIContent* aParent, PRUnichar* aBuffer, PRInt32 aStart, PRInt32 aLength)
{
nsCOMPtr<nsIContent> comment;
NS_NewCommentNode(getter_AddRefs(comment), mParser->GetNodeInfoManager());
// XXX nsresult and comment null check?
comment->SetText(aBuffer + aStart, aLength, PR_FALSE);
// XXX nsresult
PRUint32 childCount = aParent->GetChildCount();
aParent->AppendChildTo(comment, PR_FALSE);
// XXX nsresult
mParser->NotifyAppend(aParent, childCount);
}
void
nsHtml5TreeBuilder::appendCommentToDocument(PRUnichar* aBuffer, PRInt32 aStart, PRInt32 aLength)
{
nsIDocument* doc = mParser->GetDocument();
nsCOMPtr<nsIContent> comment;
NS_NewCommentNode(getter_AddRefs(comment), mParser->GetNodeInfoManager());
// XXX nsresult and comment null check?
comment->SetText(aBuffer + aStart, aLength, PR_FALSE);
// XXX nsresult
PRUint32 childCount = doc->GetChildCount();
doc->AppendChildTo(comment, PR_FALSE);
// XXX nsresult
nsNodeUtils::ContentInserted(doc, comment, childCount);
}
void
nsHtml5TreeBuilder::addAttributesToElement(nsIContent* aElement, nsHtml5HtmlAttributes* aAttributes)
{
PRInt32 len = aAttributes->getLength();
for (PRInt32 i = 0; i < len; ++i) {
nsIAtom* localName = aAttributes->getLocalName(i);
PRInt32 nsuri = aAttributes->getURI(i);
if (!aElement->HasAttr(nsuri, localName)) {
aElement->SetAttr(nsuri, localName, aAttributes->getPrefix(i), *(aAttributes->getValue(i)), PR_TRUE);
// XXX should not fire mutation event here
}
}
}
void
nsHtml5TreeBuilder::startCoalescing()
{
mCharBufferFillLength = 0;
mCharBufferAllocLength = 1024;
mCharBuffer = new PRUnichar[mCharBufferAllocLength];
}
void
nsHtml5TreeBuilder::endCoalescing()
{
delete[] mCharBuffer;
}
void
nsHtml5TreeBuilder::start(PRBool fragment)
{
mHasProcessedBase = PR_FALSE;
mParser->WillBuildModelImpl();
mParser->GetDocument()->BeginLoad(); // XXX fragment?
}
void
nsHtml5TreeBuilder::end()
{
}
void
nsHtml5TreeBuilder::appendDoctypeToDocument(nsIAtom* aName, nsString* aPublicId, nsString* aSystemId)
{
// Adapted from nsXMLContentSink
// Create a new doctype node
nsCOMPtr<nsIDOMDocumentType> docType;
nsAutoString voidString;
voidString.SetIsVoid(PR_TRUE);
NS_NewDOMDocumentType(getter_AddRefs(docType), mParser->GetNodeInfoManager(), nsnull,
aName, nsnull, nsnull, *aPublicId, *aSystemId,
voidString);
// if (NS_FAILED(rv) || !docType) {
// return rv;
// }
nsCOMPtr<nsIContent> content = do_QueryInterface(docType);
NS_ASSERTION(content, "doctype isn't content?");
mParser->GetDocument()->AppendChildTo(content, PR_TRUE);
// XXX rv
// nsXMLContentSink can flush here, but what's the point?
// It can also interrupt here, but we can't.
}
void
nsHtml5TreeBuilder::elementPushed(PRInt32 aNamespace, nsIAtom* aName, nsIContent* aElement)
{
NS_ASSERTION((aNamespace == kNameSpaceID_XHTML || aNamespace == kNameSpaceID_SVG || aNamespace == kNameSpaceID_MathML), "Element isn't HTML, SVG or MathML!");
NS_ASSERTION(aName, "Element doesn't have local name!");
NS_ASSERTION(aElement, "No element!");
// Give autoloading links a chance to fire
if (aNamespace == kNameSpaceID_XHTML) {
if (aName == nsHtml5Atoms::body) {
mParser->StartLayout(PR_FALSE);
}
} else {
nsIDocShell* docShell = mParser->GetDocShell();
if (docShell) {
nsresult rv = aElement->MaybeTriggerAutoLink(docShell);
if (rv == NS_XML_AUTOLINK_REPLACE ||
rv == NS_XML_AUTOLINK_UNDEFINED) {
// If we do not terminate the parse, we just keep generating link trigger
// events. We want to parse only up to the first replace link, and stop.
mParser->Terminate();
}
}
}
MaybeFlushAndMaybeSuspend();
}
void
nsHtml5TreeBuilder::elementPopped(PRInt32 aNamespace, nsIAtom* aName, nsIContent* aElement)
{
NS_ASSERTION((aNamespace == kNameSpaceID_XHTML || aNamespace == kNameSpaceID_SVG || aNamespace == kNameSpaceID_MathML), "Element isn't HTML, SVG or MathML!");
NS_ASSERTION(aName, "Element doesn't have local name!");
NS_ASSERTION(aElement, "No element!");
MaybeFlushAndMaybeSuspend();
if (aNamespace == kNameSpaceID_MathML) {
return;
}
// we now have only SVG and HTML
if (aName == nsHtml5Atoms::script) {
// mConstrainSize = PR_TRUE; // XXX what is this?
requestSuspension();
mParser->SetScriptElement(aElement);
return;
}
if (aName == nsHtml5Atoms::title) {
Flush();
aElement->DoneAddingChildren(PR_TRUE);
return;
}
if (aName == nsHtml5Atoms::style || (aNamespace == kNameSpaceID_XHTML && aName == nsHtml5Atoms::link)) {
mParser->UpdateStyleSheet(aElement);
return;
}
if (aNamespace == kNameSpaceID_SVG) {
#ifdef MOZ_SVG
if (aElement->HasAttr(kNameSpaceID_None, nsHtml5Atoms::onload)) {
Flush();
nsEvent event(PR_TRUE, NS_SVG_LOAD);
event.eventStructType = NS_SVG_EVENT;
event.flags |= NS_EVENT_FLAG_CANT_BUBBLE;
// Do we care about forcing presshell creation if it hasn't happened yet?
// That is, should this code flush or something? Does it really matter?
// For that matter, do we really want to try getting the prescontext? Does
// this event ever want one?
nsRefPtr<nsPresContext> ctx;
nsCOMPtr<nsIPresShell> shell = mParser->GetDocument()->GetPrimaryShell();
if (shell) {
ctx = shell->GetPresContext();
}
nsEventDispatcher::Dispatch(aElement, ctx, &event);
}
#endif
return;
}
// we now have only HTML
// Some HTML nodes need DoneAddingChildren() called to initialize
// properly (eg form state restoration).
if (aName == nsHtml5Atoms::select ||
aName == nsHtml5Atoms::textarea ||
#ifdef MOZ_MEDIA
aName == nsHtml5Atoms::video ||
aName == nsHtml5Atoms::audio ||
#endif
aName == nsHtml5Atoms::object ||
aName == nsHtml5Atoms::applet) {
Flush();
aElement->DoneAddingChildren(PR_TRUE);
return;
}
if (aName == nsHtml5Atoms::base && !mHasProcessedBase) {
// The first base wins
mParser->ProcessBASETag(aElement);
// result?
mHasProcessedBase = PR_TRUE;
return;
}
if (aName == nsHtml5Atoms::meta) {
/* Call the nsContentSink method. */
// mParser->ProcessMETATag(aElement);
// XXX nsresult
return;
}
return;
}
void
nsHtml5TreeBuilder::accumulateCharacters(PRUnichar* aBuf, PRInt32 aStart, PRInt32 aLength)
{
PRInt32 newFillLen = mCharBufferFillLength + aLength;
if (newFillLen > mCharBufferAllocLength) {
PRInt32 newAllocLength = newFillLen + (newFillLen >> 1);
PRUnichar* newBuf = new PRUnichar[newAllocLength];
memcpy(newBuf, mCharBuffer, sizeof(PRUnichar) * mCharBufferFillLength);
delete[] mCharBuffer;
mCharBuffer = newBuf;
mCharBufferAllocLength = newAllocLength;
}
memcpy(mCharBuffer + mCharBufferFillLength, aBuf + aStart, sizeof(PRUnichar) * aLength);
mCharBufferFillLength = newFillLen;
}
void
nsHtml5TreeBuilder::flushCharacters()
{
if (mCharBufferFillLength > 0) {
appendCharacters(currentNode(), mCharBuffer, 0,
mCharBufferFillLength);
mCharBufferFillLength = 0;
}
}
void
nsHtml5TreeBuilder::MaybeFlushAndMaybeSuspend()
{
if (mParser->DidProcessATokenImpl() == NS_ERROR_HTMLPARSER_INTERRUPTED) {
mParser->Suspend();
requestSuspension();
}
if (mParser->IsTimeToNotify()) {
Flush();
}
}
void
nsHtml5TreeBuilder::Flush()
{
}

View File

@ -0,0 +1,11 @@
private:
nsHtml5Parser* mParser; // weak ref
PRUnichar* mCharBuffer;
PRInt32 mCharBufferFillLength;
PRInt32 mCharBufferAllocLength;
PRBool mHasProcessedBase;
void MaybeFlushAndMaybeSuspend();
public:
nsHtml5TreeBuilder(nsHtml5Parser* aParser);
~nsHtml5TreeBuilder();
void Flush();

View File

@ -0,0 +1,118 @@
/*
* Copyright (c) 2008 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* 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
* DEALINGS IN THE SOFTWARE.
*/
/*
* THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
* Please edit UTF16Buffer.java instead and regenerate.
*/
#define nsHtml5UTF16Buffer_cpp__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsString.h"
#include "nsINameSpaceManager.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "jArray.h"
#include "nsHtml5DocumentMode.h"
#include "nsHtml5ArrayCopy.h"
#include "nsHtml5NamedCharacters.h"
#include "nsHtml5Parser.h"
#include "nsHtml5StringLiterals.h"
#include "nsHtml5Atoms.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
#include "nsHtml5AttributeName.h"
#include "nsHtml5ElementName.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5StackNode.h"
#include "nsHtml5Portability.h"
#include "nsHtml5UTF16Buffer.h"
nsHtml5UTF16Buffer::nsHtml5UTF16Buffer(PRUnichar* buffer, PRInt32 start, PRInt32 end)
: buffer(buffer),
start(start),
end(end)
{
}
PRInt32
nsHtml5UTF16Buffer::getStart()
{
return start;
}
void
nsHtml5UTF16Buffer::setStart(PRInt32 start)
{
this->start = start;
}
PRUnichar*
nsHtml5UTF16Buffer::getBuffer()
{
return buffer;
}
PRInt32
nsHtml5UTF16Buffer::getEnd()
{
return end;
}
PRBool
nsHtml5UTF16Buffer::hasMore()
{
return start < end;
}
void
nsHtml5UTF16Buffer::adjust(PRBool lastWasCR)
{
if (lastWasCR && buffer[start] == '\n') {
start++;
}
}
void
nsHtml5UTF16Buffer::setEnd(PRInt32 end)
{
this->end = end;
}
void
nsHtml5UTF16Buffer::initializeStatics()
{
}
void
nsHtml5UTF16Buffer::releaseStatics()
{
}
#include "nsHtml5UTF16BufferCppSupplement.h"

View File

@ -0,0 +1,82 @@
/*
* Copyright (c) 2008 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* 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
* DEALINGS IN THE SOFTWARE.
*/
/*
* THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
* Please edit UTF16Buffer.java instead and regenerate.
*/
#ifndef nsHtml5UTF16Buffer_h__
#define nsHtml5UTF16Buffer_h__
#include "prtypes.h"
#include "nsIAtom.h"
#include "nsString.h"
#include "nsINameSpaceManager.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "jArray.h"
#include "nsHtml5DocumentMode.h"
#include "nsHtml5ArrayCopy.h"
#include "nsHtml5NamedCharacters.h"
#include "nsHtml5Parser.h"
#include "nsHtml5StringLiterals.h"
#include "nsHtml5Atoms.h"
class nsHtml5Parser;
class nsHtml5Tokenizer;
class nsHtml5TreeBuilder;
class nsHtml5AttributeName;
class nsHtml5ElementName;
class nsHtml5HtmlAttributes;
class nsHtml5StackNode;
class nsHtml5Portability;
class nsHtml5UTF16Buffer
{
private:
PRUnichar* buffer;
PRInt32 start;
PRInt32 end;
public:
nsHtml5UTF16Buffer(PRUnichar* buffer, PRInt32 start, PRInt32 end);
PRInt32 getStart();
void setStart(PRInt32 start);
PRUnichar* getBuffer();
PRInt32 getEnd();
PRBool hasMore();
void adjust(PRBool lastWasCR);
void setEnd(PRInt32 end);
static void initializeStatics();
static void releaseStatics();
#include "nsHtml5UTF16BufferHSupplement.h"
};
#ifdef nsHtml5UTF16Buffer_cpp__
#endif
#endif

View File

@ -0,0 +1,59 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is HTML Parser C++ Translator code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Henri Sivonen <hsivonen@iki.fi>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
nsHtml5UTF16Buffer::nsHtml5UTF16Buffer(PRInt32 size)
: buffer(new PRUnichar[size]),
start(0),
end(0),
next(nsnull),
key(nsnull)
{
}
nsHtml5UTF16Buffer::nsHtml5UTF16Buffer(void* key)
: buffer(nsnull),
start(0),
end(0),
next(nsnull),
key(key)
{
}
nsHtml5UTF16Buffer::~nsHtml5UTF16Buffer()
{
delete[] buffer;
}

View File

@ -0,0 +1,43 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is HTML Parser C++ Translator code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Henri Sivonen <hsivonen@iki.fi>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
public:
nsHtml5UTF16Buffer(PRInt32 size);
nsHtml5UTF16Buffer(void* key);
~nsHtml5UTF16Buffer();
nsHtml5UTF16Buffer* next;
void* key;

View File

@ -1365,33 +1365,6 @@ nsXMLContentSink::ParsePIData(const nsString &aData, nsString &aHref,
aIsAlternate = alternate.EqualsLiteral("yes");
}
/*
* Extends nsContentSink::ProcessMETATag to grab the 'viewport' meta tag. This
* information is ignored by the generic content sink because it only stores
* http-equiv meta tags. We need it in the XMLContentSink for XHTML documents.
*
* Initially implemented for bug #436083
*/
nsresult
nsXMLContentSink::ProcessMETATag(nsIContent *aContent) {
/* Call the superclass method. */
nsContentSink::ProcessMETATag(aContent);
nsresult rv = NS_OK;
/* Look for the viewport meta tag. If we find it, process it and put the
* data into the document header. */
if (aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
nsGkAtoms::viewport, eIgnoreCase)) {
nsAutoString value;
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::content, value);
rv = nsContentUtils::ProcessViewportInfo(mDocument, value);
}
return rv;
}
NS_IMETHODIMP
nsXMLContentSink::HandleXMLDeclaration(const PRUnichar *aVersion,
const PRUnichar *aEncoding,

View File

@ -111,8 +111,6 @@ public:
nsString &aTitle, nsString &aMedia,
PRBool &aIsAlternate);
virtual nsresult ProcessMETATag(nsIContent* aContent);
protected:
// Start layout. If aIgnorePendingSheets is true, this will happen even if
// we still have stylesheet loads pending. Otherwise, we'll wait until the

View File

@ -97,6 +97,7 @@ REQUIRES = xpcom \
uconv \
txtsvc \
thebes \
html5 \
$(NULL)
CPPSRCS = \
@ -123,6 +124,7 @@ SHARED_LIBRARY_LIBS = \
$(DEPTH)/content/events/src/$(LIB_PREFIX)gkconevents_s.$(LIB_SUFFIX) \
$(DEPTH)/content/html/content/src/$(LIB_PREFIX)gkconhtmlcon_s.$(LIB_SUFFIX) \
$(DEPTH)/content/html/document/src/$(LIB_PREFIX)gkconhtmldoc_s.$(LIB_SUFFIX) \
$(DEPTH)/content/html/parser/src/$(LIB_PREFIX)html5p.$(LIB_SUFFIX) \
$(DEPTH)/content/xml/content/src/$(LIB_PREFIX)gkconxmlcon_s.$(LIB_SUFFIX) \
$(DEPTH)/content/xml/document/src/$(LIB_PREFIX)gkconxmldoc_s.$(LIB_SUFFIX) \
$(DEPTH)/content/xslt/src/base/$(LIB_PREFIX)txbase_s.$(LIB_SUFFIX) \

View File

@ -83,6 +83,7 @@
#include "nsXMLHttpRequest.h"
#include "nsIFocusEventSuppressor.h"
#include "nsDOMThreadService.h"
#include "nsHtml5Module.h"
#ifdef MOZ_XUL
#include "nsXULPopupManager.h"
@ -262,6 +263,8 @@ nsLayoutStatics::Initialize()
}
#endif
nsHtml5Module::InitializeStatics();
return NS_OK;
}
@ -347,6 +350,8 @@ nsLayoutStatics::Shutdown()
#endif
nsXMLHttpRequest::ShutdownACCache();
nsHtml5Module::ReleaseStatics();
}
void