| 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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 tracking_double_click_(false), | 413 tracking_double_click_(false), |
| 414 double_click_time_(0), | 414 double_click_time_(0), |
| 415 can_discard_mousemove_(false), | 415 can_discard_mousemove_(false), |
| 416 ignore_ime_messages_(false), | 416 ignore_ime_messages_(false), |
| 417 delete_at_end_pressed_(false), | 417 delete_at_end_pressed_(false), |
| 418 font_(font), | 418 font_(font), |
| 419 possible_drag_(false), | 419 possible_drag_(false), |
| 420 in_drag_(false), | 420 in_drag_(false), |
| 421 initiated_drag_(false), | 421 initiated_drag_(false), |
| 422 drop_highlight_position_(-1), | 422 drop_highlight_position_(-1), |
| 423 ime_candidate_window_open_(false), |
| 423 background_color_(skia::SkColorToCOLORREF(LocationBarView::GetColor( | 424 background_color_(skia::SkColorToCOLORREF(LocationBarView::GetColor( |
| 424 ToolbarModel::NONE, LocationBarView::BACKGROUND))), | 425 ToolbarModel::NONE, LocationBarView::BACKGROUND))), |
| 425 security_level_(ToolbarModel::NONE), | 426 security_level_(ToolbarModel::NONE), |
| 426 text_object_model_(NULL) { | 427 text_object_model_(NULL) { |
| 427 // Dummy call to a function exported by riched20.dll to ensure it sets up an | 428 // Dummy call to a function exported by riched20.dll to ensure it sets up an |
| 428 // import dependency on the dll. | 429 // import dependency on the dll. |
| 429 CreateTextServices(NULL, NULL, NULL); | 430 CreateTextServices(NULL, NULL, NULL); |
| 430 | 431 |
| 431 saved_selection_for_focus_change_.cpMin = -1; | 432 saved_selection_for_focus_change_.cpMin = -1; |
| 432 | 433 |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 bool OmniboxViewWin::IsImeComposing() const { | 945 bool OmniboxViewWin::IsImeComposing() const { |
| 945 bool ime_composing = false; | 946 bool ime_composing = false; |
| 946 HIMC context = ImmGetContext(m_hWnd); | 947 HIMC context = ImmGetContext(m_hWnd); |
| 947 if (context) { | 948 if (context) { |
| 948 ime_composing = !!ImmGetCompositionString(context, GCS_COMPSTR, NULL, 0); | 949 ime_composing = !!ImmGetCompositionString(context, GCS_COMPSTR, NULL, 0); |
| 949 ImmReleaseContext(m_hWnd, context); | 950 ImmReleaseContext(m_hWnd, context); |
| 950 } | 951 } |
| 951 return ime_composing; | 952 return ime_composing; |
| 952 } | 953 } |
| 953 | 954 |
| 955 bool OmniboxViewWin::ShouldHideAutocompletePopup() const { |
| 956 // Don't let the autocomplete popup be shown when IME candidate window is |
| 957 // open, so they don't overlap. |
| 958 return ime_candidate_window_open_; |
| 959 } |
| 960 |
| 954 views::View* OmniboxViewWin::AddToView(views::View* parent) { | 961 views::View* OmniboxViewWin::AddToView(views::View* parent) { |
| 955 views::NativeViewHost* host = new views::NativeViewHost; | 962 views::NativeViewHost* host = new views::NativeViewHost; |
| 956 parent->AddChildView(host); | 963 parent->AddChildView(host); |
| 957 host->set_focus_view(parent); | 964 host->set_focus_view(parent); |
| 958 host->Attach(GetNativeView()); | 965 host->Attach(GetNativeView()); |
| 959 return host; | 966 return host; |
| 960 } | 967 } |
| 961 | 968 |
| 962 int OmniboxViewWin::OnPerformDrop(const views::DropTargetEvent& event) { | 969 int OmniboxViewWin::OnPerformDrop(const views::DropTargetEvent& event) { |
| 963 return OnPerformDropImpl(event, false); | 970 return OnPerformDropImpl(event, false); |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1344 autocomplete_accessibility_.Attach(GetIAccessible()); | 1351 autocomplete_accessibility_.Attach(GetIAccessible()); |
| 1345 | 1352 |
| 1346 if (autocomplete_accessibility_) { | 1353 if (autocomplete_accessibility_) { |
| 1347 return LresultFromObject(IID_IAccessible, wparam, | 1354 return LresultFromObject(IID_IAccessible, wparam, |
| 1348 autocomplete_accessibility_); | 1355 autocomplete_accessibility_); |
| 1349 } | 1356 } |
| 1350 } | 1357 } |
| 1351 return 0; | 1358 return 0; |
| 1352 } | 1359 } |
| 1353 | 1360 |
| 1361 LRESULT OmniboxViewWin::OnImeNotify(UINT message, |
| 1362 WPARAM wparam, |
| 1363 LPARAM lparam) { |
| 1364 switch (wparam) { |
| 1365 case IMN_OPENCANDIDATE: |
| 1366 ime_candidate_window_open_ = true; |
| 1367 break; |
| 1368 case IMN_CLOSECANDIDATE: |
| 1369 ime_candidate_window_open_ = false; |
| 1370 break; |
| 1371 default: |
| 1372 break; |
| 1373 } |
| 1374 return DefWindowProc(message, wparam, lparam); |
| 1375 } |
| 1376 |
| 1354 LRESULT OmniboxViewWin::OnImeComposition(UINT message, | 1377 LRESULT OmniboxViewWin::OnImeComposition(UINT message, |
| 1355 WPARAM wparam, | 1378 WPARAM wparam, |
| 1356 LPARAM lparam) { | 1379 LPARAM lparam) { |
| 1357 if (ignore_ime_messages_) { | 1380 if (ignore_ime_messages_) { |
| 1358 // This message was sent while we're in the middle of meddling with the | 1381 // This message was sent while we're in the middle of meddling with the |
| 1359 // underlying edit control. If we handle it below, OnAfterPossibleChange() | 1382 // underlying edit control. If we handle it below, OnAfterPossibleChange() |
| 1360 // can get bogus text for the edit, and rerun autocomplete, destructively | 1383 // can get bogus text for the edit, and rerun autocomplete, destructively |
| 1361 // modifying the result set that we're in the midst of using. For example, | 1384 // modifying the result set that we're in the midst of using. For example, |
| 1362 // if SetWindowTextAndCaretPos() was called due to the user clicking an | 1385 // if SetWindowTextAndCaretPos() was called due to the user clicking an |
| 1363 // entry in the popup, we're in the middle of executing SetSelectedLine(), | 1386 // entry in the popup, we're in the middle of executing SetSelectedLine(), |
| (...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2617 // PosFromChar(i) might return 0 when i is greater than 1. | 2640 // PosFromChar(i) might return 0 when i is greater than 1. |
| 2618 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2641 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
| 2619 } | 2642 } |
| 2620 | 2643 |
| 2621 bool OmniboxViewWin::IsCaretAtEnd() const { | 2644 bool OmniboxViewWin::IsCaretAtEnd() const { |
| 2622 long length = GetTextLength(); | 2645 long length = GetTextLength(); |
| 2623 CHARRANGE sel; | 2646 CHARRANGE sel; |
| 2624 GetSelection(sel); | 2647 GetSelection(sel); |
| 2625 return sel.cpMin == sel.cpMax && sel.cpMin == length; | 2648 return sel.cpMin == sel.cpMax && sel.cpMin == length; |
| 2626 } | 2649 } |
| OLD | NEW |