2009-01-14 20:38:07 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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 http://mozilla.org/MPL/2.0/. */
|
2009-01-14 20:38:07 -08:00
|
|
|
|
|
|
|
#ifndef NS_SMILPARSERUTILS_H_
|
|
|
|
#define NS_SMILPARSERUTILS_H_
|
|
|
|
|
|
|
|
#include "nsTArray.h"
|
2013-11-25 11:46:20 -08:00
|
|
|
#include "nsStringFwd.h"
|
2009-01-14 20:38:07 -08:00
|
|
|
|
|
|
|
class nsISMILAttr;
|
2013-11-25 11:46:20 -08:00
|
|
|
class nsSMILKeySpline;
|
2009-01-14 20:38:07 -08:00
|
|
|
class nsSMILTimeValue;
|
|
|
|
class nsSMILValue;
|
|
|
|
class nsSMILRepeatCount;
|
2010-01-12 12:00:49 -08:00
|
|
|
class nsSMILTimeValueSpecParams;
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2013-03-18 20:18:45 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class SVGAnimationElement;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-14 20:38:07 -08:00
|
|
|
/**
|
|
|
|
* Common parsing utilities for the SMIL module. There is little re-use here; it
|
|
|
|
* simply serves to simplify other classes by moving parsing outside and to aid
|
|
|
|
* unit testing.
|
|
|
|
*/
|
|
|
|
class nsSMILParserUtils
|
|
|
|
{
|
|
|
|
public:
|
2010-04-28 16:00:53 -07:00
|
|
|
// Abstract helper-class for assisting in parsing |values| attribute
|
2013-11-25 11:46:20 -08:00
|
|
|
class MOZ_STACK_CLASS GenericValueParser {
|
2010-04-28 16:00:53 -07:00
|
|
|
public:
|
2013-11-25 11:46:20 -08:00
|
|
|
virtual bool Parse(const nsAString& aValueStr) = 0;
|
2010-04-28 16:00:53 -07:00
|
|
|
};
|
|
|
|
|
2013-11-25 11:46:20 -08:00
|
|
|
static const nsDependentSubstring TrimWhitespace(const nsAString& aString);
|
|
|
|
|
|
|
|
static bool ParseKeySplines(const nsAString& aSpec,
|
|
|
|
FallibleTArray<nsSMILKeySpline>& aKeySplines);
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2010-04-28 16:00:54 -07:00
|
|
|
// Used for parsing the |keyTimes| and |keyPoints| attributes.
|
2013-11-25 11:46:20 -08:00
|
|
|
static bool ParseSemicolonDelimitedProgressList(const nsAString& aSpec,
|
|
|
|
bool aNonDecreasing,
|
|
|
|
FallibleTArray<double>& aArray);
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2013-11-25 11:46:20 -08:00
|
|
|
static bool ParseValues(const nsAString& aSpec,
|
|
|
|
const mozilla::dom::SVGAnimationElement* aSrcElement,
|
|
|
|
const nsISMILAttr& aAttribute,
|
|
|
|
FallibleTArray<nsSMILValue>& aValuesArray,
|
|
|
|
bool& aPreventCachingOfSandwich);
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2010-04-28 16:00:53 -07:00
|
|
|
// Generic method that will run some code on each sub-section of an animation
|
|
|
|
// element's "values" list.
|
2013-11-25 11:46:20 -08:00
|
|
|
static bool ParseValuesGeneric(const nsAString& aSpec,
|
|
|
|
GenericValueParser& aParser);
|
2010-01-12 12:00:49 -08:00
|
|
|
|
2013-11-25 11:46:20 -08:00
|
|
|
static bool ParseRepeatCount(const nsAString& aSpec,
|
|
|
|
nsSMILRepeatCount& aResult);
|
2010-01-12 12:00:49 -08:00
|
|
|
|
2013-11-25 11:46:20 -08:00
|
|
|
static bool ParseTimeValueSpecParams(const nsAString& aSpec,
|
|
|
|
nsSMILTimeValueSpecParams& aResult);
|
2009-01-14 20:38:07 -08:00
|
|
|
|
|
|
|
/*
|
2013-11-25 11:46:20 -08:00
|
|
|
* Parses a clock value as defined in the SMIL Animation specification.
|
|
|
|
* If parsing succeeds the returned value will be a non-negative, definite
|
|
|
|
* time value i.e. IsDefinite will return true.
|
2009-01-14 20:38:07 -08:00
|
|
|
*
|
|
|
|
* @param aSpec The string containing a clock value, e.g. "10s"
|
2013-11-25 11:46:20 -08:00
|
|
|
* @param aResult The parsed result. [OUT]
|
|
|
|
* @return true if parsing succeeded, otherwise false.
|
2009-01-14 20:38:07 -08:00
|
|
|
*/
|
2013-11-25 11:46:20 -08:00
|
|
|
static bool ParseClockValue(const nsAString& aSpec,
|
|
|
|
nsSMILTimeValue* aResult);
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2009-10-02 14:37:25 -07:00
|
|
|
/*
|
|
|
|
* This method checks whether the given string looks like a negative number.
|
|
|
|
* Specifically, it checks whether the string looks matches the pattern
|
|
|
|
* "[whitespace]*-[numeral].*" If the string matches this pattern, this
|
|
|
|
* method returns the index of the first character after the '-' sign
|
|
|
|
* (i.e. the index of the absolute value). If not, this method returns -1.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
static int32_t CheckForNegativeNumber(const nsAString& aStr);
|
2009-01-14 20:38:07 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // NS_SMILPARSERUTILS_H_
|