Commit fc986af9 authored by Robert Longson's avatar Robert Longson
Browse files

Bug 729139 - Accept negative radius arcs in markup. r=jwatt

parent f306ab5f
Loading
Loading
Loading
Loading
+0 −30
Original line number Diff line number Diff line
@@ -98,36 +98,6 @@ void nsSVGDataParser::RewindTo(const char* aPos)

//----------------------------------------------------------------------

nsresult nsSVGDataParser::MatchNonNegativeNumber(float* aX)
{
  // XXX inefficient implementation. We probably hit the RewindTo case
  // often.
  
  const char* pos = mTokenPos;

  nsresult rv = MatchFloatingPointConst();

  if (NS_FAILED(rv)) {
    RewindTo(pos);
    ENSURE_MATCHED(MatchIntegerConst());
  }

  char* end;
  *aX = float(PR_strtod(pos, &end));
  if (pos != end && NS_finite(*aX)) {
    return NS_OK;
  }
  
  return NS_ERROR_FAILURE;
}

bool nsSVGDataParser::IsTokenNonNegativeNumberStarter()
{
  return (mTokenType == DIGIT || mTokenType == POINT);
}

//----------------------------------------------------------------------

nsresult nsSVGDataParser::MatchNumber(float* aX)
{
  const char* pos = mTokenPos;
+0 −3
Original line number Diff line number Diff line
@@ -34,9 +34,6 @@ protected:
  void RewindTo(const char* aPos);
  virtual nsresult Match()=0;

  nsresult MatchNonNegativeNumber(float* aX);
  bool IsTokenNonNegativeNumberStarter();
  
  nsresult MatchNumber(float* x);
  bool IsTokenNumberStarter();
  
+3 −3
Original line number Diff line number Diff line
@@ -789,13 +789,13 @@ nsresult nsSVGPathDataParser::MatchEllipticalArcArg(float* x, float* y,
                                                    float* r1, float* r2, float* angle,
                                                    bool* largeArcFlag, bool* sweepFlag)
{
  ENSURE_MATCHED(MatchNonNegativeNumber(r1));
  ENSURE_MATCHED(MatchNumber(r1));

  if (IsTokenCommaWspStarter()) {
    ENSURE_MATCHED(MatchCommaWsp());
  }

  ENSURE_MATCHED(MatchNonNegativeNumber(r2));
  ENSURE_MATCHED(MatchNumber(r2));

  if (IsTokenCommaWspStarter()) {
    ENSURE_MATCHED(MatchCommaWsp());
@@ -827,7 +827,7 @@ nsresult nsSVGPathDataParser::MatchEllipticalArcArg(float* x, float* y,

bool nsSVGPathDataParser::IsTokenEllipticalArcArgStarter()
{
  return IsTokenNonNegativeNumberStarter();
  return IsTokenNumberStarter();
}


+17 −0
Original line number Diff line number Diff line
<!--
     Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/publicdomain/zero/1.0/
-->
<svg xmlns="http://www.w3.org/2000/svg">

  <title>Reference for negative radius path arc handling</title>

  <!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=729139 -->

  <!-- Check that a negative arc radius is treated as positive. -->
  <path d="M 150,0
           a 150,150 0 0,1 106.066,256.066
           l -35.355,-35.355
           a 100,100 0 0,0 -70.711,-170.711
           z" fill="#3d7fe6" shape-rendering="crispEdges"/>
</svg>
+17 −0
Original line number Diff line number Diff line
<!--
     Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/publicdomain/zero/1.0/
-->
<svg xmlns="http://www.w3.org/2000/svg">

  <title>Testcase for negative radius path arc handling</title>

  <!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=729139 -->

  <!-- Check that a negative arc radius is treated as positive. -->
  <path d="M 150,0
           a 150,150 0 0,1 106.066,256.066
           l -35.355,-35.355
           a -100,-100 0 0,0 -70.711,-170.711
           z" fill="#3d7fe6" shape-rendering="crispEdges"/>
</svg>
Loading