当前位置: 首页>>代码示例>>C#>>正文


C# CssValue.SetInitialValue方法代码示例

本文整理汇总了C#中CssValue.SetInitialValue方法的典型用法代码示例。如果您正苦于以下问题:C# CssValue.SetInitialValue方法的具体用法?C# CssValue.SetInitialValue怎么用?C# CssValue.SetInitialValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CssValue的用法示例。


在下文中一共展示了CssValue.SetInitialValue方法的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;
        }
开发者ID:jorik041,项目名称:CsCss,代码行数:67,代码来源:nsCSSParser.conv.cs

示例2: 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) ||
//.........这里部分代码省略.........
开发者ID:jorik041,项目名称:CsCss,代码行数:101,代码来源:nsCSSParser.conv.cs

示例3: ParseFamily

        internal bool ParseFamily(ref nsCSSValue aValue)
        {
            var family = new StringBuilder();
              bool single = false;

              // keywords only have meaning in the first position
              if (!ParseOneFamily(family, ref single))
            return false;

              // check for keywords, but only when keywords appear by themselves
              // i.e. not in compounds such as font-family: default blah;
              if (single) {
            nsCSSKeyword keyword = nsCSSKeywords.LookupKeyword(family);
            if (keyword == nsCSSKeyword.inherit) {
              aValue.SetInheritValue();
              return true;
            }
            // 605231 - don't parse unquoted 'default' reserved keyword
            if (keyword == [email protected]) {
              return false;
            }
            if (keyword == nsCSSKeyword._moz_initial || keyword == nsCSSKeyword.initial) {
              aValue.SetInitialValue();
              return true;
            }
            if (keyword == nsCSSKeyword._moz_use_system_font &&
                !IsParsingCompoundProperty()) {
              aValue.SetSystemFontValue();
              return true;
            }
              }

              for (;;) {
            if (!ExpectSymbol(',', true))
              break;

            family.Append(',');

            var nextFamily = new StringBuilder();
            if (!ParseOneFamily(nextFamily, ref single))
              return false;

            // at this point unquoted keywords are not allowed
            // as font family names but can appear within names
            if (single) {
              nsCSSKeyword keyword = nsCSSKeywords.LookupKeyword(nextFamily);
              switch (keyword) {
                case nsCSSKeyword.inherit:
                case nsCSSKeyword.initial:
                case [email protected]:
                case nsCSSKeyword._moz_initial:
                case nsCSSKeyword._moz_use_system_font:
                  return false;
                default:
                  break;
              }
            }

            family.Append(nextFamily);
              }

              if (family.IsEmpty()) {
            return false;
              }
              aValue.SetStringValue(family, nsCSSUnit.Families);
              return true;
        }
开发者ID:jorik041,项目名称:CsCss,代码行数:67,代码来源:nsCSSParser.conv.cs


注:本文中的CssValue.SetInitialValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。