diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-20 01:28:55 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-20 01:28:55 +0000 |
commit | 2cd7eb8743299ff81a2c7054650b21c5a11dd376 (patch) | |
tree | c9001e097fa526b0488385a08b6adc9b0c9f1584 /webkit/glue/editor_client_impl.h | |
parent | 5c6f1c6b32f9da207706cf2d94560196e9d20303 (diff) | |
download | chromium_src-2cd7eb8743299ff81a2c7054650b21c5a11dd376.zip chromium_src-2cd7eb8743299ff81a2c7054650b21c5a11dd376.tar.gz chromium_src-2cd7eb8743299ff81a2c7054650b21c5a11dd376.tar.bz2 |
A new implementation of the autofill using the editor client API.
This simplifies code as we don't need to listen for events on input elements, the editor client API is only triggered when the text changes.
The only quirk we have to work around is that when the editor client API notifies us that the text has changed, the selection is not set properly, preventing us from reliably finding out if the caret is at the end of the text.
To work around that issue, we post a task that does the autofill after the text change callback.
BUG=None
TEST=Trigger the autofill behavior with form and passwords.
Review URL: http://codereview.chromium.org/11479
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5742 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/editor_client_impl.h')
-rw-r--r-- | webkit/glue/editor_client_impl.h | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/webkit/glue/editor_client_impl.h b/webkit/glue/editor_client_impl.h index 189a9af..4d0f057 100644 --- a/webkit/glue/editor_client_impl.h +++ b/webkit/glue/editor_client_impl.h @@ -6,6 +6,7 @@ #define WEBKIT_GLUE_EDITOR_CLIENT_IMPL_H__ #include "base/compiler_specific.h" +#include "base/task.h" #include "build/build_config.h" @@ -17,6 +18,7 @@ MSVC_POP_WARNING(); namespace WebCore { class Frame; +class HTMLInputElement; class Node; class PlatformKeyboardEvent; } @@ -103,9 +105,6 @@ class EditorClientImpl : public WebCore::EditorClient { virtual void setInputMethodState(bool enabled); void SetUseEditorDelegate(bool value) { use_editor_delegate_ = value; } - // HACK for webkit bug #16976. - // TODO (timsteele): Clean this up once webkit bug 16976 is fixed. - void PreserveSelection(); // It would be better to add these methods to the objects they describe, but // those are in WebCore and therefore inaccessible. @@ -123,21 +122,23 @@ class EditorClientImpl : public WebCore::EditorClient { void ModifySelection(WebCore::Frame* frame, WebCore::KeyboardEvent* event); + void DoAutofill(WebCore::HTMLInputElement* input_element, bool backspace); + protected: WebViewImpl* web_view_; bool use_editor_delegate_; bool in_redo_; - // Should preserve the selection in next call to shouldChangeSelectedRange. - bool preserve_; - - // Points to an HTMLInputElement that was just autocompleted (else NULL), - // for use by respondToChangedContents(). - WebCore::Element* pending_inline_autocompleted_element_; - typedef std::deque<WTF::RefPtr<WebCore::EditCommand> > EditCommandStack; EditCommandStack undo_stack_; EditCommandStack redo_stack_; + + private: + // Whether the last entered key was a backspace. + bool backspace_pressed_; + + // The method factory used to post autofill related tasks. + ScopedRunnableMethodFactory<EditorClientImpl> autofill_factory_; }; #endif // WEBKIT_GLUE_EDITOR_CLIENT_IMPL_H__ |