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 17 matching lines...) Expand all Loading... | |
73 #include "core/events/TouchEvent.h" | 72 #include "core/events/TouchEvent.h" |
74 #include "core/events/UIEvent.h" | 73 #include "core/events/UIEvent.h" |
75 #include "core/events/WheelEvent.h" | 74 #include "core/events/WheelEvent.h" |
76 #include "core/frame/LocalFrame.h" | 75 #include "core/frame/LocalFrame.h" |
77 #include "core/html/HTMLAnchorElement.h" | 76 #include "core/html/HTMLAnchorElement.h" |
78 #include "core/html/HTMLDialogElement.h" | 77 #include "core/html/HTMLDialogElement.h" |
79 #include "core/html/HTMLFrameOwnerElement.h" | 78 #include "core/html/HTMLFrameOwnerElement.h" |
80 #include "core/html/HTMLStyleElement.h" | 79 #include "core/html/HTMLStyleElement.h" |
81 #include "core/page/ContextMenuController.h" | 80 #include "core/page/ContextMenuController.h" |
82 #include "core/page/EventHandler.h" | 81 #include "core/page/EventHandler.h" |
82 #include "core/page/EventHandlerRegistry.h" | |
83 #include "core/page/Page.h" | 83 #include "core/page/Page.h" |
84 #include "core/frame/Settings.h" | 84 #include "core/frame/Settings.h" |
85 #include "core/rendering/FlowThreadController.h" | 85 #include "core/rendering/FlowThreadController.h" |
86 #include "core/rendering/RenderBox.h" | 86 #include "core/rendering/RenderBox.h" |
87 #include "core/svg/graphics/SVGImage.h" | 87 #include "core/svg/graphics/SVGImage.h" |
88 #include "platform/Partitions.h" | 88 #include "platform/Partitions.h" |
89 #include "wtf/HashSet.h" | 89 #include "wtf/HashSet.h" |
90 #include "wtf/PassOwnPtr.h" | 90 #include "wtf/PassOwnPtr.h" |
91 #include "wtf/RefCountedLeakCounter.h" | 91 #include "wtf/RefCountedLeakCounter.h" |
92 #include "wtf/Vector.h" | 92 #include "wtf/Vector.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 void Node::willBeDeletedFromDocument() | 285 void Node::willBeDeletedFromDocument() |
286 { | 286 { |
287 if (!isTreeScopeInitialized()) | 287 if (!isTreeScopeInitialized()) |
288 return; | 288 return; |
289 | 289 |
290 Document& document = this->document(); | 290 Document& document = this->document(); |
291 | 291 |
292 if (hasEventTargetData()) { | 292 if (hasEventTargetData()) { |
293 clearEventTargetData(); | 293 clearEventTargetData(); |
294 document.didClearTouchEventHandlers(this); | 294 document.didClearTouchEventHandlers(this); |
295 EventHandlerRegistry::from(document)->didRemoveAllEventHandlers(*this); | 295 if (document.page()) |
296 EventHandlerRegistry::from(*document.page())->didRemoveAllEventHandl ers(*this); | |
296 } | 297 } |
297 | 298 |
298 if (AXObjectCache* cache = document.existingAXObjectCache()) | 299 if (AXObjectCache* cache = document.existingAXObjectCache()) |
299 cache->remove(this); | 300 cache->remove(this); |
300 | 301 |
301 document.markers().removeMarkers(this); | 302 document.markers().removeMarkers(this); |
302 } | 303 } |
303 | 304 |
304 NodeRareData* Node::rareData() const | 305 NodeRareData* Node::rareData() const |
305 { | 306 { |
(...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1936 oldController->didRemoveWheelEventHandler(oldDocument); | 1937 oldController->didRemoveWheelEventHandler(oldDocument); |
1937 newController->didAddWheelEventHandler(document()); | 1938 newController->didAddWheelEventHandler(document()); |
1938 } | 1939 } |
1939 | 1940 |
1940 if (const TouchEventTargetSet* touchHandlers = oldDocument.touchEventTargets ()) { | 1941 if (const TouchEventTargetSet* touchHandlers = oldDocument.touchEventTargets ()) { |
1941 while (touchHandlers->contains(this)) { | 1942 while (touchHandlers->contains(this)) { |
1942 oldDocument.didRemoveTouchEventHandler(this); | 1943 oldDocument.didRemoveTouchEventHandler(this); |
1943 document().didAddTouchEventHandler(this); | 1944 document().didAddTouchEventHandler(this); |
1944 } | 1945 } |
1945 } | 1946 } |
1946 EventHandlerRegistry::from(document())->didMoveFromOtherDocument(*this, oldD ocument); | 1947 if (document().page()) |
Rick Byers
2014/04/24 21:30:12
In what cases does a Document not have a Page? It
Sami
2014/04/25 19:51:15
After a document is detached it will no longer hav
| |
1948 EventHandlerRegistry::from(*document().page())->didMoveFromOtherDocument (*this, oldDocument); | |
1947 | 1949 |
1948 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserv erRegistry()) { | 1950 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserv erRegistry()) { |
1949 for (size_t i = 0; i < registry->size(); ++i) { | 1951 for (size_t i = 0; i < registry->size(); ++i) { |
1950 document().addMutationObserverTypes(registry->at(i)->mutationTypes() ); | 1952 document().addMutationObserverTypes(registry->at(i)->mutationTypes() ); |
1951 } | 1953 } |
1952 } | 1954 } |
1953 | 1955 |
1954 if (HashSet<MutationObserverRegistration*>* transientRegistry = transientMut ationObserverRegistry()) { | 1956 if (HashSet<MutationObserverRegistration*>* transientRegistry = transientMut ationObserverRegistry()) { |
1955 for (HashSet<MutationObserverRegistration*>::iterator iter = transientRe gistry->begin(); iter != transientRegistry->end(); ++iter) { | 1957 for (HashSet<MutationObserverRegistration*>::iterator iter = transientRe gistry->begin(); iter != transientRegistry->end(); ++iter) { |
1956 document().addMutationObserverTypes((*iter)->mutationTypes()); | 1958 document().addMutationObserverTypes((*iter)->mutationTypes()); |
1957 } | 1959 } |
1958 } | 1960 } |
1959 } | 1961 } |
1960 | 1962 |
1961 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve ntType, PassRefPtr<EventListener> listener, bool useCapture) | 1963 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve ntType, PassRefPtr<EventListener> listener, bool useCapture) |
1962 { | 1964 { |
1963 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu re)) | 1965 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu re)) |
1964 return false; | 1966 return false; |
1965 | 1967 |
1966 Document& document = targetNode->document(); | 1968 Document& document = targetNode->document(); |
1967 document.addListenerTypeIfNeeded(eventType); | 1969 document.addListenerTypeIfNeeded(eventType); |
1968 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse wheel) | 1970 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse wheel) |
1969 WheelController::from(document)->didAddWheelEventHandler(document); | 1971 WheelController::from(document)->didAddWheelEventHandler(document); |
1970 else if (isTouchEventType(eventType)) | 1972 else if (isTouchEventType(eventType)) |
1971 document.didAddTouchEventHandler(targetNode); | 1973 document.didAddTouchEventHandler(targetNode); |
1972 EventHandlerRegistry::from(document)->didAddEventHandler(*targetNode, eventT ype); | 1974 if (document.page()) |
1975 EventHandlerRegistry::from(*document.page())->didAddEventHandler(*target Node, eventType); | |
1973 | 1976 |
1974 return true; | 1977 return true; |
1975 } | 1978 } |
1976 | 1979 |
1977 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe ner> listener, bool useCapture) | 1980 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe ner> listener, bool useCapture) |
1978 { | 1981 { |
1979 return tryAddEventListener(this, eventType, listener, useCapture); | 1982 return tryAddEventListener(this, eventType, listener, useCapture); |
1980 } | 1983 } |
1981 | 1984 |
1982 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString& eventType, EventListener* listener, bool useCapture) | 1985 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString& eventType, EventListener* listener, bool useCapture) |
1983 { | 1986 { |
1984 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa pture)) | 1987 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa pture)) |
1985 return false; | 1988 return false; |
1986 | 1989 |
1987 // FIXME: Notify Document that the listener has vanished. We need to keep tr ack of a number of | 1990 // FIXME: Notify Document that the listener has vanished. We need to keep tr ack of a number of |
1988 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh ow_bug.cgi?id=33861 | 1991 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh ow_bug.cgi?id=33861 |
1989 Document& document = targetNode->document(); | 1992 Document& document = targetNode->document(); |
1990 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse wheel) | 1993 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse wheel) |
1991 WheelController::from(document)->didRemoveWheelEventHandler(document); | 1994 WheelController::from(document)->didRemoveWheelEventHandler(document); |
1992 else if (isTouchEventType(eventType)) | 1995 else if (isTouchEventType(eventType)) |
1993 document.didRemoveTouchEventHandler(targetNode); | 1996 document.didRemoveTouchEventHandler(targetNode); |
1994 EventHandlerRegistry::from(document)->didRemoveEventHandler(*targetNode, eve ntType); | 1997 if (document.page()) |
1998 EventHandlerRegistry::from(*document.page())->didRemoveEventHandler(*tar getNode, eventType); | |
1995 | 1999 |
1996 return true; | 2000 return true; |
1997 } | 2001 } |
1998 | 2002 |
1999 bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis tener, bool useCapture) | 2003 bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis tener, bool useCapture) |
2000 { | 2004 { |
2001 return tryRemoveEventListener(this, eventType, listener, useCapture); | 2005 return tryRemoveEventListener(this, eventType, listener, useCapture); |
2002 } | 2006 } |
2003 | 2007 |
2004 void Node::removeAllEventListeners() | 2008 void Node::removeAllEventListeners() |
2005 { | 2009 { |
2006 if (hasEventListeners()) | 2010 if (hasEventListeners() && document().page()) |
2007 EventHandlerRegistry::from(document())->didRemoveAllEventHandlers(*this) ; | 2011 EventHandlerRegistry::from(*document().page())->didRemoveAllEventHandler s(*this); |
2008 EventTarget::removeAllEventListeners(); | 2012 EventTarget::removeAllEventListeners(); |
2009 document().didClearTouchEventHandlers(this); | 2013 document().didClearTouchEventHandlers(this); |
2010 } | 2014 } |
2011 | 2015 |
2012 void Node::removeAllEventListenersRecursively() | 2016 void Node::removeAllEventListenersRecursively() |
2013 { | 2017 { |
2014 for (Node* node = this; node; node = NodeTraversal::next(*node)) { | 2018 for (Node* node = this; node; node = NodeTraversal::next(*node)) { |
2015 node->removeAllEventListeners(); | 2019 node->removeAllEventListeners(); |
2016 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o lderShadowRoot()) | 2020 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o lderShadowRoot()) |
2017 root->removeAllEventListenersRecursively(); | 2021 root->removeAllEventListenersRecursively(); |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2544 node->showTreeForThis(); | 2548 node->showTreeForThis(); |
2545 } | 2549 } |
2546 | 2550 |
2547 void showNodePath(const WebCore::Node* node) | 2551 void showNodePath(const WebCore::Node* node) |
2548 { | 2552 { |
2549 if (node) | 2553 if (node) |
2550 node->showNodePathForThis(); | 2554 node->showNodePathForThis(); |
2551 } | 2555 } |
2552 | 2556 |
2553 #endif | 2557 #endif |
OLD | NEW |