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.h" | 5 #include "ui/gfx/render_text.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <climits> | 8 #include <climits> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 paint->setSubpixelText(params.subpixel_positioning); | 396 paint->setSubpixelText(params.subpixel_positioning); |
397 paint->setAutohinted(params.autohinter); | 397 paint->setAutohinted(params.autohinter); |
398 paint->setHinting(FontRenderParamsHintingToSkPaintHinting(params.hinting)); | 398 paint->setHinting(FontRenderParamsHintingToSkPaintHinting(params.hinting)); |
399 } | 399 } |
400 | 400 |
401 } // namespace internal | 401 } // namespace internal |
402 | 402 |
403 RenderText::~RenderText() { | 403 RenderText::~RenderText() { |
404 } | 404 } |
405 | 405 |
406 // static | |
406 RenderText* RenderText::CreateInstance() { | 407 RenderText* RenderText::CreateInstance() { |
407 #if defined(OS_MACOSX) | 408 #if defined(OS_MACOSX) |
408 static const bool use_native = | 409 static const bool use_native = |
409 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 410 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
410 switches::kEnableHarfBuzzRenderText); | 411 switches::kEnableHarfBuzzRenderText); |
411 if (use_native) | 412 if (use_native) |
412 return new RenderTextMac; | 413 return new RenderTextMac; |
413 #endif // defined(OS_MACOSX) | 414 #endif // defined(OS_MACOSX) |
414 return new RenderTextHarfBuzz; | 415 return new RenderTextHarfBuzz; |
415 } | 416 } |
416 | 417 |
418 // static | |
417 RenderText* RenderText::CreateInstanceForEditing() { | 419 RenderText* RenderText::CreateInstanceForEditing() { |
418 return new RenderTextHarfBuzz; | 420 return new RenderTextHarfBuzz; |
419 } | 421 } |
420 | 422 |
421 void RenderText::SetText(const base::string16& text) { | 423 void RenderText::SetText(const base::string16& text) { |
422 DCHECK(!composition_range_.IsValid()); | 424 DCHECK(!composition_range_.IsValid()); |
423 if (text_ == text) | 425 if (text_ == text) |
424 return; | 426 return; |
425 text_ = text; | 427 text_ = text; |
426 | 428 |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1087 | 1089 |
1088 HorizontalAlignment RenderText::GetCurrentHorizontalAlignment() { | 1090 HorizontalAlignment RenderText::GetCurrentHorizontalAlignment() { |
1089 if (horizontal_alignment_ != ALIGN_TO_HEAD) | 1091 if (horizontal_alignment_ != ALIGN_TO_HEAD) |
1090 return horizontal_alignment_; | 1092 return horizontal_alignment_; |
1091 return GetDisplayTextDirection() == base::i18n::RIGHT_TO_LEFT ? | 1093 return GetDisplayTextDirection() == base::i18n::RIGHT_TO_LEFT ? |
1092 ALIGN_RIGHT : ALIGN_LEFT; | 1094 ALIGN_RIGHT : ALIGN_LEFT; |
1093 } | 1095 } |
1094 | 1096 |
1095 Vector2d RenderText::GetAlignmentOffset(size_t line_number) { | 1097 Vector2d RenderText::GetAlignmentOffset(size_t line_number) { |
1096 // TODO(ckocagil): Enable |lines_| usage in other platforms. | 1098 // TODO(ckocagil): Enable |lines_| usage in other platforms. |
1097 #if defined(OS_WIN) | 1099 #if defined(OS_WIN) |
msw
2015/02/20 01:55:53
Change the #ifs in this function to check Multilin
Jun Mukai
2015/02/25 21:15:40
Done.
| |
1098 DCHECK_LT(line_number, lines_.size()); | 1100 DCHECK_LT(line_number, lines_.size()); |
1099 #endif | 1101 #endif |
1100 Vector2d offset; | 1102 Vector2d offset; |
1101 HorizontalAlignment horizontal_alignment = GetCurrentHorizontalAlignment(); | 1103 HorizontalAlignment horizontal_alignment = GetCurrentHorizontalAlignment(); |
1102 if (horizontal_alignment != ALIGN_LEFT) { | 1104 if (horizontal_alignment != ALIGN_LEFT) { |
1103 #if defined(OS_WIN) | 1105 #if defined(OS_WIN) |
1104 const int width = std::ceil(lines_[line_number].size.width()) + | 1106 const int width = std::ceil(lines_[line_number].size.width()) + |
1105 (cursor_enabled_ ? 1 : 0); | 1107 (cursor_enabled_ ? 1 : 0); |
1106 #else | 1108 #else |
1107 const int width = GetContentWidth(); | 1109 const int width = GetContentWidth(); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1457 | 1459 |
1458 SetDisplayOffset(display_offset_.x() + delta_x); | 1460 SetDisplayOffset(display_offset_.x() + delta_x); |
1459 } | 1461 } |
1460 | 1462 |
1461 void RenderText::DrawSelection(Canvas* canvas) { | 1463 void RenderText::DrawSelection(Canvas* canvas) { |
1462 for (const Rect& s : GetSubstringBounds(selection())) | 1464 for (const Rect& s : GetSubstringBounds(selection())) |
1463 canvas->FillRect(s, selection_background_focused_color_); | 1465 canvas->FillRect(s, selection_background_focused_color_); |
1464 } | 1466 } |
1465 | 1467 |
1466 } // namespace gfx | 1468 } // namespace gfx |
OLD | NEW |