Source/core/rendering/RenderImage.cpp
// Sets the image height and width to fit the alt text.  Returns true if the
// image size changed.
Sets the image height and width to fit the alt text.  Returns true if the
image size changed.
Sets the image height and width to fit the alt text . Returns true if the image size changed .
bool RenderImage::setImageSizeForAltText(ImageResource* newImage )
{
    IntSize imageSize;
    if (newImage && newImage->imageForRenderer(this))
        imageSize = imageSizeForError(newImage);
    else if (!m_altText.isEmpty() || newImage) {
        imageSize = IntSize(paddingWidth, paddingHeight);
    }
    if (!m_altText.isEmpty()) {
        FontCachePurgePreventer fontCachePurgePreventer;
        const Font& font = style()->font();
        IntSize paddedTextSize(paddingWidth + min(ceilf(font.width(RenderBlockFlow::constructTextRun(this, font, m_altText, style()))), maxAltTextWidth), paddingHeight + min(font.fontMetrics().height(), maxAltTextHeight));
        imageSize = imageSize.expandedTo(paddedTextSize);
    }
    if (imageSize == intrinsicSize())
        return false;
    setIntrinsicSize(imageSize);
    return true;
}
bool RenderImage :: setImageSizeForAltText ( ImageResource * newImage ) { IntSize imageSize ; if ( newImage && newImage -> imageForRenderer ( this ) ) imageSize = imageSizeForError ( newImage ) ; else if ( ! m_altText . isEmpty ( ) || newImage ) { imageSize = IntSize ( paddingWidth , paddingHeight ) ; } if ( ! m_altText . isEmpty ( ) ) { FontCachePurgePreventer fontCachePurgePreventer ; const Font & font = style ( ) -> font ( ) ; IntSize paddedTextSize ( paddingWidth + min ( ceilf ( font . width ( RenderBlockFlow :: constructTextRun ( this , font , m_altText , style ( ) ) ) ) , maxAltTextWidth ) , paddingHeight + min ( font . fontMetrics ( ) . height ( ) , maxAltTextHeight ) ) ; imageSize = imageSize . expandedTo ( paddedTextSize ) ; } if ( imageSize == intrinsicSize ( ) ) return false ; setIntrinsicSize ( imageSize ) ; return true ; }
Sets the image height and width to fit the alt text.
Sets the image height and width to fit the alt text .
/* = 0 */ // If we'll be displaying either text or an image, add a little padding. // we have an alt and the user meant it (its not a text we invented)