LCOV - code coverage report
Current view: top level - dom/svg - SVGPolygonElement.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 13 28 46.4 %
Date: 2017-07-14 16:53:18 Functions: 4 6 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #include "mozilla/dom/SVGPolygonElement.h"
       8             : #include "mozilla/dom/SVGPolygonElementBinding.h"
       9             : #include "mozilla/gfx/2D.h"
      10             : #include "SVGContentUtils.h"
      11             : 
      12             : using namespace mozilla;
      13             : using namespace mozilla::gfx;
      14             : 
      15           4 : NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(Polygon)
      16             : 
      17             : namespace mozilla {
      18             : namespace dom {
      19             : 
      20             : JSObject*
      21           0 : SVGPolygonElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
      22             : {
      23           0 :   return SVGPolygonElementBinding::Wrap(aCx, this, aGivenProto);
      24             : }
      25             : 
      26             : //----------------------------------------------------------------------
      27             : // Implementation
      28             : 
      29          14 : SVGPolygonElement::SVGPolygonElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
      30          14 :   : SVGPolygonElementBase(aNodeInfo)
      31             : {
      32          14 : }
      33             : 
      34             : //----------------------------------------------------------------------
      35             : // nsIDOMNode methods
      36             : 
      37          24 : NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPolygonElement)
      38             : 
      39             : //----------------------------------------------------------------------
      40             : // SVGGeometryElement methods
      41             : 
      42             : void
      43           0 : SVGPolygonElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
      44             : {
      45           0 :   SVGPolyElement::GetMarkPoints(aMarks);
      46             : 
      47           0 :   if (aMarks->IsEmpty() || aMarks->LastElement().type != nsSVGMark::eEnd) {
      48           0 :     return;
      49             :   }
      50             : 
      51           0 :   nsSVGMark *endMark = &aMarks->LastElement();
      52           0 :   nsSVGMark *startMark = &aMarks->ElementAt(0);
      53           0 :   float angle = atan2(startMark->y - endMark->y, startMark->x - endMark->x);
      54             : 
      55           0 :   endMark->type = nsSVGMark::eMid;
      56           0 :   endMark->angle = SVGContentUtils::AngleBisect(angle, endMark->angle);
      57           0 :   startMark->angle = SVGContentUtils::AngleBisect(angle, startMark->angle);
      58             :   // for a polygon (as opposed to a polyline) there's an implicit extra point
      59             :   // co-located with the start point that SVGPolyElement::GetMarkPoints
      60             :   // doesn't return
      61           0 :   aMarks->AppendElement(nsSVGMark(startMark->x, startMark->y, startMark->angle,
      62           0 :                                   nsSVGMark::eEnd));
      63             : }
      64             : 
      65             : already_AddRefed<Path>
      66          12 : SVGPolygonElement::BuildPath(PathBuilder* aBuilder)
      67             : {
      68          12 :   const SVGPointList &points = mPoints.GetAnimValue();
      69             : 
      70          12 :   if (points.IsEmpty()) {
      71           0 :     return nullptr;
      72             :   }
      73             : 
      74          12 :   aBuilder->MoveTo(points[0]);
      75         140 :   for (uint32_t i = 1; i < points.Length(); ++i) {
      76         128 :     aBuilder->LineTo(points[i]);
      77             :   }
      78             : 
      79          12 :   aBuilder->Close();
      80             : 
      81          12 :   return aBuilder->Finish();
      82             : }
      83             : 
      84             : } // namespace dom
      85             : } // namespace mozilla

Generated by: LCOV version 1.13