oops -- I didn't mean to update these -- backing out

git-svn-id: svn://10.0.0.236/trunk@33225 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rickg%netscape.com
1999-05-29 03:04:16 +00:00
parent 4cf139826e
commit bf2176589a
8 changed files with 198 additions and 108 deletions

View File

@@ -445,7 +445,7 @@ nsHTMLContentSinkStream::nsHTMLContentSinkStream(nsIOutputStream* aOutStream,
nsString* aOutString,
const nsString* aCharsetOverride,
PRBool aDoFormat,
PRBool aDoHeader) : mBuffer("",eOneByte) {
PRBool aDoHeader) {
NS_INIT_REFCNT();
mLowerCaseTags = PR_TRUE;
memset(mHTMLTagStack,0,sizeof(mHTMLTagStack));
@@ -454,6 +454,8 @@ nsHTMLContentSinkStream::nsHTMLContentSinkStream(nsIOutputStream* aOutStream,
mIndent = 0;
mDoFormat = aDoFormat;
mDoHeader = aDoHeader;
mBuffer = nsnull;
mBufferSize = 0;
mUnicodeEncoder = nsnull;
mStream = aOutStream;
mString = aOutString;
@@ -503,8 +505,8 @@ nsHTMLContentSinkStream::EndContext(PRInt32 aPosition)
}
void nsHTMLContentSinkStream::EnsureBufferSize(PRInt32 aNewSize) {
/*
void nsHTMLContentSinkStream::EnsureBufferSize(PRInt32 aNewSize)
{
if (mBufferSize < aNewSize)
{
delete [] mBuffer;
@@ -514,7 +516,6 @@ void nsHTMLContentSinkStream::EnsureBufferSize(PRInt32 aNewSize) {
mBuffer[0] = 0;
}
}
*/
}
@@ -531,17 +532,24 @@ void nsHTMLContentSinkStream::EncodeToBuffer(const nsString& aSrc)
PRInt32 length = aSrc.Length();
nsresult result;
if (mUnicodeEncoder != nsnull && length > 0) {
//EnsureBufferSize(length);
if (mUnicodeEncoder != nsnull && length > 0)
{
EnsureBufferSize(length);
mBufferLength = mBufferSize;
mUnicodeEncoder->Reset();
mBuffer.SetCapacity(2*length); //cause that's what greg used to do, but may not be necessary.
PRInt32 theNewLength=mBuffer.mCapacity;
result = mUnicodeEncoder->Convert(aSrc.GetUnicode(), &length, (char*)mBuffer.GetBuffer(), &theNewLength);
mBuffer.Truncate(theNewLength);
result = mUnicodeEncoder->Convert(aSrc.GetUnicode(), &length, mBuffer, &mBufferLength);
mBuffer[mBufferLength] = 0;
PRInt32 temp = mBufferLength;
if (NS_SUCCEEDED(result))
result = mUnicodeEncoder->Finish((char*)mBuffer.GetBuffer(),&theNewLength);
result = mUnicodeEncoder->Finish(mBuffer,&temp);
mBuffer.ReplaceChar(CH_NBSP,' '); //switch all nbsp's to spaces
for (PRInt32 i = 0; i < mBufferLength; i++)
{
if (mBuffer[i] == char(CH_NBSP))
mBuffer[i] = ' ';
}
}
}
@@ -557,15 +565,16 @@ void nsHTMLContentSinkStream::Write(const nsString& aString)
if (mStream != nsnull)
{
nsOutputStream out(mStream);
out.write(mBuffer.GetBuffer(),mBuffer.Length());
out.write(mBuffer,mBufferLength);
}
if (0!=mString) {
if (mString != nsnull)
{
mString->Append(mBuffer);
}
}
else
{
if (0!=mStream)
if (mStream != nsnull)
{
nsOutputStream out(mStream);
const PRUnichar* unicode = aString.GetUnicode();
@@ -636,19 +645,24 @@ void nsHTMLContentSinkStream::WriteAttributes(const nsIParserNode& aNode) {
for(i=0;i<theCount;i++){
const nsString& temp=aNode.GetKeyAt(i);
if (!temp.Equals(nsString("Steve's unbelievable hack attribute"))) {
nsAutoString key(temp,eOneByte);
if (!temp.Equals(nsString("Steve's unbelievable hack attribute")))
{
nsString key = temp;
if (mLowerCaseTags == PR_TRUE)
key.ToLowerCase();
else
key.ToUpperCase();
EnsureBufferSize(key.Length());
key.ToCString(mBuffer,mBufferSize);
// send to ouput " [KEY]="
Write(' ');
Write(key.GetBuffer());
Write(mBuffer);
Write(char(kEqual));
mColPos += 1 + key.Length() + 1;
mColPos += 1 + strlen(mBuffer) + 1;
const nsString& value=aNode.GetValueAt(i);
@@ -657,7 +671,7 @@ void nsHTMLContentSinkStream::WriteAttributes(const nsIParserNode& aNode) {
Write(value);
Write('\"');
mColPos += 1 + key.Length() + 1;
mColPos += 1 + strlen(mBuffer) + 1;
}
}
}
@@ -920,18 +934,25 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode)
if (PermitWSBeforeOpen(tag))
AddIndent();
nsAutoString theBuf(tagName,eOneByte);
EnsureBufferSize(tagName.Length());
tagName.ToCString(mBuffer,mBufferSize);
Write(kLessThan);
Write(theBuf.GetBuffer());
Write(mBuffer);
mColPos += 1 + tagName.Length();
if (tag == eHTMLTag_style) {
if (tag == eHTMLTag_style)
{
Write(">\n");
const nsString& data = aNode.GetSkippedContent();
nsAutoString theBuf(data,eOneByte);
Write(theBuf.GetBuffer());
PRInt32 size = data.Length();
char* buffer = new char[size+1];
if(buffer){
data.ToCString(buffer,size+1);
Write(buffer);
delete[] buffer;
}
}
else
{
@@ -986,16 +1007,18 @@ void nsHTMLContentSinkStream::AddEndTag(const nsIParserNode& aNode)
AddIndent();
}
nsAutoString theBuf(tagName,eOneByte);
EnsureBufferSize(tagName.Length());
tagName.ToCString(mBuffer,mBufferSize);
Write(kLessThan);
Write(kForwardSlash);
Write(theBuf.GetBuffer());
Write(mBuffer);
Write(kGreaterThan);
mColPos += 1 + 1 + theBuf.Length() + 1;
mColPos += 1 + 1 + strlen(mBuffer) + 1;
if (BreakAfterClose(tag)) {
if (BreakAfterClose(tag))
{
Write('\n');
mColPos = 0;
}