Chromium Code Reviews| 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 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1583 internal::TextRunList* RenderTextHarfBuzz::GetRunList() { | 1583 internal::TextRunList* RenderTextHarfBuzz::GetRunList() { |
| 1584 DCHECK(!update_layout_run_list_); | 1584 DCHECK(!update_layout_run_list_); |
| 1585 DCHECK(!update_display_run_list_); | 1585 DCHECK(!update_display_run_list_); |
| 1586 return text_elided() ? display_run_list_.get() : &layout_run_list_; | 1586 return text_elided() ? display_run_list_.get() : &layout_run_list_; |
| 1587 } | 1587 } |
| 1588 | 1588 |
| 1589 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { | 1589 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { |
| 1590 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); | 1590 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); |
| 1591 } | 1591 } |
| 1592 | 1592 |
| 1593 bool RenderTextHarfBuzz::GetDecoratedTextForRange( | |
| 1594 const Range& range, | |
| 1595 DecoratedText* decorated_text) const { | |
| 1596 if (obscured()) | |
| 1597 return false; | |
| 1598 | |
| 1599 decorated_text->attributes.clear(); | |
| 1600 decorated_text->text = GetTextFromRange(range); | |
| 1601 | |
| 1602 const internal::TextRunList* run_list = GetRunList(); | |
| 1603 for (size_t i = 0; i < run_list->size(); i++) { | |
|
tapted
2016/09/26 02:02:31
What would be necessary to put this on the RenderT
karandeepb
2016/09/26 07:00:08
Yeah this seems plausible and may allow us to move
tapted
2016/09/26 08:07:26
DecoratedText could allow someone to apply multipl
karandeepb
2016/09/26 09:22:07
Oh ok, so basically providing a way for RenderText
| |
| 1604 const internal::TextRunHarfBuzz& run = *run_list->runs()[i]; | |
| 1605 | |
| 1606 const Range intersection = range.Intersect(run.range); | |
| 1607 DCHECK(!intersection.is_reversed()); | |
| 1608 | |
| 1609 if (!intersection.is_empty()) { | |
| 1610 // Get range relative to the decorated text. | |
| 1611 DecoratedText::RangedAttribute attribute( | |
| 1612 gfx::Range(intersection.start() - range.GetMin(), | |
| 1613 intersection.end() - range.GetMin()), | |
| 1614 run.font); | |
| 1615 attribute.weight = run.weight; | |
| 1616 attribute.underline = run.underline; | |
| 1617 attribute.italic = run.italic; | |
| 1618 attribute.strike = run.strike; | |
| 1619 attribute.diagonal_strike = run.diagonal_strike; | |
| 1620 decorated_text->attributes.push_back(attribute); | |
| 1621 } | |
| 1622 } | |
| 1623 return true; | |
| 1624 } | |
| 1625 | |
| 1593 } // namespace gfx | 1626 } // namespace gfx |
| OLD | NEW |