void ImageTokenizer::finish() { if (!m_parserStopped && m_doc->imageElement()) { CachedImage* cachedImage = m_doc->cachedImage(); RefPtr<SharedBuffer> data = m_doc->frame()->loader()->documentLoader()->mainResourceData(); // If this is a multipart image, make a copy of the current part, since the resource data // will be overwritten by the next part. if (m_doc->frame()->loader()->documentLoader()->isLoadingMultipartContent()) data = data->copy(); cachedImage->data(data.release(), true); cachedImage->finish(); cachedImage->setResponse(m_doc->frame()->loader()->documentLoader()->response()); IntSize size = cachedImage->imageSize(m_doc->frame()->pageZoomFactor()); if (size.width()) m_doc->setTitle(imageTitle(cachedImage->response().suggestedFilename(), size)); m_doc->imageChanged(); } m_doc->finishedParsing(); }
void ImageTokenizer::finish() { if (!m_parserStopped && m_doc->imageElement()) { CachedImage* cachedImage = m_doc->cachedImage(); RefPtr<SharedBuffer> data = m_doc->frame()->loader()->documentLoader()->mainResourceData(); // If this is a multipart image, make a copy of the current part, since the resource data // will be overwritten by the next part. if (m_doc->frame()->loader()->documentLoader()->isLoadingMultipartContent()) data = data->copy(); cachedImage->data(data.release(), true); cachedImage->finish(); cachedImage->setResponse(m_doc->frame()->loader()->documentLoader()->response()); IntSize size = cachedImage->imageSize(pageZoomFactor(m_doc)); 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(m_doc->url().lastPathComponent()); if (fileName.isEmpty()) fileName = m_doc->url().host(); m_doc->setTitle(imageTitle(fileName, size)); } m_doc->imageChanged(); } m_doc->finishedParsing(); }
void ImageDocumentParser::finish() { if (!isStopped() && document()->imageElement()) { CachedImage* cachedImage = document()->cachedImage(); RefPtr<SharedBuffer> data = document()->frame()->loader()->documentLoader()->mainResourceData(); // If this is a multipart image, make a copy of the current part, since the resource data // will be overwritten by the next part. if (document()->frame()->loader()->documentLoader()->isLoadingMultipartContent()) data = data->copy(); cachedImage->data(data.release(), true); cachedImage->finish(); cachedImage->setResponse(document()->frame()->loader()->documentLoader()->response()); // Report the natural image size in the page title, regardless of zoom // level. IntSize size = cachedImage->imageSize(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(); } document()->finishedParsing(); }