зеркало из https://github.com/mozilla/gecko-dev.git
Bug 958596 - Add a Describe() method to nsIContent. r=bz
This commit is contained in:
Родитель
1333bc0a0f
Коммит
5bde931383
|
@ -492,6 +492,8 @@ public:
|
|||
void ListAttributes(FILE* out) const;
|
||||
#endif
|
||||
|
||||
void Describe(nsAString& aOutDescription) const MOZ_OVERRIDE;
|
||||
|
||||
/*
|
||||
* Attribute Mapping Helpers
|
||||
*/
|
||||
|
@ -514,6 +516,8 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
void DescribeAttribute(uint32_t index, nsAString& aOutDescription) const;
|
||||
|
||||
static bool
|
||||
FindAttributeDependence(const nsIAtom* aAttribute,
|
||||
const MappedAttributeEntry* const aMaps[],
|
||||
|
|
|
@ -950,6 +950,15 @@ public:
|
|||
bool aDumpAll = true) const = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Append to aOutDescription a short (preferably one line) string
|
||||
* describing the content.
|
||||
* Currently implemented for elements only.
|
||||
*/
|
||||
virtual void Describe(nsAString& aOutDescription) const {
|
||||
aOutDescription = NS_LITERAL_STRING("(not an element)");
|
||||
}
|
||||
|
||||
enum ETabFocusType {
|
||||
//eTabFocus_textControlsMask = (1<<0), // unused - textboxes always tabbable
|
||||
eTabFocus_formElementsMask = (1<<1), // non-text form elements
|
||||
|
|
|
@ -2132,30 +2132,35 @@ Element::GetAttrCount() const
|
|||
return mAttrsAndChildren.AttrCount();
|
||||
}
|
||||
|
||||
void
|
||||
Element::DescribeAttribute(uint32_t index, nsAString& aOutDescription) const
|
||||
{
|
||||
// name
|
||||
mAttrsAndChildren.AttrNameAt(index)->GetQualifiedName(aOutDescription);
|
||||
|
||||
// value
|
||||
aOutDescription.AppendLiteral("=\"");
|
||||
nsAutoString value;
|
||||
mAttrsAndChildren.AttrAt(index)->ToString(value);
|
||||
for (int i = value.Length(); i >= 0; --i) {
|
||||
if (value[i] == char16_t('"'))
|
||||
value.Insert(char16_t('\\'), uint32_t(i));
|
||||
}
|
||||
aOutDescription.Append(value);
|
||||
aOutDescription.AppendLiteral("\"");
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void
|
||||
Element::ListAttributes(FILE* out) const
|
||||
{
|
||||
uint32_t 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] == char16_t('"'))
|
||||
value.Insert(char16_t('\\'), uint32_t(i));
|
||||
}
|
||||
buffer.Append(value);
|
||||
buffer.AppendLiteral("\"");
|
||||
nsAutoString attributeDescription;
|
||||
DescribeAttribute(index, attributeDescription);
|
||||
|
||||
fputs(" ", out);
|
||||
fputs(NS_LossyConvertUTF16toASCII(buffer).get(), out);
|
||||
fputs(NS_LossyConvertUTF16toASCII(attributeDescription).get(), out);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2279,6 +2284,21 @@ Element::DumpContent(FILE* out, int32_t aIndent,
|
|||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
Element::Describe(nsAString& aOutDescription) const
|
||||
{
|
||||
aOutDescription.Append(mNodeInfo->QualifiedName());
|
||||
aOutDescription.AppendPrintf("@%p", (void *)this);
|
||||
|
||||
uint32_t index, count = mAttrsAndChildren.AttrCount();
|
||||
for (index = 0; index < count; index++) {
|
||||
aOutDescription.Append(' ');
|
||||
nsAutoString attributeDescription;
|
||||
DescribeAttribute(index, attributeDescription);
|
||||
aOutDescription.Append(attributeDescription);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Element::CheckHandleEventForLinksPrecondition(nsEventChainVisitor& aVisitor,
|
||||
nsIURI** aURI) const
|
||||
|
|
Загрузка…
Ссылка в новой задаче