Changeset 95228 in webkit


Ignore:
Timestamp:
Sep 15, 2011 2:21:11 PM (13 years ago)
Author:
aestes@apple.com
Message:

Having an empty listener to beforeload events changes the behavior of other scripts
https://bugs.webkit.org/show_bug.cgi?id=45586

Reviewed by Darin Adler.

Source/WebCore:

Test: fast/dom/beforeload/cached-image-before-load.html

When loading a cached image after a beforeload handler has been
installed on the document, ImageLoader would dispatch both the
beforeload and load events asynchronously in such a way that caused
load to fire first. Since a side effect of firing the beforeload event
is to wire up the CachedImage to its associated RenderImage object,
this work was not done by the time load fired, and scripts that queried
renderer-dependent attributes of the image in an onload handler would
get bogus values in return.

Fix this by ensuring load fires after beforeload in the cached image case.

  • loader/ImageLoader.cpp:

(WebCore::ImageLoader::updateFromElement): Call setClient() after
dispatching beforeload, since setClient() will dispatch the load event
if the image is cached.

LayoutTests:

  • fast/dom/beforeload/cached-image-before-load-expected.txt: Added.
  • fast/dom/beforeload/cached-image-before-load.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r95226 r95228  
     12011-09-15  Andy Estes  <aestes@apple.com>
     2
     3        Having an empty listener to beforeload events changes the behavior of other scripts
     4        https://bugs.webkit.org/show_bug.cgi?id=45586
     5
     6        Reviewed by Darin Adler.
     7
     8        * fast/dom/beforeload/cached-image-before-load-expected.txt: Added.
     9        * fast/dom/beforeload/cached-image-before-load.html: Added.
     10
    1112011-09-15  Jon Lee  <jonlee@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r95227 r95228  
     12011-09-15  Andy Estes  <aestes@apple.com>
     2
     3        Having an empty listener to beforeload events changes the behavior of other scripts
     4        https://bugs.webkit.org/show_bug.cgi?id=45586
     5
     6        Reviewed by Darin Adler.
     7
     8        Test: fast/dom/beforeload/cached-image-before-load.html
     9       
     10        When loading a cached image after a beforeload handler has been
     11        installed on the document, ImageLoader would dispatch both the
     12        beforeload and load events asynchronously in such a way that caused
     13        load to fire first. Since a side effect of firing the beforeload event
     14        is to wire up the CachedImage to its associated RenderImage object,
     15        this work was not done by the time load fired, and scripts that queried
     16        renderer-dependent attributes of the image in an onload handler would
     17        get bogus values in return.
     18
     19        Fix this by ensuring load fires after beforeload in the cached image case.
     20
     21        * loader/ImageLoader.cpp:
     22        (WebCore::ImageLoader::updateFromElement): Call setClient() after
     23        dispatching beforeload, since setClient() will dispatch the load event
     24        if the image is cached.
     25
    1262011-09-15  Anders Carlsson  <andersca@apple.com>
    227
  • trunk/Source/WebCore/loader/ImageLoader.cpp

    r94427 r95228  
    203203
    204204        if (newImage) {
    205             newImage->addClient(this);
    206205            if (!m_element->document()->hasListenerType(Document::BEFORELOAD_LISTENER))
    207206                dispatchPendingBeforeLoadEvent();
    208207            else
    209208                beforeLoadEventSender().dispatchEventSoon(this);
     209
     210            // If newImage is cached, addClient() will result in the load event
     211            // being queued to fire. Ensure this happens after beforeload is
     212            // dispatched.
     213            newImage->addClient(this);
    210214        }
    211215        if (oldImage)
Note: See TracChangeset for help on using the changeset viewer.