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/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 bool result = views::Textfield::OnMouseDragged(event); | 187 bool result = views::Textfield::OnMouseDragged(event); |
188 omnibox_view_->HandleMouseDragEvent(event); | 188 omnibox_view_->HandleMouseDragEvent(event); |
189 return result; | 189 return result; |
190 } | 190 } |
191 | 191 |
192 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE { | 192 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE { |
193 views::Textfield::OnMouseReleased(event); | 193 views::Textfield::OnMouseReleased(event); |
194 omnibox_view_->HandleMouseReleaseEvent(event); | 194 omnibox_view_->HandleMouseReleaseEvent(event); |
195 } | 195 } |
196 | 196 |
197 protected: | |
198 // views::View implementation. | |
199 virtual void PaintChildren(gfx::Canvas* canvas) { | |
200 views::Textfield::PaintChildren(canvas); | |
201 } | |
202 | |
203 private: | 197 private: |
204 OmniboxViewViews* omnibox_view_; | 198 OmniboxViewViews* omnibox_view_; |
205 LocationBarView* location_bar_view_; | 199 LocationBarView* location_bar_view_; |
206 | 200 |
207 DISALLOW_COPY_AND_ASSIGN(AutocompleteTextfield); | 201 DISALLOW_COPY_AND_ASSIGN(AutocompleteTextfield); |
208 }; | 202 }; |
209 | 203 |
210 // static | 204 // static |
211 const char OmniboxViewViews::kViewClassName[] = "BrowserOmniboxViewViews"; | 205 const char OmniboxViewViews::kViewClassName[] = "BrowserOmniboxViewViews"; |
212 | 206 |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
583 // because if we already have invisible focus, the RequestFocus() call below | 577 // because if we already have invisible focus, the RequestFocus() call below |
584 // will short-circuit, preventing us from reaching | 578 // will short-circuit, preventing us from reaching |
585 // OmniboxEditModel::OnSetFocus(), which handles restoring visibility when we | 579 // OmniboxEditModel::OnSetFocus(), which handles restoring visibility when we |
586 // didn't previously have focus. | 580 // didn't previously have focus. |
587 model()->SetCaretVisibility(true); | 581 model()->SetCaretVisibility(true); |
588 // In views-implementation, the focus is on textfield rather than OmniboxView. | 582 // In views-implementation, the focus is on textfield rather than OmniboxView. |
589 textfield_->RequestFocus(); | 583 textfield_->RequestFocus(); |
590 } | 584 } |
591 | 585 |
592 void OmniboxViewViews::ApplyCaretVisibility() { | 586 void OmniboxViewViews::ApplyCaretVisibility() { |
593 if (textfield_->cursor_color() != textfield_->background_color()) | 587 textfield_->SetCursorVisible(model()->is_caret_visible()); |
594 visible_caret_color_ = textfield_->cursor_color(); | |
595 // Setting the color of the text cursor (caret) to the background color | |
596 // effectively hides it. | |
597 textfield_->SetCursorColor(model()->is_caret_visible() ? | |
598 visible_caret_color_ : textfield_->background_color()); | |
samarth
2012/12/05 23:38:21
You can kill visible_caret_color_.
msw
2012/12/06 00:03:52
Done.
| |
599 } | 588 } |
600 | 589 |
601 void OmniboxViewViews::OnTemporaryTextMaybeChanged( | 590 void OmniboxViewViews::OnTemporaryTextMaybeChanged( |
602 const string16& display_text, | 591 const string16& display_text, |
603 bool save_original_selection) { | 592 bool save_original_selection) { |
604 if (save_original_selection) | 593 if (save_original_selection) |
605 textfield_->GetSelectedRange(&saved_temporary_selection_); | 594 textfield_->GetSelectedRange(&saved_temporary_selection_); |
606 | 595 |
607 SetWindowTextAndCaretPos(display_text, display_text.length(), false, true); | 596 SetWindowTextAndCaretPos(display_text, display_text.length(), false, true); |
608 } | 597 } |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
975 if (!text.empty()) { | 964 if (!text.empty()) { |
976 // Record this paste, so we can do different behavior. | 965 // Record this paste, so we can do different behavior. |
977 model()->on_paste(); | 966 model()->on_paste(); |
978 // Force a Paste operation to trigger the text_changed code in | 967 // Force a Paste operation to trigger the text_changed code in |
979 // OnAfterPossibleChange(), even if identical contents are pasted into the | 968 // OnAfterPossibleChange(), even if identical contents are pasted into the |
980 // text box. | 969 // text box. |
981 text_before_change_.clear(); | 970 text_before_change_.clear(); |
982 textfield_->ReplaceSelection(text); | 971 textfield_->ReplaceSelection(text); |
983 } | 972 } |
984 } | 973 } |
OLD | NEW |