OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserv
ed. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 Apple Inc. All rights reserv
ed. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 // FIXME: If both previous load and this one got blocked with an error,
we can receive one error event instead of two. | 372 // FIXME: If both previous load and this one got blocked with an error,
we can receive one error event instead of two. |
373 if (m_hasPendingErrorEvent && newImage) { | 373 if (m_hasPendingErrorEvent && newImage) { |
374 errorEventSender().cancelEvent(this); | 374 errorEventSender().cancelEvent(this); |
375 m_hasPendingErrorEvent = false; | 375 m_hasPendingErrorEvent = false; |
376 } | 376 } |
377 | 377 |
378 m_image = newImage; | 378 m_image = newImage; |
379 m_hasPendingLoadEvent = newImage; | 379 m_hasPendingLoadEvent = newImage; |
380 m_imageComplete = !newImage; | 380 m_imageComplete = !newImage; |
381 | 381 |
382 updateLayoutObject(); | 382 updateLayoutObject(url); |
383 // If newImage exists and is cached, addClient() will result in the load
event | 383 // If newImage exists and is cached, addClient() will result in the load
event |
384 // being queued to fire. Ensure this happens after beforeload is dispatc
hed. | 384 // being queued to fire. Ensure this happens after beforeload is dispatc
hed. |
385 if (newImage) | 385 if (newImage) |
386 newImage->addClient(this); | 386 newImage->addClient(this); |
387 | 387 |
388 if (oldImage) | 388 if (oldImage) |
389 oldImage->removeClient(this); | 389 oldImage->removeClient(this); |
390 } | 390 } |
391 | 391 |
392 if (LayoutImageResource* imageResource = layoutImageResource()) | 392 if (LayoutImageResource* imageResource = layoutImageResource()) |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 475 |
476 ASSERT(m_failedLoadURL.isEmpty()); | 476 ASSERT(m_failedLoadURL.isEmpty()); |
477 ASSERT(resource == m_image.get()); | 477 ASSERT(resource == m_image.get()); |
478 | 478 |
479 m_imageComplete = true; | 479 m_imageComplete = true; |
480 | 480 |
481 // Update ImageAnimationPolicy for m_image. | 481 // Update ImageAnimationPolicy for m_image. |
482 if (m_image) | 482 if (m_image) |
483 m_image->updateImageAnimationPolicy(); | 483 m_image->updateImageAnimationPolicy(); |
484 | 484 |
485 updateLayoutObject(); | 485 updateLayoutObject(imageSourceToKURL(m_element->imageSourceURL())); |
486 | 486 |
487 if (m_image && m_image->image() && m_image->image()->isSVGImage()) | 487 if (m_image && m_image->image() && m_image->image()->isSVGImage()) |
488 toSVGImage(m_image->image())->updateUseCounters(element()->document()); | 488 toSVGImage(m_image->image())->updateUseCounters(element()->document()); |
489 | 489 |
490 if (!m_hasPendingLoadEvent) | 490 if (!m_hasPendingLoadEvent) |
491 return; | 491 return; |
492 | 492 |
493 if (resource->errorOccurred()) { | 493 if (resource->errorOccurred()) { |
494 loadEventSender().cancelEvent(this); | 494 loadEventSender().cancelEvent(this); |
495 m_hasPendingLoadEvent = false; | 495 m_hasPendingLoadEvent = false; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 | 531 |
532 if (layoutObject->isSVGImage()) | 532 if (layoutObject->isSVGImage()) |
533 return toLayoutSVGImage(layoutObject)->imageResource(); | 533 return toLayoutSVGImage(layoutObject)->imageResource(); |
534 | 534 |
535 if (layoutObject->isVideo()) | 535 if (layoutObject->isVideo()) |
536 return toLayoutVideo(layoutObject)->imageResource(); | 536 return toLayoutVideo(layoutObject)->imageResource(); |
537 | 537 |
538 return 0; | 538 return 0; |
539 } | 539 } |
540 | 540 |
541 void ImageLoader::updateLayoutObject() | 541 void ImageLoader::updateLayoutObject(const KURL& urlWithFragment) |
542 { | 542 { |
543 LayoutImageResource* imageResource = layoutImageResource(); | 543 LayoutImageResource* imageResource = layoutImageResource(); |
544 | 544 |
545 if (!imageResource) | 545 if (!imageResource) |
546 return; | 546 return; |
547 | 547 |
548 // Only update the layoutObject if it doesn't have an image or if what we ha
ve | 548 // Only update the layoutObject if it doesn't have an image or if what we ha
ve |
549 // is a complete image. This prevents flickering in the case where a dynami
c | 549 // is a complete image. This prevents flickering in the case where a dynami
c |
550 // change is happening between two images. | 550 // change is happening between two images. |
551 ImageResource* cachedImage = imageResource->cachedImage(); | 551 ImageResource* cachedImage = imageResource->cachedImage(); |
552 if (m_image != cachedImage && (m_imageComplete || !cachedImage)) | 552 if (m_image != cachedImage && (m_imageComplete || !cachedImage)) |
553 imageResource->setImageResource(m_image.get()); | 553 imageResource->setImageResource(m_image.get(), urlWithFragment); |
554 } | 554 } |
555 | 555 |
556 void ImageLoader::updatedHasPendingEvent() | 556 void ImageLoader::updatedHasPendingEvent() |
557 { | 557 { |
558 // If an Element that does image loading is removed from the DOM the load/er
ror event for the image is still observable. | 558 // If an Element that does image loading is removed from the DOM the load/er
ror event for the image is still observable. |
559 // As long as the ImageLoader is actively loading, the Element itself needs
to be ref'ed to keep it from being | 559 // As long as the ImageLoader is actively loading, the Element itself needs
to be ref'ed to keep it from being |
560 // destroyed by DOM manipulation or garbage collection. | 560 // destroyed by DOM manipulation or garbage collection. |
561 // If such an Element wishes for the load to stop when removed from the DOM
it needs to stop the ImageLoader explicitly. | 561 // If such an Element wishes for the load to stop when removed from the DOM
it needs to stop the ImageLoader explicitly. |
562 bool wasProtected = m_elementIsProtected; | 562 bool wasProtected = m_elementIsProtected; |
563 m_elementIsProtected = m_hasPendingLoadEvent || m_hasPendingErrorEvent; | 563 m_elementIsProtected = m_hasPendingLoadEvent || m_hasPendingErrorEvent; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 | 674 |
675 void ImageLoader::sourceImageChanged() | 675 void ImageLoader::sourceImageChanged() |
676 { | 676 { |
677 for (auto& client : m_clients) { | 677 for (auto& client : m_clients) { |
678 ImageLoaderClient* handle = client; | 678 ImageLoaderClient* handle = client; |
679 handle->notifyImageSourceChanged(); | 679 handle->notifyImageSourceChanged(); |
680 } | 680 } |
681 } | 681 } |
682 | 682 |
683 } // namespace blink | 683 } // namespace blink |
OLD | NEW |