Changeset 125147 in webkit


Ignore:
Timestamp:
Aug 8, 2012 9:16:38 PM (12 years ago)
Author:
morrita@google.com
Message:

[SVG] load events shouldn't be fired during Node::insrtedInto()
https://bugs.webkit.org/show_bug.cgi?id=92969

Reviewed by Ryosuke Niwa.

Source/WebCore:

Event dispatches during insertedInto() allow event handlers to
break DOM tree cosistency. This chagne makes them async for load
events which are dispatched during insertedInto() call. This
prevents event handlers from breaking tree consistency while the
notification traversal.

Test: svg/custom/loadevents-async.html

  • svg/SVGElement.cpp:

(WebCore::SVGElement::sendSVGLoadEventIfPossibleAsynchronously): Added.
(WebCore):
(WebCore::SVGElement::svgLoadEventTimerFired): Added.
(WebCore::SVGElement::svgLoadEventTimer):

  • Added a stub. Implemented in SVGScriptElement, SVGStopElement, SVGUseElement where the load event happens.
  • svg/SVGElement.h:

(SVGElement):

  • svg/SVGExternalResourcesRequired.cpp:

(WebCore::SVGExternalResourcesRequired::insertedIntoDocument):

  • Replaces event dispatch call with async version.
  • svg/SVGScriptElement.h:
  • svg/SVGStyleElement.h:
  • svg/SVGUseElement.h:

LayoutTests:

  • svg/custom/loadevents-async-expected.txt: Added.
  • svg/custom/loadevents-async.html: Added.
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r125140 r125147  
     12012-08-08  MORITA Hajime  <morrita@google.com>
     2
     3        [SVG] load events shouldn't be fired during Node::insrtedInto()
     4        https://bugs.webkit.org/show_bug.cgi?id=92969
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * svg/custom/loadevents-async-expected.txt: Added.
     9        * svg/custom/loadevents-async.html: Added.
     10
    1112012-08-08  Tony Chang  <tony@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r125146 r125147  
     12012-08-08  MORITA Hajime  <morrita@google.com>
     2
     3        [SVG] load events shouldn't be fired during Node::insrtedInto()
     4        https://bugs.webkit.org/show_bug.cgi?id=92969
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Event dispatches during insertedInto() allow event handlers to
     9        break DOM tree cosistency. This chagne makes them async for load
     10        events which are dispatched during insertedInto() call. This
     11        prevents event handlers from breaking tree consistency while the
     12        notification traversal.
     13
     14        Test: svg/custom/loadevents-async.html
     15
     16        * svg/SVGElement.cpp:
     17        (WebCore::SVGElement::sendSVGLoadEventIfPossibleAsynchronously): Added.
     18        (WebCore):
     19        (WebCore::SVGElement::svgLoadEventTimerFired): Added.
     20        (WebCore::SVGElement::svgLoadEventTimer):
     21        - Added a stub. Implemented in SVGScriptElement, SVGStopElement, SVGUseElement
     22          where the load event happens.
     23        * svg/SVGElement.h:
     24        (SVGElement):
     25        * svg/SVGExternalResourcesRequired.cpp:
     26        (WebCore::SVGExternalResourcesRequired::insertedIntoDocument):
     27        - Replaces event dispatch call with async version.
     28        * svg/SVGScriptElement.h:
     29        * svg/SVGStyleElement.h:
     30        * svg/SVGUseElement.h:
     31
    1322012-08-08  Adam Barth  <abarth@webkit.org>
    233
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r122449 r125147  
    476476            break;
    477477    }
     478}
     479
     480void SVGElement::sendSVGLoadEventIfPossibleAsynchronously()
     481{
     482    svgLoadEventTimer()->startOneShot(0);
     483}
     484
     485void SVGElement::svgLoadEventTimerFired(Timer<SVGElement>*)
     486{
     487    sendSVGLoadEventIfPossible();
     488}
     489
     490Timer<SVGElement>* SVGElement::svgLoadEventTimer()
     491{
     492    ASSERT_NOT_REACHED();
     493    return 0;
    478494}
    479495
  • trunk/Source/WebCore/svg/SVGElement.h

    r121330 r125147  
    2828#include "SVGPropertyInfo.h"
    2929#include "StyledElement.h"
     30#include "Timer.h"
    3031#include <wtf/HashMap.h>
    3132
     
    7374
    7475    void sendSVGLoadEventIfPossible(bool sendParentLoadEvents = false);
     76    void sendSVGLoadEventIfPossibleAsynchronously();
     77    void svgLoadEventTimerFired(Timer<SVGElement>*);
     78    virtual Timer<SVGElement>* svgLoadEventTimer();
    7579
    7680    virtual AffineTransform* supplementalTransform() { return 0; }
  • trunk/Source/WebCore/svg/SVGExternalResourcesRequired.cpp

    r117195 r125147  
    104104        return;
    105105    setHaveFiredLoadEvent(true);
    106     targetElement->sendSVGLoadEventIfPossible();
     106    targetElement->sendSVGLoadEventIfPossibleAsynchronously();
    107107}
    108108
  • trunk/Source/WebCore/svg/SVGScriptElement.cpp

    r118963 r125147  
    4848    : SVGElement(tagName, document)
    4949    , ScriptElement(this, wasInsertedByParser, alreadyStarted)
     50    , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired)
    5051{
    5152    ASSERT(hasTagName(SVGNames::scriptTag));
  • trunk/Source/WebCore/svg/SVGScriptElement.h

    r118963 r125147  
    7676    virtual bool isParserInserted() const { return ScriptElement::isParserInserted(); }
    7777    virtual bool haveFiredLoadEvent() const { return ScriptElement::haveFiredLoadEvent(); }
     78    virtual Timer<SVGElement>* svgLoadEventTimer() OVERRIDE { return &m_svgLoadEventTimer; }
    7879
    7980    BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGScriptElement)
     
    8384
    8485    String m_type;
     86    Timer<SVGElement> m_svgLoadEventTimer;
    8587};
    8688
  • trunk/Source/WebCore/svg/SVGStyleElement.cpp

    r118192 r125147  
    3838    : SVGElement(tagName, document)
    3939    , StyleElement(document, createdByParser)
     40    , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired)
    4041{
    4142    ASSERT(hasTagName(SVGNames::styleTag));
  • trunk/Source/WebCore/svg/SVGStyleElement.h

    r118192 r125147  
    6464    virtual bool sheetLoaded() { return StyleElement::sheetLoaded(document()); }
    6565    virtual void startLoadingDynamicSheet() { StyleElement::startLoadingDynamicSheet(document()); }
     66    virtual Timer<SVGElement>* svgLoadEventTimer() OVERRIDE { return &m_svgLoadEventTimer; }
     67
     68    Timer<SVGElement> m_svgLoadEventTimer;
    6669};
    6770
  • trunk/Source/WebCore/svg/SVGUseElement.cpp

    r122449 r125147  
    9090    , m_haveFiredLoadEvent(false)
    9191    , m_needsShadowTreeRecreation(false)
     92    , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired)
    9293{
    9394    ASSERT(hasCustomCallbacks());
  • trunk/Source/WebCore/svg/SVGUseElement.h

    r122449 r125147  
    125125    virtual bool isParserInserted() const { return m_wasInsertedByParser; }
    126126    virtual bool haveFiredLoadEvent() const { return m_haveFiredLoadEvent; }
     127    virtual Timer<SVGElement>* svgLoadEventTimer() OVERRIDE { return &m_svgLoadEventTimer; }
    127128
    128129    bool m_wasInsertedByParser;
     
    131132    RefPtr<SVGElementInstance> m_targetElementInstance;
    132133    CachedResourceHandle<CachedSVGDocument> m_cachedDocument;
     134    Timer<SVGElement> m_svgLoadEventTimer;
    133135};
    134136
Note: See TracChangeset for help on using the changeset viewer.