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


C++ nsCSSValue::Reset方法代码示例

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


在下文中一共展示了nsCSSValue::Reset方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

static nsresult
GetOperatingSystemVersion(nsPresContext* aPresContext, const nsMediaFeature* aFeature,
                         nsCSSValue& aResult)
{
  aResult.Reset();
  if (ShouldResistFingerprinting(aPresContext)) {
    return NS_OK;
  }

#ifdef XP_WIN
  int32_t metricResult;
  if (NS_SUCCEEDED(
        LookAndFeel::GetInt(LookAndFeel::eIntID_OperatingSystemVersionIdentifier,
                            &metricResult))) {
    for (size_t i = 0; i < ArrayLength(osVersionStrings); ++i) {
      if (metricResult == osVersionStrings[i].id) {
        aResult.SetStringValue(nsDependentString(osVersionStrings[i].name),
                               eCSSUnit_Ident);
        break;
      }
    }
  }
#endif
  return NS_OK;
}
开发者ID:LongyunZhang,项目名称:gecko-dev,代码行数:25,代码来源:nsMediaFeatures.cpp

示例2:

static void
GetOperatingSystemVersion(nsIDocument* aDocument, const nsMediaFeature* aFeature,
                         nsCSSValue& aResult)
{
  aResult.Reset();

  MOZ_ASSERT(aFeature->mReqFlags & nsMediaFeature::eUserAgentAndChromeOnly);
  if (nsContentUtils::ShouldResistFingerprinting(aDocument)) {
    return;
  }

#ifdef XP_WIN
  int32_t metricResult;
  if (NS_SUCCEEDED(
        LookAndFeel::GetInt(LookAndFeel::eIntID_OperatingSystemVersionIdentifier,
                            &metricResult))) {
    for (size_t i = 0; i < ArrayLength(osVersionStrings); ++i) {
      if (metricResult == osVersionStrings[i].id) {
        aResult.SetStringValue(nsDependentString(osVersionStrings[i].name),
                               eCSSUnit_Ident);
        break;
      }
    }
  }
#endif
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:26,代码来源:nsMediaFeatures.cpp

示例3: GetWindowsThemeIdentifier

static void
GetWindowsTheme(nsIDocument* aDocument, const nsMediaFeature* aFeature,
                nsCSSValue& aResult)
{
  aResult.Reset();

  MOZ_ASSERT(aFeature->mReqFlags & nsMediaFeature::eUserAgentAndChromeOnly);
  if (nsContentUtils::ShouldResistFingerprinting(aDocument)) {
    return;
  }

#ifdef XP_WIN
  uint8_t windowsThemeId = GetWindowsThemeIdentifier();

  // Classic mode should fail to match.
  if (windowsThemeId == LookAndFeel::eWindowsTheme_Classic)
    return;

  // Look up the appropriate theme string
  for (size_t i = 0; i < ArrayLength(themeStrings); ++i) {
    if (windowsThemeId == themeStrings[i].id) {
      aResult.SetStringValue(nsDependentString(themeStrings[i].name),
                             eCSSUnit_Ident);
      break;
    }
  }
#endif
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:28,代码来源:nsMediaFeatures.cpp

示例4: HasSystemMetric

static void
GetSystemMetric(nsIDocument* aDocument, const nsMediaFeature* aFeature,
                nsCSSValue& aResult)
{
  aResult.Reset();

  const bool isAccessibleFromContentPages =
    !(aFeature->mReqFlags & nsMediaFeature::eUserAgentAndChromeOnly);

  MOZ_ASSERT(!isAccessibleFromContentPages ||
             *aFeature->mName == nsGkAtoms::_moz_touch_enabled);

  if (isAccessibleFromContentPages &&
      nsContentUtils::ShouldResistFingerprinting(aDocument)) {
    // If "privacy.resistFingerprinting" is enabled, then we simply don't
    // return any system-backed media feature values. (No spoofed values
    // returned.)
    return;
  }

  MOZ_ASSERT(aFeature->mValueType == nsMediaFeature::eBoolInteger,
             "unexpected type");

  nsAtom* metricAtom = *aFeature->mData.mMetric;
  bool hasMetric = HasSystemMetric(metricAtom);
  aResult.SetIntValue(hasMetric ? 1 : 0, eCSSUnit_Integer);
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:27,代码来源:nsMediaFeatures.cpp

示例5:

static void
GetScan(nsPresContext* aPresContext, const nsMediaFeature*,
        nsCSSValue& aResult)
{
  // Since Gecko doesn't support the 'tv' media type, the 'scan'
  // feature is never present.
  aResult.Reset();
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:8,代码来源:nsMediaFeatures.cpp

示例6: if

// parse an input string in the following format (see bug 148326 for testcases):
// [+|-] unsigned-number (% [pseudo-unit] | pseudo-unit | css-unit | namedspace)
bool
nsMathMLmpaddedFrame::ParseAttribute(nsString&   aString,
                                     int32_t&    aSign,
                                     nsCSSValue& aCSSValue,
                                     int32_t&    aPseudoUnit)
{
  aCSSValue.Reset();
  aSign = NS_MATHML_SIGN_INVALID;
  aPseudoUnit = NS_MATHML_PSEUDO_UNIT_UNSPECIFIED;
  aString.CompressWhitespace(); // aString is not a const in this code

  int32_t stringLength = aString.Length();
  if (!stringLength)
    return false;

  nsAutoString number, unit;

  //////////////////////
  // see if the sign is there

  int32_t i = 0;

  if (aString[0] == '+') {
    aSign = NS_MATHML_SIGN_PLUS;
    i++;
  }
  else if (aString[0] == '-') {
    aSign = NS_MATHML_SIGN_MINUS;
    i++;
  }
  else
    aSign = NS_MATHML_SIGN_UNSPECIFIED;

  // get the number
  bool gotDot = false, gotPercent = false;
  for (; i < stringLength; i++) {
    PRUnichar c = aString[i];
    if (gotDot && c == '.') {
      // error - two dots encountered
      aSign = NS_MATHML_SIGN_INVALID;
      return false;
    }

    if (c == '.')
      gotDot = true;
    else if (!nsCRT::IsAsciiDigit(c)) {
      break;
    }
    number.Append(c);
  }

  // catch error if we didn't enter the loop above... we could simply initialize
  // floatValue = 1, to cater for cases such as width="height", but that wouldn't
  // be in line with the spec which requires an explicit number
  if (number.IsEmpty()) {
    aSign = NS_MATHML_SIGN_INVALID;
    return false;
  }

  nsresult errorCode;
  float floatValue = number.ToFloat(&errorCode);
  if (NS_FAILED(errorCode)) {
    aSign = NS_MATHML_SIGN_INVALID;
    return false;
  }

  // see if this is a percentage-based value
  if (i < stringLength && aString[i] == '%') {
    i++;
    gotPercent = true;
  }

  // the remainder now should be a css-unit, or a pseudo-unit, or a named-space
  aString.Right(unit, stringLength - i);

  if (unit.IsEmpty()) {
    if (gotPercent) {
      // case ["+"|"-"] unsigned-number "%" 
      aCSSValue.SetPercentValue(floatValue / 100.0f);
      aPseudoUnit = NS_MATHML_PSEUDO_UNIT_ITSELF;
      return true;
    } else {
      // case ["+"|"-"] unsigned-number
      // XXXfredw: should we allow non-zero unitless values? See bug 757703.
      if (!floatValue) {
        aCSSValue.SetFloatValue(floatValue, eCSSUnit_Number);
        aPseudoUnit = NS_MATHML_PSEUDO_UNIT_ITSELF;
        return true;
      }
    }
  }
  else if (unit.EqualsLiteral("width"))  aPseudoUnit = NS_MATHML_PSEUDO_UNIT_WIDTH;
  else if (unit.EqualsLiteral("height")) aPseudoUnit = NS_MATHML_PSEUDO_UNIT_HEIGHT;
  else if (unit.EqualsLiteral("depth"))  aPseudoUnit = NS_MATHML_PSEUDO_UNIT_DEPTH;
  else if (!gotPercent) { // percentage can only apply to a pseudo-unit

    // see if the unit is a named-space
    if (nsMathMLElement::ParseNamedSpaceValue(unit, aCSSValue,
//.........这里部分代码省略.........
开发者ID:hideakihata,项目名称:mozilla-central.fgv,代码行数:101,代码来源:nsMathMLmpaddedFrame.cpp

示例7: if

// parse an input string in the following format (see bug 148326 for testcases):
// [+|-] unsigned-number (% [pseudo-unit] | pseudo-unit | css-unit | namedspace)
PRBool
nsMathMLmpaddedFrame::ParseAttribute(nsString&   aString,
                                     PRInt32&    aSign,
                                     nsCSSValue& aCSSValue,
                                     PRInt32&    aPseudoUnit)
{
  aCSSValue.Reset();
  aSign = NS_MATHML_SIGN_INVALID;
  aPseudoUnit = NS_MATHML_PSEUDO_UNIT_UNSPECIFIED;
  aString.CompressWhitespace(); // aString is not a const in this code

  PRInt32 stringLength = aString.Length();
  if (!stringLength)
    return PR_FALSE;

  nsAutoString number, unit;

  //////////////////////
  // see if the sign is there

  PRInt32 i = 0;

  if (aString[0] == '+') {
    aSign = NS_MATHML_SIGN_PLUS;
    i++;
  }
  else if (aString[0] == '-') {
    aSign = NS_MATHML_SIGN_MINUS;
    i++;
  }
  else
    aSign = NS_MATHML_SIGN_UNSPECIFIED;

  // skip any space after the sign
  if (i < stringLength && nsCRT::IsAsciiSpace(aString[i]))
    i++;

  // get the number
  PRBool gotDot = PR_FALSE, gotPercent = PR_FALSE;
  for (; i < stringLength; i++) {
    PRUnichar c = aString[i];
    if (gotDot && c == '.') {
      // error - two dots encountered
      aSign = NS_MATHML_SIGN_INVALID;
      return PR_FALSE;
    }

    if (c == '.')
      gotDot = PR_TRUE;
    else if (!nsCRT::IsAsciiDigit(c)) {
      break;
    }
    number.Append(c);
  }

  // catch error if we didn't enter the loop above... we could simply initialize
  // floatValue = 1, to cater for cases such as width="height", but that wouldn't
  // be in line with the spec which requires an explicit number
  if (number.IsEmpty()) {
#ifdef NS_DEBUG
    printf("mpadded: attribute with bad numeric value: %s\n",
            NS_LossyConvertUTF16toASCII(aString).get());
#endif
    aSign = NS_MATHML_SIGN_INVALID;
    return PR_FALSE;
  }

  PRInt32 errorCode;
  float floatValue = number.ToFloat(&errorCode);
  if (errorCode) {
    aSign = NS_MATHML_SIGN_INVALID;
    return PR_FALSE;
  }

  // skip any space after the number
  if (i < stringLength && nsCRT::IsAsciiSpace(aString[i]))
    i++;

  // see if this is a percentage-based value
  if (i < stringLength && aString[i] == '%') {
    i++;
    gotPercent = PR_TRUE;

    // skip any space after the '%' sign
    if (i < stringLength && nsCRT::IsAsciiSpace(aString[i]))
      i++;
  }

  // the remainder now should be a css-unit, or a pseudo-unit, or a named-space
  aString.Right(unit, stringLength - i);

  if (unit.IsEmpty()) {
    // also cater for the edge case of "0" for which the unit is optional
    if (gotPercent || !floatValue) {
      aCSSValue.SetPercentValue(floatValue / 100.0f);
      aPseudoUnit = NS_MATHML_PSEUDO_UNIT_ITSELF;
      return PR_TRUE;
    }
//.........这里部分代码省略.........
开发者ID:amyvmiwei,项目名称:firefox,代码行数:101,代码来源:nsMathMLmpaddedFrame.cpp

示例8: if

/* static */ PRBool
nsMathMLFrame::ParseNamedSpaceValue(nsIFrame*   aMathMLmstyleFrame,
                                    nsString&   aString,
                                    nsCSSValue& aCSSValue)
{
  aCSSValue.Reset();
  aString.CompressWhitespace(); //  aString is not a const in this code...
  if (!aString.Length()) return PR_FALSE;

  // See if it is one of the 'namedspace' (ranging 1/18em...7/18em)
  PRInt32 i = 0;
  nsIAtom* namedspaceAtom = nsnull;
  if (aString.EqualsLiteral("veryverythinmathspace")) {
    i = 1;
    namedspaceAtom = nsMathMLAtoms::veryverythinmathspace_;
  }
  else if (aString.EqualsLiteral("verythinmathspace")) {
    i = 2;
    namedspaceAtom = nsMathMLAtoms::verythinmathspace_;
  }
  else if (aString.EqualsLiteral("thinmathspace")) {
    i = 3;
    namedspaceAtom = nsMathMLAtoms::thinmathspace_;
  }
  else if (aString.EqualsLiteral("mediummathspace")) {
    i = 4;
    namedspaceAtom = nsMathMLAtoms::mediummathspace_;
  }
  else if (aString.EqualsLiteral("thickmathspace")) {
    i = 5;
    namedspaceAtom = nsMathMLAtoms::thickmathspace_;
  }
  else if (aString.EqualsLiteral("verythickmathspace")) {
    i = 6;
    namedspaceAtom = nsMathMLAtoms::verythickmathspace_;
  }
  else if (aString.EqualsLiteral("veryverythickmathspace")) {
    i = 7;
    namedspaceAtom = nsMathMLAtoms::veryverythickmathspace_;
  }

  if (0 != i) {
    if (aMathMLmstyleFrame) {
      // see if there is a <mstyle> that has overriden the default value
      // GetAttribute() will recurse all the way up into the <mstyle> hierarchy
      nsAutoString value;
      if (NS_CONTENT_ATTR_HAS_VALUE ==
          GetAttribute(nsnull, aMathMLmstyleFrame, namedspaceAtom, value)) {
        if (ParseNumericValue(value, aCSSValue) &&
            aCSSValue.IsLengthUnit()) {
          return PR_TRUE;
        }
      }
    }

    // fall back to the default value
    aCSSValue.SetFloatValue(float(i)/float(18), eCSSUnit_EM);
    return PR_TRUE;
  }

  return PR_FALSE;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:62,代码来源:nsMathMLFrame.cpp


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