| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 ImageObserver::trace(visitor); | 145 ImageObserver::trace(visitor); |
| 146 MultipartImageResourceParser::Client::trace(visitor); | 146 MultipartImageResourceParser::Client::trace(visitor); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void ImageResource::checkNotify() { | 149 void ImageResource::checkNotify() { |
| 150 // Don't notify observers and clients of completion if this ImageResource is | 150 // Don't notify observers and clients of completion if this ImageResource is |
| 151 // about to be reloaded. | 151 // about to be reloaded. |
| 152 if (m_isSchedulingReload || shouldReloadBrokenPlaceholder()) | 152 if (m_isSchedulingReload || shouldReloadBrokenPlaceholder()) |
| 153 return; | 153 return; |
| 154 | 154 |
| 155 notifyObserversInternal(MarkFinishedOption::ShouldMarkFinished); | 155 notifyObserversInternal(); |
| 156 Resource::checkNotify(); | 156 Resource::checkNotify(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void ImageResource::notifyObserversInternal( | 159 void ImageResource::notifyObserversInternal() { |
| 160 MarkFinishedOption markFinishedOption) { | |
| 161 if (isLoading()) | 160 if (isLoading()) |
| 162 return; | 161 return; |
| 163 | 162 |
| 164 for (auto* observer : m_observers.asVector()) { | 163 for (auto* observer : m_observers.asVector()) { |
| 165 if (m_observers.contains(observer)) { | 164 if (m_observers.contains(observer)) { |
| 166 if (markFinishedOption == MarkFinishedOption::ShouldMarkFinished) | 165 markObserverFinished(observer); |
| 167 markObserverFinished(observer); | |
| 168 observer->imageNotifyFinished(this); | 166 observer->imageNotifyFinished(this); |
| 169 } | 167 } |
| 170 } | 168 } |
| 171 } | 169 } |
| 172 | 170 |
| 173 void ImageResource::markObserverFinished(ImageResourceObserver* observer) { | 171 void ImageResource::markObserverFinished(ImageResourceObserver* observer) { |
| 174 if (m_observers.contains(observer)) { | 172 if (m_observers.contains(observer)) { |
| 175 m_finishedObservers.add(observer); | 173 m_finishedObservers.add(observer); |
| 176 m_observers.remove(observer); | 174 m_observers.remove(observer); |
| 177 } | 175 } |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 m_multipartParsingState = MultipartParsingState::ParsingFirstPart; | 691 m_multipartParsingState = MultipartParsingState::ParsingFirstPart; |
| 694 return; | 692 return; |
| 695 } | 693 } |
| 696 updateImageAndClearBuffer(); | 694 updateImageAndClearBuffer(); |
| 697 | 695 |
| 698 if (m_multipartParsingState == MultipartParsingState::ParsingFirstPart) { | 696 if (m_multipartParsingState == MultipartParsingState::ParsingFirstPart) { |
| 699 m_multipartParsingState = MultipartParsingState::FinishedParsingFirstPart; | 697 m_multipartParsingState = MultipartParsingState::FinishedParsingFirstPart; |
| 700 // Notify finished when the first part ends. | 698 // Notify finished when the first part ends. |
| 701 if (!errorOccurred()) | 699 if (!errorOccurred()) |
| 702 setStatus(Cached); | 700 setStatus(Cached); |
| 703 // We will also notify clients/observers of the finish in | 701 // We notify clients/observers of finish here, and they will not be |
| 704 // Resource::finish()/error() so we don't mark them finished here. | 702 // notified again in Resource::finish()/error(). |
| 705 notifyObserversInternal(MarkFinishedOption::DoNotMarkFinished); | 703 checkNotify(); |
| 706 notifyClientsInternal(MarkFinishedOption::DoNotMarkFinished); | |
| 707 if (loader()) | 704 if (loader()) |
| 708 loader()->didFinishLoadingFirstPartInMultipart(); | 705 loader()->didFinishLoadingFirstPartInMultipart(); |
| 709 } | 706 } |
| 710 } | 707 } |
| 711 | 708 |
| 712 void ImageResource::multipartDataReceived(const char* bytes, size_t size) { | 709 void ImageResource::multipartDataReceived(const char* bytes, size_t size) { |
| 713 DCHECK(m_multipartParser); | 710 DCHECK(m_multipartParser); |
| 714 Resource::appendData(bytes, size); | 711 Resource::appendData(bytes, size); |
| 715 } | 712 } |
| 716 | 713 |
| 717 bool ImageResource::isAccessAllowed(SecurityOrigin* securityOrigin) { | 714 bool ImageResource::isAccessAllowed(SecurityOrigin* securityOrigin) { |
| 718 if (response().wasFetchedViaServiceWorker()) { | 715 if (response().wasFetchedViaServiceWorker()) { |
| 719 return response().serviceWorkerResponseType() != | 716 return response().serviceWorkerResponseType() != |
| 720 WebServiceWorkerResponseTypeOpaque; | 717 WebServiceWorkerResponseTypeOpaque; |
| 721 } | 718 } |
| 722 if (!getImage()->currentFrameHasSingleSecurityOrigin()) | 719 if (!getImage()->currentFrameHasSingleSecurityOrigin()) |
| 723 return false; | 720 return false; |
| 724 if (passesAccessControlCheck(securityOrigin)) | 721 if (passesAccessControlCheck(securityOrigin)) |
| 725 return true; | 722 return true; |
| 726 return !securityOrigin->taintsCanvas(response().url()); | 723 return !securityOrigin->taintsCanvas(response().url()); |
| 727 } | 724 } |
| 728 | 725 |
| 729 } // namespace blink | 726 } // namespace blink |
| OLD | NEW |