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 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 DCHECK_LE( | |
| 408 std::abs(last_segment.x_range.end() - segment.x_range.start()), | |
| 409 std::numeric_limits<float>::epsilon()); | |
|
msw
2016/05/04 22:03:59
It seems like there's likely floating math roundin
xdai1
2016/05/04 22:49:46
I agree with you. Thanks for your suggestion!
| |
| 410 last_segment.char_range.set_end(segment.char_range.end()); | 407 last_segment.char_range.set_end(segment.char_range.end()); |
| 411 last_segment.x_range.set_end(SkScalarToFloat(text_x_) + | 408 last_segment.x_range.set_end(SkScalarToFloat(text_x_) + |
| 412 segment.width()); | 409 segment.width()); |
| 413 if (run.is_rtl && last_segment.char_range.end() == run.range.end()) | 410 if (run.is_rtl && last_segment.char_range.end() == run.range.end()) |
| 414 UpdateRTLSegmentRanges(); | 411 UpdateRTLSegmentRanges(); |
| 415 line->size.set_width(line->size.width() + segment.width()); | 412 line->size.set_width(line->size.width() + segment.width()); |
| 416 text_x_ += segment.width(); | 413 text_x_ += segment.width(); |
| 417 available_width_ -= segment.width(); | 414 available_width_ -= segment.width(); |
| 418 return; | 415 return; |
| 419 } | 416 } |
| (...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1580 DCHECK(!update_layout_run_list_); | 1577 DCHECK(!update_layout_run_list_); |
| 1581 DCHECK(!update_display_run_list_); | 1578 DCHECK(!update_display_run_list_); |
| 1582 return text_elided() ? display_run_list_.get() : &layout_run_list_; | 1579 return text_elided() ? display_run_list_.get() : &layout_run_list_; |
| 1583 } | 1580 } |
| 1584 | 1581 |
| 1585 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { | 1582 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { |
| 1586 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); | 1583 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); |
| 1587 } | 1584 } |
| 1588 | 1585 |
| 1589 } // namespace gfx | 1586 } // namespace gfx |
| OLD | NEW |