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

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: Reflect comments 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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 case ResourceStatus::kCached: 391 case ResourceStatus::kCached:
392 case ResourceStatus::kLoadError: 392 case ResourceStatus::kLoadError:
393 case ResourceStatus::kDecodeError: 393 case ResourceStatus::kDecodeError:
394 // Load start due to revalidation/reload. 394 // Load start due to revalidation/reload.
395 break; 395 break;
396 } 396 }
397 397
398 content_status_ = ResourceStatus::kPending; 398 content_status_ = ResourceStatus::kPending;
399 } 399 }
400 400
401 void ImageResourceContent::AsyncLoadCompleted(const blink::Image* image) {
402 if (image_ != image)
403 return;
404 CHECK_EQ(size_available_, Image::kSizeAvailableAndLoadingAsynchronously);
405 size_available_ = Image::kSizeAvailable;
406 UpdateToLoadedContentStatus(ResourceStatus::kCached);
407 NotifyObservers(kShouldNotifyFinish);
408 }
409
401 ImageResourceContent::UpdateImageResult ImageResourceContent::UpdateImage( 410 ImageResourceContent::UpdateImageResult ImageResourceContent::UpdateImage(
402 PassRefPtr<SharedBuffer> data, 411 PassRefPtr<SharedBuffer> data,
403 ResourceStatus status, 412 ResourceStatus status,
404 UpdateImageOption update_image_option, 413 UpdateImageOption update_image_option,
405 bool all_data_received) { 414 bool all_data_received) {
406 TRACE_EVENT0("blink", "ImageResourceContent::updateImage"); 415 TRACE_EVENT0("blink", "ImageResourceContent::updateImage");
407 416
408 #if DCHECK_IS_ON() 417 #if DCHECK_IS_ON()
409 DCHECK(!is_update_image_being_called_); 418 DCHECK(!is_update_image_being_called_);
410 AutoReset<bool> scope(&is_update_image_being_called_, true); 419 AutoReset<bool> scope(&is_update_image_being_called_, true);
(...skipping 20 matching lines...) Expand all
431 case kUpdateImage: 440 case kUpdateImage:
432 case kClearAndUpdateImage: 441 case kClearAndUpdateImage:
433 // Have the image update its data from its internal buffer. It will not do 442 // Have the image update its data from its internal buffer. It will not do
434 // anything now, but will delay decoding until queried for info (like size 443 // anything now, but will delay decoding until queried for info (like size
435 // or specific image frames). 444 // or specific image frames).
436 if (data) { 445 if (data) {
437 if (!image_) 446 if (!image_)
438 image_ = CreateImage(); 447 image_ = CreateImage();
439 DCHECK(image_); 448 DCHECK(image_);
440 size_available_ = image_->SetData(std::move(data), all_data_received); 449 size_available_ = image_->SetData(std::move(data), all_data_received);
450 if (!all_data_received) {
yhirano 2017/05/09 08:33:57 This is same as L477-L479. Why do we have the same
hiroshige 2017/05/10 22:45:49 Done, unified the style.
451 DCHECK_NE(size_available_,
452 Image::kSizeAvailableAndLoadingAsynchronously);
453 }
441 } 454 }
442 455
443 // Go ahead and tell our observers to try to draw if we have either 456 // Go ahead and tell our observers to try to draw if we have either
444 // received all the data or the size is known. Each chunk from the network 457 // received all the data or the size is known. Each chunk from the network
445 // causes observers to repaint, which will force that chunk to decode. 458 // causes observers to repaint, which will force that chunk to decode.
446 if (size_available_ == Image::kSizeUnavailable && !all_data_received) 459 if (size_available_ == Image::kSizeUnavailable && !all_data_received)
447 return UpdateImageResult::kNoDecodeError; 460 return UpdateImageResult::kNoDecodeError;
448 461
449 if (info_->ShouldShowPlaceholder() && all_data_received) { 462 if (info_->ShouldShowPlaceholder() && all_data_received) {
450 if (image_ && !image_->IsNull()) { 463 if (image_ && !image_->IsNull()) {
451 IntSize dimensions = image_->Size(); 464 IntSize dimensions = image_->Size();
452 ClearImage(); 465 ClearImage();
453 image_ = PlaceholderImage::Create(this, dimensions); 466 image_ = PlaceholderImage::Create(this, dimensions);
454 } 467 }
455 } 468 }
456 469
457 if (!image_ || image_->IsNull()) { 470 if (!image_ || image_->IsNull()) {
458 ClearImage(); 471 ClearImage();
459 return UpdateImageResult::kShouldDecodeError; 472 return UpdateImageResult::kShouldDecodeError;
460 } 473 }
461 break; 474 break;
462 } 475 }
463 476
477 DCHECK(all_data_received ||
478 size_available_ != Image::kSizeAvailableAndLoadingAsynchronously);
479
464 // Notifies the observers. 480 // Notifies the observers.
465 // It would be nice to only redraw the decoded band of the image, but with the 481 // It would be nice to only redraw the decoded band of the image, but with the
466 // current design (decoding delayed until painting) that seems hard. 482 // current design (decoding delayed until painting) that seems hard.
467 483 //
468 if (all_data_received) { 484 // In the case of kSizeAvailableAndLoadingAsynchronously, we are waiting for
485 // SVG image completion, and thus we notify observers of kDoNotNotifyFinish
486 // here, and will notify observers of finish later in AsyncLoadCompleted().
487 if (all_data_received &&
488 size_available_ != Image::kSizeAvailableAndLoadingAsynchronously) {
469 UpdateToLoadedContentStatus(status); 489 UpdateToLoadedContentStatus(status);
470 NotifyObservers(kShouldNotifyFinish); 490 NotifyObservers(kShouldNotifyFinish);
471 } else { 491 } else {
472 NotifyObservers(kDoNotNotifyFinish); 492 NotifyObservers(kDoNotNotifyFinish);
473 } 493 }
474 494
475 return UpdateImageResult::kNoDecodeError; 495 return UpdateImageResult::kNoDecodeError;
476 } 496 }
477 497
478 void ImageResourceContent::DecodedSizeChangedTo(const blink::Image* image, 498 void ImageResourceContent::DecodedSizeChangedTo(const blink::Image* image,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 614
595 const ResourceResponse& ImageResourceContent::GetResponse() const { 615 const ResourceResponse& ImageResourceContent::GetResponse() const {
596 return info_->GetResponse(); 616 return info_->GetResponse();
597 } 617 }
598 618
599 const ResourceError& ImageResourceContent::GetResourceError() const { 619 const ResourceError& ImageResourceContent::GetResourceError() const {
600 return info_->GetResourceError(); 620 return info_->GetResourceError();
601 } 621 }
602 622
603 } // namespace blink 623 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698