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

Unified Diff: ui/views/controls/textfield/native_textfield_views.cc

Issue 24012002: Move Range code to gfx. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: d Created 7 years, 3 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: ui/views/controls/textfield/native_textfield_views.cc
diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc
index 76ba3cb457259df8528ecb960a04081602b1dda7..883c292e7077ba8ad7e7eebdd185fe49a544f6a5 100644
--- a/ui/views/controls/textfield/native_textfield_views.cc
+++ b/ui/views/controls/textfield/native_textfield_views.cc
@@ -21,11 +21,11 @@
#include "ui/base/dragdrop/drag_utils.h"
#include "ui/base/events/event.h"
#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/range/range.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/insets.h"
+#include "ui/gfx/range/range.h"
#include "ui/gfx/render_text.h"
#include "ui/gfx/text_constants.h"
#include "ui/native_theme/native_theme.h"
@@ -129,7 +129,7 @@ bool NativeTextfieldViews::OnMouseDragged(const ui::MouseEvent& event) {
if (aggregated_clicks_ == 1) {
model_->SelectWord();
// Expand the selection so the initially selected word remains selected.
- ui::Range selection = GetRenderText()->selection();
+ gfx::Range selection = GetRenderText()->selection();
const size_t min = std::min(selection.GetMin(),
double_click_word_.GetMin());
const size_t max = std::max(selection.GetMax(),
@@ -272,10 +272,10 @@ bool NativeTextfieldViews::CanDrop(const OSExchangeData& data) {
int NativeTextfieldViews::OnDragUpdated(const ui::DropTargetEvent& event) {
DCHECK(CanDrop(event.data()));
- const ui::Range& selection = GetRenderText()->selection();
+ const gfx::Range& selection = GetRenderText()->selection();
drop_cursor_position_ = GetRenderText()->FindCursorPosition(event.location());
bool in_selection = !selection.is_empty() &&
- selection.Contains(ui::Range(drop_cursor_position_.caret_pos()));
+ selection.Contains(gfx::Range(drop_cursor_position_.caret_pos()));
is_drop_cursor_visible_ = !in_selection;
// TODO(msw): Pan over text when the user drags to the visible text edge.
OnCaretBoundsChanged();
@@ -324,7 +324,7 @@ int NativeTextfieldViews::OnPerformDrop(const ui::DropTargetEvent& event) {
if (move) {
// Adjust the drop destination if it is on or after the current selection.
size_t drop = drop_destination_model.caret_pos();
- drop -= GetSelectedRange().Intersect(ui::Range(0, drop)).length();
+ drop -= GetSelectedRange().Intersect(gfx::Range(0, drop)).length();
model_->DeleteSelectionAndInsertTextAt(text, drop);
} else {
model_->MoveCursorTo(drop_destination_model);
@@ -370,7 +370,7 @@ void NativeTextfieldViews::SelectRect(const gfx::Point& start,
gfx::SelectionModel start_caret = GetRenderText()->FindCursorPosition(start);
gfx::SelectionModel end_caret = GetRenderText()->FindCursorPosition(end);
gfx::SelectionModel selection(
- ui::Range(start_caret.caret_pos(), end_caret.caret_pos()),
+ gfx::Range(start_caret.caret_pos(), end_caret.caret_pos()),
end_caret.caret_affinity());
OnBeforeUserAction();
@@ -628,11 +628,11 @@ bool NativeTextfieldViews::IsIMEComposing() const {
return model_->HasCompositionText();
}
-ui::Range NativeTextfieldViews::GetSelectedRange() const {
+gfx::Range NativeTextfieldViews::GetSelectedRange() const {
return GetRenderText()->selection();
}
-void NativeTextfieldViews::SelectRange(const ui::Range& range) {
+void NativeTextfieldViews::SelectRange(const gfx::Range& range) {
model_->SelectRange(range);
OnCaretBoundsChanged();
SchedulePaint();
@@ -836,7 +836,7 @@ void NativeTextfieldViews::SetColor(SkColor value) {
SchedulePaint();
}
-void NativeTextfieldViews::ApplyColor(SkColor value, const ui::Range& range) {
+void NativeTextfieldViews::ApplyColor(SkColor value, const gfx::Range& range) {
GetRenderText()->ApplyColor(value, range);
SchedulePaint();
}
@@ -848,7 +848,7 @@ void NativeTextfieldViews::SetStyle(gfx::TextStyle style, bool value) {
void NativeTextfieldViews::ApplyStyle(gfx::TextStyle style,
bool value,
- const ui::Range& range) {
+ const gfx::Range& range) {
GetRenderText()->ApplyStyle(style, value, range);
SchedulePaint();
}
@@ -990,7 +990,7 @@ bool NativeTextfieldViews::GetCompositionCharacterBounds(uint32 index,
DCHECK(rect);
if (!HasCompositionText())
return false;
- const ui::Range& composition_range = GetRenderText()->GetCompositionRange();
+ const gfx::Range& composition_range = GetRenderText()->GetCompositionRange();
const uint32 left_cursor_pos = composition_range.start() + index;
const uint32 right_cursor_pos = composition_range.start() + index + 1;
DCHECK(!composition_range.is_empty());
@@ -1019,7 +1019,7 @@ bool NativeTextfieldViews::HasCompositionText() {
return model_->HasCompositionText();
}
-bool NativeTextfieldViews::GetTextRange(ui::Range* range) {
+bool NativeTextfieldViews::GetTextRange(gfx::Range* range) {
if (!ImeEditingAllowed())
return false;
@@ -1027,7 +1027,7 @@ bool NativeTextfieldViews::GetTextRange(ui::Range* range) {
return true;
}
-bool NativeTextfieldViews::GetCompositionTextRange(ui::Range* range) {
+bool NativeTextfieldViews::GetCompositionTextRange(gfx::Range* range) {
if (!ImeEditingAllowed())
return false;
@@ -1035,14 +1035,14 @@ bool NativeTextfieldViews::GetCompositionTextRange(ui::Range* range) {
return true;
}
-bool NativeTextfieldViews::GetSelectionRange(ui::Range* range) {
+bool NativeTextfieldViews::GetSelectionRange(gfx::Range* range) {
if (!ImeEditingAllowed())
return false;
*range = GetSelectedRange();
return true;
}
-bool NativeTextfieldViews::SetSelectionRange(const ui::Range& range) {
+bool NativeTextfieldViews::SetSelectionRange(const gfx::Range& range) {
if (!ImeEditingAllowed() || !range.IsValid())
return false;
@@ -1052,7 +1052,7 @@ bool NativeTextfieldViews::SetSelectionRange(const ui::Range& range) {
return true;
}
-bool NativeTextfieldViews::DeleteRange(const ui::Range& range) {
+bool NativeTextfieldViews::DeleteRange(const gfx::Range& range) {
if (!ImeEditingAllowed() || range.is_empty())
return false;
@@ -1067,12 +1067,12 @@ bool NativeTextfieldViews::DeleteRange(const ui::Range& range) {
}
bool NativeTextfieldViews::GetTextFromRange(
- const ui::Range& range,
+ const gfx::Range& range,
string16* text) {
if (!ImeEditingAllowed() || !range.IsValid())
return false;
- ui::Range text_range;
+ gfx::Range text_range;
if (!GetTextRange(&text_range) || !text_range.Contains(range))
return false;
@@ -1093,12 +1093,12 @@ bool NativeTextfieldViews::ChangeTextDirectionAndLayoutAlignment(
void NativeTextfieldViews::ExtendSelectionAndDelete(
size_t before,
size_t after) {
- ui::Range range = GetSelectedRange();
+ gfx::Range range = GetSelectedRange();
DCHECK_GE(range.start(), before);
range.set_start(range.start() - before);
range.set_end(range.end() + after);
- ui::Range text_range;
+ gfx::Range text_range;
if (GetTextRange(&text_range) && text_range.Contains(range))
DeleteRange(range);
}
@@ -1224,7 +1224,7 @@ bool NativeTextfieldViews::HandleKeyEvent(const ui::KeyEvent& key_event) {
// forward/back of the browser history.
if (alt)
break;
- const ui::Range selection_range = GetSelectedRange();
+ const gfx::Range selection_range = GetSelectedRange();
model_->MoveCursor(
control ? gfx::WORD_BREAK : gfx::CHARACTER_BREAK,
(key_code == ui::VKEY_RIGHT) ? gfx::CURSOR_RIGHT : gfx::CURSOR_LEFT,
« no previous file with comments | « ui/views/controls/textfield/native_textfield_views.h ('k') | ui/views/controls/textfield/native_textfield_views_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698