Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / svg / SVGPolylineElement.cpp
blobc771d40d149974f9570aa2470754e88cdbf15a1a
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/. */
7 #include "mozilla/dom/SVGPolylineElement.h"
8 #include "mozilla/dom/SVGPolylineElementBinding.h"
9 #include "mozilla/dom/SVGAnimatedLength.h"
10 #include "mozilla/gfx/2D.h"
12 using namespace mozilla::gfx;
14 NS_IMPL_NS_NEW_SVG_ELEMENT(Polyline)
16 namespace mozilla::dom {
18 JSObject* SVGPolylineElement::WrapNode(JSContext* aCx,
19 JS::Handle<JSObject*> aGivenProto) {
20 return SVGPolylineElement_Binding::Wrap(aCx, this, aGivenProto);
23 //----------------------------------------------------------------------
24 // Implementation
26 SVGPolylineElement::SVGPolylineElement(
27 already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
28 : SVGPolylineElementBase(std::move(aNodeInfo)) {}
30 //----------------------------------------------------------------------
31 // nsINode methods
33 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPolylineElement)
35 //----------------------------------------------------------------------
36 // SVGGeometryElement methods
38 already_AddRefed<Path> SVGPolylineElement::BuildPath(PathBuilder* aBuilder) {
39 const SVGPointList& points = mPoints.GetAnimValue();
41 if (points.IsEmpty()) {
42 return nullptr;
45 float zoom = UserSpaceMetrics::GetZoom(this);
47 aBuilder->MoveTo(points[0] * zoom);
48 for (uint32_t i = 1; i < points.Length(); ++i) {
49 aBuilder->LineTo(points[i] * zoom);
52 return aBuilder->Finish();
55 } // namespace mozilla::dom