Ignore:
Timestamp:
Sep 21, 2013, 11:25:43 AM (12 years ago)
Author:
Darin Adler
Message:

Shink attribute event listener code
https://bugs.webkit.org/show_bug.cgi?id=121735

Reviewed by Antti Koivisto.

  • GNUmakefile.list.am: Eliminate ScriptEventListener source files.
  • Target.pri: Ditto.
  • UseJSC.cmake: Ditto.
  • WebCore.vcxproj/WebCore.vcxproj: Ditto.
  • WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • bindings/js/JSBindingsAllInOne.cpp: Ditto.
  • bindings/js/JSDOMGlobalObject.h: Removed unneeded forward declarations

of JSEventListener and JSLazyEventListener.

  • bindings/js/JSLazyEventListener.cpp:

(WebCore::JSLazyEventListener::JSLazyEventListener): Changed type to
ContainerNode because the node pointer is only ever used for elements
and documents.
(WebCore::eventParameterName): Moved this function here from
ScriptEventListener.cpp, but also rewrote to use NeverDestroyed.
(WebCore::JSLazyEventListener::createForNode): Moved this function
here from ScriptEventListener.cpp, cleaned up a bit.
(WebCore::JSLazyEventListener::createForDOMWindow): Ditto.

  • bindings/js/JSLazyEventListener.h: Replaced the old create function

with two new create functions we can use directly. Also used some
OVERRIDE, some FINAL, and a bit of WTF_DELETED_FUNCTION so we don't
accidentally call create and create a non-lazy listener.

  • bindings/js/ScriptEventListener.cpp: Removed.
  • bindings/js/ScriptEventListener.h: Removed.
  • dom/ContainerNode.cpp:

(WebCore::ContainerNode::setAttributeEventListener): Added.
Calls JSLazyEventListener::createForNode and then calls the other
overload of setAttributeEventListener, to obviate having more code
at the call site.

  • dom/ContainerNode.h: Added overload of setAttributeEventListener

for convenient use in Document and Element implementations.

  • dom/Document.cpp:

(WebCore::Document::prepareForDestruction): Use m_domWindow instead
of the domWindow() function.
(WebCore::Document::removeAllEventListeners): Ditto.
(WebCore::Document::errorEventTarget): Ditto.
(WebCore::Document::takeDOMWindowFrom): Ditto.
(WebCore::Document::setWindowAttributeEventListener): Ditto. Also
added an overload that calls JSLazyEventListener::createForDOMWindow.
(WebCore::Document::getWindowAttributeEventListener): Use m_domWindow.
(WebCore::Document::dispatchWindowEvent): Ditto.
(WebCore::Document::dispatchWindowLoadEvent): Ditto.
(WebCore::Document::enqueueWindowEvent): Ditto.
(WebCore::Document::enqueuePopstateEvent): Ditto.

  • dom/Document.h: Added overload of setWindowAttributeEventListener.
  • html/HTMLBodyElement.cpp: Removed unnneded include.

(WebCore::HTMLBodyElement::parseAttribute): Removed all the calls to
createAttributeEventListener, and use the setAttributeEventListener
overloads instead.

  • html/HTMLButtonElement.cpp: Ditto.
  • html/HTMLElement.cpp:

(WebCore::HTMLElement::parseAttribute): Ditto.

  • html/HTMLFormControlElement.cpp: Ditto.
  • html/HTMLFormElement.cpp: Ditto.
  • html/HTMLFrameElementBase.cpp:

(WebCore::HTMLFrameElementBase::parseAttribute): Ditto.

  • html/HTMLFrameSetElement.cpp:

(WebCore::HTMLFrameSetElement::parseAttribute): Ditto.

  • html/HTMLImageElement.cpp:

(WebCore::HTMLImageElement::parseAttribute): Ditto.

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::parseAttribute): Ditto.

  • html/HTMLLinkElement.cpp:

(WebCore::HTMLLinkElement::parseAttribute): Ditto.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::parseAttribute): Ditto.

  • html/HTMLObjectElement.cpp:

(WebCore::HTMLObjectElement::parseAttribute): Ditto.

  • html/HTMLScriptElement.cpp:

(WebCore::HTMLScriptElement::parseAttribute): Ditto.

  • html/HTMLSelectElement.cpp: Ditto.
  • html/HTMLStyleElement.cpp: Ditto.
  • html/HTMLTextFormControlElement.cpp: Ditto.
  • html/HTMLTrackElement.cpp: Ditto.
  • html/track/LoadableTextTrack.cpp: Ditto.
  • svg/SVGElement.cpp:

(WebCore::SVGElement::parseAttribute): Ditto.

  • svg/SVGSVGElement.cpp:

(WebCore::SVGSVGElement::parseAttribute): Ditto.

  • svg/SVGScriptElement.cpp:

(WebCore::SVGScriptElement::parseAttribute): Ditto.

  • inspector/InspectorDOMAgent.cpp:

(WebCore::InspectorDOMAgent::buildObjectForEventListener):
Moved the code here to dig inside a JSEventListener for things like
the source location. This used to be spread across multiple function
calls in ScriptEventListener.h, which were doing and redoing the same
things, so better to just get it all at once.

  • html/parser/XSSAuditor.cpp:

(WebCore::XSSAuditor::init): Fixed "minium" typo.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/html/HTMLFrameSetElement.cpp

    r156147 r156231  
    3838#include "MouseEvent.h"
    3939#include "RenderFrameSet.h"
    40 #include "ScriptEventListener.h"
    4140#include "Text.h"
    4241
     
    115114        m_borderColorSet = !value.isEmpty();
    116115    else if (name == onloadAttr)
    117         document().setWindowAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(document().frame(), name, value));
     116        document().setWindowAttributeEventListener(eventNames().loadEvent, name, value);
    118117    else if (name == onbeforeunloadAttr)
    119         document().setWindowAttributeEventListener(eventNames().beforeunloadEvent, createAttributeEventListener(document().frame(), name, value));
     118        document().setWindowAttributeEventListener(eventNames().beforeunloadEvent, name, value);
    120119    else if (name == onunloadAttr)
    121         document().setWindowAttributeEventListener(eventNames().unloadEvent, createAttributeEventListener(document().frame(), name, value));
     120        document().setWindowAttributeEventListener(eventNames().unloadEvent, name, value);
    122121    else if (name == onblurAttr)
    123         document().setWindowAttributeEventListener(eventNames().blurEvent, createAttributeEventListener(document().frame(), name, value));
     122        document().setWindowAttributeEventListener(eventNames().blurEvent, name, value);
    124123    else if (name == onfocusAttr)
    125         document().setWindowAttributeEventListener(eventNames().focusEvent, createAttributeEventListener(document().frame(), name, value));
     124        document().setWindowAttributeEventListener(eventNames().focusEvent, name, value);
    126125    else if (name == onfocusinAttr)
    127         document().setWindowAttributeEventListener(eventNames().focusinEvent, createAttributeEventListener(document().frame(), name, value));
     126        document().setWindowAttributeEventListener(eventNames().focusinEvent, name, value);
    128127    else if (name == onfocusoutAttr)
    129         document().setWindowAttributeEventListener(eventNames().focusoutEvent, createAttributeEventListener(document().frame(), name, value));
     128        document().setWindowAttributeEventListener(eventNames().focusoutEvent, name, value);
    130129#if ENABLE(ORIENTATION_EVENTS)
    131130    else if (name == onorientationchangeAttr)
    132         document().setWindowAttributeEventListener(eventNames().orientationchangeEvent, createAttributeEventListener(document().frame(), name, value));
     131        document().setWindowAttributeEventListener(eventNames().orientationchangeEvent, name, value);
    133132#endif
    134133    else if (name == onhashchangeAttr)
    135         document().setWindowAttributeEventListener(eventNames().hashchangeEvent, createAttributeEventListener(document().frame(), name, value));
     134        document().setWindowAttributeEventListener(eventNames().hashchangeEvent, name, value);
    136135    else if (name == onresizeAttr)
    137         document().setWindowAttributeEventListener(eventNames().resizeEvent, createAttributeEventListener(document().frame(), name, value));
     136        document().setWindowAttributeEventListener(eventNames().resizeEvent, name, value);
    138137    else if (name == onscrollAttr)
    139         document().setWindowAttributeEventListener(eventNames().scrollEvent, createAttributeEventListener(document().frame(), name, value));
     138        document().setWindowAttributeEventListener(eventNames().scrollEvent, name, value);
    140139    else if (name == onstorageAttr)
    141         document().setWindowAttributeEventListener(eventNames().storageEvent, createAttributeEventListener(document().frame(), name, value));
     140        document().setWindowAttributeEventListener(eventNames().storageEvent, name, value);
    142141    else if (name == ononlineAttr)
    143         document().setWindowAttributeEventListener(eventNames().onlineEvent, createAttributeEventListener(document().frame(), name, value));
     142        document().setWindowAttributeEventListener(eventNames().onlineEvent, name, value);
    144143    else if (name == onofflineAttr)
    145         document().setWindowAttributeEventListener(eventNames().offlineEvent, createAttributeEventListener(document().frame(), name, value));
     144        document().setWindowAttributeEventListener(eventNames().offlineEvent, name, value);
    146145    else if (name == onpopstateAttr)
    147         document().setWindowAttributeEventListener(eventNames().popstateEvent, createAttributeEventListener(document().frame(), name, value));
     146        document().setWindowAttributeEventListener(eventNames().popstateEvent, name, value);
    148147    else
    149148        HTMLElement::parseAttribute(name, value);
Note: See TracChangeset for help on using the changeset viewer.