nsDOMCSSRect.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 rectangle values in DOM computed style */
  6. #include "mozilla/dom/RectBinding.h"
  7. #include "nsROCSSPrimitiveValue.h"
  8. #include "nsDOMCSSRect.h"
  9. using namespace mozilla;
  10. nsDOMCSSRect::nsDOMCSSRect(nsROCSSPrimitiveValue* aTop,
  11. nsROCSSPrimitiveValue* aRight,
  12. nsROCSSPrimitiveValue* aBottom,
  13. nsROCSSPrimitiveValue* aLeft)
  14. : mTop(aTop), mRight(aRight), mBottom(aBottom), mLeft(aLeft)
  15. {
  16. }
  17. nsDOMCSSRect::~nsDOMCSSRect(void)
  18. {
  19. }
  20. NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCSSRect)
  21. NS_INTERFACE_MAP_ENTRY(nsIDOMRect)
  22. NS_INTERFACE_MAP_ENTRY(nsISupports)
  23. NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
  24. NS_INTERFACE_MAP_END
  25. NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCSSRect)
  26. NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCSSRect)
  27. NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMCSSRect, mTop, mBottom, mLeft, mRight)
  28. JSObject*
  29. nsDOMCSSRect::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
  30. {
  31. return dom::RectBinding::Wrap(cx, this, aGivenProto);
  32. }
  33. NS_IMETHODIMP
  34. nsDOMCSSRect::GetTop(nsIDOMCSSPrimitiveValue** aTop)
  35. {
  36. NS_ENSURE_TRUE(mTop, NS_ERROR_NOT_INITIALIZED);
  37. *aTop = mTop;
  38. NS_ADDREF(*aTop);
  39. return NS_OK;
  40. }
  41. NS_IMETHODIMP
  42. nsDOMCSSRect::GetRight(nsIDOMCSSPrimitiveValue** aRight)
  43. {
  44. NS_ENSURE_TRUE(mRight, NS_ERROR_NOT_INITIALIZED);
  45. *aRight = mRight;
  46. NS_ADDREF(*aRight);
  47. return NS_OK;
  48. }
  49. NS_IMETHODIMP
  50. nsDOMCSSRect::GetBottom(nsIDOMCSSPrimitiveValue** aBottom)
  51. {
  52. NS_ENSURE_TRUE(mBottom, NS_ERROR_NOT_INITIALIZED);
  53. *aBottom = mBottom;
  54. NS_ADDREF(*aBottom);
  55. return NS_OK;
  56. }
  57. NS_IMETHODIMP
  58. nsDOMCSSRect::GetLeft(nsIDOMCSSPrimitiveValue** aLeft)
  59. {
  60. NS_ENSURE_TRUE(mLeft, NS_ERROR_NOT_INITIALIZED);
  61. *aLeft = mLeft;
  62. NS_ADDREF(*aLeft);
  63. return NS_OK;
  64. }