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.)

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

mercurial