| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "ui/gfx/render_text.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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 return base::i18n::RIGHT_TO_LEFT; | 334 return base::i18n::RIGHT_TO_LEFT; |
| 335 return base::i18n::LEFT_TO_RIGHT; | 335 return base::i18n::LEFT_TO_RIGHT; |
| 336 } | 336 } |
| 337 | 337 |
| 338 int RenderText::GetStringWidth() { | 338 int RenderText::GetStringWidth() { |
| 339 return default_style_.font.GetStringWidth(text()); | 339 return default_style_.font.GetStringWidth(text()); |
| 340 } | 340 } |
| 341 | 341 |
| 342 void RenderText::Draw(Canvas* canvas) { | 342 void RenderText::Draw(Canvas* canvas) { |
| 343 // Clip the canvas to the text display area. | 343 // Clip the canvas to the text display area. |
| 344 canvas->ClipRectInt(display_rect_.x(), display_rect_.y(), | 344 canvas->ClipRectInt(display_rect_); |
| 345 display_rect_.width(), display_rect_.height()); | |
| 346 | 345 |
| 347 // Draw the selection. | 346 // Draw the selection. |
| 348 std::vector<Rect> selection(GetSubstringBounds(GetSelectionStart(), | 347 std::vector<Rect> selection(GetSubstringBounds(GetSelectionStart(), |
| 349 GetCursorPosition())); | 348 GetCursorPosition())); |
| 350 SkColor selection_color = | 349 SkColor selection_color = |
| 351 focused() ? kFocusedSelectionColor : kUnfocusedSelectionColor; | 350 focused() ? kFocusedSelectionColor : kUnfocusedSelectionColor; |
| 352 for (std::vector<Rect>::const_iterator i = selection.begin(); | 351 for (std::vector<Rect>::const_iterator i = selection.begin(); |
| 353 i < selection.end(); ++i) { | 352 i < selection.end(); ++i) { |
| 354 Rect r(*i); | 353 Rect r(*i); |
| 355 canvas->FillRectInt(selection_color, r.x(), r.y(), r.width(), r.height()); | 354 canvas->FillRectInt(selection_color, r.x(), r.y(), r.width(), r.height()); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 // LTR character. | 653 // LTR character. |
| 655 // | 654 // |
| 656 // Pan to show the cursor when it overflows to the left. | 655 // Pan to show the cursor when it overflows to the left. |
| 657 delta_offset = display_rect_.x() - cursor_bounds_.x(); | 656 delta_offset = display_rect_.x() - cursor_bounds_.x(); |
| 658 } | 657 } |
| 659 display_offset_.Offset(delta_offset, 0); | 658 display_offset_.Offset(delta_offset, 0); |
| 660 cursor_bounds_.Offset(delta_offset, 0); | 659 cursor_bounds_.Offset(delta_offset, 0); |
| 661 } | 660 } |
| 662 | 661 |
| 663 } // namespace gfx | 662 } // namespace gfx |
| OLD | NEW |