author Robert Strong <>
Wed, 19 Oct 2016 13:27:01 -0700
changeset 348675 4d6033fadbc589a5f6170803e6af65ed8de5c96d
parent 284279 91d6e262b662a0b4e47358665e222d3927337af9
child 416428 6a629adbb62a299d7208373d1c6f375149d2afdb
permissions -rw-r--r--
Client code for Bug 1309125 - Allow configuration of the download throttle via the update.xml. r=mhowell, a=rkothari

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */


#include "mozilla/Attributes.h"
#include "mozilla/gfx/Point.h"
#include "nsSVGDataParser.h"

namespace mozilla {
class SVGPathData;
} // namespace mozilla

// nsSVGPathDataParser: a simple recursive descent parser that builds
// DOMSVGPathSegs from path data strings. The grammar for path data
// can be found in SVG CR 20001102, chapter 8.

class nsSVGPathDataParser : public nsSVGDataParser
  nsSVGPathDataParser(const nsAString& aValue,
                      mozilla::SVGPathData* aList)
    : nsSVGDataParser(aValue),
    MOZ_ASSERT(aList, "null path data");

  bool Parse();


  bool ParseCoordPair(float& aX, float& aY);
  bool ParseFlag(bool& aFlag);

  bool ParsePath();
  bool IsStartOfSubPath() const;
  bool ParseSubPath();
  bool ParseSubPathElements();
  bool ParseSubPathElement(char16_t aCommandType,
                           bool aAbsCoords);

  bool ParseMoveto();
  bool ParseClosePath();
  bool ParseLineto(bool aAbsCoords);
  bool ParseHorizontalLineto(bool aAbsCoords);
  bool ParseVerticalLineto(bool aAbsCoords);
  bool ParseCurveto(bool aAbsCoords);
  bool ParseSmoothCurveto(bool aAbsCoords);
  bool ParseQuadBezierCurveto(bool aAbsCoords);
  bool ParseSmoothQuadBezierCurveto(bool aAbsCoords);  
  bool ParseEllipticalArc(bool aAbsCoords);  

  mozilla::SVGPathData * const mPathSegList;

class nsSVGArcConverter
  typedef mozilla::gfx::Point Point;

  nsSVGArcConverter(const Point& from,
                    const Point& to,
                    const Point& radii,
                    double angle,
                    bool largeArcFlag,
                    bool sweepFlag);
  bool GetNextSegment(Point* cp1, Point* cp2, Point* to);
  int32_t mNumSegs, mSegIndex;
  double mTheta, mDelta, mT;
  double mSinPhi, mCosPhi;
  double mRx, mRy;
  Point mFrom, mC;