content/base/src/nsDOMTokenList.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 /*
michael@0 6 * Implementation of DOMTokenList specified by HTML5.
michael@0 7 */
michael@0 8
michael@0 9 #ifndef nsDOMTokenList_h___
michael@0 10 #define nsDOMTokenList_h___
michael@0 11
michael@0 12 #include "nsCOMPtr.h"
michael@0 13 #include "nsDOMString.h"
michael@0 14 #include "nsWrapperCache.h"
michael@0 15 #include "mozilla/dom/Element.h"
michael@0 16 #include "mozilla/dom/BindingDeclarations.h"
michael@0 17
michael@0 18 namespace mozilla {
michael@0 19 class ErrorResult;
michael@0 20
michael@0 21 } // namespace mozilla
michael@0 22
michael@0 23 class nsAttrValue;
michael@0 24 class nsIAtom;
michael@0 25
michael@0 26 // nsISupports must be on the primary inheritance chain
michael@0 27 // because nsDOMSettableTokenList is traversed by Element.
michael@0 28 class nsDOMTokenList : public nsISupports,
michael@0 29 public nsWrapperCache
michael@0 30 {
michael@0 31 protected:
michael@0 32 typedef mozilla::dom::Element Element;
michael@0 33
michael@0 34 public:
michael@0 35 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 36 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMTokenList)
michael@0 37
michael@0 38 nsDOMTokenList(Element* aElement, nsIAtom* aAttrAtom);
michael@0 39
michael@0 40 virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE;
michael@0 41
michael@0 42 Element* GetParentObject()
michael@0 43 {
michael@0 44 return mElement;
michael@0 45 }
michael@0 46
michael@0 47 uint32_t Length();
michael@0 48 void Item(uint32_t aIndex, nsAString& aResult)
michael@0 49 {
michael@0 50 bool found;
michael@0 51 IndexedGetter(aIndex, found, aResult);
michael@0 52 if (!found) {
michael@0 53 SetDOMStringToNull(aResult);
michael@0 54 }
michael@0 55 }
michael@0 56 void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aResult);
michael@0 57 bool Contains(const nsAString& aToken, mozilla::ErrorResult& aError);
michael@0 58 void Add(const nsAString& aToken, mozilla::ErrorResult& aError);
michael@0 59 void Add(const nsTArray<nsString>& aTokens,
michael@0 60 mozilla::ErrorResult& aError);
michael@0 61 void Remove(const nsAString& aToken, mozilla::ErrorResult& aError);
michael@0 62 void Remove(const nsTArray<nsString>& aTokens,
michael@0 63 mozilla::ErrorResult& aError);
michael@0 64 bool Toggle(const nsAString& aToken,
michael@0 65 const mozilla::dom::Optional<bool>& force,
michael@0 66 mozilla::ErrorResult& aError);
michael@0 67 void Stringify(nsAString& aResult);
michael@0 68
michael@0 69 protected:
michael@0 70 virtual ~nsDOMTokenList();
michael@0 71
michael@0 72 nsresult CheckToken(const nsAString& aStr);
michael@0 73 nsresult CheckTokens(const nsTArray<nsString>& aStr);
michael@0 74 void AddInternal(const nsAttrValue* aAttr,
michael@0 75 const nsTArray<nsString>& aTokens);
michael@0 76 void RemoveInternal(const nsAttrValue* aAttr,
michael@0 77 const nsTArray<nsString>& aTokens);
michael@0 78 inline const nsAttrValue* GetParsedAttr();
michael@0 79
michael@0 80 nsCOMPtr<Element> mElement;
michael@0 81 nsCOMPtr<nsIAtom> mAttrAtom;
michael@0 82 };
michael@0 83
michael@0 84 #endif // nsDOMTokenList_h___

mercurial