void ImageDocumentParser::finish() { if (!isStopped() && document()->imageElement() && document()->cachedImage()) { ImageResource* cachedImage = document()->cachedImage(); DocumentLoader* loader = document()->loader(); cachedImage->setResponse(loader->response()); cachedImage->setLoadFinishTime(loader->timing().responseEnd()); cachedImage->finish(); // Report the natural image size in the page title, regardless of zoom level. // At a zoom level of 1 the image is guaranteed to have an integer size. IntSize size = flooredIntSize(cachedImage->imageSizeForLayoutObject(document()->imageElement()->layoutObject(), 1.0f)); if (size.width()) { // Compute the title, we use the decoded filename of the resource, falling // back on the (decoded) hostname if there is no path. String fileName = decodeURLEscapeSequences(document()->url().lastPathComponent()); if (fileName.isEmpty()) fileName = document()->url().host(); document()->setTitle(imageTitle(fileName, size)); } document()->imageUpdated(); } // TODO(esprehn): These null checks on Document don't make sense, document() // will ASSERT if it was null. Do these want to check isDetached() ? if (document()) document()->finishedParsing(); }
void ImageDocumentParser::finish() { if (!isStopped() && document()->imageElement() && document()->cachedImage()) { ImageResource* cachedImage = document()->cachedImage(); cachedImage->finish(); cachedImage->setResponse(document()->frame()->loader().documentLoader()->response()); // Report the natural image size in the page title, regardless of zoom level. // At a zoom level of 1 the image is guaranteed to have an integer size. IntSize size = flooredIntSize(cachedImage->imageSizeForLayoutObject(document()->imageElement()->layoutObject(), 1.0f)); if (size.width()) { // Compute the title, we use the decoded filename of the resource, falling // back on the (decoded) hostname if there is no path. String fileName = decodeURLEscapeSequences(document()->url().lastPathComponent()); if (fileName.isEmpty()) fileName = document()->url().host(); document()->setTitle(imageTitle(fileName, size)); } document()->imageUpdated(); } if (document()) document()->finishedParsing(); }
FloatSize HTMLImageElement::elementSize() const { ImageResource* image = cachedImage(); if (!image) return FloatSize(); return FloatSize(image->imageSizeForLayoutObject(layoutObject(), 1.0f)); }
FloatSize HTMLImageElement::defaultDestinationSize() const { ImageResource* image = cachedImage(); if (!image) return FloatSize(); LayoutSize size; size = image->imageSizeForLayoutObject(layoutObject(), 1.0f); if (layoutObject() && layoutObject()->isLayoutImage() && image->image() && !image->image()->hasRelativeWidth()) size.scale(toLayoutImage(layoutObject())->imageDevicePixelRatio()); return FloatSize(size); }