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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 // queried for info (like size or specific image frames). | 360 // queried for info (like size or specific image frames). |
361 if (m_image) | 361 if (m_image) |
362 sizeAvailable = m_image->setData(m_data, allDataReceived); | 362 sizeAvailable = m_image->setData(m_data, allDataReceived); |
363 | 363 |
364 // Go ahead and tell our observers to try to draw if we have either | 364 // Go ahead and tell our observers to try to draw if we have either |
365 // received all the data or the size is known. Each chunk from the | 365 // received all the data or the size is known. Each chunk from the |
366 // network causes observers to repaint, which will force that chunk | 366 // network causes observers to repaint, which will force that chunk |
367 // to decode. | 367 // to decode. |
368 if (sizeAvailable || allDataReceived) { | 368 if (sizeAvailable || allDataReceived) { |
369 if (!m_image || m_image->isNull()) { | 369 if (!m_image || m_image->isNull()) { |
370 error(errorOccurred() ? getStatus() : DecodeError); | 370 if (!errorOccurred()) |
| 371 setStatus(DecodeError); |
| 372 clear(); |
371 if (memoryCache()->contains(this)) | 373 if (memoryCache()->contains(this)) |
372 memoryCache()->remove(this); | 374 memoryCache()->remove(this); |
373 return; | 375 return; |
374 } | 376 } |
375 | 377 |
376 // It would be nice to only redraw the decoded band of the image, but wi
th the current design | 378 // It would be nice to only redraw the decoded band of the image, but wi
th the current design |
377 // (decoding delayed until painting) that seems hard. | 379 // (decoding delayed until painting) that seems hard. |
378 notifyObservers(); | 380 notifyObservers(); |
379 } | 381 } |
380 } | 382 } |
381 | 383 |
382 void ImageResource::finish() | 384 void ImageResource::updateImageAndClearBuffer() |
| 385 { |
| 386 clearImage(); |
| 387 updateImage(true); |
| 388 m_data.clear(); |
| 389 } |
| 390 |
| 391 void ImageResource::finish(double loadFinishTime) |
383 { | 392 { |
384 if (m_multipartParser) { | 393 if (m_multipartParser) { |
385 m_multipartParser->finish(); | 394 m_multipartParser->finish(); |
386 if (m_data) { | 395 if (m_data) |
387 clearImage(); | 396 updateImageAndClearBuffer(); |
388 updateImage(true); | |
389 m_data.clear(); | |
390 } | |
391 } else { | 397 } else { |
392 updateImage(true); | 398 updateImage(true); |
393 } | 399 } |
394 Resource::finish(); | 400 Resource::finish(loadFinishTime); |
395 } | 401 } |
396 | 402 |
397 void ImageResource::error(Resource::Status status) | 403 void ImageResource::error(const ResourceError& error) |
398 { | 404 { |
399 if (m_multipartParser) | 405 if (m_multipartParser) |
400 m_multipartParser->cancel(); | 406 m_multipartParser->cancel(); |
401 clear(); | 407 clear(); |
402 Resource::error(status); | 408 Resource::error(error); |
403 notifyObservers(); | 409 notifyObservers(); |
404 } | 410 } |
405 | 411 |
406 void ImageResource::responseReceived(const ResourceResponse& response, PassOwnPt
r<WebDataConsumerHandle> handle) | 412 void ImageResource::responseReceived(const ResourceResponse& response, PassOwnPt
r<WebDataConsumerHandle> handle) |
407 { | 413 { |
408 ASSERT(!handle); | 414 ASSERT(!handle); |
409 ASSERT(!m_multipartParser); | 415 ASSERT(!m_multipartParser); |
410 // If there's no boundary, just handle the request normally. | 416 // If there's no boundary, just handle the request normally. |
411 if (response.isMultipart() && !response.multipartBoundary().isEmpty()) | 417 if (response.isMultipart() && !response.multipartBoundary().isEmpty()) |
412 m_multipartParser = new MultipartImageResourceParser(response, response.
multipartBoundary(), this); | 418 m_multipartParser = new MultipartImageResourceParser(response, response.
multipartBoundary(), this); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 m_image->setAnimationPolicy(newPolicy); | 497 m_image->setAnimationPolicy(newPolicy); |
492 } | 498 } |
493 } | 499 } |
494 | 500 |
495 void ImageResource::reloadIfLoFi(ResourceFetcher* fetcher) | 501 void ImageResource::reloadIfLoFi(ResourceFetcher* fetcher) |
496 { | 502 { |
497 if (!m_response.httpHeaderField("chrome-proxy").contains("q=low")) | 503 if (!m_response.httpHeaderField("chrome-proxy").contains("q=low")) |
498 return; | 504 return; |
499 m_resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache); | 505 m_resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache); |
500 m_resourceRequest.setLoFiState(WebURLRequest::LoFiOff); | 506 m_resourceRequest.setLoFiState(WebURLRequest::LoFiOff); |
501 error(Resource::LoadError); | 507 if (isLoading()) |
| 508 m_loader->cancel(); |
| 509 else |
| 510 updateImageAndClearBuffer(); |
502 setStatus(NotStarted); | 511 setStatus(NotStarted); |
503 load(fetcher); | 512 load(fetcher); |
504 } | 513 } |
505 | 514 |
506 void ImageResource::changedInRect(const blink::Image* image, const IntRect& rect
) | 515 void ImageResource::changedInRect(const blink::Image* image, const IntRect& rect
) |
507 { | 516 { |
508 if (!image || image != m_image) | 517 if (!image || image != m_image) |
509 return; | 518 return; |
510 notifyObservers(&rect); | 519 notifyObservers(&rect); |
511 } | 520 } |
512 | 521 |
513 void ImageResource::onePartInMultipartReceived(const ResourceResponse& response) | 522 void ImageResource::onePartInMultipartReceived(const ResourceResponse& response) |
514 { | 523 { |
515 ASSERT(m_multipartParser); | 524 ASSERT(m_multipartParser); |
516 | 525 |
517 m_response = response; | 526 m_response = response; |
518 if (m_multipartParsingState == MultipartParsingState::WaitingForFirstPart) { | 527 if (m_multipartParsingState == MultipartParsingState::WaitingForFirstPart) { |
519 // We have nothing to do because we don't have any data. | 528 // We have nothing to do because we don't have any data. |
520 m_multipartParsingState = MultipartParsingState::ParsingFirstPart; | 529 m_multipartParsingState = MultipartParsingState::ParsingFirstPart; |
521 return; | 530 return; |
522 } | 531 } |
523 clear(); | 532 updateImageAndClearBuffer(); |
524 updateImage(true); | |
525 m_data.clear(); | |
526 | 533 |
527 if (m_multipartParsingState == MultipartParsingState::ParsingFirstPart) { | 534 if (m_multipartParsingState == MultipartParsingState::ParsingFirstPart) { |
528 m_multipartParsingState = MultipartParsingState::FinishedParsingFirstPar
t; | 535 m_multipartParsingState = MultipartParsingState::FinishedParsingFirstPar
t; |
529 // Notify finished when the first part ends. | 536 // Notify finished when the first part ends. |
530 if (!errorOccurred()) | 537 if (!errorOccurred()) |
531 setStatus(Cached); | 538 setStatus(Cached); |
532 checkNotify(); | 539 checkNotify(); |
533 if (m_loader) | 540 if (m_loader) |
534 m_loader->didFinishLoadingOnePart(0, WebURLLoaderClient::kUnknownEnc
odedDataLength); | 541 m_loader->didFinishLoadingOnePart(0, WebURLLoaderClient::kUnknownEnc
odedDataLength); |
535 } | 542 } |
(...skipping 10 matching lines...) Expand all Loading... |
546 if (response().wasFetchedViaServiceWorker()) | 553 if (response().wasFetchedViaServiceWorker()) |
547 return response().serviceWorkerResponseType() != WebServiceWorkerRespons
eTypeOpaque; | 554 return response().serviceWorkerResponseType() != WebServiceWorkerRespons
eTypeOpaque; |
548 if (!getImage()->currentFrameHasSingleSecurityOrigin()) | 555 if (!getImage()->currentFrameHasSingleSecurityOrigin()) |
549 return false; | 556 return false; |
550 if (passesAccessControlCheck(securityOrigin)) | 557 if (passesAccessControlCheck(securityOrigin)) |
551 return true; | 558 return true; |
552 return !securityOrigin->taintsCanvas(response().url()); | 559 return !securityOrigin->taintsCanvas(response().url()); |
553 } | 560 } |
554 | 561 |
555 } // namespace blink | 562 } // namespace blink |
OLD | NEW |