Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Unified Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 120503005: Merge NativeTextfieldViews into views::Textfield. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix touch drag and drop unit test. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/omnibox/omnibox_view_views.cc
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
index 4ba3789b5d8183326b50af945843607092dbaabe..b25c9dc45af443f7905a7def19e47a7518e04838 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -44,7 +44,6 @@
#include "ui/gfx/selection_model.h"
#include "ui/views/border.h"
#include "ui/views/button_drag_utils.h"
-#include "ui/views/controls/textfield/native_textfield_views.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/ime/input_method.h"
#include "ui/views/layout/fill_layout.h"
@@ -176,7 +175,7 @@ void OmniboxViewViews::Init() {
// Initialize the popup view using the same font.
popup_view_.reset(OmniboxPopupContentsView::Create(
- font_list(), this, model(), location_bar_view_));
+ GetFontList(), this, model(), location_bar_view_));
#if defined(OS_CHROMEOS)
chromeos::input_method::InputMethodManager::Get()->
@@ -353,7 +352,7 @@ bool OmniboxViewViews::HandleEarlyTabActions(const ui::KeyEvent& event) {
if (event.IsShiftDown() &&
model()->popup_model()->selected_line_state() ==
OmniboxPopupModel::KEYWORD) {
- model()->ClearKeyword(text());
+ model()->ClearKeyword(GetText());
} else {
model()->OnUpOrDownKeyPressed(event.IsShiftDown() ? -1 : 1);
}
@@ -457,7 +456,7 @@ void OmniboxViewViews::Update() {
// is still fully selected, the user's typing will replace the edit contents
// as they'd intended.
const gfx::Range range(GetSelectedRange());
- const bool was_select_all = (range.length() == text().length());
+ const bool was_select_all = (range.length() == GetText().length());
RevertAll();
@@ -478,7 +477,7 @@ void OmniboxViewViews::Update() {
base::string16 OmniboxViewViews::GetText() const {
// TODO(oshima): IME support
- return text();
+ return Textfield::GetText();
}
void OmniboxViewViews::SetUserText(const base::string16& text,
@@ -503,7 +502,7 @@ void OmniboxViewViews::SetWindowTextAndCaretPos(const base::string16& text,
}
void OmniboxViewViews::SetForcedQuery() {
- const base::string16 current_text(text());
+ const base::string16 current_text(GetText());
const size_t start = current_text.find_first_not_of(base::kWhitespaceUTF16);
if (start == base::string16::npos || (current_text[start] != '?'))
OmniboxView::SetUserText(base::ASCIIToUTF16("?"));
@@ -513,7 +512,7 @@ void OmniboxViewViews::SetForcedQuery() {
bool OmniboxViewViews::IsSelectAll() const {
// TODO(oshima): IME support.
- return text() == GetSelectedText();
+ return GetText() == GetSelectedText();
}
bool OmniboxViewViews::DeleteAtEndPressed() {
@@ -548,7 +547,7 @@ void OmniboxViewViews::UpdatePopup() {
const gfx::Range sel = GetSelectedRange();
model()->StartAutocomplete(
!sel.is_empty(),
- sel.GetMax() < text().length() ||
+ sel.GetMax() < GetText().length() ||
(IsIMEComposing() && !IsOmniboxAutoCompletionForImeEnabled()));
}
@@ -580,7 +579,7 @@ void OmniboxViewViews::OnTemporaryTextMaybeChanged(
bool OmniboxViewViews::OnInlineAutocompleteTextMaybeChanged(
const base::string16& display_text,
size_t user_text_length) {
- if (display_text == text())
+ if (display_text == GetText())
return false;
if (IsIMEComposing()) {
@@ -609,14 +608,14 @@ void OmniboxViewViews::OnRevertTemporaryText() {
void OmniboxViewViews::OnBeforePossibleChange() {
// Record our state.
- text_before_change_ = text();
+ text_before_change_ = GetText();
sel_before_change_ = GetSelectedRange();
ime_composing_before_change_ = IsIMEComposing();
}
bool OmniboxViewViews::OnAfterPossibleChange() {
// See if the text or selection have changed since OnBeforePossibleChange().
- const base::string16 new_text = text();
+ const base::string16 new_text = GetText();
const gfx::Range new_sel = GetSelectedRange();
const bool text_changed = (new_text != text_before_change_) ||
(ime_composing_before_change_ != IsIMEComposing());
@@ -674,7 +673,9 @@ base::string16 OmniboxViewViews::GetGrayTextAutocompletion() const {
}
int OmniboxViewViews::GetTextWidth() const {
- return textfield_view_->GetWidthNeededForText();
+ // Returns the width necessary to display the current text, including any
+ // necessary space for the cursor or border/margin.
+ return GetRenderText()->GetContentWidth() + GetInsets().width();
}
int OmniboxViewViews::GetWidth() const {
@@ -711,18 +712,18 @@ bool OmniboxViewViews::HandleKeyEvent(views::Textfield* textfield,
if (model()->is_keyword_hint() || model()->keyword().empty() ||
HasSelection() || GetCursorPosition() != 0)
return false;
- model()->ClearKeyword(text());
+ model()->ClearKeyword(GetText());
return true;
}
if (event.key_code() == ui::VKEY_DELETE && !event.IsAltDown()) {
delete_at_end_pressed_ =
- (!HasSelection() && GetCursorPosition() == text().length());
+ (!HasSelection() && GetCursorPosition() == GetText().length());
}
// Handle the right-arrow key for LTR text and the left-arrow key for RTL text
// if there is gray text that needs to be committed.
- if (GetCursorPosition() == text().length()) {
+ if (GetCursorPosition() == GetText().length()) {
base::i18n::TextDirection direction = GetTextDirection();
if ((direction == base::i18n::LEFT_TO_RIGHT &&
event.key_code() == ui::VKEY_RIGHT) ||
@@ -918,7 +919,7 @@ void OmniboxViewViews::CandidateWindowClosed(
int OmniboxViewViews::GetOmniboxTextLength() const {
// TODO(oshima): Support IME.
- return static_cast<int>(text().length());
+ return static_cast<int>(GetText().length());
}
void OmniboxViewViews::EmphasizeURLComponents() {
@@ -929,8 +930,8 @@ void OmniboxViewViews::EmphasizeURLComponents() {
// be treated as a search or a navigation, and is the same method the Paste
// And Go system uses.
url_parse::Component scheme, host;
- AutocompleteInput::ParseForEmphasizeComponents(text(), &scheme, &host);
- bool grey_out_url = text().substr(scheme.begin, scheme.len) ==
+ AutocompleteInput::ParseForEmphasizeComponents(GetText(), &scheme, &host);
+ bool grey_out_url = GetText().substr(scheme.begin, scheme.len) ==
base::UTF8ToUTF16(extensions::kExtensionScheme);
bool grey_base = model()->CurrentTextIsURL() &&
(host.is_nonempty() || grey_out_url);

Powered by Google App Engine
This is Rietveld 408576698