Bug 1181297 - Add debug descriptor to nsINode. r=smaug

--HG--
extra : rebase_source : bd60af0462be0c276e5732aa42cd1bc524541152
This commit is contained in:
Benoit Girard 2015-07-08 15:58:07 -04:00
Родитель 072f83b8a1
Коммит 9c4edf5571
2 изменённых файлов: 38 добавлений и 1 удалений

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

@ -422,6 +422,36 @@ nsINode::IsInAnonymousSubtree() const
return AsContent()->IsInAnonymousSubtree();
}
std::ostream&
operator<<(std::ostream& aStream, const nsINode& aNode)
{
nsAutoString elemDesc;
const nsINode* curr = &aNode;
while (curr) {
const nsString& localName = curr->LocalName();
nsString id;
if (curr->IsElement()) {
curr->AsElement()->GetId(id);
}
if (!elemDesc.IsEmpty()) {
elemDesc = elemDesc + NS_LITERAL_STRING(".");
}
elemDesc = elemDesc + localName;
if (!id.IsEmpty()) {
elemDesc = elemDesc + NS_LITERAL_STRING("['") + id +
NS_LITERAL_STRING("']");
}
curr = curr->GetParentNode();
}
NS_ConvertUTF16toUTF8 str(elemDesc);
return aStream << str.get();
}
bool
nsINode::IsAnonymousContentInSVGUseSubtree() const
{

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

@ -22,6 +22,7 @@
#include "js/TypeDecls.h" // for Handle, Value, JSObject, JSContext
#include "mozilla/dom/DOMString.h"
#include "mozilla/dom/BindingDeclarations.h"
#include <iosfwd>
// Including 'windows.h' will #define GetClassInfo to something else.
#ifdef XP_WIN
@ -582,6 +583,12 @@ public:
return mNodeInfo->NamespaceID() == aNamespace;
}
/**
* Print a debugger friendly descriptor of this element. This will describe
* the position of this element in the document.
*/
friend std::ostream& operator<<(std::ostream& aStream, const nsINode& aNode);
protected:
// These 2 methods are useful for the recursive templates IsHTMLElement,
// IsSVGElement, etc.
@ -1722,7 +1729,7 @@ public:
mNodeInfo->GetPrefix(aPrefix);
}
#endif
void GetLocalName(mozilla::dom::DOMString& aLocalName)
void GetLocalName(mozilla::dom::DOMString& aLocalName) const
{
const nsString& localName = LocalName();
if (localName.IsVoid()) {