1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_SVGRect_h 8 #define mozilla_dom_SVGRect_h 9 10 #include "mozilla/dom/SVGIRect.h" 11 #include "mozilla/gfx/Rect.h" 12 #include "nsSVGElement.h" 13 14 //////////////////////////////////////////////////////////////////////// 15 // SVGRect class 16 17 namespace mozilla { 18 namespace dom { 19 20 class SVGRect final : public SVGIRect 21 { 22 public: 23 explicit SVGRect(nsIContent* aParent, float x=0.0f, float y=0.0f, float w=0.0f, 24 float h=0.0f); 25 26 NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SVGRect)27 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SVGRect) 28 29 // WebIDL 30 virtual float X() const override final 31 { 32 return mX; 33 } 34 SetX(float aX,ErrorResult & aRv)35 virtual void SetX(float aX, ErrorResult& aRv) final 36 { 37 mX = aX; 38 } 39 Y()40 virtual float Y() const override final 41 { 42 return mY; 43 } 44 SetY(float aY,ErrorResult & aRv)45 virtual void SetY(float aY, ErrorResult& aRv) final 46 { 47 mY = aY; 48 } 49 Width()50 virtual float Width() const override final 51 { 52 return mWidth; 53 } 54 SetWidth(float aWidth,ErrorResult & aRv)55 virtual void SetWidth(float aWidth, ErrorResult& aRv) final 56 { 57 mWidth = aWidth; 58 } 59 Height()60 virtual float Height() const override final 61 { 62 return mHeight; 63 } 64 SetHeight(float aHeight,ErrorResult & aRv)65 virtual void SetHeight(float aHeight, ErrorResult& aRv) final 66 { 67 mHeight = aHeight; 68 } 69 GetParentObject()70 virtual nsIContent* GetParentObject() const override 71 { 72 return mParent; 73 } 74 75 protected: ~SVGRect()76 ~SVGRect() {} 77 78 nsCOMPtr<nsIContent> mParent; 79 float mX, mY, mWidth, mHeight; 80 }; 81 82 } // namespace dom 83 } // namespace mozilla 84 85 already_AddRefed<mozilla::dom::SVGRect> 86 NS_NewSVGRect(nsIContent* aParent, float x=0.0f, float y=0.0f, 87 float width=0.0f, float height=0.0f); 88 89 already_AddRefed<mozilla::dom::SVGRect> 90 NS_NewSVGRect(nsIContent* aParent, const mozilla::gfx::Rect& rect); 91 92 #endif //mozilla_dom_SVGRect_h 93