OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_harfbuzz.h" | 5 #include "ui/gfx/render_text_harfbuzz.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/i18n/bidi_line_iterator.h" | 10 #include "base/i18n/bidi_line_iterator.h" |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 std::unique_ptr<RenderText> RenderTextHarfBuzz::CreateInstanceOfSameType() | 775 std::unique_ptr<RenderText> RenderTextHarfBuzz::CreateInstanceOfSameType() |
776 const { | 776 const { |
777 return base::WrapUnique(new RenderTextHarfBuzz); | 777 return base::WrapUnique(new RenderTextHarfBuzz); |
778 } | 778 } |
779 | 779 |
780 bool RenderTextHarfBuzz::MultilineSupported() const { | 780 bool RenderTextHarfBuzz::MultilineSupported() const { |
781 return true; | 781 return true; |
782 } | 782 } |
783 | 783 |
784 const base::string16& RenderTextHarfBuzz::GetDisplayText() { | 784 const base::string16& RenderTextHarfBuzz::GetDisplayText() { |
785 // TODO(oshima): Consider supporting eliding multi-line text. | 785 // TODO(krb): Consider other elision modes for multiline. |
786 // This requires max_line support first. | 786 if ((multiline() && (max_lines() == 0 || elide_behavior() != ELIDE_TAIL)) || |
787 if (multiline() || | 787 elide_behavior() == NO_ELIDE || elide_behavior() == FADE_TAIL) { |
788 elide_behavior() == NO_ELIDE || | |
789 elide_behavior() == FADE_TAIL) { | |
790 // Call UpdateDisplayText to clear |display_text_| and |text_elided_| | 788 // Call UpdateDisplayText to clear |display_text_| and |text_elided_| |
791 // on the RenderText class. | 789 // on the RenderText class. |
792 UpdateDisplayText(0); | 790 UpdateDisplayText(0); |
793 update_display_text_ = false; | 791 update_display_text_ = false; |
794 display_run_list_.reset(); | 792 display_run_list_.reset(); |
795 return layout_text(); | 793 return layout_text(); |
796 } | 794 } |
797 | 795 |
798 EnsureLayoutRunList(); | 796 EnsureLayoutRunList(); |
799 DCHECK(!update_display_text_); | 797 DCHECK(!update_display_text_); |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1564 UpdateDisplayText(multiline() ? 0 : layout_run_list_.width()); | 1562 UpdateDisplayText(multiline() ? 0 : layout_run_list_.width()); |
1565 update_display_text_ = false; | 1563 update_display_text_ = false; |
1566 update_display_run_list_ = text_elided(); | 1564 update_display_run_list_ = text_elided(); |
1567 } | 1565 } |
1568 } | 1566 } |
1569 | 1567 |
1570 base::i18n::BreakIterator* RenderTextHarfBuzz::GetGraphemeIterator() { | 1568 base::i18n::BreakIterator* RenderTextHarfBuzz::GetGraphemeIterator() { |
1571 if (update_grapheme_iterator_) { | 1569 if (update_grapheme_iterator_) { |
1572 update_grapheme_iterator_ = false; | 1570 update_grapheme_iterator_ = false; |
1573 grapheme_iterator_.reset(new base::i18n::BreakIterator( | 1571 grapheme_iterator_.reset(new base::i18n::BreakIterator( |
1574 GetDisplayText(), | 1572 GetDisplayText(), |
tapted
2016/05/11 00:16:26
So thinking about it some more - I think this is t
| |
1575 base::i18n::BreakIterator::BREAK_CHARACTER)); | 1573 base::i18n::BreakIterator::BREAK_CHARACTER)); |
1576 if (!grapheme_iterator_->Init()) | 1574 if (!grapheme_iterator_->Init()) |
1577 grapheme_iterator_.reset(); | 1575 grapheme_iterator_.reset(); |
1578 } | 1576 } |
1579 return grapheme_iterator_.get(); | 1577 return grapheme_iterator_.get(); |
1580 } | 1578 } |
1581 | 1579 |
1582 internal::TextRunList* RenderTextHarfBuzz::GetRunList() { | 1580 internal::TextRunList* RenderTextHarfBuzz::GetRunList() { |
1583 DCHECK(!update_layout_run_list_); | 1581 DCHECK(!update_layout_run_list_); |
1584 DCHECK(!update_display_run_list_); | 1582 DCHECK(!update_display_run_list_); |
1585 return text_elided() ? display_run_list_.get() : &layout_run_list_; | 1583 return text_elided() ? display_run_list_.get() : &layout_run_list_; |
1586 } | 1584 } |
1587 | 1585 |
1588 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { | 1586 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { |
1589 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); | 1587 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); |
1590 } | 1588 } |
1591 | 1589 |
1592 } // namespace gfx | 1590 } // namespace gfx |
OLD | NEW |