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 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1914 for (unsigned i = 0; i < types.size(); ++i) | 1914 for (unsigned i = 0; i < types.size(); ++i) |
1915 document().addListenerTypeIfNeeded(types[i]); | 1915 document().addListenerTypeIfNeeded(types[i]); |
1916 } | 1916 } |
1917 } | 1917 } |
1918 | 1918 |
1919 if (AXObjectCache::accessibilityEnabled()) { | 1919 if (AXObjectCache::accessibilityEnabled()) { |
1920 if (AXObjectCache* cache = oldDocument.existingAXObjectCache()) | 1920 if (AXObjectCache* cache = oldDocument.existingAXObjectCache()) |
1921 cache->remove(this); | 1921 cache->remove(this); |
1922 } | 1922 } |
1923 | 1923 |
1924 const EventListenerVector& mousewheelListeners = getEventListeners(EventType
Names::mousewheel); | 1924 EventHandlerRegistry::from(document())->didMoveToNewDocument(*this, oldDocum
ent); |
1925 WheelController* oldController = WheelController::from(oldDocument); | |
1926 WheelController* newController = WheelController::from(document()); | |
1927 for (size_t i = 0; i < mousewheelListeners.size(); ++i) { | |
1928 oldController->didRemoveWheelEventHandler(oldDocument); | |
1929 newController->didAddWheelEventHandler(document()); | |
1930 } | |
1931 | |
1932 const EventListenerVector& wheelListeners = getEventListeners(EventTypeNames
::wheel); | |
1933 for (size_t i = 0; i < wheelListeners.size(); ++i) { | |
1934 oldController->didRemoveWheelEventHandler(oldDocument); | |
1935 newController->didAddWheelEventHandler(document()); | |
1936 } | |
1937 | |
1938 if (const TouchEventTargetSet* touchHandlers = oldDocument.touchEventTargets
()) { | |
1939 while (touchHandlers->contains(this)) { | |
1940 oldDocument.didRemoveTouchEventHandler(this); | |
1941 document().didAddTouchEventHandler(this); | |
1942 } | |
1943 } | |
1944 | 1925 |
1945 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserv
erRegistry()) { | 1926 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserv
erRegistry()) { |
1946 for (size_t i = 0; i < registry->size(); ++i) { | 1927 for (size_t i = 0; i < registry->size(); ++i) { |
1947 document().addMutationObserverTypes(registry->at(i)->mutationTypes()
); | 1928 document().addMutationObserverTypes(registry->at(i)->mutationTypes()
); |
1948 } | 1929 } |
1949 } | 1930 } |
1950 | 1931 |
1951 if (HashSet<MutationObserverRegistration*>* transientRegistry = transientMut
ationObserverRegistry()) { | 1932 if (HashSet<MutationObserverRegistration*>* transientRegistry = transientMut
ationObserverRegistry()) { |
1952 for (HashSet<MutationObserverRegistration*>::iterator iter = transientRe
gistry->begin(); iter != transientRegistry->end(); ++iter) { | 1933 for (HashSet<MutationObserverRegistration*>::iterator iter = transientRe
gistry->begin(); iter != transientRegistry->end(); ++iter) { |
1953 document().addMutationObserverTypes((*iter)->mutationTypes()); | 1934 document().addMutationObserverTypes((*iter)->mutationTypes()); |
1954 } | 1935 } |
1955 } | 1936 } |
1956 } | 1937 } |
1957 | 1938 |
1958 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve
ntType, PassRefPtr<EventListener> listener, bool useCapture) | 1939 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve
ntType, PassRefPtr<EventListener> listener, bool useCapture) |
1959 { | 1940 { |
1960 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu
re)) | 1941 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu
re)) |
1961 return false; | 1942 return false; |
1962 | 1943 |
1963 Document& document = targetNode->document(); | 1944 Document& document = targetNode->document(); |
1964 document.addListenerTypeIfNeeded(eventType); | 1945 document.addListenerTypeIfNeeded(eventType); |
1965 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse
wheel) | 1946 EventHandlerRegistry::from(document)->didAddEventHandler(*targetNode, eventT
ype); |
1966 WheelController::from(document)->didAddWheelEventHandler(document); | |
1967 else if (isTouchEventType(eventType)) | |
1968 document.didAddTouchEventHandler(targetNode); | |
1969 | 1947 |
1970 return true; | 1948 return true; |
1971 } | 1949 } |
1972 | 1950 |
1973 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe
ner> listener, bool useCapture) | 1951 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe
ner> listener, bool useCapture) |
1974 { | 1952 { |
1975 return tryAddEventListener(this, eventType, listener, useCapture); | 1953 return tryAddEventListener(this, eventType, listener, useCapture); |
1976 } | 1954 } |
1977 | 1955 |
1978 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString&
eventType, EventListener* listener, bool useCapture) | 1956 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString&
eventType, EventListener* listener, bool useCapture) |
1979 { | 1957 { |
1980 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa
pture)) | 1958 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa
pture)) |
1981 return false; | 1959 return false; |
1982 | 1960 |
1983 // FIXME: Notify Document that the listener has vanished. We need to keep tr
ack of a number of | 1961 // FIXME: Notify Document that the listener has vanished. We need to keep tr
ack of a number of |
1984 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh
ow_bug.cgi?id=33861 | 1962 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh
ow_bug.cgi?id=33861 |
1985 Document& document = targetNode->document(); | 1963 Document& document = targetNode->document(); |
1986 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse
wheel) | 1964 EventHandlerRegistry::from(document)->didRemoveEventHandler(*targetNode, eve
ntType); |
1987 WheelController::from(document)->didRemoveWheelEventHandler(document); | |
1988 else if (isTouchEventType(eventType)) | |
1989 document.didRemoveTouchEventHandler(targetNode); | |
1990 | 1965 |
1991 return true; | 1966 return true; |
1992 } | 1967 } |
1993 | 1968 |
1994 bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis
tener, bool useCapture) | 1969 bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis
tener, bool useCapture) |
1995 { | 1970 { |
1996 return tryRemoveEventListener(this, eventType, listener, useCapture); | 1971 return tryRemoveEventListener(this, eventType, listener, useCapture); |
1997 } | 1972 } |
1998 | 1973 |
1999 void Node::removeAllEventListeners() | 1974 void Node::removeAllEventListeners() |
2000 { | 1975 { |
2001 EventTarget::removeAllEventListeners(); | 1976 EventTarget::removeAllEventListeners(); |
2002 document().didClearTouchEventHandlers(this); | 1977 EventHandlerRegistry::from(document())->didRemoveAllEventHandlers(*this); |
2003 } | 1978 } |
2004 | 1979 |
2005 typedef HashMap<Node*, OwnPtr<EventTargetData> > EventTargetDataMap; | 1980 typedef HashMap<Node*, OwnPtr<EventTargetData> > EventTargetDataMap; |
2006 | 1981 |
2007 static EventTargetDataMap& eventTargetDataMap() | 1982 static EventTargetDataMap& eventTargetDataMap() |
2008 { | 1983 { |
2009 DEFINE_STATIC_LOCAL(EventTargetDataMap, map, ()); | 1984 DEFINE_STATIC_LOCAL(EventTargetDataMap, map, ()); |
2010 return map; | 1985 return map; |
2011 } | 1986 } |
2012 | 1987 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2524 node->showTreeForThis(); | 2499 node->showTreeForThis(); |
2525 } | 2500 } |
2526 | 2501 |
2527 void showNodePath(const WebCore::Node* node) | 2502 void showNodePath(const WebCore::Node* node) |
2528 { | 2503 { |
2529 if (node) | 2504 if (node) |
2530 node->showNodePathForThis(); | 2505 node->showNodePathForThis(); |
2531 } | 2506 } |
2532 | 2507 |
2533 #endif | 2508 #endif |
OLD | NEW |