| 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 "ui/gfx/render_text_win.h" | 5 #include "ui/gfx/render_text_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/i18n/break_iterator.h" | 9 #include "base/i18n/break_iterator.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 } | 335 } |
| 336 | 336 |
| 337 void RenderTextWin::SetSelectionModel(const SelectionModel& model) { | 337 void RenderTextWin::SetSelectionModel(const SelectionModel& model) { |
| 338 RenderText::SetSelectionModel(model); | 338 RenderText::SetSelectionModel(model); |
| 339 // TODO(xji|msw): The text selection color is applied in ItemizeLogicalText(). | 339 // TODO(xji|msw): The text selection color is applied in ItemizeLogicalText(). |
| 340 // So, the layout must be updated in order to draw the proper selection range. | 340 // So, the layout must be updated in order to draw the proper selection range. |
| 341 // Colors should be applied in DrawVisualText(), as done by RenderTextLinux. | 341 // Colors should be applied in DrawVisualText(), as done by RenderTextLinux. |
| 342 ResetLayout(); | 342 ResetLayout(); |
| 343 } | 343 } |
| 344 | 344 |
| 345 void RenderTextWin::GetGlyphBounds(size_t index, | 345 ui::Range RenderTextWin::GetGlyphBounds(size_t index) { |
| 346 ui::Range* xspan, | |
| 347 int* height) { | |
| 348 const size_t run_index = | 346 const size_t run_index = |
| 349 GetRunContainingCaret(SelectionModel(index, CURSOR_FORWARD)); | 347 GetRunContainingCaret(SelectionModel(index, CURSOR_FORWARD)); |
| 350 DCHECK_LT(run_index, runs_.size()); | 348 DCHECK_LT(run_index, runs_.size()); |
| 351 internal::TextRun* run = runs_[run_index]; | 349 internal::TextRun* run = runs_[run_index]; |
| 352 const size_t layout_index = TextIndexToLayoutIndex(index); | 350 const size_t layout_index = TextIndexToLayoutIndex(index); |
| 353 xspan->set_start(GetGlyphXBoundary(run, layout_index, false)); | 351 return ui::Range(GetGlyphXBoundary(run, layout_index, false), |
| 354 xspan->set_end(GetGlyphXBoundary(run, layout_index, true)); | 352 GetGlyphXBoundary(run, layout_index, true)); |
| 355 *height = run->font.GetHeight(); | |
| 356 } | 353 } |
| 357 | 354 |
| 358 std::vector<Rect> RenderTextWin::GetSubstringBounds(const ui::Range& range) { | 355 std::vector<Rect> RenderTextWin::GetSubstringBounds(const ui::Range& range) { |
| 359 DCHECK(!needs_layout_); | 356 DCHECK(!needs_layout_); |
| 360 DCHECK(ui::Range(0, text().length()).Contains(range)); | 357 DCHECK(ui::Range(0, text().length()).Contains(range)); |
| 361 ui::Range layout_range(TextIndexToLayoutIndex(range.start()), | 358 ui::Range layout_range(TextIndexToLayoutIndex(range.start()), |
| 362 TextIndexToLayoutIndex(range.end())); | 359 TextIndexToLayoutIndex(range.end())); |
| 363 DCHECK(ui::Range(0, GetLayoutText().length()).Contains(layout_range)); | 360 DCHECK(ui::Range(0, GetLayoutText().length()).Contains(layout_range)); |
| 364 | 361 |
| 365 std::vector<Rect> bounds; | 362 std::vector<Rect> bounds; |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 size_t position = LayoutIndexToTextIndex(run->range.end()); | 836 size_t position = LayoutIndexToTextIndex(run->range.end()); |
| 840 position = IndexOfAdjacentGrapheme(position, CURSOR_BACKWARD); | 837 position = IndexOfAdjacentGrapheme(position, CURSOR_BACKWARD); |
| 841 return SelectionModel(position, CURSOR_FORWARD); | 838 return SelectionModel(position, CURSOR_FORWARD); |
| 842 } | 839 } |
| 843 | 840 |
| 844 RenderText* RenderText::CreateInstance() { | 841 RenderText* RenderText::CreateInstance() { |
| 845 return new RenderTextWin; | 842 return new RenderTextWin; |
| 846 } | 843 } |
| 847 | 844 |
| 848 } // namespace gfx | 845 } // namespace gfx |
| OLD | NEW |