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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 font_(parent_view->font()), | 470 font_(parent_view->font()), |
471 possible_drag_(false), | 471 possible_drag_(false), |
472 in_drag_(false), | 472 in_drag_(false), |
473 initiated_drag_(false), | 473 initiated_drag_(false), |
474 drop_highlight_position_(-1), | 474 drop_highlight_position_(-1), |
475 ime_candidate_window_open_(false), | 475 ime_candidate_window_open_(false), |
476 background_color_(skia::SkColorToCOLORREF(LocationBarView::GetColor( | 476 background_color_(skia::SkColorToCOLORREF(LocationBarView::GetColor( |
477 chrome::search::IsInstantExtendedAPIEnabled(parent_view_->profile()), | 477 chrome::search::IsInstantExtendedAPIEnabled(parent_view_->profile()), |
478 ToolbarModel::NONE, LocationBarView::BACKGROUND))), | 478 ToolbarModel::NONE, LocationBarView::BACKGROUND))), |
479 security_level_(ToolbarModel::NONE), | 479 security_level_(ToolbarModel::NONE), |
480 text_object_model_(NULL) { | 480 text_object_model_(NULL), |
481 in_on_ime_composition_(false) { | |
481 if (!loaded_library_module_) | 482 if (!loaded_library_module_) |
482 loaded_library_module_ = LoadLibrary(kRichEditDLLName); | 483 loaded_library_module_ = LoadLibrary(kRichEditDLLName); |
483 | 484 |
484 saved_selection_for_focus_change_.cpMin = -1; | 485 saved_selection_for_focus_change_.cpMin = -1; |
485 | 486 |
486 g_paint_patcher.Pointer()->RefPatch(); | 487 g_paint_patcher.Pointer()->RefPatch(); |
487 | 488 |
488 Create(location_bar->GetWidget()->GetNativeView(), 0, 0, 0, | 489 Create(location_bar->GetWidget()->GetNativeView(), 0, 0, 0, |
489 l10n_util::GetExtendedStyles()); | 490 l10n_util::GetExtendedStyles()); |
490 SetReadOnly(popup_window_mode_); | 491 SetReadOnly(popup_window_mode_); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
744 return; | 745 return; |
745 } | 746 } |
746 | 747 |
747 // Don't inline autocomplete when: | 748 // Don't inline autocomplete when: |
748 // * The user is deleting text | 749 // * The user is deleting text |
749 // * The caret/selection isn't at the end of the text | 750 // * The caret/selection isn't at the end of the text |
750 // * The user has just pasted in something that replaced all the text | 751 // * The user has just pasted in something that replaced all the text |
751 // * The user is trying to compose something in an IME | 752 // * The user is trying to compose something in an IME |
752 CHARRANGE sel; | 753 CHARRANGE sel; |
753 GetSel(sel); | 754 GetSel(sel); |
755 bool prevent_inline_auto_completion = | |
falken
2012/10/10 09:51:33
nit: I think this can just be prevent_inline_autoc
Seigo Nonaka
2012/10/10 10:18:22
Done.
| |
756 (sel.cpMax < GetTextLength()) || IsImeComposing(); | |
757 | |
758 // SetSel doesn't work when the TSF based text input modules such as CJK | |
759 // on-screen keyboards on Windows 8 insert a character and then CUAS | |
falken
2012/10/10 09:51:33
I think the CUAS acronym isn't widely known. Consi
Seigo Nonaka
2012/10/10 10:18:22
Done.
| |
760 // translates it into IMM32 protocol like WM_IME_COMPOSITION. As a result, | |
falken
2012/10/10 09:51:33
"into an IMM32 protocol message"
Seigo Nonaka
2012/10/10 10:18:22
Done.
| |
761 // auto-completed text will not be updated as expected. To workaround this | |
762 // issue, temporary disable auto-completion during WM_IME_COMPOSITION iff | |
763 // Windows 8. | |
764 // TODO(nona): Re-enable auto-completion for Korean, where this issue is not | |
765 // reproducible for some reasons. | |
766 // TODO(nona): Remove this workaround after fixing crbug.com/154379. | |
767 if (base::win::GetVersion() >= base::win::VERSION_WIN8) | |
768 prevent_inline_auto_completion |= in_on_ime_composition_; | |
754 model()->StartAutocomplete(sel.cpMax != sel.cpMin, | 769 model()->StartAutocomplete(sel.cpMax != sel.cpMin, |
755 (sel.cpMax < GetTextLength()) || IsImeComposing()); | 770 prevent_inline_auto_completion); |
756 } | 771 } |
757 | 772 |
758 void OmniboxViewWin::SetFocus() { | 773 void OmniboxViewWin::SetFocus() { |
759 ::SetFocus(m_hWnd); | 774 ::SetFocus(m_hWnd); |
760 } | 775 } |
761 | 776 |
762 void OmniboxViewWin::SetDropHighlightPosition(int position) { | 777 void OmniboxViewWin::SetDropHighlightPosition(int position) { |
763 if (drop_highlight_position_ != position) { | 778 if (drop_highlight_position_ != position) { |
764 RepaintDropHighlight(drop_highlight_position_); | 779 RepaintDropHighlight(drop_highlight_position_); |
765 drop_highlight_position_ = position; | 780 drop_highlight_position_ = position; |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1401 // This message was sent while we're in the middle of meddling with the | 1416 // This message was sent while we're in the middle of meddling with the |
1402 // underlying edit control. If we handle it below, OnAfterPossibleChange() | 1417 // underlying edit control. If we handle it below, OnAfterPossibleChange() |
1403 // can get bogus text for the edit, and rerun autocomplete, destructively | 1418 // can get bogus text for the edit, and rerun autocomplete, destructively |
1404 // modifying the result set that we're in the midst of using. For example, | 1419 // modifying the result set that we're in the midst of using. For example, |
1405 // if SetWindowTextAndCaretPos() was called due to the user clicking an | 1420 // if SetWindowTextAndCaretPos() was called due to the user clicking an |
1406 // entry in the popup, we're in the middle of executing SetSelectedLine(), | 1421 // entry in the popup, we're in the middle of executing SetSelectedLine(), |
1407 // and changing the results can cause checkfailures. | 1422 // and changing the results can cause checkfailures. |
1408 return DefWindowProc(message, wparam, lparam); | 1423 return DefWindowProc(message, wparam, lparam); |
1409 } | 1424 } |
1410 | 1425 |
1426 in_on_ime_composition_ = true; | |
1411 ScopedFreeze freeze(this, GetTextObjectModel()); | 1427 ScopedFreeze freeze(this, GetTextObjectModel()); |
1412 OnBeforePossibleChange(); | 1428 OnBeforePossibleChange(); |
1413 LRESULT result = DefWindowProc(message, wparam, lparam); | 1429 LRESULT result = DefWindowProc(message, wparam, lparam); |
1414 // Force an IME composition confirmation operation to trigger the text_changed | 1430 // Force an IME composition confirmation operation to trigger the text_changed |
1415 // code in OnAfterPossibleChange(), even if identical contents are confirmed, | 1431 // code in OnAfterPossibleChange(), even if identical contents are confirmed, |
1416 // to make sure the model can update its internal states correctly. | 1432 // to make sure the model can update its internal states correctly. |
1417 OnAfterPossibleChangeInternal((lparam & GCS_RESULTSTR) != 0); | 1433 OnAfterPossibleChangeInternal((lparam & GCS_RESULTSTR) != 0); |
1434 in_on_ime_composition_ = false; | |
1418 return result; | 1435 return result; |
1419 } | 1436 } |
1420 | 1437 |
1421 LRESULT OmniboxViewWin::OnImeNotify(UINT message, | 1438 LRESULT OmniboxViewWin::OnImeNotify(UINT message, |
1422 WPARAM wparam, | 1439 WPARAM wparam, |
1423 LPARAM lparam) { | 1440 LPARAM lparam) { |
1424 // Close the popup when the IME composition window is open, so they don't | 1441 // Close the popup when the IME composition window is open, so they don't |
1425 // overlap. | 1442 // overlap. |
1426 switch (wparam) { | 1443 switch (wparam) { |
1427 case IMN_OPENCANDIDATE: | 1444 case IMN_OPENCANDIDATE: |
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2679 return (rect.left - client_rect.left) + (client_rect.right - rect.right); | 2696 return (rect.left - client_rect.left) + (client_rect.right - rect.right); |
2680 } | 2697 } |
2681 | 2698 |
2682 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { | 2699 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { |
2683 // Use font_.GetStringWidth() instead of | 2700 // Use font_.GetStringWidth() instead of |
2684 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is | 2701 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is |
2685 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, | 2702 // 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. | 2703 // PosFromChar(i) might return 0 when i is greater than 1. |
2687 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2704 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
2688 } | 2705 } |
OLD | NEW |