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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 m_image.clear(); | 368 m_image.clear(); |
369 } | 369 } |
370 | 370 |
371 void ImageResource::updateImage(bool allDataReceived) | 371 void ImageResource::updateImage(bool allDataReceived) |
372 { | 372 { |
373 TRACE_EVENT0("blink", "ImageResource::updateImage"); | 373 TRACE_EVENT0("blink", "ImageResource::updateImage"); |
374 | 374 |
375 if (m_data) | 375 if (m_data) |
376 createImage(); | 376 createImage(); |
377 | 377 |
378 Image::SizeAvailability sizeAvailable = Image::SizeUnavailable; | 378 bool sizeAvailable = false; |
379 | 379 |
380 // Have the image update its data from its internal buffer. | 380 // Have the image update its data from its internal buffer. |
381 // It will not do anything now, but will delay decoding until | 381 // It will not do anything now, but will delay decoding until |
382 // queried for info (like size or specific image frames). | 382 // queried for info (like size or specific image frames). |
383 if (m_data) { | 383 if (m_data) { |
384 DCHECK(m_image); | 384 DCHECK(m_image); |
385 sizeAvailable = m_image->setData(m_data, allDataReceived); | 385 sizeAvailable = m_image->setData(m_data, allDataReceived); |
386 } | 386 } |
387 | 387 |
388 // Go ahead and tell our observers to try to draw if we have either | 388 // Go ahead and tell our observers to try to draw if we have either |
389 // received all the data or the size is known. Each chunk from the | 389 // received all the data or the size is known. Each chunk from the |
390 // network causes observers to repaint, which will force that chunk | 390 // network causes observers to repaint, which will force that chunk |
391 // to decode. | 391 // to decode. |
392 if (sizeAvailable == Image::SizeUnavailable && !allDataReceived) | 392 if (sizeAvailable || allDataReceived) { |
393 return; | 393 if (!m_image || m_image->isNull()) { |
394 if (errorOccurred()) | 394 if (!errorOccurred()) |
395 return; | 395 setStatus(DecodeError); |
396 if (!m_image || m_image->isNull()) { | 396 clear(); |
397 setStatus(DecodeError); | 397 if (memoryCache()->contains(this)) |
398 if (!allDataReceived && m_loader) | 398 memoryCache()->remove(this); |
399 m_loader->didFinishLoading(nullptr, monotonicallyIncreasingTime(), e
ncodedSize()); | 399 } |
400 clear(); | 400 |
401 memoryCache()->remove(this); | 401 // It would be nice to only redraw the decoded band of the image, but wi
th the current design |
| 402 // (decoding delayed until painting) that seems hard. |
| 403 notifyObservers(); |
402 } | 404 } |
403 | |
404 // It would be nice to only redraw the decoded band of the image, but with t
he current design | |
405 // (decoding delayed until painting) that seems hard. | |
406 notifyObservers(); | |
407 } | 405 } |
408 | 406 |
409 void ImageResource::updateImageAndClearBuffer() | 407 void ImageResource::updateImageAndClearBuffer() |
410 { | 408 { |
411 clearImage(); | 409 clearImage(); |
412 updateImage(true); | 410 updateImage(true); |
413 m_data.clear(); | 411 m_data.clear(); |
414 } | 412 } |
415 | 413 |
416 void ImageResource::finish(double loadFinishTime) | 414 void ImageResource::finish(double loadFinishTime) |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 if (response().wasFetchedViaServiceWorker()) | 585 if (response().wasFetchedViaServiceWorker()) |
588 return response().serviceWorkerResponseType() != WebServiceWorkerRespons
eTypeOpaque; | 586 return response().serviceWorkerResponseType() != WebServiceWorkerRespons
eTypeOpaque; |
589 if (!getImage()->currentFrameHasSingleSecurityOrigin()) | 587 if (!getImage()->currentFrameHasSingleSecurityOrigin()) |
590 return false; | 588 return false; |
591 if (passesAccessControlCheck(securityOrigin)) | 589 if (passesAccessControlCheck(securityOrigin)) |
592 return true; | 590 return true; |
593 return !securityOrigin->taintsCanvas(response().url()); | 591 return !securityOrigin->taintsCanvas(response().url()); |
594 } | 592 } |
595 | 593 |
596 } // namespace blink | 594 } // namespace blink |
OLD | NEW |