本文整理汇总了C#中CssValue类的典型用法代码示例。如果您正苦于以下问题:C# CssValue类的具体用法?C# CssValue怎么用?C# CssValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CssValue类属于命名空间,在下文中一共展示了CssValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveValue
protected static bool MoveValue(ref CssValue aSource, ref CssValue aDest)
{
bool changed = aSource != aDest;
aDest = aSource;
aSource.Reset();
return changed;
}
示例2: PatchValue
// transform 0.04s linear, opacity 0.04s linear, visibility 0.04s linear;
// -webkit-transform 0.04s linear, opacity 0.04s linear, visibility 0.04s linear;
public static CssValue PatchValue(CssValue value, Browser browser)
{
if (value.Kind != NodeKind.ValueList) return value;
var a = (CssValueList)value;
var list = new CssValueList(a.Seperator);
foreach (var node in a)
{
if (node.Kind == NodeKind.ValueList) // For comma seperated componented lists
{
list.Add(PatchValue(node, browser));
}
else if (node.Kind == NodeKind.String && node.ToString() == "transform")
{
list.Add(new CssString(browser.Prefix.Text + "transform"));
}
else
{
list.Add(node);
}
}
return list;
}
示例3: BinaryExpression
// ||, &&, ==, !=
// +, -, *, /, %
public BinaryExpression(CssValue left, BinaryOperator op, CssValue right)
: base(NodeKind.Expression)
{
Left = left;
Operator = op;
Right = right;
}
示例4: PeriodicValue
public PeriodicValue(IPropertyValue[] options, IEnumerable<CssToken> tokens, String[] labels)
{
_top = options[0];
_right = options[1] ?? _top;
_bottom = options[2] ?? _top;
_left = options[3] ?? _right;
_original = new CssValue(tokens);
_labels = labels;
}
示例5: ReadExpressionFrom
public CssValue ReadExpressionFrom(CssValue left)
{
var opToken = Read(); // Read operator
ReadTrivia();
var op = (BinaryOperator)((int)opToken.Kind);
// This may be another expression...
// TODO: Make recurssive
var right = ReadComponent();
return new BinaryExpression(left, op, right);
}
示例6: SetSide
public void SetSide(Side side, CssValue aValue)
{
switch (side) {
case Side.Top:
mTop = aValue;
break;
case Side.Right:
mRight = aValue;
break;
case Side.Bottom:
mBottom = aValue;
break;
case Side.Left:
mLeft = aValue;
break;
default:
throw new ArgumentOutOfRangeException("side");
}
}
示例7: TrySetValue
internal Boolean TrySetValue(CssValue value)
{
var result = false;
if (value == null)
{
result = !IsMinimum && !IsMaximum && Converter.HasDefault();
}
else
{
result = Converter.Convert(value) != null;
}
if (result)
{
_value = value;
}
return result;
}
示例8: Patch
public Patch(string name, CssValue value)
{
Name = name;
Value = value;
}
示例9: GradientValue
public GradientValue(Boolean repeating, IPropertyValue initial, IPropertyValue[] stops, IEnumerable<CssToken> tokens)
{
_repeating = repeating;
_initial = initial;
_stops = stops;
_original = new CssValue(tokens);
}
示例10: GetUnit
//typedef nsCSSValue input_type;
//typedef nsCSSValue::Array input_array_type;
public static CssUnit GetUnit(CssValue aValue)
{
return aValue.GetUnit();
}
示例11: ParseFlex
// flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]
internal bool ParseFlex()
{
// First check for inherit / initial
var tmpVal = new nsCSSValue();
if (ParseVariant(ref tmpVal, VARIANT_INHERIT, null)) {
AppendValue(nsCSSProperty.FlexGrow, tmpVal);
AppendValue(nsCSSProperty.FlexShrink, tmpVal);
AppendValue(nsCSSProperty.FlexBasis, tmpVal);
return true;
}
// Next, check for 'none' == '0 0 auto'
if (ParseVariant(ref tmpVal, VARIANT_NONE, null)) {
AppendValue(nsCSSProperty.FlexGrow, new nsCSSValue(0.0f, nsCSSUnit.Number));
AppendValue(nsCSSProperty.FlexShrink, new nsCSSValue(0.0f, nsCSSUnit.Number));
AppendValue(nsCSSProperty.FlexBasis, new nsCSSValue(nsCSSUnit.Auto));
return true;
}
// OK, try parsing our value as individual per-subproperty components:
// [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]
// Each subproperty has a default value that it takes when it's omitted in a
// "flex" shorthand value. These default values are *only* for the shorthand
// syntax -- they're distinct from the subproperties' own initial values. We
// start with each subproperty at its default, as if we had "flex: 1 1 0%".
var flexGrow = new nsCSSValue(1.0f, nsCSSUnit.Number);
var flexShrink = new nsCSSValue(1.0f, nsCSSUnit.Number);
var flexBasis = new nsCSSValue(0.0f, nsCSSUnit.Percent);
// OVERVIEW OF PARSING STRATEGY:
// =============================
// a) Parse the first component as either flex-basis or flex-grow.
// b) If it wasn't flex-grow, parse the _next_ component as flex-grow.
// c) Now we've just parsed flex-grow -- so try parsing the next thing as
// flex-shrink.
// d) Finally: If we didn't get flex-basis at the beginning, try to parse
// it now, at the end.
//
// More details in each section below.
uint32_t flexBasisVariantMask =
(nsCSSProps.ParserVariant(nsCSSProperty.FlexBasis) & ~(VARIANT_INHERIT));
// (a) Parse first component. It can be either be a 'flex-basis' value or a
// 'flex-grow' value, so we use the flex-basis-specific variant mask, along
// with VARIANT_NUMBER to accept 'flex-grow' values.
//
// NOTE: if we encounter unitless 0 here, we *must* interpret it as a
// 'flex-grow' value (a number), *not* as a 'flex-basis' value (a length).
// Conveniently, that's the behavior this combined variant-mask gives us --
// it'll treat unitless 0 as a number. The flexbox spec requires this:
// "a unitless zero that is not already preceded by two flex factors must be
// interpreted as a flex factor.
if (!ParseNonNegativeVariant(ref tmpVal, flexBasisVariantMask | VARIANT_NUMBER,
nsCSSProps.kWidthKTable)) {
// First component was not a valid flex-basis or flex-grow value. Fail.
return false;
}
// Record what we just parsed as either flex-basis or flex-grow:
bool wasFirstComponentFlexBasis = (tmpVal.GetUnit() != nsCSSUnit.Number);
if (wasFirstComponentFlexBasis) flexBasis = tmpVal; else flexGrow = tmpVal;
// (b) If we didn't get flex-grow yet, parse _next_ component as flex-grow.
bool doneParsing = false;
if (wasFirstComponentFlexBasis) {
if (ParseNonNegativeVariant(ref tmpVal, VARIANT_NUMBER, null)) {
flexGrow = tmpVal;
} else {
// Failed to parse anything after our flex-basis -- that's fine. We can
// skip the remaining parsing.
doneParsing = true;
}
}
if (!doneParsing) {
// (c) OK -- the last thing we parsed was flex-grow, so look for a
// flex-shrink in the next position.
if (ParseNonNegativeVariant(ref tmpVal, VARIANT_NUMBER, null)) {
flexShrink = tmpVal;
}
// d) Finally: If we didn't get flex-basis at the beginning, try to parse
// it now, at the end.
//
// NOTE: If we encounter unitless 0 in this final position, we'll parse it
// as a 'flex-basis' value. That's OK, because we know it must have
// been "preceded by 2 flex factors" (justification below), which gets us
// out of the spec's requirement of otherwise having to treat unitless 0
// as a flex factor.
//
// JUSTIFICATION: How do we know that a unitless 0 here must have been
// preceded by 2 flex factors? Well, suppose we had a unitless 0 that
// was preceded by only 1 flex factor. Then, we would have already
// accepted this unitless 0 as the 'flex-shrink' value, up above (since
// it's a valid flex-shrink value), and we'd have moved on to the next
// token (if any). And of course, if we instead had a unitless 0 preceded
// by *no* flex factors (if it were the first token), we would've already
//.........这里部分代码省略.........
示例12: ParseTextOverflow
internal bool ParseTextOverflow(ref nsCSSValue aValue)
{
if (ParseVariant(ref aValue, VARIANT_INHERIT, null)) {
// 'inherit' and 'initial' must be alone
return true;
}
var left = new nsCSSValue();
if (!ParseVariant(ref left, VARIANT_KEYWORD | VARIANT_STRING,
nsCSSProps.kTextOverflowKTable))
return false;
var right = new nsCSSValue();
if (ParseVariant(ref right, VARIANT_KEYWORD | VARIANT_STRING,
nsCSSProps.kTextOverflowKTable))
aValue.SetPairValue(left, right);
else {
aValue = left;
}
return true;
}
示例13: ParseTransform
/* Parses a transform property list by continuously reading in properties
* and constructing a matrix from it.
*/
bool ParseTransform(bool aIsPrefixed)
{
var value = new nsCSSValue();
if (ParseVariant(ref value, VARIANT_INHERIT | VARIANT_NONE, null)) {
// 'inherit', 'initial', and 'none' must be alone
if (!ExpectEndProperty()) {
return false;
}
} else {
nsCSSValueList cur = value.SetListValue();
for (;;) {
bool is3D = false;
if (!ParseSingleTransform(aIsPrefixed, ref cur.mValue, ref is3D)) {
return false;
}
if (is3D && !nsLayoutUtils.Are3DTransformsEnabled()) {
return false;
}
if (CheckEndProperty()) {
break;
}
cur.mNext = new nsCSSValueList();
cur = cur.mNext;
}
}
AppendValue(nsCSSProperty.Transform, value);
return true;
}
示例14: ParseTransformOrigin
bool ParseTransformOrigin(bool aPerspective)
{
var position = new nsCSSValuePair();
if (!ParseBoxPositionValues(ref position, true))
return false;
nsCSSProperty prop = nsCSSProperty.TransformOrigin;
if (aPerspective) {
if (!ExpectEndProperty()) {
return false;
}
prop = nsCSSProperty.PerspectiveOrigin;
}
// Unlike many other uses of pairs, this position should always be stored
// as a pair, even if the values are the same, so it always serializes as
// a pair, and to keep the computation code simple.
if (position.mXValue.GetUnit() == nsCSSUnit.Inherit ||
position.mXValue.GetUnit() == nsCSSUnit.Initial) {
Debug.Assert(position.mXValue == position.mYValue,
"inherit/initial only half?");
AppendValue(prop, position.mXValue);
} else {
var value = new nsCSSValue();
if (aPerspective) {
value.SetPairValue(position.mXValue, position.mYValue);
} else {
var depth = new nsCSSValue();
if (!nsLayoutUtils.Are3DTransformsEnabled() ||
// only try parsing if 3-D transforms are enabled
!ParseVariant(ref depth, VARIANT_LENGTH | VARIANT_CALC, null)) {
depth.SetFloatValue(0.0f, nsCSSUnit.Pixel);
}
value.SetTripletValue(position.mXValue, position.mYValue, depth);
}
AppendValue(prop, value);
}
return true;
}
示例15: ParseTransitionStepTimingFunctionValues
internal bool ParseTransitionStepTimingFunctionValues(ref nsCSSValue aValue)
{
Debug.Assert(!mHavePushBack &&
mToken.mType == nsCSSTokenType.Function &&
mToken.mIdentStr.LowerCaseEqualsLiteral("steps"),
"unexpected initial state");
nsCSSValue[] val = new nsCSSValue[2];
if (!ParseOneOrLargerVariant(ref val[0], VARIANT_INTEGER, null)) {
return false;
}
int32_t type = nsStyle.TRANSITION_TIMING_FUNCTION_STEP_END;
if (ExpectSymbol(',', true)) {
if (!GetToken(true)) {
return false;
}
type = -1;
if (mToken.mType == nsCSSTokenType.Ident) {
if (mToken.mIdentStr.LowerCaseEqualsLiteral("start")) {
type = nsStyle.TRANSITION_TIMING_FUNCTION_STEP_START;
} else if (mToken.mIdentStr.LowerCaseEqualsLiteral("end")) {
type = nsStyle.TRANSITION_TIMING_FUNCTION_STEP_END;
}
}
if (type == -1) {
UngetToken();
return false;
}
}
val[1].SetIntValue(type, nsCSSUnit.Enumerated);
if (!ExpectSymbol(')', true)) {
return false;
}
aValue.SetArrayValue(val, nsCSSUnit.Steps);
return true;
}