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, 2010, 2011 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "core/dom/ChildListMutationScope.h" | 35 #include "core/dom/ChildListMutationScope.h" |
36 #include "core/dom/ChildNodeList.h" | 36 #include "core/dom/ChildNodeList.h" |
37 #include "core/dom/DOMImplementation.h" | 37 #include "core/dom/DOMImplementation.h" |
38 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
39 #include "core/dom/DocumentFragment.h" | 39 #include "core/dom/DocumentFragment.h" |
40 #include "core/dom/DocumentMarkerController.h" | 40 #include "core/dom/DocumentMarkerController.h" |
41 #include "core/dom/DocumentType.h" | 41 #include "core/dom/DocumentType.h" |
42 #include "core/dom/Element.h" | 42 #include "core/dom/Element.h" |
43 #include "core/dom/ElementRareData.h" | 43 #include "core/dom/ElementRareData.h" |
44 #include "core/dom/ElementTraversal.h" | 44 #include "core/dom/ElementTraversal.h" |
| 45 #include "core/dom/EventHandlerRegistry.h" |
45 #include "core/dom/ExceptionCode.h" | 46 #include "core/dom/ExceptionCode.h" |
46 #include "core/dom/LiveNodeList.h" | 47 #include "core/dom/LiveNodeList.h" |
47 #include "core/dom/NodeRareData.h" | 48 #include "core/dom/NodeRareData.h" |
48 #include "core/dom/NodeRenderingTraversal.h" | 49 #include "core/dom/NodeRenderingTraversal.h" |
49 #include "core/dom/NodeTraversal.h" | 50 #include "core/dom/NodeTraversal.h" |
50 #include "core/dom/ProcessingInstruction.h" | 51 #include "core/dom/ProcessingInstruction.h" |
51 #include "core/dom/Range.h" | 52 #include "core/dom/Range.h" |
52 #include "core/dom/StaticNodeList.h" | 53 #include "core/dom/StaticNodeList.h" |
53 #include "core/dom/TemplateContentDocumentFragment.h" | 54 #include "core/dom/TemplateContentDocumentFragment.h" |
54 #include "core/dom/Text.h" | 55 #include "core/dom/Text.h" |
55 #include "core/dom/TreeScopeAdopter.h" | 56 #include "core/dom/TreeScopeAdopter.h" |
56 #include "core/dom/UserActionElementSet.h" | 57 #include "core/dom/UserActionElementSet.h" |
57 #include "core/dom/WheelController.h" | |
58 #include "core/dom/shadow/ElementShadow.h" | 58 #include "core/dom/shadow/ElementShadow.h" |
59 #include "core/dom/shadow/InsertionPoint.h" | 59 #include "core/dom/shadow/InsertionPoint.h" |
60 #include "core/dom/shadow/ShadowRoot.h" | 60 #include "core/dom/shadow/ShadowRoot.h" |
61 #include "core/editing/htmlediting.h" | 61 #include "core/editing/htmlediting.h" |
62 #include "core/editing/markup.h" | 62 #include "core/editing/markup.h" |
63 #include "core/events/Event.h" | 63 #include "core/events/Event.h" |
64 #include "core/events/EventDispatchMediator.h" | 64 #include "core/events/EventDispatchMediator.h" |
65 #include "core/events/EventDispatcher.h" | 65 #include "core/events/EventDispatcher.h" |
66 #include "core/events/EventListener.h" | 66 #include "core/events/EventListener.h" |
67 #include "core/events/GestureEvent.h" | 67 #include "core/events/GestureEvent.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 281 |
282 void Node::willBeDeletedFromDocument() | 282 void Node::willBeDeletedFromDocument() |
283 { | 283 { |
284 if (!isTreeScopeInitialized()) | 284 if (!isTreeScopeInitialized()) |
285 return; | 285 return; |
286 | 286 |
287 Document& document = this->document(); | 287 Document& document = this->document(); |
288 | 288 |
289 if (hasEventTargetData()) { | 289 if (hasEventTargetData()) { |
290 clearEventTargetData(); | 290 clearEventTargetData(); |
291 document.didClearTouchEventHandlers(this); | 291 EventHandlerRegistry::from(document)->didRemoveAllEventHandlers(*this); |
292 } | 292 } |
293 | 293 |
294 if (AXObjectCache* cache = document.existingAXObjectCache()) | 294 if (AXObjectCache* cache = document.existingAXObjectCache()) |
295 cache->remove(this); | 295 cache->remove(this); |
296 | 296 |
297 document.markers().removeMarkers(this); | 297 document.markers().removeMarkers(this); |
298 } | 298 } |
299 | 299 |
300 NodeRareData* Node::rareData() const | 300 NodeRareData* Node::rareData() const |
301 { | 301 { |
(...skipping 1615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1917 for (unsigned i = 0; i < types.size(); ++i) | 1917 for (unsigned i = 0; i < types.size(); ++i) |
1918 document().addListenerTypeIfNeeded(types[i]); | 1918 document().addListenerTypeIfNeeded(types[i]); |
1919 } | 1919 } |
1920 } | 1920 } |
1921 | 1921 |
1922 if (AXObjectCache::accessibilityEnabled()) { | 1922 if (AXObjectCache::accessibilityEnabled()) { |
1923 if (AXObjectCache* cache = oldDocument.existingAXObjectCache()) | 1923 if (AXObjectCache* cache = oldDocument.existingAXObjectCache()) |
1924 cache->remove(this); | 1924 cache->remove(this); |
1925 } | 1925 } |
1926 | 1926 |
1927 const EventListenerVector& mousewheelListeners = getEventListeners(EventType
Names::mousewheel); | 1927 EventHandlerRegistry::from(document())->didMoveToNewDocument(*this, oldDocum
ent); |
1928 WheelController* oldController = WheelController::from(oldDocument); | |
1929 WheelController* newController = WheelController::from(document()); | |
1930 for (size_t i = 0; i < mousewheelListeners.size(); ++i) { | |
1931 oldController->didRemoveWheelEventHandler(oldDocument); | |
1932 newController->didAddWheelEventHandler(document()); | |
1933 } | |
1934 | |
1935 const EventListenerVector& wheelListeners = getEventListeners(EventTypeNames
::wheel); | |
1936 for (size_t i = 0; i < wheelListeners.size(); ++i) { | |
1937 oldController->didRemoveWheelEventHandler(oldDocument); | |
1938 newController->didAddWheelEventHandler(document()); | |
1939 } | |
1940 | |
1941 if (const TouchEventTargetSet* touchHandlers = oldDocument.touchEventTargets
()) { | |
1942 while (touchHandlers->contains(this)) { | |
1943 oldDocument.didRemoveTouchEventHandler(this); | |
1944 document().didAddTouchEventHandler(this); | |
1945 } | |
1946 } | |
1947 | 1928 |
1948 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserv
erRegistry()) { | 1929 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserv
erRegistry()) { |
1949 for (size_t i = 0; i < registry->size(); ++i) { | 1930 for (size_t i = 0; i < registry->size(); ++i) { |
1950 document().addMutationObserverTypes(registry->at(i)->mutationTypes()
); | 1931 document().addMutationObserverTypes(registry->at(i)->mutationTypes()
); |
1951 } | 1932 } |
1952 } | 1933 } |
1953 | 1934 |
1954 if (HashSet<MutationObserverRegistration*>* transientRegistry = transientMut
ationObserverRegistry()) { | 1935 if (HashSet<MutationObserverRegistration*>* transientRegistry = transientMut
ationObserverRegistry()) { |
1955 for (HashSet<MutationObserverRegistration*>::iterator iter = transientRe
gistry->begin(); iter != transientRegistry->end(); ++iter) { | 1936 for (HashSet<MutationObserverRegistration*>::iterator iter = transientRe
gistry->begin(); iter != transientRegistry->end(); ++iter) { |
1956 document().addMutationObserverTypes((*iter)->mutationTypes()); | 1937 document().addMutationObserverTypes((*iter)->mutationTypes()); |
1957 } | 1938 } |
1958 } | 1939 } |
1959 } | 1940 } |
1960 | 1941 |
1961 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve
ntType, PassRefPtr<EventListener> listener, bool useCapture) | 1942 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve
ntType, PassRefPtr<EventListener> listener, bool useCapture) |
1962 { | 1943 { |
1963 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu
re)) | 1944 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu
re)) |
1964 return false; | 1945 return false; |
1965 | 1946 |
1966 Document& document = targetNode->document(); | 1947 Document& document = targetNode->document(); |
1967 document.addListenerTypeIfNeeded(eventType); | 1948 document.addListenerTypeIfNeeded(eventType); |
1968 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse
wheel) | 1949 EventHandlerRegistry::from(document)->didAddEventHandler(*targetNode, eventT
ype); |
1969 WheelController::from(document)->didAddWheelEventHandler(document); | |
1970 else if (isTouchEventType(eventType)) | |
1971 document.didAddTouchEventHandler(targetNode); | |
1972 | 1950 |
1973 return true; | 1951 return true; |
1974 } | 1952 } |
1975 | 1953 |
1976 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe
ner> listener, bool useCapture) | 1954 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe
ner> listener, bool useCapture) |
1977 { | 1955 { |
1978 return tryAddEventListener(this, eventType, listener, useCapture); | 1956 return tryAddEventListener(this, eventType, listener, useCapture); |
1979 } | 1957 } |
1980 | 1958 |
1981 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString&
eventType, EventListener* listener, bool useCapture) | 1959 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString&
eventType, EventListener* listener, bool useCapture) |
1982 { | 1960 { |
1983 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa
pture)) | 1961 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa
pture)) |
1984 return false; | 1962 return false; |
1985 | 1963 |
1986 // FIXME: Notify Document that the listener has vanished. We need to keep tr
ack of a number of | 1964 // FIXME: Notify Document that the listener has vanished. We need to keep tr
ack of a number of |
1987 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh
ow_bug.cgi?id=33861 | 1965 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh
ow_bug.cgi?id=33861 |
1988 Document& document = targetNode->document(); | 1966 Document& document = targetNode->document(); |
1989 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse
wheel) | 1967 EventHandlerRegistry::from(document)->didRemoveEventHandler(*targetNode, eve
ntType); |
1990 WheelController::from(document)->didRemoveWheelEventHandler(document); | |
1991 else if (isTouchEventType(eventType)) | |
1992 document.didRemoveTouchEventHandler(targetNode); | |
1993 | 1968 |
1994 return true; | 1969 return true; |
1995 } | 1970 } |
1996 | 1971 |
1997 bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis
tener, bool useCapture) | 1972 bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis
tener, bool useCapture) |
1998 { | 1973 { |
1999 return tryRemoveEventListener(this, eventType, listener, useCapture); | 1974 return tryRemoveEventListener(this, eventType, listener, useCapture); |
2000 } | 1975 } |
2001 | 1976 |
2002 void Node::removeAllEventListeners() | 1977 void Node::removeAllEventListeners() |
2003 { | 1978 { |
2004 EventTarget::removeAllEventListeners(); | 1979 EventTarget::removeAllEventListeners(); |
2005 document().didClearTouchEventHandlers(this); | 1980 EventHandlerRegistry::from(document())->didRemoveAllEventHandlers(*this); |
2006 } | 1981 } |
2007 | 1982 |
2008 typedef HashMap<Node*, OwnPtr<EventTargetData> > EventTargetDataMap; | 1983 typedef HashMap<Node*, OwnPtr<EventTargetData> > EventTargetDataMap; |
2009 | 1984 |
2010 static EventTargetDataMap& eventTargetDataMap() | 1985 static EventTargetDataMap& eventTargetDataMap() |
2011 { | 1986 { |
2012 DEFINE_STATIC_LOCAL(EventTargetDataMap, map, ()); | 1987 DEFINE_STATIC_LOCAL(EventTargetDataMap, map, ()); |
2013 return map; | 1988 return map; |
2014 } | 1989 } |
2015 | 1990 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2527 node->showTreeForThis(); | 2502 node->showTreeForThis(); |
2528 } | 2503 } |
2529 | 2504 |
2530 void showNodePath(const WebCore::Node* node) | 2505 void showNodePath(const WebCore::Node* node) |
2531 { | 2506 { |
2532 if (node) | 2507 if (node) |
2533 node->showNodePathForThis(); | 2508 node->showNodePathForThis(); |
2534 } | 2509 } |
2535 | 2510 |
2536 #endif | 2511 #endif |
OLD | NEW |