Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: third_party/WebKit/Source/core/fetch/ImageResource.cpp

Issue 2004263003: Delay resetting image animation, if possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: expand the comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResource.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 void ImageResource::destroyDecodedDataIfPossible() 199 void ImageResource::destroyDecodedDataIfPossible()
200 { 200 {
201 if (!hasClientsOrObservers() && !isLoading() && (!m_image || (m_image->hasOn eRef() && m_image->isBitmapImage()))) { 201 if (!hasClientsOrObservers() && !isLoading() && (!m_image || (m_image->hasOn eRef() && m_image->isBitmapImage()))) {
202 m_image = nullptr; 202 m_image = nullptr;
203 setDecodedSize(0); 203 setDecodedSize(0);
204 } else if (m_image && !errorOccurred()) { 204 } else if (m_image && !errorOccurred()) {
205 m_image->destroyDecodedData(true); 205 m_image->destroyDecodedData(true);
206 } 206 }
207 } 207 }
208 208
209 void ImageResource::doResetAnimation()
210 {
211 if (m_image)
212 m_image->resetAnimation();
213 }
214
209 void ImageResource::allClientsAndObserversRemoved() 215 void ImageResource::allClientsAndObserversRemoved()
210 { 216 {
211 if (m_image && !errorOccurred()) 217 if (m_image && !errorOccurred()) {
212 m_image->resetAnimation(); 218 // If possible, delay the resetting until back at the event loop.
219 // Doing so after a conservative GC prevents resetAnimation() from
220 // upsetting ongoing animation updates (crbug.com/613709)
221 if (!ThreadHeap::willObjectBeLazilySwept(this))
haraken 2016/05/24 15:40:54 Hmm, I'm not really happy about using ThreadHeap::
sof 2016/05/24 15:47:20 As this method will be called by another object's
222 Platform::current()->currentThread()->getWebTaskRunner()->postTask(B LINK_FROM_HERE, bind(&ImageResource::doResetAnimation, CrossThreadWeakPersistent ThisPointer<ImageResource>(this)));
223 else
224 m_image->resetAnimation();
225 }
213 if (m_multipartParser) 226 if (m_multipartParser)
214 m_multipartParser->cancel(); 227 m_multipartParser->cancel();
215 Resource::allClientsAndObserversRemoved(); 228 Resource::allClientsAndObserversRemoved();
216 } 229 }
217 230
218 void ImageResource::appendData(const char* data, size_t length) 231 void ImageResource::appendData(const char* data, size_t length)
219 { 232 {
220 if (m_multipartParser) { 233 if (m_multipartParser) {
221 m_multipartParser->appendData(data, length); 234 m_multipartParser->appendData(data, length);
222 } else { 235 } else {
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 if (response().wasFetchedViaServiceWorker()) 566 if (response().wasFetchedViaServiceWorker())
554 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque; 567 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque;
555 if (!getImage()->currentFrameHasSingleSecurityOrigin()) 568 if (!getImage()->currentFrameHasSingleSecurityOrigin())
556 return false; 569 return false;
557 if (passesAccessControlCheck(securityOrigin)) 570 if (passesAccessControlCheck(securityOrigin))
558 return true; 571 return true;
559 return !securityOrigin->taintsCanvas(response().url()); 572 return !securityOrigin->taintsCanvas(response().url());
560 } 573 }
561 574
562 } // namespace blink 575 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698