mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 950497 - Make self-referencing CSS variables invalid even if they have fallback. r=dbaron
This commit is contained in:
parent
12910b47d0
commit
ebb7bfe9b8
@ -99,6 +99,7 @@ default-preferences pref(layout.css.variables.enabled,true)
|
||||
== variable-reference-36.html variable-reference-36-ref.html
|
||||
== variable-reference-37.html variable-reference-37-ref.html
|
||||
== variable-reference-38.html variable-reference-38-ref.html
|
||||
== variable-reference-39.html support/color-green-ref.html
|
||||
== variable-supports-01.html support/color-green-ref.html
|
||||
== variable-supports-02.html support/color-green-ref.html
|
||||
== variable-supports-03.html support/color-green-ref.html
|
||||
|
@ -0,0 +1,17 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<title>CSS Test: Test declaring a variable that references itself but uses fallback.</title>
|
||||
<link rel="author" title="Cameron McCormack" href="mailto:cam@mcc.id.au">
|
||||
<link rel="help" href="http://dev.w3.org/csswg/css-variables/#cycles">
|
||||
<link rel="match" href="support/color-green-ref.html">
|
||||
<style>
|
||||
p {
|
||||
color: red;
|
||||
var-a: var(a, red);
|
||||
color: var(a, green);
|
||||
}
|
||||
</style>
|
||||
<p>This text must be green.</p>
|
@ -193,6 +193,12 @@ CSSVariableResolver::Resolve(const CSSVariableValues* aInherited,
|
||||
mReferences[id].AppendElement(i);
|
||||
}
|
||||
}
|
||||
// If a variable references itself, it is invalid. (RemoveCycles
|
||||
// does not check for cycles consisting of a single variable, so we
|
||||
// check here.)
|
||||
if (data.HasReferenceToVariable(id)) {
|
||||
mVariables[id].mValue.Truncate();
|
||||
}
|
||||
// Also record whether it referenced any variables that don't exist
|
||||
// in the resolver, so that we can ensure we still resolve its value
|
||||
// in ResolveVariable, even though its mReferences list is empty.
|
||||
|
@ -25,7 +25,7 @@ var values = [
|
||||
["var-a: var(b)", "var-a", ""],
|
||||
["var-a: var(b); var-b: 1px", "var-a", " 1px"],
|
||||
["var-a: var(b, 1px)", "var-a", " 1px"],
|
||||
["var-a: var(a, 1px)", "var-a", " 1px"],
|
||||
["var-a: var(a, 1px)", "var-a", ""],
|
||||
["var-a: something 3px url(whereever) calc(var(a) + 1px)", "var-a", ""],
|
||||
["var-a: something 3px url(whereever) calc(var(b,1em) + 1px)", "var-a", " something 3px url(whereever) calc(1em + 1px)"],
|
||||
["var-a: var(b, var(c, var(d, Black)))", "var-a", " Black"],
|
||||
|
Loading…
Reference in New Issue
Block a user