const nsAString& nsCParserStartNode::GetValueAt(PRUint32 anIndex) const { if (PRInt32(anIndex) < mAttributes.GetSize()) { CAttributeToken* attr = static_cast<CAttributeToken*>(mAttributes.ObjectAt(anIndex)); if (attr) { return attr->GetValue(); } } return EmptyString(); }
/** * This method gets called when a tag needs to write it's attributes * * @update gess 3/25/98 * @param * @return result status */ nsresult CViewSourceHTML::WriteAttributes(const nsAString& tagName, nsTokenAllocator* allocator, PRInt32 attrCount, PRBool aOwnerInError) { nsresult result=NS_OK; if(attrCount){ //go collect the attributes... int attr = 0; for(attr = 0; attr < attrCount; ++attr){ CToken* theToken = mTokenizer->PeekToken(); if(theToken) { eHTMLTokenTypes theType = eHTMLTokenTypes(theToken->GetTokenType()); if(eToken_attribute == theType){ mTokenizer->PopToken(); //pop it for real... mTokenNode.AddAttribute(theToken); //and add it to the node. CAttributeToken* theAttrToken = (CAttributeToken*)theToken; const nsSubstring& theKey = theAttrToken->GetKey(); // The attribute is only in error if its owner is NOT in error. const PRBool attributeInError = !aOwnerInError && theAttrToken->IsInError(); result = WriteTag(kAttributeName,theKey,0,attributeInError); const nsSubstring& theValue = theAttrToken->GetValue(); if(!theValue.IsEmpty() || theAttrToken->mHasEqualWithoutValue){ if (IsUrlAttribute(tagName, theKey, theValue)) { WriteHrefAttribute(allocator, theValue); } else { WriteTag(kAttributeValue,theValue,0,attributeInError); } } } } else return kEOF; } } return result; }