summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/gfx/break_list.h12
-rw-r--r--ui/gfx/break_list_unittest.cc80
-rw-r--r--ui/gfx/canvas_skia.cc14
-rw-r--r--ui/gfx/render_text.cc43
-rw-r--r--ui/gfx/render_text.h24
-rw-r--r--ui/gfx/render_text_linux.cc14
-rw-r--r--ui/gfx/render_text_linux.h5
-rw-r--r--ui/gfx/render_text_mac.cc9
-rw-r--r--ui/gfx/render_text_mac.h5
-rw-r--r--ui/gfx/render_text_unittest.cc74
-rw-r--r--ui/gfx/render_text_win.cc42
-rw-r--r--ui/gfx/render_text_win.h7
-rw-r--r--ui/gfx/selection_model.cc11
-rw-r--r--ui/gfx/selection_model.h6
14 files changed, 171 insertions, 175 deletions
diff --git a/ui/gfx/break_list.h b/ui/gfx/break_list.h
index 4b549fc..b55debf 100644
--- a/ui/gfx/break_list.h
+++ b/ui/gfx/break_list.h
@@ -40,7 +40,7 @@ class BreakList {
void SetValue(T value);
// Adjust the breaks to apply |value| over the supplied |range|.
- void ApplyValue(T value, const gfx::Range& range);
+ void ApplyValue(T value, const Range& range);
// Set the max position and trim any breaks at or beyond that position.
void SetMax(size_t max);
@@ -52,7 +52,7 @@ class BreakList {
// Get the range of the supplied break; returns the break's start position and
// the next break's start position (or |max_| for the terminal break).
- gfx::Range GetRange(const typename BreakList<T>::const_iterator& i) const;
+ Range GetRange(const typename BreakList<T>::const_iterator& i) const;
// Comparison functions for testing purposes.
bool EqualsValueForTesting(T value) const;
@@ -83,12 +83,12 @@ void BreakList<T>::SetValue(T value) {
}
template<class T>
-void BreakList<T>::ApplyValue(T value, const gfx::Range& range) {
+void BreakList<T>::ApplyValue(T value, const Range& range) {
if (!range.IsValid() || range.is_empty())
return;
DCHECK(!breaks_.empty());
DCHECK(!range.is_reversed());
- DCHECK(gfx::Range(0, max_).Contains(range));
+ DCHECK(Range(0, max_).Contains(range));
// Erase any breaks in |range|, then add start and end breaks as needed.
typename std::vector<Break>::iterator start = GetBreak(range.start());
@@ -136,10 +136,10 @@ typename std::vector<std::pair<size_t, T> >::const_iterator
}
template<class T>
-gfx::Range BreakList<T>::GetRange(
+Range BreakList<T>::GetRange(
const typename BreakList<T>::const_iterator& i) const {
const typename BreakList<T>::const_iterator next = i + 1;
- return gfx::Range(i->first, next == breaks_.end() ? max_ : next->first);
+ return Range(i->first, next == breaks_.end() ? max_ : next->first);
}
template<class T>
diff --git a/ui/gfx/break_list_unittest.cc b/ui/gfx/break_list_unittest.cc
index d1b1d04..5d4e39b 100644
--- a/ui/gfx/break_list_unittest.cc
+++ b/ui/gfx/break_list_unittest.cc
@@ -32,10 +32,10 @@ TEST_F(BreakListTest, ApplyValue) {
breaks.SetMax(max);
// Ensure ApplyValue is a no-op on invalid and empty ranges.
- breaks.ApplyValue(true, gfx::Range::InvalidRange());
+ breaks.ApplyValue(true, Range::InvalidRange());
EXPECT_TRUE(breaks.EqualsValueForTesting(false));
for (size_t i = 0; i < 3; ++i) {
- breaks.ApplyValue(true, gfx::Range(i, i));
+ breaks.ApplyValue(true, Range(i, i));
EXPECT_TRUE(breaks.EqualsValueForTesting(false));
}
@@ -45,7 +45,7 @@ TEST_F(BreakListTest, ApplyValue) {
expected.push_back(std::pair<size_t, bool>(2, true));
expected.push_back(std::pair<size_t, bool>(3, false));
for (size_t i = 0; i < 2; ++i) {
- breaks.ApplyValue(true, gfx::Range(2, 3));
+ breaks.ApplyValue(true, Range(2, 3));
EXPECT_TRUE(breaks.EqualsForTesting(expected));
}
@@ -54,43 +54,43 @@ TEST_F(BreakListTest, ApplyValue) {
EXPECT_TRUE(breaks.EqualsValueForTesting(true));
// Ensure applying a value over [0, |max|) is the same as setting a value.
- breaks.ApplyValue(false, gfx::Range(0, max));
+ breaks.ApplyValue(false, Range(0, max));
EXPECT_TRUE(breaks.EqualsValueForTesting(false));
// Ensure applying a value that is already applied has no effect.
- breaks.ApplyValue(false, gfx::Range(0, 2));
- breaks.ApplyValue(false, gfx::Range(3, 6));
- breaks.ApplyValue(false, gfx::Range(7, max));
+ breaks.ApplyValue(false, Range(0, 2));
+ breaks.ApplyValue(false, Range(3, 6));
+ breaks.ApplyValue(false, Range(7, max));
EXPECT_TRUE(breaks.EqualsValueForTesting(false));
// Ensure applying an identical neighboring value merges the ranges.
- breaks.ApplyValue(true, gfx::Range(0, 3));
- breaks.ApplyValue(true, gfx::Range(3, 6));
- breaks.ApplyValue(true, gfx::Range(6, max));
+ breaks.ApplyValue(true, Range(0, 3));
+ breaks.ApplyValue(true, Range(3, 6));
+ breaks.ApplyValue(true, Range(6, max));
EXPECT_TRUE(breaks.EqualsValueForTesting(true));
// Ensure applying a value with the same range overrides the ranged value.
- breaks.ApplyValue(false, gfx::Range(2, 3));
- breaks.ApplyValue(true, gfx::Range(2, 3));
+ breaks.ApplyValue(false, Range(2, 3));
+ breaks.ApplyValue(true, Range(2, 3));
EXPECT_TRUE(breaks.EqualsValueForTesting(true));
// Ensure applying a value with a containing range overrides contained values.
- breaks.ApplyValue(false, gfx::Range(0, 1));
- breaks.ApplyValue(false, gfx::Range(2, 3));
- breaks.ApplyValue(true, gfx::Range(0, 3));
+ breaks.ApplyValue(false, Range(0, 1));
+ breaks.ApplyValue(false, Range(2, 3));
+ breaks.ApplyValue(true, Range(0, 3));
EXPECT_TRUE(breaks.EqualsValueForTesting(true));
- breaks.ApplyValue(false, gfx::Range(4, 5));
- breaks.ApplyValue(false, gfx::Range(6, 7));
- breaks.ApplyValue(false, gfx::Range(8, 9));
- breaks.ApplyValue(true, gfx::Range(4, 9));
+ breaks.ApplyValue(false, Range(4, 5));
+ breaks.ApplyValue(false, Range(6, 7));
+ breaks.ApplyValue(false, Range(8, 9));
+ breaks.ApplyValue(true, Range(4, 9));
EXPECT_TRUE(breaks.EqualsValueForTesting(true));
// Ensure applying various overlapping values yields the intended results.
- breaks.ApplyValue(false, gfx::Range(1, 4));
- breaks.ApplyValue(false, gfx::Range(5, 8));
- breaks.ApplyValue(true, gfx::Range(0, 2));
- breaks.ApplyValue(true, gfx::Range(3, 6));
- breaks.ApplyValue(true, gfx::Range(7, max));
+ breaks.ApplyValue(false, Range(1, 4));
+ breaks.ApplyValue(false, Range(5, 8));
+ breaks.ApplyValue(true, Range(0, 2));
+ breaks.ApplyValue(true, Range(3, 6));
+ breaks.ApplyValue(true, Range(7, max));
std::vector<std::pair<size_t, bool> > overlap;
overlap.push_back(std::pair<size_t, bool>(0, true));
overlap.push_back(std::pair<size_t, bool>(2, false));
@@ -104,9 +104,9 @@ TEST_F(BreakListTest, SetMax) {
// Ensure values adjust to accommodate max position changes.
BreakList<bool> breaks(false);
breaks.SetMax(9);
- breaks.ApplyValue(true, gfx::Range(0, 2));
- breaks.ApplyValue(true, gfx::Range(3, 6));
- breaks.ApplyValue(true, gfx::Range(7, 9));
+ breaks.ApplyValue(true, Range(0, 2));
+ breaks.ApplyValue(true, Range(3, 6));
+ breaks.ApplyValue(true, Range(7, 9));
std::vector<std::pair<size_t, bool> > expected;
expected.push_back(std::pair<size_t, bool>(0, true));
@@ -134,25 +134,25 @@ TEST_F(BreakListTest, SetMax) {
TEST_F(BreakListTest, GetBreakAndRange) {
BreakList<bool> breaks(false);
breaks.SetMax(8);
- breaks.ApplyValue(true, gfx::Range(1, 2));
- breaks.ApplyValue(true, gfx::Range(4, 6));
+ breaks.ApplyValue(true, Range(1, 2));
+ breaks.ApplyValue(true, Range(4, 6));
struct {
size_t position;
size_t break_index;
- gfx::Range range;
+ Range range;
} cases[] = {
- { 0, 0, gfx::Range(0, 1) },
- { 1, 1, gfx::Range(1, 2) },
- { 2, 2, gfx::Range(2, 4) },
- { 3, 2, gfx::Range(2, 4) },
- { 4, 3, gfx::Range(4, 6) },
- { 5, 3, gfx::Range(4, 6) },
- { 6, 4, gfx::Range(6, 8) },
- { 7, 4, gfx::Range(6, 8) },
+ { 0, 0, Range(0, 1) },
+ { 1, 1, Range(1, 2) },
+ { 2, 2, Range(2, 4) },
+ { 3, 2, Range(2, 4) },
+ { 4, 3, Range(4, 6) },
+ { 5, 3, Range(4, 6) },
+ { 6, 4, Range(6, 8) },
+ { 7, 4, Range(6, 8) },
// Positions at or beyond the max simply return the last break and range.
- { 8, 4, gfx::Range(6, 8) },
- { 9, 4, gfx::Range(6, 8) },
+ { 8, 4, Range(6, 8) },
+ { 9, 4, Range(6, 8) },
};
diff --git a/ui/gfx/canvas_skia.cc b/ui/gfx/canvas_skia.cc
index 5d38606..ef8ee36 100644
--- a/ui/gfx/canvas_skia.cc
+++ b/ui/gfx/canvas_skia.cc
@@ -84,15 +84,15 @@ bool PixelShouldGetHalo(const SkBitmap& bitmap,
// Strips accelerator character prefixes in |text| if needed, based on |flags|.
// Returns a range in |text| to underline or gfx::Range::InvalidRange() if
// underlining is not needed.
-gfx::Range StripAcceleratorChars(int flags, base::string16* text) {
+Range StripAcceleratorChars(int flags, base::string16* text) {
if (flags & (Canvas::SHOW_PREFIX | Canvas::HIDE_PREFIX)) {
int char_pos = -1;
int char_span = 0;
*text = RemoveAcceleratorChar(*text, '&', &char_pos, &char_span);
if ((flags & Canvas::SHOW_PREFIX) && char_pos != -1)
- return gfx::Range(char_pos, char_pos + char_span);
+ return Range(char_pos, char_pos + char_span);
}
- return gfx::Range::InvalidRange();
+ return Range::InvalidRange();
}
// Elides |text| and adjusts |range| appropriately. If eliding causes |range|
@@ -100,7 +100,7 @@ gfx::Range StripAcceleratorChars(int flags, base::string16* text) {
void ElideTextAndAdjustRange(const FontList& font_list,
int width,
base::string16* text,
- gfx::Range* range) {
+ Range* range) {
const base::char16 start_char =
(range->IsValid() ? text->at(range->start()) : 0);
*text = gfx::ElideText(*text, font_list, width, gfx::ELIDE_AT_END);
@@ -108,7 +108,7 @@ void ElideTextAndAdjustRange(const FontList& font_list,
return;
if (range->start() >= text->length() ||
text->at(range->start()) != start_char) {
- *range = gfx::Range::InvalidRange();
+ *range = Range::InvalidRange();
}
}
@@ -272,7 +272,7 @@ void Canvas::DrawStringRectWithShadows(const base::string16& text,
&strings);
for (size_t i = 0; i < strings.size(); i++) {
- gfx::Range range = StripAcceleratorChars(flags, &strings[i]);
+ Range range = StripAcceleratorChars(flags, &strings[i]);
UpdateRenderText(rect, strings[i], font_list, flags, color,
render_text.get());
int line_padding = 0;
@@ -299,7 +299,7 @@ void Canvas::DrawStringRectWithShadows(const base::string16& text,
rect += Vector2d(0, line_height);
}
} else {
- gfx::Range range = StripAcceleratorChars(flags, &adjusted_text);
+ Range range = StripAcceleratorChars(flags, &adjusted_text);
bool elide_text = ((flags & NO_ELLIPSIS) == 0);
#if defined(OS_LINUX)
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
index 5f47528..47f42e3 100644
--- a/ui/gfx/render_text.cc
+++ b/ui/gfx/render_text.cc
@@ -288,8 +288,8 @@ StyleIterator::StyleIterator(const BreakList<SkColor>& colors,
StyleIterator::~StyleIterator() {}
-gfx::Range StyleIterator::GetRange() const {
- gfx::Range range(colors_.GetRange(color_));
+Range StyleIterator::GetRange() const {
+ Range range(colors_.GetRange(color_));
for (size_t i = 0; i < NUM_TEXT_STYLES; ++i)
range = range.Intersect(styles_[i].GetRange(style_[i]));
return range;
@@ -450,8 +450,8 @@ void RenderText::MoveCursor(BreakType break_type,
bool RenderText::MoveCursorTo(const SelectionModel& model) {
// Enforce valid selection model components.
size_t text_length = text().length();
- gfx::Range range(std::min(model.selection().start(), text_length),
- std::min(model.caret_pos(), text_length));
+ Range range(std::min(model.selection().start(), text_length),
+ std::min(model.caret_pos(), text_length));
// The current model only supports caret positions at valid character indices.
if (!IsCursorablePosition(range.start()) ||
!IsCursorablePosition(range.end()))
@@ -469,9 +469,9 @@ bool RenderText::MoveCursorTo(const Point& point, bool select) {
return MoveCursorTo(position);
}
-bool RenderText::SelectRange(const gfx::Range& range) {
- gfx::Range sel(std::min(range.start(), text().length()),
- std::min(range.end(), text().length()));
+bool RenderText::SelectRange(const Range& range) {
+ Range sel(std::min(range.start(), text().length()),
+ std::min(range.end(), text().length()));
if (!IsCursorablePosition(sel.start()) || !IsCursorablePosition(sel.end()))
return false;
LogicalCursorDirection affinity =
@@ -495,8 +495,7 @@ void RenderText::ClearSelection() {
void RenderText::SelectAll(bool reversed) {
const size_t length = text().length();
- const gfx::Range all = reversed ? gfx::Range(length, 0) :
- gfx::Range(0, length);
+ const Range all = reversed ? Range(length, 0) : Range(0, length);
const bool success = SelectRange(all);
DCHECK(success);
}
@@ -537,13 +536,13 @@ void RenderText::SelectWord() {
MoveCursorTo(reversed ? selection_min : selection_max, true);
}
-const gfx::Range& RenderText::GetCompositionRange() const {
+const Range& RenderText::GetCompositionRange() const {
return composition_range_;
}
-void RenderText::SetCompositionRange(const gfx::Range& composition_range) {
+void RenderText::SetCompositionRange(const Range& composition_range) {
CHECK(!composition_range.IsValid() ||
- gfx::Range(0, text_.length()).Contains(composition_range));
+ Range(0, text_.length()).Contains(composition_range));
composition_range_.set_end(composition_range.end());
composition_range_.set_start(composition_range.start());
ResetLayout();
@@ -559,7 +558,7 @@ void RenderText::SetColor(SkColor value) {
#endif
}
-void RenderText::ApplyColor(SkColor value, const gfx::Range& range) {
+void RenderText::ApplyColor(SkColor value, const Range& range) {
colors_.ApplyValue(value, range);
#if defined(OS_WIN)
@@ -584,9 +583,7 @@ void RenderText::SetStyle(TextStyle style, bool value) {
}
}
-void RenderText::ApplyStyle(TextStyle style,
- bool value,
- const gfx::Range& range) {
+void RenderText::ApplyStyle(TextStyle style, bool value, const Range& range) {
styles_[style].ApplyValue(value, range);
// Only invalidate the layout on font changes; not for colors or decorations.
@@ -728,7 +725,7 @@ Rect RenderText::GetCursorBounds(const SelectionModel& caret,
} else {
size_t grapheme_start = (caret_affinity == CURSOR_FORWARD) ?
caret_pos : IndexOfAdjacentGrapheme(caret_pos, CURSOR_BACKWARD);
- gfx::Range xspan(GetGlyphBounds(grapheme_start));
+ Range xspan(GetGlyphBounds(grapheme_start));
if (insert_mode) {
x = (caret_affinity == CURSOR_BACKWARD) ? xspan.end() : xspan.start();
} else { // overtype mode
@@ -769,7 +766,7 @@ size_t RenderText::IndexOfAdjacentGrapheme(size_t index,
}
SelectionModel RenderText::GetSelectionModelForSelectionStart() {
- const gfx::Range& sel = selection();
+ const Range& sel = selection();
if (sel.is_empty())
return selection_model_;
return SelectionModel(sel.start(),
@@ -792,7 +789,7 @@ RenderText::RenderText()
selection_color_(kDefaultColor),
selection_background_focused_color_(kDefaultSelectionBackgroundColor),
focused_(false),
- composition_range_(gfx::Range::InvalidRange()),
+ composition_range_(Range::InvalidRange()),
colors_(kDefaultColor),
styles_(NUM_TEXT_STYLES),
composition_and_selection_styles_applied_(false),
@@ -875,7 +872,7 @@ void RenderText::ApplyCompositionAndSelectionStyles() {
// Apply the selected text color to the [un-reversed] selection range.
if (!selection().is_empty()) {
- const gfx::Range range(selection().GetMin(), selection().GetMax());
+ const Range range(selection().GetMin(), selection().GetMax());
colors_.ApplyValue(selection_color_, range);
}
composition_and_selection_styles_applied_ = true;
@@ -1029,20 +1026,20 @@ void RenderText::ApplyTextShadows(internal::SkiaTextRenderer* renderer) {
}
// static
-bool RenderText::RangeContainsCaret(const gfx::Range& range,
+bool RenderText::RangeContainsCaret(const Range& range,
size_t caret_pos,
LogicalCursorDirection caret_affinity) {
// NB: exploits unsigned wraparound (WG14/N1124 section 6.2.5 paragraph 9).
size_t adjacent = (caret_affinity == CURSOR_BACKWARD) ?
caret_pos - 1 : caret_pos + 1;
- return range.Contains(gfx::Range(caret_pos, adjacent));
+ return range.Contains(Range(caret_pos, adjacent));
}
void RenderText::MoveCursorTo(size_t position, bool select) {
size_t cursor = std::min(position, text().length());
if (IsCursorablePosition(cursor))
SetSelectionModel(SelectionModel(
- gfx::Range(select ? selection().start() : cursor, cursor),
+ Range(select ? selection().start() : cursor, cursor),
(cursor == 0) ? CURSOR_FORWARD : CURSOR_BACKWARD));
}
diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h
index fe4720f..598f4e1 100644
--- a/ui/gfx/render_text.h
+++ b/ui/gfx/render_text.h
@@ -96,7 +96,7 @@ class StyleIterator {
bool style(TextStyle s) const { return style_[s]->second; }
// Get the intersecting range of the current iterator set.
- gfx::Range GetRange() const;
+ Range GetRange() const;
// Update the iterator to point to colors and styles applicable at |position|.
void UpdatePosition(size_t position);
@@ -246,7 +246,7 @@ class UI_EXPORT RenderText {
const SelectionModel& selection_model() const { return selection_model_; }
- const gfx::Range& selection() const { return selection_model_.selection(); }
+ const Range& selection() const { return selection_model_.selection(); }
size_t cursor_position() const { return selection_model_.caret_pos(); }
void SetCursorPosition(size_t position);
@@ -275,7 +275,7 @@ class UI_EXPORT RenderText {
// to be the text length.
// If the |range| start or end is not a cursorable position (not on grapheme
// boundary), it is a NO-OP and returns false. Otherwise, returns true.
- bool SelectRange(const gfx::Range& range);
+ bool SelectRange(const Range& range);
// Returns true if the local point is over selected text.
bool IsPointInSelection(const Point& point);
@@ -293,19 +293,19 @@ class UI_EXPORT RenderText {
// boundaries.
void SelectWord();
- const gfx::Range& GetCompositionRange() const;
- void SetCompositionRange(const gfx::Range& composition_range);
+ const Range& GetCompositionRange() const;
+ void SetCompositionRange(const Range& composition_range);
// Set the text color over the entire text or a logical character range.
// The |range| should be valid, non-reversed, and within [0, text().length()].
void SetColor(SkColor value);
- void ApplyColor(SkColor value, const gfx::Range& range);
+ void ApplyColor(SkColor value, const Range& range);
// Set various text styles over the entire text or a logical character range.
// The respective |style| is applied if |value| is true, or removed if false.
// The |range| should be valid, non-reversed, and within [0, text().length()].
void SetStyle(TextStyle style, bool value);
- void ApplyStyle(TextStyle style, bool value, const gfx::Range& range);
+ void ApplyStyle(TextStyle style, bool value, const Range& range);
// Returns whether this style is enabled consistently across the entire
// RenderText.
@@ -374,7 +374,7 @@ class UI_EXPORT RenderText {
// Sets shadows to drawn with text.
void SetTextShadows(const ShadowValues& shadows);
- typedef std::pair<Font, gfx::Range> FontSpan;
+ typedef std::pair<Font, Range> FontSpan;
// For testing purposes, returns which fonts were chosen for which parts of
// the text by returning a vector of Font and Range pairs, where each range
// specifies the character range for which the corresponding font has been
@@ -425,7 +425,7 @@ class UI_EXPORT RenderText {
// of the glyph starting at |index|. If the glyph is RTL then the returned
// Range will have is_reversed() true. (This does not return a Rect because a
// Rect can't have a negative width.)
- virtual gfx::Range GetGlyphBounds(size_t index) = 0;
+ virtual Range GetGlyphBounds(size_t index) = 0;
// Get the visual bounds containing the logical substring within the |range|.
// If |range| is empty, the result is empty. These bounds could be visually
@@ -433,7 +433,7 @@ class UI_EXPORT RenderText {
// These bounds are in local coordinates, but may be outside the visible
// region if the text is longer than the textfield. Subsequent text, cursor,
// or bounds changes may invalidate returned values.
- virtual std::vector<Rect> GetSubstringBounds(const gfx::Range& range) = 0;
+ virtual std::vector<Rect> GetSubstringBounds(const Range& range) = 0;
// Convert between indices into |text_| and indices into |obscured_text_|,
// which differ when the text is obscured. Regardless of whether or not the
@@ -489,7 +489,7 @@ class UI_EXPORT RenderText {
// A convenience function to check whether the glyph attached to the caret
// is within the given range.
- static bool RangeContainsCaret(const gfx::Range& range,
+ static bool RangeContainsCaret(const Range& range,
size_t caret_pos,
LogicalCursorDirection caret_affinity);
@@ -575,7 +575,7 @@ class UI_EXPORT RenderText {
bool focused_;
// Composition text range.
- gfx::Range composition_range_;
+ Range composition_range_;
// Color and style breaks, used to color and stylize ranges of text.
// BreakList positions are stored with text indices, not layout indices.
diff --git a/ui/gfx/render_text_linux.cc b/ui/gfx/render_text_linux.cc
index 11bc487..acb9f90b 100644
--- a/ui/gfx/render_text_linux.cc
+++ b/ui/gfx/render_text_linux.cc
@@ -42,7 +42,7 @@ bool IsForwardMotion(VisualCursorDirection direction, const PangoItem* item) {
// Checks whether |range| contains |index|. This is not the same as calling
// |range.Contains(gfx::Range(index))| - as that would return true when
// |index| == |range.end()|.
-bool IndexInRange(const gfx::Range& range, size_t index) {
+bool IndexInRange(const Range& range, size_t index) {
return index >= range.start() && index < range.end();
}
@@ -137,7 +137,7 @@ std::vector<RenderText::FontSpan> RenderTextLinux::GetFontSpansForTesting() {
PangoItem* item = reinterpret_cast<PangoLayoutRun*>(it->data)->item;
const int start = LayoutIndexToTextIndex(item->offset);
const int end = LayoutIndexToTextIndex(item->offset + item->length);
- const gfx::Range range(start, end);
+ const Range range(start, end);
ScopedPangoFontDescription desc(pango_font_describe(item->analysis.font));
spans.push_back(RenderText::FontSpan(Font(desc.get()), range));
@@ -214,14 +214,14 @@ SelectionModel RenderTextLinux::AdjacentWordSelectionModel(
return cur;
}
-gfx::Range RenderTextLinux::GetGlyphBounds(size_t index) {
+Range RenderTextLinux::GetGlyphBounds(size_t index) {
PangoRectangle pos;
pango_layout_index_to_pos(layout_, TextIndexToLayoutIndex(index), &pos);
// TODO(derat): Support fractional ranges for subpixel positioning?
- return gfx::Range(PANGO_PIXELS(pos.x), PANGO_PIXELS(pos.x + pos.width));
+ return Range(PANGO_PIXELS(pos.x), PANGO_PIXELS(pos.x + pos.width));
}
-std::vector<Rect> RenderTextLinux::GetSubstringBounds(const gfx::Range& range) {
+std::vector<Rect> RenderTextLinux::GetSubstringBounds(const Range& range) {
DCHECK_LE(range.GetMax(), text().length());
if (range.is_empty())
return std::vector<Rect>();
@@ -428,7 +428,7 @@ void RenderTextLinux::DrawVisualText(Canvas* canvas) {
// Track the current style and its text (not layout) index range.
style.UpdatePosition(GetGlyphTextIndex(run, style_start_glyph_index));
- gfx::Range style_range = style.GetRange();
+ Range style_range = style.GetRange();
do {
const PangoGlyphInfo& glyph = run->glyphs->glyphs[glyph_index];
@@ -478,7 +478,7 @@ GSList* RenderTextLinux::GetRunContainingCaret(
GSList* run = current_line_->runs;
while (run) {
PangoItem* item = reinterpret_cast<PangoLayoutRun*>(run->data)->item;
- gfx::Range item_range(item->offset, item->offset + item->length);
+ Range item_range(item->offset, item->offset + item->length);
if (RangeContainsCaret(item_range, position, affinity))
return run;
run = run->next;
diff --git a/ui/gfx/render_text_linux.h b/ui/gfx/render_text_linux.h
index 39aaaef..1500fc0 100644
--- a/ui/gfx/render_text_linux.h
+++ b/ui/gfx/render_text_linux.h
@@ -32,9 +32,8 @@ class RenderTextLinux : public RenderText {
virtual SelectionModel AdjacentWordSelectionModel(
const SelectionModel& selection,
VisualCursorDirection direction) OVERRIDE;
- virtual gfx::Range GetGlyphBounds(size_t index) OVERRIDE;
- virtual std::vector<Rect> GetSubstringBounds(
- const gfx::Range& range) OVERRIDE;
+ virtual Range GetGlyphBounds(size_t index) OVERRIDE;
+ virtual std::vector<Rect> GetSubstringBounds(const Range& range) OVERRIDE;
virtual size_t TextIndexToLayoutIndex(size_t index) const OVERRIDE;
virtual size_t LayoutIndexToTextIndex(size_t index) const OVERRIDE;
virtual bool IsCursorablePosition(size_t position) OVERRIDE;
diff --git a/ui/gfx/render_text_mac.cc b/ui/gfx/render_text_mac.cc
index 39460b5..eebee49 100644
--- a/ui/gfx/render_text_mac.cc
+++ b/ui/gfx/render_text_mac.cc
@@ -47,8 +47,7 @@ std::vector<RenderText::FontSpan> RenderTextMac::GetFontSpansForTesting() {
for (size_t i = 0; i < runs_.size(); ++i) {
gfx::Font font(runs_[i].font_name, runs_[i].text_size);
const CFRange cf_range = CTRunGetStringRange(runs_[i].ct_run);
- const gfx::Range range(cf_range.location,
- cf_range.location + cf_range.length);
+ const Range range(cf_range.location, cf_range.location + cf_range.length);
spans.push_back(RenderText::FontSpan(font, range));
}
@@ -69,12 +68,12 @@ SelectionModel RenderTextMac::AdjacentWordSelectionModel(
return SelectionModel();
}
-gfx::Range RenderTextMac::GetGlyphBounds(size_t index) {
+Range RenderTextMac::GetGlyphBounds(size_t index) {
// TODO(asvitkine): Implement this. http://crbug.com/131618
- return gfx::Range();
+ return Range();
}
-std::vector<Rect> RenderTextMac::GetSubstringBounds(const gfx::Range& range) {
+std::vector<Rect> RenderTextMac::GetSubstringBounds(const Range& range) {
// TODO(asvitkine): Implement this. http://crbug.com/131618
return std::vector<Rect>();
}
diff --git a/ui/gfx/render_text_mac.h b/ui/gfx/render_text_mac.h
index 41259bc..be5f128 100644
--- a/ui/gfx/render_text_mac.h
+++ b/ui/gfx/render_text_mac.h
@@ -39,9 +39,8 @@ class RenderTextMac : public RenderText {
virtual SelectionModel AdjacentWordSelectionModel(
const SelectionModel& selection,
VisualCursorDirection direction) OVERRIDE;
- virtual gfx::Range GetGlyphBounds(size_t index) OVERRIDE;
- virtual std::vector<Rect> GetSubstringBounds(
- const gfx::Range& range) OVERRIDE;
+ virtual Range GetGlyphBounds(size_t index) OVERRIDE;
+ virtual std::vector<Rect> GetSubstringBounds(const Range& range) OVERRIDE;
virtual size_t TextIndexToLayoutIndex(size_t index) const OVERRIDE;
virtual size_t LayoutIndexToTextIndex(size_t index) const OVERRIDE;
virtual bool IsCursorablePosition(size_t position) OVERRIDE;
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index 5d1b248..52cb834 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -43,7 +43,7 @@ const wchar_t kRtlLtrRtl[] = L"\x5d0" L"a" L"\x5d1";
// Checks whether |range| contains |index|. This is not the same as calling
// |range.Contains(gfx::Range(index))| - as that would return true when
// |index| == |range.end()|.
-bool IndexInRange(const gfx::Range& range, size_t index) {
+bool IndexInRange(const Range& range, size_t index) {
return index >= range.start() && index < range.end();
}
@@ -125,8 +125,8 @@ TEST_F(RenderTextTest, ApplyColorAndStyle) {
render_text->SetText(ASCIIToUTF16("012345678"));
// Apply a ranged color and style and check the resulting breaks.
- render_text->ApplyColor(SK_ColorRED, gfx::Range(1, 4));
- render_text->ApplyStyle(BOLD, true, gfx::Range(2, 5));
+ render_text->ApplyColor(SK_ColorRED, Range(1, 4));
+ render_text->ApplyStyle(BOLD, true, Range(2, 5));
std::vector<std::pair<size_t, SkColor> > expected_color;
expected_color.push_back(std::pair<size_t, SkColor>(0, SK_ColorBLACK));
expected_color.push_back(std::pair<size_t, SkColor>(1, SK_ColorRED));
@@ -147,8 +147,8 @@ TEST_F(RenderTextTest, ApplyColorAndStyle) {
// Apply a color and style over the text end and check the resulting breaks.
// (INT_MAX should be used instead of the text length for the range end)
const size_t text_length = render_text->text().length();
- render_text->ApplyColor(SK_ColorRED, gfx::Range(0, text_length));
- render_text->ApplyStyle(BOLD, true, gfx::Range(2, text_length));
+ render_text->ApplyColor(SK_ColorRED, Range(0, text_length));
+ render_text->ApplyStyle(BOLD, true, Range(2, text_length));
std::vector<std::pair<size_t, SkColor> > expected_color_end;
expected_color_end.push_back(std::pair<size_t, SkColor>(0, SK_ColorRED));
EXPECT_TRUE(render_text->colors().EqualsForTesting(expected_color_end));
@@ -158,9 +158,9 @@ TEST_F(RenderTextTest, ApplyColorAndStyle) {
EXPECT_TRUE(render_text->styles()[BOLD].EqualsForTesting(expected_style_end));
// Ensure ranged values adjust to accommodate text length changes.
- render_text->ApplyStyle(ITALIC, true, gfx::Range(0, 2));
- render_text->ApplyStyle(ITALIC, true, gfx::Range(3, 6));
- render_text->ApplyStyle(ITALIC, true, gfx::Range(7, text_length));
+ render_text->ApplyStyle(ITALIC, true, Range(0, 2));
+ render_text->ApplyStyle(ITALIC, true, Range(3, 6));
+ render_text->ApplyStyle(ITALIC, true, Range(7, text_length));
std::vector<std::pair<size_t, bool> > expected_italic;
expected_italic.push_back(std::pair<size_t, bool>(0, true));
expected_italic.push_back(std::pair<size_t, bool>(2, false));
@@ -188,8 +188,8 @@ TEST_F(RenderTextTest, PangoAttributes) {
render_text->SetText(ASCIIToUTF16("012345678"));
// Apply ranged BOLD/ITALIC styles and check the resulting Pango attributes.
- render_text->ApplyStyle(BOLD, true, gfx::Range(2, 4));
- render_text->ApplyStyle(ITALIC, true, gfx::Range(1, 3));
+ render_text->ApplyStyle(BOLD, true, Range(2, 4));
+ render_text->ApplyStyle(ITALIC, true, Range(1, 3));
struct {
int start;
@@ -240,22 +240,22 @@ void TestVisualCursorMotionInObscuredField(RenderText* render_text,
render_text->SetText(text);
int len = text.length();
render_text->MoveCursor(LINE_BREAK, CURSOR_RIGHT, select);
- EXPECT_EQ(SelectionModel(gfx::Range(select ? 0 : len, len), CURSOR_FORWARD),
+ EXPECT_EQ(SelectionModel(Range(select ? 0 : len, len), CURSOR_FORWARD),
render_text->selection_model());
render_text->MoveCursor(LINE_BREAK, CURSOR_LEFT, select);
EXPECT_EQ(SelectionModel(0, CURSOR_BACKWARD), render_text->selection_model());
for (int j = 1; j <= len; ++j) {
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_RIGHT, select);
- EXPECT_EQ(SelectionModel(gfx::Range(select ? 0 : j, j), CURSOR_BACKWARD),
+ EXPECT_EQ(SelectionModel(Range(select ? 0 : j, j), CURSOR_BACKWARD),
render_text->selection_model());
}
for (int j = len - 1; j >= 0; --j) {
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_LEFT, select);
- EXPECT_EQ(SelectionModel(gfx::Range(select ? 0 : j, j), CURSOR_FORWARD),
+ EXPECT_EQ(SelectionModel(Range(select ? 0 : j, j), CURSOR_FORWARD),
render_text->selection_model());
}
render_text->MoveCursor(WORD_BREAK, CURSOR_RIGHT, select);
- EXPECT_EQ(SelectionModel(gfx::Range(select ? 0 : len, len), CURSOR_FORWARD),
+ EXPECT_EQ(SelectionModel(Range(select ? 0 : len, len), CURSOR_FORWARD),
render_text->selection_model());
render_text->MoveCursor(WORD_BREAK, CURSOR_LEFT, select);
EXPECT_EQ(SelectionModel(0, CURSOR_BACKWARD), render_text->selection_model());
@@ -879,8 +879,8 @@ TEST_F(RenderTextTest, SelectAll) {
// Ensure that SelectAll respects the |reversed| argument regardless of
// application locale and text content directionality.
scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
- const SelectionModel expected_reversed(gfx::Range(3, 0), CURSOR_FORWARD);
- const SelectionModel expected_forwards(gfx::Range(0, 3), CURSOR_BACKWARD);
+ const SelectionModel expected_reversed(Range(3, 0), CURSOR_FORWARD);
+ const SelectionModel expected_forwards(Range(0, 3), CURSOR_BACKWARD);
const bool was_rtl = base::i18n::IsRTL();
for (size_t i = 0; i < 2; ++i) {
@@ -907,39 +907,39 @@ TEST_F(RenderTextTest, SelectAll) {
render_text->SetText(WideToUTF16(L"abc\x05d0\x05d1\x05d2"));
// Left arrow on select ranging (6, 4).
render_text->MoveCursor(LINE_BREAK, CURSOR_RIGHT, false);
- EXPECT_EQ(gfx::Range(6), render_text->selection());
+ EXPECT_EQ(Range(6), render_text->selection());
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_LEFT, false);
- EXPECT_EQ(gfx::Range(4), render_text->selection());
+ EXPECT_EQ(Range(4), render_text->selection());
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_LEFT, false);
- EXPECT_EQ(gfx::Range(5), render_text->selection());
+ EXPECT_EQ(Range(5), render_text->selection());
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_LEFT, false);
- EXPECT_EQ(gfx::Range(6), render_text->selection());
+ EXPECT_EQ(Range(6), render_text->selection());
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_RIGHT, true);
- EXPECT_EQ(gfx::Range(6, 5), render_text->selection());
+ EXPECT_EQ(Range(6, 5), render_text->selection());
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_RIGHT, true);
- EXPECT_EQ(gfx::Range(6, 4), render_text->selection());
+ EXPECT_EQ(Range(6, 4), render_text->selection());
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_LEFT, false);
- EXPECT_EQ(gfx::Range(6), render_text->selection());
+ EXPECT_EQ(Range(6), render_text->selection());
// Right arrow on select ranging (4, 6).
render_text->MoveCursor(LINE_BREAK, CURSOR_LEFT, false);
- EXPECT_EQ(gfx::Range(0), render_text->selection());
+ EXPECT_EQ(Range(0), render_text->selection());
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_RIGHT, false);
- EXPECT_EQ(gfx::Range(1), render_text->selection());
+ EXPECT_EQ(Range(1), render_text->selection());
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_RIGHT, false);
- EXPECT_EQ(gfx::Range(2), render_text->selection());
+ EXPECT_EQ(Range(2), render_text->selection());
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_RIGHT, false);
- EXPECT_EQ(gfx::Range(3), render_text->selection());
+ EXPECT_EQ(Range(3), render_text->selection());
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_RIGHT, false);
- EXPECT_EQ(gfx::Range(5), render_text->selection());
+ EXPECT_EQ(Range(5), render_text->selection());
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_RIGHT, false);
- EXPECT_EQ(gfx::Range(4), render_text->selection());
+ EXPECT_EQ(Range(4), render_text->selection());
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_LEFT, true);
- EXPECT_EQ(gfx::Range(4, 5), render_text->selection());
+ EXPECT_EQ(Range(4, 5), render_text->selection());
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_LEFT, true);
- EXPECT_EQ(gfx::Range(4, 6), render_text->selection());
+ EXPECT_EQ(Range(4, 6), render_text->selection());
render_text->MoveCursor(CHARACTER_BREAK, CURSOR_RIGHT, false);
- EXPECT_EQ(gfx::Range(4), render_text->selection());
+ EXPECT_EQ(Range(4), render_text->selection());
}
#endif // !defined(OS_MACOSX)
@@ -1226,7 +1226,7 @@ TEST_F(RenderTextTest, StringSizeBoldWidth) {
EXPECT_GT(bold_width, plain_width);
// Now, apply a plain style over the first word only.
- render_text->ApplyStyle(BOLD, false, gfx::Range(0, 5));
+ render_text->ApplyStyle(BOLD, false, Range(0, 5));
const int plain_bold_width = render_text->GetStringSize().width();
EXPECT_GT(plain_bold_width, plain_width);
EXPECT_LT(plain_bold_width, bold_width);
@@ -1465,7 +1465,7 @@ TEST_F(RenderTextTest, SelectWord) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) {
render_text->SetCursorPosition(cases[i].cursor);
render_text->SelectWord();
- EXPECT_EQ(gfx::Range(cases[i].selection_start, cases[i].selection_end),
+ EXPECT_EQ(Range(cases[i].selection_start, cases[i].selection_end),
render_text->selection());
}
}
@@ -1498,13 +1498,13 @@ TEST_F(RenderTextTest, SelectMultipleWords) {
scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
render_text->SetText(ASCIIToUTF16(kTestURL));
- render_text->SelectRange(gfx::Range(16, 20));
+ render_text->SelectRange(Range(16, 20));
render_text->SelectWord();
EXPECT_EQ(ASCIIToUTF16("google.com"), GetSelectedText(render_text.get()));
EXPECT_FALSE(render_text->selection().is_reversed());
// SelectWord should preserve the selection direction.
- render_text->SelectRange(gfx::Range(20, 16));
+ render_text->SelectRange(Range(20, 16));
render_text->SelectWord();
EXPECT_EQ(ASCIIToUTF16("google.com"), GetSelectedText(render_text.get()));
EXPECT_TRUE(render_text->selection().is_reversed());
@@ -1643,7 +1643,7 @@ TEST_F(RenderTextTest, SelectionKeepsLigatures) {
for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
render_text->SetText(WideToUTF16(kTestStrings[i]));
const int expected_width = render_text->GetStringSize().width();
- render_text->MoveCursorTo(SelectionModel(gfx::Range(0, 1), CURSOR_FORWARD));
+ render_text->MoveCursorTo(SelectionModel(Range(0, 1), CURSOR_FORWARD));
EXPECT_EQ(expected_width, render_text->GetStringSize().width());
// Draw the text. It shouldn't hit any DCHECKs or crash.
// See http://crbug.com/214150
diff --git a/ui/gfx/render_text_win.cc b/ui/gfx/render_text_win.cc
index f0e42bd..e283de3 100644
--- a/ui/gfx/render_text_win.cc
+++ b/ui/gfx/render_text_win.cc
@@ -134,25 +134,25 @@ bool IsUnicodeBidiControlCharacter(char16 c) {
// Returns the corresponding glyph range of the given character range.
// |range| is in text-space (0 corresponds to |GetLayoutText()[0]|).
// Returned value is in run-space (0 corresponds to the first glyph in the run).
-gfx::Range CharRangeToGlyphRange(const internal::TextRun& run,
- const gfx::Range& range) {
+Range CharRangeToGlyphRange(const internal::TextRun& run,
+ const Range& range) {
DCHECK(run.range.Contains(range));
DCHECK(!range.is_reversed());
DCHECK(!range.is_empty());
- const gfx::Range run_range = gfx::Range(range.start() - run.range.start(),
- range.end() - run.range.start());
- gfx::Range result;
+ const Range run_range(range.start() - run.range.start(),
+ range.end() - run.range.start());
+ Range result;
if (run.script_analysis.fRTL) {
- result = gfx::Range(run.logical_clusters[run_range.end() - 1],
+ result = Range(run.logical_clusters[run_range.end() - 1],
run_range.start() > 0 ? run.logical_clusters[run_range.start() - 1]
: run.glyph_count);
} else {
- result = gfx::Range(run.logical_clusters[run_range.start()],
+ result = Range(run.logical_clusters[run_range.start()],
run_range.end() < run.range.length() ?
run.logical_clusters[run_range.end()] : run.glyph_count);
}
DCHECK(!result.is_reversed());
- DCHECK(gfx::Range(0, run.glyph_count).Contains(result));
+ DCHECK(Range(0, run.glyph_count).Contains(result));
return result;
}
@@ -534,8 +534,8 @@ std::vector<RenderText::FontSpan> RenderTextWin::GetFontSpansForTesting() {
std::vector<RenderText::FontSpan> spans;
for (size_t i = 0; i < runs_.size(); ++i) {
spans.push_back(RenderText::FontSpan(runs_[i]->font,
- gfx::Range(LayoutIndexToTextIndex(runs_[i]->range.start()),
- LayoutIndexToTextIndex(runs_[i]->range.end()))));
+ Range(LayoutIndexToTextIndex(runs_[i]->range.start()),
+ LayoutIndexToTextIndex(runs_[i]->range.end()))));
}
return spans;
@@ -632,7 +632,7 @@ SelectionModel RenderTextWin::AdjacentWordSelectionModel(
return SelectionModel(pos, CURSOR_FORWARD);
}
-gfx::Range RenderTextWin::GetGlyphBounds(size_t index) {
+Range RenderTextWin::GetGlyphBounds(size_t index) {
const size_t run_index =
GetRunContainingCaret(SelectionModel(index, CURSOR_FORWARD));
// Return edge bounds if the index is invalid or beyond the layout text size.
@@ -640,16 +640,16 @@ gfx::Range RenderTextWin::GetGlyphBounds(size_t index) {
return Range(string_width_);
internal::TextRun* run = runs_[run_index];
const size_t layout_index = TextIndexToLayoutIndex(index);
- return gfx::Range(GetGlyphXBoundary(run, layout_index, false),
- GetGlyphXBoundary(run, layout_index, true));
+ return Range(GetGlyphXBoundary(run, layout_index, false),
+ GetGlyphXBoundary(run, layout_index, true));
}
-std::vector<Rect> RenderTextWin::GetSubstringBounds(const gfx::Range& range) {
+std::vector<Rect> RenderTextWin::GetSubstringBounds(const Range& range) {
DCHECK(!needs_layout_);
- DCHECK(gfx::Range(0, text().length()).Contains(range));
- gfx::Range layout_range(TextIndexToLayoutIndex(range.start()),
- TextIndexToLayoutIndex(range.end()));
- DCHECK(gfx::Range(0, GetLayoutText().length()).Contains(layout_range));
+ DCHECK(Range(0, text().length()).Contains(range));
+ Range layout_range(TextIndexToLayoutIndex(range.start()),
+ TextIndexToLayoutIndex(range.end()));
+ DCHECK(Range(0, GetLayoutText().length()).Contains(layout_range));
std::vector<Rect> rects;
if (layout_range.is_empty())
@@ -660,11 +660,11 @@ std::vector<Rect> RenderTextWin::GetSubstringBounds(const gfx::Range& range) {
// TODO(msw): The bounds should probably not always be leading the range ends.
for (size_t i = 0; i < runs_.size(); ++i) {
const internal::TextRun* run = runs_[visual_to_logical_[i]];
- gfx::Range intersection = run->range.Intersect(layout_range);
+ Range intersection = run->range.Intersect(layout_range);
if (intersection.IsValid()) {
DCHECK(!intersection.is_reversed());
- gfx::Range range_x(GetGlyphXBoundary(run, intersection.start(), false),
- GetGlyphXBoundary(run, intersection.end(), false));
+ Range range_x(GetGlyphXBoundary(run, intersection.start(), false),
+ GetGlyphXBoundary(run, intersection.end(), false));
if (range_x.is_empty())
continue;
range_x = Range(range_x.GetMin(), range_x.GetMax());
diff --git a/ui/gfx/render_text_win.h b/ui/gfx/render_text_win.h
index b5e77b8..423e31f 100644
--- a/ui/gfx/render_text_win.h
+++ b/ui/gfx/render_text_win.h
@@ -23,7 +23,7 @@ struct TextRun {
TextRun();
~TextRun();
- gfx::Range range;
+ Range range;
Font font;
// A gfx::Font::FontStyle flag to specify bold and italic styles.
// Supersedes |font.GetFontStyle()|. Stored separately to avoid calling
@@ -76,9 +76,8 @@ class RenderTextWin : public RenderText {
virtual SelectionModel AdjacentWordSelectionModel(
const SelectionModel& selection,
VisualCursorDirection direction) OVERRIDE;
- virtual gfx::Range GetGlyphBounds(size_t index) OVERRIDE;
- virtual std::vector<Rect> GetSubstringBounds(
- const gfx::Range& range) OVERRIDE;
+ virtual Range GetGlyphBounds(size_t index) OVERRIDE;
+ virtual std::vector<Rect> GetSubstringBounds(const Range& range) OVERRIDE;
virtual size_t TextIndexToLayoutIndex(size_t index) const OVERRIDE;
virtual size_t LayoutIndexToTextIndex(size_t index) const OVERRIDE;
virtual bool IsCursorablePosition(size_t position) OVERRIDE;
diff --git a/ui/gfx/selection_model.cc b/ui/gfx/selection_model.cc
index 1aac031..5352d86 100644
--- a/ui/gfx/selection_model.cc
+++ b/ui/gfx/selection_model.cc
@@ -10,14 +10,17 @@
namespace gfx {
SelectionModel::SelectionModel()
- : selection_(0), caret_affinity_(CURSOR_BACKWARD) {}
+ : selection_(0),
+ caret_affinity_(CURSOR_BACKWARD) {}
SelectionModel::SelectionModel(size_t position, LogicalCursorDirection affinity)
- : selection_(position), caret_affinity_(affinity) {}
+ : selection_(position),
+ caret_affinity_(affinity) {}
-SelectionModel::SelectionModel(gfx::Range selection,
+SelectionModel::SelectionModel(const Range& selection,
LogicalCursorDirection affinity)
- : selection_(selection), caret_affinity_(affinity) {}
+ : selection_(selection),
+ caret_affinity_(affinity) {}
bool SelectionModel::operator==(const SelectionModel& sel) const {
return selection_ == sel.selection() &&
diff --git a/ui/gfx/selection_model.h b/ui/gfx/selection_model.h
index 3832b9d..0b811d1 100644
--- a/ui/gfx/selection_model.h
+++ b/ui/gfx/selection_model.h
@@ -67,9 +67,9 @@ class UI_EXPORT SelectionModel {
SelectionModel(size_t position, LogicalCursorDirection affinity);
// Create a SelectionModel representing a selection (which may be empty).
// The caret position is the end of the range.
- SelectionModel(gfx::Range selection, LogicalCursorDirection affinity);
+ SelectionModel(const Range& selection, LogicalCursorDirection affinity);
- const gfx::Range& selection() const { return selection_; }
+ const Range& selection() const { return selection_; }
size_t caret_pos() const { return selection_.end(); }
LogicalCursorDirection caret_affinity() const { return caret_affinity_; }
@@ -87,7 +87,7 @@ class UI_EXPORT SelectionModel {
void set_selection_start(size_t pos) { selection_.set_start(pos); }
// Logical selection. The logical caret position is the end of the selection.
- gfx::Range selection_;
+ Range selection_;
// The logical direction from the caret position (selection_.end()) to the
// character it is attached to for display purposes. This matters only when