Bug 935274, speed up getting wrapper from nsIHTMLCollection, r=peterv

--HG--
extra : rebase_source : d5d0a8355ee84ce6291ae8ebca8f76e06f6cc44e
This commit is contained in:
Olli Pettay 2013-11-12 17:22:22 +02:00
parent 483de405ce
commit f381920fdb
6 changed files with 53 additions and 18 deletions

View File

@ -253,8 +253,14 @@ public:
// nsWrapperCache
using nsWrapperCache::GetWrapperPreserveColor;
virtual JSObject* WrapObject(JSContext *cx,
JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
protected:
virtual JSObject* GetWrapperPreserveColorInternal() MOZ_OVERRIDE
{
return nsWrapperCache::GetWrapperPreserveColor();
}
public:
// nsIDOMHTMLCollection
NS_DECL_NSIDOMHTMLCOLLECTION

View File

@ -24,8 +24,8 @@ class Element;
// IID for the nsIHTMLCollection interface
#define NS_IHTMLCOLLECTION_IID \
{ 0x5643235d, 0x9a72, 0x4b6a, \
{ 0xa6, 0x0c, 0x64, 0x63, 0x72, 0xb7, 0x53, 0x4a } }
{ 0x4e169191, 0x5196, 0x4e17, \
{ 0xa4, 0x79, 0xd5, 0x35, 0x0b, 0x5b, 0x0a, 0xcd } }
/**
* An internal interface
@ -76,11 +76,11 @@ public:
JSObject* GetWrapperPreserveColor()
{
nsWrapperCache* cache;
CallQueryInterface(this, &cache);
return cache->GetWrapperPreserveColor();
return GetWrapperPreserveColorInternal();
}
virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> scope) = 0;
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) = 0;
protected:
virtual JSObject* GetWrapperPreserveColorInternal() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLCollection, NS_IHTMLCOLLECTION_IID)

View File

@ -79,8 +79,15 @@ public:
nsresult GetSortedControls(nsTArray<nsGenericHTMLFormElement*>& aControls) const;
// nsWrapperCache
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
using nsWrapperCache::GetWrapperPreserveColor;
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
protected:
virtual JSObject* GetWrapperPreserveColorInternal() MOZ_OVERRIDE
{
return nsWrapperCache::GetWrapperPreserveColor();
}
public:
static bool ShouldBeInElements(nsIFormControl* aFormControl);

View File

@ -42,8 +42,14 @@ public:
// nsWrapperCache
using nsWrapperCache::GetWrapperPreserveColor;
virtual JSObject* WrapObject(JSContext* cx,
JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
protected:
virtual JSObject* GetWrapperPreserveColorInternal() MOZ_OVERRIDE
{
return nsWrapperCache::GetWrapperPreserveColor();
}
public:
// nsIDOMHTMLOptionsCollection interface
NS_DECL_NSIDOMHTMLOPTIONSCOLLECTION

View File

@ -55,9 +55,16 @@ public:
HTMLPropertiesCollection(nsGenericHTMLElement* aRoot);
virtual ~HTMLPropertiesCollection();
// nsWrapperCache
using nsWrapperCache::GetWrapperPreserveColor;
virtual JSObject* WrapObject(JSContext *cx,
JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
protected:
virtual JSObject* GetWrapperPreserveColorInternal() MOZ_OVERRIDE
{
return nsWrapperCache::GetWrapperPreserveColor();
}
public:
virtual Element* GetElementAt(uint32_t aIndex);

View File

@ -50,13 +50,15 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TableRowsCollection)
// nsWrapperCache
virtual JSObject* WrapObject(JSContext *cx,
JS::Handle<JSObject*> scope) MOZ_OVERRIDE
using nsWrapperCache::GetWrapperPreserveColor;
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
protected:
virtual JSObject* GetWrapperPreserveColorInternal() MOZ_OVERRIDE
{
return mozilla::dom::HTMLCollectionBinding::Wrap(cx, scope, this);
return nsWrapperCache::GetWrapperPreserveColor();
}
protected:
// Those rows that are not in table sections
HTMLTableElement* mParent;
nsRefPtr<nsContentList> mOrphanRows;
@ -82,6 +84,13 @@ TableRowsCollection::~TableRowsCollection()
// reference for us.
}
JSObject*
TableRowsCollection::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope)
{
return HTMLCollectionBinding::Wrap(aCx, aScope, this);
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(TableRowsCollection, mOrphanRows)
NS_IMPL_CYCLE_COLLECTING_ADDREF(TableRowsCollection)
NS_IMPL_CYCLE_COLLECTING_RELEASE(TableRowsCollection)