本文整理汇总了C#中CssValue.SetIntValue方法的典型用法代码示例。如果您正苦于以下问题:C# CssValue.SetIntValue方法的具体用法?C# CssValue.SetIntValue怎么用?C# CssValue.SetIntValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CssValue
的用法示例。
在下文中一共展示了CssValue.SetIntValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseVariant
// Assigns to aValue iff it returns true.
internal bool ParseVariant(ref nsCSSValue aValue,
int32_t aVariantMask,
int32_t[] aKeywordTable)
{
Debug.Assert(!(mHashlessColorQuirk && ((aVariantMask & VARIANT_COLOR) != 0)) ||
!((aVariantMask & VARIANT_NUMBER) != 0),
"can't distinguish colors from numbers");
Debug.Assert(!(mHashlessColorQuirk && ((aVariantMask & VARIANT_COLOR) != 0)) ||
!(mUnitlessLengthQuirk && ((aVariantMask & VARIANT_LENGTH) != 0)),
"can't distinguish colors from lengths");
Debug.Assert(!(mUnitlessLengthQuirk && ((aVariantMask & VARIANT_LENGTH) != 0)) ||
!((aVariantMask & VARIANT_NUMBER) != 0),
"can't distinguish lengths from numbers");
Debug.Assert(!((aVariantMask & VARIANT_IDENTIFIER) != 0) ||
!((aVariantMask & VARIANT_IDENTIFIER_NO_INHERIT) != 0),
"must not set both VARIANT_IDENTIFIER and VARIANT_IDENTIFIER_NO_INHERIT");
if (!GetToken(true)) {
return false;
}
nsCSSToken tk = mToken;
if (((aVariantMask & (VARIANT_AHK | VARIANT_NORMAL | VARIANT_NONE | VARIANT_ALL)) != 0) &&
(nsCSSTokenType.Ident == tk.mType)) {
nsCSSKeyword keyword = nsCSSKeywords.LookupKeyword(tk.mIdentStr);
if (nsCSSKeyword.UNKNOWN < keyword) { // known keyword
if ((aVariantMask & VARIANT_AUTO) != 0) {
if (nsCSSKeyword.auto == keyword) {
aValue.SetAutoValue();
return true;
}
}
if ((aVariantMask & VARIANT_INHERIT) != 0) {
// XXX Should we check IsParsingCompoundProperty, or do all
// callers handle it? (Not all callers set it, though, since
// they want the quirks that are disabled by setting it.)
if (nsCSSKeyword.inherit == keyword) {
aValue.SetInheritValue();
return true;
}
else if (nsCSSKeyword._moz_initial == keyword ||
nsCSSKeyword.initial == keyword) { // anything that can inherit can also take an initial val.
aValue.SetInitialValue();
return true;
}
}
if ((aVariantMask & VARIANT_NONE) != 0) {
if (nsCSSKeyword.none == keyword) {
aValue.SetNoneValue();
return true;
}
}
if ((aVariantMask & VARIANT_ALL) != 0) {
if (nsCSSKeyword.all == keyword) {
aValue.SetAllValue();
return true;
}
}
if ((aVariantMask & VARIANT_NORMAL) != 0) {
if (nsCSSKeyword.normal == keyword) {
aValue.SetNormalValue();
return true;
}
}
if ((aVariantMask & VARIANT_SYSFONT) != 0) {
if (nsCSSKeyword._moz_use_system_font == keyword &&
!IsParsingCompoundProperty()) {
aValue.SetSystemFontValue();
return true;
}
}
if ((aVariantMask & VARIANT_KEYWORD) != 0) {
int32_t value = 0;
if (nsCSSProps.FindKeyword(keyword, aKeywordTable, ref value)) {
aValue.SetIntValue(value, nsCSSUnit.Enumerated);
return true;
}
}
}
}
// Check VARIANT_NUMBER and VARIANT_INTEGER before VARIANT_LENGTH or
// VARIANT_ZERO_ANGLE.
if (((aVariantMask & VARIANT_NUMBER) != 0) &&
(nsCSSTokenType.Number == tk.mType)) {
aValue.SetFloatValue(tk.mNumber, nsCSSUnit.Number);
return true;
}
if (((aVariantMask & VARIANT_INTEGER) != 0) &&
(nsCSSTokenType.Number == tk.mType) && tk.mIntegerValid) {
aValue.SetIntValue(tk.mInteger, nsCSSUnit.Integer);
return true;
}
if (((aVariantMask & (VARIANT_LENGTH | VARIANT_ANGLE |
VARIANT_FREQUENCY | VARIANT_TIME)) != 0 &&
nsCSSTokenType.Dimension == tk.mType) ||
((aVariantMask & (VARIANT_LENGTH | VARIANT_ZERO_ANGLE)) != 0 &&
nsCSSTokenType.Number == tk.mType &&
tk.mNumber == 0.0f)) {
if (((aVariantMask & VARIANT_POSITIVE_DIMENSION) != 0 &&
tk.mNumber <= 0.0) ||
//.........这里部分代码省略.........
示例2: ParseTextDecoration
internal bool ParseTextDecoration()
{
const int eDecorationNone = nsStyle.TEXT_DECORATION_LINE_NONE;
const int eDecorationUnderline = nsStyle.TEXT_DECORATION_LINE_UNDERLINE;
const int eDecorationOverline = nsStyle.TEXT_DECORATION_LINE_OVERLINE;
const int eDecorationLineThrough = nsStyle.TEXT_DECORATION_LINE_LINE_THROUGH;
const int eDecorationBlink = nsStyle.TEXT_DECORATION_LINE_BLINK;
const int eDecorationPrefAnchors = nsStyle.TEXT_DECORATION_LINE_PREF_ANCHORS;
/*TODO: static*/ int32_t[] kTextDecorationKTable = {
(int32_t)nsCSSKeyword.none, eDecorationNone,
(int32_t)nsCSSKeyword.underline, eDecorationUnderline,
(int32_t)nsCSSKeyword.overline, eDecorationOverline,
(int32_t)nsCSSKeyword.line_through, eDecorationLineThrough,
(int32_t)nsCSSKeyword.blink, eDecorationBlink,
(int32_t)nsCSSKeyword._moz_anchor_decoration, eDecorationPrefAnchors,
(int32_t)nsCSSKeyword.UNKNOWN,-1
};
var value = new nsCSSValue();
if (!ParseVariant(ref value, VARIANT_HK, kTextDecorationKTable)) {
return false;
}
nsCSSValue blink = new nsCSSValue(), line = new nsCSSValue(), style = new nsCSSValue(), color = new nsCSSValue();
switch (value.GetUnit()) {
case nsCSSUnit.Enumerated: {
// We shouldn't accept decoration line style and color via
// text-decoration.
color.SetIntValue(nsStyle.COLOR_MOZ_USE_TEXT_COLOR,
nsCSSUnit.Enumerated);
style.SetIntValue(nsStyle.TEXT_DECORATION_STYLE_SOLID,
nsCSSUnit.Enumerated);
int32_t intValue = value.GetIntValue();
if (intValue == eDecorationNone) {
blink.SetIntValue(nsStyle.TEXT_BLINK_NONE, nsCSSUnit.Enumerated);
line.SetIntValue(nsStyle.TEXT_DECORATION_LINE_NONE,
nsCSSUnit.Enumerated);
break;
}
// look for more keywords
var keyword = new nsCSSValue();
int32_t index = 0;
for (index = 0; index < 3; index++) {
if (!ParseEnum(ref keyword, kTextDecorationKTable)) {
break;
}
int32_t newValue = keyword.GetIntValue();
if (newValue == eDecorationNone || ((newValue & intValue) != 0)) {
// 'none' keyword in conjuction with others is not allowed, and
// duplicate keyword is not allowed.
return false;
}
intValue |= newValue;
}
blink.SetIntValue((intValue & eDecorationBlink) != 0 ?
nsStyle.TEXT_BLINK_BLINK : nsStyle.TEXT_BLINK_NONE,
nsCSSUnit.Enumerated);
line.SetIntValue((intValue & ~eDecorationBlink), nsCSSUnit.Enumerated);
break;
}
goto default;
default:
blink = line = color = style = value;
break;
}
AppendValue(nsCSSProperty.TextBlink, blink);
AppendValue(nsCSSProperty.TextDecorationLine, line);
AppendValue(nsCSSProperty.TextDecorationColor, color);
AppendValue(nsCSSProperty.TextDecorationStyle, style);
return true;
}
示例3: ParseTextDecorationLine
internal bool ParseTextDecorationLine(ref nsCSSValue aValue)
{
if (ParseVariant(ref aValue, VARIANT_HK, nsCSSProps.kTextDecorationLineKTable)) {
if (nsCSSUnit.Enumerated == aValue.GetUnit()) {
int32_t intValue = aValue.GetIntValue();
if (intValue != nsStyle.TEXT_DECORATION_LINE_NONE) {
// look for more keywords
var keyword = new nsCSSValue();
int32_t index = 0;
for (index = 0; index < 2; index++) {
if (ParseEnum(ref keyword, nsCSSProps.kTextDecorationLineKTable)) {
int32_t newValue = keyword.GetIntValue();
if (newValue == nsStyle.TEXT_DECORATION_LINE_NONE ||
((newValue & intValue) != 0)) {
// 'none' keyword in conjuction with others is not allowed, and
// duplicate keyword is not allowed.
return false;
}
intValue |= newValue;
}
else {
break;
}
}
aValue.SetIntValue(intValue, nsCSSUnit.Enumerated);
}
}
return true;
}
return false;
}
示例4: ParseOverflow
internal bool ParseOverflow()
{
var overflow = new nsCSSValue();
if (!ParseVariant(ref overflow, VARIANT_HK,
nsCSSProps.kOverflowKTable) ||
!ExpectEndProperty())
return false;
var overflowX = new nsCSSValue(overflow);
var overflowY = new nsCSSValue(overflow);
if (nsCSSUnit.Enumerated == overflow.GetUnit())
switch(overflow.GetIntValue()) {
case nsStyle.OVERFLOW_SCROLLBARS_HORIZONTAL:
overflowX.SetIntValue(nsStyle.OVERFLOW_SCROLL, nsCSSUnit.Enumerated);
overflowY.SetIntValue(nsStyle.OVERFLOW_HIDDEN, nsCSSUnit.Enumerated);
break;
case nsStyle.OVERFLOW_SCROLLBARS_VERTICAL:
overflowX.SetIntValue(nsStyle.OVERFLOW_HIDDEN, nsCSSUnit.Enumerated);
overflowY.SetIntValue(nsStyle.OVERFLOW_SCROLL, nsCSSUnit.Enumerated);
break;
}
AppendValue(nsCSSProperty.OverflowX, overflowX);
AppendValue(nsCSSProperty.OverflowY, overflowY);
return true;
}
示例5: ParsePaintOrder
internal bool ParsePaintOrder()
{
/*TODO: static*/ int32_t[] kPaintOrderKTable = {
(int32_t)nsCSSKeyword.normal, nsStyle.PAINT_ORDER_NORMAL,
(int32_t)nsCSSKeyword.fill, nsStyle.PAINT_ORDER_FILL,
(int32_t)nsCSSKeyword.stroke, nsStyle.PAINT_ORDER_STROKE,
(int32_t)nsCSSKeyword.markers, nsStyle.PAINT_ORDER_MARKERS,
(int32_t)nsCSSKeyword.UNKNOWN,-1
};
var value = new nsCSSValue();
if (!ParseVariant(ref value, VARIANT_HK, kPaintOrderKTable)) {
return false;
}
uint32_t seen = 0;
uint32_t order = 0;
uint32_t position = 0;
// Ensure that even cast to a signed int32_t when stored in CSSValue,
// we have enough space for the entire paint-order value.
if (value.GetUnit() == nsCSSUnit.Enumerated) {
uint32_t component = ((uint32_t)(value.GetIntValue()));
if (component != nsStyle.PAINT_ORDER_NORMAL) {
bool parsedOK = true;
for (;;) {
if (((seen & (1 << component)) != 0)) {
// Already seen this component.
UngetToken();
parsedOK = false;
break;
}
seen |= (1 << component);
order |= (component << position);
position += nsStyle.PAINT_ORDER_BITWIDTH;
if (!ParseEnum(ref value, kPaintOrderKTable)) {
break;
}
component = value.GetIntValue();
if (component == nsStyle.PAINT_ORDER_NORMAL) {
// Can't have "normal" in the middle of the list of paint components.
UngetToken();
parsedOK = false;
break;
}
}
// Fill in the remaining paint-order components in the order of their
// constant values.
if (parsedOK) {
for (component = 1;
component <= nsStyle.PAINT_ORDER_LAST_VALUE;
component++) {
if (!(((seen & (1 << component)) != 0))) {
order |= (component << position);
position += nsStyle.PAINT_ORDER_BITWIDTH;
}
}
}
}
value.SetIntValue(((int32_t)(order)), nsCSSUnit.Enumerated);
}
if (!ExpectEndProperty()) {
return false;
}
AppendValue(nsCSSProperty.PaintOrder, value);
return true;
}
示例6: ParseMarks
internal bool ParseMarks(ref nsCSSValue aValue)
{
if (ParseVariant(ref aValue, VARIANT_HK, nsCSSProps.kPageMarksKTable)) {
if (nsCSSUnit.Enumerated == aValue.GetUnit()) {
if (nsStyle.PAGE_MARKS_NONE != aValue.GetIntValue() &&
false == CheckEndProperty()) {
var second = new nsCSSValue();
if (ParseEnum(ref second, nsCSSProps.kPageMarksKTable)) {
// 'none' keyword in conjuction with others is not allowed
if (nsStyle.PAGE_MARKS_NONE != second.GetIntValue()) {
aValue.SetIntValue(aValue.GetIntValue() | second.GetIntValue(),
nsCSSUnit.Enumerated);
return true;
}
}
return false;
}
}
return true;
}
return false;
}
示例7: ParseEnum
internal bool ParseEnum(ref nsCSSValue aValue,
int32_t[] aKeywordTable)
{
string ident = NextIdent();
if (null == ident) {
return false;
}
nsCSSKeyword keyword = nsCSSKeywords.LookupKeyword(ident);
if (nsCSSKeyword.UNKNOWN < keyword) {
int32_t value = 0;
if (nsCSSProps.FindKeyword(keyword, aKeywordTable, ref value)) {
aValue.SetIntValue(value, nsCSSUnit.Enumerated);
return true;
}
}
// Put the unknown identifier back and return
UngetToken();
return false;
}
示例8: ParseColor
// The types to pass to ParseColorComponent. These correspond to the
// various datatypes that can go within rgb().
internal bool ParseColor(ref nsCSSValue aValue)
{
if (!GetToken(true)) {
{ if (!mSuppressErrors) mReporter.ReportUnexpected("PEColorEOF"); };
return false;
}
nsCSSToken tk = mToken;
var rgba = new nscolor();
switch (tk.mType) {
case nsCSSTokenType.ID:
case nsCSSTokenType.Hash:
// #xxyyzz
if (nscolor.HexToRGB(tk.mIdentStr, ref rgba)) {
aValue.SetColorValue(rgba);
return true;
}
break;
case nsCSSTokenType.Ident:
if (nscolor.ColorNameToRGB(tk.mIdentStr, ref rgba)) {
aValue.SetStringValue(tk.mIdentStr, nsCSSUnit.Ident);
return true;
}
else {
nsCSSKeyword keyword = nsCSSKeywords.LookupKeyword(tk.mIdentStr);
if (nsCSSKeyword.UNKNOWN < keyword) { // known keyword
int32_t value = 0;
if (nsCSSProps.FindKeyword(keyword, nsCSSProps.kColorKTable, ref value)) {
aValue.SetIntValue(value, nsCSSUnit.EnumColor);
return true;
}
}
}
break;
case nsCSSTokenType.Function:
if (mToken.mIdentStr.LowerCaseEqualsLiteral("rgb")) {
// rgb ( component , component , component )
uint8_t r = 0, g = 0, b = 0;
int32_t type = COLOR_TYPE_UNKNOWN;
if (ParseColorComponent(ref r, ref type, ',') &&
ParseColorComponent(ref g, ref type, ',') &&
ParseColorComponent(ref b, ref type, ')')) {
aValue.SetColorValue(nscolor.RGB(r,g,b));
return true;
}
SkipUntil(')');
return false;
}
else if (mToken.mIdentStr.LowerCaseEqualsLiteral("-moz-rgba") ||
mToken.mIdentStr.LowerCaseEqualsLiteral("rgba")) {
// rgba ( component , component , component , opacity )
uint8_t r = 0, g = 0, b = 0, a = 0;
int32_t type = COLOR_TYPE_UNKNOWN;
if (ParseColorComponent(ref r, ref type, ',') &&
ParseColorComponent(ref g, ref type, ',') &&
ParseColorComponent(ref b, ref type, ',') &&
ParseColorOpacity(ref a)) {
aValue.SetColorValue(nscolor.RGBA(r, g, b, a));
return true;
}
SkipUntil(')');
return false;
}
else if (mToken.mIdentStr.LowerCaseEqualsLiteral("hsl")) {
// hsl ( hue , saturation , lightness )
// "hue" is a number, "saturation" and "lightness" are percentages.
if (ParseHSLColor(ref rgba, ')')) {
aValue.SetColorValue(rgba);
return true;
}
SkipUntil(')');
return false;
}
else if (mToken.mIdentStr.LowerCaseEqualsLiteral("-moz-hsla") ||
mToken.mIdentStr.LowerCaseEqualsLiteral("hsla")) {
// hsla ( hue , saturation , lightness , opacity )
// "hue" is a number, "saturation" and "lightness" are percentages,
// "opacity" is a number.
uint8_t a = 0;
if (ParseHSLColor(ref rgba, ',') &&
ParseColorOpacity(ref a)) {
aValue.SetColorValue(nscolor.RGBA(rgba.R, rgba.G,
rgba.B, a));
return true;
}
SkipUntil(')');
return false;
}
break;
default:
break;
}
// try 'xxyyzz' without '#' prefix for compatibility with IE and Nav4x (bug 23236 and 45804)
// TODO support hashless colors
// It's not a color
//.........这里部分代码省略.........
示例9: ParseTextDecoration
internal bool ParseTextDecoration()
{
const int eDecorationNone = nsStyle.TextDecorationLineNone;
const int eDecorationUnderline = nsStyle.TextDecorationLineUnderline;
const int eDecorationOverline = nsStyle.TextDecorationLineOverline;
const int eDecorationLineThrough = nsStyle.TextDecorationLineLineThrough;
const int eDecorationBlink = nsStyle.TextDecorationLineBlink;
const int eDecorationPrefAnchors = nsStyle.TextDecorationLinePrefAnchors;
/*TODO: static*/ int32_t[] kTextDecorationKTable = {
(int32_t)nsCSSKeyword.None, eDecorationNone,
(int32_t)nsCSSKeyword.Underline, eDecorationUnderline,
(int32_t)nsCSSKeyword.Overline, eDecorationOverline,
(int32_t)nsCSSKeyword.LineThrough, eDecorationLineThrough,
(int32_t)nsCSSKeyword.Blink, eDecorationBlink,
(int32_t)nsCSSKeyword.MozAnchorDecoration, eDecorationPrefAnchors,
(int32_t)nsCSSKeyword.Unknown,-1
};
var value = new nsCSSValue();
if (!ParseVariant(ref value, VARIANT_HK, kTextDecorationKTable)) {
return false;
}
nsCSSValue blink = new nsCSSValue(), line = new nsCSSValue(), style = new nsCSSValue(), color = new nsCSSValue();
switch (value.GetUnit()) {
case nsCSSUnit.Enumerated: {
// We shouldn't accept decoration line style and color via
// text-decoration.
color.SetIntValue(nsStyle.ColorMozUseTextColor,
nsCSSUnit.Enumerated);
style.SetIntValue(nsStyle.TextDecorationStyleSolid,
nsCSSUnit.Enumerated);
int32_t intValue = value.GetIntValue();
if (intValue == eDecorationNone) {
blink.SetIntValue(nsStyle.TextBlinkNone, nsCSSUnit.Enumerated);
line.SetIntValue(nsStyle.TextDecorationLineNone,
nsCSSUnit.Enumerated);
break;
}
// look for more keywords
var keyword = new nsCSSValue();
int32_t index = 0;
for (index = 0; index < 3; index++) {
if (!ParseEnum(ref keyword, kTextDecorationKTable)) {
break;
}
int32_t newValue = keyword.GetIntValue();
if (newValue == eDecorationNone || ((newValue & intValue) != 0)) {
// 'none' keyword in conjuction with others is not allowed, and
// duplicate keyword is not allowed.
return false;
}
intValue |= newValue;
}
blink.SetIntValue((intValue & eDecorationBlink) != 0 ?
nsStyle.TextBlinkBlink : nsStyle.TextBlinkNone,
nsCSSUnit.Enumerated);
line.SetIntValue((intValue & ~eDecorationBlink), nsCSSUnit.Enumerated);
break;
}
goto default;
default:
blink = line = color = style = value;
break;
}
AppendValue(nsCSSProperty.TextBlink, blink);
AppendValue(nsCSSProperty.TextDecorationLine, line);
AppendValue(nsCSSProperty.TextDecorationColor, color);
AppendValue(nsCSSProperty.TextDecorationStyle, style);
return true;
}
示例10: ParseOverflow
internal bool ParseOverflow()
{
var overflow = new nsCSSValue();
if (!ParseVariant(ref overflow, VARIANT_HK,
nsCSSProps.kOverflowKTable) ||
!ExpectEndProperty())
return false;
var overflowX = new nsCSSValue(overflow);
var overflowY = new nsCSSValue(overflow);
if (nsCSSUnit.Enumerated == overflow.GetUnit())
switch(overflow.GetIntValue()) {
case nsStyle.OverflowScrollbarsHorizontal:
overflowX.SetIntValue(nsStyle.OverflowScroll, nsCSSUnit.Enumerated);
overflowY.SetIntValue(nsStyle.OverflowHidden, nsCSSUnit.Enumerated);
break;
case nsStyle.OverflowScrollbarsVertical:
overflowX.SetIntValue(nsStyle.OverflowHidden, nsCSSUnit.Enumerated);
overflowY.SetIntValue(nsStyle.OverflowScroll, nsCSSUnit.Enumerated);
break;
}
AppendValue(nsCSSProperty.OverflowX, overflowX);
AppendValue(nsCSSProperty.OverflowY, overflowY);
return true;
}