summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsuzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-15 20:47:53 +0000
committersuzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-15 20:47:53 +0000
commite6d6b43f9aa5b1da627fe7067d36fe47d46abedb (patch)
treeb066da36f24e062329731d3767b32fa4c855d581
parent051e4ecafeb6da960517224bdd0348dae7e43784 (diff)
downloadchromium_src-e6d6b43f9aa5b1da627fe7067d36fe47d46abedb.zip
chromium_src-e6d6b43f9aa5b1da627fe7067d36fe47d46abedb.tar.gz
chromium_src-e6d6b43f9aa5b1da627fe7067d36fe47d46abedb.tar.bz2
Replace views::TextRange with ui::Range.
BUG=none TEST=original unittests. Review URL: http://codereview.chromium.org/6695021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78280 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_views.cc20
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_views.h8
-rw-r--r--views/controls/textfield/native_textfield_gtk.cc8
-rw-r--r--views/controls/textfield/native_textfield_gtk.h6
-rw-r--r--views/controls/textfield/native_textfield_views.cc6
-rw-r--r--views/controls/textfield/native_textfield_views.h5
-rw-r--r--views/controls/textfield/native_textfield_win.cc6
-rw-r--r--views/controls/textfield/native_textfield_win.h5
-rw-r--r--views/controls/textfield/native_textfield_wrapper.h9
-rw-r--r--views/controls/textfield/text_range.h67
-rw-r--r--views/controls/textfield/textfield.cc8
-rw-r--r--views/controls/textfield/textfield.h9
-rw-r--r--views/controls/textfield/textfield_views_model.cc8
-rw-r--r--views/controls/textfield/textfield_views_model.h10
-rw-r--r--views/controls/textfield/textfield_views_model_unittest.cc38
-rw-r--r--views/views.gyp1
16 files changed, 75 insertions, 139 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_views.cc b/chrome/browser/autocomplete/autocomplete_edit_view_views.cc
index 0d1bdc3..e3626b7 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_views.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_views.cc
@@ -77,12 +77,12 @@ class AutocompleteTextfield : public views::Textfield {
// Stores omnibox state for each tab.
struct ViewState {
- explicit ViewState(const views::TextRange& selection_range)
+ explicit ViewState(const ui::Range& selection_range)
: selection_range(selection_range) {
}
// Range of selected text.
- views::TextRange selection_range;
+ ui::Range selection_range;
};
struct AutocompleteEditState {
@@ -295,7 +295,7 @@ void AutocompleteEditViewViews::SaveStateToTab(TabContents* tab) {
// NOTE: GetStateForTabSwitch may affect GetSelection, so order is important.
AutocompleteEditModel::State model_state = model_->GetStateForTabSwitch();
- views::TextRange selection;
+ ui::Range selection;
textfield_->GetSelectedRange(&selection);
GetStateAccessor()->SetProperty(
tab->property_bag(),
@@ -378,7 +378,7 @@ void AutocompleteEditViewViews::SetUserText(const string16& text,
void AutocompleteEditViewViews::SetWindowTextAndCaretPos(
const string16& text,
size_t caret_pos) {
- const views::TextRange range(caret_pos, caret_pos);
+ const ui::Range range(caret_pos, caret_pos);
SetTextAndSelectedRange(text, range);
}
@@ -404,7 +404,7 @@ bool AutocompleteEditViewViews::DeleteAtEndPressed() {
void AutocompleteEditViewViews::GetSelectionBounds(
string16::size_type* start,
string16::size_type* end) {
- views::TextRange range;
+ ui::Range range;
textfield_->GetSelectedRange(&range);
*start = static_cast<size_t>(range.end());
*end = static_cast<size_t>(range.start());
@@ -430,7 +430,7 @@ void AutocompleteEditViewViews::UpdatePopup() {
// Don't inline autocomplete when the caret/selection isn't at the end of
// the text, or in the middle of composition.
- views::TextRange sel;
+ ui::Range sel;
textfield_->GetSelectedRange(&sel);
bool no_inline_autocomplete = sel.GetMax() < GetTextLength();
@@ -463,7 +463,7 @@ bool AutocompleteEditViewViews::OnInlineAutocompleteTextMaybeChanged(
size_t user_text_length) {
if (display_text == GetText())
return false;
- views::TextRange range(display_text.size(), user_text_length);
+ ui::Range range(display_text.size(), user_text_length);
SetTextAndSelectedRange(display_text, range);
TextChanged();
return true;
@@ -489,7 +489,7 @@ bool AutocompleteEditViewViews::OnAfterPossibleChange() {
content_maybe_changed_by_key_press_ = true;
return false;
}
- views::TextRange new_sel;
+ ui::Range new_sel;
textfield_->GetSelectedRange(&new_sel);
size_t length = GetTextLength();
@@ -639,7 +639,7 @@ void AutocompleteEditViewViews::TextChanged() {
void AutocompleteEditViewViews::SetTextAndSelectedRange(
const string16& text,
- const views::TextRange& range) {
+ const ui::Range& range) {
if (text != GetText())
textfield_->SetText(text);
textfield_->SelectRange(range);
@@ -651,7 +651,7 @@ string16 AutocompleteEditViewViews::GetSelectedText() const {
}
void AutocompleteEditViewViews::SelectRange(size_t caret, size_t end) {
- const views::TextRange range(caret, end);
+ const ui::Range range(caret, end);
textfield_->SelectRange(range);
}
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_views.h b/chrome/browser/autocomplete/autocomplete_edit_view_views.h
index 1dd1316..3c66c8c 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_views.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_views.h
@@ -14,7 +14,7 @@
#include "chrome/browser/ui/toolbar/toolbar_model.h"
#include "chrome/common/page_transition_types.h"
#include "content/common/notification_observer.h"
-#include "views/controls/textfield/text_range.h"
+#include "ui/base/range/range.h"
#include "views/controls/textfield/textfield_controller.h"
#include "views/view.h"
#include "webkit/glue/window_open_disposition.h"
@@ -145,7 +145,7 @@ class AutocompleteEditViewViews : public views::View,
// Update the field with |text| and set the selection.
void SetTextAndSelectedRange(const string16& text,
- const views::TextRange& range);
+ const ui::Range& range);
// Returns the selected text.
string16 GetSelectedText() const;
@@ -175,11 +175,11 @@ class AutocompleteEditViewViews : public views::View,
// Selection at the point where the user started using the
// arrows to move around in the popup.
- views::TextRange saved_temporary_selection_;
+ ui::Range saved_temporary_selection_;
// Tracking state before and after a possible change.
string16 text_before_change_;
- views::TextRange sel_before_change_;
+ ui::Range sel_before_change_;
// TODO(oshima): following flags are copied from gtk implementation.
// It should be possible to refactor this class to simplify flags and
diff --git a/views/controls/textfield/native_textfield_gtk.cc b/views/controls/textfield/native_textfield_gtk.cc
index a71d679..ec7c271 100644
--- a/views/controls/textfield/native_textfield_gtk.cc
+++ b/views/controls/textfield/native_textfield_gtk.cc
@@ -9,13 +9,13 @@
#include "base/logging.h"
#include "base/utf_string_conversions.h"
+#include "ui/base/range/range.h"
#include "ui/gfx/gtk_util.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/skia_utils_gtk.h"
#include "views/controls/textfield/gtk_views_entry.h"
#include "views/controls/textfield/gtk_views_textview.h"
#include "views/controls/textfield/native_textfield_views.h"
-#include "views/controls/textfield/text_range.h"
#include "views/controls/textfield/textfield.h"
#include "views/controls/textfield/textfield_controller.h"
#include "views/widget/widget_gtk.h"
@@ -345,15 +345,15 @@ bool NativeTextfieldGtk::IsIMEComposing() const {
return false;
}
-void NativeTextfieldGtk::GetSelectedRange(TextRange* range) const {
+void NativeTextfieldGtk::GetSelectedRange(ui::Range* range) const {
gint start_pos;
gint end_pos;
gtk_editable_get_selection_bounds(
GTK_EDITABLE(native_view()), &start_pos, &end_pos);
- range->SetRange(start_pos, end_pos);
+ *range = ui::Range(start_pos, end_pos);
}
-void NativeTextfieldGtk::SelectRange(const TextRange& range) {
+void NativeTextfieldGtk::SelectRange(const ui::Range& range) {
NOTREACHED();
}
diff --git a/views/controls/textfield/native_textfield_gtk.h b/views/controls/textfield/native_textfield_gtk.h
index 802d1fb..ee728e5 100644
--- a/views/controls/textfield/native_textfield_gtk.h
+++ b/views/controls/textfield/native_textfield_gtk.h
@@ -14,8 +14,6 @@
namespace views {
-class TextRange;
-
class NativeTextfieldGtk : public NativeControlGtk,
public NativeTextfieldWrapper {
public:
@@ -50,8 +48,8 @@ class NativeTextfieldGtk : public NativeControlGtk,
virtual View* GetView() OVERRIDE;
virtual gfx::NativeView GetTestingHandle() const OVERRIDE;
virtual bool IsIMEComposing() const OVERRIDE;
- virtual void GetSelectedRange(TextRange* range) const OVERRIDE;
- virtual void SelectRange(const TextRange& range) OVERRIDE;
+ virtual void GetSelectedRange(ui::Range* range) const OVERRIDE;
+ virtual void SelectRange(const ui::Range& range) OVERRIDE;
virtual size_t GetCursorPosition() const OVERRIDE;
virtual bool HandleKeyPressed(const views::KeyEvent& e) OVERRIDE;
virtual bool HandleKeyReleased(const views::KeyEvent& e) OVERRIDE;
diff --git a/views/controls/textfield/native_textfield_views.cc b/views/controls/textfield/native_textfield_views.cc
index d6214b2..f935193 100644
--- a/views/controls/textfield/native_textfield_views.cc
+++ b/views/controls/textfield/native_textfield_views.cc
@@ -12,13 +12,13 @@
#include "base/utf_string_conversions.h"
#include "grit/app_strings.h"
#include "ui/base/clipboard/clipboard.h"
+#include "ui/base/range/range.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/insets.h"
#include "views/background.h"
#include "views/border.h"
#include "views/controls/menu/menu_2.h"
-#include "views/controls/textfield/text_range.h"
#include "views/controls/textfield/textfield.h"
#include "views/controls/textfield/textfield_controller.h"
#include "views/controls/textfield/textfield_views_model.h"
@@ -278,11 +278,11 @@ bool NativeTextfieldViews::IsIMEComposing() const {
return false;
}
-void NativeTextfieldViews::GetSelectedRange(TextRange* range) const {
+void NativeTextfieldViews::GetSelectedRange(ui::Range* range) const {
model_->GetSelectedRange(range);
}
-void NativeTextfieldViews::SelectRange(const TextRange& range) {
+void NativeTextfieldViews::SelectRange(const ui::Range& range) {
model_->SelectRange(range);
UpdateCursorBoundsAndTextOffset();
SchedulePaint();
diff --git a/views/controls/textfield/native_textfield_views.h b/views/controls/textfield/native_textfield_views.h
index 059e0f9bee..1f80147 100644
--- a/views/controls/textfield/native_textfield_views.h
+++ b/views/controls/textfield/native_textfield_views.h
@@ -27,7 +27,6 @@ namespace views {
class KeyEvent;
class Menu2;
class TextfieldViewsModel;
-class TextRange;
// A views/skia only implementation of NativeTextfieldWrapper.
// No platform specific code is used.
@@ -86,8 +85,8 @@ class NativeTextfieldViews : public views::View,
virtual View* GetView() OVERRIDE;
virtual gfx::NativeView GetTestingHandle() const OVERRIDE;
virtual bool IsIMEComposing() const OVERRIDE;
- virtual void GetSelectedRange(TextRange* range) const OVERRIDE;
- virtual void SelectRange(const TextRange& range) OVERRIDE;
+ virtual void GetSelectedRange(ui::Range* range) const OVERRIDE;
+ virtual void SelectRange(const ui::Range& range) OVERRIDE;
virtual size_t GetCursorPosition() const OVERRIDE;
virtual bool HandleKeyPressed(const views::KeyEvent& e) OVERRIDE;
virtual bool HandleKeyReleased(const views::KeyEvent& e) OVERRIDE;
diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc
index 0cc8700..f8b2ea2 100644
--- a/views/controls/textfield/native_textfield_win.cc
+++ b/views/controls/textfield/native_textfield_win.cc
@@ -19,13 +19,13 @@
#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_win.h"
+#include "ui/base/range/range.h"
#include "ui/gfx/native_theme_win.h"
#include "views/controls/label.h"
#include "views/controls/menu/menu_2.h"
#include "views/controls/menu/menu_win.h"
#include "views/controls/native/native_view_host.h"
#include "views/controls/textfield/native_textfield_views.h"
-#include "views/controls/textfield/text_range.h"
#include "views/controls/textfield/textfield.h"
#include "views/controls/textfield/textfield_controller.h"
#include "views/focus/focus_manager.h"
@@ -339,11 +339,11 @@ bool NativeTextfieldWin::IsIMEComposing() const {
return composition_size > 0;
}
-void NativeTextfieldWin::GetSelectedRange(TextRange* range) const {
+void NativeTextfieldWin::GetSelectedRange(ui::Range* range) const {
NOTREACHED();
}
-void NativeTextfieldWin::SelectRange(const TextRange& range) {
+void NativeTextfieldWin::SelectRange(const ui::Range& range) {
NOTREACHED();
}
diff --git a/views/controls/textfield/native_textfield_win.h b/views/controls/textfield/native_textfield_win.h
index 7946a00..9ec30d2 100644
--- a/views/controls/textfield/native_textfield_win.h
+++ b/views/controls/textfield/native_textfield_win.h
@@ -25,7 +25,6 @@ namespace views {
class Menu2;
class NativeViewHost;
class Textfield;
-class TextRange;
static const int kDefaultEditStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN |
WS_CLIPSIBLINGS;
@@ -79,8 +78,8 @@ class NativeTextfieldWin
virtual View* GetView() OVERRIDE;
virtual gfx::NativeView GetTestingHandle() const OVERRIDE;
virtual bool IsIMEComposing() const OVERRIDE;
- virtual void GetSelectedRange(TextRange* range) const OVERRIDE;
- virtual void SelectRange(const TextRange& range) OVERRIDE;
+ virtual void GetSelectedRange(ui::Range* range) const OVERRIDE;
+ virtual void SelectRange(const ui::Range& range) OVERRIDE;
virtual size_t GetCursorPosition() const OVERRIDE;
virtual bool HandleKeyPressed(const views::KeyEvent& event) OVERRIDE;
virtual bool HandleKeyReleased(const views::KeyEvent& event) OVERRIDE;
diff --git a/views/controls/textfield/native_textfield_wrapper.h b/views/controls/textfield/native_textfield_wrapper.h
index 1e98564..2ad5b6c 100644
--- a/views/controls/textfield/native_textfield_wrapper.h
+++ b/views/controls/textfield/native_textfield_wrapper.h
@@ -13,11 +13,14 @@ namespace gfx {
class Insets;
} // namespace gfx
+namespace ui {
+class Range;
+} // namespace ui
+
namespace views {
class KeyEvent;
class Textfield;
-class TextRange;
class View;
// An interface implemented by an object that provides a platform-native
@@ -93,10 +96,10 @@ class NativeTextfieldWrapper {
virtual bool IsIMEComposing() const = 0;
// Gets the selected range.
- virtual void GetSelectedRange(TextRange* range) const = 0;
+ virtual void GetSelectedRange(ui::Range* range) const = 0;
// Selects the text given by |range|.
- virtual void SelectRange(const TextRange& range) = 0;
+ virtual void SelectRange(const ui::Range& range) = 0;
// Returns the currnet cursor position.
virtual size_t GetCursorPosition() const = 0;
diff --git a/views/controls/textfield/text_range.h b/views/controls/textfield/text_range.h
deleted file mode 100644
index c367444..0000000
--- a/views/controls/textfield/text_range.h
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef VIEWS_CONTROLS_TEXTFIELD_TEXT_RANGE_H_
-#define VIEWS_CONTROLS_TEXTFIELD_TEXT_RANGE_H_
-#pragma once
-
-#include <stddef.h>
-
-#include <algorithm>
-
-namespace views {
-
-// TextRange specifies the range of text in the Textfield. This is used to
-// specify selected text and will be used to change the attributes of characters
-// in the textfield. When this is used for selection, the end is caret position,
-// and the start is where selection started. The range preserves the direction,
-// and selecting from the end to the begining is considered "reverse" order.
-// (that is, start > end is reverse)
-class TextRange {
- public:
- TextRange() : start_(0), end_(0) {}
- TextRange(size_t start, size_t end) : start_(start), end_(end) {}
-
- // Allow copy so that the omnibox can save the view state for each tabs.
- explicit TextRange(const TextRange& range)
- : start_(range.start_),
- end_(range.end_) {}
-
- // Returns the start position;
- size_t start() const { return start_; }
-
- // Returns the end position.
- size_t end() const { return end_; }
-
- // Returns true if the selected text is empty.
- bool is_empty() const { return start_ == end_; }
-
- // Returns true if the selection is made in reverse order.
- bool is_reverse() const { return start_ > end_; }
-
- // Returns the min of selected range.
- size_t GetMin() const { return std::min(start_, end_); }
-
- // Returns the max of selected range.
- size_t GetMax() const { return std::max(start_, end_); }
-
- // Returns true if the the selection range is same ignoring the direction.
- bool EqualsIgnoringDirection(const TextRange& range) const {
- return GetMin() == range.GetMin() && GetMax() == range.GetMax();
- }
-
- // Set the range with |start| and |end|.
- void SetRange(size_t start, size_t end) {
- start_ = start;
- end_ = end;
- }
-
- private:
- size_t start_;
- size_t end_;
-};
-
-} // namespace views
-
-#endif // VIEWS_CONTROLS_TEXTFIELD_TEXT_RANGE_H_
diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc
index 7716fc0..ec99e77 100644
--- a/views/controls/textfield/textfield.cc
+++ b/views/controls/textfield/textfield.cc
@@ -14,10 +14,10 @@
#include "base/utf_string_conversions.h"
#include "ui/base/accessibility/accessible_view_state.h"
#include "ui/base/keycodes/keyboard_codes.h"
+#include "ui/base/range/range.h"
#include "ui/gfx/insets.h"
#include "views/controls/native/native_view_host.h"
#include "views/controls/textfield/native_textfield_wrapper.h"
-#include "views/controls/textfield/text_range.h"
#include "views/controls/textfield/textfield_controller.h"
#include "views/widget/widget.h"
@@ -245,12 +245,12 @@ bool Textfield::IsIMEComposing() const {
return native_wrapper_ && native_wrapper_->IsIMEComposing();
}
-void Textfield::GetSelectedRange(TextRange* range) const {
+void Textfield::GetSelectedRange(ui::Range* range) const {
DCHECK(native_wrapper_);
native_wrapper_->GetSelectedRange(range);
}
-void Textfield::SelectRange(const TextRange& range) {
+void Textfield::SelectRange(const ui::Range& range) {
DCHECK(native_wrapper_);
native_wrapper_->SelectRange(range);
}
@@ -354,7 +354,7 @@ void Textfield::GetAccessibleState(ui::AccessibleViewState* state) {
state->value = text_;
DCHECK(native_wrapper_);
- TextRange range;
+ ui::Range range;
native_wrapper_->GetSelectedRange(&range);
state->selection_start = range.start();
state->selection_end = range.end();
diff --git a/views/controls/textfield/textfield.h b/views/controls/textfield/textfield.h
index 046919b6..ca87bdf 100644
--- a/views/controls/textfield/textfield.h
+++ b/views/controls/textfield/textfield.h
@@ -30,12 +30,15 @@
#include "views/controls/textfield/native_textfield_wrapper.h"
#endif
+namespace ui {
+class Range;
+} // namespace ui
+
namespace views {
class KeyEvent;
class NativeTextfieldWrapper;
class TextfieldController;
-class TextRange;
// This class implements a View that wraps a native text (edit) field.
class Textfield : public View {
@@ -173,11 +176,11 @@ class Textfield : public View {
// Gets the selected range. This is views-implementation only and
// has to be called after the wrapper is created.
- void GetSelectedRange(TextRange* range) const;
+ void GetSelectedRange(ui::Range* range) const;
// Selects the text given by |range|. This is views-implementation only and
// has to be called after the wrapper is created.
- void SelectRange(const TextRange& range);
+ void SelectRange(const ui::Range& range);
// Returns the current cursor position. This is views-implementation
// only and has to be called after the wrapper is created.
diff --git a/views/controls/textfield/textfield_views_model.cc b/views/controls/textfield/textfield_views_model.cc
index 4d88ffb..ef12404 100644
--- a/views/controls/textfield/textfield_views_model.cc
+++ b/views/controls/textfield/textfield_views_model.cc
@@ -11,8 +11,8 @@
#include "base/utf_string_conversions.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
+#include "ui/base/range/range.h"
#include "ui/gfx/font.h"
-#include "views/controls/textfield/text_range.h"
#include "views/controls/textfield/textfield.h"
#include "views/views_delegate.h"
@@ -221,11 +221,11 @@ string16 TextfieldViewsModel::GetSelectedText() const {
std::abs(static_cast<long>(cursor_pos_ - selection_begin_)));
}
-void TextfieldViewsModel::GetSelectedRange(TextRange* range) const {
- range->SetRange(selection_begin_, cursor_pos_);
+void TextfieldViewsModel::GetSelectedRange(ui::Range* range) const {
+ *range = ui::Range(selection_begin_, cursor_pos_);
}
-void TextfieldViewsModel::SelectRange(const TextRange& range) {
+void TextfieldViewsModel::SelectRange(const ui::Range& range) {
selection_begin_ = GetSafePosition(range.start());
cursor_pos_ = GetSafePosition(range.end());
}
diff --git a/views/controls/textfield/textfield_views_model.h b/views/controls/textfield/textfield_views_model.h
index 1e580b7..c7e7e9a 100644
--- a/views/controls/textfield/textfield_views_model.h
+++ b/views/controls/textfield/textfield_views_model.h
@@ -16,9 +16,11 @@ namespace gfx {
class Font;
} // namespace gfx
-namespace views {
+namespace ui {
+class Range;
+} // namespace ui
-class TextRange;
+namespace views {
// A model that represents a text content for TextfieldViews.
// It supports editing, selection and cursor manipulation.
@@ -116,9 +118,9 @@ class TextfieldViewsModel {
// Returns the selected text.
string16 GetSelectedText() const;
- void GetSelectedRange(TextRange* range) const;
+ void GetSelectedRange(ui::Range* range) const;
- void SelectRange(const TextRange& range);
+ void SelectRange(const ui::Range& range);
// Selects all text.
void SelectAll();
diff --git a/views/controls/textfield/textfield_views_model_unittest.cc b/views/controls/textfield/textfield_views_model_unittest.cc
index b44b487..6c946da 100644
--- a/views/controls/textfield/textfield_views_model_unittest.cc
+++ b/views/controls/textfield/textfield_views_model_unittest.cc
@@ -9,7 +9,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
-#include "views/controls/textfield/text_range.h"
+#include "ui/base/range/range.h"
#include "views/controls/textfield/textfield.h"
#include "views/controls/textfield/textfield_views_model.h"
#include "views/test/test_views_delegate.h"
@@ -106,7 +106,7 @@ TEST_F(TextfieldViewsModelTest, Selection) {
model.SelectAll();
EXPECT_STR_EQ("HELLO", model.GetSelectedText());
// SelectAll should select towards the end.
- TextRange range;
+ ui::Range range;
model.GetSelectedRange(&range);
EXPECT_EQ(0U, range.start());
EXPECT_EQ(5U, range.end());
@@ -409,7 +409,7 @@ TEST_F(TextfieldViewsModelTest, RangeTest) {
TextfieldViewsModel model;
model.Append(ASCIIToUTF16("HELLO WORLD"));
model.MoveCursorToStart(false);
- TextRange range;
+ ui::Range range;
model.GetSelectedRange(&range);
EXPECT_TRUE(range.is_empty());
EXPECT_EQ(0U, range.start());
@@ -418,7 +418,7 @@ TEST_F(TextfieldViewsModelTest, RangeTest) {
model.MoveCursorToNextWord(true);
model.GetSelectedRange(&range);
EXPECT_FALSE(range.is_empty());
- EXPECT_FALSE(range.is_reverse());
+ EXPECT_FALSE(range.is_reversed());
EXPECT_EQ(0U, range.start());
EXPECT_EQ(5U, range.end());
@@ -444,14 +444,14 @@ TEST_F(TextfieldViewsModelTest, RangeTest) {
model.MoveCursorToPreviousWord(true);
model.GetSelectedRange(&range);
EXPECT_FALSE(range.is_empty());
- EXPECT_TRUE(range.is_reverse());
+ EXPECT_TRUE(range.is_reversed());
EXPECT_EQ(11U, range.start());
EXPECT_EQ(6U, range.end());
model.MoveCursorRight(true);
model.GetSelectedRange(&range);
EXPECT_FALSE(range.is_empty());
- EXPECT_TRUE(range.is_reverse());
+ EXPECT_TRUE(range.is_reversed());
EXPECT_EQ(11U, range.start());
EXPECT_EQ(7U, range.end());
@@ -465,7 +465,7 @@ TEST_F(TextfieldViewsModelTest, RangeTest) {
model.MoveCursorToStart(true);
model.GetSelectedRange(&range);
EXPECT_FALSE(range.is_empty());
- EXPECT_TRUE(range.is_reverse());
+ EXPECT_TRUE(range.is_reversed());
EXPECT_EQ(11U, range.start());
EXPECT_EQ(0U, range.end());
}
@@ -473,42 +473,42 @@ TEST_F(TextfieldViewsModelTest, RangeTest) {
TEST_F(TextfieldViewsModelTest, SelectRangeTest) {
TextfieldViewsModel model;
model.Append(ASCIIToUTF16("HELLO WORLD"));
- TextRange range(0, 6);
- EXPECT_FALSE(range.is_reverse());
+ ui::Range range(0, 6);
+ EXPECT_FALSE(range.is_reversed());
model.SelectRange(range);
EXPECT_STR_EQ("HELLO ", model.GetSelectedText());
- range.SetRange(6, 1);
- EXPECT_TRUE(range.is_reverse());
+ range = ui::Range(6, 1);
+ EXPECT_TRUE(range.is_reversed());
model.SelectRange(range);
EXPECT_STR_EQ("ELLO ", model.GetSelectedText());
- range.SetRange(2, 1000);
- EXPECT_FALSE(range.is_reverse());
+ range = ui::Range(2, 1000);
+ EXPECT_FALSE(range.is_reversed());
model.SelectRange(range);
EXPECT_STR_EQ("LLO WORLD", model.GetSelectedText());
- range.SetRange(1000, 3);
- EXPECT_TRUE(range.is_reverse());
+ range = ui::Range(1000, 3);
+ EXPECT_TRUE(range.is_reversed());
model.SelectRange(range);
EXPECT_STR_EQ("LO WORLD", model.GetSelectedText());
- range.SetRange(0, 0);
+ range = ui::Range(0, 0);
EXPECT_TRUE(range.is_empty());
model.SelectRange(range);
EXPECT_TRUE(model.GetSelectedText().empty());
- range.SetRange(3, 3);
+ range = ui::Range(3, 3);
EXPECT_TRUE(range.is_empty());
model.SelectRange(range);
EXPECT_TRUE(model.GetSelectedText().empty());
- range.SetRange(1000, 100);
+ range = ui::Range(1000, 100);
EXPECT_FALSE(range.is_empty());
model.SelectRange(range);
EXPECT_TRUE(model.GetSelectedText().empty());
- range.SetRange(1000, 1000);
+ range = ui::Range(1000, 1000);
EXPECT_TRUE(range.is_empty());
model.SelectRange(range);
EXPECT_TRUE(model.GetSelectedText().empty());
diff --git a/views/views.gyp b/views/views.gyp
index 874ce24..9570d91 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -236,7 +236,6 @@
'controls/textfield/gtk_views_entry.h',
'controls/textfield/gtk_views_textview.cc',
'controls/textfield/gtk_views_textview.h',
- 'controls/textfield/text_range.h',
'controls/textfield/textfield.cc',
'controls/textfield/textfield.h',
'controls/textfield/textfield_controller.h',