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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 placeholder_option_ = PlaceholderOption::kDoNotReloadPlaceholder; | 454 placeholder_option_ = PlaceholderOption::kDoNotReloadPlaceholder; |
455 } else { | 455 } else { |
456 placeholder_option_ = PlaceholderOption::kReloadPlaceholderOnDecodeError; | 456 placeholder_option_ = PlaceholderOption::kReloadPlaceholderOnDecodeError; |
457 } | 457 } |
458 } | 458 } |
459 } | 459 } |
460 | 460 |
461 bool ImageResource::ShouldShowPlaceholder() const { | 461 bool ImageResource::ShouldShowPlaceholder() const { |
462 switch (placeholder_option_) { | 462 switch (placeholder_option_) { |
463 case PlaceholderOption::kShowAndReloadPlaceholderAlways: | 463 case PlaceholderOption::kShowAndReloadPlaceholderAlways: |
| 464 case PlaceholderOption::kShowAndDoNotReloadPlaceholder: |
464 return true; | 465 return true; |
465 case PlaceholderOption::kReloadPlaceholderOnDecodeError: | 466 case PlaceholderOption::kReloadPlaceholderOnDecodeError: |
466 case PlaceholderOption::kDoNotReloadPlaceholder: | 467 case PlaceholderOption::kDoNotReloadPlaceholder: |
467 return false; | 468 return false; |
468 } | 469 } |
469 NOTREACHED(); | 470 NOTREACHED(); |
470 return false; | 471 return false; |
471 } | 472 } |
472 | 473 |
473 bool ImageResource::ShouldReloadBrokenPlaceholder() const { | 474 bool ImageResource::ShouldReloadBrokenPlaceholder() const { |
474 switch (placeholder_option_) { | 475 switch (placeholder_option_) { |
475 case PlaceholderOption::kShowAndReloadPlaceholderAlways: | 476 case PlaceholderOption::kShowAndReloadPlaceholderAlways: |
476 return ErrorOccurred(); | 477 return ErrorOccurred(); |
477 case PlaceholderOption::kReloadPlaceholderOnDecodeError: | 478 case PlaceholderOption::kReloadPlaceholderOnDecodeError: |
478 return GetStatus() == ResourceStatus::kDecodeError; | 479 return GetStatus() == ResourceStatus::kDecodeError; |
| 480 case PlaceholderOption::kShowAndDoNotReloadPlaceholder: |
479 case PlaceholderOption::kDoNotReloadPlaceholder: | 481 case PlaceholderOption::kDoNotReloadPlaceholder: |
480 return false; | 482 return false; |
481 } | 483 } |
482 NOTREACHED(); | 484 NOTREACHED(); |
483 return false; | 485 return false; |
484 } | 486 } |
485 | 487 |
486 static bool IsLoFiImage(const ImageResource& resource) { | 488 static bool IsLoFiImage(const ImageResource& resource) { |
487 if (resource.IsLoaded()) { | 489 if (resource.IsLoaded()) { |
488 return resource.GetResponse() | 490 return resource.GetResponse() |
(...skipping 22 matching lines...) Expand all Loading... |
511 // progress doesn't cause clients and observers to be notified of completion | 513 // progress doesn't cause clients and observers to be notified of completion |
512 // prematurely. | 514 // prematurely. |
513 DCHECK(!is_scheduling_reload_); | 515 DCHECK(!is_scheduling_reload_); |
514 is_scheduling_reload_ = true; | 516 is_scheduling_reload_ = true; |
515 | 517 |
516 SetCachePolicyBypassingCache(); | 518 SetCachePolicyBypassingCache(); |
517 | 519 |
518 // The reloaded image should not use any previews transformations. | 520 // The reloaded image should not use any previews transformations. |
519 WebURLRequest::PreviewsState previews_state_for_reload = | 521 WebURLRequest::PreviewsState previews_state_for_reload = |
520 WebURLRequest::kPreviewsNoTransform; | 522 WebURLRequest::kPreviewsNoTransform; |
| 523 WebURLRequest::PreviewsState old_previews_state = |
| 524 GetResourceRequest().GetPreviewsState(); |
521 | 525 |
522 if (policy == kReloadIfNeeded && (GetResourceRequest().GetPreviewsState() & | 526 if (policy == kReloadIfNeeded && (GetResourceRequest().GetPreviewsState() & |
523 WebURLRequest::kClientLoFiOn)) { | 527 WebURLRequest::kClientLoFiOn)) { |
524 // If the image attempted to use Client LoFi, but encountered a decoding | 528 // If the image attempted to use Client LoFi, but encountered a decoding |
525 // error and is being automatically reloaded, then also set the appropriate | 529 // error and is being automatically reloaded, then also set the appropriate |
526 // PreviewsState bit for that. This allows the embedder to count the | 530 // PreviewsState bit for that. This allows the embedder to count the |
527 // bandwidth used for this reload against the data savings of the initial | 531 // bandwidth used for this reload against the data savings of the initial |
528 // response. | 532 // response. |
529 previews_state_for_reload |= WebURLRequest::kClientLoFiAutoReload; | 533 previews_state_for_reload |= WebURLRequest::kClientLoFiAutoReload; |
530 } | 534 } |
531 SetPreviewsState(previews_state_for_reload); | 535 SetPreviewsState(previews_state_for_reload); |
532 | 536 |
533 if (placeholder_option_ != PlaceholderOption::kDoNotReloadPlaceholder) | 537 if (placeholder_option_ != PlaceholderOption::kDoNotReloadPlaceholder) |
534 ClearRangeRequestHeader(); | 538 ClearRangeRequestHeader(); |
535 placeholder_option_ = PlaceholderOption::kDoNotReloadPlaceholder; | 539 |
| 540 if (old_previews_state & WebURLRequest::kClientLoFiOn && |
| 541 policy != kReloadAlways) { |
| 542 placeholder_option_ = PlaceholderOption::kShowAndDoNotReloadPlaceholder; |
| 543 } else { |
| 544 placeholder_option_ = PlaceholderOption::kDoNotReloadPlaceholder; |
| 545 } |
536 | 546 |
537 if (IsLoading()) { | 547 if (IsLoading()) { |
538 Loader()->Cancel(); | 548 Loader()->Cancel(); |
539 // Canceling the loader causes error() to be called, which in turn calls | 549 // Canceling the loader causes error() to be called, which in turn calls |
540 // clear() and notifyObservers(), so there's no need to call these again | 550 // clear() and notifyObservers(), so there's no need to call these again |
541 // here. | 551 // here. |
542 } else { | 552 } else { |
543 ClearData(); | 553 ClearData(); |
544 SetEncodedSize(0); | 554 SetEncodedSize(0); |
545 UpdateImage(nullptr, ImageResourceContent::kClearImageAndNotifyObservers, | 555 UpdateImage(nullptr, ImageResourceContent::kClearImageAndNotifyObservers, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 // reloading in Step 3 due to notifyObservers()'s | 644 // reloading in Step 3 due to notifyObservers()'s |
635 // schedulingReloadOrShouldReloadBrokenPlaceholder() check. | 645 // schedulingReloadOrShouldReloadBrokenPlaceholder() check. |
636 // 3. reloadIfLoFiOrPlaceholderImage() is called via ResourceFetcher | 646 // 3. reloadIfLoFiOrPlaceholderImage() is called via ResourceFetcher |
637 // (a) via didFinishLoading() called in decodeError(), or | 647 // (a) via didFinishLoading() called in decodeError(), or |
638 // (b) after returning ImageResource::updateImage(). | 648 // (b) after returning ImageResource::updateImage(). |
639 DecodeError(all_data_received); | 649 DecodeError(all_data_received); |
640 } | 650 } |
641 } | 651 } |
642 | 652 |
643 } // namespace blink | 653 } // namespace blink |
OLD | NEW |