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

Side by Side Diff: third_party/WebKit/Source/core/loader/resource/ImageResourceContent.cpp

Issue 2613853002: Phase III Step 2: Call imageNotifyFinished() and image load event after SVG loading completes (Closed)
Patch Set: Rebase Created 3 years, 7 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/loader/resource/ImageResourceContent.h" 5 #include "core/loader/resource/ImageResourceContent.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "core/loader/resource/ImageResource.h" 9 #include "core/loader/resource/ImageResource.h"
10 #include "core/loader/resource/ImageResourceInfo.h" 10 #include "core/loader/resource/ImageResourceInfo.h"
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 case ResourceStatus::kCached: 399 case ResourceStatus::kCached:
400 case ResourceStatus::kLoadError: 400 case ResourceStatus::kLoadError:
401 case ResourceStatus::kDecodeError: 401 case ResourceStatus::kDecodeError:
402 // Load start due to revalidation/reload. 402 // Load start due to revalidation/reload.
403 break; 403 break;
404 } 404 }
405 405
406 content_status_ = ResourceStatus::kPending; 406 content_status_ = ResourceStatus::kPending;
407 } 407 }
408 408
409 void ImageResourceContent::AsyncLoadCompleted(const blink::Image* image) {
410 if (image_ != image)
411 return;
412 CHECK_EQ(size_available_, Image::kSizeAvailableAndLoadingAsynchronously);
413 size_available_ = Image::kSizeAvailable;
414 UpdateToLoadedContentStatus(ResourceStatus::kCached);
415 NotifyObservers(kShouldNotifyFinish);
416 }
417
409 ImageResourceContent::UpdateImageResult ImageResourceContent::UpdateImage( 418 ImageResourceContent::UpdateImageResult ImageResourceContent::UpdateImage(
410 PassRefPtr<SharedBuffer> data, 419 PassRefPtr<SharedBuffer> data,
411 ResourceStatus status, 420 ResourceStatus status,
412 UpdateImageOption update_image_option, 421 UpdateImageOption update_image_option,
413 bool all_data_received) { 422 bool all_data_received) {
414 TRACE_EVENT0("blink", "ImageResourceContent::updateImage"); 423 TRACE_EVENT0("blink", "ImageResourceContent::updateImage");
415 424
416 #if DCHECK_IS_ON() 425 #if DCHECK_IS_ON()
417 DCHECK(!is_update_image_being_called_); 426 DCHECK(!is_update_image_being_called_);
418 AutoReset<bool> scope(&is_update_image_being_called_, true); 427 AutoReset<bool> scope(&is_update_image_being_called_, true);
(...skipping 20 matching lines...) Expand all
439 case kUpdateImage: 448 case kUpdateImage:
440 case kClearAndUpdateImage: 449 case kClearAndUpdateImage:
441 // Have the image update its data from its internal buffer. It will not do 450 // Have the image update its data from its internal buffer. It will not do
442 // anything now, but will delay decoding until queried for info (like size 451 // anything now, but will delay decoding until queried for info (like size
443 // or specific image frames). 452 // or specific image frames).
444 if (data) { 453 if (data) {
445 if (!image_) 454 if (!image_)
446 image_ = CreateImage(); 455 image_ = CreateImage();
447 DCHECK(image_); 456 DCHECK(image_);
448 size_available_ = image_->SetData(std::move(data), all_data_received); 457 size_available_ = image_->SetData(std::move(data), all_data_received);
458 DCHECK(all_data_received ||
459 size_available_ !=
460 Image::kSizeAvailableAndLoadingAsynchronously);
449 } 461 }
450 462
451 // Go ahead and tell our observers to try to draw if we have either 463 // Go ahead and tell our observers to try to draw if we have either
452 // received all the data or the size is known. Each chunk from the network 464 // received all the data or the size is known. Each chunk from the network
453 // causes observers to repaint, which will force that chunk to decode. 465 // causes observers to repaint, which will force that chunk to decode.
454 if (size_available_ == Image::kSizeUnavailable && !all_data_received) 466 if (size_available_ == Image::kSizeUnavailable && !all_data_received)
455 return UpdateImageResult::kNoDecodeError; 467 return UpdateImageResult::kNoDecodeError;
456 468
457 if (info_->ShouldShowPlaceholder() && all_data_received) { 469 if (info_->ShouldShowPlaceholder() && all_data_received) {
458 if (image_ && !image_->IsNull()) { 470 if (image_ && !image_->IsNull()) {
459 IntSize dimensions = image_->Size(); 471 IntSize dimensions = image_->Size();
460 ClearImage(); 472 ClearImage();
461 image_ = PlaceholderImage::Create(this, dimensions); 473 image_ = PlaceholderImage::Create(this, dimensions);
462 } 474 }
463 } 475 }
464 476
465 if (!image_ || image_->IsNull()) { 477 if (!image_ || image_->IsNull()) {
466 ClearImage(); 478 ClearImage();
467 return UpdateImageResult::kShouldDecodeError; 479 return UpdateImageResult::kShouldDecodeError;
468 } 480 }
469 break; 481 break;
470 } 482 }
471 483
484 DCHECK(all_data_received ||
485 size_available_ != Image::kSizeAvailableAndLoadingAsynchronously);
486
472 // Notifies the observers. 487 // Notifies the observers.
473 // It would be nice to only redraw the decoded band of the image, but with the 488 // It would be nice to only redraw the decoded band of the image, but with the
474 // current design (decoding delayed until painting) that seems hard. 489 // current design (decoding delayed until painting) that seems hard.
475 490 //
476 if (all_data_received) { 491 // In the case of kSizeAvailableAndLoadingAsynchronously, we are waiting for
492 // SVG image completion, and thus we notify observers of kDoNotNotifyFinish
493 // here, and will notify observers of finish later in AsyncLoadCompleted().
494 if (all_data_received &&
495 size_available_ != Image::kSizeAvailableAndLoadingAsynchronously) {
477 UpdateToLoadedContentStatus(status); 496 UpdateToLoadedContentStatus(status);
478 NotifyObservers(kShouldNotifyFinish); 497 NotifyObservers(kShouldNotifyFinish);
479 } else { 498 } else {
480 NotifyObservers(kDoNotNotifyFinish); 499 NotifyObservers(kDoNotNotifyFinish);
481 } 500 }
482 501
483 return UpdateImageResult::kNoDecodeError; 502 return UpdateImageResult::kNoDecodeError;
484 } 503 }
485 504
486 void ImageResourceContent::DecodedSizeChangedTo(const blink::Image* image, 505 void ImageResourceContent::DecodedSizeChangedTo(const blink::Image* image,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 621
603 const ResourceResponse& ImageResourceContent::GetResponse() const { 622 const ResourceResponse& ImageResourceContent::GetResponse() const {
604 return info_->GetResponse(); 623 return info_->GetResponse();
605 } 624 }
606 625
607 const ResourceError& ImageResourceContent::GetResourceError() const { 626 const ResourceError& ImageResourceContent::GetResourceError() const {
608 return info_->GetResourceError(); 627 return info_->GetResourceError();
609 } 628 }
610 629
611 } // namespace blink 630 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698