Fixing bug 394534. Make first attribute win in misplaced content. Patch by bzbarsky@mit.edu, r=mrbkap@gmail.com, sr=peterv@propagandism.org, a=jonas@sicking.cc/dsicore@mozilla.com

This commit is contained in:
jst@mozilla.org 2007-09-10 16:50:16 -07:00
parent 22f6392e92
commit 766c82a844
4 changed files with 24 additions and 3 deletions

View File

@ -377,3 +377,4 @@ random-if(MOZ_WIDGET_TOOLKIT=="cocoa") == 379316-2.html 379316-2-ref.html # bug
== 393671-2.html 393671-2-ref.html
== 393671-3.html 393671-3-ref.html
== 394111-1.html about:blank # Really an assertion test rather than a rendering test
== 394534-1.html 394534-1-ref.html

View File

@ -1062,7 +1062,7 @@ PushMisplacedAttributes(nsIParserNode& aNode, nsDeque& aDeque)
nsCParserNode& theAttrNode = static_cast<nsCParserNode &>(aNode);
for (PRInt32 count = aNode.GetAttributeCount(); count > 0; --count) {
CToken* theAttrToken = theAttrNode.PopAttributeToken();
CToken* theAttrToken = theAttrNode.PopAttributeTokenFront();
if (theAttrToken) {
theAttrToken->SetNewlineCount(0);
aDeque.Push(theAttrToken);
@ -1742,14 +1742,19 @@ CNavDTD::HandleSavedTokens(PRInt32 anIndex)
if (theToken) {
theTag = (eHTMLTags)theToken->GetTypeID();
attrCount = theToken->GetAttributeCount();
// Put back attributes, which once got popped out, into the tokenizer
// 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
// the PopFront them all?
nsDeque temp;
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 static_cast<CToken*>(mAttributes.Pop());
}
CToken*
nsCParserStartNode::PopAttributeTokenFront()
{
return static_cast<CToken*>(mAttributes.PopFront());
}
void nsCParserStartNode::GetSource(nsString& aString) const
{
aString.Assign(PRUnichar('<'));

View File

@ -239,6 +239,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
@ -314,6 +317,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) const;
virtual nsresult ReleaseAll();
protected: