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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 paint->setSubpixelText(params.subpixel_positioning); | 395 paint->setSubpixelText(params.subpixel_positioning); |
396 paint->setAutohinted(params.autohinter); | 396 paint->setAutohinted(params.autohinter); |
397 paint->setHinting(FontRenderParamsHintingToSkPaintHinting(params.hinting)); | 397 paint->setHinting(FontRenderParamsHintingToSkPaintHinting(params.hinting)); |
398 } | 398 } |
399 | 399 |
400 } // namespace internal | 400 } // namespace internal |
401 | 401 |
402 RenderText::~RenderText() { | 402 RenderText::~RenderText() { |
403 } | 403 } |
404 | 404 |
405 // static | |
405 RenderText* RenderText::CreateInstance() { | 406 RenderText* RenderText::CreateInstance() { |
406 #if defined(OS_MACOSX) | 407 #if defined(OS_MACOSX) |
407 static const bool use_native = | 408 static const bool use_native = |
408 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 409 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
409 switches::kEnableHarfBuzzRenderText); | 410 switches::kEnableHarfBuzzRenderText); |
410 if (use_native) | 411 if (use_native) |
411 return new RenderTextMac; | 412 return new RenderTextMac; |
412 #endif // defined(OS_MACOSX) | 413 #endif // defined(OS_MACOSX) |
413 return new RenderTextHarfBuzz; | 414 return new RenderTextHarfBuzz; |
414 } | 415 } |
415 | 416 |
417 // static | |
416 RenderText* RenderText::CreateInstanceForEditing() { | 418 RenderText* RenderText::CreateInstanceForEditing() { |
417 return new RenderTextHarfBuzz; | 419 return new RenderTextHarfBuzz; |
418 } | 420 } |
419 | 421 |
422 // static | |
423 bool RenderText::MultilineSupported() { | |
424 // TODO(mukai): turn on for HarfBuzz when https://crrev.com/882643005/ is | |
msw
2015/02/05 20:16:41
Shouldn't this be non-static for RTHB=>true and RT
Jun Mukai
2015/02/12 21:43:04
Done.
| |
425 // ready. | |
426 return false; | |
427 } | |
428 | |
420 void RenderText::SetText(const base::string16& text) { | 429 void RenderText::SetText(const base::string16& text) { |
421 DCHECK(!composition_range_.IsValid()); | 430 DCHECK(!composition_range_.IsValid()); |
422 if (text_ == text) | 431 if (text_ == text) |
423 return; | 432 return; |
424 text_ = text; | 433 text_ = text; |
425 | 434 |
426 // Adjust ranged styles and colors to accommodate a new text length. | 435 // Adjust ranged styles and colors to accommodate a new text length. |
427 // Clear style ranges as they might break new text graphemes and apply | 436 // Clear style ranges as they might break new text graphemes and apply |
428 // the first style to the whole text instead. | 437 // the first style to the whole text instead. |
429 const size_t text_length = text_.length(); | 438 const size_t text_length = text_.length(); |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1416 SetDisplayOffset(display_offset_.x() + delta_x); | 1425 SetDisplayOffset(display_offset_.x() + delta_x); |
1417 } | 1426 } |
1418 | 1427 |
1419 void RenderText::DrawSelection(Canvas* canvas) { | 1428 void RenderText::DrawSelection(Canvas* canvas) { |
1420 const std::vector<Rect> sel = GetSubstringBounds(selection()); | 1429 const std::vector<Rect> sel = GetSubstringBounds(selection()); |
1421 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 1430 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
1422 canvas->FillRect(*i, selection_background_focused_color_); | 1431 canvas->FillRect(*i, selection_background_focused_color_); |
1423 } | 1432 } |
1424 | 1433 |
1425 } // namespace gfx | 1434 } // namespace gfx |
OLD | NEW |