Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_win.cc

Issue 11093044: Fix omnibox suggestion: restore selection on WM_IME_ENDCOMPOSITION (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Restore selection Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <locale> 8 #include <locale>
9 #include <string> 9 #include <string>
10 10
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 ScopedFreeze freeze(this, GetTextObjectModel()); 1411 ScopedFreeze freeze(this, GetTextObjectModel());
1412 OnBeforePossibleChange(); 1412 OnBeforePossibleChange();
1413 LRESULT result = DefWindowProc(message, wparam, lparam); 1413 LRESULT result = DefWindowProc(message, wparam, lparam);
1414 // Force an IME composition confirmation operation to trigger the text_changed 1414 // Force an IME composition confirmation operation to trigger the text_changed
1415 // code in OnAfterPossibleChange(), even if identical contents are confirmed, 1415 // code in OnAfterPossibleChange(), even if identical contents are confirmed,
1416 // to make sure the model can update its internal states correctly. 1416 // to make sure the model can update its internal states correctly.
1417 OnAfterPossibleChangeInternal((lparam & GCS_RESULTSTR) != 0); 1417 OnAfterPossibleChangeInternal((lparam & GCS_RESULTSTR) != 0);
1418 return result; 1418 return result;
1419 } 1419 }
1420 1420
1421
1422 LRESULT OmniboxViewWin::OnImeEndComposition(UINT message, WPARAM wparam,
1423 LPARAM lparam) {
1424 // Unlike RichEdit 2.0, RichEdit 4.1 clears the selection when it receives
Peter Kasting 2012/10/12 03:29:46 Nit: Slightly better: // The edit control auto-
Seigo Nonaka 2012/10/12 03:58:07 Updated, thanks. On 2012/10/12 03:29:46, Peter Kas
1425 // WM_IME_ENDCOMPOSITION. Here we need to restore the selection manually.
1426 CHARRANGE range;
1427 GetSel(range);
1428 LRESULT result = DefWindowProc(message, wparam, lparam);
1429 SetSel(range);
1430 return result;
1431 }
1432
1421 LRESULT OmniboxViewWin::OnImeNotify(UINT message, 1433 LRESULT OmniboxViewWin::OnImeNotify(UINT message,
1422 WPARAM wparam, 1434 WPARAM wparam,
1423 LPARAM lparam) { 1435 LPARAM lparam) {
1424 // Close the popup when the IME composition window is open, so they don't 1436 // Close the popup when the IME composition window is open, so they don't
1425 // overlap. 1437 // overlap.
1426 switch (wparam) { 1438 switch (wparam) {
1427 case IMN_OPENCANDIDATE: 1439 case IMN_OPENCANDIDATE:
1428 ime_candidate_window_open_ = true; 1440 ime_candidate_window_open_ = true;
1429 CloseOmniboxPopup(); 1441 CloseOmniboxPopup();
1430 break; 1442 break;
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after
2679 return (rect.left - client_rect.left) + (client_rect.right - rect.right); 2691 return (rect.left - client_rect.left) + (client_rect.right - rect.right);
2680 } 2692 }
2681 2693
2682 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { 2694 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const {
2683 // Use font_.GetStringWidth() instead of 2695 // Use font_.GetStringWidth() instead of
2684 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is 2696 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is
2685 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, 2697 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout,
2686 // PosFromChar(i) might return 0 when i is greater than 1. 2698 // PosFromChar(i) might return 0 when i is greater than 1.
2687 return font_.GetStringWidth(text) + GetHorizontalMargin(); 2699 return font_.GetStringWidth(text) + GetHorizontalMargin();
2688 } 2700 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698