| 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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 m_multipartParsingState = MultipartParsingState::ParsingFirstPart; | 689 m_multipartParsingState = MultipartParsingState::ParsingFirstPart; |
| 692 return; | 690 return; |
| 693 } | 691 } |
| 694 updateImageAndClearBuffer(); | 692 updateImageAndClearBuffer(); |
| 695 | 693 |
| 696 if (m_multipartParsingState == MultipartParsingState::ParsingFirstPart) { | 694 if (m_multipartParsingState == MultipartParsingState::ParsingFirstPart) { |
| 697 m_multipartParsingState = MultipartParsingState::FinishedParsingFirstPart; | 695 m_multipartParsingState = MultipartParsingState::FinishedParsingFirstPart; |
| 698 // Notify finished when the first part ends. | 696 // Notify finished when the first part ends. |
| 699 if (!errorOccurred()) | 697 if (!errorOccurred()) |
| 700 setStatus(Cached); | 698 setStatus(Cached); |
| 701 // We will also notify clients/observers of the finish in | 699 // We notify clients/observers of finish here, and they will not be |
| 702 // Resource::finish()/error() so we don't mark them finished here. | 700 // notified again in Resource::finish()/error(). |
| 703 notifyObserversInternal(MarkFinishedOption::DoNotMarkFinished); | 701 notifyObserversInternal(); |
| 704 notifyClientsInternal(MarkFinishedOption::DoNotMarkFinished); | 702 notifyClientsInternal(); |
| 705 if (loader()) | 703 if (loader()) |
| 706 loader()->didFinishLoadingFirstPartInMultipart(); | 704 loader()->didFinishLoadingFirstPartInMultipart(); |
| 707 } | 705 } |
| 708 } | 706 } |
| 709 | 707 |
| 710 void ImageResource::multipartDataReceived(const char* bytes, size_t size) { | 708 void ImageResource::multipartDataReceived(const char* bytes, size_t size) { |
| 711 DCHECK(m_multipartParser); | 709 DCHECK(m_multipartParser); |
| 712 Resource::appendData(bytes, size); | 710 Resource::appendData(bytes, size); |
| 713 } | 711 } |
| 714 | 712 |
| 715 bool ImageResource::isAccessAllowed(SecurityOrigin* securityOrigin) { | 713 bool ImageResource::isAccessAllowed(SecurityOrigin* securityOrigin) { |
| 716 if (response().wasFetchedViaServiceWorker()) { | 714 if (response().wasFetchedViaServiceWorker()) { |
| 717 return response().serviceWorkerResponseType() != | 715 return response().serviceWorkerResponseType() != |
| 718 WebServiceWorkerResponseTypeOpaque; | 716 WebServiceWorkerResponseTypeOpaque; |
| 719 } | 717 } |
| 720 if (!getImage()->currentFrameHasSingleSecurityOrigin()) | 718 if (!getImage()->currentFrameHasSingleSecurityOrigin()) |
| 721 return false; | 719 return false; |
| 722 if (passesAccessControlCheck(securityOrigin)) | 720 if (passesAccessControlCheck(securityOrigin)) |
| 723 return true; | 721 return true; |
| 724 return !securityOrigin->taintsCanvas(response().url()); | 722 return !securityOrigin->taintsCanvas(response().url()); |
| 725 } | 723 } |
| 726 | 724 |
| 727 } // namespace blink | 725 } // namespace blink |
| OLD | NEW |