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_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/property_bag.h" | 8 #include "base/property_bag.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 !textfield_->HasFocus(); | 390 !textfield_->HasFocus(); |
391 } | 391 } |
392 | 392 |
393 void OmniboxViewViews::HandleMouseDragEvent(const views::MouseEvent& event) { | 393 void OmniboxViewViews::HandleMouseDragEvent(const views::MouseEvent& event) { |
394 select_all_on_mouse_release_ = false; | 394 select_all_on_mouse_release_ = false; |
395 } | 395 } |
396 | 396 |
397 void OmniboxViewViews::HandleMouseReleaseEvent(const views::MouseEvent& event) { | 397 void OmniboxViewViews::HandleMouseReleaseEvent(const views::MouseEvent& event) { |
398 if ((event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) && | 398 if ((event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) && |
399 select_all_on_mouse_release_) { | 399 select_all_on_mouse_release_) { |
400 textfield_->SelectAll(); | 400 // Select all in the reverse direction so as not to scroll the caret |
| 401 // into view and shift the contents jarringly. |
| 402 SelectAll(true); |
401 } | 403 } |
402 select_all_on_mouse_release_ = false; | 404 select_all_on_mouse_release_ = false; |
403 } | 405 } |
404 | 406 |
405 void OmniboxViewViews::HandleFocusIn() { | 407 void OmniboxViewViews::HandleFocusIn() { |
406 // TODO(oshima): Get control key state. | 408 // TODO(oshima): Get control key state. |
407 model_->OnSetFocus(false); | 409 model_->OnSetFocus(false); |
408 // Don't call controller_->OnSetFocus as this view has already | 410 // Don't call controller_->OnSetFocus as this view has already |
409 // acquired the focus. | 411 // acquired the focus. |
410 } | 412 } |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 const ui::Range& range) { | 945 const ui::Range& range) { |
944 if (text != GetText()) | 946 if (text != GetText()) |
945 textfield_->SetText(text); | 947 textfield_->SetText(text); |
946 textfield_->SelectRange(range); | 948 textfield_->SelectRange(range); |
947 } | 949 } |
948 | 950 |
949 string16 OmniboxViewViews::GetSelectedText() const { | 951 string16 OmniboxViewViews::GetSelectedText() const { |
950 // TODO(oshima): Support instant, IME. | 952 // TODO(oshima): Support instant, IME. |
951 return textfield_->GetSelectedText(); | 953 return textfield_->GetSelectedText(); |
952 } | 954 } |
OLD | NEW |