Changeset 82891 in webkit
- Timestamp:
- Apr 4, 2011 4:23:06 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r82890 r82891 1 2011-04-04 Dimitri Glazkov <dglazkov@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 Introduce EventDispatchMediator abstraction, which encapsulate all 6 non-trivial logic around firing a specific type of an event. 7 https://bugs.webkit.org/show_bug.cgi?id=57562 8 9 Refactoring, covered by existing tests. 10 11 * dom/Event.cpp: 12 (WebCore::EventDispatchMediator::EventDispatchMediator): Added. 13 (WebCore::EventDispatchMediator::~EventDispatchMediator): Added. 14 (WebCore::EventDispatchMediator::dispatchEvent): Added. 15 (WebCore::EventDispatchMediator::event): Added. 16 * dom/Event.h: Added decl. 17 * dom/EventDispatcher.cpp: 18 (WebCore::EventDispatcher::dispatchEvent): Changed to use EventDispatchMediator. 19 * dom/EventDispatcher.h: Updated decls. 20 * dom/KeyboardEvent.cpp: 21 (WebCore::KeyboardEventDispatchMediator::KeyboardEventDispatchMediator): Added. 22 (WebCore::KeyboardEventDispatchMediator::dispatchEvent): Added. 23 * dom/KeyboardEvent.h: Updated decls 24 * dom/Node.cpp: 25 (WebCore::Node::dispatchEvent): Changed to use EventDispatchMediator. 26 (WebCore::Node::dispatchKeyEvent): Changed to use KeyboardEventDispatchMediator. 27 1 28 2011-04-04 Martin Robinson <mrobinson@igalia.com> 2 29 -
trunk/Source/WebCore/dom/Event.cpp
r82264 r82891 272 272 } 273 273 274 bool Event::dispatch(EventDispatcher* dispatcher)275 {276 return dispatcher->dispatchEvent(this);277 }278 279 274 void Event::setTarget(PassRefPtr<EventTarget> target) 280 275 { … … 300 295 } 301 296 297 EventDispatchMediator::EventDispatchMediator(PassRefPtr<Event> event) 298 : m_event(event) 299 { 300 } 301 302 EventDispatchMediator::~EventDispatchMediator() 303 { 304 } 305 306 bool EventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const 307 { 308 return dispatcher->dispatchEvent(m_event.get()); 309 } 310 311 Event* EventDispatchMediator::event() const 312 { 313 return m_event.get(); 314 } 315 302 316 } // namespace WebCore -
trunk/Source/WebCore/dom/Event.h
r82264 r82891 167 167 virtual Clipboard* clipboard() const { return 0; } 168 168 169 virtual bool dispatch(EventDispatcher*);170 169 171 170 protected: … … 195 194 }; 196 195 196 class EventDispatchMediator { 197 public: 198 explicit EventDispatchMediator(PassRefPtr<Event>); 199 virtual ~EventDispatchMediator(); 200 201 virtual bool dispatchEvent(EventDispatcher*) const; 202 Event* event() const; 203 private: 204 RefPtr<Event> m_event; 205 }; 206 197 207 } // namespace WebCore 198 208 -
trunk/Source/WebCore/dom/EventDispatcher.cpp
r82584 r82891 54 54 static HashSet<Node*>* gNodesDispatchingSimulatedClicks = 0; 55 55 56 bool EventDispatcher::dispatchEvent(Node* node, PassRefPtr<Event> prpEvent) 57 { 58 RefPtr<Event> event = prpEvent; 59 56 bool EventDispatcher::dispatchEvent(Node* node, const EventDispatchMediator& mediator) 57 { 60 58 EventDispatcher dispatcher(node); 61 return event->dispatch(&dispatcher);59 return mediator.dispatchEvent(&dispatcher); 62 60 } 63 61 -
trunk/Source/WebCore/dom/EventDispatcher.h
r82376 r82891 34 34 class Event; 35 35 class EventContext; 36 class EventDispatchMediator; 36 37 class EventTarget; 37 38 class FrameView; … … 48 49 class EventDispatcher { 49 50 public: 50 static bool dispatchEvent(Node*, PassRefPtr<Event>);51 static bool dispatchEvent(Node*, const EventDispatchMediator&); 51 52 static void dispatchScopedEvent(Node*, PassRefPtr<Event>); 52 53 -
trunk/Source/WebCore/dom/KeyboardEvent.cpp
r82264 r82891 162 162 } 163 163 164 bool KeyboardEvent::dispatch(EventDispatcher* dispatcher) 164 KeyboardEventDispatchMediator::KeyboardEventDispatchMediator(PassRefPtr<KeyboardEvent> event) 165 : EventDispatchMediator(event) 166 { 167 } 168 169 bool KeyboardEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const 165 170 { 166 171 // Make sure not to return true if we already took default action while handling the event. 167 return dispatcher->dispatchEvent(this) && !defaultHandled();172 return EventDispatchMediator::dispatchEvent(dispatcher) && !event()->defaultHandled(); 168 173 } 169 174 -
trunk/Source/WebCore/dom/KeyboardEvent.h
r82720 r82891 102 102 const String& keyIdentifier, unsigned keyLocation, 103 103 bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, bool altGraphKey); 104 virtual bool dispatch(EventDispatcher*);105 104 106 105 OwnPtr<PlatformKeyboardEvent> m_keyEvent; … … 117 116 KeyboardEvent* findKeyboardEvent(Event*); 118 117 118 class KeyboardEventDispatchMediator : public EventDispatchMediator { 119 public: 120 explicit KeyboardEventDispatchMediator(PassRefPtr<KeyboardEvent>); 121 122 private: 123 virtual bool dispatchEvent(EventDispatcher*) const; 124 }; 125 119 126 } // namespace WebCore 120 127 -
trunk/Source/WebCore/dom/Node.cpp
r82886 r82891 2614 2614 bool Node::dispatchEvent(PassRefPtr<Event> event) 2615 2615 { 2616 return EventDispatcher::dispatchEvent(this, event);2616 return EventDispatcher::dispatchEvent(this, EventDispatchMediator(event)); 2617 2617 } 2618 2618 … … 2646 2646 bool Node::dispatchKeyEvent(const PlatformKeyboardEvent& event) 2647 2647 { 2648 return EventDispatcher::dispatchEvent(this, KeyboardEvent ::create(event, document()->defaultView()));2648 return EventDispatcher::dispatchEvent(this, KeyboardEventDispatchMediator(KeyboardEvent::create(event, document()->defaultView()))); 2649 2649 } 2650 2650
Note: See TracChangeset
for help on using the changeset viewer.