Changeset 156372 in webkit
- Timestamp:
- Sep 24, 2013 4:39:51 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r156364 r156372 1 2013-09-24 Andreas Kling <akling@apple.com> 2 3 Move keyboard event dispatch from Node to Element. 4 <https://webkit.org/b/121873> 5 6 Reviewed by Antti Koivisto. 7 8 We only dispatch keyboard events on Elements so that logic shouldn't be in Node. 9 10 * dom/Document.cpp: 11 (WebCore::eventTargetElementForDocument): 12 13 Reworked to return Element instead of Node. 14 15 * dom/Document.h: 16 * dom/Element.h: 17 * dom/Element.cpp: 18 (WebCore::Element::dispatchKeyEvent): 19 20 Moved from Node to Element. 21 22 * editing/AlternativeTextController.cpp: 23 (WebCore::AlternativeTextController::insertDictatedText): 24 * page/EventHandler.cpp: 25 (WebCore::EventHandler::keyEvent): 26 (WebCore::EventHandler::handleTextInputEvent): 27 28 Adjusted for above changes. 29 1 30 2013-09-24 Zoltan Horvath <zoltan@webkit.org> 2 31 -
trunk/Source/WebCore/dom/Document.cpp
r156339 r156372 5735 5735 #endif 5736 5736 5737 Node* eventTargetNodeForDocument(Document* doc)5737 Element* eventTargetElementForDocument(Document* doc) 5738 5738 { 5739 5739 if (!doc) 5740 5740 return 0; 5741 Node* node= doc->focusedElement();5742 if (! node&& doc->isPluginDocument()) {5741 Element* element = doc->focusedElement(); 5742 if (!element && doc->isPluginDocument()) { 5743 5743 PluginDocument* pluginDocument = toPluginDocument(doc); 5744 node= pluginDocument->pluginElement();5745 } 5746 if (! node&& doc->isHTMLDocument())5747 node= doc->body();5748 if (! node)5749 node= doc->documentElement();5750 return node;5744 element = pluginDocument->pluginElement(); 5745 } 5746 if (!element && doc->isHTMLDocument()) 5747 element = doc->body(); 5748 if (!element) 5749 element = doc->documentElement(); 5750 return element; 5751 5751 } 5752 5752 -
trunk/Source/WebCore/dom/Document.h
r156256 r156372 1643 1643 } 1644 1644 1645 Node* eventTargetNodeForDocument(Document*);1645 Element* eventTargetElementForDocument(Document*); 1646 1646 1647 1647 } // namespace WebCore -
trunk/Source/WebCore/dom/Element.cpp
r156256 r156372 66 66 #include "InsertionPoint.h" 67 67 #include "InspectorInstrumentation.h" 68 #include "KeyboardEvent.h" 68 69 #include "MutationObserverInterestGroup.h" 69 70 #include "MutationRecord.h" … … 239 240 } 240 241 242 bool Element::dispatchKeyEvent(const PlatformKeyboardEvent& event) 243 { 244 return EventDispatcher::dispatchEvent(this, KeyboardEventDispatchMediator::create(KeyboardEvent::create(event, document().defaultView()))); 245 } 246 241 247 void Element::dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions eventOptions, SimulatedClickVisualOptions visualOptions) 242 248 { -
trunk/Source/WebCore/dom/Element.h
r156250 r156372 535 535 void setSavedLayerScrollOffset(const IntSize&); 536 536 537 bool dispatchKeyEvent(const PlatformKeyboardEvent&); 537 538 void dispatchSimulatedClick(Event* underlyingEvent, SimulatedClickMouseEventOptions = SendNoEvents, SimulatedClickVisualOptions = ShowPressedLook); 538 539 void dispatchFocusInEvent(const AtomicString& eventType, PassRefPtr<Element> oldFocusedElement); -
trunk/Source/WebCore/dom/Node.cpp
r156256 r156372 2111 2111 } 2112 2112 2113 bool Node::dispatchKeyEvent(const PlatformKeyboardEvent& event)2114 {2115 return EventDispatcher::dispatchEvent(this, KeyboardEventDispatchMediator::create(KeyboardEvent::create(event, document().defaultView())));2116 }2117 2118 2113 bool Node::dispatchMouseEvent(const PlatformMouseEvent& event, const AtomicString& eventType, 2119 2114 int detail, Node* relatedTarget) -
trunk/Source/WebCore/dom/Node.h
r156250 r156372 550 550 bool dispatchDOMActivateEvent(int detail, PassRefPtr<Event> underlyingEvent); 551 551 552 bool dispatchKeyEvent(const PlatformKeyboardEvent&);553 552 bool dispatchWheelEvent(const PlatformWheelEvent&); 554 553 bool dispatchMouseEvent(const PlatformMouseEvent&, const AtomicString& eventType, int clickCount = 0, Node* relatedTarget = 0); -
trunk/Source/WebCore/editing/AlternativeTextController.cpp
r155228 r156372 34 34 #include "Editor.h" 35 35 #include "EditorClient.h" 36 #include "Element.h" 36 37 #include "Event.h" 37 38 #include "ExceptionCodePlaceholder.h" … … 692 693 target = triggeringEvent->target(); 693 694 else 694 target = eventTarget NodeForDocument(m_frame.document());695 target = eventTargetElementForDocument(m_frame.document()); 695 696 if (!target) 696 697 return false; -
trunk/Source/WebCore/page/EventHandler.cpp
r155548 r156372 3280 3280 // Check for cases where we are too early for events -- possible unmatched key up 3281 3281 // from pressing return in the location bar. 3282 RefPtr< Node> node = eventTargetNodeForDocument(m_frame.document());3283 if (! node)3282 RefPtr<Element> element = eventTargetElementForDocument(m_frame.document()); 3283 if (!element) 3284 3284 return false; 3285 3285 … … 3304 3304 // FIXME: it would be fair to let an input method handle KeyUp events before DOM dispatch. 3305 3305 if (initialKeyEvent.type() == PlatformEvent::KeyUp || initialKeyEvent.type() == PlatformEvent::Char) 3306 return ! node->dispatchKeyEvent(initialKeyEvent);3306 return !element->dispatchKeyEvent(initialKeyEvent); 3307 3307 3308 3308 bool backwardCompatibilityMode = needsKeyboardEventDisambiguationQuirks(); … … 3314 3314 if (matchedAnAccessKey) 3315 3315 keydown->setDefaultPrevented(true); 3316 keydown->setTarget( node);3316 keydown->setTarget(element); 3317 3317 3318 3318 if (initialKeyEvent.type() == PlatformEvent::RawKeyDown) { 3319 node->dispatchEvent(keydown, IGNORE_EXCEPTION);3319 element->dispatchEvent(keydown, IGNORE_EXCEPTION); 3320 3320 // If frame changed as a result of keydown dispatch, then return true to avoid sending a subsequent keypress message to the new frame. 3321 3321 bool changedFocusedFrame = m_frame.page() && &m_frame != &m_frame.page()->focusController().focusedOrMainFrame(); … … 3335 3335 keyDownEvent.setWindowsVirtualKeyCode(CompositionEventKeyCode); 3336 3336 keydown = KeyboardEvent::create(keyDownEvent, m_frame.document()->defaultView()); 3337 keydown->setTarget( node);3337 keydown->setTarget(element); 3338 3338 keydown->setDefaultHandled(); 3339 3339 } 3340 3340 3341 node->dispatchEvent(keydown, IGNORE_EXCEPTION);3341 element->dispatchEvent(keydown, IGNORE_EXCEPTION); 3342 3342 // If frame changed as a result of keydown dispatch, then return early to avoid sending a subsequent keypress message to the new frame. 3343 3343 bool changedFocusedFrame = m_frame.page() && &m_frame != &m_frame.page()->focusController().focusedOrMainFrame(); … … 3346 3346 return keydownResult; 3347 3347 3348 // Focus may have changed during keydown handling, so refetch node.3349 // But if we are dispatching a fake backward compatibility keypress, then we pretend that the keypress happened on the original node.3348 // Focus may have changed during keydown handling, so refetch element. 3349 // But if we are dispatching a fake backward compatibility keypress, then we pretend that the keypress happened on the original element. 3350 3350 if (!keydownResult) { 3351 node = eventTargetNodeForDocument(m_frame.document());3352 if (! node)3351 element = eventTargetElementForDocument(m_frame.document()); 3352 if (!element) 3353 3353 return false; 3354 3354 } … … 3359 3359 return keydownResult; 3360 3360 RefPtr<KeyboardEvent> keypress = KeyboardEvent::create(keyPressEvent, m_frame.document()->defaultView()); 3361 keypress->setTarget( node);3361 keypress->setTarget(element); 3362 3362 if (keydownResult) 3363 3363 keypress->setDefaultPrevented(true); … … 3365 3365 keypress->keypressCommands() = keydown->keypressCommands(); 3366 3366 #endif 3367 node->dispatchEvent(keypress, IGNORE_EXCEPTION);3367 element->dispatchEvent(keypress, IGNORE_EXCEPTION); 3368 3368 3369 3369 return keydownResult || keypress->defaultPrevented() || keypress->defaultHandled(); … … 3705 3705 target = underlyingEvent->target(); 3706 3706 else 3707 target = eventTarget NodeForDocument(m_frame.document());3707 target = eventTargetElementForDocument(m_frame.document()); 3708 3708 if (!target) 3709 3709 return false;
Note: See TracChangeset
for help on using the changeset viewer.