| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 tracking_double_click_(false), | 412 tracking_double_click_(false), |
| 413 double_click_time_(0), | 413 double_click_time_(0), |
| 414 can_discard_mousemove_(false), | 414 can_discard_mousemove_(false), |
| 415 ignore_ime_messages_(false), | 415 ignore_ime_messages_(false), |
| 416 delete_at_end_pressed_(false), | 416 delete_at_end_pressed_(false), |
| 417 font_(font), | 417 font_(font), |
| 418 possible_drag_(false), | 418 possible_drag_(false), |
| 419 in_drag_(false), | 419 in_drag_(false), |
| 420 initiated_drag_(false), | 420 initiated_drag_(false), |
| 421 drop_highlight_position_(-1), | 421 drop_highlight_position_(-1), |
| 422 ime_candidate_window_open_(false), |
| 422 background_color_(skia::SkColorToCOLORREF(LocationBarView::GetColor( | 423 background_color_(skia::SkColorToCOLORREF(LocationBarView::GetColor( |
| 423 ToolbarModel::NONE, LocationBarView::BACKGROUND))), | 424 ToolbarModel::NONE, LocationBarView::BACKGROUND))), |
| 424 security_level_(ToolbarModel::NONE), | 425 security_level_(ToolbarModel::NONE), |
| 425 text_object_model_(NULL) { | 426 text_object_model_(NULL) { |
| 426 // Dummy call to a function exported by riched20.dll to ensure it sets up an | 427 // Dummy call to a function exported by riched20.dll to ensure it sets up an |
| 427 // import dependency on the dll. | 428 // import dependency on the dll. |
| 428 CreateTextServices(NULL, NULL, NULL); | 429 CreateTextServices(NULL, NULL, NULL); |
| 429 | 430 |
| 430 saved_selection_for_focus_change_.cpMin = -1; | 431 saved_selection_for_focus_change_.cpMin = -1; |
| 431 | 432 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 ClosePopup(); | 687 ClosePopup(); |
| 687 model_->Revert(); | 688 model_->Revert(); |
| 688 saved_selection_for_focus_change_.cpMin = -1; | 689 saved_selection_for_focus_change_.cpMin = -1; |
| 689 TextChanged(); | 690 TextChanged(); |
| 690 } | 691 } |
| 691 | 692 |
| 692 void OmniboxViewWin::UpdatePopup() { | 693 void OmniboxViewWin::UpdatePopup() { |
| 693 ScopedFreeze freeze(this, GetTextObjectModel()); | 694 ScopedFreeze freeze(this, GetTextObjectModel()); |
| 694 model_->SetInputInProgress(true); | 695 model_->SetInputInProgress(true); |
| 695 | 696 |
| 697 // Don't allow the popup to open while the candidate window is open, so |
| 698 // they don't overlap. |
| 699 if (ime_candidate_window_open_) |
| 700 return; |
| 701 |
| 696 if (!model_->has_focus()) { | 702 if (!model_->has_focus()) { |
| 697 // When we're in the midst of losing focus, don't rerun autocomplete. This | 703 // When we're in the midst of losing focus, don't rerun autocomplete. This |
| 698 // can happen when losing focus causes the IME to cancel/finalize a | 704 // can happen when losing focus causes the IME to cancel/finalize a |
| 699 // composition. We still want to note that user input is in progress, we | 705 // composition. We still want to note that user input is in progress, we |
| 700 // just don't want to do anything else. | 706 // just don't want to do anything else. |
| 701 // | 707 // |
| 702 // Note that in this case the ScopedFreeze above was unnecessary; however, | 708 // Note that in this case the ScopedFreeze above was unnecessary; however, |
| 703 // we're inside the callstack of OnKillFocus(), which has already frozen the | 709 // we're inside the callstack of OnKillFocus(), which has already frozen the |
| 704 // edit, so this will never result in an unnecessary UpdateWindow() call. | 710 // edit, so this will never result in an unnecessary UpdateWindow() call. |
| 705 return; | 711 return; |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1363 ScopedFreeze freeze(this, GetTextObjectModel()); | 1369 ScopedFreeze freeze(this, GetTextObjectModel()); |
| 1364 OnBeforePossibleChange(); | 1370 OnBeforePossibleChange(); |
| 1365 LRESULT result = DefWindowProc(message, wparam, lparam); | 1371 LRESULT result = DefWindowProc(message, wparam, lparam); |
| 1366 // Force an IME composition confirmation operation to trigger the text_changed | 1372 // Force an IME composition confirmation operation to trigger the text_changed |
| 1367 // code in OnAfterPossibleChange(), even if identical contents are confirmed, | 1373 // code in OnAfterPossibleChange(), even if identical contents are confirmed, |
| 1368 // to make sure the model can update its internal states correctly. | 1374 // to make sure the model can update its internal states correctly. |
| 1369 OnAfterPossibleChangeInternal((lparam & GCS_RESULTSTR) != 0); | 1375 OnAfterPossibleChangeInternal((lparam & GCS_RESULTSTR) != 0); |
| 1370 return result; | 1376 return result; |
| 1371 } | 1377 } |
| 1372 | 1378 |
| 1379 LRESULT OmniboxViewWin::OnImeNotify(UINT message, |
| 1380 WPARAM wparam, |
| 1381 LPARAM lparam) { |
| 1382 // Close the popup when the IME composition window is open, so they don't |
| 1383 // overlap. |
| 1384 switch (wparam) { |
| 1385 case IMN_OPENCANDIDATE: |
| 1386 ime_candidate_window_open_ = true; |
| 1387 ClosePopup(); |
| 1388 break; |
| 1389 case IMN_CLOSECANDIDATE: |
| 1390 ime_candidate_window_open_ = false; |
| 1391 UpdatePopup(); |
| 1392 break; |
| 1393 default: |
| 1394 break; |
| 1395 } |
| 1396 return DefWindowProc(message, wparam, lparam); |
| 1397 } |
| 1398 |
| 1373 void OmniboxViewWin::OnKeyDown(TCHAR key, | 1399 void OmniboxViewWin::OnKeyDown(TCHAR key, |
| 1374 UINT repeat_count, | 1400 UINT repeat_count, |
| 1375 UINT flags) { | 1401 UINT flags) { |
| 1376 delete_at_end_pressed_ = false; | 1402 delete_at_end_pressed_ = false; |
| 1377 | 1403 |
| 1378 if (OnKeyDownAllModes(key, repeat_count, flags)) | 1404 if (OnKeyDownAllModes(key, repeat_count, flags)) |
| 1379 return; | 1405 return; |
| 1380 | 1406 |
| 1381 // Make sure that we handle system key events like Alt-F4. | 1407 // Make sure that we handle system key events like Alt-F4. |
| 1382 if (popup_window_mode_) { | 1408 if (popup_window_mode_) { |
| (...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2612 // PosFromChar(i) might return 0 when i is greater than 1. | 2638 // PosFromChar(i) might return 0 when i is greater than 1. |
| 2613 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2639 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
| 2614 } | 2640 } |
| 2615 | 2641 |
| 2616 bool OmniboxViewWin::IsCaretAtEnd() const { | 2642 bool OmniboxViewWin::IsCaretAtEnd() const { |
| 2617 long length = GetTextLength(); | 2643 long length = GetTextLength(); |
| 2618 CHARRANGE sel; | 2644 CHARRANGE sel; |
| 2619 GetSelection(sel); | 2645 GetSelection(sel); |
| 2620 return sel.cpMin == sel.cpMax && sel.cpMin == length; | 2646 return sel.cpMin == sel.cpMax && sel.cpMin == length; |
| 2621 } | 2647 } |
| OLD | NEW |