Fix for bug 362937 (Merge element's List and DumpContent implementations). r/sr=jst.

This commit is contained in:
peterv%propagandism.org 2006-12-27 17:26:32 +00:00
Родитель d77d24a317
Коммит 019102b4fd
5 изменённых файлов: 107 добавлений и 233 удалений

Просмотреть файл

@ -3574,63 +3574,104 @@ nsGenericElement::AppendTextTo(nsAString& aResult)
#ifdef DEBUG
void
nsGenericElement::List(FILE* out, PRInt32 aIndent) const
nsGenericElement::ListAttributes(FILE* out) const
{
PRUint32 index, count = mAttrsAndChildren.AttrCount();
for (index = 0; index < count; index++) {
nsAutoString buffer;
// name
mAttrsAndChildren.AttrNameAt(index)->GetQualifiedName(buffer);
// value
buffer.AppendLiteral("=\"");
nsAutoString value;
mAttrsAndChildren.AttrAt(index)->ToString(value);
for (int i = value.Length(); i >= 0; --i) {
if (value[i] == PRUnichar('"'))
value.Insert(PRUnichar('\\'), PRUint32(i));
}
buffer.Append(value);
buffer.AppendLiteral("\"");
fputs(" ", out);
fputs(NS_LossyConvertUTF16toASCII(buffer).get(), out);
}
}
void
nsGenericElement::List(FILE* out, PRInt32 aIndent,
const nsCString& aPrefix) const
{
PRInt32 indent;
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
fputs(aPrefix.get(), out);
nsAutoString buf;
mNodeInfo->GetQualifiedName(buf);
fputs(NS_LossyConvertUTF16toASCII(buf).get(), out);
fprintf(out, "@%p", (void *)this);
PRUint32 index, attrcount = mAttrsAndChildren.AttrCount();
for (index = 0; index < attrcount; index++) {
nsAutoString buffer;
// name
mAttrsAndChildren.AttrNameAt(index)->GetQualifiedName(buffer);
// value
buffer.AppendLiteral("=");
nsAutoString value;
mAttrsAndChildren.AttrAt(index)->ToString(value);
buffer.Append(value);
fputs(" ", out);
fputs(NS_LossyConvertUTF16toASCII(buffer).get(), out);
}
ListAttributes(out);
fprintf(out, " intrinsicstate=[%08x]", IntrinsicState());
fprintf(out, " refcount=%d<", mRefCnt.get());
fputs("\n", out);
PRUint32 kids = GetChildCount();
PRUint32 i, length = GetChildCount();
if (length > 0) {
fputs("\n", out);
for (index = 0; index < kids; index++) {
nsIContent *kid = GetChildAt(index);
kid->List(out, aIndent + 1);
for (i = 0; i < length; ++i) {
nsIContent *kid = GetChildAt(i);
kid->List(out, aIndent + 1);
}
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
}
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
fputs(">\n", out);
// XXX sXBL/XBL2 issue! Owner or current document?
nsIDocument *document = GetOwnerDoc();
if (document) {
nsIPresShell *shell = document->GetShellAt(0);
nsCOMPtr<nsISupportsArray> anonymousElements;
if (shell) {
shell->GetAnonymousContentFor(NS_CONST_CAST(nsGenericElement*, this),
getter_AddRefs(anonymousElements));
}
if (anonymousElements) {
anonymousElements->Count(&length);
if (length > 0) {
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
fputs("native-anonymous-children<\n", out);
for (i = 0; i < length; ++i) {
nsCOMPtr<nsIDOMNode> node = do_QueryElementAt(anonymousElements, i);
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
child->List(out, aIndent + 1);
}
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
fputs(">\n", out);
}
}
nsIBindingManager* bindingManager = document->BindingManager();
nsCOMPtr<nsIDOMNodeList> anonymousChildren;
bindingManager->GetAnonymousNodesFor(NS_CONST_CAST(nsGenericElement*, this),
getter_AddRefs(anonymousChildren));
if (anonymousChildren) {
PRUint32 length;
anonymousChildren->GetLength(&length);
if (length) {
if (length > 0) {
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
fputs("anonymous-children<\n", out);
for (PRUint32 i = 0; i < length; ++i) {
for (i = 0; i < length; ++i) {
nsCOMPtr<nsIDOMNode> node;
anonymousChildren->Item(i, getter_AddRefs(node));
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
@ -3653,13 +3694,12 @@ nsGenericElement::List(FILE* out, PRInt32 aIndent) const
NS_ASSERTION(contentList != nsnull, "oops, binding manager lied");
PRUint32 length;
contentList->GetLength(&length);
if (length) {
if (length > 0) {
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
fputs("content-list<\n", out);
for (PRUint32 i = 0; i < length; ++i) {
for (i = 0; i < length; ++i) {
nsCOMPtr<nsIDOMNode> node;
contentList->Item(i, getter_AddRefs(node));
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
@ -3677,6 +3717,32 @@ void
nsGenericElement::DumpContent(FILE* out, PRInt32 aIndent,
PRBool aDumpAll) const
{
PRInt32 indent;
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
nsAutoString buf;
mNodeInfo->GetQualifiedName(buf);
fputs("<", out);
fputs(NS_LossyConvertUTF16toASCII(buf).get(), out);
if(aDumpAll) ListAttributes(out);
fputs(">", out);
if(aIndent) fputs("\n", out);
PRInt32 index, kids = GetChildCount();
for (index = 0; index < kids; index++) {
nsIContent *kid = GetChildAt(index);
PRInt32 indent = aIndent ? aIndent + 1 : 0;
kid->DumpContent(out, indent, aDumpAll);
}
for (indent = aIndent; --indent >= 0; ) fputs(" ", out);
fputs("</", out);
fputs(NS_LossyConvertUTF16toASCII(buf).get(), out);
fputs(">", out);
if(aIndent) fputs("\n", out);
}
#endif

Просмотреть файл

@ -434,8 +434,13 @@ public:
virtual nsresult SetScriptTypeID(PRUint32 aLang);
#ifdef DEBUG
virtual void List(FILE* out, PRInt32 aIndent) const;
virtual void DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const;
virtual void List(FILE* out, PRInt32 aIndent) const
{
List(out, aIndent, EmptyCString());
}
virtual void DumpContent(FILE* out, PRInt32 aIndent, PRBool aDumpAll) const;
void List(FILE* out, PRInt32 aIndent, const nsCString& aPrefix) const;
void ListAttributes(FILE* out) const;
#endif
virtual nsIAtom* GetID() const;

Просмотреть файл

@ -1862,96 +1862,6 @@ nsGenericHTMLElement::GetBaseTarget(nsAString& aBaseTarget) const
}
}
#ifdef DEBUG
void
nsGenericHTMLElement::ListAttributes(FILE* out) const
{
PRUint32 index, count = GetAttrCount();
for (index = 0; index < count; index++) {
// name
const nsAttrName* name = GetAttrNameAt(index);
nsAutoString buffer;
name->LocalName()->ToString(buffer);
// value
nsAutoString value;
GetAttr(name->NamespaceID(), name->LocalName(), value);
buffer.AppendLiteral("=\"");
for (int i = value.Length(); i >= 0; --i) {
if (value[i] == PRUnichar('"'))
value.Insert(PRUnichar('\\'), PRUint32(i));
}
buffer.Append(value);
buffer.AppendLiteral("\"");
fputs(" ", out);
fputs(NS_LossyConvertUTF16toASCII(buffer).get(), out);
}
}
void
nsGenericHTMLElement::List(FILE* out, PRInt32 aIndent) const
{
PRInt32 index;
for (index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buf;
mNodeInfo->GetQualifiedName(buf);
fputs(NS_LossyConvertUTF16toASCII(buf).get(), out);
fprintf(out, "@%p", (void*)this);
ListAttributes(out);
fprintf(out, " intrinsicstate=[%08x]", IntrinsicState());
fprintf(out, " refcount=%d<", mRefCnt.get());
fputs("\n", out);
PRInt32 kids = GetChildCount();
for (index = 0; index < kids; index++) {
nsIContent *kid = GetChildAt(index);
kid->List(out, aIndent + 1);
}
for (index = aIndent; --index >= 0; ) fputs(" ", out);
fputs(">\n", out);
}
void
nsGenericHTMLElement::DumpContent(FILE* out, PRInt32 aIndent,
PRBool aDumpAll) const
{
PRInt32 index;
for (index = aIndent; --index >= 0; ) fputs(" ", out);
nsAutoString buf;
mNodeInfo->GetQualifiedName(buf);
fputs("<",out);
fputs(NS_LossyConvertUTF16toASCII(buf).get(), out);
if(aDumpAll) ListAttributes(out);
fputs(">",out);
if(aIndent) fputs("\n", out);
PRInt32 kids = GetChildCount();
for (index = 0; index < kids; index++) {
nsIContent *kid = GetChildAt(index);
PRInt32 indent = aIndent ? aIndent + 1 : 0;
kid->DumpContent(out, indent, aDumpAll);
}
for (index = aIndent; --index >= 0; ) fputs(" ", out);
fputs("</",out);
fputs(NS_LossyConvertUTF16toASCII(buf).get(), out);
fputs(">",out);
if(aIndent) fputs("\n", out);
}
#endif
PRBool
nsGenericHTMLElement::IsNodeOfType(PRUint32 aFlags) const
{

Просмотреть файл

@ -189,10 +189,6 @@ public:
PRBool aCompileEventHandlers);
virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
PRBool aNotify);
#ifdef DEBUG
virtual void List(FILE* out, PRInt32 aIndent) const;
virtual void DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const;
#endif
virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
virtual void RemoveFocus(nsPresContext *aPresContext);
virtual PRBool IsFocusable(PRInt32 *aTabIndex = nsnull);
@ -240,10 +236,6 @@ public:
*/
void GetBaseTarget(nsAString& aBaseTarget) const;
#ifdef DEBUG
void ListAttributes(FILE* out) const;
#endif
/**
* Get the primary form control frame for this content (see
* GetFormControlFrameFor)

Просмотреть файл

@ -1526,115 +1526,16 @@ nsXULElement::GetAttrCount() const
#ifdef DEBUG
static void
rdf_Indent(FILE* out, PRInt32 aIndent)
{
for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out);
}
void
nsXULElement::List(FILE* out, PRInt32 aIndent) const
{
PRUint32 i;
rdf_Indent(out, aIndent);
fputs("<XUL", out);
if (HasSlots()) fputs("*", out);
fputs(" ", out);
nsAutoString as;
mNodeInfo->GetQualifiedName(as);
fputs(NS_LossyConvertUTF16toASCII(as).get(), out);
fprintf(out, "@%p", (void *)this);
PRUint32 nattrs = GetAttrCount();
for (i = 0; i < nattrs; ++i) {
const nsAttrName* name = GetAttrNameAt(i);
nsAutoString v;
GetAttr(name->NamespaceID(), name->LocalName(), v);
fputs(" ", out);
nsAutoString s;
name->GetQualifiedName(s);
fputs(NS_LossyConvertUTF16toASCII(s).get(), out);
fputs("=", out);
fputs(NS_LossyConvertUTF16toASCII(v).get(), out);
nsCString prefix("<XUL");
if (HasSlots()) {
prefix.Append('*');
}
prefix.Append(' ');
PRUint32 nchildren = GetChildCount();
if (nchildren) {
fputs("\n", out);
for (i = 0; i < nchildren; ++i) {
GetChildAt(i)->List(out, aIndent + 1);
}
rdf_Indent(out, aIndent);
}
fputs(">\n", out);
// XXX sXBL/XBL2 issue! Owner or current document?
nsIDocument* doc = GetCurrentDoc();
if (doc) {
nsIBindingManager *bindingManager = doc->BindingManager();
nsCOMPtr<nsIDOMNodeList> anonymousChildren;
bindingManager->GetAnonymousNodesFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsXULElement*, this)),
getter_AddRefs(anonymousChildren));
if (anonymousChildren) {
PRUint32 length;
anonymousChildren->GetLength(&length);
if (length) {
rdf_Indent(out, aIndent);
fputs("anonymous-children<\n", out);
for (PRUint32 i2 = 0; i2 < length; ++i2) {
nsCOMPtr<nsIDOMNode> node;
anonymousChildren->Item(i2, getter_AddRefs(node));
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
child->List(out, aIndent + 1);
}
rdf_Indent(out, aIndent);
fputs(">\n", out);
}
}
PRBool hasContentList;
bindingManager->HasContentListFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsXULElement*, this)),
&hasContentList);
if (hasContentList) {
nsCOMPtr<nsIDOMNodeList> contentList;
bindingManager->GetContentListFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsXULElement*, this)),
getter_AddRefs(contentList));
NS_ASSERTION(contentList != nsnull, "oops, binding manager lied");
PRUint32 length;
contentList->GetLength(&length);
if (length) {
rdf_Indent(out, aIndent);
fputs("content-list<\n", out);
for (PRUint32 i2 = 0; i2 < length; ++i2) {
nsCOMPtr<nsIDOMNode> node;
contentList->Item(i2, getter_AddRefs(node));
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
child->List(out, aIndent + 1);
}
rdf_Indent(out, aIndent);
fputs(">\n", out);
}
}
}
nsGenericElement::List(out, aIndent, prefix);
}
#endif