2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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-15 07:38:07 +03:00
|
|
|
|
|
|
|
#ifndef NS_SMILPARSERUTILS_H_
|
|
|
|
#define NS_SMILPARSERUTILS_H_
|
|
|
|
|
|
|
|
#include "nsTArray.h"
|
2013-11-25 23:46:20 +04:00
|
|
|
#include "nsStringFwd.h"
|
2009-01-15 07:38:07 +03:00
|
|
|
|
|
|
|
class nsISMILAttr;
|
|
|
|
|
2013-03-19 07:18:45 +04:00
|
|
|
namespace mozilla {
|
2019-01-23 16:48:08 +03:00
|
|
|
|
2019-01-21 16:08:12 +03:00
|
|
|
class SMILKeySpline;
|
|
|
|
class SMILRepeatCount;
|
2019-01-22 10:28:40 +03:00
|
|
|
class SMILTimeValue;
|
|
|
|
class SMILTimeValueSpecParams;
|
2019-01-23 16:48:08 +03:00
|
|
|
class SMILValue;
|
|
|
|
|
2013-03-19 07:18:45 +04:00
|
|
|
namespace dom {
|
|
|
|
class SVGAnimationElement;
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
2013-03-19 07:18:45 +04:00
|
|
|
|
2009-01-15 07:38:07 +03: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.
|
|
|
|
*/
|
2019-01-08 10:55:14 +03:00
|
|
|
class SMILParserUtils {
|
2009-01-15 07:38:07 +03:00
|
|
|
public:
|
2010-04-29 03:00:53 +04:00
|
|
|
// Abstract helper-class for assisting in parsing |values| attribute
|
2013-11-25 23:46:20 +04:00
|
|
|
class MOZ_STACK_CLASS GenericValueParser {
|
2010-04-29 03:00:53 +04:00
|
|
|
public:
|
2013-11-25 23:46:20 +04:00
|
|
|
virtual bool Parse(const nsAString& aValueStr) = 0;
|
2010-04-29 03:00:53 +04:00
|
|
|
};
|
|
|
|
|
2013-11-25 23:46:20 +04:00
|
|
|
static const nsDependentSubstring TrimWhitespace(const nsAString& aString);
|
|
|
|
|
|
|
|
static bool ParseKeySplines(const nsAString& aSpec,
|
2019-01-08 10:55:14 +03:00
|
|
|
FallibleTArray<SMILKeySpline>& aKeySplines);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2010-04-29 03:00:54 +04:00
|
|
|
// Used for parsing the |keyTimes| and |keyPoints| attributes.
|
2013-11-25 23:46:20 +04:00
|
|
|
static bool ParseSemicolonDelimitedProgressList(
|
|
|
|
const nsAString& aSpec, bool aNonDecreasing,
|
|
|
|
FallibleTArray<double>& aArray);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2013-11-25 23:46:20 +04:00
|
|
|
static bool ParseValues(const nsAString& aSpec,
|
|
|
|
const mozilla::dom::SVGAnimationElement* aSrcElement,
|
|
|
|
const nsISMILAttr& aAttribute,
|
2019-01-23 16:48:08 +03:00
|
|
|
FallibleTArray<SMILValue>& aValuesArray,
|
2013-11-25 23:46:20 +04:00
|
|
|
bool& aPreventCachingOfSandwich);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2010-04-29 03:00:53 +04:00
|
|
|
// Generic method that will run some code on each sub-section of an animation
|
|
|
|
// element's "values" list.
|
2013-11-25 23:46:20 +04:00
|
|
|
static bool ParseValuesGeneric(const nsAString& aSpec,
|
|
|
|
GenericValueParser& aParser);
|
2010-01-12 23:00:49 +03:00
|
|
|
|
2013-11-25 23:46:20 +04:00
|
|
|
static bool ParseRepeatCount(const nsAString& aSpec,
|
2019-01-21 16:08:12 +03:00
|
|
|
SMILRepeatCount& aResult);
|
2010-01-12 23:00:49 +03:00
|
|
|
|
2013-11-25 23:46:20 +04:00
|
|
|
static bool ParseTimeValueSpecParams(const nsAString& aSpec,
|
2019-01-22 10:28:40 +03:00
|
|
|
SMILTimeValueSpecParams& aResult);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
|
|
|
/*
|
2013-11-25 23:46:20 +04: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-15 07:38:07 +03:00
|
|
|
*
|
|
|
|
* @param aSpec The string containing a clock value, e.g. "10s"
|
2013-11-25 23:46:20 +04:00
|
|
|
* @param aResult The parsed result. [OUT]
|
|
|
|
* @return true if parsing succeeded, otherwise false.
|
2009-01-15 07:38:07 +03:00
|
|
|
*/
|
2019-01-22 10:28:40 +03:00
|
|
|
static bool ParseClockValue(const nsAString& aSpec, SMILTimeValue* aResult);
|
2009-01-15 07:38:07 +03:00
|
|
|
|
2009-10-03 01:37:25 +04: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 19:56:38 +04:00
|
|
|
static int32_t CheckForNegativeNumber(const nsAString& aStr);
|
2009-01-15 07:38:07 +03:00
|
|
|
};
|
|
|
|
|
2019-01-08 10:55:14 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2009-01-15 07:38:07 +03:00
|
|
|
#endif // NS_SMILPARSERUTILS_H_
|