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" | |
46 #include "core/dom/ExceptionCode.h" | 45 #include "core/dom/ExceptionCode.h" |
47 #include "core/dom/LiveNodeList.h" | 46 #include "core/dom/LiveNodeList.h" |
48 #include "core/dom/NodeRareData.h" | 47 #include "core/dom/NodeRareData.h" |
49 #include "core/dom/NodeRenderingTraversal.h" | 48 #include "core/dom/NodeRenderingTraversal.h" |
50 #include "core/dom/NodeTraversal.h" | 49 #include "core/dom/NodeTraversal.h" |
51 #include "core/dom/ProcessingInstruction.h" | 50 #include "core/dom/ProcessingInstruction.h" |
52 #include "core/dom/Range.h" | 51 #include "core/dom/Range.h" |
53 #include "core/dom/StaticNodeList.h" | 52 #include "core/dom/StaticNodeList.h" |
54 #include "core/dom/TemplateContentDocumentFragment.h" | 53 #include "core/dom/TemplateContentDocumentFragment.h" |
55 #include "core/dom/Text.h" | 54 #include "core/dom/Text.h" |
(...skipping 18 matching lines...) Expand all Loading... |
74 #include "core/events/TouchEvent.h" | 73 #include "core/events/TouchEvent.h" |
75 #include "core/events/UIEvent.h" | 74 #include "core/events/UIEvent.h" |
76 #include "core/events/WheelEvent.h" | 75 #include "core/events/WheelEvent.h" |
77 #include "core/frame/LocalFrame.h" | 76 #include "core/frame/LocalFrame.h" |
78 #include "core/html/HTMLAnchorElement.h" | 77 #include "core/html/HTMLAnchorElement.h" |
79 #include "core/html/HTMLDialogElement.h" | 78 #include "core/html/HTMLDialogElement.h" |
80 #include "core/html/HTMLFrameOwnerElement.h" | 79 #include "core/html/HTMLFrameOwnerElement.h" |
81 #include "core/html/HTMLStyleElement.h" | 80 #include "core/html/HTMLStyleElement.h" |
82 #include "core/page/ContextMenuController.h" | 81 #include "core/page/ContextMenuController.h" |
83 #include "core/page/EventHandler.h" | 82 #include "core/page/EventHandler.h" |
| 83 #include "core/page/EventHandlerRegistry.h" |
84 #include "core/page/Page.h" | 84 #include "core/page/Page.h" |
85 #include "core/frame/Settings.h" | 85 #include "core/frame/Settings.h" |
86 #include "core/rendering/FlowThreadController.h" | 86 #include "core/rendering/FlowThreadController.h" |
87 #include "core/rendering/RenderBox.h" | 87 #include "core/rendering/RenderBox.h" |
88 #include "core/svg/graphics/SVGImage.h" | 88 #include "core/svg/graphics/SVGImage.h" |
89 #include "platform/Partitions.h" | 89 #include "platform/Partitions.h" |
90 #include "platform/TraceEvent.h" | 90 #include "platform/TraceEvent.h" |
91 #include "platform/TracedValue.h" | 91 #include "platform/TracedValue.h" |
92 #include "wtf/HashSet.h" | 92 #include "wtf/HashSet.h" |
93 #include "wtf/PassOwnPtr.h" | 93 #include "wtf/PassOwnPtr.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 void Node::willBeDeletedFromDocument() | 297 void Node::willBeDeletedFromDocument() |
298 { | 298 { |
299 if (!isTreeScopeInitialized()) | 299 if (!isTreeScopeInitialized()) |
300 return; | 300 return; |
301 | 301 |
302 Document& document = this->document(); | 302 Document& document = this->document(); |
303 | 303 |
304 if (hasEventTargetData()) { | 304 if (hasEventTargetData()) { |
305 clearEventTargetData(); | 305 clearEventTargetData(); |
306 document.didClearTouchEventHandlers(this); | 306 document.didClearTouchEventHandlers(this); |
307 EventHandlerRegistry::from(document)->didRemoveAllEventHandlers(*this); | 307 if (document.page()) |
| 308 EventHandlerRegistry::from(*document.page())->didRemoveAllEventHandl
ers(*this); |
308 } | 309 } |
309 | 310 |
310 if (AXObjectCache* cache = document.existingAXObjectCache()) | 311 if (AXObjectCache* cache = document.existingAXObjectCache()) |
311 cache->remove(this); | 312 cache->remove(this); |
312 | 313 |
313 document.markers().removeMarkers(this); | 314 document.markers().removeMarkers(this); |
314 } | 315 } |
315 #endif | 316 #endif |
316 | 317 |
317 NodeRareData* Node::rareData() const | 318 NodeRareData* Node::rareData() const |
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1954 oldController->didRemoveWheelEventHandler(oldDocument); | 1955 oldController->didRemoveWheelEventHandler(oldDocument); |
1955 newController->didAddWheelEventHandler(document()); | 1956 newController->didAddWheelEventHandler(document()); |
1956 } | 1957 } |
1957 | 1958 |
1958 if (const TouchEventTargetSet* touchHandlers = oldDocument.touchEventTargets
()) { | 1959 if (const TouchEventTargetSet* touchHandlers = oldDocument.touchEventTargets
()) { |
1959 while (touchHandlers->contains(this)) { | 1960 while (touchHandlers->contains(this)) { |
1960 oldDocument.didRemoveTouchEventHandler(this); | 1961 oldDocument.didRemoveTouchEventHandler(this); |
1961 document().didAddTouchEventHandler(this); | 1962 document().didAddTouchEventHandler(this); |
1962 } | 1963 } |
1963 } | 1964 } |
1964 EventHandlerRegistry::from(document())->didMoveFromOtherDocument(*this, oldD
ocument); | 1965 if (oldDocument.page() != document().page()) { |
| 1966 if (oldDocument.page()) |
| 1967 EventHandlerRegistry::from(*oldDocument.page())->didMoveOutOfPage(*t
his); |
| 1968 if (document().page()) |
| 1969 EventHandlerRegistry::from(*document().page())->didMoveIntoPage(*thi
s); |
| 1970 } |
1965 | 1971 |
1966 if (WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* reg
istry = mutationObserverRegistry()) { | 1972 if (WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* reg
istry = mutationObserverRegistry()) { |
1967 for (size_t i = 0; i < registry->size(); ++i) { | 1973 for (size_t i = 0; i < registry->size(); ++i) { |
1968 document().addMutationObserverTypes(registry->at(i)->mutationTypes()
); | 1974 document().addMutationObserverTypes(registry->at(i)->mutationTypes()
); |
1969 } | 1975 } |
1970 } | 1976 } |
1971 | 1977 |
1972 if (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration> >* tr
ansientRegistry = transientMutationObserverRegistry()) { | 1978 if (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration> >* tr
ansientRegistry = transientMutationObserverRegistry()) { |
1973 for (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration>
>::iterator iter = transientRegistry->begin(); iter != transientRegistry->end();
++iter) { | 1979 for (WillBeHeapHashSet<RawPtrWillBeMember<MutationObserverRegistration>
>::iterator iter = transientRegistry->begin(); iter != transientRegistry->end();
++iter) { |
1974 document().addMutationObserverTypes((*iter)->mutationTypes()); | 1980 document().addMutationObserverTypes((*iter)->mutationTypes()); |
1975 } | 1981 } |
1976 } | 1982 } |
1977 } | 1983 } |
1978 | 1984 |
1979 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve
ntType, PassRefPtr<EventListener> listener, bool useCapture) | 1985 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve
ntType, PassRefPtr<EventListener> listener, bool useCapture) |
1980 { | 1986 { |
1981 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu
re)) | 1987 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu
re)) |
1982 return false; | 1988 return false; |
1983 | 1989 |
1984 Document& document = targetNode->document(); | 1990 Document& document = targetNode->document(); |
1985 document.addListenerTypeIfNeeded(eventType); | 1991 document.addListenerTypeIfNeeded(eventType); |
1986 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse
wheel) | 1992 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse
wheel) |
1987 WheelController::from(document)->didAddWheelEventHandler(document); | 1993 WheelController::from(document)->didAddWheelEventHandler(document); |
1988 else if (isTouchEventType(eventType)) | 1994 else if (isTouchEventType(eventType)) |
1989 document.didAddTouchEventHandler(targetNode); | 1995 document.didAddTouchEventHandler(targetNode); |
1990 EventHandlerRegistry::from(document)->didAddEventHandler(*targetNode, eventT
ype); | 1996 if (document.page()) |
| 1997 EventHandlerRegistry::from(*document.page())->didAddEventHandler(*target
Node, eventType); |
1991 | 1998 |
1992 return true; | 1999 return true; |
1993 } | 2000 } |
1994 | 2001 |
1995 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe
ner> listener, bool useCapture) | 2002 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe
ner> listener, bool useCapture) |
1996 { | 2003 { |
1997 return tryAddEventListener(this, eventType, listener, useCapture); | 2004 return tryAddEventListener(this, eventType, listener, useCapture); |
1998 } | 2005 } |
1999 | 2006 |
2000 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString&
eventType, EventListener* listener, bool useCapture) | 2007 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString&
eventType, EventListener* listener, bool useCapture) |
2001 { | 2008 { |
2002 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa
pture)) | 2009 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa
pture)) |
2003 return false; | 2010 return false; |
2004 | 2011 |
2005 // FIXME: Notify Document that the listener has vanished. We need to keep tr
ack of a number of | 2012 // FIXME: Notify Document that the listener has vanished. We need to keep tr
ack of a number of |
2006 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh
ow_bug.cgi?id=33861 | 2013 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh
ow_bug.cgi?id=33861 |
2007 Document& document = targetNode->document(); | 2014 Document& document = targetNode->document(); |
2008 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse
wheel) | 2015 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse
wheel) |
2009 WheelController::from(document)->didRemoveWheelEventHandler(document); | 2016 WheelController::from(document)->didRemoveWheelEventHandler(document); |
2010 else if (isTouchEventType(eventType)) | 2017 else if (isTouchEventType(eventType)) |
2011 document.didRemoveTouchEventHandler(targetNode); | 2018 document.didRemoveTouchEventHandler(targetNode); |
2012 EventHandlerRegistry::from(document)->didRemoveEventHandler(*targetNode, eve
ntType); | 2019 if (document.page()) |
| 2020 EventHandlerRegistry::from(*document.page())->didRemoveEventHandler(*tar
getNode, eventType); |
2013 | 2021 |
2014 return true; | 2022 return true; |
2015 } | 2023 } |
2016 | 2024 |
2017 bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis
tener, bool useCapture) | 2025 bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis
tener, bool useCapture) |
2018 { | 2026 { |
2019 return tryRemoveEventListener(this, eventType, listener, useCapture); | 2027 return tryRemoveEventListener(this, eventType, listener, useCapture); |
2020 } | 2028 } |
2021 | 2029 |
2022 void Node::removeAllEventListeners() | 2030 void Node::removeAllEventListeners() |
2023 { | 2031 { |
2024 if (hasEventListeners()) | 2032 if (hasEventListeners() && document().page()) |
2025 EventHandlerRegistry::from(document())->didRemoveAllEventHandlers(*this)
; | 2033 EventHandlerRegistry::from(*document().page())->didRemoveAllEventHandler
s(*this); |
2026 EventTarget::removeAllEventListeners(); | 2034 EventTarget::removeAllEventListeners(); |
2027 document().didClearTouchEventHandlers(this); | 2035 document().didClearTouchEventHandlers(this); |
2028 } | 2036 } |
2029 | 2037 |
2030 void Node::removeAllEventListenersRecursively() | 2038 void Node::removeAllEventListenersRecursively() |
2031 { | 2039 { |
2032 for (Node* node = this; node; node = NodeTraversal::next(*node)) { | 2040 for (Node* node = this; node; node = NodeTraversal::next(*node)) { |
2033 node->removeAllEventListeners(); | 2041 node->removeAllEventListeners(); |
2034 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o
lderShadowRoot()) | 2042 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o
lderShadowRoot()) |
2035 root->removeAllEventListenersRecursively(); | 2043 root->removeAllEventListenersRecursively(); |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2582 node->showTreeForThis(); | 2590 node->showTreeForThis(); |
2583 } | 2591 } |
2584 | 2592 |
2585 void showNodePath(const WebCore::Node* node) | 2593 void showNodePath(const WebCore::Node* node) |
2586 { | 2594 { |
2587 if (node) | 2595 if (node) |
2588 node->showNodePathForThis(); | 2596 node->showNodePathForThis(); |
2589 } | 2597 } |
2590 | 2598 |
2591 #endif | 2599 #endif |
OLD | NEW |