| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 } | 128 } |
| 129 | 129 |
| 130 void ImageDocumentParser::appendBytes(DocumentWriter*, const char*, size_t) | 130 void ImageDocumentParser::appendBytes(DocumentWriter*, const char*, size_t) |
| 131 { | 131 { |
| 132 Frame* frame = document()->frame(); | 132 Frame* frame = document()->frame(); |
| 133 Settings* settings = frame->settings(); | 133 Settings* settings = frame->settings(); |
| 134 if (!frame->loader()->client()->allowImage(!settings || settings->areImagesE
nabled(), document()->url())) | 134 if (!frame->loader()->client()->allowImage(!settings || settings->areImagesE
nabled(), document()->url())) |
| 135 return; | 135 return; |
| 136 | 136 |
| 137 CachedImage* cachedImage = document()->cachedImage(); | 137 CachedImage* cachedImage = document()->cachedImage(); |
| 138 cachedImage->data(frame->loader()->documentLoader()->mainResourceData(), fal
se); | 138 cachedImage->data(frame->loader()->documentLoader()->mainResourceData()); |
| 139 | 139 |
| 140 document()->imageUpdated(); | 140 document()->imageUpdated(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void ImageDocumentParser::finish() | 143 void ImageDocumentParser::finish() |
| 144 { | 144 { |
| 145 if (!isStopped() && document()->imageElement()) { | 145 if (!isStopped() && document()->imageElement()) { |
| 146 CachedImage* cachedImage = document()->cachedImage(); | 146 CachedImage* cachedImage = document()->cachedImage(); |
| 147 RefPtr<ResourceBuffer> data = document()->frame()->loader()->documentLoa
der()->mainResourceData(); | |
| 148 | 147 |
| 149 // If this is a multipart image, make a copy of the current part, since
the resource data | 148 // If this is a multipart image, make a copy of the current part, since
the resource data |
| 150 // will be overwritten by the next part. | 149 // will be overwritten by the next part. |
| 151 if (document()->frame()->loader()->documentLoader()->isLoadingMultipartC
ontent()) | 150 if (document()->frame()->loader()->documentLoader()->isLoadingMultipartC
ontent()) { |
| 152 data = data->copy(); | 151 RefPtr<ResourceBuffer> data = document()->frame()->loader()->documen
tLoader()->mainResourceData()->copy(); |
| 152 cachedImage->data(data); |
| 153 } |
| 153 | 154 |
| 154 cachedImage->data(data.release(), true); | |
| 155 cachedImage->finish(); | 155 cachedImage->finish(); |
| 156 | 156 |
| 157 cachedImage->setResponse(document()->frame()->loader()->documentLoader()
->response()); | 157 cachedImage->setResponse(document()->frame()->loader()->documentLoader()
->response()); |
| 158 | 158 |
| 159 // Report the natural image size in the page title, regardless of zoom l
evel. | 159 // Report the natural image size in the page title, regardless of zoom l
evel. |
| 160 // At a zoom level of 1 the image is guaranteed to have an integer size. | 160 // At a zoom level of 1 the image is guaranteed to have an integer size. |
| 161 IntSize size = flooredIntSize(cachedImage->imageSizeForRenderer(document
()->imageElement()->renderer(), 1.0f)); | 161 IntSize size = flooredIntSize(cachedImage->imageSizeForRenderer(document
()->imageElement()->renderer(), 1.0f)); |
| 162 if (size.width()) { | 162 if (size.width()) { |
| 163 // Compute the title, we use the decoded filename of the resource, f
alling | 163 // Compute the title, we use the decoded filename of the resource, f
alling |
| 164 // back on the (decoded) hostname if there is no path. | 164 // back on the (decoded) hostname if there is no path. |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 void ImageDocumentElement::didMoveToNewDocument(Document* oldDocument) | 407 void ImageDocumentElement::didMoveToNewDocument(Document* oldDocument) |
| 408 { | 408 { |
| 409 if (m_imageDocument) { | 409 if (m_imageDocument) { |
| 410 m_imageDocument->disconnectImageElement(); | 410 m_imageDocument->disconnectImageElement(); |
| 411 m_imageDocument = 0; | 411 m_imageDocument = 0; |
| 412 } | 412 } |
| 413 HTMLImageElement::didMoveToNewDocument(oldDocument); | 413 HTMLImageElement::didMoveToNewDocument(oldDocument); |
| 414 } | 414 } |
| 415 | 415 |
| 416 } | 416 } |
| OLD | NEW |