Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: Source/core/dom/Node.cpp

Issue 225823007: Migrate wheel events to EventHandlerRegistry (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/dom/WheelController.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "core/dom/NodeRenderingTraversal.h" 49 #include "core/dom/NodeRenderingTraversal.h"
50 #include "core/dom/NodeTraversal.h" 50 #include "core/dom/NodeTraversal.h"
51 #include "core/dom/ProcessingInstruction.h" 51 #include "core/dom/ProcessingInstruction.h"
52 #include "core/dom/Range.h" 52 #include "core/dom/Range.h"
53 #include "core/dom/StaticNodeList.h" 53 #include "core/dom/StaticNodeList.h"
54 #include "core/dom/TemplateContentDocumentFragment.h" 54 #include "core/dom/TemplateContentDocumentFragment.h"
55 #include "core/dom/Text.h" 55 #include "core/dom/Text.h"
56 #include "core/dom/TreeScopeAdopter.h" 56 #include "core/dom/TreeScopeAdopter.h"
57 #include "core/dom/UserActionElementSet.h" 57 #include "core/dom/UserActionElementSet.h"
58 #include "core/dom/WeakNodeMap.h" 58 #include "core/dom/WeakNodeMap.h"
59 #include "core/dom/WheelController.h"
60 #include "core/dom/shadow/ElementShadow.h" 59 #include "core/dom/shadow/ElementShadow.h"
61 #include "core/dom/shadow/InsertionPoint.h" 60 #include "core/dom/shadow/InsertionPoint.h"
62 #include "core/dom/shadow/ShadowRoot.h" 61 #include "core/dom/shadow/ShadowRoot.h"
63 #include "core/editing/htmlediting.h" 62 #include "core/editing/htmlediting.h"
64 #include "core/editing/markup.h" 63 #include "core/editing/markup.h"
65 #include "core/events/Event.h" 64 #include "core/events/Event.h"
66 #include "core/events/EventDispatchMediator.h" 65 #include "core/events/EventDispatchMediator.h"
67 #include "core/events/EventDispatcher.h" 66 #include "core/events/EventDispatcher.h"
68 #include "core/events/EventListener.h" 67 #include "core/events/EventListener.h"
69 #include "core/events/GestureEvent.h" 68 #include "core/events/GestureEvent.h"
(...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 } 1939 }
1941 } 1940 }
1942 1941
1943 if (AXObjectCache::accessibilityEnabled()) { 1942 if (AXObjectCache::accessibilityEnabled()) {
1944 if (AXObjectCache* cache = oldDocument.existingAXObjectCache()) 1943 if (AXObjectCache* cache = oldDocument.existingAXObjectCache())
1945 cache->remove(this); 1944 cache->remove(this);
1946 } 1945 }
1947 1946
1948 oldDocument.markers().removeMarkers(this); 1947 oldDocument.markers().removeMarkers(this);
1949 1948
1950 const EventListenerVector& mousewheelListeners = getEventListeners(EventType Names::mousewheel);
1951 WheelController* oldController = WheelController::from(oldDocument);
1952 WheelController* newController = WheelController::from(document());
1953 for (size_t i = 0; i < mousewheelListeners.size(); ++i) {
1954 oldController->didRemoveWheelEventHandler(oldDocument);
1955 newController->didAddWheelEventHandler(document());
1956 }
1957
1958 const EventListenerVector& wheelListeners = getEventListeners(EventTypeNames ::wheel);
1959 for (size_t i = 0; i < wheelListeners.size(); ++i) {
1960 oldController->didRemoveWheelEventHandler(oldDocument);
1961 newController->didAddWheelEventHandler(document());
1962 }
1963 1949
1964 if (const TouchEventTargetSet* touchHandlers = oldDocument.touchEventTargets ()) { 1950 if (const TouchEventTargetSet* touchHandlers = oldDocument.touchEventTargets ()) {
1965 while (touchHandlers->contains(this)) { 1951 while (touchHandlers->contains(this)) {
1966 oldDocument.didRemoveTouchEventHandler(this); 1952 oldDocument.didRemoveTouchEventHandler(this);
1967 document().didAddTouchEventHandler(this); 1953 document().didAddTouchEventHandler(this);
1968 } 1954 }
1969 } 1955 }
1970 if (oldDocument.frameHost() != document().frameHost()) { 1956 if (oldDocument.frameHost() != document().frameHost()) {
1971 if (oldDocument.frameHost()) 1957 if (oldDocument.frameHost())
1972 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHos t(*this); 1958 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHos t(*this);
(...skipping 14 matching lines...) Expand all
1987 } 1973 }
1988 } 1974 }
1989 1975
1990 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve ntType, PassRefPtr<EventListener> listener, bool useCapture) 1976 static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve ntType, PassRefPtr<EventListener> listener, bool useCapture)
1991 { 1977 {
1992 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu re)) 1978 if (!targetNode->EventTarget::addEventListener(eventType, listener, useCaptu re))
1993 return false; 1979 return false;
1994 1980
1995 Document& document = targetNode->document(); 1981 Document& document = targetNode->document();
1996 document.addListenerTypeIfNeeded(eventType); 1982 document.addListenerTypeIfNeeded(eventType);
1997 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse wheel) 1983 if (isTouchEventType(eventType))
1998 WheelController::from(document)->didAddWheelEventHandler(document);
1999 else if (isTouchEventType(eventType))
2000 document.didAddTouchEventHandler(targetNode); 1984 document.didAddTouchEventHandler(targetNode);
2001 if (document.frameHost()) 1985 if (document.frameHost())
2002 document.frameHost()->eventHandlerRegistry().didAddEventHandler(*targetN ode, eventType); 1986 document.frameHost()->eventHandlerRegistry().didAddEventHandler(*targetN ode, eventType);
2003 1987
2004 return true; 1988 return true;
2005 } 1989 }
2006 1990
2007 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe ner> listener, bool useCapture) 1991 bool Node::addEventListener(const AtomicString& eventType, PassRefPtr<EventListe ner> listener, bool useCapture)
2008 { 1992 {
2009 return tryAddEventListener(this, eventType, listener, useCapture); 1993 return tryAddEventListener(this, eventType, listener, useCapture);
2010 } 1994 }
2011 1995
2012 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString& eventType, EventListener* listener, bool useCapture) 1996 static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString& eventType, EventListener* listener, bool useCapture)
2013 { 1997 {
2014 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa pture)) 1998 if (!targetNode->EventTarget::removeEventListener(eventType, listener, useCa pture))
2015 return false; 1999 return false;
2016 2000
2017 // FIXME: Notify Document that the listener has vanished. We need to keep tr ack of a number of 2001 // FIXME: Notify Document that the listener has vanished. We need to keep tr ack of a number of
2018 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh ow_bug.cgi?id=33861 2002 // listeners for each type, not just a bool - see https://bugs.webkit.org/sh ow_bug.cgi?id=33861
2019 Document& document = targetNode->document(); 2003 Document& document = targetNode->document();
2020 if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mouse wheel) 2004 if (isTouchEventType(eventType))
2021 WheelController::from(document)->didRemoveWheelEventHandler(document);
2022 else if (isTouchEventType(eventType))
2023 document.didRemoveTouchEventHandler(targetNode); 2005 document.didRemoveTouchEventHandler(targetNode);
2024 if (document.frameHost()) 2006 if (document.frameHost())
2025 document.frameHost()->eventHandlerRegistry().didRemoveEventHandler(*targ etNode, eventType); 2007 document.frameHost()->eventHandlerRegistry().didRemoveEventHandler(*targ etNode, eventType);
2026 2008
2027 return true; 2009 return true;
2028 } 2010 }
2029 2011
2030 bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis tener, bool useCapture) 2012 bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis tener, bool useCapture)
2031 { 2013 {
2032 return tryRemoveEventListener(this, eventType, listener, useCapture); 2014 return tryRemoveEventListener(this, eventType, listener, useCapture);
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
2596 node->showTreeForThis(); 2578 node->showTreeForThis();
2597 } 2579 }
2598 2580
2599 void showNodePath(const WebCore::Node* node) 2581 void showNodePath(const WebCore::Node* node)
2600 { 2582 {
2601 if (node) 2583 if (node)
2602 node->showNodePathForThis(); 2584 node->showNodePathForThis();
2603 } 2585 }
2604 2586
2605 #endif 2587 #endif
OLDNEW
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/dom/WheelController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698