OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "CSSStyleRule.h" | 32 #include "CSSStyleRule.h" |
33 #include "CSSStyleSelector.h" | 33 #include "CSSStyleSelector.h" |
34 #include "CSSStyleSheet.h" | 34 #include "CSSStyleSheet.h" |
35 #include "CString.h" | 35 #include "CString.h" |
36 #include "ChildNodeList.h" | 36 #include "ChildNodeList.h" |
37 #include "ClassNodeList.h" | 37 #include "ClassNodeList.h" |
38 #include "DOMImplementation.h" | 38 #include "DOMImplementation.h" |
39 #include "Document.h" | 39 #include "Document.h" |
40 #include "DynamicNodeList.h" | 40 #include "DynamicNodeList.h" |
41 #include "Element.h" | 41 #include "Element.h" |
42 #include "Event.h" | |
43 #include "EventException.h" | |
44 #include "EventHandler.h" | |
45 #include "EventListener.h" | |
46 #include "EventNames.h" | |
47 #include "ExceptionCode.h" | 42 #include "ExceptionCode.h" |
48 #include "Frame.h" | 43 #include "Frame.h" |
49 #include "FrameView.h" | |
50 #include "HTMLNames.h" | 44 #include "HTMLNames.h" |
51 #include "JSDOMBinding.h" | 45 #include "JSDOMBinding.h" |
52 #include "KeyboardEvent.h" | |
53 #include "Logging.h" | 46 #include "Logging.h" |
54 #include "MouseEvent.h" | |
55 #include "MutationEvent.h" | |
56 #include "NameNodeList.h" | 47 #include "NameNodeList.h" |
57 #include "NamedAttrMap.h" | 48 #include "NamedAttrMap.h" |
58 #include "NodeRareData.h" | 49 #include "NodeRareData.h" |
59 #include "Page.h" | |
60 #include "PlatformMouseEvent.h" | |
61 #include "PlatformWheelEvent.h" | |
62 #include "ProcessingInstruction.h" | 50 #include "ProcessingInstruction.h" |
63 #include "ProgressEvent.h" | |
64 #include "RegisteredEventListener.h" | |
65 #include "RenderObject.h" | 51 #include "RenderObject.h" |
66 #include "ScriptController.h" | 52 #include "ScriptController.h" |
67 #include "SelectorNodeList.h" | 53 #include "SelectorNodeList.h" |
68 #include "StringBuilder.h" | 54 #include "StringBuilder.h" |
69 #include "TagNodeList.h" | 55 #include "TagNodeList.h" |
70 #include "Text.h" | 56 #include "Text.h" |
71 #include "TextEvent.h" | |
72 #include "UIEvent.h" | |
73 #include "UIEventWithKeyState.h" | |
74 #include "WebKitAnimationEvent.h" | |
75 #include "WebKitTransitionEvent.h" | |
76 #include "WheelEvent.h" | |
77 #include "XMLNames.h" | 57 #include "XMLNames.h" |
78 #include "htmlediting.h" | 58 #include "htmlediting.h" |
79 #include <wtf/HashSet.h> | |
80 #include <wtf/RefCountedLeakCounter.h> | 59 #include <wtf/RefCountedLeakCounter.h> |
81 | 60 |
82 #if ENABLE(DOM_STORAGE) | |
83 #include "StorageEvent.h" | |
84 #endif | |
85 | |
86 #if ENABLE(SVG) | |
87 #include "SVGElementInstance.h" | |
88 #include "SVGUseElement.h" | |
89 #endif | |
90 | |
91 #define DUMP_NODE_STATISTICS 0 | 61 #define DUMP_NODE_STATISTICS 0 |
92 | 62 |
93 using namespace std; | 63 using namespace std; |
94 | 64 |
95 namespace WebCore { | 65 namespace WebCore { |
96 | 66 |
97 using namespace HTMLNames; | 67 using namespace HTMLNames; |
98 | 68 |
99 static HashSet<Node*>* gNodesDispatchingSimulatedClicks = 0; | |
100 | |
101 bool Node::isSupported(const String& feature, const String& version) | 69 bool Node::isSupported(const String& feature, const String& version) |
102 { | 70 { |
103 return DOMImplementation::hasFeature(feature, version); | 71 return DOMImplementation::hasFeature(feature, version); |
104 } | 72 } |
105 | 73 |
106 #if DUMP_NODE_STATISTICS | 74 #if DUMP_NODE_STATISTICS |
107 static HashSet<Node*> liveNodeSet; | 75 static HashSet<Node*> liveNodeSet; |
108 #endif | 76 #endif |
109 | 77 |
110 void Node::dumpStatistics() | 78 void Node::dumpStatistics() |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 if (it != ignoreSet.end()) | 336 if (it != ignoreSet.end()) |
369 ignoreSet.remove(it); | 337 ignoreSet.remove(it); |
370 else | 338 else |
371 nodeCounter.decrement(); | 339 nodeCounter.decrement(); |
372 #endif | 340 #endif |
373 | 341 |
374 #if DUMP_NODE_STATISTICS | 342 #if DUMP_NODE_STATISTICS |
375 liveNodeSet.remove(this); | 343 liveNodeSet.remove(this); |
376 #endif | 344 #endif |
377 | 345 |
378 if (!eventListeners().isEmpty() && !inDocument()) | |
379 document()->unregisterDisconnectedNodeWithEventListeners(this); | |
380 | |
381 if (!hasRareData()) | 346 if (!hasRareData()) |
382 ASSERT(!NodeRareData::rareDataMap().contains(this)); | 347 ASSERT(!NodeRareData::rareDataMap().contains(this)); |
383 else { | 348 else { |
384 if (m_document && rareData()->nodeLists()) | 349 if (m_document && rareData()->nodeLists()) |
385 m_document->removeNodeListCache(); | 350 m_document->removeNodeListCache(); |
386 | 351 |
387 NodeRareData::NodeRareDataMap& dataMap = NodeRareData::rareDataMap(); | 352 NodeRareData::NodeRareDataMap& dataMap = NodeRareData::rareDataMap(); |
388 NodeRareData::NodeRareDataMap::iterator it = dataMap.find(this); | 353 NodeRareData::NodeRareDataMap::iterator it = dataMap.find(this); |
389 ASSERT(it != dataMap.end()); | 354 ASSERT(it != dataMap.end()); |
390 delete it->second; | 355 delete it->second; |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 if (m_inActiveChain) | 1069 if (m_inActiveChain) |
1105 doc->activeChainNodeDetached(this); | 1070 doc->activeChainNodeDetached(this); |
1106 | 1071 |
1107 m_active = false; | 1072 m_active = false; |
1108 m_hovered = false; | 1073 m_hovered = false; |
1109 m_inActiveChain = false; | 1074 m_inActiveChain = false; |
1110 m_attached = false; | 1075 m_attached = false; |
1111 m_inDetach = false; | 1076 m_inDetach = false; |
1112 } | 1077 } |
1113 | 1078 |
| 1079 void Node::insertedIntoDocument() |
| 1080 { |
| 1081 // Note: EventTargetNode::insertedIntoDocument does not call through here, s
o if you |
| 1082 // change this function, change that one as well. |
| 1083 setInDocument(true); |
| 1084 } |
| 1085 |
| 1086 void Node::removedFromDocument() |
| 1087 { |
| 1088 // Note: EventTargetNode::insertedIntoDocument does not call through here, s
o if you |
| 1089 // change this function, change that one as well. |
| 1090 setInDocument(false); |
| 1091 } |
| 1092 |
1114 Node *Node::previousEditable() const | 1093 Node *Node::previousEditable() const |
1115 { | 1094 { |
1116 Node *node = previousLeafNode(); | 1095 Node *node = previousLeafNode(); |
1117 while (node) { | 1096 while (node) { |
1118 if (node->isContentEditable()) | 1097 if (node->isContentEditable()) |
1119 return node; | 1098 return node; |
1120 node = node->previousLeafNode(); | 1099 node = node->previousLeafNode(); |
1121 } | 1100 } |
1122 return 0; | 1101 return 0; |
1123 } | 1102 } |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2128 | 2107 |
2129 ContainerNode* Node::eventParentNode() | 2108 ContainerNode* Node::eventParentNode() |
2130 { | 2109 { |
2131 Node* parent = parentNode(); | 2110 Node* parent = parentNode(); |
2132 ASSERT(!parent || parent->isContainerNode()); | 2111 ASSERT(!parent || parent->isContainerNode()); |
2133 return static_cast<ContainerNode*>(parent); | 2112 return static_cast<ContainerNode*>(parent); |
2134 } | 2113 } |
2135 | 2114 |
2136 // -------- | 2115 // -------- |
2137 | 2116 |
2138 ScriptExecutionContext* Node::scriptExecutionContext() const | |
2139 { | |
2140 return document(); | |
2141 } | |
2142 | |
2143 const RegisteredEventListenerVector& Node::eventListeners() const | |
2144 { | |
2145 if (hasRareData()) { | |
2146 if (RegisteredEventListenerVector* listeners = rareData()->listeners()) | |
2147 return *listeners; | |
2148 } | |
2149 static const RegisteredEventListenerVector* emptyListenersVector = new Regis
teredEventListenerVector; | |
2150 return *emptyListenersVector; | |
2151 } | |
2152 | |
2153 void Node::insertedIntoDocument() | |
2154 { | |
2155 if (!eventListeners().isEmpty()) | |
2156 document()->unregisterDisconnectedNodeWithEventListeners(this); | |
2157 | |
2158 setInDocument(true); | |
2159 } | |
2160 | |
2161 void Node::removedFromDocument() | |
2162 { | |
2163 if (!eventListeners().isEmpty()) | |
2164 document()->registerDisconnectedNodeWithEventListeners(this); | |
2165 | |
2166 setInDocument(false); | |
2167 } | |
2168 | |
2169 void Node::willMoveToNewOwnerDocument() | |
2170 { | |
2171 if (!eventListeners().isEmpty()) | |
2172 document()->unregisterDisconnectedNodeWithEventListeners(this); | |
2173 } | |
2174 | |
2175 void Node::didMoveToNewOwnerDocument() | |
2176 { | |
2177 if (!eventListeners().isEmpty()) | |
2178 document()->registerDisconnectedNodeWithEventListeners(this); | |
2179 } | |
2180 | |
2181 static inline void updateSVGElementInstancesAfterEventListenerChange(Node* refer
enceNode) | |
2182 { | |
2183 ASSERT(referenceNode); | |
2184 | |
2185 #if ENABLE(SVG) | |
2186 if (!referenceNode->isSVGElement()) | |
2187 return; | |
2188 | |
2189 // Elements living inside a <use> shadow tree, never cause any updates! | |
2190 if (referenceNode->shadowTreeRootNode()) | |
2191 return; | |
2192 | |
2193 // We're possibly (a child of) an element that is referenced by a <use> clie
nt | |
2194 // If an event listeners changes on a referenced element, update all instanc
es. | |
2195 for (Node* node = referenceNode; node; node = node->parentNode()) { | |
2196 if (!node->hasID() || !node->isSVGElement()) | |
2197 continue; | |
2198 | |
2199 SVGElementInstance::invalidateAllInstancesOfElement(static_cast<SVGEleme
nt*>(node)); | |
2200 break; | |
2201 } | |
2202 #endif | |
2203 } | |
2204 | |
2205 void Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe
ner> listener, bool useCapture) | |
2206 { | |
2207 Document* document = this->document(); | |
2208 if (!document->attached()) | |
2209 return; | |
2210 | |
2211 document->addListenerTypeIfNeeded(eventType); | |
2212 | |
2213 RegisteredEventListenerVector& listeners = ensureRareData()->ensureListeners
(); | |
2214 | |
2215 // Remove existing identical listener set with identical arguments. | |
2216 // The DOM2 spec says that "duplicate instances are discarded" in this case. | |
2217 removeEventListener(eventType, listener.get(), useCapture); | |
2218 | |
2219 // adding the first one | |
2220 if (listeners.isEmpty() && !inDocument()) | |
2221 document->registerDisconnectedNodeWithEventListeners(this); | |
2222 | |
2223 listeners.append(RegisteredEventListener::create(eventType, listener, useCap
ture)); | |
2224 updateSVGElementInstancesAfterEventListenerChange(this); | |
2225 } | |
2226 | |
2227 void Node::removeEventListener(const AtomicString& eventType, EventListener* lis
tener, bool useCapture) | |
2228 { | |
2229 if (!hasRareData()) | |
2230 return; | |
2231 | |
2232 RegisteredEventListenerVector* listeners = rareData()->listeners(); | |
2233 if (!listeners) | |
2234 return; | |
2235 | |
2236 size_t size = listeners->size(); | |
2237 for (size_t i = 0; i < size; ++i) { | |
2238 RegisteredEventListener& r = *listeners->at(i); | |
2239 if (r.eventType() == eventType && r.listener() == listener && r.useCaptu
re() == useCapture) { | |
2240 r.setRemoved(true); | |
2241 listeners->remove(i); | |
2242 | |
2243 // removed last | |
2244 if (listeners->isEmpty() && !inDocument()) | |
2245 document()->unregisterDisconnectedNodeWithEventListeners(this); | |
2246 | |
2247 updateSVGElementInstancesAfterEventListenerChange(this); | |
2248 return; | |
2249 } | |
2250 } | |
2251 } | |
2252 | |
2253 void Node::removeAllEventListenersSlowCase() | |
2254 { | |
2255 ASSERT(hasRareData()); | |
2256 | |
2257 RegisteredEventListenerVector* listeners = rareData()->listeners(); | |
2258 if (!listeners) | |
2259 return; | |
2260 | |
2261 size_t size = listeners->size(); | |
2262 for (size_t i = 0; i < size; ++i) | |
2263 listeners->at(i)->setRemoved(true); | |
2264 listeners->clear(); | |
2265 } | |
2266 | |
2267 void Node::handleLocalEvents(Event* event, bool useCapture) | |
2268 { | |
2269 if (disabled() && event->isMouseEvent()) | |
2270 return; | |
2271 | |
2272 RegisteredEventListenerVector listenersCopy = eventListeners(); | |
2273 size_t size = listenersCopy.size(); | |
2274 for (size_t i = 0; i < size; ++i) { | |
2275 const RegisteredEventListener& r = *listenersCopy[i]; | |
2276 if (r.eventType() == event->type() && r.useCapture() == useCapture && !r
.removed()) | |
2277 r.listener()->handleEvent(event, false); | |
2278 } | |
2279 } | |
2280 | |
2281 #if ENABLE(SVG) | |
2282 static inline SVGElementInstance* eventTargetAsSVGElementInstance(Node* referenc
eNode) | |
2283 { | |
2284 ASSERT(referenceNode); | |
2285 if (!referenceNode->isSVGElement()) | |
2286 return 0; | |
2287 | |
2288 // Spec: The event handling for the non-exposed tree works as if the referen
ced element had been textually included | |
2289 // as a deeply cloned child of the 'use' element, except that events are dis
patched to the SVGElementInstance objects | |
2290 for (Node* n = referenceNode; n; n = n->parentNode()) { | |
2291 if (!n->isShadowNode() || !n->isSVGElement()) | |
2292 continue; | |
2293 | |
2294 Node* shadowTreeParentElement = n->shadowParentNode(); | |
2295 ASSERT(shadowTreeParentElement->hasTagName(SVGNames::useTag)); | |
2296 | |
2297 if (SVGElementInstance* instance = static_cast<SVGUseElement*>(shadowTre
eParentElement)->instanceForShadowTreeElement(referenceNode)) | |
2298 return instance; | |
2299 } | |
2300 | |
2301 return 0; | |
2302 } | |
2303 #endif | |
2304 | |
2305 static inline EventTarget* eventTargetRespectingSVGTargetRules(Node* referenceNo
de) | |
2306 { | |
2307 ASSERT(referenceNode); | |
2308 | |
2309 #if ENABLE(SVG) | |
2310 if (SVGElementInstance* instance = eventTargetAsSVGElementInstance(reference
Node)) { | |
2311 ASSERT(instance->shadowTreeElement() == referenceNode); | |
2312 return instance; | |
2313 } | |
2314 #endif | |
2315 | |
2316 return referenceNode; | |
2317 } | |
2318 | |
2319 bool Node::dispatchEvent(PassRefPtr<Event> e, ExceptionCode& ec) | |
2320 { | |
2321 RefPtr<Event> evt(e); | |
2322 ASSERT(!eventDispatchForbidden()); | |
2323 if (!evt || evt->type().isEmpty()) { | |
2324 ec = EventException::UNSPECIFIED_EVENT_TYPE_ERR; | |
2325 return false; | |
2326 } | |
2327 | |
2328 evt->setTarget(eventTargetRespectingSVGTargetRules(this)); | |
2329 | |
2330 RefPtr<FrameView> view = document()->view(); | |
2331 return dispatchGenericEvent(evt.release()); | |
2332 } | |
2333 | |
2334 bool Node::dispatchGenericEvent(PassRefPtr<Event> prpEvent) | |
2335 { | |
2336 RefPtr<Event> event(prpEvent); | |
2337 | |
2338 ASSERT(!eventDispatchForbidden()); | |
2339 ASSERT(event->target()); | |
2340 ASSERT(!event->type().isNull()); // JavaScript code can create an event with
an empty name, but not null. | |
2341 | |
2342 // Make a vector of ancestors to send the event to. | |
2343 // If the node is not in a document just send the event to it. | |
2344 // Be sure to ref all of nodes since event handlers could result in the last
reference going away. | |
2345 RefPtr<Node> thisNode(this); | |
2346 Vector<RefPtr<ContainerNode> > ancestors; | |
2347 if (inDocument()) { | |
2348 for (ContainerNode* ancestor = eventParentNode(); ancestor; ancestor = a
ncestor->eventParentNode()) { | |
2349 #if ENABLE(SVG) | |
2350 // Skip <use> shadow tree elements. | |
2351 if (ancestor->isSVGElement() && ancestor->isShadowNode()) | |
2352 continue; | |
2353 #endif | |
2354 ancestors.append(ancestor); | |
2355 } | |
2356 } | |
2357 | |
2358 // Set up a pointer to indicate whether to dispatch window events. | |
2359 // We don't dispatch load events to the window. That quirk was originally | |
2360 // added because Mozilla doesn't propagate load events to the window object. | |
2361 Document* documentForWindowEvents = 0; | |
2362 if (event->type() != eventNames().loadEvent) { | |
2363 Node* topLevelContainer = ancestors.isEmpty() ? this : ancestors.last().
get(); | |
2364 if (topLevelContainer->isDocumentNode()) | |
2365 documentForWindowEvents = static_cast<Document*>(topLevelContainer); | |
2366 } | |
2367 | |
2368 // Give the target node a chance to do some work before DOM event handlers g
et a crack. | |
2369 void* data = preDispatchEventHandler(event.get()); | |
2370 if (event->propagationStopped()) | |
2371 goto doneDispatching; | |
2372 | |
2373 // Trigger capturing event handlers, starting at the top and working our way
down. | |
2374 event->setEventPhase(Event::CAPTURING_PHASE); | |
2375 | |
2376 if (documentForWindowEvents) { | |
2377 event->setCurrentTarget(documentForWindowEvents); | |
2378 documentForWindowEvents->handleWindowEvent(event.get(), true); | |
2379 if (event->propagationStopped()) | |
2380 goto doneDispatching; | |
2381 } | |
2382 for (size_t i = ancestors.size(); i; --i) { | |
2383 ContainerNode* ancestor = ancestors[i - 1].get(); | |
2384 event->setCurrentTarget(eventTargetRespectingSVGTargetRules(ancestor)); | |
2385 ancestor->handleLocalEvents(event.get(), true); | |
2386 if (event->propagationStopped()) | |
2387 goto doneDispatching; | |
2388 } | |
2389 | |
2390 event->setEventPhase(Event::AT_TARGET); | |
2391 | |
2392 // We do want capturing event listeners to be invoked here, even though | |
2393 // that violates some versions of the DOM specification; Mozilla does it. | |
2394 event->setCurrentTarget(eventTargetRespectingSVGTargetRules(this)); | |
2395 handleLocalEvents(event.get(), true); | |
2396 if (event->propagationStopped()) | |
2397 goto doneDispatching; | |
2398 handleLocalEvents(event.get(), false); | |
2399 if (event->propagationStopped()) | |
2400 goto doneDispatching; | |
2401 | |
2402 if (event->bubbles() && !event->cancelBubble()) { | |
2403 // Trigger bubbling event handlers, starting at the bottom and working o
ur way up. | |
2404 event->setEventPhase(Event::BUBBLING_PHASE); | |
2405 | |
2406 size_t size = ancestors.size(); | |
2407 for (size_t i = 0; i < size; ++i) { | |
2408 ContainerNode* ancestor = ancestors[i].get(); | |
2409 event->setCurrentTarget(eventTargetRespectingSVGTargetRules(ancestor
)); | |
2410 ancestor->handleLocalEvents(event.get(), false); | |
2411 if (event->propagationStopped() || event->cancelBubble()) | |
2412 goto doneDispatching; | |
2413 } | |
2414 if (documentForWindowEvents) { | |
2415 event->setCurrentTarget(documentForWindowEvents); | |
2416 documentForWindowEvents->handleWindowEvent(event.get(), false); | |
2417 if (event->propagationStopped() || event->cancelBubble()) | |
2418 goto doneDispatching; | |
2419 } | |
2420 } | |
2421 | |
2422 doneDispatching: | |
2423 event->setCurrentTarget(0); | |
2424 event->setEventPhase(0); | |
2425 | |
2426 // Pass the data from the preDispatchEventHandler to the postDispatchEventHa
ndler. | |
2427 postDispatchEventHandler(event.get(), data); | |
2428 | |
2429 // Call default event handlers. While the DOM does have a concept of prevent
ing | |
2430 // default handling, the detail of which handlers are called is an internal | |
2431 // implementation detail and not part of the DOM. | |
2432 if (!event->defaultPrevented() && !event->defaultHandled()) { | |
2433 // Non-bubbling events call only one default event handler, the one for
the target. | |
2434 defaultEventHandler(event.get()); | |
2435 ASSERT(!event->defaultPrevented()); | |
2436 if (event->defaultHandled()) | |
2437 goto doneWithDefault; | |
2438 // For bubbling events, call default event handlers on the same targets
in the | |
2439 // same order as the bubbling phase. | |
2440 if (event->bubbles()) { | |
2441 size_t size = ancestors.size(); | |
2442 for (size_t i = 0; i < size; ++i) { | |
2443 ContainerNode* ancestor = ancestors[i].get(); | |
2444 ancestor->defaultEventHandler(event.get()); | |
2445 ASSERT(!event->defaultPrevented()); | |
2446 if (event->defaultHandled()) | |
2447 goto doneWithDefault; | |
2448 } | |
2449 } | |
2450 } | |
2451 | |
2452 doneWithDefault: | |
2453 Document::updateDocumentsRendering(); | |
2454 | |
2455 return !event->defaultPrevented(); | |
2456 } | |
2457 | |
2458 bool Node::dispatchSubtreeModifiedEvent() | |
2459 { | |
2460 ASSERT(!eventDispatchForbidden()); | |
2461 | |
2462 document()->incDOMTreeVersion(); | |
2463 | |
2464 notifyNodeListsAttributeChanged(); // FIXME: Can do better some day. Really
only care about the name attribute changing. | |
2465 | |
2466 if (!document()->hasListenerType(Document::DOMSUBTREEMODIFIED_LISTENER)) | |
2467 return false; | |
2468 ExceptionCode ec = 0; | |
2469 return dispatchEvent(MutationEvent::create(eventNames().DOMSubtreeModifiedEv
ent, true, false, 0, String(), String(), String(), 0), ec); | |
2470 } | |
2471 | |
2472 void Node::dispatchWindowEvent(PassRefPtr<Event> e) | |
2473 { | |
2474 ASSERT(!eventDispatchForbidden()); | |
2475 RefPtr<Event> evt(e); | |
2476 RefPtr<Document> doc = document(); | |
2477 evt->setTarget(doc); | |
2478 doc->handleWindowEvent(evt.get(), true); | |
2479 doc->handleWindowEvent(evt.get(), false); | |
2480 } | |
2481 | |
2482 void Node::dispatchWindowEvent(const AtomicString& eventType, bool canBubbleArg,
bool cancelableArg) | |
2483 { | |
2484 ASSERT(!eventDispatchForbidden()); | |
2485 RefPtr<Document> doc = document(); | |
2486 dispatchWindowEvent(Event::create(eventType, canBubbleArg, cancelableArg)); | |
2487 | |
2488 if (eventType == eventNames().loadEvent) { | |
2489 // For onload events, send a separate load event to the enclosing frame
only. | |
2490 // This is a DOM extension and is independent of bubbling/capturing rule
s of | |
2491 // the DOM. | |
2492 Element* ownerElement = doc->ownerElement(); | |
2493 if (ownerElement) { | |
2494 RefPtr<Event> ownerEvent = Event::create(eventType, false, cancelabl
eArg); | |
2495 ownerEvent->setTarget(ownerElement); | |
2496 ownerElement->dispatchGenericEvent(ownerEvent.release()); | |
2497 } | |
2498 } | |
2499 } | |
2500 | |
2501 bool Node::dispatchUIEvent(const AtomicString& eventType, int detail, PassRefPtr
<Event> underlyingEvent) | |
2502 { | |
2503 ASSERT(!eventDispatchForbidden()); | |
2504 ASSERT(eventType == eventNames().DOMFocusInEvent || eventType == eventNames(
).DOMFocusOutEvent || eventType == eventNames().DOMActivateEvent); | |
2505 | |
2506 bool cancelable = eventType == eventNames().DOMActivateEvent; | |
2507 | |
2508 ExceptionCode ec = 0; | |
2509 RefPtr<UIEvent> evt = UIEvent::create(eventType, true, cancelable, document(
)->defaultView(), detail); | |
2510 evt->setUnderlyingEvent(underlyingEvent); | |
2511 return dispatchEvent(evt.release(), ec); | |
2512 } | |
2513 | |
2514 bool Node::dispatchKeyEvent(const PlatformKeyboardEvent& key) | |
2515 { | |
2516 ASSERT(!eventDispatchForbidden()); | |
2517 ExceptionCode ec = 0; | |
2518 RefPtr<KeyboardEvent> keyboardEvent = KeyboardEvent::create(key, document()-
>defaultView()); | |
2519 bool r = dispatchEvent(keyboardEvent, ec); | |
2520 | |
2521 // we want to return false if default is prevented (already taken care of) | |
2522 // or if the element is default-handled by the DOM. Otherwise we let it just | |
2523 // let it get handled by AppKit | |
2524 if (keyboardEvent->defaultHandled()) | |
2525 r = false; | |
2526 | |
2527 return r; | |
2528 } | |
2529 | |
2530 bool Node::dispatchMouseEvent(const PlatformMouseEvent& event, const AtomicStrin
g& eventType, | |
2531 int detail, Node* relatedTarget) | |
2532 { | |
2533 ASSERT(!eventDispatchForbidden()); | |
2534 | |
2535 IntPoint contentsPos; | |
2536 if (FrameView* view = document()->view()) | |
2537 contentsPos = view->windowToContents(event.pos()); | |
2538 | |
2539 short button = event.button(); | |
2540 | |
2541 ASSERT(event.eventType() == MouseEventMoved || button != NoButton); | |
2542 | |
2543 return dispatchMouseEvent(eventType, button, detail, | |
2544 contentsPos.x(), contentsPos.y(), event.globalX(), event.globalY(), | |
2545 event.ctrlKey(), event.altKey(), event.shiftKey(), event.metaKey(), | |
2546 false, relatedTarget); | |
2547 } | |
2548 | |
2549 void Node::dispatchSimulatedMouseEvent(const AtomicString& eventType, | |
2550 PassRefPtr<Event> underlyingEvent) | |
2551 { | |
2552 ASSERT(!eventDispatchForbidden()); | |
2553 | |
2554 bool ctrlKey = false; | |
2555 bool altKey = false; | |
2556 bool shiftKey = false; | |
2557 bool metaKey = false; | |
2558 if (UIEventWithKeyState* keyStateEvent = findEventWithKeyState(underlyingEve
nt.get())) { | |
2559 ctrlKey = keyStateEvent->ctrlKey(); | |
2560 altKey = keyStateEvent->altKey(); | |
2561 shiftKey = keyStateEvent->shiftKey(); | |
2562 metaKey = keyStateEvent->metaKey(); | |
2563 } | |
2564 | |
2565 // Like Gecko, we just pass 0 for everything when we make a fake mouse event
. | |
2566 // Internet Explorer instead gives the current mouse position and state. | |
2567 dispatchMouseEvent(eventType, 0, 0, 0, 0, 0, 0, | |
2568 ctrlKey, altKey, shiftKey, metaKey, true, 0, underlyingEvent); | |
2569 } | |
2570 | |
2571 void Node::dispatchSimulatedClick(PassRefPtr<Event> event, bool sendMouseEvents,
bool showPressedLook) | |
2572 { | |
2573 if (!gNodesDispatchingSimulatedClicks) | |
2574 gNodesDispatchingSimulatedClicks = new HashSet<Node*>; | |
2575 else if (gNodesDispatchingSimulatedClicks->contains(this)) | |
2576 return; | |
2577 | |
2578 gNodesDispatchingSimulatedClicks->add(this); | |
2579 | |
2580 // send mousedown and mouseup before the click, if requested | |
2581 if (sendMouseEvents) | |
2582 dispatchSimulatedMouseEvent(eventNames().mousedownEvent, event.get()); | |
2583 setActive(true, showPressedLook); | |
2584 if (sendMouseEvents) | |
2585 dispatchSimulatedMouseEvent(eventNames().mouseupEvent, event.get()); | |
2586 setActive(false); | |
2587 | |
2588 // always send click | |
2589 dispatchSimulatedMouseEvent(eventNames().clickEvent, event); | |
2590 | |
2591 gNodesDispatchingSimulatedClicks->remove(this); | |
2592 } | |
2593 | |
2594 bool Node::dispatchMouseEvent(const AtomicString& eventType, int button, int det
ail, | |
2595 int pageX, int pageY, int screenX, int screenY, | |
2596 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, | |
2597 bool isSimulated, Node* relatedTargetArg, PassRefPtr<Event> underlyingEvent) | |
2598 { | |
2599 ASSERT(!eventDispatchForbidden()); | |
2600 if (disabled()) // Don't even send DOM events for disabled controls.. | |
2601 return true; | |
2602 | |
2603 if (eventType.isEmpty()) | |
2604 return false; // Shouldn't happen. | |
2605 | |
2606 // Dispatching the first event can easily result in this node being destroye
d. | |
2607 // Since we dispatch up to three events here, we need to make sure we're ref
erenced | |
2608 // so the pointer will be good for the two subsequent ones. | |
2609 RefPtr<Node> protect(this); | |
2610 | |
2611 bool cancelable = eventType != eventNames().mousemoveEvent; | |
2612 | |
2613 ExceptionCode ec = 0; | |
2614 | |
2615 bool swallowEvent = false; | |
2616 | |
2617 // Attempting to dispatch with a non-EventTarget relatedTarget causes the re
latedTarget to be silently ignored. | |
2618 RefPtr<Node> relatedTarget = relatedTargetArg; | |
2619 | |
2620 if (Frame* frame = document()->frame()) { | |
2621 float pageZoom = frame->pageZoomFactor(); | |
2622 if (pageZoom != 1.0f) { | |
2623 // Adjust our pageX and pageY to account for the page zoom. | |
2624 pageX = lroundf(pageX / pageZoom); | |
2625 pageY = lroundf(pageY / pageZoom); | |
2626 } | |
2627 } | |
2628 | |
2629 RefPtr<Event> mouseEvent = MouseEvent::create(eventType, | |
2630 true, cancelable, document()->defaultView(), | |
2631 detail, screenX, screenY, pageX, pageY, | |
2632 ctrlKey, altKey, shiftKey, metaKey, button, | |
2633 relatedTarget, 0, isSimulated); | |
2634 mouseEvent->setUnderlyingEvent(underlyingEvent.get()); | |
2635 | |
2636 dispatchEvent(mouseEvent, ec); | |
2637 bool defaultHandled = mouseEvent->defaultHandled(); | |
2638 bool defaultPrevented = mouseEvent->defaultPrevented(); | |
2639 if (defaultHandled || defaultPrevented) | |
2640 swallowEvent = true; | |
2641 | |
2642 // Special case: If it's a double click event, we also send the dblclick eve
nt. This is not part | |
2643 // of the DOM specs, but is used for compatibility with the ondblclick="" at
tribute. This is treated | |
2644 // as a separate event in other DOM-compliant browsers like Firefox, and so
we do the same. | |
2645 if (eventType == eventNames().clickEvent && detail == 2) { | |
2646 RefPtr<Event> doubleClickEvent = MouseEvent::create(eventNames().dblclic
kEvent, | |
2647 true, cancelable, document()->defaultView(), | |
2648 detail, screenX, screenY, pageX, pageY, | |
2649 ctrlKey, altKey, shiftKey, metaKey, button, | |
2650 relatedTarget, 0, isSimulated); | |
2651 doubleClickEvent->setUnderlyingEvent(underlyingEvent.get()); | |
2652 if (defaultHandled) | |
2653 doubleClickEvent->setDefaultHandled(); | |
2654 dispatchEvent(doubleClickEvent, ec); | |
2655 if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPreve
nted()) | |
2656 swallowEvent = true; | |
2657 } | |
2658 | |
2659 return swallowEvent; | |
2660 } | |
2661 | |
2662 void Node::dispatchWheelEvent(PlatformWheelEvent& e) | |
2663 { | |
2664 ASSERT(!eventDispatchForbidden()); | |
2665 if (e.deltaX() == 0 && e.deltaY() == 0) | |
2666 return; | |
2667 | |
2668 FrameView* view = document()->view(); | |
2669 if (!view) | |
2670 return; | |
2671 | |
2672 IntPoint pos = view->windowToContents(e.pos()); | |
2673 | |
2674 // Convert the deltas from pixels to lines if we have a pixel scroll event. | |
2675 float deltaX = e.deltaX(); | |
2676 float deltaY = e.deltaY(); | |
2677 | |
2678 // FIXME: Should we do anything with a ScrollByPageWheelEvent here? | |
2679 // It will be treated like a line scroll of 1 right now. | |
2680 if (e.granularity() == ScrollByPixelWheelEvent) { | |
2681 deltaX /= cMouseWheelPixelsPerLineStep; | |
2682 deltaY /= cMouseWheelPixelsPerLineStep; | |
2683 } | |
2684 | |
2685 RefPtr<WheelEvent> we = WheelEvent::create(e.deltaX(), e.deltaY(), | |
2686 document()->defaultView(), e.globalX(), e.globalY(), pos.x(), pos.y(), | |
2687 e.ctrlKey(), e.altKey(), e.shiftKey(), e.metaKey()); | |
2688 ExceptionCode ec = 0; | |
2689 if (!dispatchEvent(we.release(), ec)) | |
2690 e.accept(); | |
2691 } | |
2692 | |
2693 bool Node::dispatchWebKitAnimationEvent(const AtomicString& eventType, const Str
ing& animationName, double elapsedTime) | |
2694 { | |
2695 ASSERT(!eventDispatchForbidden()); | |
2696 | |
2697 ExceptionCode ec = 0; | |
2698 return dispatchEvent(WebKitAnimationEvent::create(eventType, animationName,
elapsedTime), ec); | |
2699 } | |
2700 | |
2701 bool Node::dispatchWebKitTransitionEvent(const AtomicString& eventType, const St
ring& propertyName, double elapsedTime) | |
2702 { | |
2703 ASSERT(!eventDispatchForbidden()); | |
2704 | |
2705 ExceptionCode ec = 0; | |
2706 return dispatchEvent(WebKitTransitionEvent::create(eventType, propertyName,
elapsedTime), ec); | |
2707 } | |
2708 | |
2709 void Node::dispatchFocusEvent() | |
2710 { | |
2711 dispatchEventForType(eventNames().focusEvent, false, false); | |
2712 } | |
2713 | |
2714 void Node::dispatchBlurEvent() | |
2715 { | |
2716 dispatchEventForType(eventNames().blurEvent, false, false); | |
2717 } | |
2718 | |
2719 bool Node::dispatchEventForType(const AtomicString& eventType, bool canBubbleArg
, bool cancelableArg) | |
2720 { | |
2721 ASSERT(!eventDispatchForbidden()); | |
2722 ExceptionCode ec = 0; | |
2723 return dispatchEvent(Event::create(eventType, canBubbleArg, cancelableArg),
ec); | |
2724 } | |
2725 | |
2726 bool Node::dispatchProgressEvent(const AtomicString &eventType, bool lengthCompu
tableArg, unsigned loadedArg, unsigned totalArg) | |
2727 { | |
2728 ASSERT(!eventDispatchForbidden()); | |
2729 ExceptionCode ec = 0; | |
2730 return dispatchEvent(ProgressEvent::create(eventType, lengthComputableArg, l
oadedArg, totalArg), ec); | |
2731 } | |
2732 | |
2733 void Node::dispatchStorageEvent(const AtomicString &eventType, const String& key
, const String& oldValue, const String& newValue, Frame* source) | |
2734 { | |
2735 #if ENABLE(DOM_STORAGE) | |
2736 ASSERT(!eventDispatchForbidden()); | |
2737 ExceptionCode ec = 0; | |
2738 dispatchEvent(StorageEvent::create(eventType, key, oldValue, newValue, sourc
e->document()->documentURI(), source->domWindow()), ec); | |
2739 #endif | |
2740 } | |
2741 | |
2742 void Node::removeInlineEventListenerForType(const AtomicString& eventType) | |
2743 { | |
2744 if (!hasRareData()) | |
2745 return; | |
2746 | |
2747 RegisteredEventListenerVector* listeners = rareData()->listeners(); | |
2748 if (!listeners) | |
2749 return; | |
2750 | |
2751 size_t size = listeners->size(); | |
2752 for (size_t i = 0; i < size; ++i) { | |
2753 RegisteredEventListener& r = *listeners->at(i); | |
2754 if (r.eventType() != eventType || !r.listener()->isInline()) | |
2755 continue; | |
2756 | |
2757 r.setRemoved(true); | |
2758 listeners->remove(i); | |
2759 | |
2760 // removed last | |
2761 if (listeners->isEmpty() && !inDocument()) | |
2762 document()->unregisterDisconnectedNodeWithEventListeners(this); | |
2763 | |
2764 updateSVGElementInstancesAfterEventListenerChange(this); | |
2765 return; | |
2766 } | |
2767 } | |
2768 | |
2769 void Node::setInlineEventListenerForType(const AtomicString& eventType, PassRefP
tr<EventListener> listener) | |
2770 { | |
2771 // In case we are the only one holding a reference to it, we don't want remo
veInlineEventListenerForType to destroy it. | |
2772 removeInlineEventListenerForType(eventType); | |
2773 if (listener) | |
2774 addEventListener(eventType, listener, false); | |
2775 } | |
2776 | |
2777 void Node::setInlineEventListenerForTypeAndAttribute(const AtomicString& eventTy
pe, Attribute* attr) | |
2778 { | |
2779 setInlineEventListenerForType(eventType, document()->createEventListener(att
r->localName().string(), attr->value(), this)); | |
2780 } | |
2781 | |
2782 EventListener* Node::inlineEventListenerForType(const AtomicString& eventType) c
onst | |
2783 { | |
2784 const RegisteredEventListenerVector& listeners = eventListeners(); | |
2785 size_t size = listeners.size(); | |
2786 for (size_t i = 0; i < size; ++i) { | |
2787 const RegisteredEventListener& r = *listeners[i]; | |
2788 if (r.eventType() == eventType && r.listener()->isInline()) | |
2789 return r.listener(); | |
2790 } | |
2791 return 0; | |
2792 } | |
2793 | |
2794 bool Node::disabled() const | |
2795 { | |
2796 return false; | |
2797 } | |
2798 | |
2799 void Node::defaultEventHandler(Event* event) | |
2800 { | |
2801 if (event->target() != this) | |
2802 return; | |
2803 const AtomicString& eventType = event->type(); | |
2804 if (eventType == eventNames().keydownEvent || eventType == eventNames().keyp
ressEvent) { | |
2805 if (event->isKeyboardEvent()) | |
2806 if (Frame* frame = document()->frame()) | |
2807 frame->eventHandler()->defaultKeyboardEventHandler(static_cast<K
eyboardEvent*>(event)); | |
2808 } else if (eventType == eventNames().clickEvent) { | |
2809 int detail = event->isUIEvent() ? static_cast<UIEvent*>(event)->detail()
: 0; | |
2810 dispatchUIEvent(eventNames().DOMActivateEvent, detail, event); | |
2811 } else if (eventType == eventNames().contextmenuEvent) { | |
2812 if (Frame* frame = document()->frame()) | |
2813 if (Page* page = frame->page()) | |
2814 page->contextMenuController()->handleContextMenuEvent(event); | |
2815 } else if (eventType == eventNames().textInputEvent) { | |
2816 if (event->isTextEvent()) | |
2817 if (Frame* frame = document()->frame()) | |
2818 frame->eventHandler()->defaultTextInputEventHandler(static_cast<
TextEvent*>(event)); | |
2819 } | |
2820 } | |
2821 | |
2822 EventListener* Node::onabort() const | |
2823 { | |
2824 return inlineEventListenerForType(eventNames().abortEvent); | |
2825 } | |
2826 | |
2827 void Node::setOnabort(PassRefPtr<EventListener> eventListener) | |
2828 { | |
2829 setInlineEventListenerForType(eventNames().abortEvent, eventListener); | |
2830 } | |
2831 | |
2832 EventListener* Node::onblur() const | |
2833 { | |
2834 return inlineEventListenerForType(eventNames().blurEvent); | |
2835 } | |
2836 | |
2837 void Node::setOnblur(PassRefPtr<EventListener> eventListener) | |
2838 { | |
2839 setInlineEventListenerForType(eventNames().blurEvent, eventListener); | |
2840 } | |
2841 | |
2842 EventListener* Node::onchange() const | |
2843 { | |
2844 return inlineEventListenerForType(eventNames().changeEvent); | |
2845 } | |
2846 | |
2847 void Node::setOnchange(PassRefPtr<EventListener> eventListener) | |
2848 { | |
2849 setInlineEventListenerForType(eventNames().changeEvent, eventListener); | |
2850 } | |
2851 | |
2852 EventListener* Node::onclick() const | |
2853 { | |
2854 return inlineEventListenerForType(eventNames().clickEvent); | |
2855 } | |
2856 | |
2857 void Node::setOnclick(PassRefPtr<EventListener> eventListener) | |
2858 { | |
2859 setInlineEventListenerForType(eventNames().clickEvent, eventListener); | |
2860 } | |
2861 | |
2862 EventListener* Node::oncontextmenu() const | |
2863 { | |
2864 return inlineEventListenerForType(eventNames().contextmenuEvent); | |
2865 } | |
2866 | |
2867 void Node::setOncontextmenu(PassRefPtr<EventListener> eventListener) | |
2868 { | |
2869 setInlineEventListenerForType(eventNames().contextmenuEvent, eventListener); | |
2870 } | |
2871 | |
2872 EventListener* Node::ondblclick() const | |
2873 { | |
2874 return inlineEventListenerForType(eventNames().dblclickEvent); | |
2875 } | |
2876 | |
2877 void Node::setOndblclick(PassRefPtr<EventListener> eventListener) | |
2878 { | |
2879 setInlineEventListenerForType(eventNames().dblclickEvent, eventListener); | |
2880 } | |
2881 | |
2882 EventListener* Node::onerror() const | |
2883 { | |
2884 return inlineEventListenerForType(eventNames().errorEvent); | |
2885 } | |
2886 | |
2887 void Node::setOnerror(PassRefPtr<EventListener> eventListener) | |
2888 { | |
2889 setInlineEventListenerForType(eventNames().errorEvent, eventListener); | |
2890 } | |
2891 | |
2892 EventListener* Node::onfocus() const | |
2893 { | |
2894 return inlineEventListenerForType(eventNames().focusEvent); | |
2895 } | |
2896 | |
2897 void Node::setOnfocus(PassRefPtr<EventListener> eventListener) | |
2898 { | |
2899 setInlineEventListenerForType(eventNames().focusEvent, eventListener); | |
2900 } | |
2901 | |
2902 EventListener* Node::oninput() const | |
2903 { | |
2904 return inlineEventListenerForType(eventNames().inputEvent); | |
2905 } | |
2906 | |
2907 void Node::setOninput(PassRefPtr<EventListener> eventListener) | |
2908 { | |
2909 setInlineEventListenerForType(eventNames().inputEvent, eventListener); | |
2910 } | |
2911 | |
2912 EventListener* Node::onkeydown() const | |
2913 { | |
2914 return inlineEventListenerForType(eventNames().keydownEvent); | |
2915 } | |
2916 | |
2917 void Node::setOnkeydown(PassRefPtr<EventListener> eventListener) | |
2918 { | |
2919 setInlineEventListenerForType(eventNames().keydownEvent, eventListener); | |
2920 } | |
2921 | |
2922 EventListener* Node::onkeypress() const | |
2923 { | |
2924 return inlineEventListenerForType(eventNames().keypressEvent); | |
2925 } | |
2926 | |
2927 void Node::setOnkeypress(PassRefPtr<EventListener> eventListener) | |
2928 { | |
2929 setInlineEventListenerForType(eventNames().keypressEvent, eventListener); | |
2930 } | |
2931 | |
2932 EventListener* Node::onkeyup() const | |
2933 { | |
2934 return inlineEventListenerForType(eventNames().keyupEvent); | |
2935 } | |
2936 | |
2937 void Node::setOnkeyup(PassRefPtr<EventListener> eventListener) | |
2938 { | |
2939 setInlineEventListenerForType(eventNames().keyupEvent, eventListener); | |
2940 } | |
2941 | |
2942 EventListener* Node::onload() const | |
2943 { | |
2944 return inlineEventListenerForType(eventNames().loadEvent); | |
2945 } | |
2946 | |
2947 void Node::setOnload(PassRefPtr<EventListener> eventListener) | |
2948 { | |
2949 setInlineEventListenerForType(eventNames().loadEvent, eventListener); | |
2950 } | |
2951 | |
2952 EventListener* Node::onmousedown() const | |
2953 { | |
2954 return inlineEventListenerForType(eventNames().mousedownEvent); | |
2955 } | |
2956 | |
2957 void Node::setOnmousedown(PassRefPtr<EventListener> eventListener) | |
2958 { | |
2959 setInlineEventListenerForType(eventNames().mousedownEvent, eventListener); | |
2960 } | |
2961 | |
2962 EventListener* Node::onmousemove() const | |
2963 { | |
2964 return inlineEventListenerForType(eventNames().mousemoveEvent); | |
2965 } | |
2966 | |
2967 void Node::setOnmousemove(PassRefPtr<EventListener> eventListener) | |
2968 { | |
2969 setInlineEventListenerForType(eventNames().mousemoveEvent, eventListener); | |
2970 } | |
2971 | |
2972 EventListener* Node::onmouseout() const | |
2973 { | |
2974 return inlineEventListenerForType(eventNames().mouseoutEvent); | |
2975 } | |
2976 | |
2977 void Node::setOnmouseout(PassRefPtr<EventListener> eventListener) | |
2978 { | |
2979 setInlineEventListenerForType(eventNames().mouseoutEvent, eventListener); | |
2980 } | |
2981 | |
2982 EventListener* Node::onmouseover() const | |
2983 { | |
2984 return inlineEventListenerForType(eventNames().mouseoverEvent); | |
2985 } | |
2986 | |
2987 void Node::setOnmouseover(PassRefPtr<EventListener> eventListener) | |
2988 { | |
2989 setInlineEventListenerForType(eventNames().mouseoverEvent, eventListener); | |
2990 } | |
2991 | |
2992 EventListener* Node::onmouseup() const | |
2993 { | |
2994 return inlineEventListenerForType(eventNames().mouseupEvent); | |
2995 } | |
2996 | |
2997 void Node::setOnmouseup(PassRefPtr<EventListener> eventListener) | |
2998 { | |
2999 setInlineEventListenerForType(eventNames().mouseupEvent, eventListener); | |
3000 } | |
3001 | |
3002 EventListener* Node::onmousewheel() const | |
3003 { | |
3004 return inlineEventListenerForType(eventNames().mousewheelEvent); | |
3005 } | |
3006 | |
3007 void Node::setOnmousewheel(PassRefPtr<EventListener> eventListener) | |
3008 { | |
3009 setInlineEventListenerForType(eventNames().mousewheelEvent, eventListener); | |
3010 } | |
3011 | |
3012 EventListener* Node::onbeforecut() const | |
3013 { | |
3014 return inlineEventListenerForType(eventNames().beforecutEvent); | |
3015 } | |
3016 | |
3017 void Node::setOnbeforecut(PassRefPtr<EventListener> eventListener) | |
3018 { | |
3019 setInlineEventListenerForType(eventNames().beforecutEvent, eventListener); | |
3020 } | |
3021 | |
3022 EventListener* Node::oncut() const | |
3023 { | |
3024 return inlineEventListenerForType(eventNames().cutEvent); | |
3025 } | |
3026 | |
3027 void Node::setOncut(PassRefPtr<EventListener> eventListener) | |
3028 { | |
3029 setInlineEventListenerForType(eventNames().cutEvent, eventListener); | |
3030 } | |
3031 | |
3032 EventListener* Node::onbeforecopy() const | |
3033 { | |
3034 return inlineEventListenerForType(eventNames().beforecopyEvent); | |
3035 } | |
3036 | |
3037 void Node::setOnbeforecopy(PassRefPtr<EventListener> eventListener) | |
3038 { | |
3039 setInlineEventListenerForType(eventNames().beforecopyEvent, eventListener); | |
3040 } | |
3041 | |
3042 EventListener* Node::oncopy() const | |
3043 { | |
3044 return inlineEventListenerForType(eventNames().copyEvent); | |
3045 } | |
3046 | |
3047 void Node::setOncopy(PassRefPtr<EventListener> eventListener) | |
3048 { | |
3049 setInlineEventListenerForType(eventNames().copyEvent, eventListener); | |
3050 } | |
3051 | |
3052 EventListener* Node::onbeforepaste() const | |
3053 { | |
3054 return inlineEventListenerForType(eventNames().beforepasteEvent); | |
3055 } | |
3056 | |
3057 void Node::setOnbeforepaste(PassRefPtr<EventListener> eventListener) | |
3058 { | |
3059 setInlineEventListenerForType(eventNames().beforepasteEvent, eventListener); | |
3060 } | |
3061 | |
3062 EventListener* Node::onpaste() const | |
3063 { | |
3064 return inlineEventListenerForType(eventNames().pasteEvent); | |
3065 } | |
3066 | |
3067 void Node::setOnpaste(PassRefPtr<EventListener> eventListener) | |
3068 { | |
3069 setInlineEventListenerForType(eventNames().pasteEvent, eventListener); | |
3070 } | |
3071 | |
3072 EventListener* Node::ondragenter() const | |
3073 { | |
3074 return inlineEventListenerForType(eventNames().dragenterEvent); | |
3075 } | |
3076 | |
3077 void Node::setOndragenter(PassRefPtr<EventListener> eventListener) | |
3078 { | |
3079 setInlineEventListenerForType(eventNames().dragenterEvent, eventListener); | |
3080 } | |
3081 | |
3082 EventListener* Node::ondragover() const | |
3083 { | |
3084 return inlineEventListenerForType(eventNames().dragoverEvent); | |
3085 } | |
3086 | |
3087 void Node::setOndragover(PassRefPtr<EventListener> eventListener) | |
3088 { | |
3089 setInlineEventListenerForType(eventNames().dragoverEvent, eventListener); | |
3090 } | |
3091 | |
3092 EventListener* Node::ondragleave() const | |
3093 { | |
3094 return inlineEventListenerForType(eventNames().dragleaveEvent); | |
3095 } | |
3096 | |
3097 void Node::setOndragleave(PassRefPtr<EventListener> eventListener) | |
3098 { | |
3099 setInlineEventListenerForType(eventNames().dragleaveEvent, eventListener); | |
3100 } | |
3101 | |
3102 EventListener* Node::ondrop() const | |
3103 { | |
3104 return inlineEventListenerForType(eventNames().dropEvent); | |
3105 } | |
3106 | |
3107 void Node::setOndrop(PassRefPtr<EventListener> eventListener) | |
3108 { | |
3109 setInlineEventListenerForType(eventNames().dropEvent, eventListener); | |
3110 } | |
3111 | |
3112 EventListener* Node::ondragstart() const | |
3113 { | |
3114 return inlineEventListenerForType(eventNames().dragstartEvent); | |
3115 } | |
3116 | |
3117 void Node::setOndragstart(PassRefPtr<EventListener> eventListener) | |
3118 { | |
3119 setInlineEventListenerForType(eventNames().dragstartEvent, eventListener); | |
3120 } | |
3121 | |
3122 EventListener* Node::ondrag() const | |
3123 { | |
3124 return inlineEventListenerForType(eventNames().dragEvent); | |
3125 } | |
3126 | |
3127 void Node::setOndrag(PassRefPtr<EventListener> eventListener) | |
3128 { | |
3129 setInlineEventListenerForType(eventNames().dragEvent, eventListener); | |
3130 } | |
3131 | |
3132 EventListener* Node::ondragend() const | |
3133 { | |
3134 return inlineEventListenerForType(eventNames().dragendEvent); | |
3135 } | |
3136 | |
3137 void Node::setOndragend(PassRefPtr<EventListener> eventListener) | |
3138 { | |
3139 setInlineEventListenerForType(eventNames().dragendEvent, eventListener); | |
3140 } | |
3141 | |
3142 EventListener* Node::onreset() const | |
3143 { | |
3144 return inlineEventListenerForType(eventNames().resetEvent); | |
3145 } | |
3146 | |
3147 void Node::setOnreset(PassRefPtr<EventListener> eventListener) | |
3148 { | |
3149 setInlineEventListenerForType(eventNames().resetEvent, eventListener); | |
3150 } | |
3151 | |
3152 EventListener* Node::onresize() const | |
3153 { | |
3154 return inlineEventListenerForType(eventNames().resizeEvent); | |
3155 } | |
3156 | |
3157 void Node::setOnresize(PassRefPtr<EventListener> eventListener) | |
3158 { | |
3159 setInlineEventListenerForType(eventNames().resizeEvent, eventListener); | |
3160 } | |
3161 | |
3162 EventListener* Node::onscroll() const | |
3163 { | |
3164 return inlineEventListenerForType(eventNames().scrollEvent); | |
3165 } | |
3166 | |
3167 void Node::setOnscroll(PassRefPtr<EventListener> eventListener) | |
3168 { | |
3169 setInlineEventListenerForType(eventNames().scrollEvent, eventListener); | |
3170 } | |
3171 | |
3172 EventListener* Node::onsearch() const | |
3173 { | |
3174 return inlineEventListenerForType(eventNames().searchEvent); | |
3175 } | |
3176 | |
3177 void Node::setOnsearch(PassRefPtr<EventListener> eventListener) | |
3178 { | |
3179 setInlineEventListenerForType(eventNames().searchEvent, eventListener); | |
3180 } | |
3181 | |
3182 EventListener* Node::onselect() const | |
3183 { | |
3184 return inlineEventListenerForType(eventNames().selectEvent); | |
3185 } | |
3186 | |
3187 void Node::setOnselect(PassRefPtr<EventListener> eventListener) | |
3188 { | |
3189 setInlineEventListenerForType(eventNames().selectEvent, eventListener); | |
3190 } | |
3191 | |
3192 EventListener* Node::onselectstart() const | |
3193 { | |
3194 return inlineEventListenerForType(eventNames().selectstartEvent); | |
3195 } | |
3196 | |
3197 void Node::setOnselectstart(PassRefPtr<EventListener> eventListener) | |
3198 { | |
3199 setInlineEventListenerForType(eventNames().selectstartEvent, eventListener); | |
3200 } | |
3201 | |
3202 EventListener* Node::onsubmit() const | |
3203 { | |
3204 return inlineEventListenerForType(eventNames().submitEvent); | |
3205 } | |
3206 | |
3207 void Node::setOnsubmit(PassRefPtr<EventListener> eventListener) | |
3208 { | |
3209 setInlineEventListenerForType(eventNames().submitEvent, eventListener); | |
3210 } | |
3211 | |
3212 EventListener* Node::onunload() const | |
3213 { | |
3214 return inlineEventListenerForType(eventNames().unloadEvent); | |
3215 } | |
3216 | |
3217 void Node::setOnunload(PassRefPtr<EventListener> eventListener) | |
3218 { | |
3219 setInlineEventListenerForType(eventNames().unloadEvent, eventListener); | |
3220 } | |
3221 | |
3222 } // namespace WebCore | 2117 } // namespace WebCore |
3223 | 2118 |
3224 #ifndef NDEBUG | 2119 #ifndef NDEBUG |
3225 | 2120 |
3226 void showTree(const WebCore::Node* node) | 2121 void showTree(const WebCore::Node* node) |
3227 { | 2122 { |
3228 if (node) | 2123 if (node) |
3229 node->showTreeForThis(); | 2124 node->showTreeForThis(); |
3230 } | 2125 } |
3231 | 2126 |
3232 #endif | 2127 #endif |
3233 | 2128 |
OLD | NEW |