[css-properties-values-api] Support fallbacks.

According to css-variables-1, any custom property that participates in a
cycle is invalid. This also applies to registered custom properties.
In the current implementation, however, registered custom properties
with an initial value can not become invalid; they compute to their initial
value instead, as provided by registerProperty. A consequence of this, is
that fallbacks (specified by var()-references) are never triggered if the
referenced property is a registered property with an initial value defined.

The value for any unregistered custom property, if no other value is
specified, is the invalid initial value described by css-variables-1.
This means we can just avoid storing the variable on ComputedStyle, to
signify the invalid initial value.

However, the value for any registered custom property, if no other value is
specified, can be the initial value specified by registerProperty. When
there is no value explicitly stored on ComputedStyle, we check
StyleInitialData and fetch the initial value from there. Hence, we can not
use the absence of a value to signify an invalid registered variable, as
we already use this state to mean "initial value from registerProperty".
This means that we must explicitly store a value for registered properties
that participate in a cycle. This CL adds CSSInvalidVariableValue to do
this.

 * When resolving a registered custom property, if a cycle is detected, set
   the registered value to CSSInvalidVariableValue.
 * When looking up a registered custom property, if we already have the
   value CSSInvalidVariableValue, return nullptr instead of initial data.
   This triggers fallbacks.
 * The code that set the cycle_detected flag was weird; a cycle could be
   marked as detected, even though ResolveTokenRange succeeded. This meant
   that any custom property which referenced a property in a cycle would
   also be treated as part of the cycle, which is wrong. Fixed by only
   setting the cycle_detected flag when we have cycle start points.
 * CSSInterpolationType did not initialize its cycle_detected variable,
   which led to undefined behavior.

R=futhark@chromium.org

Bug: 641877
Change-Id: I2c518b176de26f7b2f05b36b568041a228fcb0ea
Reviewed-on: https://chromium-review.googlesource.com/c/1333758
Commit-Queue: Anders Ruud <andruud@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608014}
13 files changed