Bug 968766 - Part e: Introduce HTMLAllCollection::Item; r=jst

This commit is contained in:
Ms2ger 2014-02-09 09:04:35 +01:00
parent c4958481bc
commit d368c17b35
2 changed files with 10 additions and 4 deletions

View File

@ -87,6 +87,12 @@ HTMLAllCollection::Length()
return Collection()->Length(true);
}
nsIContent*
HTMLAllCollection::Item(uint32_t aIndex)
{
return Collection()->Item(aIndex);
}
JSObject*
HTMLAllCollection::GetObject(JSContext* aCx, ErrorResult& aRv)
{
@ -216,9 +222,7 @@ nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JS::Handle<JSObject*> ob
// Map document.all[n] (where n is a number) to the n:th item in
// the document.all node list.
nsRefPtr<nsContentList> nodeList = doc->All()->Collection();
nsIContent *node = nodeList->Item(JSID_TO_INT(id));
nsIContent* node = doc->All()->Item(SafeCast<uint32_t>(JSID_TO_INT(id)));
result = node;
cache = node;

View File

@ -16,6 +16,7 @@
class nsContentList;
class nsHTMLDocument;
class nsIContent;
namespace mozilla {
class ErrorResult;
@ -32,12 +33,13 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(HTMLAllCollection)
uint32_t Length();
nsIContent* Item(uint32_t aIndex);
JSObject* GetObject(JSContext* aCx, ErrorResult& aRv);
private:
nsContentList* Collection();
private:
JS::Heap<JSObject*> mObject;
nsRefPtr<nsHTMLDocument> mDocument;
nsRefPtr<nsContentList> mCollection;