SVGPolylineElement.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/SVGPolylineElement.h"
  6. #include "mozilla/dom/SVGPolylineElementBinding.h"
  7. #include "mozilla/gfx/2D.h"
  8. using namespace mozilla;
  9. using namespace mozilla::gfx;
  10. NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Polyline)
  11. namespace mozilla {
  12. namespace dom {
  13. JSObject*
  14. SVGPolylineElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
  15. {
  16. return SVGPolylineElementBinding::Wrap(aCx, this, aGivenProto);
  17. }
  18. //----------------------------------------------------------------------
  19. // Implementation
  20. SVGPolylineElement::SVGPolylineElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
  21. : SVGPolylineElementBase(aNodeInfo)
  22. {
  23. }
  24. //----------------------------------------------------------------------
  25. // nsIDOMNode methods
  26. NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPolylineElement)
  27. //----------------------------------------------------------------------
  28. // nsSVGPathGeometryElement methods
  29. already_AddRefed<Path>
  30. SVGPolylineElement::BuildPath(PathBuilder* aBuilder)
  31. {
  32. const SVGPointList &points = mPoints.GetAnimValue();
  33. if (points.IsEmpty()) {
  34. return nullptr;
  35. }
  36. aBuilder->MoveTo(points[0]);
  37. for (uint32_t i = 1; i < points.Length(); ++i) {
  38. aBuilder->LineTo(points[i]);
  39. }
  40. return aBuilder->Finish();
  41. }
  42. } // namespace dom
  43. } // namespace mozilla