mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
116 lines
3.6 KiB
C
116 lines
3.6 KiB
C
|
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
||
|
/* 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/. */
|
||
|
|
||
|
/* computed CSS Variable values */
|
||
|
|
||
|
#ifndef mozilla_CSSVariableValues_h
|
||
|
#define mozilla_CSSVariableValues_h
|
||
|
|
||
|
#include "nsCSSScanner.h"
|
||
|
#include "nsDataHashtable.h"
|
||
|
#include "nsTArray.h"
|
||
|
|
||
|
namespace mozilla {
|
||
|
|
||
|
class CSSVariableValues
|
||
|
{
|
||
|
public:
|
||
|
CSSVariableValues();
|
||
|
CSSVariableValues(const CSSVariableValues& aOther);
|
||
|
#ifdef DEBUG
|
||
|
~CSSVariableValues();
|
||
|
#endif
|
||
|
CSSVariableValues& operator=(const CSSVariableValues& aOther);
|
||
|
|
||
|
/**
|
||
|
* Gets the value of a variable in this set of computed variables.
|
||
|
*
|
||
|
* @param aName The variable name (not including any "var-" prefix that would
|
||
|
* be part of the custom property name).
|
||
|
* @param aValue Out parameter into which the value of the variable will
|
||
|
* be stored.
|
||
|
* @return Whether a variable with the given name was found. When false
|
||
|
* is returned, aValue will not be modified.
|
||
|
*/
|
||
|
bool Get(const nsAString& aName, nsString& aValue) const;
|
||
|
|
||
|
/**
|
||
|
* Gets the value of a variable in this set of computed variables, along
|
||
|
* with information on the types of tokens that appear at the start and
|
||
|
* end of the token stream.
|
||
|
*
|
||
|
* @param aName The variable name (not including any "var-" prefix that would
|
||
|
* be part of the custom property name).
|
||
|
* @param aValue Out parameter into which the value of the variable will
|
||
|
* be stored.
|
||
|
* @param aFirstToken The type of token at the start of the variable value.
|
||
|
* @param aLastToken The type of token at the en of the variable value.
|
||
|
* @return Whether a variable with the given name was found. When false
|
||
|
* is returned, aValue, aFirstToken and aLastToken will not be modified.
|
||
|
*/
|
||
|
bool Get(const nsAString& aName,
|
||
|
nsString& aValue,
|
||
|
nsCSSTokenSerializationType& aFirstToken,
|
||
|
nsCSSTokenSerializationType& aLastToken) const;
|
||
|
|
||
|
/**
|
||
|
* Adds or modifies an existing entry in this set of variable values.
|
||
|
*
|
||
|
* @param aName The variable name (not including any "var-" prefix that would
|
||
|
* be part of the custom property name) whose value is to be set.
|
||
|
* @param aValue The variable value.
|
||
|
* @param aFirstToken The type of token at the start of the variable value.
|
||
|
* @param aLastToken The type of token at the en of the variable value.
|
||
|
*/
|
||
|
void Put(const nsAString& aName,
|
||
|
nsString aValue,
|
||
|
nsCSSTokenSerializationType aFirstToken,
|
||
|
nsCSSTokenSerializationType aLastToken);
|
||
|
|
||
|
private:
|
||
|
struct Variable
|
||
|
{
|
||
|
Variable()
|
||
|
: mFirstToken(eCSSTokenSerialization_Nothing)
|
||
|
, mLastToken(eCSSTokenSerialization_Nothing)
|
||
|
{}
|
||
|
|
||
|
Variable(const nsAString& aVariableName,
|
||
|
nsString aValue,
|
||
|
nsCSSTokenSerializationType aFirstToken,
|
||
|
nsCSSTokenSerializationType aLastToken)
|
||
|
: mVariableName(aVariableName)
|
||
|
, mValue(aValue)
|
||
|
, mFirstToken(aFirstToken)
|
||
|
, mLastToken(aLastToken)
|
||
|
{}
|
||
|
|
||
|
nsString mVariableName;
|
||
|
nsString mValue;
|
||
|
nsCSSTokenSerializationType mFirstToken;
|
||
|
nsCSSTokenSerializationType mLastToken;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* Adds all the variables from aOther into this object.
|
||
|
*/
|
||
|
void CopyVariablesFrom(const CSSVariableValues& aOther);
|
||
|
|
||
|
/**
|
||
|
* Map of variable names to IDs. Variable IDs are indexes into
|
||
|
* mVariables.
|
||
|
*/
|
||
|
nsDataHashtable<nsStringHashKey, size_t> mVariableIDs;
|
||
|
|
||
|
/**
|
||
|
* Array of variables, indexed by variable ID.
|
||
|
*/
|
||
|
nsTArray<Variable> mVariables;
|
||
|
};
|
||
|
|
||
|
} // namespace mozilla
|
||
|
|
||
|
#endif
|