summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-11 00:37:15 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-11 00:37:15 +0000
commit553aabb40b432ecdc2c289c935ba77874928dfcc (patch)
tree7ecabde66cc28677bc092a715c2a1228cac80ba5 /chrome/browser/autocomplete/autocomplete_edit_view_win.cc
parent2ca83cd871de1a2c322a48b80d06f4d3c8bb6923 (diff)
downloadchromium_src-553aabb40b432ecdc2c289c935ba77874928dfcc.zip
chromium_src-553aabb40b432ecdc2c289c935ba77874928dfcc.tar.gz
chromium_src-553aabb40b432ecdc2c289c935ba77874928dfcc.tar.bz2
Makes the instant suggested text autocomplete after 1.3 seconds. There
are a number of parts of this patch that need work, but it should be good enough for us to decide if we want to pursue it. BUG=none TEST=none Review URL: http://codereview.chromium.org/4385001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65741 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_edit_view_win.cc')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.cc42
1 files changed, 17 insertions, 25 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
index b76a2b5..75e96d5 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
@@ -22,7 +22,6 @@
#include "app/win/drag_source.h"
#include "app/win/drop_target.h"
#include "app/win/iat_patch_function.h"
-#include "app/win/scoped_prop.h"
#include "base/auto_reset.h"
#include "base/basictypes.h"
#include "base/i18n/rtl.h"
@@ -439,10 +438,6 @@ AutocompleteEditViewWin::AutocompleteEditViewWin(
SendMessage(m_hWnd, EM_SETWORDBREAKPROC, 0,
reinterpret_cast<LPARAM>(&WordBreakProc));
- // Makes it EN_SELCHANGE is sent to our parent window and back to us by way of
- // ProcessWindowMessage.
- SetEventMask(ENM_SELCHANGE);
-
// Get the metrics for the font.
HDC dc = ::GetDC(NULL);
SelectObject(dc, font_.GetNativeFont());
@@ -473,9 +468,6 @@ AutocompleteEditViewWin::AutocompleteEditViewWin(
SetBackgroundColor(background_color_);
- message_handler_prop_.reset(
- views::ChildWindowMessageProcessor::Register(m_hWnd, this));
-
// By default RichEdit has a drop target. Revoke it so that we can install our
// own. Revoke takes care of deleting the existing one.
RevokeDragDrop(m_hWnd);
@@ -660,6 +652,20 @@ void AutocompleteEditViewWin::SetWindowTextAndCaretPos(const std::wstring& text,
PlaceCaretAt(caret_pos);
}
+void AutocompleteEditViewWin::ReplaceSelection(const string16& text) {
+ CHARRANGE selection;
+ GetSel(selection);
+ if (selection.cpMin == selection.cpMax && text.empty())
+ return;
+
+ const std::wstring w_text(UTF16ToWide(text));
+ ScopedFreeze freeze(this, GetTextObjectModel());
+ OnBeforePossibleChange();
+ ReplaceSel(w_text.c_str(), TRUE);
+ SetSelection(selection.cpMin, selection.cpMin + w_text.size());
+ OnAfterPossibleChange();
+}
+
void AutocompleteEditViewWin::SetForcedQuery() {
const std::wstring current_text(GetText());
const size_t start = current_text.find_first_not_of(kWhitespaceWide);
@@ -894,6 +900,9 @@ bool AutocompleteEditViewWin::OnAfterPossibleChange() {
const bool something_changed = model_->OnAfterPossibleChange(new_text,
selection_differs, text_differs, just_deleted_text, at_end_of_edit);
+ if (selection_differs)
+ controller_->OnSelectionBoundsChanged();
+
if (something_changed && text_differs)
TextChanged();
@@ -1064,19 +1073,6 @@ void AutocompleteEditViewWin::ExecuteCommand(int command_id) {
OnAfterPossibleChange();
}
-bool AutocompleteEditViewWin::ProcessMessage(UINT message,
- WPARAM w_param,
- LPARAM l_param,
- LRESULT* result) {
- if (message == WM_NOTIFY) {
- NMHDR* header = reinterpret_cast<NMHDR*>(l_param);
- if (header->code == EN_SELCHANGE) {
- // TODO(sky): wire this up.
- }
- }
- return false;
-}
-
// static
int CALLBACK AutocompleteEditViewWin::WordBreakProc(LPTSTR edit_text,
int current_pos,
@@ -1267,10 +1263,6 @@ void AutocompleteEditViewWin::OnCut() {
ReplaceSel(L"", true);
}
-void AutocompleteEditViewWin::OnDestroy() {
- message_handler_prop_.reset();
-}
-
LRESULT AutocompleteEditViewWin::OnGetObject(UINT uMsg,
WPARAM wparam,
LPARAM lparam) {