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
Родитель 648c636bba
Коммит 4f4d815566
36 изменённых файлов: 151 добавлений и 3389 удалений

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

@ -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
};

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,285 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* MODULE NOTES:
* @update gpk 7/12/98
* @update gess 7/20/98
*
* If you've been paying attention to our many content sink classes, you may be
* asking yourself, "why do we need yet another one?" The answer is that this
* implementation, unlike all the others, really sends its output a given stream
* rather than to an actual content sink (as defined in our HTML document system).
*
* We use this class for a number of purposes:
* 1) For actual document i/o using XIF (xml interchange format)
* 2) For document conversions
* 3) For debug purposes (to cause output to go to cout or a file)
*
* The output is formatted, or not, according to the flags passed in.
* Tags with the attribute "_moz_dirty" will be prettyprinted
* regardless of the flags (and this attribute will not be output).
*/
#ifndef NS_TXTCONTENTSINK_STREAM
#define NS_TXTCONTENTSINK_STREAM
#include "nsIHTMLContentSink.h"
#include "nsParserCIID.h"
#include "nsCOMPtr.h"
#include "nsHTMLTags.h"
#include "nsISaveAsCharset.h"
#include "nsIEntityConverter.h"
#include "nsIURI.h"
#include "nsAWritableString.h"
#define NS_IHTMLCONTENTSINKSTREAM_IID \
{0xa39c6bff, 0x15f0, 0x11d2, \
{0x80, 0x41, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4}}
#if !defined(XP_MAC) && !defined(__KCC)
class ostream;
#endif
class nsIParserNode;
class nsIOutputStream;
class nsIDTD;
class nsIHTMLContentSinkStream : public nsIHTMLContentSink {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTMLCONTENTSINKSTREAM_IID)
NS_DEFINE_STATIC_CID_ACCESSOR(NS_HTMLCONTENTSINKSTREAM_CID)
NS_IMETHOD Initialize(nsIOutputStream* aOutStream,
nsAWritableString* aOutString,
const nsAReadableString* aCharsetOverride,
PRUint32 aFlags) = 0;
};
class nsHTMLContentSinkStream : public nsIHTMLContentSinkStream
{
public:
/**
* Constructor with associated stream. If you use this, it means that you want
* this class to emits its output to the stream you provide.
* @update gpk 04/30/99
* @param aOutStream -- stream where you want output sent
* @param aOutStream -- ref to string where you want output sent
*/
nsHTMLContentSinkStream();
/**
* virtual destructor
* @update gess7/7/98
*/
virtual ~nsHTMLContentSinkStream();
// nsISupports
NS_DECL_ISUPPORTS
// nsIHTMLContentSinkStream
NS_IMETHOD Initialize(nsIOutputStream* aOutStream,
nsAWritableString* aOutString,
const nsAReadableString* aCharsetOverride,
PRUint32 aFlags);
/*******************************************************************
* The following methods are inherited from nsIContentSink.
* Please see that file for details.
*******************************************************************/
NS_IMETHOD WillBuildModel(void);
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel);
NS_IMETHOD WillInterrupt(void);
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD NotifyError(const nsParserError* aError);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
/*******************************************************************
* The following methods are inherited from nsIHTMLContentSink.
* Please see that file for details.
*******************************************************************/
NS_IMETHOD SetTitle(const nsString& aValue);
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref) { return NS_OK; }
NS_IMETHOD DoFragment(PRBool aFlag);
NS_IMETHOD BeginContext(PRInt32 aPosition);
NS_IMETHOD EndContext(PRInt32 aPosition);
public:
void SetLowerCaseTags(PRBool aDoLowerCase) { mLowerCaseTags = aDoLowerCase; }
protected:
PRBool IsBlockLevel(eHTMLTags aTag);
PRInt32 BreakBeforeOpen(eHTMLTags aTag);
PRInt32 BreakAfterOpen(eHTMLTags aTag);
PRInt32 BreakBeforeClose(eHTMLTags aTag);
PRInt32 BreakAfterClose(eHTMLTags aTag);
PRBool IndentChildren(eHTMLTags aTag);
void WriteAttributes(const nsIParserNode& aNode);
void AddStartTag(const nsIParserNode& aNode);
void AddEndTag(const nsIParserNode& aNode);
void AddIndent();
void EnsureBufferSize(PRInt32 aNewSize);
NS_IMETHOD InitEncoders();
PRInt32 Write(const nsAReadableString& aString); // returns # chars written
void Write(const char* aCharBuffer);
void Write(char aChar);
// Handle wrapping and conditional wrapping:
PRBool HasLongLines(const nsAReadableString& text);
void WriteWrapped(const nsAReadableString& text);
// Is this node "dirty", needing reformatting?
PRBool IsDirty(const nsIParserNode& aNode);
protected:
nsIOutputStream* mStream;
nsAWritableString* mString;
nsIDTD* mDTD;
int mTabLevel;
char* mBuffer;
PRInt32 mBufferSize;
PRInt32 mBufferLength;
PRInt32 mIndent;
PRBool mLowerCaseTags;
PRInt32 mHTMLStackPos;
eHTMLTags mHTMLTagStack[1024]; // warning: hard-coded nesting level
PRBool mDirtyStack[1024]; // warning: hard-coded nesting level
PRInt32 mColPos;
PRBool mInBody;
PRUint32 mFlags;
nsCOMPtr<nsIURI> mURI;
PRBool mDoFormat;
PRBool mBodyOnly;
PRBool mHasOpenHtmlTag;
PRInt32 mPreLevel;
PRInt32 mMaxColumn;
nsString mLineBreak;
nsCOMPtr<nsISaveAsCharset> mCharsetEncoder;
nsCOMPtr<nsIEntityConverter> mEntityConverter;
nsString mCharsetOverride;
};
inline nsresult
NS_New_HTML_ContentSinkStream(nsIHTMLContentSink** aInstancePtrResult,
nsIOutputStream* aOutStream,
const nsAReadableString* aCharsetOverride,
PRUint32 aFlags)
{
nsCOMPtr<nsIHTMLContentSinkStream> it;
nsresult rv;
rv = nsComponentManager::CreateInstance(nsIHTMLContentSinkStream::GetCID(),
nsnull,
NS_GET_IID(nsIHTMLContentSinkStream),
getter_AddRefs(it));
if (NS_SUCCEEDED(rv)) {
rv = it->Initialize(aOutStream,
nsnull,
aCharsetOverride,
aFlags);
if (NS_SUCCEEDED(rv)) {
rv = it->QueryInterface(NS_GET_IID(nsIHTMLContentSink),
(void**)aInstancePtrResult);
}
}
return rv;
}
inline nsresult
NS_New_HTML_ContentSinkStream(nsIHTMLContentSink** aInstancePtrResult,
nsAWritableString* aOutString, PRUint32 aFlags)
{
nsCOMPtr<nsIHTMLContentSinkStream> it;
nsresult rv;
rv = nsComponentManager::CreateInstance(nsIHTMLContentSinkStream::GetCID(),
nsnull,
NS_GET_IID(nsIHTMLContentSinkStream),
getter_AddRefs(it));
if (NS_SUCCEEDED(rv)) {
rv = it->Initialize(nsnull,
aOutString,
nsnull,
aFlags);
if (NS_SUCCEEDED(rv)) {
rv = it->QueryInterface(NS_GET_IID(nsIHTMLContentSink),
(void**)aInstancePtrResult);
}
}
return rv;
}
#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);

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

@ -26,7 +26,6 @@ REQUIRES = xpcom \
htmlparser \
necko \
layout \
dom \
content \
$(NULL)

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

@ -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
};

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,285 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 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 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* MODULE NOTES:
* @update gpk 7/12/98
* @update gess 7/20/98
*
* If you've been paying attention to our many content sink classes, you may be
* asking yourself, "why do we need yet another one?" The answer is that this
* implementation, unlike all the others, really sends its output a given stream
* rather than to an actual content sink (as defined in our HTML document system).
*
* We use this class for a number of purposes:
* 1) For actual document i/o using XIF (xml interchange format)
* 2) For document conversions
* 3) For debug purposes (to cause output to go to cout or a file)
*
* The output is formatted, or not, according to the flags passed in.
* Tags with the attribute "_moz_dirty" will be prettyprinted
* regardless of the flags (and this attribute will not be output).
*/
#ifndef NS_TXTCONTENTSINK_STREAM
#define NS_TXTCONTENTSINK_STREAM
#include "nsIHTMLContentSink.h"
#include "nsParserCIID.h"
#include "nsCOMPtr.h"
#include "nsHTMLTags.h"
#include "nsISaveAsCharset.h"
#include "nsIEntityConverter.h"
#include "nsIURI.h"
#include "nsAWritableString.h"
#define NS_IHTMLCONTENTSINKSTREAM_IID \
{0xa39c6bff, 0x15f0, 0x11d2, \
{0x80, 0x41, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4}}
#if !defined(XP_MAC) && !defined(__KCC)
class ostream;
#endif
class nsIParserNode;
class nsIOutputStream;
class nsIDTD;
class nsIHTMLContentSinkStream : public nsIHTMLContentSink {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTMLCONTENTSINKSTREAM_IID)
NS_DEFINE_STATIC_CID_ACCESSOR(NS_HTMLCONTENTSINKSTREAM_CID)
NS_IMETHOD Initialize(nsIOutputStream* aOutStream,
nsAWritableString* aOutString,
const nsAReadableString* aCharsetOverride,
PRUint32 aFlags) = 0;
};
class nsHTMLContentSinkStream : public nsIHTMLContentSinkStream
{
public:
/**
* Constructor with associated stream. If you use this, it means that you want
* this class to emits its output to the stream you provide.
* @update gpk 04/30/99
* @param aOutStream -- stream where you want output sent
* @param aOutStream -- ref to string where you want output sent
*/
nsHTMLContentSinkStream();
/**
* virtual destructor
* @update gess7/7/98
*/
virtual ~nsHTMLContentSinkStream();
// nsISupports
NS_DECL_ISUPPORTS
// nsIHTMLContentSinkStream
NS_IMETHOD Initialize(nsIOutputStream* aOutStream,
nsAWritableString* aOutString,
const nsAReadableString* aCharsetOverride,
PRUint32 aFlags);
/*******************************************************************
* The following methods are inherited from nsIContentSink.
* Please see that file for details.
*******************************************************************/
NS_IMETHOD WillBuildModel(void);
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel);
NS_IMETHOD WillInterrupt(void);
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
NS_IMETHOD NotifyError(const nsParserError* aError);
NS_IMETHOD AddComment(const nsIParserNode& aNode);
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode=0);
NS_IMETHOD FlushPendingNotifications() { return NS_OK; }
/*******************************************************************
* The following methods are inherited from nsIHTMLContentSink.
* Please see that file for details.
*******************************************************************/
NS_IMETHOD SetTitle(const nsString& aValue);
NS_IMETHOD OpenHTML(const nsIParserNode& aNode);
NS_IMETHOD CloseHTML(const nsIParserNode& aNode);
NS_IMETHOD OpenHead(const nsIParserNode& aNode);
NS_IMETHOD CloseHead(const nsIParserNode& aNode);
NS_IMETHOD OpenBody(const nsIParserNode& aNode);
NS_IMETHOD CloseBody(const nsIParserNode& aNode);
NS_IMETHOD OpenForm(const nsIParserNode& aNode);
NS_IMETHOD CloseForm(const nsIParserNode& aNode);
NS_IMETHOD OpenMap(const nsIParserNode& aNode);
NS_IMETHOD CloseMap(const nsIParserNode& aNode);
NS_IMETHOD OpenFrameset(const nsIParserNode& aNode);
NS_IMETHOD CloseFrameset(const nsIParserNode& aNode);
NS_IMETHOD GetPref(PRInt32 aTag,PRBool& aPref) { return NS_OK; }
NS_IMETHOD DoFragment(PRBool aFlag);
NS_IMETHOD BeginContext(PRInt32 aPosition);
NS_IMETHOD EndContext(PRInt32 aPosition);
public:
void SetLowerCaseTags(PRBool aDoLowerCase) { mLowerCaseTags = aDoLowerCase; }
protected:
PRBool IsBlockLevel(eHTMLTags aTag);
PRInt32 BreakBeforeOpen(eHTMLTags aTag);
PRInt32 BreakAfterOpen(eHTMLTags aTag);
PRInt32 BreakBeforeClose(eHTMLTags aTag);
PRInt32 BreakAfterClose(eHTMLTags aTag);
PRBool IndentChildren(eHTMLTags aTag);
void WriteAttributes(const nsIParserNode& aNode);
void AddStartTag(const nsIParserNode& aNode);
void AddEndTag(const nsIParserNode& aNode);
void AddIndent();
void EnsureBufferSize(PRInt32 aNewSize);
NS_IMETHOD InitEncoders();
PRInt32 Write(const nsAReadableString& aString); // returns # chars written
void Write(const char* aCharBuffer);
void Write(char aChar);
// Handle wrapping and conditional wrapping:
PRBool HasLongLines(const nsAReadableString& text);
void WriteWrapped(const nsAReadableString& text);
// Is this node "dirty", needing reformatting?
PRBool IsDirty(const nsIParserNode& aNode);
protected:
nsIOutputStream* mStream;
nsAWritableString* mString;
nsIDTD* mDTD;
int mTabLevel;
char* mBuffer;
PRInt32 mBufferSize;
PRInt32 mBufferLength;
PRInt32 mIndent;
PRBool mLowerCaseTags;
PRInt32 mHTMLStackPos;
eHTMLTags mHTMLTagStack[1024]; // warning: hard-coded nesting level
PRBool mDirtyStack[1024]; // warning: hard-coded nesting level
PRInt32 mColPos;
PRBool mInBody;
PRUint32 mFlags;
nsCOMPtr<nsIURI> mURI;
PRBool mDoFormat;
PRBool mBodyOnly;
PRBool mHasOpenHtmlTag;
PRInt32 mPreLevel;
PRInt32 mMaxColumn;
nsString mLineBreak;
nsCOMPtr<nsISaveAsCharset> mCharsetEncoder;
nsCOMPtr<nsIEntityConverter> mEntityConverter;
nsString mCharsetOverride;
};
inline nsresult
NS_New_HTML_ContentSinkStream(nsIHTMLContentSink** aInstancePtrResult,
nsIOutputStream* aOutStream,
const nsAReadableString* aCharsetOverride,
PRUint32 aFlags)
{
nsCOMPtr<nsIHTMLContentSinkStream> it;
nsresult rv;
rv = nsComponentManager::CreateInstance(nsIHTMLContentSinkStream::GetCID(),
nsnull,
NS_GET_IID(nsIHTMLContentSinkStream),
getter_AddRefs(it));
if (NS_SUCCEEDED(rv)) {
rv = it->Initialize(aOutStream,
nsnull,
aCharsetOverride,
aFlags);
if (NS_SUCCEEDED(rv)) {
rv = it->QueryInterface(NS_GET_IID(nsIHTMLContentSink),
(void**)aInstancePtrResult);
}
}
return rv;
}
inline nsresult
NS_New_HTML_ContentSinkStream(nsIHTMLContentSink** aInstancePtrResult,
nsAWritableString* aOutString, PRUint32 aFlags)
{
nsCOMPtr<nsIHTMLContentSinkStream> it;
nsresult rv;
rv = nsComponentManager::CreateInstance(nsIHTMLContentSinkStream::GetCID(),
nsnull,
NS_GET_IID(nsIHTMLContentSinkStream),
getter_AddRefs(it));
if (NS_SUCCEEDED(rv)) {
rv = it->Initialize(nsnull,
aOutString,
nsnull,
aFlags);
if (NS_SUCCEEDED(rv)) {
rv = it->QueryInterface(NS_GET_IID(nsIHTMLContentSink),
(void**)aInstancePtrResult);
}
}
return rv;
}
#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);

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

@ -26,7 +26,6 @@ REQUIRES = xpcom \
htmlparser \
necko \
layout \
dom \
content \
$(NULL)