SVGRect.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* -*- Mode: C++; tab-width: 8; 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. #include "mozilla/dom/SVGRect.h"
  6. #include "nsSVGElement.h"
  7. using namespace mozilla::gfx;
  8. namespace mozilla {
  9. namespace dom {
  10. //----------------------------------------------------------------------
  11. // implementation:
  12. SVGRect::SVGRect(nsIContent* aParent, float x, float y, float w, float h)
  13. : SVGIRect(), mParent(aParent), mX(x), mY(y), mWidth(w), mHeight(h)
  14. {
  15. }
  16. //----------------------------------------------------------------------
  17. // nsISupports methods:
  18. NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(SVGRect, mParent)
  19. NS_IMPL_CYCLE_COLLECTING_ADDREF(SVGRect)
  20. NS_IMPL_CYCLE_COLLECTING_RELEASE(SVGRect)
  21. NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGRect)
  22. NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
  23. NS_INTERFACE_MAP_ENTRY(nsISupports)
  24. NS_INTERFACE_MAP_END
  25. } // namespace dom
  26. } // namespace mozilla
  27. ////////////////////////////////////////////////////////////////////////
  28. // Exported creation functions:
  29. already_AddRefed<mozilla::dom::SVGRect>
  30. NS_NewSVGRect(nsIContent* aParent, float aX, float aY, float aWidth,
  31. float aHeight)
  32. {
  33. RefPtr<mozilla::dom::SVGRect> rect =
  34. new mozilla::dom::SVGRect(aParent, aX, aY, aWidth, aHeight);
  35. return rect.forget();
  36. }
  37. already_AddRefed<mozilla::dom::SVGRect>
  38. NS_NewSVGRect(nsIContent* aParent, const Rect& aRect)
  39. {
  40. return NS_NewSVGRect(aParent, aRect.x, aRect.y,
  41. aRect.width, aRect.height);
  42. }