зеркало из https://github.com/mozilla/pjs.git
Bug 92190. Add anonymous children to nsIContent::List() output, add gdb-callable routines for listing frame and content trees. r=hyatt, sr=jst
This commit is contained in:
Родитель
a79dbc6f96
Коммит
232d08fd54
|
@ -83,6 +83,20 @@
|
|||
// baseURI
|
||||
#include "nsIXMLDocument.h"
|
||||
|
||||
#ifdef DEBUG_waterson
|
||||
|
||||
/**
|
||||
* List a content tree to stdout. Meant to be called from gdb.
|
||||
*/
|
||||
void
|
||||
DebugListContentTree(nsIContent* aElement)
|
||||
{
|
||||
aElement->List(stdout, 0);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsChildContentList::nsChildContentList(nsIContent *aContent)
|
||||
|
@ -3284,6 +3298,64 @@ nsGenericContainerElement::List(FILE* out, PRInt32 aIndent) const
|
|||
}
|
||||
fputs(">\n", out);
|
||||
|
||||
if (mDocument) {
|
||||
nsCOMPtr<nsIBindingManager> bindingManager;
|
||||
mDocument->GetBindingManager(getter_AddRefs(bindingManager));
|
||||
if (bindingManager) {
|
||||
nsCOMPtr<nsIDOMNodeList> anonymousChildren;
|
||||
bindingManager->GetAnonymousNodesFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsGenericContainerElement*, this)),
|
||||
getter_AddRefs(anonymousChildren));
|
||||
|
||||
if (anonymousChildren) {
|
||||
PRUint32 length;
|
||||
anonymousChildren->GetLength(&length);
|
||||
if (length) {
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
fputs("anonymous-children<\n", out);
|
||||
|
||||
for (PRUint32 i = 0; i < length; ++i) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
anonymousChildren->Item(i, getter_AddRefs(node));
|
||||
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
|
||||
child->List(out, aIndent + 1);
|
||||
}
|
||||
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
fputs(">\n", out);
|
||||
}
|
||||
}
|
||||
|
||||
PRBool hasContentList;
|
||||
bindingManager->HasContentListFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsGenericContainerElement*, this)),
|
||||
&hasContentList);
|
||||
|
||||
if (hasContentList) {
|
||||
nsCOMPtr<nsIDOMNodeList> contentList;
|
||||
bindingManager->GetContentListFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsGenericContainerElement*, this)),
|
||||
getter_AddRefs(contentList));
|
||||
|
||||
NS_ASSERTION(contentList != nsnull, "oops, binding manager lied");
|
||||
|
||||
PRUint32 length;
|
||||
contentList->GetLength(&length);
|
||||
if (length) {
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
fputs("content-list<\n", out);
|
||||
|
||||
for (PRUint32 i = 0; i < length; ++i) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
contentList->Item(i, getter_AddRefs(node));
|
||||
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
|
||||
child->List(out, aIndent + 1);
|
||||
}
|
||||
|
||||
for (index = aIndent; --index >= 0; ) fputs(" ", out);
|
||||
fputs(">\n", out);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ public:
|
|||
// For a given element with an insertion point child, returns a flat list of all the real children.
|
||||
NS_IMETHOD GetContentListFor(nsIContent* aContent, nsIDOMNodeList** aResult) = 0;
|
||||
NS_IMETHOD SetContentListFor(nsIContent* aContent, nsISupportsArray* aList)=0;
|
||||
NS_IMETHOD HasContentListFor(nsIContent* aContent, PRBool* aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetAnonymousNodesFor(nsIContent* aContent, nsIDOMNodeList** aResult) = 0;
|
||||
NS_IMETHOD SetAnonymousNodesFor(nsIContent* aContent, nsISupportsArray* aList) = 0;
|
||||
|
|
|
@ -309,6 +309,7 @@ public:
|
|||
|
||||
NS_IMETHOD GetContentListFor(nsIContent* aContent, nsIDOMNodeList** aResult);
|
||||
NS_IMETHOD SetContentListFor(nsIContent* aContent, nsISupportsArray* aList);
|
||||
NS_IMETHOD HasContentListFor(nsIContent* aContent, PRBool* aResult);
|
||||
|
||||
NS_IMETHOD GetAnonymousNodesFor(nsIContent* aContent, nsIDOMNodeList** aResult);
|
||||
NS_IMETHOD SetAnonymousNodesFor(nsIContent* aContent, nsISupportsArray* aList);
|
||||
|
@ -717,6 +718,21 @@ nsBindingManager::SetContentListFor(nsIContent* aContent, nsISupportsArray* aLis
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::HasContentListFor(nsIContent* aContent, PRBool* aResult)
|
||||
{
|
||||
*aResult = PR_FALSE;
|
||||
if (mContentListTable) {
|
||||
nsISupportsKey key(aContent);
|
||||
nsCOMPtr<nsIDOMNodeList> list =
|
||||
NS_STATIC_CAST(nsIDOMNodeList*, mContentListTable->Get(&key));
|
||||
|
||||
*aResult = (list != nsnull);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBindingManager::GetAnonymousNodesFor(nsIContent* aContent, nsIDOMNodeList** aResult)
|
||||
{
|
||||
|
|
|
@ -17,10 +17,8 @@
|
|||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author(s):
|
||||
* Chris Waterson <waterson@netscape.com>
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Waterson <waterson@netscape.com>
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* Peter Annema <disttsc@bart.nl>
|
||||
* Brendan Eich <brendan@mozilla.org>
|
||||
|
@ -3401,34 +3399,27 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const
|
|||
{
|
||||
NS_PRECONDITION(mDocument != nsnull, "bad content");
|
||||
|
||||
nsresult rv;
|
||||
{
|
||||
PRInt32 i;
|
||||
|
||||
rdf_Indent(out, aIndent);
|
||||
fputs("<XUL", out);
|
||||
if (mSlots) fputs("*", out);
|
||||
fputs(" ", out);
|
||||
|
||||
PRInt32 namespaceID;
|
||||
NodeInfo()->GetNamespaceID(namespaceID);
|
||||
|
||||
if (namespaceID == kNameSpaceID_Unknown) {
|
||||
fputs("unknown:", out);
|
||||
}
|
||||
|
||||
nsAutoString as;
|
||||
NodeInfo()->GetQualifiedName(as);
|
||||
fputs(as, out);
|
||||
}
|
||||
fputs(NS_ConvertUCS2toUTF8(as).get(), out);
|
||||
|
||||
fprintf(out, "@%p", this);
|
||||
|
||||
{
|
||||
PRInt32 nattrs;
|
||||
GetAttributeCount(nattrs);
|
||||
|
||||
if (NS_SUCCEEDED(rv = GetAttributeCount(nattrs))) {
|
||||
for (PRInt32 i = 0; i < nattrs; ++i) {
|
||||
nsIAtom* attr = nsnull;
|
||||
for (i = 0; i < nattrs; ++i) {
|
||||
nsCOMPtr<nsIAtom> attr;
|
||||
nsCOMPtr<nsIAtom> prefix;
|
||||
PRInt32 nameSpaceID;
|
||||
GetAttributeNameAt(i, nameSpaceID, attr, *getter_AddRefs(prefix));
|
||||
GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attr), *getter_AddRefs(prefix));
|
||||
|
||||
nsAutoString v;
|
||||
GetAttribute(nameSpaceID, attr, v);
|
||||
|
@ -3440,40 +3431,89 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const
|
|||
if (prefix) {
|
||||
prefix->ToString(s);
|
||||
|
||||
fputs(s, out);
|
||||
fputs(NS_ConvertUCS2toUTF8(s).get(), out);
|
||||
fputs(":", out);
|
||||
}
|
||||
|
||||
attr->ToString(s);
|
||||
NS_RELEASE(attr);
|
||||
|
||||
fputs(s, out);
|
||||
fputs(NS_ConvertUCS2toUTF8(s).get(), out);
|
||||
fputs("=", out);
|
||||
fputs(v, out);
|
||||
}
|
||||
fputs(NS_ConvertUCS2toUTF8(v).get(), out);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
PRInt32 nchildren;
|
||||
ChildCount(nchildren);
|
||||
|
||||
if (nchildren) {
|
||||
fputs("\n", out);
|
||||
|
||||
for (i = 0; i < nchildren; ++i) {
|
||||
nsCOMPtr<nsIContent> child;
|
||||
ChildAt(i, *getter_AddRefs(child));
|
||||
|
||||
child->List(out, aIndent + 1);
|
||||
}
|
||||
|
||||
rdf_Indent(out, aIndent);
|
||||
}
|
||||
fputs(">\n", out);
|
||||
|
||||
{
|
||||
PRInt32 nchildren;
|
||||
if (NS_FAILED(rv = ChildCount(nchildren)))
|
||||
return rv;
|
||||
if (mDocument) {
|
||||
nsCOMPtr<nsIBindingManager> bindingManager;
|
||||
mDocument->GetBindingManager(getter_AddRefs(bindingManager));
|
||||
if (bindingManager) {
|
||||
nsCOMPtr<nsIDOMNodeList> anonymousChildren;
|
||||
bindingManager->GetAnonymousNodesFor(NS_STATIC_CAST(nsIContent*, NS_CONST_CAST(nsXULElement*, this)),
|
||||
getter_AddRefs(anonymousChildren));
|
||||
|
||||
for (PRInt32 i = 0; i < nchildren; ++i) {
|
||||
nsIContent* child;
|
||||
if (NS_FAILED(rv = ChildAt(i, child)))
|
||||
return rv;
|
||||
if (anonymousChildren) {
|
||||
PRUint32 length;
|
||||
anonymousChildren->GetLength(&length);
|
||||
if (length) {
|
||||
rdf_Indent(out, aIndent);
|
||||
fputs("anonymous-children<\n", out);
|
||||
|
||||
rv = child->List(out, aIndent + 1);
|
||||
NS_RELEASE(child);
|
||||
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);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1111,7 +1111,8 @@ nsContainerFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent)
|
|||
if (0 != mState) {
|
||||
fprintf(out, " [state=%08x]", mState);
|
||||
}
|
||||
fprintf(out, " sc=%p", mStyleContext);
|
||||
fprintf(out, " [content=%p]", mContent);
|
||||
fprintf(out, " [sc=%p]", mStyleContext);
|
||||
|
||||
// Output the children
|
||||
nsIAtom* listName = nsnull;
|
||||
|
|
|
@ -2319,6 +2319,34 @@ PRInt32 nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
|
|||
}
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
||||
#ifdef DEBUG_waterson
|
||||
|
||||
/**
|
||||
* List a single frame to stdout. Meant to be called from gdb.
|
||||
*/
|
||||
void
|
||||
DebugListFrame(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
||||
{
|
||||
((nsFrame*) aFrame)->List(aPresContext, stdout, 0);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* List a frame tree to stdout. Meant to be called from gdb.
|
||||
*/
|
||||
void
|
||||
DebugListFrameTree(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
||||
{
|
||||
nsIFrameDebug* fdbg;
|
||||
aFrame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**) &fdbg);
|
||||
if (fdbg)
|
||||
fdbg->List(aPresContext, stdout, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// Debugging
|
||||
NS_IMETHODIMP
|
||||
nsFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const
|
||||
|
@ -2337,6 +2365,7 @@ nsFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const
|
|||
if (0 != mState) {
|
||||
fprintf(out, " [state=%08x]", mState);
|
||||
}
|
||||
fprintf(out, " [content=%p]", mContent);
|
||||
fputs("\n", out);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1111,7 +1111,8 @@ nsContainerFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent)
|
|||
if (0 != mState) {
|
||||
fprintf(out, " [state=%08x]", mState);
|
||||
}
|
||||
fprintf(out, " sc=%p", mStyleContext);
|
||||
fprintf(out, " [content=%p]", mContent);
|
||||
fprintf(out, " [sc=%p]", mStyleContext);
|
||||
|
||||
// Output the children
|
||||
nsIAtom* listName = nsnull;
|
||||
|
|
|
@ -2319,6 +2319,34 @@ PRInt32 nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
|
|||
}
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
|
||||
#ifdef DEBUG_waterson
|
||||
|
||||
/**
|
||||
* List a single frame to stdout. Meant to be called from gdb.
|
||||
*/
|
||||
void
|
||||
DebugListFrame(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
||||
{
|
||||
((nsFrame*) aFrame)->List(aPresContext, stdout, 0);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* List a frame tree to stdout. Meant to be called from gdb.
|
||||
*/
|
||||
void
|
||||
DebugListFrameTree(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
||||
{
|
||||
nsIFrameDebug* fdbg;
|
||||
aFrame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**) &fdbg);
|
||||
if (fdbg)
|
||||
fdbg->List(aPresContext, stdout, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// Debugging
|
||||
NS_IMETHODIMP
|
||||
nsFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const
|
||||
|
@ -2337,6 +2365,7 @@ nsFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const
|
|||
if (0 != mState) {
|
||||
fprintf(out, " [state=%08x]", mState);
|
||||
}
|
||||
fprintf(out, " [content=%p]", mContent);
|
||||
fputs("\n", out);
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче