LCOV - code coverage report
Current view: top level - dom/svg - SVGPoint.h (source / functions) Hit Total Coverage
Test: output.info Lines: 17 39 43.6 %
Date: 2017-07-14 16:53:18 Functions: 6 14 42.9 %
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             : #ifndef MOZILLA_SVGPOINT_H__
       8             : #define MOZILLA_SVGPOINT_H__
       9             : 
      10             : #include "nsDebug.h"
      11             : #include "gfxPoint.h"
      12             : #include "mozilla/gfx/Point.h"
      13             : #include "mozilla/FloatingPoint.h"
      14             : 
      15             : namespace mozilla {
      16             : 
      17             : /**
      18             :  * This class is currently used for point list attributes.
      19             :  *
      20             :  * The DOM wrapper class for this class is DOMSVGPoint.
      21             :  */
      22             : class SVGPoint
      23             : {
      24             :   typedef mozilla::gfx::Point Point;
      25             : 
      26             : public:
      27             : 
      28           0 :   SVGPoint()
      29           0 :     : mX(0.0f)
      30           0 :     , mY(0.0f)
      31           0 :   {}
      32             : 
      33         207 :   SVGPoint(float aX, float aY)
      34         207 :     : mX(aX)
      35         207 :     , mY(aY)
      36             :   {
      37         207 :     NS_ASSERTION(IsValid(), "Constructed an invalid SVGPoint");
      38         207 :   }
      39             : 
      40        1259 :   SVGPoint(const SVGPoint &aOther)
      41        1259 :     : mX(aOther.mX)
      42        1259 :     , mY(aOther.mY)
      43        1259 :   {}
      44             : 
      45           0 :   SVGPoint& operator=(const SVGPoint &rhs) {
      46           0 :     mX = rhs.mX;
      47           0 :     mY = rhs.mY;
      48           0 :     return *this;
      49             :   }
      50             : 
      51             :   bool operator==(const SVGPoint &rhs) const {
      52             :     return mX == rhs.mX && mY == rhs.mY;
      53             :   }
      54             : 
      55           0 :   SVGPoint& operator+=(const SVGPoint &rhs) {
      56           0 :     mX += rhs.mX;
      57           0 :     mY += rhs.mY;
      58           0 :     return *this;
      59             :   }
      60             : 
      61             :   operator gfxPoint() const {
      62             :     return gfxPoint(mX, mY);
      63             :   }
      64             : 
      65         420 :   operator Point() const {
      66         420 :     return Point(mX, mY);
      67             :   }
      68             : 
      69             : #ifdef DEBUG
      70         207 :   bool IsValid() const {
      71         207 :     return IsFinite(mX) && IsFinite(mY);
      72             :   }
      73             : #endif
      74             : 
      75             :   void SetX(float aX)
      76             :     { mX = aX; }
      77             :   void SetY(float aY)
      78             :     { mY = aY; }
      79         770 :   float GetX() const
      80         770 :     { return mX; }
      81         770 :   float GetY() const
      82         770 :     { return mY; }
      83             : 
      84           0 :   bool operator!=(const SVGPoint &rhs) const {
      85           0 :     return mX != rhs.mX || mY != rhs.mY;
      86             :   }
      87             : 
      88             :   float mX;
      89             :   float mY;
      90             : };
      91             : 
      92           0 : inline SVGPoint operator+(const SVGPoint& aP1,
      93             :                           const SVGPoint& aP2)
      94             : {
      95           0 :   return SVGPoint(aP1.mX + aP2.mX, aP1.mY + aP2.mY);
      96             : }
      97             : 
      98           0 : inline SVGPoint operator-(const SVGPoint& aP1,
      99             :                           const SVGPoint& aP2)
     100             : {
     101           0 :   return SVGPoint(aP1.mX - aP2.mX, aP1.mY - aP2.mY);
     102             : }
     103             : 
     104           0 : inline SVGPoint operator*(float aFactor,
     105             :                           const SVGPoint& aPoint)
     106             : {
     107           0 :   return SVGPoint(aFactor * aPoint.mX, aFactor * aPoint.mY);
     108             : }
     109             : 
     110           0 : inline SVGPoint operator*(const SVGPoint& aPoint,
     111             :                           float aFactor)
     112             : {
     113           0 :   return SVGPoint(aFactor * aPoint.mX, aFactor * aPoint.mY);
     114             : }
     115             : 
     116             : } // namespace mozilla
     117             : 
     118             : #endif // MOZILLA_SVGPOINT_H__

Generated by: LCOV version 1.13