Chromium Code Reviews| 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" |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 void Node::willBeDeletedFromDocument() | 285 void Node::willBeDeletedFromDocument() |
| 285 { | 286 { |
| 286 if (!isTreeScopeInitialized()) | 287 if (!isTreeScopeInitialized()) |
| 287 return; | 288 return; |
| 288 | 289 |
| 289 Document& document = this->document(); | 290 Document& document = this->document(); |
| 290 | 291 |
| 291 if (hasEventTargetData()) { | 292 if (hasEventTargetData()) { |
| 292 clearEventTargetData(); | 293 clearEventTargetData(); |
| 293 document.didClearTouchEventHandlers(this); | 294 document.didClearTouchEventHandlers(this); |
| 295 EventHandlerRegistry::from(document)->didRemoveAllEventHandlers(*this); | |
| 294 } | 296 } |
| 295 | 297 |
| 296 if (AXObjectCache* cache = document.existingAXObjectCache()) | 298 if (AXObjectCache* cache = document.existingAXObjectCache()) |
| 297 cache->remove(this); | 299 cache->remove(this); |
| 298 | 300 |
| 299 document.markers().removeMarkers(this); | 301 document.markers().removeMarkers(this); |
| 300 } | 302 } |
| 301 | 303 |
| 302 NodeRareData* Node::rareData() const | 304 NodeRareData* Node::rareData() const |
| 303 { | 305 { |
| (...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1934 oldController->didRemoveWheelEventHandler(oldDocument); | 1936 oldController->didRemoveWheelEventHandler(oldDocument); |
| 1935 newController->didAddWheelEventHandler(document()); | 1937 newController->didAddWheelEventHandler(document()); |
| 1936 } | 1938 } |
| 1937 | 1939 |
| 1938 if (const TouchEventTargetSet* touchHandlers = oldDocument.touchEventTargets ()) { | 1940 if (const TouchEventTargetSet* touchHandlers = oldDocument.touchEventTargets ()) { |
| 1939 while (touchHandlers->contains(this)) { | 1941 while (touchHandlers->contains(this)) { |
| 1940 oldDocument.didRemoveTouchEventHandler(this); | 1942 oldDocument.didRemoveTouchEventHandler(this); |
| 1941 document().didAddTouchEventHandler(this); | 1943 document().didAddTouchEventHandler(this); |
| 1942 } | 1944 } |
| 1943 } | 1945 } |
| 1946 EventHandlerRegistry::from(document())->didMoveFromOtherDocument(*this, oldD ocument); | |
| 1944 | 1947 |
| 1945 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserv erRegistry()) { | 1948 if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserv erRegistry()) { |
| 1946 for (size_t i = 0; i < registry->size(); ++i) { | 1949 for (size_t i = 0; i < registry->size(); ++i) { |
| 1947 document().addMutationObserverTypes(registry->at(i)->mutationTypes() ); | 1950 document().addMutationObserverTypes(registry->at(i)->mutationTypes() ); |
| 1948 } | 1951 } |
| 1949 } | 1952 } |
| 1950 | 1953 |
| 1951 if (HashSet<MutationObserverRegistration*>* transientRegistry = transientMut ationObserverRegistry()) { | 1954 if (HashSet<MutationObserverRegistration*>* transientRegistry = transientMut ationObserverRegistry()) { |
| 1952 for (HashSet<MutationObserverRegistration*>::iterator iter = transientRe gistry->begin(); iter != transientRegistry->end(); ++iter) { | 1955 for (HashSet<MutationObserverRegistration*>::iterator iter = transientRe gistry->begin(); iter != transientRegistry->end(); ++iter) { |
| 1953 document().addMutationObserverTypes((*iter)->mutationTypes()); | 1956 document().addMutationObserverTypes((*iter)->mutationTypes()); |
| 1954 } | 1957 } |
| 1955 } | 1958 } |
| 1956 } | 1959 } |
| 1957 | 1960 |
| 1958 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve ntType, PassRefPtr<EventListener> listener, bool useCapture) | 1961 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve ntType, PassRefPtr<EventListener> listener, bool useCapture) |
| 1959 { | 1962 { |
| 1960 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu re)) | 1963 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu re)) |
| 1961 return false; | 1964 return false; |
| 1962 | 1965 |
| 1963 Document& document = targetNode->document(); | 1966 Document& document = targetNode->document(); |
| 1964 document.addListenerTypeIfNeeded(eventType); | 1967 document.addListenerTypeIfNeeded(eventType); |
| 1965 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse wheel) | 1968 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse wheel) |
| 1966 WheelController::from(document)->didAddWheelEventHandler(document); | 1969 WheelController::from(document)->didAddWheelEventHandler(document); |
| 1967 else if (isTouchEventType(eventType)) | 1970 else if (isTouchEventType(eventType)) |
| 1968 document.didAddTouchEventHandler(targetNode); | 1971 document.didAddTouchEventHandler(targetNode); |
| 1972 EventHandlerRegistry::from(document)->didAddEventHandler(*targetNode, eventT ype); | |
| 1969 | 1973 |
| 1970 return true; | 1974 return true; |
| 1971 } | 1975 } |
| 1972 | 1976 |
| 1973 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe ner> listener, bool useCapture) | 1977 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe ner> listener, bool useCapture) |
| 1974 { | 1978 { |
| 1975 return tryAddEventListener(this, eventType, listener, useCapture); | 1979 return tryAddEventListener(this, eventType, listener, useCapture); |
| 1976 } | 1980 } |
| 1977 | 1981 |
| 1978 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString& eventType, EventListener* listener, bool useCapture) | 1982 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString& eventType, EventListener* listener, bool useCapture) |
| 1979 { | 1983 { |
| 1980 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa pture)) | 1984 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa pture)) |
| 1981 return false; | 1985 return false; |
| 1982 | 1986 |
| 1983 // FIXME: Notify Document that the listener has vanished. We need to keep tr ack of a number of | 1987 // 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 | 1988 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh ow_bug.cgi?id=33861 |
| 1985 Document& document = targetNode->document(); | 1989 Document& document = targetNode->document(); |
| 1986 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse wheel) | 1990 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse wheel) |
| 1987 WheelController::from(document)->didRemoveWheelEventHandler(document); | 1991 WheelController::from(document)->didRemoveWheelEventHandler(document); |
| 1988 else if (isTouchEventType(eventType)) | 1992 else if (isTouchEventType(eventType)) |
| 1989 document.didRemoveTouchEventHandler(targetNode); | 1993 document.didRemoveTouchEventHandler(targetNode); |
| 1994 EventHandlerRegistry::from(document)->didRemoveEventHandler(*targetNode, eve ntType); | |
| 1990 | 1995 |
| 1991 return true; | 1996 return true; |
| 1992 } | 1997 } |
| 1993 | 1998 |
| 1994 bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis tener, bool useCapture) | 1999 bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis tener, bool useCapture) |
| 1995 { | 2000 { |
| 1996 return tryRemoveEventListener(this, eventType, listener, useCapture); | 2001 return tryRemoveEventListener(this, eventType, listener, useCapture); |
| 1997 } | 2002 } |
| 1998 | 2003 |
| 1999 void Node::removeAllEventListeners() | 2004 void Node::removeAllEventListeners() |
| 2000 { | 2005 { |
| 2001 EventTarget::removeAllEventListeners(); | 2006 EventTarget::removeAllEventListeners(); |
| 2002 document().didClearTouchEventHandlers(this); | 2007 document().didClearTouchEventHandlers(this); |
| 2008 EventHandlerRegistry::from(document())->didRemoveAllEventHandlers(*this); | |
|
abarth-chromium
2014/04/17 18:05:12
It's kind of lame that we'll create the EventHandl
Sami
2014/04/17 18:40:53
I think I can guard this with hasEventListeners()
| |
| 2003 } | 2009 } |
| 2004 | 2010 |
| 2005 void Node::removeAllEventListenersRecursively() | 2011 void Node::removeAllEventListenersRecursively() |
| 2006 { | 2012 { |
| 2007 for (Node* node = this; node; node = NodeTraversal::next(*node)) { | 2013 for (Node* node = this; node; node = NodeTraversal::next(*node)) { |
| 2008 node->removeAllEventListeners(); | 2014 node->removeAllEventListeners(); |
| 2009 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o lderShadowRoot()) | 2015 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->o lderShadowRoot()) |
| 2010 root->removeAllEventListenersRecursively(); | 2016 root->removeAllEventListenersRecursively(); |
| 2011 } | 2017 } |
| 2012 } | 2018 } |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2537 node->showTreeForThis(); | 2543 node->showTreeForThis(); |
| 2538 } | 2544 } |
| 2539 | 2545 |
| 2540 void showNodePath(const WebCore::Node* node) | 2546 void showNodePath(const WebCore::Node* node) |
| 2541 { | 2547 { |
| 2542 if (node) | 2548 if (node) |
| 2543 node->showNodePathForThis(); | 2549 node->showNodePathForThis(); |
| 2544 } | 2550 } |
| 2545 | 2551 |
| 2546 #endif | 2552 #endif |
| OLD | NEW |