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


C++ ImageResource::imageForLayoutObject方法代码示例

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


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

示例1: containerSizeIsSetForLayoutObject

static bool containerSizeIsSetForLayoutObject(ImageResource& cachedImage, const LayoutObject* layoutObject)
{
    const Image* image = cachedImage.image();
    // If a container size has been specified for this layoutObject, then
    // imageForLayoutObject() will return the SVGImageForContainer while image()
    // will return the underlying SVGImage.
    return !image->isSVGImage() || image != cachedImage.imageForLayoutObject(layoutObject);
}
开发者ID:smishenk,项目名称:chromium-crosswalk,代码行数:8,代码来源:LayoutSVGImage.cpp

示例2: writeImageToDataObject

static void writeImageToDataObject(DataObject* dataObject, Element* element, const KURL& url)
{
    // Shove image data into a DataObject for use as a file
    ImageResource* cachedImage = getImageResource(element);
    if (!cachedImage || !cachedImage->imageForLayoutObject(element->layoutObject()) || !cachedImage->isLoaded())
        return;

    SharedBuffer* imageBuffer = cachedImage->imageForLayoutObject(element->layoutObject())->data();
    if (!imageBuffer || !imageBuffer->size())
        return;

    String imageExtension = cachedImage->image()->filenameExtension();
    ASSERT(!imageExtension.isEmpty());

    // Determine the filename for the file contents of the image.
    String filename = cachedImage->response().suggestedFilename();
    if (filename.isEmpty())
        filename = url.lastPathComponent();

    String fileExtension;
    if (filename.isEmpty()) {
        filename = element->getAttribute(HTMLNames::altAttr);
    } else {
        // Strip any existing extension. Assume that alt text is usually not a filename.
        int extensionIndex = filename.reverseFind('.');
        if (extensionIndex != -1) {
            fileExtension = filename.substring(extensionIndex + 1);
            filename.truncate(extensionIndex);
        }
    }

    if (!fileExtension.isEmpty() && fileExtension != imageExtension) {
        String imageMimeType = MIMETypeRegistry::getMIMETypeForExtension(imageExtension);
        ASSERT(imageMimeType.startsWith("image/"));
        // Use the file extension only if it has imageMimeType: it's untrustworthy otherwise.
        if (imageMimeType == MIMETypeRegistry::getMIMETypeForExtension(fileExtension))
            imageExtension = fileExtension;
    }

    imageExtension = "." + imageExtension;
    validateFilename(filename, imageExtension);

    dataObject->addSharedBuffer(filename + imageExtension, imageBuffer);
}
开发者ID:shaoboyan,项目名称:chromium-crosswalk,代码行数:44,代码来源:DataTransfer.cpp

示例3: nullImage

PassRefPtr<Image> CSSCrossfadeValue::image(LayoutObject* renderer, const IntSize& size)
{
    if (size.isEmpty())
        return nullptr;

    Document* document = &renderer->document();
    ImageResource* cachedFromImage = cachedImageForCSSValue(m_fromValue.get(), document);
    ImageResource* cachedToImage = cachedImageForCSSValue(m_toValue.get(), document);

    if (!cachedFromImage || !cachedToImage)
        return Image::nullImage();

    Image* fromImage = cachedFromImage->imageForLayoutObject(renderer);
    Image* toImage = cachedToImage->imageForLayoutObject(renderer);

    if (!fromImage || !toImage)
        return Image::nullImage();

    m_generatedImage = CrossfadeGeneratedImage::create(fromImage, toImage, m_percentageValue->getFloatValue(), fixedSize(renderer), size);

    return m_generatedImage.release();
}
开发者ID:kingysu,项目名称:blink-crosswalk,代码行数:22,代码来源:CSSCrossfadeValue.cpp

示例4: fixedSize

IntSize CSSCrossfadeValue::fixedSize(const LayoutObject* renderer)
{
    float percentage = m_percentageValue->getFloatValue();
    float inversePercentage = 1 - percentage;

    Document* document = &renderer->document();
    ImageResource* cachedFromImage = cachedImageForCSSValue(m_fromValue.get(), document);
    ImageResource* cachedToImage = cachedImageForCSSValue(m_toValue.get(), document);

    if (!cachedFromImage || !cachedToImage)
        return IntSize();

    IntSize fromImageSize = cachedFromImage->imageForLayoutObject(renderer)->size();
    IntSize toImageSize = cachedToImage->imageForLayoutObject(renderer)->size();

    // Rounding issues can cause transitions between images of equal size to return
    // a different fixed size; avoid performing the interpolation if the images are the same size.
    if (fromImageSize == toImageSize)
        return fromImageSize;

    return IntSize(fromImageSize.width() * inversePercentage + toImageSize.width() * percentage,
        fromImageSize.height() * inversePercentage + toImageSize.height() * percentage);
}
开发者ID:kingysu,项目名称:blink-crosswalk,代码行数:23,代码来源:CSSCrossfadeValue.cpp


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