Avoid excessive content-changed reflows during text appending

git-svn-id: svn://10.0.0.236/trunk@6172 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
kipp%netscape.com 1998-07-22 17:40:05 +00:00
parent 0a063a503f
commit 9bc848dc75
2 changed files with 26 additions and 0 deletions

View File

@ -1116,6 +1116,8 @@ NS_IMETHODIMP HTMLContentSink::AddLeaf(const nsIParserNode& aNode)
break;
}
PRBool sleazyTextHackXXX = PR_FALSE;
nsresult rv = NS_OK;
nsIHTMLContent* leaf = nsnull;
switch (aNode.GetTokenType()) {
@ -1159,6 +1161,7 @@ NS_IMETHODIMP HTMLContentSink::AddLeaf(const nsIParserNode& aNode)
case eToken_whitespace:
case eToken_newline:
rv = AddText(aNode.GetText(), &leaf);
sleazyTextHackXXX = PR_TRUE;
break;
case eToken_entity:
@ -1171,6 +1174,7 @@ NS_IMETHODIMP HTMLContentSink::AddLeaf(const nsIParserNode& aNode)
else {
rv = AddText(tmp, &leaf);
}
sleazyTextHackXXX = PR_TRUE;
}
break;
@ -1184,6 +1188,10 @@ NS_IMETHODIMP HTMLContentSink::AddLeaf(const nsIParserNode& aNode)
AppendToCorrectParent(parentType, parent,
(nsHTMLTag) aNode.GetNodeType(), leaf,
PR_FALSE);
if (sleazyTextHackXXX) {
// XXX Prevent incremental reflows on the text as it pours in
leaf->SetDocument(nsnull);
}
} else {
// XXX drop stuff on the floor that doesn't have a container!
// Bad parser!
@ -1319,6 +1327,11 @@ void
HTMLContentSink::FlushText()
{
if (nsnull != mCurrentText) {
// XXX sleazyTextHackXXX repair document pointer in text object
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
nsIContent* content = nsnull;
mCurrentText->QueryInterface(kIContentIID, (void**) &content);
content->SetDocument(mDocument);
NS_RELEASE(mCurrentText);
}
}

View File

@ -1116,6 +1116,8 @@ NS_IMETHODIMP HTMLContentSink::AddLeaf(const nsIParserNode& aNode)
break;
}
PRBool sleazyTextHackXXX = PR_FALSE;
nsresult rv = NS_OK;
nsIHTMLContent* leaf = nsnull;
switch (aNode.GetTokenType()) {
@ -1159,6 +1161,7 @@ NS_IMETHODIMP HTMLContentSink::AddLeaf(const nsIParserNode& aNode)
case eToken_whitespace:
case eToken_newline:
rv = AddText(aNode.GetText(), &leaf);
sleazyTextHackXXX = PR_TRUE;
break;
case eToken_entity:
@ -1171,6 +1174,7 @@ NS_IMETHODIMP HTMLContentSink::AddLeaf(const nsIParserNode& aNode)
else {
rv = AddText(tmp, &leaf);
}
sleazyTextHackXXX = PR_TRUE;
}
break;
@ -1184,6 +1188,10 @@ NS_IMETHODIMP HTMLContentSink::AddLeaf(const nsIParserNode& aNode)
AppendToCorrectParent(parentType, parent,
(nsHTMLTag) aNode.GetNodeType(), leaf,
PR_FALSE);
if (sleazyTextHackXXX) {
// XXX Prevent incremental reflows on the text as it pours in
leaf->SetDocument(nsnull);
}
} else {
// XXX drop stuff on the floor that doesn't have a container!
// Bad parser!
@ -1319,6 +1327,11 @@ void
HTMLContentSink::FlushText()
{
if (nsnull != mCurrentText) {
// XXX sleazyTextHackXXX repair document pointer in text object
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
nsIContent* content = nsnull;
mCurrentText->QueryInterface(kIContentIID, (void**) &content);
content->SetDocument(mDocument);
NS_RELEASE(mCurrentText);
}
}