mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 23:27:30 +09:00
Merge remote-tracking branch 'origin/tracking' into custom
This commit is contained in:
commit
8a4c2cbeff
2 changed files with 61 additions and 23 deletions
|
|
@ -2640,6 +2640,25 @@ StopRecordingAndAppendTokens(nsString& aResult,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
ResolveEnvironmentVariable(const nsAString& aName,
|
||||||
|
nsString& aValue,
|
||||||
|
nsCSSTokenSerializationType& aFirstToken,
|
||||||
|
nsCSSTokenSerializationType& aLastToken)
|
||||||
|
{
|
||||||
|
// hard-code the few values of the Environment Variables spec
|
||||||
|
if (aName.EqualsLiteral("safe-area-inset-top") ||
|
||||||
|
aName.EqualsLiteral("safe-area-inset-bottom") ||
|
||||||
|
aName.EqualsLiteral("safe-area-inset-left") ||
|
||||||
|
aName.EqualsLiteral("safe-area-inset-right")) {
|
||||||
|
aValue.AppendLiteral(" 0px");
|
||||||
|
aFirstToken = eCSSTokenSerialization_Whitespace;
|
||||||
|
aLastToken = eCSSTokenSerialization_Dimension;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CSSParserImpl::ResolveValueWithVariableReferencesRec(
|
CSSParserImpl::ResolveValueWithVariableReferencesRec(
|
||||||
nsString& aResult,
|
nsString& aResult,
|
||||||
|
|
@ -2757,8 +2776,10 @@ CSSParserImpl::ResolveValueWithVariableReferencesRec(
|
||||||
}
|
}
|
||||||
|
|
||||||
case eCSSToken_Function:
|
case eCSSToken_Function:
|
||||||
if (mToken.mIdent.LowerCaseEqualsLiteral("var")) {
|
if (mToken.mIdent.LowerCaseEqualsLiteral("env") ||
|
||||||
// Save the tokens before the "var(" to our resolved value.
|
mToken.mIdent.LowerCaseEqualsLiteral("var")) {
|
||||||
|
bool functionIsVariable = mToken.mIdent.LowerCaseEqualsLiteral("var");
|
||||||
|
// Save the tokens before the "env(" to our resolved value.
|
||||||
nsString recording;
|
nsString recording;
|
||||||
mScanner->StopRecording(recording);
|
mScanner->StopRecording(recording);
|
||||||
recording.Truncate(lengthBeforeVar);
|
recording.Truncate(lengthBeforeVar);
|
||||||
|
|
@ -2768,10 +2789,20 @@ CSSParserImpl::ResolveValueWithVariableReferencesRec(
|
||||||
recLastToken = eCSSTokenSerialization_Nothing;
|
recLastToken = eCSSTokenSerialization_Nothing;
|
||||||
|
|
||||||
if (!GetToken(true) ||
|
if (!GetToken(true) ||
|
||||||
mToken.mType != eCSSToken_Ident ||
|
mToken.mType != eCSSToken_Ident) {
|
||||||
!nsCSSProps::IsCustomPropertyName(mToken.mIdent)) {
|
// function must be followed by an identifier
|
||||||
// "var(" must be followed by an identifier, and it must be a
|
return false;
|
||||||
// custom property name.
|
}
|
||||||
|
|
||||||
|
// Expand the function call into variableValue
|
||||||
|
nsString variableValue;
|
||||||
|
nsCSSTokenSerializationType varFirstToken = eCSSTokenSerialization_Nothing;
|
||||||
|
nsCSSTokenSerializationType varLastToken = eCSSTokenSerialization_Nothing;
|
||||||
|
bool valid = false;
|
||||||
|
|
||||||
|
if (functionIsVariable) {
|
||||||
|
if (!nsCSSProps::IsCustomPropertyName(mToken.mIdent)) {
|
||||||
|
// "var(" identifier must be a custom property name.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2787,11 +2818,14 @@ CSSParserImpl::ResolveValueWithVariableReferencesRec(
|
||||||
// check if the variable value is the empty string, as that means
|
// check if the variable value is the empty string, as that means
|
||||||
// that the variable was invalid at computed value time due to
|
// that the variable was invalid at computed value time due to
|
||||||
// unresolveable variable references or cycles.
|
// unresolveable variable references or cycles.
|
||||||
nsString variableValue;
|
valid = aVariables->Get(variableName, variableValue,
|
||||||
nsCSSTokenSerializationType varFirstToken, varLastToken;
|
|
||||||
bool valid = aVariables->Get(variableName, variableValue,
|
|
||||||
varFirstToken, varLastToken) &&
|
varFirstToken, varLastToken) &&
|
||||||
!variableValue.IsEmpty();
|
!variableValue.IsEmpty();
|
||||||
|
} else {
|
||||||
|
valid = ResolveEnvironmentVariable(mToken.mIdent, variableValue,
|
||||||
|
varFirstToken,varLastToken) &&
|
||||||
|
!variableValue.IsEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
if (!GetToken(true) ||
|
if (!GetToken(true) ||
|
||||||
mToken.IsSymbol(')')) {
|
mToken.IsSymbol(')')) {
|
||||||
|
|
|
||||||
|
|
@ -752,7 +752,11 @@ nsCSSScanner::ScanIdent(nsCSSToken& aToken)
|
||||||
aToken.mType = eCSSToken_Function;
|
aToken.mType = eCSSToken_Function;
|
||||||
if (aToken.mIdent.LowerCaseEqualsLiteral("url")) {
|
if (aToken.mIdent.LowerCaseEqualsLiteral("url")) {
|
||||||
NextURL(aToken);
|
NextURL(aToken);
|
||||||
} else if (aToken.mIdent.LowerCaseEqualsLiteral("var")) {
|
} else if (aToken.mIdent.LowerCaseEqualsLiteral("var") ||
|
||||||
|
aToken.mIdent.LowerCaseEqualsLiteral("env")) {
|
||||||
|
// env() queries are technically not variables, but share all the
|
||||||
|
// same handling. For the purposes of resolving the token stream later,
|
||||||
|
// pretend they are.
|
||||||
mSeenVariableReference = true;
|
mSeenVariableReference = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue