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/canvas.h" | 5 #include "ui/gfx/canvas.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "ui/base/range/range.h" | 10 #include "ui/base/range/range.h" |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 desired_characters_to_truncate_from_head, | 454 desired_characters_to_truncate_from_head, |
455 text.length()); | 455 text.length()); |
456 clipped_text = text.substr(desired_characters_to_truncate_from_head); | 456 clipped_text = text.substr(desired_characters_to_truncate_from_head); |
457 } | 457 } |
458 | 458 |
459 render_text->set_fade_tail(true); | 459 render_text->set_fade_tail(true); |
460 render_text->set_fade_head(true); | 460 render_text->set_fade_head(true); |
461 break; | 461 break; |
462 } | 462 } |
463 | 463 |
| 464 // Default to left alignment unless right alignment was chosen above. |
| 465 if (!(flags & TEXT_ALIGN_RIGHT)) |
| 466 flags |= TEXT_ALIGN_LEFT; |
| 467 |
464 gfx::Rect rect = display_rect; | 468 gfx::Rect rect = display_rect; |
465 UpdateRenderText(rect, clipped_text, font, flags, color, render_text.get()); | 469 UpdateRenderText(rect, clipped_text, font, flags, color, render_text.get()); |
466 | 470 |
467 const int line_height = render_text->GetStringSize().height(); | 471 const int line_height = render_text->GetStringSize().height(); |
468 rect.Offset(0, VAlignText(line_height, flags, display_rect.height())); | 472 rect.Offset(0, VAlignText(line_height, flags, display_rect.height())); |
469 rect.set_height(line_height); | 473 rect.set_height(line_height); |
470 render_text->SetDisplayRect(rect); | 474 render_text->SetDisplayRect(rect); |
471 | 475 |
472 canvas_->save(SkCanvas::kClip_SaveFlag); | 476 canvas_->save(SkCanvas::kClip_SaveFlag); |
473 ClipRect(display_rect); | 477 ClipRect(display_rect); |
474 render_text->Draw(this); | 478 render_text->Draw(this); |
475 canvas_->restore(); | 479 canvas_->restore(); |
476 } | 480 } |
477 | 481 |
478 } // namespace gfx | 482 } // namespace gfx |
OLD | NEW |