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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 if (intersection.IsValid()) { | 374 if (intersection.IsValid()) { |
375 DCHECK(!intersection.is_reversed()); | 375 DCHECK(!intersection.is_reversed()); |
376 ui::Range range_x(GetGlyphXBoundary(run, intersection.start(), false), | 376 ui::Range range_x(GetGlyphXBoundary(run, intersection.start(), false), |
377 GetGlyphXBoundary(run, intersection.end(), false)); | 377 GetGlyphXBoundary(run, intersection.end(), false)); |
378 Rect rect(range_x.GetMin(), 0, range_x.length(), run->font.GetHeight()); | 378 Rect rect(range_x.GetMin(), 0, range_x.length(), run->font.GetHeight()); |
379 // Center the rect vertically in the display area. | 379 // Center the rect vertically in the display area. |
380 rect.Offset(0, (display_rect().height() - rect.height()) / 2); | 380 rect.Offset(0, (display_rect().height() - rect.height()) / 2); |
381 rect.set_origin(ToViewPoint(rect.origin())); | 381 rect.set_origin(ToViewPoint(rect.origin())); |
382 // Union this with the last rect if they're adjacent. | 382 // Union this with the last rect if they're adjacent. |
383 if (!bounds.empty() && rect.SharesEdgeWith(bounds.back())) { | 383 if (!bounds.empty() && rect.SharesEdgeWith(bounds.back())) { |
384 rect = rect.Union(bounds.back()); | 384 rect.Union(bounds.back()); |
385 bounds.pop_back(); | 385 bounds.pop_back(); |
386 } | 386 } |
387 bounds.push_back(rect); | 387 bounds.push_back(rect); |
388 } | 388 } |
389 } | 389 } |
390 return bounds; | 390 return bounds; |
391 } | 391 } |
392 | 392 |
393 size_t RenderTextWin::TextIndexToLayoutIndex(size_t index) const { | 393 size_t RenderTextWin::TextIndexToLayoutIndex(size_t index) const { |
394 if (!obscured()) | 394 if (!obscured()) |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 size_t position = LayoutIndexToTextIndex(run->range.end()); | 828 size_t position = LayoutIndexToTextIndex(run->range.end()); |
829 position = IndexOfAdjacentGrapheme(position, CURSOR_BACKWARD); | 829 position = IndexOfAdjacentGrapheme(position, CURSOR_BACKWARD); |
830 return SelectionModel(position, CURSOR_FORWARD); | 830 return SelectionModel(position, CURSOR_FORWARD); |
831 } | 831 } |
832 | 832 |
833 RenderText* RenderText::CreateInstance() { | 833 RenderText* RenderText::CreateInstance() { |
834 return new RenderTextWin; | 834 return new RenderTextWin; |
835 } | 835 } |
836 | 836 |
837 } // namespace gfx | 837 } // namespace gfx |
OLD | NEW |