| 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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 IntSize dimensions = m_image->size(); | 415 IntSize dimensions = m_image->size(); |
| 416 clearImage(); | 416 clearImage(); |
| 417 m_image = PlaceholderImage::create(this, dimensions); | 417 m_image = PlaceholderImage::create(this, dimensions); |
| 418 } else { | 418 } else { |
| 419 // Clear the image so that it gets treated like a decoding error, since | 419 // Clear the image so that it gets treated like a decoding error, since |
| 420 // the attempt to build a placeholder image failed. | 420 // the attempt to build a placeholder image failed. |
| 421 clearImage(); | 421 clearImage(); |
| 422 } | 422 } |
| 423 } | 423 } |
| 424 | 424 |
| 425 if (!m_image || m_image->isNull()) { | 425 if (!m_image || m_image->isNull()) |
| 426 size_t size = encodedSize(); | 426 decodeError(); |
| 427 clear(); | |
| 428 if (!errorOccurred()) | |
| 429 setStatus(DecodeError); | |
| 430 if (!allDataReceived && loader()) | |
| 431 loader()->didFinishLoading(nullptr, monotonicallyIncreasingTime(), size); | |
| 432 memoryCache()->remove(this); | |
| 433 } | |
| 434 | 427 |
| 435 // It would be nice to only redraw the decoded band of the image, but with the | 428 // It would be nice to only redraw the decoded band of the image, but with the |
| 436 // current design (decoding delayed until painting) that seems hard. | 429 // current design (decoding delayed until painting) that seems hard. |
| 437 notifyObservers(allDataReceived); | 430 notifyObservers(allDataReceived); |
| 438 } | 431 } |
| 439 | 432 |
| 433 void ImageResource::decodeError() { |
| 434 if (isLoading() && loader()) { |
| 435 loader()->cancel(DecodeError); |
| 436 } else if (!errorOccurred()) { |
| 437 setStatus(DecodeError); |
| 438 clear(); |
| 439 setEncodedSize(0); |
| 440 memoryCache()->remove(this); |
| 441 } |
| 442 } |
| 443 |
| 440 void ImageResource::updateImageAndClearBuffer() { | 444 void ImageResource::updateImageAndClearBuffer() { |
| 441 clearImage(); | 445 clearImage(); |
| 442 updateImage(true); | 446 updateImage(true); |
| 443 clearData(); | 447 clearData(); |
| 444 } | 448 } |
| 445 | 449 |
| 446 void ImageResource::finish(double loadFinishTime) { | 450 void ImageResource::finish(double loadFinishTime) { |
| 447 if (m_multipartParser) { | 451 if (m_multipartParser) { |
| 448 m_multipartParser->finish(); | 452 m_multipartParser->finish(); |
| 449 if (data()) | 453 if (data()) |
| 450 updateImageAndClearBuffer(); | 454 updateImageAndClearBuffer(); |
| 451 } else { | 455 } else { |
| 452 updateImage(true); | 456 updateImage(true); |
| 453 // As encoded image data can be created from m_image (see | 457 // As encoded image data can be created from m_image (see |
| 454 // ImageResource::resourceBuffer(), we don't have to keep m_data. Let's | 458 // ImageResource::resourceBuffer(), we don't have to keep m_data. Let's |
| 455 // clear this. As for the lifetimes of m_image and m_data, see this | 459 // clear this. As for the lifetimes of m_image and m_data, see this |
| 456 // document: | 460 // document: |
| 457 // https://docs.google.com/document/d/1v0yTAZ6wkqX2U_M6BNIGUJpM1s0TIw1Vsqpxo
L7aciY/edit?usp=sharing | 461 // https://docs.google.com/document/d/1v0yTAZ6wkqX2U_M6BNIGUJpM1s0TIw1Vsqpxo
L7aciY/edit?usp=sharing |
| 458 clearData(); | 462 clearData(); |
| 459 setEncodedSizeMemoryUsage(0); | 463 setEncodedSizeMemoryUsage(0); |
| 460 } | 464 } |
| 461 Resource::finish(loadFinishTime); | 465 Resource::finish(loadFinishTime); |
| 462 } | 466 } |
| 463 | 467 |
| 464 void ImageResource::error(const ResourceError& error) { | 468 void ImageResource::error(const ResourceError& error, Status errorStatus) { |
| 465 if (m_multipartParser) | 469 if (m_multipartParser) |
| 466 m_multipartParser->cancel(); | 470 m_multipartParser->cancel(); |
| 467 clear(); | 471 clear(); |
| 468 Resource::error(error); | 472 Resource::error(error, errorStatus); |
| 469 notifyObservers(true); | 473 notifyObservers(true); |
| 470 } | 474 } |
| 471 | 475 |
| 472 void ImageResource::responseReceived( | 476 void ImageResource::responseReceived( |
| 473 const ResourceResponse& response, | 477 const ResourceResponse& response, |
| 474 std::unique_ptr<WebDataConsumerHandle> handle) { | 478 std::unique_ptr<WebDataConsumerHandle> handle) { |
| 475 DCHECK(!handle); | 479 DCHECK(!handle); |
| 476 DCHECK(!m_multipartParser); | 480 DCHECK(!m_multipartParser); |
| 477 // If there's no boundary, just handle the request normally. | 481 // If there's no boundary, just handle the request normally. |
| 478 if (response.isMultipart() && !response.multipartBoundary().isEmpty()) { | 482 if (response.isMultipart() && !response.multipartBoundary().isEmpty()) { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 WebServiceWorkerResponseTypeOpaque; | 642 WebServiceWorkerResponseTypeOpaque; |
| 639 } | 643 } |
| 640 if (!getImage()->currentFrameHasSingleSecurityOrigin()) | 644 if (!getImage()->currentFrameHasSingleSecurityOrigin()) |
| 641 return false; | 645 return false; |
| 642 if (passesAccessControlCheck(securityOrigin)) | 646 if (passesAccessControlCheck(securityOrigin)) |
| 643 return true; | 647 return true; |
| 644 return !securityOrigin->taintsCanvas(response().url()); | 648 return !securityOrigin->taintsCanvas(response().url()); |
| 645 } | 649 } |
| 646 | 650 |
| 647 } // namespace blink | 651 } // namespace blink |
| OLD | NEW |