Remove lots of machinery related to inline event handlers.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/671173006
This commit is contained in:
Elliott Sprehn 2014-10-23 15:41:57 -07:00
parent f01716ead2
commit c403da314c
36 changed files with 48 additions and 447 deletions

View File

@ -42,9 +42,8 @@
namespace blink {
V8AbstractEventListener::V8AbstractEventListener(bool isAttribute, ScriptState* scriptState)
: EventListener(JSEventListenerType)
, m_isAttribute(isAttribute)
V8AbstractEventListener::V8AbstractEventListener(ScriptState* scriptState)
: EventListener()
, m_scriptState(scriptState)
, m_isolate(scriptState->isolate())
{
@ -52,9 +51,8 @@ V8AbstractEventListener::V8AbstractEventListener(bool isAttribute, ScriptState*
InspectorCounters::incrementCounter(InspectorCounters::JSEventListenerCounter);
}
V8AbstractEventListener::V8AbstractEventListener(bool isAttribute, v8::Isolate* isolate)
: EventListener(JSEventListenerType)
, m_isAttribute(isAttribute)
V8AbstractEventListener::V8AbstractEventListener(v8::Isolate* isolate)
: EventListener()
, m_scriptState(nullptr)
, m_isolate(isolate)
{
@ -66,7 +64,7 @@ V8AbstractEventListener::~V8AbstractEventListener()
{
if (!m_listener.isEmpty()) {
v8::HandleScope scope(m_isolate);
V8EventListenerList::clearWrapper(m_listener.newLocal(isolate()), m_isAttribute, isolate());
V8EventListenerList::clearWrapper(m_listener.newLocal(isolate()), isolate());
}
if (isMainThread())
InspectorCounters::decrementCounter(InspectorCounters::JSEventListenerCounter);
@ -139,9 +137,6 @@ void V8AbstractEventListener::invokeEventHandler(Event* event, v8::Local<v8::Val
if (returnValue.IsEmpty())
return;
if (m_isAttribute && shouldPreventDefault(returnValue))
event->preventDefault();
}
bool V8AbstractEventListener::shouldPreventDefault(v8::Local<v8::Value> returnValue)
@ -164,11 +159,6 @@ v8::Local<v8::Object> V8AbstractEventListener::getReceiverObject(Event* event)
return v8::Local<v8::Object>::New(isolate(), v8::Handle<v8::Object>::Cast(value));
}
bool V8AbstractEventListener::belongsToTheCurrentWorld() const
{
return isolate()->InContext() && &world() == &DOMWrapperWorld::current(isolate());
}
void V8AbstractEventListener::setWeakCallback(const v8::WeakCallbackData<v8::Object, V8AbstractEventListener> &data)
{
data.GetParameter()->m_listener.clear();

View File

@ -56,9 +56,7 @@ public:
static const V8AbstractEventListener* cast(const EventListener* listener)
{
return listener->type() == JSEventListenerType
? static_cast<const V8AbstractEventListener*>(listener)
: 0;
return static_cast<const V8AbstractEventListener*>(listener);
}
static V8AbstractEventListener* cast(EventListener* listener)
@ -72,8 +70,6 @@ public:
virtual void handleEvent(ExecutionContext*, Event*) OVERRIDE;
virtual bool isLazy() const { return false; }
// Returns the listener object, either a function or an object.
v8::Local<v8::Object> getListenerObject(ExecutionContext* context)
{
@ -108,7 +104,6 @@ public:
m_listener.clear();
}
virtual bool belongsToTheCurrentWorld() const OVERRIDE FINAL;
v8::Isolate* isolate() const { return m_isolate; }
virtual DOMWrapperWorld& world() const { return scriptState()->world(); }
ScriptState* scriptState() const
@ -119,8 +114,8 @@ public:
void setScriptState(ScriptState* scriptState) { m_scriptState = scriptState; }
protected:
V8AbstractEventListener(bool isAttribute, ScriptState*);
V8AbstractEventListener(bool isAttribute, v8::Isolate*);
V8AbstractEventListener(ScriptState*);
V8AbstractEventListener(v8::Isolate*);
virtual void prepareListenerObject(ExecutionContext*) { }
@ -132,9 +127,6 @@ protected:
v8::Local<v8::Object> getReceiverObject(Event*);
private:
// Implementation of EventListener function.
virtual bool virtualisAttribute() const OVERRIDE { return m_isAttribute; }
virtual v8::Local<v8::Value> callListenerFunction(v8::Handle<v8::Value> jsevent, Event*) = 0;
virtual bool shouldPreventDefault(v8::Local<v8::Value> returnValue);
@ -142,13 +134,6 @@ private:
static void setWeakCallback(const v8::WeakCallbackData<v8::Object, V8AbstractEventListener>&);
ScopedPersistent<v8::Object> m_listener;
// Indicates if this is an HTML type listener.
bool m_isAttribute;
// For V8LazyEventListener, m_scriptState can be 0 until V8LazyEventListener is actually used.
// m_scriptState is set lazily because V8LazyEventListener doesn't know the associated frame
// until the listener is actually used.
RefPtr<ScriptState> m_scriptState;
v8::Isolate* m_isolate;
};

View File

@ -42,8 +42,8 @@
namespace blink {
V8ErrorHandler::V8ErrorHandler(v8::Local<v8::Object> listener, bool isInline, ScriptState* scriptState)
: V8EventListener(listener, isInline, scriptState)
V8ErrorHandler::V8ErrorHandler(v8::Local<v8::Object> listener, ScriptState* scriptState)
: V8EventListener(listener, scriptState)
{
}

View File

@ -42,15 +42,15 @@ class LocalFrame;
class V8ErrorHandler FINAL : public V8EventListener {
public:
static PassRefPtr<V8ErrorHandler> create(v8::Local<v8::Object> listener, bool isInline, ScriptState* scriptState)
static PassRefPtr<V8ErrorHandler> create(v8::Local<v8::Object> listener, ScriptState* scriptState)
{
return adoptRef(new V8ErrorHandler(listener, isInline, scriptState));
return adoptRef(new V8ErrorHandler(listener, scriptState));
}
static void storeExceptionOnErrorEventWrapper(ErrorEvent*, v8::Handle<v8::Value>, v8::Handle<v8::Object> creationContext, v8::Isolate*);
private:
V8ErrorHandler(v8::Local<v8::Object> listener, bool isInline, ScriptState*);
V8ErrorHandler(v8::Local<v8::Object> listener, ScriptState*);
virtual v8::Local<v8::Value> callListenerFunction(v8::Handle<v8::Value> jsEvent, Event*) OVERRIDE;
virtual bool shouldPreventDefault(v8::Local<v8::Value> returnValue) OVERRIDE;

View File

@ -38,8 +38,8 @@
namespace blink {
V8EventListener::V8EventListener(v8::Local<v8::Object> listener, bool isAttribute, ScriptState* scriptState)
: V8AbstractEventListener(isAttribute, scriptState)
V8EventListener::V8EventListener(v8::Local<v8::Object> listener, ScriptState* scriptState)
: V8AbstractEventListener(scriptState)
{
setListenerObject(listener);
}
@ -56,7 +56,6 @@ v8::Local<v8::Function> V8EventListener::getListenerFunction(ExecutionContext*)
return v8::Local<v8::Function>::Cast(listener);
if (listener->IsObject()) {
ASSERT_WITH_MESSAGE(!isAttribute(), "EventHandler attributes should only accept JS Functions as input.");
v8::Local<v8::Value> property = listener->Get(v8AtomicString(isolate(), "handleEvent"));
// Check that no exceptions were thrown when getting the
// handleEvent property and that the value is a function.

View File

@ -44,13 +44,13 @@ class LocalFrame;
// that can handle the event.
class V8EventListener : public V8AbstractEventListener {
public:
static PassRefPtr<V8EventListener> create(v8::Local<v8::Object> listener, bool isAttribute, ScriptState* scriptState)
static PassRefPtr<V8EventListener> create(v8::Local<v8::Object> listener, ScriptState* scriptState)
{
return adoptRef(new V8EventListener(listener, isAttribute, scriptState));
return adoptRef(new V8EventListener(listener, scriptState));
}
protected:
V8EventListener(v8::Local<v8::Object> listener, bool isAttribute, ScriptState*);
V8EventListener(v8::Local<v8::Object> listener, ScriptState*);
v8::Local<v8::Function> getListenerFunction(ExecutionContext*);

View File

@ -36,18 +36,17 @@
namespace blink {
PassRefPtr<EventListener> V8EventListenerList::getEventListener(ScriptState* scriptState, v8::Local<v8::Value> value, bool isAttribute, ListenerLookupType lookup)
PassRefPtr<EventListener> V8EventListenerList::getEventListener(ScriptState* scriptState, v8::Local<v8::Value> value, ListenerLookupType lookup)
{
ASSERT(!scriptState->contextIsEmpty());
if (lookup == ListenerFindOnly) {
// Used by EventTarget::removeEventListener, specifically
// EventTargetV8Internal::removeEventListenerMethod
ASSERT(!isAttribute);
return V8EventListenerList::findWrapper(value, scriptState);
}
if (toDOMWindow(scriptState->context()))
return V8EventListenerList::findOrCreateWrapper<V8EventListener>(value, isAttribute, scriptState);
return V8EventListenerList::findOrCreateWrapper<V8EventListener>(value, scriptState);
ASSERT_NOT_REACHED();
return nullptr;

View File

@ -53,20 +53,20 @@ public:
if (!value->IsObject())
return nullptr;
v8::Handle<v8::String> wrapperProperty = getHiddenProperty(false, scriptState->isolate());
v8::Handle<v8::String> wrapperProperty = getHiddenProperty(scriptState->isolate());
return doFindWrapper(v8::Local<v8::Object>::Cast(value), wrapperProperty, scriptState);
}
template<typename WrapperType>
static PassRefPtr<V8EventListener> findOrCreateWrapper(v8::Local<v8::Value>, bool isAttribute, ScriptState*);
static PassRefPtr<V8EventListener> findOrCreateWrapper(v8::Local<v8::Value>, ScriptState*);
static void clearWrapper(v8::Handle<v8::Object> listenerObject, bool isAttribute, v8::Isolate* isolate)
static void clearWrapper(v8::Handle<v8::Object> listenerObject, v8::Isolate* isolate)
{
v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isAttribute, isolate);
v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isolate);
listenerObject->DeleteHiddenValue(wrapperProperty);
}
static PassRefPtr<EventListener> getEventListener(ScriptState*, v8::Local<v8::Value>, bool isAttribute, ListenerLookupType);
static PassRefPtr<EventListener> getEventListener(ScriptState*, v8::Local<v8::Value>, ListenerLookupType);
private:
static V8EventListener* doFindWrapper(v8::Local<v8::Object> object, v8::Handle<v8::String> wrapperProperty, ScriptState* scriptState)
@ -79,30 +79,28 @@ private:
return static_cast<V8EventListener*>(v8::External::Cast(*listener)->Value());
}
static inline v8::Handle<v8::String> getHiddenProperty(bool isAttribute, v8::Isolate* isolate)
static inline v8::Handle<v8::String> getHiddenProperty(v8::Isolate* isolate)
{
return isAttribute ? v8AtomicString(isolate, "attributeListener") : v8AtomicString(isolate, "listener");
return v8AtomicString(isolate, "listener");
}
};
template<typename WrapperType>
PassRefPtr<V8EventListener> V8EventListenerList::findOrCreateWrapper(v8::Local<v8::Value> value, bool isAttribute, ScriptState* scriptState)
PassRefPtr<V8EventListener> V8EventListenerList::findOrCreateWrapper(v8::Local<v8::Value> value, ScriptState* scriptState)
{
v8::Isolate* isolate = scriptState->isolate();
ASSERT(isolate->InContext());
if (!value->IsObject()
// Non-callable attribute setter input is treated as null (no wrapper)
|| (isAttribute && !value->IsFunction()))
if (!value->IsObject())
return nullptr;
v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isAttribute, isolate);
v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isolate);
V8EventListener* wrapper = doFindWrapper(object, wrapperProperty, scriptState);
if (wrapper)
return wrapper;
RefPtr<V8EventListener> wrapperPtr = WrapperType::create(object, isAttribute, scriptState);
RefPtr<V8EventListener> wrapperPtr = WrapperType::create(object, scriptState);
if (wrapperPtr)
object->SetHiddenValue(wrapperProperty, v8::External::New(isolate, wrapperPtr.get()));

View File

@ -62,8 +62,6 @@ static void addReferencesForNodeWithEventListeners(v8::Isolate* isolate, Node* n
EventListenerIterator iterator(node);
while (EventListener* listener = iterator.nextListener()) {
if (listener->type() != EventListener::JSEventListenerType)
continue;
V8AbstractEventListener* v8listener = static_cast<V8AbstractEventListener*>(listener);
if (!v8listener->hasExistingListenerObject())
continue;

View File

@ -372,9 +372,9 @@ def setter_expression(interface, attribute, context):
if (interface.name in ['Window'] and
attribute.name == 'onerror'):
includes.add('bindings/core/v8/V8ErrorHandler.h')
arguments.append('V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(v8Value, true, ScriptState::current(info.GetIsolate()))')
arguments.append('V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(v8Value, ScriptState::current(info.GetIsolate()))')
else:
arguments.append('V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, true, ListenerFindOrCreate)')
arguments.append('V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), v8Value, ListenerFindOrCreate)')
elif idl_type.is_interface_type:
# FIXME: should be able to eliminate WTF::getPtr in most or all cases
arguments.append('WTF::getPtr(cppValue)')

View File

@ -135,9 +135,9 @@ if (info.Length() > {{argument.index}} && {% if argument.is_nullable %}!isUndefi
{# FIXME: remove EventListener special case #}
{% if argument.idl_type == 'EventListener' %}
{% if method.name == 'removeEventListener' or method.name == 'removeListener' %}
{{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), info[{{argument.index}}], false, ListenerFindOnly);
{{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), info[{{argument.index}}], ListenerFindOnly);
{% else %}{# method.name == 'addEventListener' #}
{{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), info[{{argument.index}}], false, ListenerFindOrCreate);
{{argument.name}} = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), info[{{argument.index}}], ListenerFindOrCreate);
{% endif %}{# method.name #}
{% else %}{# argument.idl_type == 'EventListener' #}
{# Callback functions must be functions:

View File

@ -34,7 +34,6 @@
readonly attribute DOMString implementsReadonlyStringAttribute;
attribute DOMString implementsStringAttribute;
attribute Node implementsNodeAttribute;
attribute EventHandler implementsEventHandlerAttribute;
void implementsVoidMethod();
[CallWith=ExecutionContext, RaisesException] TestInterfaceEmpty implementsComplexMethod(DOMString strArg, TestInterfaceEmpty testInterfaceEmptyArg);

View File

@ -31,7 +31,6 @@
interface TestInterfaceNode : Node {
attribute DOMString stringAttribute;
readonly attribute TestInterfaceEmpty readonlyTestInterfaceEmptyAttribute;
attribute EventHandler eventHandlerAttribute;
[PerWorldBindings] readonly attribute TestInterfaceEmpty perWorldBindingsReadonlyTestInterfaceEmptyAttribute;
[Reflect] attribute DOMString reflectStringAttribute;
[Reflect, URL] attribute DOMString reflectUrlStringAttribute;

View File

@ -150,8 +150,6 @@ interface TestObject {
// Static attributes
static attribute DOMString staticStringAttribute;
static attribute long staticLongAttribute;
// Exceptional type
attribute EventHandler eventHandlerAttribute;
// Extended attributes
[CachedAttribute=isValueDirty] attribute any cachedAttributeAnyAttribute;

View File

@ -91,8 +91,6 @@ public:
// remove this method.
bool finishedInternal() const { return m_finished; }
DEFINE_ATTRIBUTE_EVENT_LISTENER(finish);
virtual const AtomicString& interfaceName() const OVERRIDE;
virtual ExecutionContext* executionContext() const OVERRIDE;
virtual bool hasPendingActivity() const OVERRIDE;

View File

@ -46,5 +46,4 @@
[RuntimeEnabled=WebAnimationsAPI] void reverse();
void cancel();
[MeasureAs=AnimationPlayerFinishEvent] attribute EventHandler onfinish;
};

View File

@ -718,7 +718,6 @@ sky_core_files = [
"frame/DOMTimer.h",
"frame/DOMWindowBase64.cpp",
"frame/DOMWindowBase64.h",
"frame/DOMWindowEventHandlers.h",
"frame/DOMWindowLifecycleNotifier.cpp",
"frame/DOMWindowLifecycleNotifier.h",
"frame/DOMWindowLifecycleObserver.cpp",
@ -1393,7 +1392,6 @@ core_dependency_idl_files = get_path_info([
"dom/URLUtilsReadOnly.idl",
"events/EventListener.idl",
"frame/WindowBase64.idl",
"frame/WindowEventHandlers.idl",
"frame/WindowTimers.idl",
"html/canvas/CanvasPathMethods.idl",
"html/canvas/MouseEventHitRegion.idl",

View File

@ -70,10 +70,6 @@ class FontFaceSet FINAL : public RefCountedSupplement<Document, FontFaceSet>, pu
public:
virtual ~FontFaceSet();
DEFINE_ATTRIBUTE_EVENT_LISTENER(loading);
DEFINE_ATTRIBUTE_EVENT_LISTENER(loadingdone);
DEFINE_ATTRIBUTE_EVENT_LISTENER(loadingerror);
bool check(const String& font, const String& text, ExceptionState&);
ScriptPromise load(ScriptState*, const String& font, const String& text);
ScriptPromise ready(ScriptState*);

View File

@ -36,10 +36,6 @@ enum FontFaceSetLoadStatus { "loading", "loaded" };
NoInterfaceObject,
] interface FontFaceSet : EventTarget {
attribute EventHandler onloading;
attribute EventHandler onloadingdone;
attribute EventHandler onloadingerror;
[RaisesException] boolean check(DOMString font, optional DOMString text = null);
[CallWith=ScriptState] Promise load(DOMString font, optional DOMString text = null);
[MeasureAs=FontFaceSetReady, CallWith=ScriptState] Promise ready();

View File

@ -53,8 +53,6 @@ public:
String media() const;
bool matches();
DEFINE_ATTRIBUTE_EVENT_LISTENER(change);
// These two functions are provided for compatibility with JS code
// written before the change listener became a DOM event.
void addDeprecatedListener(PassRefPtr<EventListener>);

View File

@ -25,13 +25,4 @@
] interface MediaQueryList : EventTarget {
readonly attribute DOMString media;
readonly attribute boolean matches;
// Even though this interface is now an event target, these functions
// exist as aliases for addEventListener for backwards compatibility
// with older versions of this interface. See the note at
// http://dev.w3.org/csswg/cssom-view/#dom-mediaquerylist-removelistener
[ImplementedAs=addDeprecatedListener] void addListener([Default=Undefined] optional EventListener listener);
[ImplementedAs=removeDeprecatedListener]void removeListener([Default=Undefined] optional EventListener listener);
attribute EventHandler onchange;
};

View File

@ -2317,22 +2317,6 @@ void Document::didSplitTextNode(Text& oldNode)
// FIXME: This should update markers for spelling and grammar checking.
}
void Document::setWindowAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener)
{
LocalDOMWindow* domWindow = this->domWindow();
if (!domWindow)
return;
domWindow->setAttributeEventListener(eventType, listener);
}
EventListener* Document::getWindowAttributeEventListener(const AtomicString& eventType)
{
LocalDOMWindow* domWindow = this->domWindow();
if (!domWindow)
return 0;
return domWindow->getAttributeEventListener(eventType);
}
EventQueue* Document::eventQueue() const
{
if (!m_domWindow)

View File

@ -203,23 +203,6 @@ public:
// DOM methods & attributes for Document
DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecopy);
DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecut);
DEFINE_ATTRIBUTE_EVENT_LISTENER(beforepaste);
DEFINE_ATTRIBUTE_EVENT_LISTENER(copy);
DEFINE_ATTRIBUTE_EVENT_LISTENER(cut);
DEFINE_ATTRIBUTE_EVENT_LISTENER(paste);
DEFINE_ATTRIBUTE_EVENT_LISTENER(readystatechange);
DEFINE_ATTRIBUTE_EVENT_LISTENER(search);
DEFINE_ATTRIBUTE_EVENT_LISTENER(securitypolicyviolation);
DEFINE_ATTRIBUTE_EVENT_LISTENER(selectionchange);
DEFINE_ATTRIBUTE_EVENT_LISTENER(selectstart);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart);
DEFINE_ATTRIBUTE_EVENT_LISTENER(wheel);
bool shouldOverrideLegacyDescription(ViewportDescription::Type);
void setViewportDescription(const ViewportDescription&);
const ViewportDescription& viewportDescription() const { return m_viewportDescription; }
@ -443,10 +426,6 @@ public:
void clearDOMWindow() { m_domWindow = nullptr; }
LocalDOMWindow* domWindow() const { return m_domWindow; }
// Helper functions for forwarding LocalDOMWindow event related tasks to the LocalDOMWindow if it exists.
void setWindowAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener>);
EventListener* getWindowAttributeEventListener(const AtomicString& eventType);
static void registerEventFactory(PassOwnPtr<EventFactoryBase>);
static PassRefPtrWillBeRawPtr<Event> createEvent(const String& eventType, ExceptionState&);

View File

@ -88,20 +88,6 @@ public:
static PassRefPtrWillBeRawPtr<Element> create(const QualifiedName&, Document*);
virtual ~Element();
DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecopy);
DEFINE_ATTRIBUTE_EVENT_LISTENER(beforecut);
DEFINE_ATTRIBUTE_EVENT_LISTENER(beforepaste);
DEFINE_ATTRIBUTE_EVENT_LISTENER(copy);
DEFINE_ATTRIBUTE_EVENT_LISTENER(cut);
DEFINE_ATTRIBUTE_EVENT_LISTENER(paste);
DEFINE_ATTRIBUTE_EVENT_LISTENER(search);
DEFINE_ATTRIBUTE_EVENT_LISTENER(selectstart);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart);
DEFINE_ATTRIBUTE_EVENT_LISTENER(wheel);
bool hasAttribute(const QualifiedName&) const;
const AtomicString& getAttribute(const QualifiedName&) const;

View File

@ -137,8 +137,7 @@ ReplacementFragment::ReplacementFragment(Document* document, DocumentFragment* f
else
shadowAncestorElement = editableRoot.get();
if (!editableRoot->getAttributeEventListener(EventTypeNames::webkitBeforeTextInserted)
&& editableRoot->rendererIsRichlyEditable()) {
if (editableRoot->rendererIsRichlyEditable()) {
removeInterchangeNodes(m_fragment.get());
return;
}

View File

@ -25,40 +25,20 @@
namespace blink {
class DOMWrapperWorld;
class Event;
class ExecutionContext;
class Event;
class ExecutionContext;
class EventListener : public RefCounted<EventListener> {
public:
enum Type {
JSEventListenerType,
ImageEventListenerType,
CPPEventListenerType,
ConditionEventListenerType,
NativeEventListenerType,
};
class EventListener : public RefCounted<EventListener> {
public:
virtual ~EventListener() { }
virtual bool operator==(const EventListener&) = 0;
virtual void handleEvent(ExecutionContext*, Event*) = 0;
virtual ~EventListener() { }
virtual bool operator==(const EventListener&) = 0;
virtual void handleEvent(ExecutionContext*, Event*) = 0;
virtual bool wasCreatedFromMarkup() const { return false; }
virtual bool belongsToTheCurrentWorld() const { return false; }
bool isAttribute() const { return virtualisAttribute(); }
Type type() const { return m_type; }
protected:
explicit EventListener(Type type)
: m_type(type)
{
}
private:
virtual bool virtualisAttribute() const { return false; }
Type m_type;
};
protected:
explicit EventListener()
{
}
};
}

View File

@ -169,53 +169,6 @@ EventListenerVector* EventListenerMap::find(const AtomicString& eventType)
return 0;
}
static void removeFirstListenerCreatedFromMarkup(EventListenerVector* listenerVector)
{
bool foundListener = false;
for (size_t i = 0; i < listenerVector->size(); ++i) {
if (!listenerVector->at(i).listener->wasCreatedFromMarkup())
continue;
foundListener = true;
listenerVector->remove(i);
break;
}
ASSERT_UNUSED(foundListener, foundListener);
}
void EventListenerMap::removeFirstEventListenerCreatedFromMarkup(const AtomicString& eventType)
{
assertNoActiveIterators();
for (unsigned i = 0; i < m_entries.size(); ++i) {
if (m_entries[i].first == eventType) {
removeFirstListenerCreatedFromMarkup(m_entries[i].second.get());
if (m_entries[i].second->isEmpty())
m_entries.remove(i);
return;
}
}
}
static void copyListenersNotCreatedFromMarkupToTarget(const AtomicString& eventType, EventListenerVector* listenerVector, EventTarget* target)
{
for (size_t i = 0; i < listenerVector->size(); ++i) {
// Event listeners created from markup have already been transfered to the shadow tree during cloning.
if ((*listenerVector)[i].listener->wasCreatedFromMarkup())
continue;
target->addEventListener(eventType, (*listenerVector)[i].listener, (*listenerVector)[i].useCapture);
}
}
void EventListenerMap::copyEventListenersNotCreatedFromMarkupToTarget(EventTarget* target)
{
assertNoActiveIterators();
for (unsigned i = 0; i < m_entries.size(); ++i)
copyListenersNotCreatedFromMarkupToTarget(m_entries[i].first, m_entries[i].second.get(), target);
}
EventListenerIterator::EventListenerIterator()
: m_map(0)
, m_entryIndex(0)

View File

@ -57,9 +57,6 @@ public:
EventListenerVector* find(const AtomicString& eventType);
Vector<AtomicString> eventTypes() const;
void removeFirstEventListenerCreatedFromMarkup(const AtomicString& eventType);
void copyEventListenersNotCreatedFromMarkupToTarget(EventTarget*);
private:
friend class EventListenerIterator;

View File

@ -123,33 +123,6 @@ bool EventTarget::removeEventListener(const AtomicString& eventType, PassRefPtr<
return true;
}
bool EventTarget::setAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener)
{
clearAttributeEventListener(eventType);
if (!listener)
return false;
return addEventListener(eventType, listener, false);
}
EventListener* EventTarget::getAttributeEventListener(const AtomicString& eventType)
{
const EventListenerVector& entry = getEventListeners(eventType);
for (size_t i = 0; i < entry.size(); ++i) {
EventListener* listener = entry[i].listener.get();
if (listener->isAttribute() && listener->belongsToTheCurrentWorld())
return listener;
}
return 0;
}
bool EventTarget::clearAttributeEventListener(const AtomicString& eventType)
{
EventListener* listener = getAttributeEventListener(eventType);
if (!listener)
return false;
return removeEventListener(eventType, listener, false);
}
bool EventTarget::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event, ExceptionState& exceptionState)
{
if (!event) {

View File

@ -71,7 +71,6 @@ public:
// This is the base class for all DOM event targets. To make your class an
// EventTarget, follow these steps:
// - Make your IDL interface inherit from EventTarget.
// Optionally add "attribute EventHandler onfoo;" attributes.
// - Inherit from EventTargetWithInlineData (only in rare cases should you use
// EventTarget directly).
// - Figure out if you now need to inherit from ActiveDOMObject as well.
@ -80,8 +79,6 @@ public:
// WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(YourClassName). Make sure to include
// this header file in your .h file, or you will get very strange compiler
// errors.
// - If you added an onfoo attribute, use DEFINE_ATTRIBUTE_EVENT_LISTENER(foo)
// in your class declaration.
// - Call ScriptWrappable::init(this) in your constructor, unless you are already
// doing so.
// - Override EventTarget::interfaceName() and executionContext(). The former
@ -120,10 +117,6 @@ public:
bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>, ExceptionState&); // DOM API
virtual void uncaughtExceptionInEventHandler();
// Used for legacy "onEvent" attribute APIs.
bool setAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener>);
EventListener* getAttributeEventListener(const AtomicString& eventType);
bool hasEventListeners() const;
bool hasEventListeners(const AtomicString& eventType) const;
bool hasCapturingEventListeners(const AtomicString& eventType);
@ -155,8 +148,6 @@ private:
void fireEventListeners(Event*, EventTargetData*, EventListenerVector&);
void countLegacyEvents(const AtomicString& legacyTypeName, EventListenerVector*, EventListenerVector*);
bool clearAttributeEventListener(const AtomicString& eventType);
friend class EventListenerIterator;
};
@ -168,52 +159,6 @@ private:
EventTargetData m_eventTargetData;
};
// FIXME: These macros should be split into separate DEFINE and DECLARE
// macros to avoid causing so many header includes.
#define DEFINE_ATTRIBUTE_EVENT_LISTENER(attribute) \
EventListener* on##attribute() { return getAttributeEventListener(EventTypeNames::attribute); } \
void setOn##attribute(PassRefPtr<EventListener> listener) { setAttributeEventListener(EventTypeNames::attribute, listener); } \
#define DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(attribute) \
static EventListener* on##attribute(EventTarget& eventTarget) { return eventTarget.getAttributeEventListener(EventTypeNames::attribute); } \
static void setOn##attribute(EventTarget& eventTarget, PassRefPtr<EventListener> listener) { eventTarget.setAttributeEventListener(EventTypeNames::attribute, listener); } \
#define DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(attribute) \
EventListener* on##attribute() { return document().getWindowAttributeEventListener(EventTypeNames::attribute); } \
void setOn##attribute(PassRefPtr<EventListener> listener) { document().setWindowAttributeEventListener(EventTypeNames::attribute, listener); } \
#define DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(attribute) \
static EventListener* on##attribute(EventTarget& eventTarget) { \
if (Node* node = eventTarget.toNode()) \
return node->document().getWindowAttributeEventListener(EventTypeNames::attribute); \
ASSERT(eventTarget.toDOMWindow()); \
return eventTarget.getAttributeEventListener(EventTypeNames::attribute); \
} \
static void setOn##attribute(EventTarget& eventTarget, PassRefPtr<EventListener> listener) { \
if (Node* node = eventTarget.toNode()) \
node->document().setWindowAttributeEventListener(EventTypeNames::attribute, listener); \
else { \
ASSERT(eventTarget.toDOMWindow()); \
eventTarget.setAttributeEventListener(EventTypeNames::attribute, listener); \
} \
}
#define DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(attribute, eventName) \
EventListener* on##attribute() { return getAttributeEventListener(EventTypeNames::eventName); } \
void setOn##attribute(PassRefPtr<EventListener> listener) { setAttributeEventListener(EventTypeNames::eventName, listener); } \
#define DECLARE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(recipient, attribute) \
EventListener* on##attribute(); \
void setOn##attribute(PassRefPtr<EventListener> listener);
#define DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(type, recipient, attribute) \
EventListener* type::on##attribute() { return recipient ? recipient->getAttributeEventListener(EventTypeNames::attribute) : 0; } \
void type::setOn##attribute(PassRefPtr<EventListener> listener) \
{ \
if (recipient) \
recipient->setAttributeEventListener(EventTypeNames::attribute, listener); \
}
inline bool EventTarget::hasEventListeners() const
{
// FIXME: We should have a const version of eventTargetData.

View File

@ -1,52 +0,0 @@
/*
* Copyright (c) 2013, Opera Software ASA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Opera Software ASA nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef DOMWindowEventHandlers_h
#define DOMWindowEventHandlers_h
#include "core/events/EventTarget.h"
namespace blink {
namespace DOMWindowEventHandlers {
DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(hashchange);
DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(languagechange);
DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(message);
DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(offline);
DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(online);
DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(pagehide);
DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(pageshow);
DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(popstate);
DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(storage);
DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(unload);
}
} // namespace
#endif

View File

@ -194,24 +194,11 @@ public:
void dispatchLoadEvent();
DEFINE_ATTRIBUTE_EVENT_LISTENER(animationend);
DEFINE_ATTRIBUTE_EVENT_LISTENER(animationiteration);
DEFINE_ATTRIBUTE_EVENT_LISTENER(animationstart);
DEFINE_ATTRIBUTE_EVENT_LISTENER(search);
DEFINE_ATTRIBUTE_EVENT_LISTENER(transitionend);
DEFINE_ATTRIBUTE_EVENT_LISTENER(wheel);
// This is the interface orientation in degrees. Some examples are:
// 0 is straight up; -90 is when the device is rotated 90 clockwise;
// 90 is when rotated counter clockwise.
int orientation() const;
DEFINE_ATTRIBUTE_EVENT_LISTENER(orientationchange);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchstart);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchmove);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchend);
DEFINE_ATTRIBUTE_EVENT_LISTENER(touchcancel);
void willDetachDocumentFromFrame();
bool isInsecureScriptAccess(LocalDOMWindow& callingWindow, const String& urlString);

View File

@ -112,19 +112,6 @@
[Replaceable] readonly attribute CSS CSS;
// Event handler attributes
[RuntimeEnabled=CSSAnimationUnprefixed] attribute EventHandler onanimationend;
[RuntimeEnabled=CSSAnimationUnprefixed] attribute EventHandler onanimationiteration;
[RuntimeEnabled=CSSAnimationUnprefixed] attribute EventHandler onanimationstart;
[RuntimeEnabled=OrientationEvent] attribute EventHandler onorientationchange;
attribute EventHandler onsearch;
[RuntimeEnabled=Touch] attribute EventHandler ontouchcancel;
[RuntimeEnabled=Touch] attribute EventHandler ontouchend;
[RuntimeEnabled=Touch] attribute EventHandler ontouchmove;
[RuntimeEnabled=Touch] attribute EventHandler ontouchstart;
attribute EventHandler ontransitionend;
attribute EventHandler onwheel;
// window.toString() requires special handling in V8
[DoNotCheckSignature, DoNotCheckSecurity, Custom, NotEnumerable] stringifier;
@ -133,5 +120,4 @@
};
Window implements WindowBase64;
Window implements WindowEventHandlers;
Window implements WindowTimers;

View File

@ -1,49 +0,0 @@
/*
* Copyright (c) 2013, Opera Software ASA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Opera Software ASA nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#windoweventhandlers
[
ImplementedAs=DOMWindowEventHandlers,
LegacyTreatAsPartialInterface,
NoInterfaceObject, // Always used on target of 'implements'
] interface WindowEventHandlers {
//attribute EventHandler onafterprint;
//attribute EventHandler onbeforeprint;
attribute EventHandler onhashchange;
attribute EventHandler onlanguagechange;
attribute EventHandler onmessage;
attribute EventHandler onoffline;
attribute EventHandler ononline;
attribute EventHandler onpagehide;
attribute EventHandler onpageshow;
attribute EventHandler onpopstate;
attribute EventHandler onstorage;
attribute EventHandler onunload;
};

View File

@ -71,10 +71,6 @@ public:
virtual const AtomicString& interfaceName() const OVERRIDE;
virtual ExecutionContext* executionContext() const OVERRIDE;
DEFINE_ATTRIBUTE_EVENT_LISTENER(candidatewindowshow);
DEFINE_ATTRIBUTE_EVENT_LISTENER(candidatewindowupdate);
DEFINE_ATTRIBUTE_EVENT_LISTENER(candidatewindowhide);
void dispatchCandidateWindowShowEvent();
void dispatchCandidateWindowUpdateEvent();
void dispatchCandidateWindowHideEvent();

View File

@ -36,8 +36,4 @@ interface InputMethodContext : EventTarget {
readonly attribute unsigned long compositionEndOffset;
void confirmComposition();
attribute EventHandler oncandidatewindowshow;
attribute EventHandler oncandidatewindowupdate;
attribute EventHandler oncandidatewindowhide;
};