Changeset 181849 in webkit


Ignore:
Timestamp:
Mar 23, 2015 2:14:19 AM (9 years ago)
Author:
yoav@yoav.ws
Message:

Refactor ImageLoader's setting of CachedImage
https://bugs.webkit.org/show_bug.cgi?id=142825

Reviewed by Chris Dumez.

No new tests, since there's no functional change.

setImage and setImageWithoutConsideringPendingLoadEvent were not called with new
CachedImages and were not used as originally intended. That resulted in some dead code,
and confusion when going over the code.
This patch renames these methods into equivalent clearImage* methods, and deletes resulting dead code.

  • html/HTMLObjectElement.cpp:

(WebCore::HTMLObjectElement::renderFallbackContent): Changed setImage call to clearImage.

  • loader/ImageLoader.cpp:

(WebCore::ImageLoader::clearImage):
(WebCore::ImageLoader::clearImageWithoutConsideringPendingLoadEvent):
(WebCore::ImageLoader::notifyFinished):
(WebCore::ImageLoader::elementDidMoveToNewDocument):
(WebCore::ImageLoader::setImage): Deleted.
(WebCore::ImageLoader::setImageWithoutConsideringPendingLoadEvent): Deleted.

  • loader/ImageLoader.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r181845 r181849  
     12015-03-23  Yoav Weiss  <yoav@yoav.ws>
     2
     3        Refactor ImageLoader's setting of CachedImage
     4        https://bugs.webkit.org/show_bug.cgi?id=142825
     5
     6        Reviewed by Chris Dumez.
     7
     8        No new tests, since there's no functional change.
     9
     10        setImage and setImageWithoutConsideringPendingLoadEvent were not called with new
     11        CachedImages and were not used as originally intended. That resulted in some dead code,
     12        and confusion when going over the code.
     13        This patch renames these methods into equivalent clearImage* methods, and deletes resulting dead code.
     14
     15        * html/HTMLObjectElement.cpp:
     16        (WebCore::HTMLObjectElement::renderFallbackContent): Changed setImage call to clearImage.
     17        * loader/ImageLoader.cpp:
     18        (WebCore::ImageLoader::clearImage):
     19        (WebCore::ImageLoader::clearImageWithoutConsideringPendingLoadEvent):
     20        (WebCore::ImageLoader::notifyFinished):
     21        (WebCore::ImageLoader::elementDidMoveToNewDocument):
     22        (WebCore::ImageLoader::setImage): Deleted.
     23        (WebCore::ImageLoader::setImageWithoutConsideringPendingLoadEvent): Deleted.
     24        * loader/ImageLoader.h:
     25
    1262015-03-22  Benjamin Poulain  <benjamin@webkit.org>
    227
  • trunk/Source/WebCore/html/HTMLObjectElement.cpp

    r181507 r181849  
    383383        if (!isImageType()) {
    384384            // If we don't think we have an image type anymore, then clear the image from the loader.
    385             loader->setImage(nullptr);
     385            loader->clearImage();
    386386            return;
    387387        }
  • trunk/Source/WebCore/loader/ImageLoader.cpp

    r181412 r181849  
    124124}
    125125
    126 void ImageLoader::setImage(CachedImage* newImage)
    127 {
    128     setImageWithoutConsideringPendingLoadEvent(newImage);
     126void ImageLoader::clearImage()
     127{
     128    clearImageWithoutConsideringPendingLoadEvent();
    129129
    130130    // Only consider updating the protection ref-count of the Element immediately before returning
     
    133133}
    134134
    135 void ImageLoader::setImageWithoutConsideringPendingLoadEvent(CachedImage* newImage)
     135void ImageLoader::clearImageWithoutConsideringPendingLoadEvent()
    136136{
    137137    ASSERT(m_failedLoadURL.isEmpty());
    138138    CachedImage* oldImage = m_image.get();
    139     if (newImage != oldImage) {
    140         m_image = newImage;
     139    if (oldImage) {
     140        m_image = nullptr;
    141141        if (m_hasPendingBeforeLoadEvent) {
    142142            beforeLoadEventSender().cancelEvent(*this);
     
    152152        }
    153153        m_imageComplete = true;
    154         if (newImage)
    155             newImage->addClient(this);
    156154        if (oldImage)
    157155            oldImage->removeClient(this);
     
    289287        && !resource->passesAccessControlCheck(element().document().securityOrigin())) {
    290288
    291         setImageWithoutConsideringPendingLoadEvent(0);
     289        clearImageWithoutConsideringPendingLoadEvent();
    292290
    293291        m_hasPendingErrorEvent = true;
     
    467465{
    468466    clearFailedLoadURL();
    469     setImage(0);
     467    clearImage();
    470468}
    471469
  • trunk/Source/WebCore/loader/ImageLoader.h

    r181412 r181849  
    5959
    6060    CachedImage* image() const { return m_image.get(); }
    61     void setImage(CachedImage*); // Cancels pending beforeload and load events, and doesn't dispatch new ones.
     61    void clearImage(); // Cancels pending beforeload and load events, and doesn't dispatch new ones.
    6262
    6363    void setLoadManually(bool loadManually) { m_loadManually = loadManually; }
     
    8989    void updateRenderer();
    9090
    91     void setImageWithoutConsideringPendingLoadEvent(CachedImage*);
     91    void clearImageWithoutConsideringPendingLoadEvent();
    9292    void clearFailedLoadURL();
    9393
Note: See TracChangeset for help on using the changeset viewer.