layout/style/CSSVariableValues.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
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 /* computed CSS Variable values */
michael@0 7
michael@0 8 #ifndef mozilla_CSSVariableValues_h
michael@0 9 #define mozilla_CSSVariableValues_h
michael@0 10
michael@0 11 #include "nsCSSScanner.h"
michael@0 12 #include "nsDataHashtable.h"
michael@0 13 #include "nsTArray.h"
michael@0 14
michael@0 15 namespace mozilla {
michael@0 16
michael@0 17 class CSSVariableResolver;
michael@0 18
michael@0 19 class CSSVariableValues
michael@0 20 {
michael@0 21 public:
michael@0 22 CSSVariableValues();
michael@0 23 CSSVariableValues(const CSSVariableValues& aOther);
michael@0 24 #ifdef DEBUG
michael@0 25 ~CSSVariableValues();
michael@0 26 #endif
michael@0 27 CSSVariableValues& operator=(const CSSVariableValues& aOther);
michael@0 28
michael@0 29 bool operator==(const CSSVariableValues& aOther) const;
michael@0 30 bool operator!=(const CSSVariableValues& aOther) const
michael@0 31 { return !(*this == aOther); }
michael@0 32
michael@0 33 /**
michael@0 34 * Gets the value of a variable in this set of computed variables.
michael@0 35 *
michael@0 36 * @param aName The variable name (not including any "--" prefix that would
michael@0 37 * be part of the custom property name).
michael@0 38 * @param aValue Out parameter into which the value of the variable will
michael@0 39 * be stored.
michael@0 40 * @return Whether a variable with the given name was found. When false
michael@0 41 * is returned, aValue will not be modified.
michael@0 42 */
michael@0 43 bool Get(const nsAString& aName, nsString& aValue) const;
michael@0 44
michael@0 45 /**
michael@0 46 * Gets the value of a variable in this set of computed variables, along
michael@0 47 * with information on the types of tokens that appear at the start and
michael@0 48 * end of the token stream.
michael@0 49 *
michael@0 50 * @param aName The variable name (not including any "--" prefix that would
michael@0 51 * be part of the custom property name).
michael@0 52 * @param aValue Out parameter into which the value of the variable will
michael@0 53 * be stored.
michael@0 54 * @param aFirstToken The type of token at the start of the variable value.
michael@0 55 * @param aLastToken The type of token at the en of the variable value.
michael@0 56 * @return Whether a variable with the given name was found. When false
michael@0 57 * is returned, aValue, aFirstToken and aLastToken will not be modified.
michael@0 58 */
michael@0 59 bool Get(const nsAString& aName,
michael@0 60 nsString& aValue,
michael@0 61 nsCSSTokenSerializationType& aFirstToken,
michael@0 62 nsCSSTokenSerializationType& aLastToken) const;
michael@0 63
michael@0 64 /**
michael@0 65 * Gets the name of the variable at the given index.
michael@0 66 *
michael@0 67 * Variables on this object are ordered, and that order is just determined
michael@0 68 * based on the order that they are added to the object. A consistent
michael@0 69 * ordering is required for CSSDeclaration objects in the DOM.
michael@0 70 * CSSDeclarations expose property names as indexed properties, which need to
michael@0 71 * be stable.
michael@0 72 *
michael@0 73 * @param aIndex The index of the variable to get.
michael@0 74 * @param aName Out parameter into which the name of the variable will be
michael@0 75 * stored.
michael@0 76 */
michael@0 77 void GetVariableAt(size_t aIndex, nsAString& aName) const;
michael@0 78
michael@0 79 /**
michael@0 80 * Gets the number of variables stored on this object.
michael@0 81 */
michael@0 82 size_t Count() const;
michael@0 83
michael@0 84 /**
michael@0 85 * Adds or modifies an existing entry in this set of variable values.
michael@0 86 *
michael@0 87 * @param aName The variable name (not including any "--" prefix that would
michael@0 88 * be part of the custom property name) whose value is to be set.
michael@0 89 * @param aValue The variable value.
michael@0 90 * @param aFirstToken The type of token at the start of the variable value.
michael@0 91 * @param aLastToken The type of token at the en of the variable value.
michael@0 92 */
michael@0 93 void Put(const nsAString& aName,
michael@0 94 nsString aValue,
michael@0 95 nsCSSTokenSerializationType aFirstToken,
michael@0 96 nsCSSTokenSerializationType aLastToken);
michael@0 97
michael@0 98 /**
michael@0 99 * Copies the variables from this object into aResolver, marking them as
michael@0 100 * computed, inherited values.
michael@0 101 */
michael@0 102 void AddVariablesToResolver(CSSVariableResolver* aResolver) const;
michael@0 103
michael@0 104 private:
michael@0 105 struct Variable
michael@0 106 {
michael@0 107 Variable()
michael@0 108 : mFirstToken(eCSSTokenSerialization_Nothing)
michael@0 109 , mLastToken(eCSSTokenSerialization_Nothing)
michael@0 110 {}
michael@0 111
michael@0 112 Variable(const nsAString& aVariableName,
michael@0 113 nsString aValue,
michael@0 114 nsCSSTokenSerializationType aFirstToken,
michael@0 115 nsCSSTokenSerializationType aLastToken)
michael@0 116 : mVariableName(aVariableName)
michael@0 117 , mValue(aValue)
michael@0 118 , mFirstToken(aFirstToken)
michael@0 119 , mLastToken(aLastToken)
michael@0 120 {}
michael@0 121
michael@0 122 nsString mVariableName;
michael@0 123 nsString mValue;
michael@0 124 nsCSSTokenSerializationType mFirstToken;
michael@0 125 nsCSSTokenSerializationType mLastToken;
michael@0 126 };
michael@0 127
michael@0 128 /**
michael@0 129 * Adds all the variables from aOther into this object.
michael@0 130 */
michael@0 131 void CopyVariablesFrom(const CSSVariableValues& aOther);
michael@0 132
michael@0 133 /**
michael@0 134 * Map of variable names to IDs. Variable IDs are indexes into
michael@0 135 * mVariables.
michael@0 136 */
michael@0 137 nsDataHashtable<nsStringHashKey, size_t> mVariableIDs;
michael@0 138
michael@0 139 /**
michael@0 140 * Array of variables, indexed by variable ID.
michael@0 141 */
michael@0 142 nsTArray<Variable> mVariables;
michael@0 143 };
michael@0 144
michael@0 145 } // namespace mozilla
michael@0 146
michael@0 147 #endif

mercurial