| 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" |
| 11 #include "ui/base/text/text_elider.h" | 11 #include "ui/base/text/text_elider.h" |
| 12 #include "ui/gfx/font.h" | 12 #include "ui/gfx/font.h" |
| 13 #include "ui/gfx/font_list.h" | 13 #include "ui/gfx/font_list.h" |
| 14 #include "ui/gfx/insets.h" | 14 #include "ui/gfx/insets.h" |
| 15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 16 #include "ui/gfx/render_text.h" | 16 #include "ui/gfx/render_text.h" |
| 17 #include "ui/gfx/shadow_value.h" | 17 #include "ui/gfx/shadow_value.h" |
| 18 #include "ui/gfx/skia_util.h" | 18 #include "ui/gfx/skia_util.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // If necessary, wraps |text| with RTL/LTR directionality characters based on | 22 // If necessary, wraps |text| with RTL/LTR directionality characters based on |
| 23 // |flags| and |text| content. | 23 // |flags| and |text| content. |
| 24 // Returns true if the text will be rendered right-to-left. | 24 // Returns true if the text will be rendered right-to-left. |
| 25 // TODO(asvitkine): Support setting directionality directly on RenderText, so | 25 // TODO(msw): Nix this, now that RenderTextWin supports directionality directly. |
| 26 // that wrapping the text is not needed. | |
| 27 bool AdjustStringDirection(int flags, string16* text) { | 26 bool AdjustStringDirection(int flags, string16* text) { |
| 27 // TODO(msw): FORCE_LTR_DIRECTIONALITY does not work for RTL text now. |
| 28 |
| 28 // If the string is empty or LTR was forced, simply return false since the | 29 // If the string is empty or LTR was forced, simply return false since the |
| 29 // default RenderText directionality is already LTR. | 30 // default RenderText directionality is already LTR. |
| 30 if (text->empty() || (flags & gfx::Canvas::FORCE_LTR_DIRECTIONALITY)) | 31 if (text->empty() || (flags & gfx::Canvas::FORCE_LTR_DIRECTIONALITY)) |
| 31 return false; | 32 return false; |
| 32 | 33 |
| 33 // If RTL is forced, apply it to the string. | 34 // If RTL is forced, apply it to the string. |
| 34 if (flags & gfx::Canvas::FORCE_RTL_DIRECTIONALITY) { | 35 if (flags & gfx::Canvas::FORCE_RTL_DIRECTIONALITY) { |
| 35 base::i18n::WrapStringWithRTLFormatting(text); | 36 base::i18n::WrapStringWithRTLFormatting(text); |
| 36 return true; | 37 return true; |
| 37 } | 38 } |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 rect.set_height(line_height); | 469 rect.set_height(line_height); |
| 469 render_text->SetDisplayRect(rect); | 470 render_text->SetDisplayRect(rect); |
| 470 | 471 |
| 471 canvas_->save(SkCanvas::kClip_SaveFlag); | 472 canvas_->save(SkCanvas::kClip_SaveFlag); |
| 472 ClipRect(display_rect); | 473 ClipRect(display_rect); |
| 473 render_text->Draw(this); | 474 render_text->Draw(this); |
| 474 canvas_->restore(); | 475 canvas_->restore(); |
| 475 } | 476 } |
| 476 | 477 |
| 477 } // namespace gfx | 478 } // namespace gfx |
| OLD | NEW |