Files
palemoon27/layout/style/CSSVariableResolver.h
T
roytam1 1e81c8f57e import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1218918 - Issues with devtools "work offline" when connectivity changes r=mcmanus,dao (4b3488c7ed)
- Bug 1218315 - Replace NS_LITERAL_STRING(...).get() with MOZ_UTF16(...) on netwerk. r=nfroyd (4669777bb8)
- Bug 1069417 - Fix an error introduced when rebasing across bug 1021845 to reopen a CLOSED TREE. r=bustage (72ca0b4524)
- Bug 1069471 - Add a ViewAs() overload for matrices. r=kats (73b2f2070d)
- Bug 1212876 - Fix a bug in UntransformVector and in code that was relying on that bug. r=botond (8ae25438e2)
- Bug 1069417 - Modify TransformTo() and related functions to use typed matrices. r=kats (53338d1f4c)
- Bug 1069417 - Remove the explicit template argument of TransformTo() and related functions. r=kats (3db2cd1452)
- Bug 1069417 - Add typedefs for commonly used typed matrices. r=kats (5fa203c4d8)
- Bug 1225018 part 1 - Trigger reflow on some text emphasis changes for line height calculation. r=dbaron (e431d73a6d)
- Bug 1225018 part 3 - Use font metrics of emphasis marks to compute required leading. r=jfkthame (6690cd2fd6)
- Bug 1225018 part 4 - Ensure leading for emphasis marks of text directly inside block. r=jfkthame (b5b771cdaa)
- Bug 1224013 part 3 - Add reftests for text-emphasis with ruby. r=jfkthame (4b0fbbb8d1)
- Bug 1225018 part 5 - Add reftests for line height handling of text-emphasis. r=dholbert (9b876def46)
- Bug 1202940 part 1 - Move html.css and ua.css back to be loaded in constructor of nsLayoutStylesheetCache. r=dbaron (e23014579e)
- Bug 1077521 - Allow tables to use vertical writing modes. r=smontagu (2d6af4318e)
- Bug 1157083 <abbr> and <acronym> should use dotted underline of text-decoration instead of border-bottom r=dbaron (65c08fb512)
- Bug 1147459 - Update rule of fullscreen iframe to meet the spec. r=roc (4d2d262c2c)
- Bug 1141928 part 3 - Reftest for simple RTL case. r=jfkthame (fe0e512c1f)
- Bug 1202940 part 2 - Remove layout.css.ruby.enabled pref. r=dbaron (3f67dd7c3f)
- Bug 1224013 part 1 - Enable text-emphasis in UA sheets. r=dbaron (2213ee91b2)
- Bug 1224013 part 2 - Render text-emphasis outside ruby. r=jfkthame (533d79c988)
- Bug 1226489 - Pass only a single rule to StyleRuleChanged. r=bzbarsky (1eb206b427)
- Bug 732209 way delayed followup. Make the comments a bit clearer. DONTBUILD (acdf2554ee)
- Bug 1162608: Import cssfixme's radial-gradient unprefixing fix into CSSUnprefixingService. r=hallvors (77c3ac6813)
- Bug 1160281 - Add support for -webkit-transform-origin via CSS Unprefixing Service. r=dholbert (29ef22fe5c)
- (no bug) Remove a stale reference to a fixed bug in a comment. DONTBUILD, comment-only (64d351d868)
- Bug 1205486 - Release the ImageValues in an nsStyleContext's CSSVariableImageTable entries outside of hashtable methods to avoid re-entrancy problems. r=seth (63756da470)
- Comment typo fix; no bug. (DONTBUILD) (72842512af)
- Bug 1197307 - remove PR_snprintf calls in layout/ r=froydnj r=dholbert (fb0e969449)
- Bug 1154356 - Escape variable name in Declaration::AppendVariableAndValueToString. r=heycam (27e8032270)
2023-05-15 12:06:32 +08:00

149 lines
4.4 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/. */
/* object that resolves CSS variables using specified and inherited variable
* values
*/
#ifndef mozilla_CSSVariableResolver_h
#define mozilla_CSSVariableResolver_h
#include "mozilla/DebugOnly.h"
#include "nsCSSParser.h"
#include "nsCSSScanner.h"
#include "nsDataHashtable.h"
#include "nsTArray.h"
namespace mozilla {
class CSSVariableDeclarations;
class CSSVariableValues;
class EnumerateVariableReferencesData;
class CSSVariableResolver
{
friend class CSSVariableDeclarations;
friend class CSSVariableValues;
friend class EnumerateVariableReferencesData;
public:
/**
* Creates a new CSSVariableResolver that will output a set of resolved,
* computed variables into aOutput.
*/
explicit CSSVariableResolver(CSSVariableValues* aOutput)
: mOutput(aOutput)
#ifdef DEBUG
, mResolved(false)
#endif
{
MOZ_ASSERT(aOutput);
}
/**
* Resolves the set of inherited variables from aInherited and the
* set of specified variables from aSpecified. The resolved variables
* are written into mOutput.
*/
void Resolve(const CSSVariableValues* aInherited,
const CSSVariableDeclarations* aSpecified);
private:
struct Variable
{
Variable(const nsAString& aVariableName,
nsString aValue,
nsCSSTokenSerializationType aFirstToken,
nsCSSTokenSerializationType aLastToken,
bool aWasInherited)
: mVariableName(aVariableName)
, mValue(aValue)
, mFirstToken(aFirstToken)
, mLastToken(aLastToken)
, mWasInherited(aWasInherited)
, mResolved(false)
, mReferencesNonExistentVariable(false)
, mInStack(false)
, mIndex(0)
, mLowLink(0) { }
nsString mVariableName;
nsString mValue;
nsCSSTokenSerializationType mFirstToken;
nsCSSTokenSerializationType mLastToken;
// Whether this variable came from the set of inherited variables.
bool mWasInherited;
// Whether this variable has been resolved yet.
bool mResolved;
// Whether this variables includes any references to non-existent variables.
bool mReferencesNonExistentVariable;
// Bookkeeping for the cycle remover algorithm.
bool mInStack;
size_t mIndex;
size_t mLowLink;
};
/**
* Adds or modifies an existing entry in the set of variables to be resolved.
* This is intended to be called by the AddVariablesToResolver functions on
* the CSSVariableDeclarations and CSSVariableValues objects passed in to
* Resolve.
*
* @param aName The variable name (not including any "--" 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.
* @param aWasInherited Whether this variable came from the set of inherited
* variables.
*/
void Put(const nsAString& aVariableName,
nsString aValue,
nsCSSTokenSerializationType aFirstToken,
nsCSSTokenSerializationType aLastToken,
bool aWasInherited);
// Helper functions for Resolve.
void RemoveCycles(size_t aID);
void ResolveVariable(size_t aID);
// A mapping of variable names to an ID that indexes into mVariables
// and mReferences.
nsDataHashtable<nsStringHashKey, size_t> mVariableIDs;
// The set of variables.
nsTArray<Variable> mVariables;
// The list of variables that each variable references.
nsTArray<nsTArray<size_t> > mReferences;
// The next index to assign to a variable found during the cycle removing
// algorithm's traversal of the variable reference graph.
size_t mNextIndex;
// Stack of variable IDs that we push to as we traverse the variable reference
// graph while looking for cycles. Variable::mInStack reflects whether a
// given variable has its ID in mStack.
nsTArray<size_t> mStack;
// CSS parser to use for parsing property values with variable references.
nsCSSParser mParser;
// The object to output the resolved variables into.
CSSVariableValues* mOutput;
#ifdef DEBUG
// Whether Resolve has been called.
bool mResolved;
#endif
};
} // namespace mozilla
#endif