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

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, 9 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 m_status = ResourceStatus::Cached; 310 m_status = ResourceStatus::Cached;
311 } 311 }
312 break; 312 break;
313 case DoNotNotifyFinish: 313 case DoNotNotifyFinish:
314 if (m_status == ResourceStatus::NotStarted) 314 if (m_status == ResourceStatus::NotStarted)
315 m_status = ResourceStatus::Pending; 315 m_status = ResourceStatus::Pending;
316 break; 316 break;
317 } 317 }
318 } 318 }
319 319
320 void ImageResourceContent::loadCompleted(const blink::Image* image) {
321 if (m_image != image)
322 return;
323 CHECK_EQ(m_sizeAvailable, Image::SizeAvailableAndLoadingAsynchronously);
324 m_sizeAvailable = Image::SizeAvailable;
325 updateStatus(ResourceStatus::Cached, ShouldNotifyFinish);
326 notifyObservers(ShouldNotifyFinish);
327 }
328
320 ImageResourceContent::UpdateImageResult ImageResourceContent::updateImage( 329 ImageResourceContent::UpdateImageResult ImageResourceContent::updateImage(
321 PassRefPtr<SharedBuffer> data, 330 PassRefPtr<SharedBuffer> data,
322 ResourceStatus status, 331 ResourceStatus status,
323 UpdateImageOption updateImageOption, 332 UpdateImageOption updateImageOption,
324 bool allDataReceived) { 333 bool allDataReceived) {
325 TRACE_EVENT0("blink", "ImageResourceContent::updateImage"); 334 TRACE_EVENT0("blink", "ImageResourceContent::updateImage");
326 335
327 #if DCHECK_IS_ON() 336 #if DCHECK_IS_ON()
328 DCHECK(!m_isUpdateImageBeingCalled); 337 DCHECK(!m_isUpdateImageBeingCalled);
329 AutoReset<bool> scope(&m_isUpdateImageBeingCalled, true); 338 AutoReset<bool> scope(&m_isUpdateImageBeingCalled, true);
(...skipping 18 matching lines...) Expand all
348 case UpdateImage: 357 case UpdateImage:
349 case ClearAndUpdateImage: 358 case ClearAndUpdateImage:
350 // Have the image update its data from its internal buffer. It will not do 359 // Have the image update its data from its internal buffer. It will not do
351 // anything now, but will delay decoding until queried for info (like size 360 // anything now, but will delay decoding until queried for info (like size
352 // or specific image frames). 361 // or specific image frames).
353 if (data) { 362 if (data) {
354 if (!m_image) 363 if (!m_image)
355 m_image = createImage(); 364 m_image = createImage();
356 DCHECK(m_image); 365 DCHECK(m_image);
357 m_sizeAvailable = m_image->setData(std::move(data), allDataReceived); 366 m_sizeAvailable = m_image->setData(std::move(data), allDataReceived);
367 if (!allDataReceived) {
368 DCHECK_NE(m_sizeAvailable,
369 Image::SizeAvailableAndLoadingAsynchronously);
370 }
358 } 371 }
359 372
360 // Go ahead and tell our observers to try to draw if we have either 373 // Go ahead and tell our observers to try to draw if we have either
361 // received all the data or the size is known. Each chunk from the network 374 // received all the data or the size is known. Each chunk from the network
362 // causes observers to repaint, which will force that chunk to decode. 375 // causes observers to repaint, which will force that chunk to decode.
363 if (m_sizeAvailable == Image::SizeUnavailable && !allDataReceived) { 376 if (m_sizeAvailable == Image::SizeUnavailable && !allDataReceived) {
364 updateStatus(status, DoNotNotifyFinish); 377 updateStatus(status, DoNotNotifyFinish);
365 return UpdateImageResult::NoDecodeError; 378 return UpdateImageResult::NoDecodeError;
366 } 379 }
367 380
(...skipping 11 matching lines...) Expand all
379 return UpdateImageResult::ShouldDecodeError; 392 return UpdateImageResult::ShouldDecodeError;
380 } 393 }
381 break; 394 break;
382 } 395 }
383 396
384 // Notifies the observers. 397 // Notifies the observers.
385 // It would be nice to only redraw the decoded band of the image, but with the 398 // It would be nice to only redraw the decoded band of the image, but with the
386 // current design (decoding delayed until painting) that seems hard. 399 // current design (decoding delayed until painting) that seems hard.
387 400
388 NotifyFinishOption notifyFinishOption = 401 NotifyFinishOption notifyFinishOption =
389 allDataReceived ? ShouldNotifyFinish : DoNotNotifyFinish; 402 allDataReceived &&
403 m_sizeAvailable != Image::SizeAvailableAndLoadingAsynchronously
404 ? ShouldNotifyFinish
405 : DoNotNotifyFinish;
390 updateStatus(status, notifyFinishOption); 406 updateStatus(status, notifyFinishOption);
391 notifyObservers(notifyFinishOption); 407 notifyObservers(notifyFinishOption);
392 return UpdateImageResult::NoDecodeError; 408 return UpdateImageResult::NoDecodeError;
393 } 409 }
394 410
395 void ImageResourceContent::notifyStartLoad() { 411 void ImageResourceContent::notifyStartLoad() {
396 m_status = ResourceStatus::Pending; 412 m_status = ResourceStatus::Pending;
397 } 413 }
398 414
399 void ImageResourceContent::decodedSizeChangedTo(const blink::Image* image, 415 void ImageResourceContent::decodedSizeChangedTo(const blink::Image* image,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 525
510 const ResourceResponse& ImageResourceContent::response() const { 526 const ResourceResponse& ImageResourceContent::response() const {
511 return m_info->response(); 527 return m_info->response();
512 } 528 }
513 529
514 const ResourceError& ImageResourceContent::resourceError() const { 530 const ResourceError& ImageResourceContent::resourceError() const {
515 return m_info->resourceError(); 531 return m_info->resourceError();
516 } 532 }
517 533
518 } // namespace blink 534 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698