| 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 // that belong to the same run. | 397 // that belong to the same run. |
| 398 void AddLineSegment(const internal::LineSegment& segment) { | 398 void AddLineSegment(const internal::LineSegment& segment) { |
| 399 DCHECK(!lines_.empty()); | 399 DCHECK(!lines_.empty()); |
| 400 internal::Line* line = &lines_.back(); | 400 internal::Line* line = &lines_.back(); |
| 401 const internal::TextRunHarfBuzz& run = *(run_list_.runs()[segment.run]); | 401 const internal::TextRunHarfBuzz& run = *(run_list_.runs()[segment.run]); |
| 402 if (!line->segments.empty()) { | 402 if (!line->segments.empty()) { |
| 403 internal::LineSegment& last_segment = line->segments.back(); | 403 internal::LineSegment& last_segment = line->segments.back(); |
| 404 // Merge segments that belong to the same run. | 404 // Merge segments that belong to the same run. |
| 405 if (last_segment.run == segment.run) { | 405 if (last_segment.run == segment.run) { |
| 406 DCHECK_EQ(last_segment.char_range.end(), segment.char_range.start()); | 406 DCHECK_EQ(last_segment.char_range.end(), segment.char_range.start()); |
| 407 // Check there is less than a pixel between one run and the next. |
| 407 DCHECK_LE( | 408 DCHECK_LE( |
| 408 std::abs(last_segment.x_range.end() - segment.x_range.start()), | 409 std::abs(last_segment.x_range.end() - segment.x_range.start()), |
| 409 std::numeric_limits<float>::epsilon()); | 410 1.0f); |
| 410 last_segment.char_range.set_end(segment.char_range.end()); | 411 last_segment.char_range.set_end(segment.char_range.end()); |
| 411 last_segment.x_range.set_end(SkScalarToFloat(text_x_) + | 412 last_segment.x_range.set_end(SkScalarToFloat(text_x_) + |
| 412 segment.width()); | 413 segment.width()); |
| 413 if (run.is_rtl && last_segment.char_range.end() == run.range.end()) | 414 if (run.is_rtl && last_segment.char_range.end() == run.range.end()) |
| 414 UpdateRTLSegmentRanges(); | 415 UpdateRTLSegmentRanges(); |
| 415 line->size.set_width(line->size.width() + segment.width()); | 416 line->size.set_width(line->size.width() + segment.width()); |
| 416 text_x_ += segment.width(); | 417 text_x_ += segment.width(); |
| 417 available_width_ -= segment.width(); | 418 available_width_ -= segment.width(); |
| 418 return; | 419 return; |
| 419 } | 420 } |
| (...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 DCHECK(!update_layout_run_list_); | 1581 DCHECK(!update_layout_run_list_); |
| 1581 DCHECK(!update_display_run_list_); | 1582 DCHECK(!update_display_run_list_); |
| 1582 return text_elided() ? display_run_list_.get() : &layout_run_list_; | 1583 return text_elided() ? display_run_list_.get() : &layout_run_list_; |
| 1583 } | 1584 } |
| 1584 | 1585 |
| 1585 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { | 1586 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { |
| 1586 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); | 1587 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); |
| 1587 } | 1588 } |
| 1588 | 1589 |
| 1589 } // namespace gfx | 1590 } // namespace gfx |
| OLD | NEW |