| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
| 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 7 | 7 |
| 8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
| 9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
| 10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "wtf/StdLibExtras.h" | 40 #include "wtf/StdLibExtras.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 PassRefPtrWillBeRawPtr<ImageResource> ImageResource::fetch(FetchRequest& request
, ResourceFetcher* fetcher) | 44 PassRefPtrWillBeRawPtr<ImageResource> ImageResource::fetch(FetchRequest& request
, ResourceFetcher* fetcher) |
| 45 { | 45 { |
| 46 if (request.resourceRequest().requestContext() == WebURLRequest::RequestCont
extUnspecified) | 46 if (request.resourceRequest().requestContext() == WebURLRequest::RequestCont
extUnspecified) |
| 47 request.mutableResourceRequest().setRequestContext(WebURLRequest::Reques
tContextImage); | 47 request.mutableResourceRequest().setRequestContext(WebURLRequest::Reques
tContextImage); |
| 48 if (fetcher->context().pageDismissalEventBeingDispatched()) { | 48 if (fetcher->context().pageDismissalEventBeingDispatched()) { |
| 49 KURL requestURL = request.resourceRequest().url(); | 49 KURL requestURL = request.resourceRequest().url(); |
| 50 if (requestURL.isValid() && fetcher->context().canRequest(Resource::Imag
e, request.resourceRequest(), requestURL, request.options(), request.forPreload(
), request.originRestriction())) | 50 if (requestURL.isValid() && fetcher->context().canRequest(Resource::Imag
e, request.resourceRequest(), requestURL, request.options(), request.forPreload(
), request.getOriginRestriction())) |
| 51 fetcher->context().sendImagePing(requestURL); | 51 fetcher->context().sendImagePing(requestURL); |
| 52 return nullptr; | 52 return nullptr; |
| 53 } | 53 } |
| 54 | 54 |
| 55 if (fetcher->clientDefersImage(request.resourceRequest().url())) | 55 if (fetcher->clientDefersImage(request.resourceRequest().url())) |
| 56 request.setDefer(FetchRequest::DeferredByClient); | 56 request.setDefer(FetchRequest::DeferredByClient); |
| 57 | 57 |
| 58 return toImageResource(fetcher->requestResource(request, ImageResourceFactor
y())); | 58 return toImageResource(fetcher->requestResource(request, ImageResourceFactor
y())); |
| 59 } | 59 } |
| 60 | 60 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 setLoading(false); | 111 setLoading(false); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void ImageResource::didAddClient(ResourceClient* c) | 114 void ImageResource::didAddClient(ResourceClient* c) |
| 115 { | 115 { |
| 116 if (m_data && !m_image && !errorOccurred()) { | 116 if (m_data && !m_image && !errorOccurred()) { |
| 117 createImage(); | 117 createImage(); |
| 118 m_image->setData(m_data, true); | 118 m_image->setData(m_data, true); |
| 119 } | 119 } |
| 120 | 120 |
| 121 ASSERT(c->resourceClientType() == ImageResourceClient::expectedType()); | 121 ASSERT(c->getResourceClientType() == ImageResourceClient::expectedType()); |
| 122 if (m_image && !m_image->isNull()) | 122 if (m_image && !m_image->isNull()) |
| 123 static_cast<ImageResourceClient*>(c)->imageChanged(this); | 123 static_cast<ImageResourceClient*>(c)->imageChanged(this); |
| 124 | 124 |
| 125 Resource::didAddClient(c); | 125 Resource::didAddClient(c); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void ImageResource::didRemoveClient(ResourceClient* c) | 128 void ImageResource::didRemoveClient(ResourceClient* c) |
| 129 { | 129 { |
| 130 ASSERT(c); | 130 ASSERT(c); |
| 131 ASSERT(c->resourceClientType() == ImageResourceClient::expectedType()); | 131 ASSERT(c->getResourceClientType() == ImageResourceClient::expectedType()); |
| 132 | 132 |
| 133 Resource::didRemoveClient(c); | 133 Resource::didRemoveClient(c); |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool ImageResource::isSafeToUnlock() const | 136 bool ImageResource::isSafeToUnlock() const |
| 137 { | 137 { |
| 138 // Note that |m_image| holds a reference to |m_data| in addition to the one
held by the Resource parent class. | 138 // Note that |m_image| holds a reference to |m_data| in addition to the one
held by the Resource parent class. |
| 139 return !m_image || (m_image->hasOneRef() && m_data->refCount() == 2); | 139 return !m_image || (m_image->hasOneRef() && m_data->refCount() == 2); |
| 140 } | 140 } |
| 141 | 141 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // queried for info (like size or specific image frames). | 314 // queried for info (like size or specific image frames). |
| 315 if (m_image) | 315 if (m_image) |
| 316 sizeAvailable = m_image->setData(m_data, allDataReceived); | 316 sizeAvailable = m_image->setData(m_data, allDataReceived); |
| 317 | 317 |
| 318 // Go ahead and tell our observers to try to draw if we have either | 318 // Go ahead and tell our observers to try to draw if we have either |
| 319 // received all the data or the size is known. Each chunk from the | 319 // received all the data or the size is known. Each chunk from the |
| 320 // network causes observers to repaint, which will force that chunk | 320 // network causes observers to repaint, which will force that chunk |
| 321 // to decode. | 321 // to decode. |
| 322 if (sizeAvailable || allDataReceived) { | 322 if (sizeAvailable || allDataReceived) { |
| 323 if (!m_image || m_image->isNull()) { | 323 if (!m_image || m_image->isNull()) { |
| 324 error(errorOccurred() ? status() : DecodeError); | 324 error(errorOccurred() ? getStatus() : DecodeError); |
| 325 if (memoryCache()->contains(this)) | 325 if (memoryCache()->contains(this)) |
| 326 memoryCache()->remove(this); | 326 memoryCache()->remove(this); |
| 327 return; | 327 return; |
| 328 } | 328 } |
| 329 | 329 |
| 330 // It would be nice to only redraw the decoded band of the image, but wi
th the current design | 330 // It would be nice to only redraw the decoded band of the image, but wi
th the current design |
| 331 // (decoding delayed until painting) that seems hard. | 331 // (decoding delayed until painting) that seems hard. |
| 332 notifyObservers(); | 332 notifyObservers(); |
| 333 } | 333 } |
| 334 } | 334 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 return true; | 464 return true; |
| 465 return !securityOrigin->taintsCanvas(response().url()); | 465 return !securityOrigin->taintsCanvas(response().url()); |
| 466 } | 466 } |
| 467 | 467 |
| 468 bool ImageResource::loadingMultipartContent() const | 468 bool ImageResource::loadingMultipartContent() const |
| 469 { | 469 { |
| 470 return m_loader && m_loader->loadingMultipartContent(); | 470 return m_loader && m_loader->loadingMultipartContent(); |
| 471 } | 471 } |
| 472 | 472 |
| 473 } // namespace blink | 473 } // namespace blink |
| OLD | NEW |