зеркало из 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
|
// baseURI
|
||||||
#include "nsIXMLDocument.h"
|
#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)
|
nsChildContentList::nsChildContentList(nsIContent *aContent)
|
||||||
|
@ -3284,6 +3298,64 @@ nsGenericContainerElement::List(FILE* out, PRInt32 aIndent) const
|
||||||
}
|
}
|
||||||
fputs(">\n", out);
|
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;
|
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.
|
// 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 GetContentListFor(nsIContent* aContent, nsIDOMNodeList** aResult) = 0;
|
||||||
NS_IMETHOD SetContentListFor(nsIContent* aContent, nsISupportsArray* aList)=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 GetAnonymousNodesFor(nsIContent* aContent, nsIDOMNodeList** aResult) = 0;
|
||||||
NS_IMETHOD SetAnonymousNodesFor(nsIContent* aContent, nsISupportsArray* aList) = 0;
|
NS_IMETHOD SetAnonymousNodesFor(nsIContent* aContent, nsISupportsArray* aList) = 0;
|
||||||
|
|
|
@ -309,6 +309,7 @@ public:
|
||||||
|
|
||||||
NS_IMETHOD GetContentListFor(nsIContent* aContent, nsIDOMNodeList** aResult);
|
NS_IMETHOD GetContentListFor(nsIContent* aContent, nsIDOMNodeList** aResult);
|
||||||
NS_IMETHOD SetContentListFor(nsIContent* aContent, nsISupportsArray* aList);
|
NS_IMETHOD SetContentListFor(nsIContent* aContent, nsISupportsArray* aList);
|
||||||
|
NS_IMETHOD HasContentListFor(nsIContent* aContent, PRBool* aResult);
|
||||||
|
|
||||||
NS_IMETHOD GetAnonymousNodesFor(nsIContent* aContent, nsIDOMNodeList** aResult);
|
NS_IMETHOD GetAnonymousNodesFor(nsIContent* aContent, nsIDOMNodeList** aResult);
|
||||||
NS_IMETHOD SetAnonymousNodesFor(nsIContent* aContent, nsISupportsArray* aList);
|
NS_IMETHOD SetAnonymousNodesFor(nsIContent* aContent, nsISupportsArray* aList);
|
||||||
|
@ -717,6 +718,21 @@ nsBindingManager::SetContentListFor(nsIContent* aContent, nsISupportsArray* aLis
|
||||||
return NS_OK;
|
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
|
NS_IMETHODIMP
|
||||||
nsBindingManager::GetAnonymousNodesFor(nsIContent* aContent, nsIDOMNodeList** aResult)
|
nsBindingManager::GetAnonymousNodesFor(nsIContent* aContent, nsIDOMNodeList** aResult)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,10 +17,8 @@
|
||||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||||
* Rights Reserved.
|
* Rights Reserved.
|
||||||
*
|
*
|
||||||
* Original Author(s):
|
|
||||||
* Chris Waterson <waterson@netscape.com>
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
|
* Chris Waterson <waterson@netscape.com>
|
||||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||||
* Peter Annema <disttsc@bart.nl>
|
* Peter Annema <disttsc@bart.nl>
|
||||||
* Brendan Eich <brendan@mozilla.org>
|
* Brendan Eich <brendan@mozilla.org>
|
||||||
|
@ -3401,34 +3399,27 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(mDocument != nsnull, "bad content");
|
NS_PRECONDITION(mDocument != nsnull, "bad content");
|
||||||
|
|
||||||
nsresult rv;
|
PRInt32 i;
|
||||||
{
|
|
||||||
rdf_Indent(out, aIndent);
|
rdf_Indent(out, aIndent);
|
||||||
fputs("<XUL", out);
|
fputs("<XUL", out);
|
||||||
if (mSlots) fputs("*", out);
|
if (mSlots) fputs("*", out);
|
||||||
fputs(" ", out);
|
fputs(" ", out);
|
||||||
|
|
||||||
PRInt32 namespaceID;
|
|
||||||
NodeInfo()->GetNamespaceID(namespaceID);
|
|
||||||
|
|
||||||
if (namespaceID == kNameSpaceID_Unknown) {
|
|
||||||
fputs("unknown:", out);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsAutoString as;
|
nsAutoString as;
|
||||||
NodeInfo()->GetQualifiedName(as);
|
NodeInfo()->GetQualifiedName(as);
|
||||||
fputs(as, out);
|
fputs(NS_ConvertUCS2toUTF8(as).get(), out);
|
||||||
}
|
|
||||||
|
fprintf(out, "@%p", this);
|
||||||
|
|
||||||
{
|
|
||||||
PRInt32 nattrs;
|
PRInt32 nattrs;
|
||||||
|
GetAttributeCount(nattrs);
|
||||||
|
|
||||||
if (NS_SUCCEEDED(rv = GetAttributeCount(nattrs))) {
|
for (i = 0; i < nattrs; ++i) {
|
||||||
for (PRInt32 i = 0; i < nattrs; ++i) {
|
nsCOMPtr<nsIAtom> attr;
|
||||||
nsIAtom* attr = nsnull;
|
|
||||||
nsCOMPtr<nsIAtom> prefix;
|
nsCOMPtr<nsIAtom> prefix;
|
||||||
PRInt32 nameSpaceID;
|
PRInt32 nameSpaceID;
|
||||||
GetAttributeNameAt(i, nameSpaceID, attr, *getter_AddRefs(prefix));
|
GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attr), *getter_AddRefs(prefix));
|
||||||
|
|
||||||
nsAutoString v;
|
nsAutoString v;
|
||||||
GetAttribute(nameSpaceID, attr, v);
|
GetAttribute(nameSpaceID, attr, v);
|
||||||
|
@ -3440,40 +3431,89 @@ nsXULElement::List(FILE* out, PRInt32 aIndent) const
|
||||||
if (prefix) {
|
if (prefix) {
|
||||||
prefix->ToString(s);
|
prefix->ToString(s);
|
||||||
|
|
||||||
fputs(s, out);
|
fputs(NS_ConvertUCS2toUTF8(s).get(), out);
|
||||||
fputs(":", out);
|
fputs(":", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
attr->ToString(s);
|
attr->ToString(s);
|
||||||
NS_RELEASE(attr);
|
|
||||||
|
|
||||||
fputs(s, out);
|
fputs(NS_ConvertUCS2toUTF8(s).get(), out);
|
||||||
fputs("=", out);
|
fputs("=", out);
|
||||||
fputs(v, out);
|
fputs(NS_ConvertUCS2toUTF8(v).get(), out);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_FAILED(rv))
|
PRInt32 nchildren;
|
||||||
return rv;
|
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);
|
fputs(">\n", out);
|
||||||
|
|
||||||
{
|
if (mDocument) {
|
||||||
PRInt32 nchildren;
|
nsCOMPtr<nsIBindingManager> bindingManager;
|
||||||
if (NS_FAILED(rv = ChildCount(nchildren)))
|
mDocument->GetBindingManager(getter_AddRefs(bindingManager));
|
||||||
return rv;
|
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) {
|
if (anonymousChildren) {
|
||||||
nsIContent* child;
|
PRUint32 length;
|
||||||
if (NS_FAILED(rv = ChildAt(i, child)))
|
anonymousChildren->GetLength(&length);
|
||||||
return rv;
|
if (length) {
|
||||||
|
rdf_Indent(out, aIndent);
|
||||||
|
fputs("anonymous-children<\n", out);
|
||||||
|
|
||||||
rv = child->List(out, aIndent + 1);
|
for (PRUint32 i2 = 0; i2 < length; ++i2) {
|
||||||
NS_RELEASE(child);
|
nsCOMPtr<nsIDOMNode> node;
|
||||||
|
anonymousChildren->Item(i2, getter_AddRefs(node));
|
||||||
|
nsCOMPtr<nsIContent> child = do_QueryInterface(node);
|
||||||
|
child->List(out, aIndent + 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (NS_FAILED(rv))
|
rdf_Indent(out, aIndent);
|
||||||
return rv;
|
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) {
|
if (0 != mState) {
|
||||||
fprintf(out, " [state=%08x]", mState);
|
fprintf(out, " [state=%08x]", mState);
|
||||||
}
|
}
|
||||||
fprintf(out, " sc=%p", mStyleContext);
|
fprintf(out, " [content=%p]", mContent);
|
||||||
|
fprintf(out, " [sc=%p]", mStyleContext);
|
||||||
|
|
||||||
// Output the children
|
// Output the children
|
||||||
nsIAtom* listName = nsnull;
|
nsIAtom* listName = nsnull;
|
||||||
|
|
|
@ -2319,6 +2319,34 @@ PRInt32 nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#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
|
// Debugging
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const
|
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) {
|
if (0 != mState) {
|
||||||
fprintf(out, " [state=%08x]", mState);
|
fprintf(out, " [state=%08x]", mState);
|
||||||
}
|
}
|
||||||
|
fprintf(out, " [content=%p]", mContent);
|
||||||
fputs("\n", out);
|
fputs("\n", out);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1111,7 +1111,8 @@ nsContainerFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent)
|
||||||
if (0 != mState) {
|
if (0 != mState) {
|
||||||
fprintf(out, " [state=%08x]", mState);
|
fprintf(out, " [state=%08x]", mState);
|
||||||
}
|
}
|
||||||
fprintf(out, " sc=%p", mStyleContext);
|
fprintf(out, " [content=%p]", mContent);
|
||||||
|
fprintf(out, " [sc=%p]", mStyleContext);
|
||||||
|
|
||||||
// Output the children
|
// Output the children
|
||||||
nsIAtom* listName = nsnull;
|
nsIAtom* listName = nsnull;
|
||||||
|
|
|
@ -2319,6 +2319,34 @@ PRInt32 nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#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
|
// Debugging
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsFrame::List(nsIPresContext* aPresContext, FILE* out, PRInt32 aIndent) const
|
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) {
|
if (0 != mState) {
|
||||||
fprintf(out, " [state=%08x]", mState);
|
fprintf(out, " [state=%08x]", mState);
|
||||||
}
|
}
|
||||||
|
fprintf(out, " [content=%p]", mContent);
|
||||||
fputs("\n", out);
|
fputs("\n", out);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче