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

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

Issue 1479923002: Enumerate the return value of dispatchEvent so it is clear. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_passive_uma_add
Patch Set: Add back the EventDispatchResult enum Created 4 years, 10 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
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 2025 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 2036
2037 fireEventListeners(&event); 2037 fireEventListeners(&event);
2038 } 2038 }
2039 2039
2040 void Node::dispatchScopedEvent(PassRefPtrWillBeRawPtr<Event> event) 2040 void Node::dispatchScopedEvent(PassRefPtrWillBeRawPtr<Event> event)
2041 { 2041 {
2042 event->setTrusted(true); 2042 event->setTrusted(true);
2043 EventDispatcher::dispatchScopedEvent(*this, event->createMediator()); 2043 EventDispatcher::dispatchScopedEvent(*this, event->createMediator());
2044 } 2044 }
2045 2045
2046 bool Node::dispatchEventInternal(PassRefPtrWillBeRawPtr<Event> event) 2046 EventTarget::DispatchEventResult Node::dispatchEventInternal(PassRefPtrWillBeRaw Ptr<Event> event)
2047 { 2047 {
2048 return EventDispatcher::dispatchEvent(*this, event->createMediator()); 2048 return EventDispatcher::dispatchEvent(*this, event->createMediator());
2049 } 2049 }
2050 2050
2051 void Node::dispatchSubtreeModifiedEvent() 2051 void Node::dispatchSubtreeModifiedEvent()
2052 { 2052 {
2053 if (isInShadowTree()) 2053 if (isInShadowTree())
2054 return; 2054 return;
2055 2055
2056 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 2056 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
2057 2057
2058 if (!document().hasListenerType(Document::DOMSUBTREEMODIFIED_LISTENER)) 2058 if (!document().hasListenerType(Document::DOMSUBTREEMODIFIED_LISTENER))
2059 return; 2059 return;
2060 2060
2061 dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMSubtreeModified , true)); 2061 dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMSubtreeModified , true));
2062 } 2062 }
2063 2063
2064 bool Node::dispatchDOMActivateEvent(int detail, PassRefPtrWillBeRawPtr<Event> un derlyingEvent) 2064 EventTarget::DispatchEventResult Node::dispatchDOMActivateEvent(int detail, Pass RefPtrWillBeRawPtr<Event> underlyingEvent)
2065 { 2065 {
2066 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 2066 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
2067 RefPtrWillBeRawPtr<UIEvent> event = UIEvent::create(EventTypeNames::DOMActiv ate, true, true, document().domWindow(), detail); 2067 RefPtrWillBeRawPtr<UIEvent> event = UIEvent::create(EventTypeNames::DOMActiv ate, true, true, document().domWindow(), detail);
2068 event->setUnderlyingEvent(underlyingEvent); 2068 event->setUnderlyingEvent(underlyingEvent);
2069 dispatchScopedEvent(event); 2069 dispatchScopedEvent(event);
2070 return event->defaultHandled(); 2070
2071 // TODO(dtapuska): Dispatching scoped events shouldn't check the return
2072 // type because the scoped event could get put off in the delayed queue.
2073 return event->eventResult();
2071 } 2074 }
2072 2075
2073 bool Node::dispatchMouseEvent(const PlatformMouseEvent& nativeEvent, const Atomi cString& eventType, 2076 EventTarget::DispatchEventResult Node::dispatchMouseEvent(const PlatformMouseEve nt& nativeEvent, const AtomicString& eventType,
2074 int detail, Node* relatedTarget) 2077 int detail, Node* relatedTarget)
2075 { 2078 {
2076 RefPtrWillBeRawPtr<MouseEvent> event = MouseEvent::create(eventType, documen t().domWindow(), nativeEvent, detail, relatedTarget); 2079 RefPtrWillBeRawPtr<MouseEvent> event = MouseEvent::create(eventType, documen t().domWindow(), nativeEvent, detail, relatedTarget);
2077 return dispatchEvent(event); 2080 return dispatchEvent(event);
2078 } 2081 }
2079 2082
2080 void Node::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEve ntOptions eventOptions, SimulatedClickCreationScope scope) 2083 void Node::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEve ntOptions eventOptions, SimulatedClickCreationScope scope)
2081 { 2084 {
2082 EventDispatcher::dispatchSimulatedClick(*this, underlyingEvent, eventOptions , scope); 2085 EventDispatcher::dispatchSimulatedClick(*this, underlyingEvent, eventOptions , scope);
2083 } 2086 }
2084 2087
2085 void Node::dispatchInputEvent() 2088 void Node::dispatchInputEvent()
2086 { 2089 {
2087 dispatchScopedEvent(Event::createBubble(EventTypeNames::input)); 2090 dispatchScopedEvent(Event::createBubble(EventTypeNames::input));
2088 } 2091 }
2089 2092
2090 void Node::defaultEventHandler(Event* event) 2093 void Node::defaultEventHandler(Event* event)
2091 { 2094 {
2092 if (event->target() != this) 2095 if (event->target() != this)
2093 return; 2096 return;
2094 const AtomicString& eventType = event->type(); 2097 const AtomicString& eventType = event->type();
2095 if (eventType == EventTypeNames::keydown || eventType == EventTypeNames::key press) { 2098 if (eventType == EventTypeNames::keydown || eventType == EventTypeNames::key press) {
2096 if (event->isKeyboardEvent()) { 2099 if (event->isKeyboardEvent()) {
2097 if (LocalFrame* frame = document().frame()) 2100 if (LocalFrame* frame = document().frame())
2098 frame->eventHandler().defaultKeyboardEventHandler(toKeyboardEven t(event)); 2101 frame->eventHandler().defaultKeyboardEventHandler(toKeyboardEven t(event));
2099 } 2102 }
2100 } else if (eventType == EventTypeNames::click) { 2103 } else if (eventType == EventTypeNames::click) {
2101 int detail = event->isUIEvent() ? static_cast<UIEvent*>(event)->detail() : 0; 2104 int detail = event->isUIEvent() ? static_cast<UIEvent*>(event)->detail() : 0;
2102 if (dispatchDOMActivateEvent(detail, event)) 2105 if (dispatchDOMActivateEvent(detail, event) != EventTarget::DispatchEven tResult::NotHandled)
2103 event->setDefaultHandled(); 2106 event->setDefaultHandled();
2104 } else if (eventType == EventTypeNames::contextmenu) { 2107 } else if (eventType == EventTypeNames::contextmenu) {
2105 if (Page* page = document().page()) 2108 if (Page* page = document().page())
2106 page->contextMenuController().handleContextMenuEvent(event); 2109 page->contextMenuController().handleContextMenuEvent(event);
2107 } else if (eventType == EventTypeNames::textInput) { 2110 } else if (eventType == EventTypeNames::textInput) {
2108 if (event->hasInterface(EventNames::TextEvent)) { 2111 if (event->hasInterface(EventNames::TextEvent)) {
2109 if (LocalFrame* frame = document().frame()) 2112 if (LocalFrame* frame = document().frame())
2110 frame->eventHandler().defaultTextInputEventHandler(toTextEvent(e vent)); 2113 frame->eventHandler().defaultTextInputEventHandler(toTextEvent(e vent));
2111 } 2114 }
2112 #if OS(WIN) 2115 #if OS(WIN)
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2432 2435
2433 void showNodePath(const blink::Node* node) 2436 void showNodePath(const blink::Node* node)
2434 { 2437 {
2435 if (node) 2438 if (node)
2436 node->showNodePathForThis(); 2439 node->showNodePathForThis();
2437 else 2440 else
2438 fprintf(stderr, "Cannot showNodePath for (nil)\n"); 2441 fprintf(stderr, "Cannot showNodePath for (nil)\n");
2439 } 2442 }
2440 2443
2441 #endif 2444 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698