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