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 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(); }