| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // The Mac interface forwards most of these commands to the application layer, | 5 // The Mac interface forwards most of these commands to the application layer, |
| 6 // and I'm not really sure what to do about most of them. | 6 // and I'm not really sure what to do about most of them. |
| 7 | 7 |
| 8 #include "config.h" | 8 #include "config.h" |
| 9 #include "webkit/glue/editor_client_impl.h" | 9 #include "webkit/glue/editor_client_impl.h" |
| 10 | 10 |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 } | 604 } |
| 605 return false; | 605 return false; |
| 606 } | 606 } |
| 607 | 607 |
| 608 if (command.execute(evt)) { | 608 if (command.execute(evt)) { |
| 609 WebViewDelegate* d = web_view_->delegate(); | 609 WebViewDelegate* d = web_view_->delegate(); |
| 610 MaybeRecordCommand(d, command_name); | 610 MaybeRecordCommand(d, command_name); |
| 611 return true; | 611 return true; |
| 612 } | 612 } |
| 613 | 613 |
| 614 // Here we need to filter key events. |
| 615 // On Gtk/Linux, it emits key events with ASCII text and ctrl on for ctrl-<x>. |
| 616 // In Webkit, EditorClient::handleKeyboardEvent in |
| 617 // WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp drop such events. |
| 618 // On Mac, it emits key events with ASCII text and meta on for Command-<x>. |
| 619 // These key events should not emit text insert event. |
| 620 // Alt key would be used to insert alternative character, so we should let |
| 621 // through. Also note that Ctrl-Alt combination equals to AltGr key which is |
| 622 // also used to insert alternative character. |
| 623 // http://code.google.com/p/chromium/issues/detail?id=10846 |
| 624 // In summary, we can't think of a scenario where you'd use control w/o alt or |
| 625 // meta to do insertion of a ASCII character. |
| 626 // TODO(ukai): investigate more detail for various keyboard layout. |
| 614 if (evt->keyEvent()->text().length() == 1) { | 627 if (evt->keyEvent()->text().length() == 1) { |
| 615 UChar ch = evt->keyEvent()->text()[0U]; | 628 UChar ch = evt->keyEvent()->text()[0U]; |
| 616 | 629 |
| 617 // Don't insert null or control characters as they can result in | 630 // Don't insert null or control characters as they can result in |
| 618 // unexpected behaviour | 631 // unexpected behaviour |
| 619 if (ch < ' ') | 632 if (ch < ' ') |
| 620 return false; | 633 return false; |
| 634 // Don't insert ASCII character if ctrl w/o alt or meta is on. |
| 635 if (ch < 0x80 && |
| 636 ((evt->keyEvent()->ctrlKey() && !evt->keyEvent()->altKey()) || |
| 637 evt->keyEvent()->metaKey())) |
| 638 return false; |
| 621 } | 639 } |
| 622 | 640 |
| 623 if (!frame->editor()->canEdit()) | 641 if (!frame->editor()->canEdit()) |
| 624 return false; | 642 return false; |
| 625 | 643 |
| 626 return frame->editor()->insertText(evt->keyEvent()->text(), evt); | 644 return frame->editor()->insertText(evt->keyEvent()->text(), evt); |
| 627 } | 645 } |
| 628 | 646 |
| 629 // | 647 // |
| 630 // End of code block subject to Apple, Inc. copyright | 648 // End of code block subject to Apple, Inc. copyright |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 } | 947 } |
| 930 return L"(UNKNOWN AFFINITY)"; | 948 return L"(UNKNOWN AFFINITY)"; |
| 931 } | 949 } |
| 932 | 950 |
| 933 std::wstring EditorClientImpl::Describe(WebCore::CSSStyleDeclaration* style) { | 951 std::wstring EditorClientImpl::Describe(WebCore::CSSStyleDeclaration* style) { |
| 934 // TODO(pamg): Implement me. It's not clear what WebKit produces for this | 952 // TODO(pamg): Implement me. It's not clear what WebKit produces for this |
| 935 // (their [style description] method), and none of the layout tests provide | 953 // (their [style description] method), and none of the layout tests provide |
| 936 // an example. But because none of them use it, it's not yet important. | 954 // an example. But because none of them use it, it's not yet important. |
| 937 return std::wstring(); | 955 return std::wstring(); |
| 938 } | 956 } |
| OLD | NEW |