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