layout/style/nsDOMCSSValueList.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/style/nsDOMCSSValueList.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +/* DOM object representing lists of values in DOM computed style */
     1.9 +
    1.10 +#ifndef nsDOMCSSValueList_h___
    1.11 +#define nsDOMCSSValueList_h___
    1.12 +
    1.13 +#include "nsIDOMCSSValueList.h"
    1.14 +#include "CSSValue.h"
    1.15 +#include "nsTArray.h"
    1.16 +
    1.17 +class nsDOMCSSValueList MOZ_FINAL : public mozilla::dom::CSSValue,
    1.18 +  public nsIDOMCSSValueList
    1.19 +{
    1.20 +public:
    1.21 +  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    1.22 +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDOMCSSValueList, mozilla::dom::CSSValue)
    1.23 +
    1.24 +  // nsIDOMCSSValue
    1.25 +  NS_DECL_NSIDOMCSSVALUE
    1.26 +
    1.27 +  // nsDOMCSSValueList
    1.28 +  nsDOMCSSValueList(bool aCommaDelimited, bool aReadonly);
    1.29 +  ~nsDOMCSSValueList();
    1.30 +
    1.31 +  /**
    1.32 +   * Adds a value to this list.
    1.33 +   */
    1.34 +  void AppendCSSValue(CSSValue* aValue);
    1.35 +
    1.36 +  virtual void GetCssText(nsString& aText, mozilla::ErrorResult& aRv)
    1.37 +    MOZ_OVERRIDE MOZ_FINAL;
    1.38 +  virtual void SetCssText(const nsAString& aText,
    1.39 +                          mozilla::ErrorResult& aRv) MOZ_OVERRIDE MOZ_FINAL;
    1.40 +  virtual uint16_t CssValueType() const MOZ_OVERRIDE MOZ_FINAL;
    1.41 +
    1.42 +  CSSValue* IndexedGetter(uint32_t aIdx, bool& aFound) const
    1.43 +  {
    1.44 +    aFound = aIdx <= Length();
    1.45 +    return Item(aIdx);
    1.46 +  }
    1.47 +
    1.48 +  CSSValue* Item(uint32_t aIndex) const
    1.49 +  {
    1.50 +    return mCSSValues.SafeElementAt(aIndex);
    1.51 +  }
    1.52 +
    1.53 +  uint32_t Length() const
    1.54 +  {
    1.55 +    return mCSSValues.Length();
    1.56 +  }
    1.57 +
    1.58 +  nsISupports* GetParentObject()
    1.59 +  {
    1.60 +    return nullptr;
    1.61 +  }
    1.62 +
    1.63 +  virtual JSObject *WrapObject(JSContext *cx) MOZ_OVERRIDE;
    1.64 +
    1.65 +private:
    1.66 +  bool                        mCommaDelimited;  // some value lists use a comma
    1.67 +                                                // as the delimiter, some just use
    1.68 +                                                // spaces.
    1.69 +
    1.70 +  bool                        mReadonly;    // Are we read-only?
    1.71 +
    1.72 +  InfallibleTArray<nsRefPtr<CSSValue> > mCSSValues;
    1.73 +};
    1.74 +
    1.75 +#endif /* nsDOMCSSValueList_h___ */

mercurial