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

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 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::LoadCompleted(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) {
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
464 // Notifies the observers. 477 // Notifies the observers.
465 // It would be nice to only redraw the decoded band of the image, but with the 478 // 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. 479 // current design (decoding delayed until painting) that seems hard.
467 480 if (all_data_received &&
468 if (all_data_received) { 481 size_available_ != Image::kSizeAvailableAndLoadingAsynchronously) {
fs 2017/05/05 10:52:42 Nit: Maybe add a short comment about this addition
hiroshige 2017/05/08 17:22:06 Done.
469 UpdateToLoadedContentStatus(status); 482 UpdateToLoadedContentStatus(status);
470 NotifyObservers(kShouldNotifyFinish); 483 NotifyObservers(kShouldNotifyFinish);
471 } else { 484 } else {
472 NotifyObservers(kDoNotNotifyFinish); 485 NotifyObservers(kDoNotNotifyFinish);
473 } 486 }
474 487
475 return UpdateImageResult::kNoDecodeError; 488 return UpdateImageResult::kNoDecodeError;
476 } 489 }
477 490
478 void ImageResourceContent::DecodedSizeChangedTo(const blink::Image* image, 491 void ImageResourceContent::DecodedSizeChangedTo(const blink::Image* image,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 607
595 const ResourceResponse& ImageResourceContent::GetResponse() const { 608 const ResourceResponse& ImageResourceContent::GetResponse() const {
596 return info_->GetResponse(); 609 return info_->GetResponse();
597 } 610 }
598 611
599 const ResourceError& ImageResourceContent::GetResourceError() const { 612 const ResourceError& ImageResourceContent::GetResourceError() const {
600 return info_->GetResourceError(); 613 return info_->GetResourceError();
601 } 614 }
602 615
603 } // namespace blink 616 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698