| 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 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "PlatformKeyboardEvent.h" | 24 #include "PlatformKeyboardEvent.h" |
| 25 #include "PlatformString.h" | 25 #include "PlatformString.h" |
| 26 #include "RenderObject.h" | 26 #include "RenderObject.h" |
| 27 MSVC_POP_WARNING(); | 27 MSVC_POP_WARNING(); |
| 28 | 28 |
| 29 #include "WebKit.h" | 29 #include "WebKit.h" |
| 30 | 30 |
| 31 #undef LOG | 31 #undef LOG |
| 32 #include "base/message_loop.h" | 32 #include "base/message_loop.h" |
| 33 #include "base/string_util.h" | 33 #include "base/string_util.h" |
| 34 #include "webkit/glue/autofill_form.h" |
| 34 #include "webkit/glue/editor_client_impl.h" | 35 #include "webkit/glue/editor_client_impl.h" |
| 35 #include "webkit/glue/glue_util.h" | 36 #include "webkit/glue/glue_util.h" |
| 36 #include "webkit/glue/webkit_glue.h" | 37 #include "webkit/glue/webkit_glue.h" |
| 37 #include "webkit/glue/webview.h" | 38 #include "webkit/glue/webview.h" |
| 38 #include "webkit/glue/webview_impl.h" | 39 #include "webkit/glue/webview_impl.h" |
| 39 | 40 |
| 40 // Arbitrary depth limit for the undo stack, to keep it from using | 41 // Arbitrary depth limit for the undo stack, to keep it from using |
| 41 // unbounded memory. This is the maximum number of distinct undoable | 42 // unbounded memory. This is the maximum number of distinct undoable |
| 42 // actions -- unbroken stretches of typed characters are coalesced | 43 // actions -- unbroken stretches of typed characters are coalesced |
| 43 // into a single action. | 44 // into a single action. |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 bool autofill_on_empty_value) { | 682 bool autofill_on_empty_value) { |
| 682 // Cancel any pending DoAutofill calls. | 683 // Cancel any pending DoAutofill calls. |
| 683 autofill_factory_.RevokeAll(); | 684 autofill_factory_.RevokeAll(); |
| 684 | 685 |
| 685 // Let's try to trigger autofill for that field, if applicable. | 686 // Let's try to trigger autofill for that field, if applicable. |
| 686 if (!input_element->isEnabled() || !input_element->isTextField() || | 687 if (!input_element->isEnabled() || !input_element->isTextField() || |
| 687 input_element->isPasswordField() || !input_element->autoComplete()) { | 688 input_element->isPasswordField() || !input_element->autoComplete()) { |
| 688 return; | 689 return; |
| 689 } | 690 } |
| 690 | 691 |
| 691 std::wstring name = webkit_glue::StringToStdWString(input_element->name()); | 692 std::wstring name = AutofillForm::GetNameForInputElement(input_element); |
| 692 if (name.empty()) // If the field has no name, then we won't have values. | 693 if (name.empty()) // If the field has no name, then we won't have values. |
| 693 return; | 694 return; |
| 694 | 695 |
| 695 // Don't attempt to autofill with values that are too large. | 696 // Don't attempt to autofill with values that are too large. |
| 696 if (input_element->value().length() > kMaximumTextSizeForAutofill) | 697 if (input_element->value().length() > kMaximumTextSizeForAutofill) |
| 697 return; | 698 return; |
| 698 | 699 |
| 699 // We post a task for doing the autofill as the caret position is not set | 700 // We post a task for doing the autofill as the caret position is not set |
| 700 // properly at this point ( http://bugs.webkit.org/show_bug.cgi?id=16976) | 701 // properly at this point ( http://bugs.webkit.org/show_bug.cgi?id=16976) |
| 701 // and we need it to determine whether or not to trigger autofill. | 702 // and we need it to determine whether or not to trigger autofill. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 729 webframe->GetPasswordListener(input_element); | 730 webframe->GetPasswordListener(input_element); |
| 730 if (listener) { | 731 if (listener) { |
| 731 if (backspace) // No autocomplete for password on backspace. | 732 if (backspace) // No autocomplete for password on backspace. |
| 732 return; | 733 return; |
| 733 | 734 |
| 734 listener->OnInlineAutocompleteNeeded(input_element, value); | 735 listener->OnInlineAutocompleteNeeded(input_element, value); |
| 735 return; | 736 return; |
| 736 } | 737 } |
| 737 | 738 |
| 738 // Then trigger form autofill. | 739 // Then trigger form autofill. |
| 739 std::wstring name = webkit_glue::StringToStdWString(input_element-> | 740 std::wstring name = AutofillForm::GetNameForInputElement(input_element); |
| 740 name().string()); | 741 DCHECK_GT(static_cast<int>(name.length()), 0); |
| 741 web_view_->delegate()->QueryFormFieldAutofill(name, value, | 742 web_view_->delegate()->QueryFormFieldAutofill(name, value, |
| 742 reinterpret_cast<int64>(input_element)); | 743 reinterpret_cast<int64>(input_element)); |
| 743 } | 744 } |
| 744 | 745 |
| 745 bool EditorClientImpl::doTextFieldCommandFromEvent( | 746 bool EditorClientImpl::doTextFieldCommandFromEvent( |
| 746 WebCore::Element* element, | 747 WebCore::Element* element, |
| 747 WebCore::KeyboardEvent* event) { | 748 WebCore::KeyboardEvent* event) { |
| 748 // Remember if backspace was pressed for the autofill. It is not clear how to | 749 // Remember if backspace was pressed for the autofill. It is not clear how to |
| 749 // find if backspace was pressed from textFieldDidBeginEditing and | 750 // find if backspace was pressed from textFieldDidBeginEditing and |
| 750 // textDidChangeInTextField as when these methods are called the value of the | 751 // textDidChangeInTextField as when these methods are called the value of the |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 } | 912 } |
| 912 return L"(UNKNOWN AFFINITY)"; | 913 return L"(UNKNOWN AFFINITY)"; |
| 913 } | 914 } |
| 914 | 915 |
| 915 std::wstring EditorClientImpl::Describe(WebCore::CSSStyleDeclaration* style) { | 916 std::wstring EditorClientImpl::Describe(WebCore::CSSStyleDeclaration* style) { |
| 916 // TODO(pamg): Implement me. It's not clear what WebKit produces for this | 917 // TODO(pamg): Implement me. It's not clear what WebKit produces for this |
| 917 // (their [style description] method), and none of the layout tests provide | 918 // (their [style description] method), and none of the layout tests provide |
| 918 // an example. But because none of them use it, it's not yet important. | 919 // an example. But because none of them use it, it's not yet important. |
| 919 return std::wstring(); | 920 return std::wstring(); |
| 920 } | 921 } |
| OLD | NEW |