nsDOMCSSRGBColor.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /* DOM object representing color values in DOM computed style */
  6. #ifndef nsDOMCSSRGBColor_h__
  7. #define nsDOMCSSRGBColor_h__
  8. #include "mozilla/Attributes.h"
  9. #include "nsWrapperCache.h"
  10. class nsROCSSPrimitiveValue;
  11. class nsDOMCSSRGBColor : public nsWrapperCache
  12. {
  13. public:
  14. nsDOMCSSRGBColor(nsROCSSPrimitiveValue* aRed,
  15. nsROCSSPrimitiveValue* aGreen,
  16. nsROCSSPrimitiveValue* aBlue,
  17. nsROCSSPrimitiveValue* aAlpha,
  18. bool aHasAlpha);
  19. NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsDOMCSSRGBColor)
  20. NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsDOMCSSRGBColor)
  21. bool HasAlpha() const { return mHasAlpha; }
  22. // RGBColor webidl interface
  23. nsROCSSPrimitiveValue* Red() const
  24. {
  25. return mRed;
  26. }
  27. nsROCSSPrimitiveValue* Green() const
  28. {
  29. return mGreen;
  30. }
  31. nsROCSSPrimitiveValue* Blue() const
  32. {
  33. return mBlue;
  34. }
  35. nsROCSSPrimitiveValue* Alpha() const
  36. {
  37. return mAlpha;
  38. }
  39. nsISupports* GetParentObject() const
  40. {
  41. return nullptr;
  42. }
  43. virtual JSObject *WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
  44. override final;
  45. private:
  46. virtual ~nsDOMCSSRGBColor(void);
  47. RefPtr<nsROCSSPrimitiveValue> mRed;
  48. RefPtr<nsROCSSPrimitiveValue> mGreen;
  49. RefPtr<nsROCSSPrimitiveValue> mBlue;
  50. RefPtr<nsROCSSPrimitiveValue> mAlpha;
  51. bool mHasAlpha;
  52. };
  53. #endif // nsDOMCSSRGBColor_h__