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


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

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


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

示例1: if

/**
 * Tries to call |nsCSSValue::StartImageLoad()| on an image source.
 * Image sources are specified by |url()| or |-moz-image-rect()| function.
 */
static void
TryToStartImageLoadOnValue(const nsCSSValue& aValue, nsIDocument* aDocument,
                           nsStyleContext* aContext, nsCSSProperty aProperty,
                           bool aForTokenStream)
{
  MOZ_ASSERT(aDocument);

  if (aValue.GetUnit() == eCSSUnit_URL) {
    aValue.StartImageLoad(aDocument);
    if (aForTokenStream && aContext) {
      CSSVariableImageTable::Add(aContext, aProperty,
                                 aValue.GetImageStructValue());
    }
  }
  else if (aValue.GetUnit() == eCSSUnit_Image) {
    // If we already have a request, see if this document needs to clone it.
    imgIRequest* request = aValue.GetImageValue(nullptr);

    if (request) {
      ImageValue* imageValue = aValue.GetImageStructValue();
      aDocument->StyleImageLoader()->MaybeRegisterCSSImage(imageValue);
      if (aForTokenStream && aContext) {
        CSSVariableImageTable::Add(aContext, aProperty, imageValue);
      }
    }
  }
  else if (aValue.EqualsFunction(eCSSKeyword__moz_image_rect)) {
    nsCSSValue::Array* arguments = aValue.GetArrayValue();
    MOZ_ASSERT(arguments->Count() == 6, "unexpected num of arguments");

    const nsCSSValue& image = arguments->Item(1);
    TryToStartImageLoadOnValue(image, aDocument, aContext, aProperty,
                               aForTokenStream);
  }
}
开发者ID:Jar-win,项目名称:Waterfox,代码行数:39,代码来源:nsCSSDataBlock.cpp

示例2: if

/**
 * Tries to call |nsCSSValue::StartImageLoad()| on an image source.
 * Image sources are specified by |url()| or |-moz-image-rect()| function.
 */
static void
TryToStartImageLoadOnValue(const nsCSSValue& aValue, nsIDocument* aDocument,
                           nsCSSValueTokenStream* aTokenStream)
{
  MOZ_ASSERT(aDocument);

  if (aValue.GetUnit() == eCSSUnit_URL) {
    aValue.StartImageLoad(aDocument);
    if (aTokenStream) {
      aTokenStream->mImageValues.PutEntry(aValue.GetImageStructValue());
    }
  }
  else if (aValue.GetUnit() == eCSSUnit_Image) {
    // If we already have a request, see if this document needs to clone it.
    imgIRequest* request = aValue.GetImageValue(nullptr);

    if (request) {
      mozilla::css::ImageValue* imageValue = aValue.GetImageStructValue();
      aDocument->StyleImageLoader()->MaybeRegisterCSSImage(imageValue);
      if (aTokenStream) {
        aTokenStream->mImageValues.PutEntry(imageValue);
      }
    }
  }
  else if (aValue.EqualsFunction(eCSSKeyword__moz_image_rect)) {
    nsCSSValue::Array* arguments = aValue.GetArrayValue();
    MOZ_ASSERT(arguments->Count() == 6, "unexpected num of arguments");

    const nsCSSValue& image = arguments->Item(1);
    TryToStartImageLoadOnValue(image, aDocument, aTokenStream);
  }
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:36,代码来源:nsCSSDataBlock.cpp

示例3: if

/**
 * Tries to call |nsCSSValue::StartImageLoad()| on an image source.
 * Image sources are specified by |url()| or |-moz-image-rect()| function.
 */
static void
TryToStartImageLoadOnValue(const nsCSSValue& aValue, nsIDocument* aDocument,
                           nsStyleContext* aContext, nsCSSPropertyID aProperty,
                           bool aForTokenStream)
{
  MOZ_ASSERT(aDocument);

  if (aValue.GetUnit() == eCSSUnit_URL) {
#ifdef MOZ_ENABLE_MASK_AS_SHORTHAND
    // The 'mask-image' property accepts local reference URIs.
    // For example,
    //   mask-image: url(#mask_id); // refer to a SVG mask element, whose id is
    //                              // "mask_id", in the current document.
    // For such 'mask-image' values (pointing to an in-document element),
    // there is no need to trigger image download.
    if (aProperty == eCSSProperty_mask_image) {
      // Filter out all fragment URLs.
      // Since nsCSSValue::GetURLStructValue runs much faster than
      // nsIURI::EqualsExceptRef bellow, we get performance gain by this
      // early return.
      URLValue* urlValue = aValue.GetURLStructValue();
      if (urlValue->GetLocalURLFlag()) {
        return;
      }

      // Even though urlValue is not a fragment URL, it might still refer to
      // an internal resource.
      // For example, aDocument base URL is "http://foo/index.html" and
      // intentionally references a mask-image at
      // url(http://foo/index.html#mask) which still refers to a resource in
      // aDocument.
      nsIURI* imageURI = aValue.GetURLValue();
      if (imageURI) {
        nsIURI* docURI = aDocument->GetDocumentURI();
        bool isEqualExceptRef = false;
        nsresult  rv = imageURI->EqualsExceptRef(docURI, &isEqualExceptRef);
        if (NS_SUCCEEDED(rv) && isEqualExceptRef) {
          return;
        }
      }
    }
#endif
    aValue.StartImageLoad(aDocument);
    if (aForTokenStream && aContext) {
      CSSVariableImageTable::Add(aContext, aProperty,
                                 aValue.GetImageStructValue());
    }
  }
  else if (aValue.GetUnit() == eCSSUnit_Image) {
    // If we already have a request, see if this document needs to clone it.
    imgIRequest* request = aValue.GetImageValue(nullptr);

    if (request) {
      ImageValue* imageValue = aValue.GetImageStructValue();
      aDocument->StyleImageLoader()->MaybeRegisterCSSImage(imageValue);
      if (aForTokenStream && aContext) {
        CSSVariableImageTable::Add(aContext, aProperty, imageValue);
      }
    }
  }
  else if (aValue.EqualsFunction(eCSSKeyword__moz_image_rect)) {
    nsCSSValue::Array* arguments = aValue.GetArrayValue();
    MOZ_ASSERT(arguments->Count() == 6, "unexpected num of arguments");

    const nsCSSValue& image = arguments->Item(1);
    TryToStartImageLoadOnValue(image, aDocument, aContext, aProperty,
                               aForTokenStream);
  }
}
开发者ID:cstipkovic,项目名称:gecko-dev,代码行数:73,代码来源:nsCSSDataBlock.cpp


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