зеркало из https://github.com/mozilla/pjs.git
Support SizeOf methods
This commit is contained in:
Родитель
b0d6fc171e
Коммит
2738c38f7f
|
@ -26,7 +26,6 @@
|
|||
|
||||
// Forward declarations
|
||||
class nsIAtom;
|
||||
class nsIContentDelegate;
|
||||
class nsIDocument;
|
||||
class nsIPresContext;
|
||||
class nsString;
|
||||
|
@ -37,6 +36,7 @@ class nsIDOMEvent;
|
|||
class nsIContent;
|
||||
class nsISupportsArray;
|
||||
class nsIDOMRange;
|
||||
class nsISizeOfHandler;
|
||||
|
||||
// IID for the nsIContent interface
|
||||
#define NS_ICONTENT_IID \
|
||||
|
@ -187,6 +187,23 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const = 0;
|
||||
|
||||
/**
|
||||
* Get the size of the content object. The size value should include
|
||||
* all subordinate data referenced by the content that is not
|
||||
* accounted for by child content. However, this value should not
|
||||
* include the frame objects, style contexts, views or other data
|
||||
* that lies logically outside the content model.
|
||||
*
|
||||
* If the implementation so chooses, instead of returning the total
|
||||
* subordinate data it may instead use the sizeof handler to store
|
||||
* away subordinate data under its own key so that the subordinate
|
||||
* data may be tabulated independently of the frame itself.
|
||||
*
|
||||
* The caller is responsible for recursing over all children that
|
||||
* the content contains.
|
||||
*/
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const = 0;
|
||||
|
||||
/**
|
||||
* List the content (and anything it contains) out to the given
|
||||
* file stream. Use aIndent as the base indent during formatting.
|
||||
|
|
|
@ -170,6 +170,17 @@ public:
|
|||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const {
|
||||
return mInner.GetRangeList(aResult);
|
||||
}
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
*aResult = sizeof(*this);
|
||||
#else
|
||||
*aResult = 0;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetText(const nsTextFragment*& aFragmentsResult,
|
||||
PRInt32& aNumFragmentsResult)
|
||||
|
|
|
@ -202,6 +202,17 @@ public:
|
|||
{ return mInner.RangeRemove(aRange); }
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const
|
||||
{ return mInner.GetRangeList(aResult); }
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
*aResult = sizeof(*this);
|
||||
#else
|
||||
*aResult = 0;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
nsGenericContainerElement mInner;
|
||||
|
|
|
@ -821,6 +821,22 @@ nsGenericDOMDataNode::GetRangeList(nsVoidArray*& aResult) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
PRUint32 sum = 0;
|
||||
#ifdef DEBUG
|
||||
sum += (PRUint32) aInstanceSize;
|
||||
sum += mText.GetLength() *
|
||||
(mText.Is2b() ? sizeof(PRUnichar) : sizeof(char));
|
||||
#endif
|
||||
*aResult = sum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -172,6 +172,8 @@ struct nsGenericDOMDataNode {
|
|||
nsresult RangeAdd(nsIDOMRange& aRange);
|
||||
nsresult RangeRemove(nsIDOMRange& aRange);
|
||||
nsresult GetRangeList(nsVoidArray*& aResult) const;
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const;
|
||||
|
||||
// Implementation for nsIContent
|
||||
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
|
@ -476,7 +478,10 @@ struct nsGenericDOMDataNode {
|
|||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
}
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const { \
|
||||
return _g.SizeOf(aSizer, aResult, sizeof(*this)); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMText API by forwarding the methods to a
|
||||
|
|
|
@ -883,6 +883,21 @@ nsGenericElement::GetRangeList(nsVoidArray*& aResult) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
*aResult = (PRUint32) aInstanceSize;
|
||||
#else
|
||||
*aResult = 0;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsresult
|
||||
|
@ -1351,6 +1366,20 @@ struct nsGenericAttribute
|
|||
NS_IF_RELEASE(mName);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
PRUint32 sum = sizeof(*this) - sizeof(mValue);
|
||||
PRUint32 ssize;
|
||||
mValue.SizeOf(aSizer, &ssize);
|
||||
sum += ssize;
|
||||
*aResult = sum;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
PRInt32 mNameSpaceID;
|
||||
nsIAtom* mName;
|
||||
nsString mValue;
|
||||
|
@ -2156,3 +2185,36 @@ nsGenericContainerElement::FinishConvertToXIF(nsXIFConverter& aConverter) const
|
|||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericContainerElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
PRUint32 sum = 0;
|
||||
#ifdef DEBUG
|
||||
sum += aInstanceSize;
|
||||
if (mAttributes) {
|
||||
// Add in array of attributes size
|
||||
PRUint32 asize;
|
||||
mAttributes->SizeOf(aSizer, &asize);
|
||||
sum += asize;
|
||||
|
||||
// Add in each attributes size
|
||||
PRInt32 i, n = mAttributes->Count();
|
||||
for (i = 0; i < n; i++) {
|
||||
const nsGenericAttribute* attr = (const nsGenericAttribute*)
|
||||
mAttributes->ElementAt(i);
|
||||
if (attr) {
|
||||
PRUint32 asum = 0;
|
||||
attr->SizeOf(aSizer, &asum);
|
||||
sum += asum;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*aResult = sum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -163,6 +163,8 @@ public:
|
|||
nsresult RangeAdd(nsIDOMRange& aRange);
|
||||
nsresult RangeRemove(nsIDOMRange& aRange);
|
||||
nsresult GetRangeList(nsVoidArray*& aResult) const;
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const;
|
||||
|
||||
// Implementation for nsIJSScriptObject
|
||||
PRBool AddProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
|
@ -277,6 +279,8 @@ public:
|
|||
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const;
|
||||
|
||||
void ListAttributes(FILE* out) const;
|
||||
|
||||
|
@ -526,7 +530,10 @@ public:
|
|||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
}
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const { \
|
||||
return _g.SizeOf(aSizer, aResult, sizeof(*this)); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_ICONTENT_NO_SETPARENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
|
||||
|
@ -634,7 +641,10 @@ public:
|
|||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
}
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const { \
|
||||
return _g.SizeOf(aSizer, aResult, sizeof(*this)); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_ICONTENT_NO_SETDOCUMENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
|
||||
|
@ -742,7 +752,10 @@ public:
|
|||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
}
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const { \
|
||||
return _g.SizeOf(aSizer, aResult, sizeof(*this)); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_ICONTENT_NO_SETPARENT_NO_SETDOCUMENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
|
||||
|
@ -848,7 +861,10 @@ public:
|
|||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
}
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const { \
|
||||
return _g.SizeOf(aSizer, aResult, sizeof(*this)); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsIScriptObjectOwner API by forwarding the methods to a
|
||||
|
|
|
@ -131,6 +131,17 @@ public:
|
|||
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { aResult = 0; return NS_OK; }
|
||||
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { return NS_OK; }
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
*aResult = sizeof(*this);
|
||||
#else
|
||||
*aResult = 0;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
|
|
|
@ -573,18 +573,6 @@ nsGenericHTMLElement::GetNameSpaceID(PRInt32& aID) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//void
|
||||
//nsHTMLTagContent::SizeOfWithoutThis(nsISizeOfHandler* aHandler) const
|
||||
//{
|
||||
// if (!aHandler->HaveSeen(mTag)) {
|
||||
// mTag->SizeOf(aHandler);
|
||||
// }
|
||||
// if (!aHandler->HaveSeen(mAttributes)) {
|
||||
// mAttributes->SizeOf(aHandler);
|
||||
// }
|
||||
//}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::ParseAttributeString(const nsString& aStr,
|
||||
nsIAtom*& aName,
|
||||
|
@ -1233,6 +1221,26 @@ nsGenericHTMLElement::List(FILE* out, PRInt32 aIndent) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
PRUint32 sum = 0;
|
||||
#ifdef DEBUG
|
||||
sum += (PRUint32) aInstanceSize;
|
||||
if (mAttributes) {
|
||||
PRUint32 attrs = 0;
|
||||
mAttributes->SizeOf(aSizer, &attrs);
|
||||
sum += attrs;
|
||||
}
|
||||
#endif
|
||||
*aResult = sum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::ToHTML(FILE* out) const
|
||||
{
|
||||
|
|
|
@ -126,6 +126,8 @@ public:
|
|||
nsresult GetBaseTarget(nsString& aBaseTarget) const;
|
||||
nsresult ToHTMLString(nsString& aResult) const;
|
||||
nsresult ToHTML(FILE* out) const;
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const;
|
||||
|
||||
//----------------------------------------
|
||||
nsresult AttributeToString(nsIAtom* aAttribute,
|
||||
|
|
|
@ -175,6 +175,9 @@ public:
|
|||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const {
|
||||
return mInner.GetRangeList(aResult);
|
||||
}
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
return mInner.SizeOf(aSizer, aResult, sizeof(*this));
|
||||
}
|
||||
|
||||
// nsIHTMLContent
|
||||
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsISizeOfHandler.h"
|
||||
|
||||
//#define DEBUG_REFS
|
||||
|
||||
|
@ -204,6 +205,16 @@ struct HTMLAttribute {
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = sizeof(*this);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsIAtom* mAttribute;
|
||||
nsHTMLValue mValue;
|
||||
HTMLAttribute* mNext;
|
||||
|
@ -289,6 +300,16 @@ public:
|
|||
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
||||
|
||||
#ifdef DEBUG
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = sizeof(*this);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsIHTMLStyleSheet* mSheet;
|
||||
PRInt32 mUseCount;
|
||||
PRInt32 mAttrCount;
|
||||
|
@ -780,6 +801,8 @@ public:
|
|||
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
||||
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
|
||||
protected:
|
||||
virtual nsresult SetAttributeName(nsIAtom* aAttrName, PRBool& aFound);
|
||||
virtual nsresult UnsetAttributeName(nsIAtom* aAttrName, PRBool& aFound);
|
||||
|
@ -1460,6 +1483,41 @@ HTMLAttributesImpl::List(FILE* out, PRInt32 aIndent) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLAttributesImpl::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
PRUint32 sum = 0;
|
||||
#ifdef DEBUG
|
||||
sum = sizeof(*this);
|
||||
if (mAttrNames != mNameBuffer) {
|
||||
sum += sizeof(*mAttrNames) * mAttrSize;
|
||||
}
|
||||
if (mFirstUnmapped) {
|
||||
HTMLAttribute* ha = mFirstUnmapped;
|
||||
while (ha) {
|
||||
PRUint32 asum = 0;
|
||||
ha->SizeOf(aSizer, &asum);
|
||||
sum += asum;
|
||||
ha = ha->mNext;
|
||||
}
|
||||
}
|
||||
if (mMapped) {
|
||||
PRBool recorded;
|
||||
aSizer->RecordObject((void*)mMapped, &recorded);
|
||||
if (!recorded) {
|
||||
PRUint32 asum = 0;
|
||||
mMapped->SizeOf(aSizer, &asum);
|
||||
sum += asum;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*aResult = sum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern NS_HTML nsresult
|
||||
NS_NewHTMLAttributes(nsIHTMLAttributes** aInstancePtrResult)
|
||||
{
|
||||
|
|
|
@ -87,6 +87,8 @@ public:
|
|||
#endif
|
||||
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0;
|
||||
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const = 0;
|
||||
};
|
||||
|
||||
class nsIHTMLMappedAttributes : public nsISupports {
|
||||
|
|
|
@ -164,6 +164,17 @@ public:
|
|||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const {
|
||||
return mInner.GetRangeList(aResult);
|
||||
}
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
*aResult = sizeof(*this);
|
||||
#else
|
||||
*aResult = 0;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIXMLContent
|
||||
NS_IMETHOD SetContainingNameSpace(nsINameSpace* aNameSpace) {
|
||||
|
|
|
@ -289,7 +289,7 @@ public:
|
|||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const;
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
|
@ -2810,10 +2810,17 @@ RDFElementImpl::FinishConvertToXIF(nsXIFConverter& aConverter) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::SizeOf(nsISizeOfHandler* aHandler) const
|
||||
RDFElementImpl::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
PRUint32 sum = 0;
|
||||
#ifdef DEBUG
|
||||
sum += (PRUint32) sizeof(this);
|
||||
#endif
|
||||
*aResult = sum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
// Forward declarations
|
||||
class nsIAtom;
|
||||
class nsIContentDelegate;
|
||||
class nsIDocument;
|
||||
class nsIPresContext;
|
||||
class nsString;
|
||||
|
@ -37,6 +36,7 @@ class nsIDOMEvent;
|
|||
class nsIContent;
|
||||
class nsISupportsArray;
|
||||
class nsIDOMRange;
|
||||
class nsISizeOfHandler;
|
||||
|
||||
// IID for the nsIContent interface
|
||||
#define NS_ICONTENT_IID \
|
||||
|
@ -187,6 +187,23 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetAttributeCount(PRInt32& aCountResult) const = 0;
|
||||
|
||||
/**
|
||||
* Get the size of the content object. The size value should include
|
||||
* all subordinate data referenced by the content that is not
|
||||
* accounted for by child content. However, this value should not
|
||||
* include the frame objects, style contexts, views or other data
|
||||
* that lies logically outside the content model.
|
||||
*
|
||||
* If the implementation so chooses, instead of returning the total
|
||||
* subordinate data it may instead use the sizeof handler to store
|
||||
* away subordinate data under its own key so that the subordinate
|
||||
* data may be tabulated independently of the frame itself.
|
||||
*
|
||||
* The caller is responsible for recursing over all children that
|
||||
* the content contains.
|
||||
*/
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const = 0;
|
||||
|
||||
/**
|
||||
* List the content (and anything it contains) out to the given
|
||||
* file stream. Use aIndent as the base indent during formatting.
|
||||
|
|
|
@ -170,6 +170,17 @@ public:
|
|||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const {
|
||||
return mInner.GetRangeList(aResult);
|
||||
}
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
*aResult = sizeof(*this);
|
||||
#else
|
||||
*aResult = 0;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetText(const nsTextFragment*& aFragmentsResult,
|
||||
PRInt32& aNumFragmentsResult)
|
||||
|
|
|
@ -202,6 +202,17 @@ public:
|
|||
{ return mInner.RangeRemove(aRange); }
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const
|
||||
{ return mInner.GetRangeList(aResult); }
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
*aResult = sizeof(*this);
|
||||
#else
|
||||
*aResult = 0;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
nsGenericContainerElement mInner;
|
||||
|
|
|
@ -821,6 +821,22 @@ nsGenericDOMDataNode::GetRangeList(nsVoidArray*& aResult) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericDOMDataNode::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
PRUint32 sum = 0;
|
||||
#ifdef DEBUG
|
||||
sum += (PRUint32) aInstanceSize;
|
||||
sum += mText.GetLength() *
|
||||
(mText.Is2b() ? sizeof(PRUnichar) : sizeof(char));
|
||||
#endif
|
||||
*aResult = sum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -172,6 +172,8 @@ struct nsGenericDOMDataNode {
|
|||
nsresult RangeAdd(nsIDOMRange& aRange);
|
||||
nsresult RangeRemove(nsIDOMRange& aRange);
|
||||
nsresult GetRangeList(nsVoidArray*& aResult) const;
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const;
|
||||
|
||||
// Implementation for nsIContent
|
||||
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
|
@ -476,7 +478,10 @@ struct nsGenericDOMDataNode {
|
|||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
}
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const { \
|
||||
return _g.SizeOf(aSizer, aResult, sizeof(*this)); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsIDOMText API by forwarding the methods to a
|
||||
|
|
|
@ -883,6 +883,21 @@ nsGenericElement::GetRangeList(nsVoidArray*& aResult) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
*aResult = (PRUint32) aInstanceSize;
|
||||
#else
|
||||
*aResult = 0;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsresult
|
||||
|
@ -1351,6 +1366,20 @@ struct nsGenericAttribute
|
|||
NS_IF_RELEASE(mName);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
PRUint32 sum = sizeof(*this) - sizeof(mValue);
|
||||
PRUint32 ssize;
|
||||
mValue.SizeOf(aSizer, &ssize);
|
||||
sum += ssize;
|
||||
*aResult = sum;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
PRInt32 mNameSpaceID;
|
||||
nsIAtom* mName;
|
||||
nsString mValue;
|
||||
|
@ -2156,3 +2185,36 @@ nsGenericContainerElement::FinishConvertToXIF(nsXIFConverter& aConverter) const
|
|||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericContainerElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
PRUint32 sum = 0;
|
||||
#ifdef DEBUG
|
||||
sum += aInstanceSize;
|
||||
if (mAttributes) {
|
||||
// Add in array of attributes size
|
||||
PRUint32 asize;
|
||||
mAttributes->SizeOf(aSizer, &asize);
|
||||
sum += asize;
|
||||
|
||||
// Add in each attributes size
|
||||
PRInt32 i, n = mAttributes->Count();
|
||||
for (i = 0; i < n; i++) {
|
||||
const nsGenericAttribute* attr = (const nsGenericAttribute*)
|
||||
mAttributes->ElementAt(i);
|
||||
if (attr) {
|
||||
PRUint32 asum = 0;
|
||||
attr->SizeOf(aSizer, &asum);
|
||||
sum += asum;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*aResult = sum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -163,6 +163,8 @@ public:
|
|||
nsresult RangeAdd(nsIDOMRange& aRange);
|
||||
nsresult RangeRemove(nsIDOMRange& aRange);
|
||||
nsresult GetRangeList(nsVoidArray*& aResult) const;
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const;
|
||||
|
||||
// Implementation for nsIJSScriptObject
|
||||
PRBool AddProperty(JSContext *aContext, jsval aID, jsval *aVp);
|
||||
|
@ -277,6 +279,8 @@ public:
|
|||
nsresult BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const;
|
||||
|
||||
void ListAttributes(FILE* out) const;
|
||||
|
||||
|
@ -526,7 +530,10 @@ public:
|
|||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
}
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const { \
|
||||
return _g.SizeOf(aSizer, aResult, sizeof(*this)); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_ICONTENT_NO_SETPARENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
|
||||
|
@ -634,7 +641,10 @@ public:
|
|||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
}
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const { \
|
||||
return _g.SizeOf(aSizer, aResult, sizeof(*this)); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_ICONTENT_NO_SETDOCUMENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
|
||||
|
@ -742,7 +752,10 @@ public:
|
|||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
}
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const { \
|
||||
return _g.SizeOf(aSizer, aResult, sizeof(*this)); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_ICONTENT_NO_SETPARENT_NO_SETDOCUMENT_USING_GENERIC(_g) \
|
||||
NS_IMETHOD GetDocument(nsIDocument*& aResult) const { \
|
||||
|
@ -848,7 +861,10 @@ public:
|
|||
} \
|
||||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const { \
|
||||
return _g.GetRangeList(aResult); \
|
||||
}
|
||||
} \
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const { \
|
||||
return _g.SizeOf(aSizer, aResult, sizeof(*this)); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement the nsIScriptObjectOwner API by forwarding the methods to a
|
||||
|
|
|
@ -131,6 +131,17 @@ public:
|
|||
NS_IMETHOD GetAttributeCount(PRInt32& aResult) const { aResult = 0; return NS_OK; }
|
||||
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const { return NS_OK; }
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
*aResult = sizeof(*this);
|
||||
#else
|
||||
*aResult = 0;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
|
|
|
@ -573,18 +573,6 @@ nsGenericHTMLElement::GetNameSpaceID(PRInt32& aID) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//void
|
||||
//nsHTMLTagContent::SizeOfWithoutThis(nsISizeOfHandler* aHandler) const
|
||||
//{
|
||||
// if (!aHandler->HaveSeen(mTag)) {
|
||||
// mTag->SizeOf(aHandler);
|
||||
// }
|
||||
// if (!aHandler->HaveSeen(mAttributes)) {
|
||||
// mAttributes->SizeOf(aHandler);
|
||||
// }
|
||||
//}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::ParseAttributeString(const nsString& aStr,
|
||||
nsIAtom*& aName,
|
||||
|
@ -1233,6 +1221,26 @@ nsGenericHTMLElement::List(FILE* out, PRInt32 aIndent) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
PRUint32 sum = 0;
|
||||
#ifdef DEBUG
|
||||
sum += (PRUint32) aInstanceSize;
|
||||
if (mAttributes) {
|
||||
PRUint32 attrs = 0;
|
||||
mAttributes->SizeOf(aSizer, &attrs);
|
||||
sum += attrs;
|
||||
}
|
||||
#endif
|
||||
*aResult = sum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::ToHTML(FILE* out) const
|
||||
{
|
||||
|
|
|
@ -126,6 +126,8 @@ public:
|
|||
nsresult GetBaseTarget(nsString& aBaseTarget) const;
|
||||
nsresult ToHTMLString(nsString& aResult) const;
|
||||
nsresult ToHTML(FILE* out) const;
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult,
|
||||
size_t aInstanceSize) const;
|
||||
|
||||
//----------------------------------------
|
||||
nsresult AttributeToString(nsIAtom* aAttribute,
|
||||
|
|
|
@ -175,6 +175,9 @@ public:
|
|||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const {
|
||||
return mInner.GetRangeList(aResult);
|
||||
}
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
return mInner.SizeOf(aSizer, aResult, sizeof(*this));
|
||||
}
|
||||
|
||||
// nsIHTMLContent
|
||||
NS_IMPL_IHTMLCONTENT_USING_GENERIC(mInner)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsISizeOfHandler.h"
|
||||
|
||||
//#define DEBUG_REFS
|
||||
|
||||
|
@ -204,6 +205,16 @@ struct HTMLAttribute {
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = sizeof(*this);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsIAtom* mAttribute;
|
||||
nsHTMLValue mValue;
|
||||
HTMLAttribute* mNext;
|
||||
|
@ -289,6 +300,16 @@ public:
|
|||
|
||||
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
|
||||
|
||||
#ifdef DEBUG
|
||||
nsresult SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = sizeof(*this);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsIHTMLStyleSheet* mSheet;
|
||||
PRInt32 mUseCount;
|
||||
PRInt32 mAttrCount;
|
||||
|
@ -780,6 +801,8 @@ public:
|
|||
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
||||
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
|
||||
protected:
|
||||
virtual nsresult SetAttributeName(nsIAtom* aAttrName, PRBool& aFound);
|
||||
virtual nsresult UnsetAttributeName(nsIAtom* aAttrName, PRBool& aFound);
|
||||
|
@ -1460,6 +1483,41 @@ HTMLAttributesImpl::List(FILE* out, PRInt32 aIndent) const
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLAttributesImpl::SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const
|
||||
{
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
PRUint32 sum = 0;
|
||||
#ifdef DEBUG
|
||||
sum = sizeof(*this);
|
||||
if (mAttrNames != mNameBuffer) {
|
||||
sum += sizeof(*mAttrNames) * mAttrSize;
|
||||
}
|
||||
if (mFirstUnmapped) {
|
||||
HTMLAttribute* ha = mFirstUnmapped;
|
||||
while (ha) {
|
||||
PRUint32 asum = 0;
|
||||
ha->SizeOf(aSizer, &asum);
|
||||
sum += asum;
|
||||
ha = ha->mNext;
|
||||
}
|
||||
}
|
||||
if (mMapped) {
|
||||
PRBool recorded;
|
||||
aSizer->RecordObject((void*)mMapped, &recorded);
|
||||
if (!recorded) {
|
||||
PRUint32 asum = 0;
|
||||
mMapped->SizeOf(aSizer, &asum);
|
||||
sum += asum;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*aResult = sum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
extern NS_HTML nsresult
|
||||
NS_NewHTMLAttributes(nsIHTMLAttributes** aInstancePtrResult)
|
||||
{
|
||||
|
|
|
@ -87,6 +87,8 @@ public:
|
|||
#endif
|
||||
|
||||
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0;
|
||||
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const = 0;
|
||||
};
|
||||
|
||||
class nsIHTMLMappedAttributes : public nsISupports {
|
||||
|
|
|
@ -164,6 +164,17 @@ public:
|
|||
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const {
|
||||
return mInner.GetRangeList(aResult);
|
||||
}
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
*aResult = sizeof(*this);
|
||||
#else
|
||||
*aResult = 0;
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIXMLContent
|
||||
NS_IMETHOD SetContainingNameSpace(nsINameSpace* aNameSpace) {
|
||||
|
|
|
@ -289,7 +289,7 @@ public:
|
|||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const;
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
|
@ -2810,10 +2810,17 @@ RDFElementImpl::FinishConvertToXIF(nsXIFConverter& aConverter) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::SizeOf(nsISizeOfHandler* aHandler) const
|
||||
RDFElementImpl::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
PRUint32 sum = 0;
|
||||
#ifdef DEBUG
|
||||
sum += (PRUint32) sizeof(this);
|
||||
#endif
|
||||
*aResult = sum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -289,7 +289,7 @@ public:
|
|||
NS_IMETHOD BeginConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
NS_IMETHOD ConvertContentToXIF(nsXIFConverter& aConverter) const;
|
||||
NS_IMETHOD FinishConvertToXIF(nsXIFConverter& aConverter) const;
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aHandler) const;
|
||||
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
|
||||
NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext,
|
||||
nsEvent* aEvent,
|
||||
nsIDOMEvent** aDOMEvent,
|
||||
|
@ -2810,10 +2810,17 @@ RDFElementImpl::FinishConvertToXIF(nsXIFConverter& aConverter) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::SizeOf(nsISizeOfHandler* aHandler) const
|
||||
RDFElementImpl::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
PRUint32 sum = 0;
|
||||
#ifdef DEBUG
|
||||
sum += (PRUint32) sizeof(this);
|
||||
#endif
|
||||
*aResult = sum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче