SVGRect.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. #ifndef mozilla_dom_SVGRect_h
  6. #define mozilla_dom_SVGRect_h
  7. #include "mozilla/dom/SVGIRect.h"
  8. #include "mozilla/gfx/Rect.h"
  9. #include "nsSVGElement.h"
  10. ////////////////////////////////////////////////////////////////////////
  11. // SVGRect class
  12. namespace mozilla {
  13. namespace dom {
  14. class SVGRect final : public SVGIRect
  15. {
  16. public:
  17. explicit SVGRect(nsIContent* aParent, float x=0.0f, float y=0.0f, float w=0.0f,
  18. float h=0.0f);
  19. NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  20. NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SVGRect)
  21. // WebIDL
  22. virtual float X() const override final
  23. {
  24. return mX;
  25. }
  26. virtual void SetX(float aX, ErrorResult& aRv) final
  27. {
  28. mX = aX;
  29. }
  30. virtual float Y() const override final
  31. {
  32. return mY;
  33. }
  34. virtual void SetY(float aY, ErrorResult& aRv) final
  35. {
  36. mY = aY;
  37. }
  38. virtual float Width() const override final
  39. {
  40. return mWidth;
  41. }
  42. virtual void SetWidth(float aWidth, ErrorResult& aRv) final
  43. {
  44. mWidth = aWidth;
  45. }
  46. virtual float Height() const override final
  47. {
  48. return mHeight;
  49. }
  50. virtual void SetHeight(float aHeight, ErrorResult& aRv) final
  51. {
  52. mHeight = aHeight;
  53. }
  54. virtual nsIContent* GetParentObject() const override
  55. {
  56. return mParent;
  57. }
  58. protected:
  59. ~SVGRect() {}
  60. nsCOMPtr<nsIContent> mParent;
  61. float mX, mY, mWidth, mHeight;
  62. };
  63. } // namespace dom
  64. } // namespace mozilla
  65. already_AddRefed<mozilla::dom::SVGRect>
  66. NS_NewSVGRect(nsIContent* aParent, float x=0.0f, float y=0.0f,
  67. float width=0.0f, float height=0.0f);
  68. already_AddRefed<mozilla::dom::SVGRect>
  69. NS_NewSVGRect(nsIContent* aParent, const mozilla::gfx::Rect& rect);
  70. #endif //mozilla_dom_SVGRect_h