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

Side by Side Diff: third_party/WebKit/Source/core/input/EventHandler.cpp

Issue 2045603002: Handle the "key" field as opposed to keyIdentifier field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix chromeos Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 2666 matching lines...) Expand 10 before | Expand all | Expand 10 after
2677 2677
2678 PlatformKeyboardEvent keyPressEvent = initialKeyEvent; 2678 PlatformKeyboardEvent keyPressEvent = initialKeyEvent;
2679 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char); 2679 keyPressEvent.disambiguateKeyDownEvent(PlatformEvent::Char);
2680 if (keyPressEvent.text().isEmpty()) 2680 if (keyPressEvent.text().isEmpty())
2681 return WebInputEventResult::NotHandled; 2681 return WebInputEventResult::NotHandled;
2682 KeyboardEvent* keypress = KeyboardEvent::create(keyPressEvent, m_frame->docu ment()->domWindow()); 2682 KeyboardEvent* keypress = KeyboardEvent::create(keyPressEvent, m_frame->docu ment()->domWindow());
2683 keypress->setTarget(node); 2683 keypress->setTarget(node);
2684 return toWebInputEventResult(node->dispatchEvent(keypress)); 2684 return toWebInputEventResult(node->dispatchEvent(keypress));
2685 } 2685 }
2686 2686
2687 static WebFocusType focusDirectionForKey(const AtomicString& keyIdentifier) 2687 static WebFocusType focusDirectionForKey(const String& key)
2688 { 2688 {
2689 DEFINE_STATIC_LOCAL(AtomicString, Down, ("Down"));
2690 DEFINE_STATIC_LOCAL(AtomicString, Up, ("Up"));
2691 DEFINE_STATIC_LOCAL(AtomicString, Left, ("Left"));
2692 DEFINE_STATIC_LOCAL(AtomicString, Right, ("Right"));
2693
2694 WebFocusType retVal = WebFocusTypeNone; 2689 WebFocusType retVal = WebFocusTypeNone;
2695 2690
2696 if (keyIdentifier == Down) 2691 if (key == "ArrowDown")
bokan 2016/06/09 15:51:56 Perhaps these kind of "ArrowDown", "Backspace" typ
dtapuska 2016/06/09 18:20:33 sgtm; I can create a bug for that.
2697 retVal = WebFocusTypeDown; 2692 retVal = WebFocusTypeDown;
2698 else if (keyIdentifier == Up) 2693 else if (key == "ArrowUp")
2699 retVal = WebFocusTypeUp; 2694 retVal = WebFocusTypeUp;
2700 else if (keyIdentifier == Left) 2695 else if (key == "ArrowLeft")
2701 retVal = WebFocusTypeLeft; 2696 retVal = WebFocusTypeLeft;
2702 else if (keyIdentifier == Right) 2697 else if (key == "ArrowRight")
2703 retVal = WebFocusTypeRight; 2698 retVal = WebFocusTypeRight;
2704 2699
2705 return retVal; 2700 return retVal;
2706 } 2701 }
2707 2702
2708 void EventHandler::defaultKeyboardEventHandler(KeyboardEvent* event) 2703 void EventHandler::defaultKeyboardEventHandler(KeyboardEvent* event)
2709 { 2704 {
2710 if (event->type() == EventTypeNames::keydown) { 2705 if (event->type() == EventTypeNames::keydown) {
2711 // Clear caret blinking suspended state to make sure that caret blinks 2706 // Clear caret blinking suspended state to make sure that caret blinks
2712 // when we type again after long pressing on an empty input field. 2707 // when we type again after long pressing on an empty input field.
2713 if (m_frame && m_frame->selection().isCaretBlinkingSuspended()) 2708 if (m_frame && m_frame->selection().isCaretBlinkingSuspended())
2714 m_frame->selection().setCaretBlinkingSuspended(false); 2709 m_frame->selection().setCaretBlinkingSuspended(false);
2715 2710
2716 m_frame->editor().handleKeyboardEvent(event); 2711 m_frame->editor().handleKeyboardEvent(event);
2717 if (event->defaultHandled()) 2712 if (event->defaultHandled())
2718 return; 2713 return;
2719 if (event->keyIdentifier() == "U+0009") { 2714 if (event->key() == "Tab") {
2720 defaultTabEventHandler(event); 2715 defaultTabEventHandler(event);
2721 } else if (event->keyIdentifier() == "U+0008") { 2716 } else if (event->key() == "Backspace") {
2722 defaultBackspaceEventHandler(event); 2717 defaultBackspaceEventHandler(event);
2723 } else if (event->keyIdentifier() == "U+001B") { 2718 } else if (event->key() == "Escape") {
2724 defaultEscapeEventHandler(event); 2719 defaultEscapeEventHandler(event);
2725 } else { 2720 } else {
2726 WebFocusType type = focusDirectionForKey(AtomicString(event->keyIden tifier())); 2721 WebFocusType type = focusDirectionForKey(event->key());
2727 if (type != WebFocusTypeNone) 2722 if (type != WebFocusTypeNone)
2728 defaultArrowEventHandler(type, event); 2723 defaultArrowEventHandler(type, event);
2729 } 2724 }
2730 } 2725 }
2731 if (event->type() == EventTypeNames::keypress) { 2726 if (event->type() == EventTypeNames::keypress) {
2732 m_frame->editor().handleKeyboardEvent(event); 2727 m_frame->editor().handleKeyboardEvent(event);
2733 if (event->defaultHandled()) 2728 if (event->defaultHandled())
2734 return; 2729 return;
2735 if (event->charCode() == ' ') 2730 if (event->charCode() == ' ')
2736 defaultSpaceEventHandler(event); 2731 defaultSpaceEventHandler(event);
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
3151 3146
3152 FrameHost* EventHandler::frameHost() const 3147 FrameHost* EventHandler::frameHost() const
3153 { 3148 {
3154 if (!m_frame->page()) 3149 if (!m_frame->page())
3155 return nullptr; 3150 return nullptr;
3156 3151
3157 return &m_frame->page()->frameHost(); 3152 return &m_frame->page()->frameHost();
3158 } 3153 }
3159 3154
3160 } // namespace blink 3155 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698