Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: ui/gfx/render_text_harfbuzz.cc

Issue 2348143003: MacViews: Implement Force Touch/Mac dictionary lookup for Textfields. (Closed)
Patch Set: Address review. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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++) {
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 int style = Font::NORMAL;
1611 if (run.italic)
1612 style |= Font::ITALIC;
1613 if (run.underline)
1614 style |= Font::UNDERLINE;
1615
1616 Font font_with_style = run.font.Derive(0, style, run.weight);
1617
1618 // Get range relative to the decorated text.
1619 DecoratedText::RangedAttribute attribute(
1620 gfx::Range(intersection.start() - range.GetMin(),
1621 intersection.end() - range.GetMin()),
1622 font_with_style);
1623
1624 attribute.strike = run.strike;
1625 attribute.diagonal_strike = run.diagonal_strike;
1626 decorated_text->attributes.push_back(attribute);
1627 }
1628 }
1629 return true;
1630 }
1631
1593 } // namespace gfx 1632 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698