progress towards fixing 123041 - stop making copies of entities names and values as we retrieve them out of various entity tables

also, a few uses of NS_LITERAL_STRING, removal of long-since-unused nsHTMLContentSinkStream
r/sr=sfraser, sr=jag, r=harishd
This commit is contained in:
alecf%netscape.com 2002-02-12 21:17:53 +00:00
Родитель c01dc3e0c4
Коммит a25b33b1b3
36 изменённых файлов: 151 добавлений и 293 удалений

Просмотреть файл

@ -403,7 +403,7 @@ public:
SinkContext* mCurrentContext;
SinkContext* mHeadContext;
PRInt32 mNumOpenIFRAMES;
nsSupportsArray mScriptElements;
nsCOMPtr<nsISupportsArray> mScriptElements;
nsCOMPtr<nsIRequest> mDummyParserRequest;
nsCString mRef;
@ -701,7 +701,7 @@ HTMLContentSink::GetAttributeValueAt(const nsIParserNode& aNode,
PRInt32 aIndex)
{
// Copy value
const nsString& value = aNode.GetValueAt(aIndex);
const nsAString& value = aNode.GetValueAt(aIndex);
nsString::const_iterator iter, end_iter;
value.BeginReading(iter);
value.EndReading(end_iter);
@ -2448,6 +2448,9 @@ HTMLContentSink::Init(nsIDocument* aDoc,
nsresult rv;
rv = NS_NewISupportsArray(getter_AddRefs(mScriptElements));
if (NS_FAILED(rv)) return rv;
mDocument = aDoc;
NS_ADDREF(aDoc);
aDoc->AddObserver(this);
@ -4920,9 +4923,10 @@ HTMLContentSink::ScriptAvailable(nsresult aResult,
{
// Check if this is the element we were waiting for
PRUint32 count;
mScriptElements.Count(&count);
nsCOMPtr<nsISupports> sup(dont_AddRef(mScriptElements.ElementAt(count-1)));
nsCOMPtr<nsIDOMHTMLScriptElement> scriptElement(do_QueryInterface(sup));
mScriptElements->Count(&count);
nsCOMPtr<nsIDOMHTMLScriptElement> scriptElement =
do_QueryElementAt(mScriptElements, count-1);
if (aElement != scriptElement.get()) {
return NS_OK;
}
@ -4942,7 +4946,7 @@ HTMLContentSink::ScriptAvailable(nsresult aResult,
PreEvaluateScript();
}
else {
mScriptElements.RemoveElementAt(count-1);
mScriptElements->RemoveElementAt(count-1);
if(mParser && aWasPending){
// Loading external script failed!. So, resume
@ -4963,15 +4967,16 @@ HTMLContentSink::ScriptEvaluated(nsresult aResult,
{
// Check if this is the element we were waiting for
PRUint32 count;
mScriptElements.Count(&count);
nsCOMPtr<nsISupports> sup(dont_AddRef(mScriptElements.ElementAt(count-1)));
nsCOMPtr<nsIDOMHTMLScriptElement> scriptElement(do_QueryInterface(sup));
mScriptElements->Count(&count);
nsCOMPtr<nsIDOMHTMLScriptElement> scriptElement =
do_QueryElementAt(mScriptElements, count-1);
if (aElement != scriptElement.get()) {
return NS_OK;
}
// Pop the script element stack
mScriptElements.RemoveElementAt(count-1);
mScriptElements->RemoveElementAt(count-1);
if (NS_SUCCEEDED(aResult)) {
PostEvaluateScript();
@ -5065,7 +5070,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
mNeedToBlockParser = PR_TRUE;
nsCOMPtr<nsIDOMHTMLScriptElement> scriptElement(do_QueryInterface(element));
mScriptElements.AppendElement(scriptElement);
mScriptElements->AppendElement(scriptElement);
}
// Insert the child into the content tree. This will evaluate the

Просмотреть файл

@ -153,11 +153,6 @@ const PRInt32 kBackward = 1;
//#define DEBUG_charset
//#define rickgdebug 1
#ifdef rickgdebug
#include "nsHTMLContentSinkStream.h"
#endif
#define ID_NOT_IN_DOCUMENT ((nsIContent *)1)
static NS_DEFINE_CID(kCookieServiceCID, NS_COOKIESERVICE_CID);
@ -322,9 +317,9 @@ nsHTMLDocument::nsHTMLDocument()
NS_GET_IID(nsIRDFService),
(nsISupports**) &gRDF);
//nsCOMPtr<nsIRDFService> gRDF(do_GetService(kRDFServiceCID, &rv));
//nsCOMPtr<nsIRDFService> gRDF(do_GetService(kRDFServiceCID,
//&rv));
}
mDomainWasSet = PR_FALSE; // Bug 13871: Frameset spoofing
}
@ -358,7 +353,7 @@ nsHTMLDocument::~nsHTMLDocument()
mReferrer = nsnull;
}
NS_IF_RELEASE(mParser);
mImageMaps.Clear();
mImageMaps->Clear();
NS_IF_RELEASE(mForms);
if (mCSSLoader) {
mCSSLoader->DropDocumentReference(); // release weak ref
@ -394,6 +389,9 @@ nsHTMLDocument::Init()
nsresult rv = nsDocument::Init();
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_NewISupportsArray(getter_AddRefs(mImageMaps));
NS_ENSURE_SUCCESS(rv, rv);
static PLDHashTableOps hash_table_ops =
{
PL_DHashAllocTable,
@ -460,7 +458,7 @@ nsHTMLDocument::BaseResetToURI(nsIURI *aURL)
mBodyContent = nsnull;
mImageMaps.Clear();
mImageMaps->Clear();
NS_IF_RELEASE(mForms);
if (aURL) {
@ -1084,7 +1082,7 @@ nsHTMLDocument::AddImageMap(nsIDOMHTMLMapElement* aMap)
if (nsnull == aMap) {
return NS_ERROR_NULL_POINTER;
}
if (mImageMaps.AppendElement(aMap)) {
if (mImageMaps->AppendElement(aMap)) {
return NS_OK;
}
return NS_ERROR_OUT_OF_MEMORY;
@ -1097,7 +1095,7 @@ nsHTMLDocument::RemoveImageMap(nsIDOMHTMLMapElement* aMap)
if (nsnull == aMap) {
return NS_ERROR_NULL_POINTER;
}
mImageMaps.RemoveElement(aMap, 0);
mImageMaps->RemoveElement(aMap);
return NS_OK;
}
@ -1112,10 +1110,10 @@ nsHTMLDocument::GetImageMap(const nsString& aMapName,
nsAutoString name;
PRUint32 i, n;
mImageMaps.Count(&n);
mImageMaps->Count(&n);
for (i = 0; i < n; i++) {
nsCOMPtr<nsIDOMHTMLMapElement> map;
mImageMaps.QueryElementAt(i, NS_GET_IID(nsIDOMHTMLMapElement), getter_AddRefs(map));
mImageMaps->QueryElementAt(i, NS_GET_IID(nsIDOMHTMLMapElement), getter_AddRefs(map));
if (map && NS_SUCCEEDED(map->GetName(name))) {
if (name.EqualsIgnoreCase(aMapName)) {
*aResult = map;

Просмотреть файл

@ -228,7 +228,7 @@ protected:
nsString* mLastModified;
nsString* mReferrer;
nsDTDMode mDTDMode;
nsSupportsArray mImageMaps;
nsCOMPtr<nsISupportsArray> mImageMaps;
nsContentList *mImages;
nsContentList *mApplets;

Просмотреть файл

@ -872,7 +872,7 @@ nsHTMLFragmentContentSink::GetAttributeValueAt(const nsIParserNode& aNode,
nsString& aResult)
{
// Copy value
const nsString& value = aNode.GetValueAt(aIndex);
const nsAString& value = aNode.GetValueAt(aIndex);
aResult.Truncate();
aResult.Append(value);

Просмотреть файл

@ -1667,7 +1667,7 @@ XULContentSinkImpl::AddAttributes(const PRUnichar** aAttributes,
nsAutoString extraWhiteSpace;
PRInt32 cnt = mContextStack.Depth();
while (--cnt >= 0)
extraWhiteSpace.Assign(NS_LITERAL_STRING(" "));
extraWhiteSpace.Append(NS_LITERAL_STRING(" "));
nsAutoString qnameC,valueC;
qnameC.Assign(aAttributes[0]);
valueC.Assign(aAttributes[1]);

Просмотреть файл

@ -5255,8 +5255,8 @@ nsXULDocument::PrepareToLoadPrototype(nsIURI* aURI, const char* aCommand,
parser->SetCommand(nsCRT::strcmp(aCommand, "view-source") ? eViewNormal :
eViewSource);
nsAutoString charset(NS_LITERAL_STRING("UTF-8"));
parser->SetDocumentCharset(charset, kCharsetFromDocTypeDefault);
parser->SetDocumentCharset(NS_LITERAL_STRING("UTF-8"),
kCharsetFromDocTypeDefault);
parser->SetContentSink(sink); // grabs a reference to the parser
*aResult = parser;
@ -5275,7 +5275,10 @@ nsXULDocument::ApplyPersistentAttributes()
mApplyingPersistedAttrs = PR_TRUE;
nsSupportsArray elements;
nsresult rv;
nsCOMPtr<nsISupportsArray> elements;
rv = NS_NewISupportsArray(getter_AddRefs(elements));
if (NS_FAILED(rv)) return rv;
nsXPIDLCString docurl;
mDocumentURL->GetSpec(getter_Copies(docurl));
@ -5310,14 +5313,14 @@ nsXULDocument::ApplyPersistentAttributes()
nsXULContentUtils::MakeElementID(this, NS_ConvertASCIItoUCS2(uri), id);
// This will clear the array if there are no elements.
GetElementsForID(id, &elements);
GetElementsForID(id, elements);
PRUint32 cnt = 0;
elements.Count(&cnt);
elements->Count(&cnt);
if (! cnt)
continue;
ApplyPersistentAttributesToElements(resource, &elements);
ApplyPersistentAttributesToElements(resource, elements);
}
mApplyingPersistedAttrs = PR_FALSE;

Просмотреть файл

@ -366,7 +366,7 @@ class CAttributeToken: public CHTMLToken {
virtual const nsAReadableString& GetKey(void) {return mTextKey;}
virtual void SetKey(const nsAReadableString& aKey);
virtual void BindKey(nsScanner* aScanner, nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd);
virtual const nsString& GetValue(void) {return mTextValue;}
virtual const nsAString& GetValue(void) {return mTextValue;}
virtual void SanitizeKey();
#ifdef DEBUG
virtual void DebugDumpToken(nsOutputStream& out);

Просмотреть файл

@ -141,7 +141,7 @@ class nsIParserNode { // XXX Should be nsAParserNode
* @param anIndex is the index of the value you want
* @return string containing value.
*/
virtual const nsString& GetValueAt(PRUint32 anIndex) const =0;
virtual const nsAString& GetValueAt(PRUint32 anIndex) const =0;
/**
* NOTE: When the node is an entity, this will translate the entity

Просмотреть файл

@ -1007,20 +1007,20 @@ nsresult CNavDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
//we should only enable user-defined entities in debug builds...
PRInt32 theCount=aNode.GetAttributeCount();
const nsString* theNamePtr=0;
const nsString* theValuePtr=0;
const nsAString* theNamePtr=0;
const nsAString* theValuePtr=0;
if(theCount) {
PRInt32 theIndex=0;
for(theIndex=0;theIndex<theCount;theIndex++){
const nsAString& theKey = aNode.GetKeyAt(theIndex);
if(theKey.Equals(NS_LITERAL_STRING("ENTITY"), nsCaseInsensitiveStringComparator())) {
const nsString& theName=aNode.GetValueAt(theIndex);
const nsAString& theName=aNode.GetValueAt(theIndex);
theNamePtr=&theName;
}
else if(theKey.Equals(NS_LITERAL_STRING("VALUE"), nsCaseInsensitiveStringComparator())) {
//store the named enity with the context...
const nsString& theValue=aNode.GetValueAt(theIndex);
const nsAString& theValue=aNode.GetValueAt(theIndex);
theValuePtr=&theValue;
}
}
@ -1408,11 +1408,11 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsIParserNode
PRInt32 theCount=aNode.GetAttributeCount();
if(1<theCount){
nsAutoString theKey(aNode.GetKeyAt(0));
const nsAString& theKey = aNode.GetKeyAt(0);
if(theKey.Equals("NAME",IGNORE_CASE)) {
const nsString& theValue1=aNode.GetValueAt(0);
if(theValue1.Equals("\"CRC\"",IGNORE_CASE)) {
nsAutoString theKey2(aNode.GetKeyAt(1));
const nsAString& theKey2 = aNode.GetKeyAt(1);
if(theKey2.Equals("CONTENT",IGNORE_CASE)) {
const nsString& theValue2=aNode.GetValueAt(1);
PRInt32 err=0;
@ -2128,9 +2128,9 @@ nsresult CNavDTD::HandleEntityToken(CToken* aToken) {
nsresult result=NS_OK;
nsAutoString theStr(aToken->GetStringValue());
PRUnichar theChar=theStr.CharAt(0);
if((kHashsign!=theChar) && (-1==nsHTMLEntities::EntityToUnicode(theStr))){
const nsAString& theStr = aToken->GetStringValue();
if((kHashsign!=theStr.First()) && (-1==nsHTMLEntities::EntityToUnicode(theStr))){
CToken *theToken=0;
#ifdef DEBUG
//before we just toss this away as a bogus entity, let's check...

Просмотреть файл

@ -582,20 +582,20 @@ nsresult COtherDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
//we should only enable user-defined entities in debug builds...
PRInt32 theCount=aNode.GetAttributeCount();
const nsString* theNamePtr=0;
const nsString* theValuePtr=0;
const nsAString* theNamePtr=0;
const nsAString* theValuePtr=0;
if(theCount) {
PRInt32 theIndex=0;
for(theIndex=0;theIndex<theCount;theIndex++){
const nsAString& theKey = aNode.GetKeyAt(theIndex);
if(theKey.Equals(NS_LITERAL_STRING("ENTITY"), nsCaseInsensitiveStringComparator())) {
const nsString& theName=aNode.GetValueAt(theIndex);
const nsAString& theName=aNode.GetValueAt(theIndex);
theNamePtr=&theName;
}
else if(theKey.Equals(NS_LITERAL_STRING("VALUE"), nsCaseInsensitiveStringComparator())) {
//store the named enity with the context...
const nsString& theValue=aNode.GetValueAt(theIndex);
const nsAString& theValue=aNode.GetValueAt(theIndex);
theValuePtr=&theValue;
}
}

Просмотреть файл

@ -452,30 +452,36 @@ nsDTDContext::~nsDTDContext() {
#ifdef DEBUG
CNamedEntity* nsDTDContext::GetEntity(const nsString& aName)const {
PRInt32 theCount=mEntities.GetSize();
PRInt32 theIndex=0;
CNamedEntity* nsDTDContext::GetEntity(const nsAString& aName)const {
if (aName.Length() > 2) {
nsAString::const_iterator start, end;
aName.BeginReading(start);
aName.EndReading(end);
PRInt32 theLen=aName.Length();
PRUnichar theChar=aName.Last();
PRInt32 theLen=aName.Length();
PRUnichar theChar=aName.Last();
if(theLen>2) {
if(kSemicolon==theChar) {
theLen--;
// skip past leading and trailing quotes/etc
if(kQuote==*start) {
start++;
}
const PRUnichar *theBuf=aName.get();
if(kQuote==theBuf[0]) {
theBuf++;
theLen--;
}
if(kQuote==theChar) {
theLen--;
if(kSemicolon==theChar ||
kQuote == theChar) {
end--;
}
const nsAString& entityName = Substring(start, end);
PRInt32 theCount=mEntities.GetSize();
PRInt32 theIndex=0;
for(theIndex=0;theIndex<theCount;theIndex++) {
CNamedEntity *theResult=(CNamedEntity*)mEntities.ObjectAt(theIndex);
if(theResult && theResult->mName.EqualsWithConversion(theBuf,PR_TRUE,theLen)){
if(theResult &&
theResult->mName.Equals(entityName,
nsCaseInsensitiveStringComparator())) {
return theResult;
}
}
@ -483,7 +489,7 @@ CNamedEntity* nsDTDContext::GetEntity(const nsString& aName)const {
return 0;
}
CNamedEntity* nsDTDContext::RegisterEntity(const nsString& aName,const nsString& aValue) {
CNamedEntity* nsDTDContext::RegisterEntity(const nsAString& aName,const nsAString& aValue) {
CNamedEntity *theEntity=GetEntity(aName);
if(!GetEntity(aName)){
theEntity=new CNamedEntity(aName,aValue);
@ -843,7 +849,7 @@ PRInt32 nsDTDContext::IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsStr
for(theIndex=0;theIndex<theCount;theIndex++){
const nsAString& theKey=aNode.GetKeyAt(theIndex);
const nsString& theValue=aNode.GetValueAt(theIndex);
const nsAString& theValue=aNode.GetValueAt(theIndex);
if(theKey.Equals(NS_LITERAL_STRING("name"), nsCaseInsensitiveStringComparator())){
theEntity=GetEntity(theValue);
@ -857,9 +863,11 @@ PRInt32 nsDTDContext::IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsStr
theIncrValue=0;
}
else if(theKey.Equals(NS_LITERAL_STRING("format"), nsCaseInsensitiveStringComparator())){
PRUnichar theChar=theValue.CharAt(0);
nsAString::const_iterator start;
PRUnichar theChar=*theValue.BeginReading(start);
if('"'==theChar)
theChar=theValue.CharAt(1);
theChar=*(++start);
switch(theChar){
case 'A': case 'a': theNumFormat=CAbacus::eAlpha; break;
case 'B': case 'b': theNumFormat=CAbacus::eBinary; break;
@ -875,7 +883,7 @@ PRInt32 nsDTDContext::IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsStr
}
else if(theKey.Equals(NS_LITERAL_STRING("value"), nsCaseInsensitiveStringComparator())){
PRInt32 err=0;
theNewValue=theValue.ToInteger(&err);
theNewValue=atoi(NS_LossyConvertUCS2toASCII(theValue).get());
if(!err) {
theIncrValue=0;

Просмотреть файл

@ -234,7 +234,7 @@ public:
//used for named entities and counters (XXX debug only)
class CNamedEntity {
public:
CNamedEntity(const nsString& aName,const nsString& aValue) : mName(), mValue() {
CNamedEntity(const nsAString& aName,const nsAString& aValue) : mName(), mValue() {
PRUnichar theFirst=aName.First();
PRUnichar theLast=aName.Last();
PRInt32 theLen=aName.Length();
@ -389,8 +389,8 @@ public:
void AllocateCounters(void);
PRInt32 IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsString& aResult);
CNamedEntity* RegisterEntity(const nsString& aName,const nsString& aValue);
CNamedEntity* GetEntity(const nsString& aName)const;
CNamedEntity* RegisterEntity(const nsAString& aName,const nsAString& aValue);
CNamedEntity* GetEntity(const nsAString& aName) const;
#endif
};

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -576,7 +576,7 @@ nsLoggingSink::WriteAttributes(const nsIParserNode& aNode) {
char* key=nsnull;
char* value=nsnull;
const nsAReadableString& k = aNode.GetKeyAt(i);
const nsString& v = aNode.GetValueAt(i);
const nsAString& v = aNode.GetValueAt(i);
GetNewCString(k, &key);
if(key) {

Просмотреть файл

@ -300,7 +300,7 @@ const nsAReadableString& nsCParserNode::GetKeyAt(PRUint32 anIndex) const {
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text value
*/
const nsString& nsCParserNode::GetValueAt(PRUint32 anIndex) const {
const nsAString& nsCParserNode::GetValueAt(PRUint32 anIndex) const {
PRInt32 theCount = (mAttributes) ? mAttributes->GetSize() : 0;
NS_PRECONDITION(PRInt32(anIndex)<theCount, "Bad attr index");

Просмотреть файл

@ -214,7 +214,7 @@ class nsCParserNode : public nsIParserNode {
* @param anIndex is the index of the value you want
* @return string containing value.
*/
virtual const nsString& GetValueAt(PRUint32 anIndex) const;
virtual const nsAString& GetValueAt(PRUint32 anIndex) const;
/**
* NOTE: When the node is an entity, this will translate the entity

Просмотреть файл

@ -105,7 +105,7 @@ MOZ_DECL_CTOR_COUNTER(nsScanner)
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner::nsScanner(nsString& anHTMLString, const nsString& aCharset, PRInt32 aSource)
nsScanner::nsScanner(const nsAString& anHTMLString, const nsString& aCharset, PRInt32 aSource)
{
MOZ_COUNT_CTOR(nsScanner);
@ -163,7 +163,7 @@ nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& a
* @param aFilename --
* @return
*/
nsScanner::nsScanner(nsString& aFilename,nsInputStream& aStream,const nsString& aCharset, PRInt32 aSource) :
nsScanner::nsScanner(const nsAString& aFilename,nsInputStream& aStream,const nsString& aCharset, PRInt32 aSource) :
mFilename(aFilename)
{
MOZ_COUNT_CTOR(nsScanner);

Просмотреть файл

@ -94,7 +94,7 @@ class nsScanner {
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner(nsString& anHTMLString, const nsString& aCharset, PRInt32 aSource);
nsScanner(const nsAString& anHTMLString, const nsString& aCharset, PRInt32 aSource);
/**
* Use this constructor if you want i/o to be based on
@ -117,7 +117,7 @@ class nsScanner {
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner(nsString& aFilename, nsInputStream& aStream, const nsString& aCharset, PRInt32 aSource);
nsScanner(const nsAString& aFilename, nsInputStream& aStream, const nsString& aCharset, PRInt32 aSource);
~nsScanner();

Просмотреть файл

@ -882,7 +882,7 @@ nsresult CViewSourceHTML::WriteAttributes(PRInt32 attrCount) {
const nsAReadableString& theKey=theAttrToken->GetKey();
result=WriteTag(mKey,theKey,0,PR_FALSE);
const nsString& theValue=theAttrToken->GetValue();
const nsAString& theValue=theAttrToken->GetValue();
if((0<theValue.Length()) || (theAttrToken->mHasEqualWithoutValue)){
result=WriteTag(mValue,theValue,0,PR_FALSE);

Просмотреть файл

@ -1,82 +0,0 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..
REQUIRES = xpcom \
string \
htmlparser \
necko \
layout \
dom \
content \
$(NULL)
MAKE_OBJ_TYPE = EXE
PROGRAM = .\$(OBJDIR)\TestOutput.exe
BATCHSCRIPT = TestOutSinks.pl
OBJS = \
.\$(OBJDIR)\Convert.obj \
$(NULL)
TEST_FILES = \
plain.html \
plainwrap.out \
plainnowrap.out \
simple.html \
simplecopy.out \
simplefmt.out \
entityxif.xif \
entityxif.out \
mailquote.html \
mailquote.out \
xifstuff.xif \
xifstuff.out \
htmltable.html \
htmltable.out \
doctype.xif \
xifdtplain.out \
xifdthtml.out \
simplemail.html \
simplemail.out \
$(NULL)
LLIBS= \
$(DIST)\lib\xpcom.lib \
$(LIBNSPR) \
$(NULL)
LLFLAGS= -SUBSYSTEM:CONSOLE
include <$(DEPTH)\config\rules.mak>
# !ifdef MOZ_NO_DEBUG_RTL
# OS_CFLAGS = $(OS_CFLAGS) -DMOZ_NO_DEBUG_RTL
# !endif
libs:: $(PROGRAM)
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
$(MAKE_INSTALL) $(BATCHSCRIPT) $(DIST)\bin
$(MAKE_INSTALL) $(TEST_FILES) $(DIST)/bin/OutTestData
clobber::
rm -f $(OBJS) $(DIST)\bin\Convert.exe

Просмотреть файл

@ -366,7 +366,7 @@ class CAttributeToken: public CHTMLToken {
virtual const nsAReadableString& GetKey(void) {return mTextKey;}
virtual void SetKey(const nsAReadableString& aKey);
virtual void BindKey(nsScanner* aScanner, nsReadingIterator<PRUnichar>& aStart, nsReadingIterator<PRUnichar>& aEnd);
virtual const nsString& GetValue(void) {return mTextValue;}
virtual const nsAString& GetValue(void) {return mTextValue;}
virtual void SanitizeKey();
#ifdef DEBUG
virtual void DebugDumpToken(nsOutputStream& out);

Просмотреть файл

@ -141,7 +141,7 @@ class nsIParserNode { // XXX Should be nsAParserNode
* @param anIndex is the index of the value you want
* @return string containing value.
*/
virtual const nsString& GetValueAt(PRUint32 anIndex) const =0;
virtual const nsAString& GetValueAt(PRUint32 anIndex) const =0;
/**
* NOTE: When the node is an entity, this will translate the entity

Просмотреть файл

@ -1007,20 +1007,20 @@ nsresult CNavDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
//we should only enable user-defined entities in debug builds...
PRInt32 theCount=aNode.GetAttributeCount();
const nsString* theNamePtr=0;
const nsString* theValuePtr=0;
const nsAString* theNamePtr=0;
const nsAString* theValuePtr=0;
if(theCount) {
PRInt32 theIndex=0;
for(theIndex=0;theIndex<theCount;theIndex++){
const nsAString& theKey = aNode.GetKeyAt(theIndex);
if(theKey.Equals(NS_LITERAL_STRING("ENTITY"), nsCaseInsensitiveStringComparator())) {
const nsString& theName=aNode.GetValueAt(theIndex);
const nsAString& theName=aNode.GetValueAt(theIndex);
theNamePtr=&theName;
}
else if(theKey.Equals(NS_LITERAL_STRING("VALUE"), nsCaseInsensitiveStringComparator())) {
//store the named enity with the context...
const nsString& theValue=aNode.GetValueAt(theIndex);
const nsAString& theValue=aNode.GetValueAt(theIndex);
theValuePtr=&theValue;
}
}
@ -1408,11 +1408,11 @@ nsresult CNavDTD::WillHandleStartTag(CToken* aToken,eHTMLTags aTag,nsIParserNode
PRInt32 theCount=aNode.GetAttributeCount();
if(1<theCount){
nsAutoString theKey(aNode.GetKeyAt(0));
const nsAString& theKey = aNode.GetKeyAt(0);
if(theKey.Equals("NAME",IGNORE_CASE)) {
const nsString& theValue1=aNode.GetValueAt(0);
if(theValue1.Equals("\"CRC\"",IGNORE_CASE)) {
nsAutoString theKey2(aNode.GetKeyAt(1));
const nsAString& theKey2 = aNode.GetKeyAt(1);
if(theKey2.Equals("CONTENT",IGNORE_CASE)) {
const nsString& theValue2=aNode.GetValueAt(1);
PRInt32 err=0;
@ -2128,9 +2128,9 @@ nsresult CNavDTD::HandleEntityToken(CToken* aToken) {
nsresult result=NS_OK;
nsAutoString theStr(aToken->GetStringValue());
PRUnichar theChar=theStr.CharAt(0);
if((kHashsign!=theChar) && (-1==nsHTMLEntities::EntityToUnicode(theStr))){
const nsAString& theStr = aToken->GetStringValue();
if((kHashsign!=theStr.First()) && (-1==nsHTMLEntities::EntityToUnicode(theStr))){
CToken *theToken=0;
#ifdef DEBUG
//before we just toss this away as a bogus entity, let's check...

Просмотреть файл

@ -582,20 +582,20 @@ nsresult COtherDTD::DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag){
//we should only enable user-defined entities in debug builds...
PRInt32 theCount=aNode.GetAttributeCount();
const nsString* theNamePtr=0;
const nsString* theValuePtr=0;
const nsAString* theNamePtr=0;
const nsAString* theValuePtr=0;
if(theCount) {
PRInt32 theIndex=0;
for(theIndex=0;theIndex<theCount;theIndex++){
const nsAString& theKey = aNode.GetKeyAt(theIndex);
if(theKey.Equals(NS_LITERAL_STRING("ENTITY"), nsCaseInsensitiveStringComparator())) {
const nsString& theName=aNode.GetValueAt(theIndex);
const nsAString& theName=aNode.GetValueAt(theIndex);
theNamePtr=&theName;
}
else if(theKey.Equals(NS_LITERAL_STRING("VALUE"), nsCaseInsensitiveStringComparator())) {
//store the named enity with the context...
const nsString& theValue=aNode.GetValueAt(theIndex);
const nsAString& theValue=aNode.GetValueAt(theIndex);
theValuePtr=&theValue;
}
}

Просмотреть файл

@ -452,30 +452,36 @@ nsDTDContext::~nsDTDContext() {
#ifdef DEBUG
CNamedEntity* nsDTDContext::GetEntity(const nsString& aName)const {
PRInt32 theCount=mEntities.GetSize();
PRInt32 theIndex=0;
CNamedEntity* nsDTDContext::GetEntity(const nsAString& aName)const {
if (aName.Length() > 2) {
nsAString::const_iterator start, end;
aName.BeginReading(start);
aName.EndReading(end);
PRInt32 theLen=aName.Length();
PRUnichar theChar=aName.Last();
PRInt32 theLen=aName.Length();
PRUnichar theChar=aName.Last();
if(theLen>2) {
if(kSemicolon==theChar) {
theLen--;
// skip past leading and trailing quotes/etc
if(kQuote==*start) {
start++;
}
const PRUnichar *theBuf=aName.get();
if(kQuote==theBuf[0]) {
theBuf++;
theLen--;
}
if(kQuote==theChar) {
theLen--;
if(kSemicolon==theChar ||
kQuote == theChar) {
end--;
}
const nsAString& entityName = Substring(start, end);
PRInt32 theCount=mEntities.GetSize();
PRInt32 theIndex=0;
for(theIndex=0;theIndex<theCount;theIndex++) {
CNamedEntity *theResult=(CNamedEntity*)mEntities.ObjectAt(theIndex);
if(theResult && theResult->mName.EqualsWithConversion(theBuf,PR_TRUE,theLen)){
if(theResult &&
theResult->mName.Equals(entityName,
nsCaseInsensitiveStringComparator())) {
return theResult;
}
}
@ -483,7 +489,7 @@ CNamedEntity* nsDTDContext::GetEntity(const nsString& aName)const {
return 0;
}
CNamedEntity* nsDTDContext::RegisterEntity(const nsString& aName,const nsString& aValue) {
CNamedEntity* nsDTDContext::RegisterEntity(const nsAString& aName,const nsAString& aValue) {
CNamedEntity *theEntity=GetEntity(aName);
if(!GetEntity(aName)){
theEntity=new CNamedEntity(aName,aValue);
@ -843,7 +849,7 @@ PRInt32 nsDTDContext::IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsStr
for(theIndex=0;theIndex<theCount;theIndex++){
const nsAString& theKey=aNode.GetKeyAt(theIndex);
const nsString& theValue=aNode.GetValueAt(theIndex);
const nsAString& theValue=aNode.GetValueAt(theIndex);
if(theKey.Equals(NS_LITERAL_STRING("name"), nsCaseInsensitiveStringComparator())){
theEntity=GetEntity(theValue);
@ -857,9 +863,11 @@ PRInt32 nsDTDContext::IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsStr
theIncrValue=0;
}
else if(theKey.Equals(NS_LITERAL_STRING("format"), nsCaseInsensitiveStringComparator())){
PRUnichar theChar=theValue.CharAt(0);
nsAString::const_iterator start;
PRUnichar theChar=*theValue.BeginReading(start);
if('"'==theChar)
theChar=theValue.CharAt(1);
theChar=*(++start);
switch(theChar){
case 'A': case 'a': theNumFormat=CAbacus::eAlpha; break;
case 'B': case 'b': theNumFormat=CAbacus::eBinary; break;
@ -875,7 +883,7 @@ PRInt32 nsDTDContext::IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsStr
}
else if(theKey.Equals(NS_LITERAL_STRING("value"), nsCaseInsensitiveStringComparator())){
PRInt32 err=0;
theNewValue=theValue.ToInteger(&err);
theNewValue=atoi(NS_LossyConvertUCS2toASCII(theValue).get());
if(!err) {
theIncrValue=0;

Просмотреть файл

@ -234,7 +234,7 @@ public:
//used for named entities and counters (XXX debug only)
class CNamedEntity {
public:
CNamedEntity(const nsString& aName,const nsString& aValue) : mName(), mValue() {
CNamedEntity(const nsAString& aName,const nsAString& aValue) : mName(), mValue() {
PRUnichar theFirst=aName.First();
PRUnichar theLast=aName.Last();
PRInt32 theLen=aName.Length();
@ -389,8 +389,8 @@ public:
void AllocateCounters(void);
PRInt32 IncrementCounter(eHTMLTags aTag,nsIParserNode& aNode,nsString& aResult);
CNamedEntity* RegisterEntity(const nsString& aName,const nsString& aValue);
CNamedEntity* GetEntity(const nsString& aName)const;
CNamedEntity* RegisterEntity(const nsAString& aName,const nsAString& aValue);
CNamedEntity* GetEntity(const nsAString& aName) const;
#endif
};

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -576,7 +576,7 @@ nsLoggingSink::WriteAttributes(const nsIParserNode& aNode) {
char* key=nsnull;
char* value=nsnull;
const nsAReadableString& k = aNode.GetKeyAt(i);
const nsString& v = aNode.GetValueAt(i);
const nsAString& v = aNode.GetValueAt(i);
GetNewCString(k, &key);
if(key) {

Просмотреть файл

@ -300,7 +300,7 @@ const nsAReadableString& nsCParserNode::GetKeyAt(PRUint32 anIndex) const {
* @param anIndex-- offset of attribute to retrieve
* @return string rep of given attribute text value
*/
const nsString& nsCParserNode::GetValueAt(PRUint32 anIndex) const {
const nsAString& nsCParserNode::GetValueAt(PRUint32 anIndex) const {
PRInt32 theCount = (mAttributes) ? mAttributes->GetSize() : 0;
NS_PRECONDITION(PRInt32(anIndex)<theCount, "Bad attr index");

Просмотреть файл

@ -214,7 +214,7 @@ class nsCParserNode : public nsIParserNode {
* @param anIndex is the index of the value you want
* @return string containing value.
*/
virtual const nsString& GetValueAt(PRUint32 anIndex) const;
virtual const nsAString& GetValueAt(PRUint32 anIndex) const;
/**
* NOTE: When the node is an entity, this will translate the entity

Просмотреть файл

@ -105,7 +105,7 @@ MOZ_DECL_CTOR_COUNTER(nsScanner)
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner::nsScanner(nsString& anHTMLString, const nsString& aCharset, PRInt32 aSource)
nsScanner::nsScanner(const nsAString& anHTMLString, const nsString& aCharset, PRInt32 aSource)
{
MOZ_COUNT_CTOR(nsScanner);
@ -163,7 +163,7 @@ nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& a
* @param aFilename --
* @return
*/
nsScanner::nsScanner(nsString& aFilename,nsInputStream& aStream,const nsString& aCharset, PRInt32 aSource) :
nsScanner::nsScanner(const nsAString& aFilename,nsInputStream& aStream,const nsString& aCharset, PRInt32 aSource) :
mFilename(aFilename)
{
MOZ_COUNT_CTOR(nsScanner);

Просмотреть файл

@ -94,7 +94,7 @@ class nsScanner {
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner(nsString& anHTMLString, const nsString& aCharset, PRInt32 aSource);
nsScanner(const nsAString& anHTMLString, const nsString& aCharset, PRInt32 aSource);
/**
* Use this constructor if you want i/o to be based on
@ -117,7 +117,7 @@ class nsScanner {
* @param aMode represents the parser mode (nav, other)
* @return
*/
nsScanner(nsString& aFilename, nsInputStream& aStream, const nsString& aCharset, PRInt32 aSource);
nsScanner(const nsAString& aFilename, nsInputStream& aStream, const nsString& aCharset, PRInt32 aSource);
~nsScanner();

Просмотреть файл

@ -882,7 +882,7 @@ nsresult CViewSourceHTML::WriteAttributes(PRInt32 attrCount) {
const nsAReadableString& theKey=theAttrToken->GetKey();
result=WriteTag(mKey,theKey,0,PR_FALSE);
const nsString& theValue=theAttrToken->GetValue();
const nsAString& theValue=theAttrToken->GetValue();
if((0<theValue.Length()) || (theAttrToken->mHasEqualWithoutValue)){
result=WriteTag(mValue,theValue,0,PR_FALSE);

Просмотреть файл

@ -1,82 +0,0 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..
REQUIRES = xpcom \
string \
htmlparser \
necko \
layout \
dom \
content \
$(NULL)
MAKE_OBJ_TYPE = EXE
PROGRAM = .\$(OBJDIR)\TestOutput.exe
BATCHSCRIPT = TestOutSinks.pl
OBJS = \
.\$(OBJDIR)\Convert.obj \
$(NULL)
TEST_FILES = \
plain.html \
plainwrap.out \
plainnowrap.out \
simple.html \
simplecopy.out \
simplefmt.out \
entityxif.xif \
entityxif.out \
mailquote.html \
mailquote.out \
xifstuff.xif \
xifstuff.out \
htmltable.html \
htmltable.out \
doctype.xif \
xifdtplain.out \
xifdthtml.out \
simplemail.html \
simplemail.out \
$(NULL)
LLIBS= \
$(DIST)\lib\xpcom.lib \
$(LIBNSPR) \
$(NULL)
LLFLAGS= -SUBSYSTEM:CONSOLE
include <$(DEPTH)\config\rules.mak>
# !ifdef MOZ_NO_DEBUG_RTL
# OS_CFLAGS = $(OS_CFLAGS) -DMOZ_NO_DEBUG_RTL
# !endif
libs:: $(PROGRAM)
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
$(MAKE_INSTALL) $(BATCHSCRIPT) $(DIST)\bin
$(MAKE_INSTALL) $(TEST_FILES) $(DIST)/bin/OutTestData
clobber::
rm -f $(OBJS) $(DIST)\bin\Convert.exe