Fixing bug 394534. Make first attribute win in misplaced content. r=mrbkap@gmail.com, sr=peterv@propagandism.org, a=dveditz

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@236661 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2007-09-25 16:36:01 +00:00
parent c00a1dc95c
commit 22ccb6eb72
3 changed files with 24 additions and 2 deletions

View File

@@ -1382,7 +1382,7 @@ static void PushMisplacedAttributes(nsIParserNode& aNode,nsDeque& aDeque,PRInt32
nsCParserNode* theAttrNode = (nsCParserNode*)&aNode;
if(theAttrNode) {
while(aCount){
theAttrToken=theAttrNode->PopAttributeToken();
theAttrToken=theAttrNode->PopAttributeTokenFront();
if(theAttrToken) {
theAttrToken->SetNewlineCount(0);
aDeque.Push(theAttrToken);
@@ -2013,14 +2013,21 @@ nsresult CNavDTD::HandleSavedTokens(PRInt32 anIndex) {
if(theToken) {
theTag = (eHTMLTags)theToken->GetTypeID();
attrCount = (gHTMLElements[theTag].mSkipTarget)? 0:theToken->GetAttributeCount();
// Put back attributes, which once got popped out, into the
// tokenizer. Make sure we preserve their ordering, however!
// XXXbz would it be faster to get the tokens out with ObjectAt and
// put them in the tokenizer and then PopFront them all from
// mMisplacedContent?
nsDeque temp;
// Put back attributes, which once got popped out, into the tokenizer
for(PRInt32 j=0;j<attrCount; ++j){
CToken* theAttrToken = (CToken*)mMisplacedContent.PopFront();
if(theAttrToken) {
mTokenizer->PushTokenFront(theAttrToken);
temp.Push(theAttrToken);
}
theBadTokenCount--;
}
mTokenizer->PrependTokens(temp);
if(eToken_end==theToken->GetTokenType()) {
// Ref: Bug 25202

View File

@@ -264,6 +264,11 @@ nsCParserNode::PopAttributeToken() {
return 0;
}
CToken*
nsCParserNode::PopAttributeTokenFront() {
return 0;
}
/** Retrieve a string containing the tag and its attributes in "source" form
* @update rickg 06June2000
* @return void
@@ -353,6 +358,12 @@ nsCParserStartNode::PopAttributeToken()
return NS_STATIC_CAST(CToken*, mAttributes.Pop());
}
CToken*
nsCParserStartNode::PopAttributeTokenFront()
{
return NS_STATIC_CAST(CToken*, mAttributes.PopFront());
}
void nsCParserStartNode::GetSource(nsString& aString)
{
aString.Assign(PRUnichar('<'));

View File

@@ -238,6 +238,9 @@ class nsCParserNode : public nsIParserNode {
*/
virtual CToken* PopAttributeToken();
/** Like PopAttributeToken, but pops off the front of the attribute list */
virtual CToken* PopAttributeTokenFront();
/** Retrieve a string containing the tag and its attributes in "source" form
* @update rickg 06June2000
* @return void
@@ -312,6 +315,7 @@ public:
virtual const nsAString& GetKeyAt(PRUint32 anIndex) const;
virtual const nsAString& GetValueAt(PRUint32 anIndex) const;
virtual CToken* PopAttributeToken();
virtual CToken* PopAttributeTokenFront();
virtual void GetSource(nsString& aString);
virtual nsresult ReleaseAll();
protected: