dom/smil/nsSMILParserUtils.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef NS_SMILPARSERUTILS_H_
michael@0 7 #define NS_SMILPARSERUTILS_H_
michael@0 8
michael@0 9 #include "nsTArray.h"
michael@0 10 #include "nsStringFwd.h"
michael@0 11
michael@0 12 class nsISMILAttr;
michael@0 13 class nsSMILKeySpline;
michael@0 14 class nsSMILTimeValue;
michael@0 15 class nsSMILValue;
michael@0 16 class nsSMILRepeatCount;
michael@0 17 class nsSMILTimeValueSpecParams;
michael@0 18
michael@0 19 namespace mozilla {
michael@0 20 namespace dom {
michael@0 21 class SVGAnimationElement;
michael@0 22 }
michael@0 23 }
michael@0 24
michael@0 25 /**
michael@0 26 * Common parsing utilities for the SMIL module. There is little re-use here; it
michael@0 27 * simply serves to simplify other classes by moving parsing outside and to aid
michael@0 28 * unit testing.
michael@0 29 */
michael@0 30 class nsSMILParserUtils
michael@0 31 {
michael@0 32 public:
michael@0 33 // Abstract helper-class for assisting in parsing |values| attribute
michael@0 34 class MOZ_STACK_CLASS GenericValueParser {
michael@0 35 public:
michael@0 36 virtual bool Parse(const nsAString& aValueStr) = 0;
michael@0 37 };
michael@0 38
michael@0 39 static const nsDependentSubstring TrimWhitespace(const nsAString& aString);
michael@0 40
michael@0 41 static bool ParseKeySplines(const nsAString& aSpec,
michael@0 42 FallibleTArray<nsSMILKeySpline>& aKeySplines);
michael@0 43
michael@0 44 // Used for parsing the |keyTimes| and |keyPoints| attributes.
michael@0 45 static bool ParseSemicolonDelimitedProgressList(const nsAString& aSpec,
michael@0 46 bool aNonDecreasing,
michael@0 47 FallibleTArray<double>& aArray);
michael@0 48
michael@0 49 static bool ParseValues(const nsAString& aSpec,
michael@0 50 const mozilla::dom::SVGAnimationElement* aSrcElement,
michael@0 51 const nsISMILAttr& aAttribute,
michael@0 52 FallibleTArray<nsSMILValue>& aValuesArray,
michael@0 53 bool& aPreventCachingOfSandwich);
michael@0 54
michael@0 55 // Generic method that will run some code on each sub-section of an animation
michael@0 56 // element's "values" list.
michael@0 57 static bool ParseValuesGeneric(const nsAString& aSpec,
michael@0 58 GenericValueParser& aParser);
michael@0 59
michael@0 60 static bool ParseRepeatCount(const nsAString& aSpec,
michael@0 61 nsSMILRepeatCount& aResult);
michael@0 62
michael@0 63 static bool ParseTimeValueSpecParams(const nsAString& aSpec,
michael@0 64 nsSMILTimeValueSpecParams& aResult);
michael@0 65
michael@0 66 /*
michael@0 67 * Parses a clock value as defined in the SMIL Animation specification.
michael@0 68 * If parsing succeeds the returned value will be a non-negative, definite
michael@0 69 * time value i.e. IsDefinite will return true.
michael@0 70 *
michael@0 71 * @param aSpec The string containing a clock value, e.g. "10s"
michael@0 72 * @param aResult The parsed result. [OUT]
michael@0 73 * @return true if parsing succeeded, otherwise false.
michael@0 74 */
michael@0 75 static bool ParseClockValue(const nsAString& aSpec,
michael@0 76 nsSMILTimeValue* aResult);
michael@0 77
michael@0 78 /*
michael@0 79 * This method checks whether the given string looks like a negative number.
michael@0 80 * Specifically, it checks whether the string looks matches the pattern
michael@0 81 * "[whitespace]*-[numeral].*" If the string matches this pattern, this
michael@0 82 * method returns the index of the first character after the '-' sign
michael@0 83 * (i.e. the index of the absolute value). If not, this method returns -1.
michael@0 84 */
michael@0 85 static int32_t CheckForNegativeNumber(const nsAString& aStr);
michael@0 86 };
michael@0 87
michael@0 88 #endif // NS_SMILPARSERUTILS_H_

mercurial