| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Google, Inc. All rights reserved. | 3 * Copyright (C) 2012 Google, Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 if (!Behavior().ShouldInsertCharacter(*evt) || !CanEdit()) | 60 if (!Behavior().ShouldInsertCharacter(*evt) || !CanEdit()) |
| 61 return false; | 61 return false; |
| 62 | 62 |
| 63 const Element* const focused_element = | 63 const Element* const focused_element = |
| 64 frame_->GetDocument()->FocusedElement(); | 64 frame_->GetDocument()->FocusedElement(); |
| 65 if (!focused_element) { | 65 if (!focused_element) { |
| 66 // We may lose focused element by |command.execute(evt)|. | 66 // We may lose focused element by |command.execute(evt)|. |
| 67 return false; | 67 return false; |
| 68 } | 68 } |
| 69 if (!focused_element->ContainsIncludingHostElements( | 69 // We should not insert text at selection start if selection doesn't have |
| 70 *frame_->Selection() | 70 // focus. |
| 71 .ComputeVisibleSelectionInDOMTreeDeprecated() | 71 if (!frame_->Selection().SelectionHasFocus()) |
| 72 .Start() | |
| 73 .ComputeContainerNode())) { | |
| 74 // We should not insert text at selection start if selection doesn't have | |
| 75 // focus. See http://crbug.com/89026 | |
| 76 return false; | 72 return false; |
| 77 } | |
| 78 | 73 |
| 79 // Return true to prevent default action. e.g. Space key scroll. | 74 // Return true to prevent default action. e.g. Space key scroll. |
| 80 if (DispatchBeforeInputInsertText(evt->target()->ToNode(), key_event->text) != | 75 if (DispatchBeforeInputInsertText(evt->target()->ToNode(), key_event->text) != |
| 81 DispatchEventResult::kNotCanceled) | 76 DispatchEventResult::kNotCanceled) |
| 82 return true; | 77 return true; |
| 83 | 78 |
| 84 return InsertText(key_event->text, evt); | 79 return InsertText(key_event->text, evt); |
| 85 } | 80 } |
| 86 | 81 |
| 87 void Editor::HandleKeyboardEvent(KeyboardEvent* evt) { | 82 void Editor::HandleKeyboardEvent(KeyboardEvent* evt) { |
| 88 // Give the embedder a chance to handle the keyboard event. | 83 // Give the embedder a chance to handle the keyboard event. |
| 89 if (Client().HandleKeyboardEvent(frame_) || HandleEditingKeyboardEvent(evt)) | 84 if (Client().HandleKeyboardEvent(frame_) || HandleEditingKeyboardEvent(evt)) |
| 90 evt->SetDefaultHandled(); | 85 evt->SetDefaultHandled(); |
| 91 } | 86 } |
| 92 | 87 |
| 93 } // namespace blink | 88 } // namespace blink |
| OLD | NEW |