OLD | NEW |
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 Loading... |
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 // The edit control auto-clears the selection on WM_IME_ENDCOMPOSITION, which |
| 1425 // means any inline autocompletion we were showing will no longer be |
| 1426 // selected, and therefore no longer replaced by further user typing. To |
| 1427 // avoid this we manually restore the original selection after the edit |
| 1428 // handles the message. |
| 1429 CHARRANGE range; |
| 1430 GetSel(range); |
| 1431 LRESULT result = DefWindowProc(message, wparam, lparam); |
| 1432 SetSel(range); |
| 1433 return result; |
| 1434 } |
| 1435 |
1421 LRESULT OmniboxViewWin::OnImeNotify(UINT message, | 1436 LRESULT OmniboxViewWin::OnImeNotify(UINT message, |
1422 WPARAM wparam, | 1437 WPARAM wparam, |
1423 LPARAM lparam) { | 1438 LPARAM lparam) { |
1424 // Close the popup when the IME composition window is open, so they don't | 1439 // Close the popup when the IME composition window is open, so they don't |
1425 // overlap. | 1440 // overlap. |
1426 switch (wparam) { | 1441 switch (wparam) { |
1427 case IMN_OPENCANDIDATE: | 1442 case IMN_OPENCANDIDATE: |
1428 ime_candidate_window_open_ = true; | 1443 ime_candidate_window_open_ = true; |
1429 CloseOmniboxPopup(); | 1444 CloseOmniboxPopup(); |
1430 break; | 1445 break; |
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2679 return (rect.left - client_rect.left) + (client_rect.right - rect.right); | 2694 return (rect.left - client_rect.left) + (client_rect.right - rect.right); |
2680 } | 2695 } |
2681 | 2696 |
2682 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { | 2697 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { |
2683 // Use font_.GetStringWidth() instead of | 2698 // Use font_.GetStringWidth() instead of |
2684 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is | 2699 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is |
2685 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, | 2700 // 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. | 2701 // PosFromChar(i) might return 0 when i is greater than 1. |
2687 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2702 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
2688 } | 2703 } |
OLD | NEW |