本文整理汇总了C#中CssValue.SetRectValue方法的典型用法代码示例。如果您正苦于以下问题:C# CssValue.SetRectValue方法的具体用法?C# CssValue.SetRectValue怎么用?C# CssValue.SetRectValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CssValue
的用法示例。
在下文中一共展示了CssValue.SetRectValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseRect
internal bool ParseRect(nsCSSProperty aPropID)
{
if (! GetToken(true)) {
return false;
}
var val = new nsCSSValue();
if (mToken.mType == nsCSSTokenType.Ident) {
nsCSSKeyword keyword = nsCSSKeywords.LookupKeyword(mToken.mIdentStr);
switch (keyword) {
case nsCSSKeyword.auto:
if (!ExpectEndProperty()) {
return false;
}
val.SetAutoValue();
break;
case nsCSSKeyword.inherit:
if (!ExpectEndProperty()) {
return false;
}
val.SetInheritValue();
break;
case nsCSSKeyword.initial:
case nsCSSKeyword._moz_initial:
if (!ExpectEndProperty()) {
return false;
}
val.SetInitialValue();
break;
default:
UngetToken();
return false;
}
} else if (mToken.mType == nsCSSTokenType.Function &&
mToken.mIdentStr.LowerCaseEqualsLiteral("rect")) {
nsCSSRect rect = val.SetRectValue();
bool useCommas = false;
for (Side side = nsStyle.SIDE_TOP; side <= nsStyle.SIDE_LEFT; side++) {
if (! ParseVariant(rect.GetSide(side), v => rect.SetSide(side, v),
VARIANT_AL, null)) {
return false;
}
if (side == 0) {
useCommas = ExpectSymbol(',', true);
} else if (useCommas && (int)side < 3) {
// Skip optional commas between elements, but only if the first
// separator was a comma.
if (!ExpectSymbol(',', true)) {
return false;
}
}
}
if (!ExpectSymbol(')', true)) {
return false;
}
if (!ExpectEndProperty()) {
return false;
}
} else {
UngetToken();
return false;
}
AppendValue(aPropID, val);
return true;
}
示例2: SetBorderImageInitialValues
internal void SetBorderImageInitialValues()
{
// border-image-source: none
var source = new nsCSSValue();
source.SetNoneValue();
AppendValue(nsCSSProperty.BorderImageSource, source);
// border-image-slice: 100%
var sliceBoxValue = new nsCSSValue();
nsCSSRect sliceBox = sliceBoxValue.SetRectValue();
sliceBox.SetAllSidesTo(new nsCSSValue(1.0f, nsCSSUnit.Percent));
var slice = new nsCSSValue();
nsCSSValueList sliceList = slice.SetListValue();
sliceList.mValue = sliceBoxValue;
AppendValue(nsCSSProperty.BorderImageSlice, slice);
// border-image-width: 1
var width = new nsCSSValue();
nsCSSRect widthBox = width.SetRectValue();
widthBox.SetAllSidesTo(new nsCSSValue(1.0f, nsCSSUnit.Number));
AppendValue(nsCSSProperty.BorderImageWidth, width);
// border-image-outset: 0
var outset = new nsCSSValue();
nsCSSRect outsetBox = outset.SetRectValue();
outsetBox.SetAllSidesTo(new nsCSSValue(0.0f, nsCSSUnit.Number));
AppendValue(nsCSSProperty.BorderImageOutset, outset);
// border-image-repeat: repeat
var repeat = new nsCSSValue();
var repeatPair = new nsCSSValuePair();
repeatPair.SetBothValuesTo(new nsCSSValue(nsStyle.BORDER_IMAGE_REPEAT_STRETCH,
nsCSSUnit.Enumerated));
repeat.SetPairValue(repeatPair);
AppendValue(nsCSSProperty.BorderImageRepeat, repeat);
}
示例3: ParseGroupedBoxProperty
// Similar to ParseBoxProperties, except there is only one property
// with the result as its value, not four. Requires values be nonnegative.
internal bool ParseGroupedBoxProperty(int32_t aVariantMask,
/** outparam */ ref nsCSSValue aValue)
{
nsCSSRect result = aValue.SetRectValue();
int32_t count = 0;
for (Side index = nsStyle.SIDE_TOP; index <= nsStyle.SIDE_LEFT; index++) {
if (!ParseNonNegativeVariant(result.GetSide(index), v => result.SetSide(index, v),
aVariantMask, null)) {
break;
}
count++;
}
if (count == 0) {
return false;
}
// Provide missing values by replicating some of the values found
switch (count) {
case 1: // Make right == top
result.mRight = result.mTop;
goto case 2;
case 2: // Make bottom == top
result.mBottom = result.mTop;
goto case 3;
case 3: // Make left == right
result.mLeft = result.mRight;
break;
}
return true;
}