Fix for bug 734499 (Add new DOM binding for PaintRequestList). r=jst.

--HG--
extra : rebase_source : 37f4a1ea723db150abc07d66c6f167c27fd9c354
This commit is contained in:
Peter Van der Beken 2011-08-22 11:14:13 +02:00
parent b0f18cd351
commit 38d1d644ce
6 changed files with 54 additions and 15 deletions

View File

@ -126,7 +126,8 @@ nsDOMNotifyPaintEvent::GetClientRects(nsIDOMClientRectList** aResult)
NS_IMETHODIMP
nsDOMNotifyPaintEvent::GetPaintRequests(nsIDOMPaintRequestList** aResult)
{
nsRefPtr<nsPaintRequestList> requests = new nsPaintRequestList();
nsRefPtr<nsPaintRequestList> requests =
new nsPaintRequestList(static_cast<nsDOMEvent*>(this));
if (!requests)
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -41,6 +41,7 @@
#include "nsDOMClassInfoID.h"
#include "nsClientRect.h"
#include "nsIFrame.h"
#include "nsContentUtils.h"
DOMCI_DATA(PaintRequest, nsPaintRequest)
@ -83,15 +84,28 @@ nsPaintRequest::GetReason(nsAString& aResult)
DOMCI_DATA(PaintRequestList, nsPaintRequestList)
NS_IMPL_CYCLE_COLLECTION_CLASS(nsPaintRequestList)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsPaintRequestList)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mParent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsPaintRequestList)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mParent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsPaintRequestList)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_INTERFACE_TABLE_HEAD(nsPaintRequestList)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_TABLE1(nsPaintRequestList, nsIDOMPaintRequestList)
NS_INTERFACE_TABLE_TO_MAP_SEGUE
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsPaintRequestList)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(PaintRequestList)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(nsPaintRequestList)
NS_IMPL_RELEASE(nsPaintRequestList)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsPaintRequestList)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsPaintRequestList)
NS_IMETHODIMP
nsPaintRequestList::GetLength(PRUint32* aLength)
@ -103,6 +117,12 @@ nsPaintRequestList::GetLength(PRUint32* aLength)
NS_IMETHODIMP
nsPaintRequestList::Item(PRUint32 aIndex, nsIDOMPaintRequest** aReturn)
{
NS_IF_ADDREF(*aReturn = GetItemAt(aIndex));
NS_IF_ADDREF(*aReturn = nsPaintRequestList::GetItemAt(aIndex));
return NS_OK;
}
nsIDOMPaintRequest*
nsPaintRequestList::GetItemAt(PRUint32 aIndex)
{
return mArray.SafeObjectAt(aIndex);
}

View File

@ -42,7 +42,8 @@
#include "nsIDOMPaintRequest.h"
#include "nsIDOMPaintRequestList.h"
#include "nsPresContext.h"
#include "nsClientRect.h"
#include "nsIDOMEvent.h"
#include "dombindings.h"
class nsPaintRequest : public nsIDOMPaintRequest
{
@ -61,21 +62,33 @@ private:
nsInvalidateRequestList::Request mRequest;
};
class nsPaintRequestList : public nsIDOMPaintRequestList
class nsPaintRequestList MOZ_FINAL : public nsIDOMPaintRequestList,
public nsWrapperCache
{
public:
nsPaintRequestList() {}
nsPaintRequestList(nsIDOMEvent *aParent) : mParent(aParent)
{
SetIsProxy();
}
NS_DECL_ISUPPORTS
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsPaintRequestList)
NS_DECL_NSIDOMPAINTREQUESTLIST
void Append(nsIDOMPaintRequest* aElement) { mArray.AppendObject(aElement); }
nsIDOMPaintRequest* GetItemAt(PRUint32 aIndex)
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
bool *triedToWrap)
{
return mArray.SafeObjectAt(aIndex);
return mozilla::dom::binding::PaintRequestList::create(cx, scope, this,
triedToWrap);
}
nsISupports* GetParentObject()
{
return mParent;
}
void Append(nsIDOMPaintRequest* aElement) { mArray.AppendObject(aElement); }
static nsPaintRequestList* FromSupports(nsISupports* aSupports)
{
#ifdef DEBUG
@ -97,6 +110,7 @@ private:
~nsPaintRequestList() {}
nsCOMArray<nsIDOMPaintRequest> mArray;
nsCOMPtr<nsIDOMEvent> mParent;
};
#endif /*NSPAINTREQUEST_H_*/

View File

@ -44,5 +44,6 @@ interface nsIDOMPaintRequest;
interface nsIDOMPaintRequestList : nsISupports
{
readonly attribute unsigned long length;
nsIDOMPaintRequest item(in unsigned long index);
[getter,forward(getItemAt)] nsIDOMPaintRequest item(in unsigned long index);
[noscript,notxpcom,nostdcall] nsIDOMPaintRequest getItemAt(in unsigned long index);
};

View File

@ -97,6 +97,7 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../loader \
-I$(topsrcdir)/caps/include \
-I$(topsrcdir)/content/base/src \
-I$(topsrcdir)/content/events/src \
-I$(topsrcdir)/content/html/content/src \
-I$(topsrcdir)/content/html/document/src \
-I$(topsrcdir)/content/svg/content/src \

View File

@ -7,11 +7,13 @@ prefableClasses = {
'DOMTokenList': 'nsDOMTokenList',
'DOMSettableTokenList': 'nsDOMSettableTokenList',
'ClientRectList': 'nsClientRectList',
'PaintRequestList': 'nsPaintRequestList',
}
irregularFilenames = {
'nsHTMLOptionCollection': 'nsHTMLSelectElement',
'nsClientRectList': 'nsClientRect',
'nsPaintRequestList': 'nsPaintRequest',
}
customInheritance = {