2013-09-06 10:41:42 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_HTMLAllCollection_h
|
|
|
|
#define mozilla_dom_HTMLAllCollection_h
|
|
|
|
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
2014-02-09 12:04:37 +04:00
|
|
|
#include "nsRefPtrHashtable.h"
|
2014-05-20 23:52:21 +04:00
|
|
|
#include "nsWrapperCache.h"
|
2013-09-06 10:41:42 +04:00
|
|
|
|
2014-02-09 12:04:33 +04:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2014-02-09 12:02:45 +04:00
|
|
|
class nsContentList;
|
2013-09-06 10:41:42 +04:00
|
|
|
class nsHTMLDocument;
|
2014-02-09 12:04:35 +04:00
|
|
|
class nsIContent;
|
2014-05-20 23:52:21 +04:00
|
|
|
class nsINode;
|
2013-09-06 10:41:42 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-05-20 23:52:21 +04:00
|
|
|
class OwningNodeOrHTMLCollection;
|
2014-06-17 19:03:42 +04:00
|
|
|
template<typename> struct Nullable;
|
2014-05-20 23:52:21 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class HTMLAllCollection final : public nsISupports
|
2015-03-27 21:52:19 +03:00
|
|
|
, public nsWrapperCache
|
2013-09-06 10:41:42 +04:00
|
|
|
{
|
2014-06-25 06:09:15 +04:00
|
|
|
~HTMLAllCollection();
|
|
|
|
|
2013-09-06 10:41:42 +04:00
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit HTMLAllCollection(nsHTMLDocument* aDocument);
|
2013-09-06 10:41:42 +04:00
|
|
|
|
2014-05-20 23:52:21 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(HTMLAllCollection)
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2014-05-20 23:52:21 +04:00
|
|
|
nsINode* GetParentObject() const;
|
2013-09-06 10:41:42 +04:00
|
|
|
|
2014-02-09 12:04:33 +04:00
|
|
|
uint32_t Length();
|
2014-02-09 12:04:35 +04:00
|
|
|
nsIContent* Item(uint32_t aIndex);
|
2014-05-20 23:52:21 +04:00
|
|
|
void Item(const nsAString& aName, Nullable<OwningNodeOrHTMLCollection>& aResult)
|
|
|
|
{
|
|
|
|
NamedItem(aName, aResult);
|
|
|
|
}
|
|
|
|
nsIContent* IndexedGetter(uint32_t aIndex, bool& aFound)
|
|
|
|
{
|
|
|
|
nsIContent* result = Item(aIndex);
|
|
|
|
aFound = !!result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NamedItem(const nsAString& aName,
|
|
|
|
Nullable<OwningNodeOrHTMLCollection>& aResult)
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
NamedGetter(aName, found, aResult);
|
|
|
|
}
|
|
|
|
void NamedGetter(const nsAString& aName,
|
|
|
|
bool& aFound,
|
|
|
|
Nullable<OwningNodeOrHTMLCollection>& aResult);
|
2014-05-22 08:23:51 +04:00
|
|
|
void GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames);
|
2014-05-20 23:52:21 +04:00
|
|
|
bool NameIsEnumerable(const nsAString& aName)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
void LegacyCall(JS::Handle<JS::Value>, const nsAString& aName,
|
|
|
|
Nullable<OwningNodeOrHTMLCollection>& aResult)
|
|
|
|
{
|
|
|
|
NamedItem(aName, aResult);
|
|
|
|
}
|
2014-02-09 12:04:36 +04:00
|
|
|
|
2014-02-09 12:04:35 +04:00
|
|
|
private:
|
2014-02-09 12:02:45 +04:00
|
|
|
nsContentList* Collection();
|
|
|
|
|
2014-02-09 12:04:37 +04:00
|
|
|
/**
|
2014-05-20 23:52:21 +04:00
|
|
|
* Returns the HTMLCollection for document.all[aID], or null if there isn't one.
|
2014-02-09 12:04:37 +04:00
|
|
|
*/
|
|
|
|
nsContentList* GetDocumentAllList(const nsAString& aID);
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsHTMLDocument> mDocument;
|
|
|
|
RefPtr<nsContentList> mCollection;
|
2014-02-09 12:04:37 +04:00
|
|
|
nsRefPtrHashtable<nsStringHashKey, nsContentList> mNamedMap;
|
2013-09-06 10:41:42 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLAllCollection_h
|