示例#1
0
void ImageInputType::startResourceLoading()
{
    BaseButtonInputType::startResourceLoading();

    HTMLImageLoader* imageLoader = element().imageLoader();
    imageLoader->updateFromElement();

    RenderImage* renderer = toRenderImage(element().renderer());
    if (!renderer)
        return;

    RenderImageResource* imageResource = renderer->imageResource();
    imageResource->setImageResource(imageLoader->image());

    // If we have no image at all because we have no src attribute, set
    // image height and width for the alt text instead.
    if (!imageLoader->image() && !imageResource->cachedImage())
        renderer->setImageSizeForAltText();
}
示例#2
0
unsigned ImageInputType::width() const
{
    RefPtr<HTMLInputElement> element = this->element();

    if (!element->renderer()) {
        // Check the attribute first for an explicit pixel value.
        unsigned width;
        if (parseHTMLNonNegativeInteger(element->fastGetAttribute(widthAttr), width))
            return width;

        // If the image is available, use its width.
        if (element->hasImageLoader()) {
            HTMLImageLoader* imageLoader = element->imageLoader();
            if (imageLoader->image())
                return imageLoader->image()->imageSizeForRenderer(element->renderer(), 1).width();
        }
    }

    element->document().updateLayout();

    RenderBox* box = element->renderBox();
    return box ? adjustForAbsoluteZoom(box->contentWidth(), box) : 0;
}