2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2009-08-12 01:55:14 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Implementation of nsIDOMDOMTokenList specified by HTML5.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsDOMTokenList_h___
|
|
|
|
#define nsDOMTokenList_h___
|
|
|
|
|
|
|
|
#include "nsIDOMDOMTokenList.h"
|
2012-10-16 04:51:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsDOMString.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2009-08-12 01:55:14 -07:00
|
|
|
|
2012-09-05 13:49:53 -07:00
|
|
|
namespace mozilla {
|
|
|
|
class ErrorResult;
|
|
|
|
}
|
2009-08-12 01:55:14 -07:00
|
|
|
class nsAttrValue;
|
2012-10-16 04:51:00 -07:00
|
|
|
class nsGenericElement;
|
|
|
|
class nsIAtom;
|
2009-08-12 01:55:14 -07:00
|
|
|
|
2012-06-04 16:49:57 -07:00
|
|
|
// nsISupports must be on the primary inheritance chain
|
|
|
|
// because nsDOMSettableTokenList is traversed by nsGenericElement.
|
2011-08-22 02:14:13 -07:00
|
|
|
class nsDOMTokenList : public nsIDOMDOMTokenList,
|
|
|
|
public nsWrapperCache
|
2009-08-12 01:55:14 -07:00
|
|
|
{
|
|
|
|
public:
|
2011-08-22 02:14:13 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMTokenList)
|
2009-08-12 01:55:14 -07:00
|
|
|
NS_DECL_NSIDOMDOMTOKENLIST
|
|
|
|
|
|
|
|
nsDOMTokenList(nsGenericElement* aElement, nsIAtom* aAttrAtom);
|
|
|
|
|
|
|
|
void DropReference();
|
|
|
|
|
2012-03-14 08:25:40 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
|
2011-08-22 02:14:13 -07:00
|
|
|
bool *triedToWrap);
|
|
|
|
|
2012-10-16 04:51:00 -07:00
|
|
|
nsGenericElement* GetParentObject()
|
2011-08-22 02:14:13 -07:00
|
|
|
{
|
|
|
|
return mElement;
|
|
|
|
}
|
|
|
|
|
2012-09-05 13:49:53 -07:00
|
|
|
uint32_t Length();
|
|
|
|
void Item(uint32_t aIndex, nsAString& aResult)
|
|
|
|
{
|
|
|
|
bool found;
|
|
|
|
IndexedGetter(aIndex, found, aResult);
|
|
|
|
if (!found) {
|
|
|
|
SetDOMStringToNull(aResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aResult);
|
|
|
|
bool Contains(const nsAString& aToken, mozilla::ErrorResult& aError);
|
|
|
|
void Add(const nsAString& aToken, mozilla::ErrorResult& aError);
|
|
|
|
void Remove(const nsAString& aToken, mozilla::ErrorResult& aError);
|
|
|
|
bool Toggle(const nsAString& aToken, mozilla::ErrorResult& aError);
|
|
|
|
void Stringify(nsAString& aResult);
|
|
|
|
|
2012-06-04 16:49:57 -07:00
|
|
|
protected:
|
2012-06-18 19:30:09 -07:00
|
|
|
virtual ~nsDOMTokenList();
|
2012-06-04 16:49:57 -07:00
|
|
|
|
2009-08-12 01:55:14 -07:00
|
|
|
nsresult CheckToken(const nsAString& aStr);
|
|
|
|
void AddInternal(const nsAttrValue* aAttr, const nsAString& aToken);
|
|
|
|
void RemoveInternal(const nsAttrValue* aAttr, const nsAString& aToken);
|
2012-10-16 04:51:00 -07:00
|
|
|
inline const nsAttrValue* GetParsedAttr();
|
2009-08-12 01:55:14 -07:00
|
|
|
|
|
|
|
nsGenericElement* mElement;
|
|
|
|
nsCOMPtr<nsIAtom> mAttrAtom;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsDOMTokenList_h___
|