OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 { | 102 { |
103 return !m_listener.isEmpty(); | 103 return !m_listener.isEmpty(); |
104 } | 104 } |
105 | 105 |
106 void clearListenerObject() | 106 void clearListenerObject() |
107 { | 107 { |
108 m_listener.clear(); | 108 m_listener.clear(); |
109 } | 109 } |
110 | 110 |
111 virtual bool belongsToTheCurrentWorld() const OVERRIDE FINAL; | 111 virtual bool belongsToTheCurrentWorld() const OVERRIDE FINAL; |
112 DOMWrapperWorld& world() const { return *m_world; } | |
113 v8::Isolate* isolate() const { return m_isolate; } | 112 v8::Isolate* isolate() const { return m_isolate; } |
| 113 virtual DOMWrapperWorld& world() const { return scriptState()->world();
} |
| 114 ScriptState* scriptState() const |
| 115 { |
| 116 ASSERT(m_scriptState); |
| 117 return m_scriptState.get(); |
| 118 } |
| 119 void setScriptState(ScriptState* scriptState) { m_scriptState = scriptSt
ate; } |
114 | 120 |
115 protected: | 121 protected: |
116 V8AbstractEventListener(bool isAttribute, DOMWrapperWorld&, v8::Isolate*
); | 122 V8AbstractEventListener(bool isAttribute, ScriptState*); |
| 123 V8AbstractEventListener(bool isAttribute, v8::Isolate*); |
117 | 124 |
118 virtual void prepareListenerObject(ExecutionContext*) { } | 125 virtual void prepareListenerObject(ExecutionContext*) { } |
119 | 126 |
120 void setListenerObject(v8::Handle<v8::Object> listener); | 127 void setListenerObject(v8::Handle<v8::Object> listener); |
121 | 128 |
122 void invokeEventHandler(ExecutionContext*, Event*, v8::Local<v8::Value>
jsEvent); | 129 void invokeEventHandler(Event*, v8::Local<v8::Value> jsEvent); |
123 | 130 |
124 // Get the receiver object to use for event listener call. | 131 // Get the receiver object to use for event listener call. |
125 v8::Local<v8::Object> getReceiverObject(ExecutionContext*, Event*); | 132 v8::Local<v8::Object> getReceiverObject(Event*); |
126 | 133 |
127 private: | 134 private: |
128 // Implementation of EventListener function. | 135 // Implementation of EventListener function. |
129 virtual bool virtualisAttribute() const OVERRIDE { return m_isAttribute;
} | 136 virtual bool virtualisAttribute() const OVERRIDE { return m_isAttribute;
} |
130 | 137 |
131 virtual v8::Local<v8::Value> callListenerFunction(ExecutionContext*, v8:
:Handle<v8::Value> jsevent, Event*) = 0; | 138 virtual v8::Local<v8::Value> callListenerFunction(ExecutionContext*, v8:
:Handle<v8::Value> jsevent, Event*) = 0; |
132 | 139 |
133 virtual bool shouldPreventDefault(v8::Local<v8::Value> returnValue); | 140 virtual bool shouldPreventDefault(v8::Local<v8::Value> returnValue); |
134 | 141 |
135 static void setWeakCallback(const v8::WeakCallbackData<v8::Object, V8Abs
tractEventListener>&); | 142 static void setWeakCallback(const v8::WeakCallbackData<v8::Object, V8Abs
tractEventListener>&); |
136 | 143 |
137 ScopedPersistent<v8::Object> m_listener; | 144 ScopedPersistent<v8::Object> m_listener; |
138 | 145 |
139 // Indicates if this is an HTML type listener. | 146 // Indicates if this is an HTML type listener. |
140 bool m_isAttribute; | 147 bool m_isAttribute; |
141 | 148 |
142 RefPtr<DOMWrapperWorld> m_world; | 149 // For V8LazyEventListener, m_scriptState can be 0 until V8LazyEventList
ener is actually used. |
| 150 // m_scriptState is set lazily because V8LazyEventListener doesn't know
the associated frame |
| 151 // until the listener is actually used. |
| 152 RefPtr<ScriptState> m_scriptState; |
143 v8::Isolate* m_isolate; | 153 v8::Isolate* m_isolate; |
144 }; | 154 }; |
145 | 155 |
146 } // namespace WebCore | 156 } // namespace WebCore |
147 | 157 |
148 #endif // V8AbstractEventListener_h | 158 #endif // V8AbstractEventListener_h |
OLD | NEW |