| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ight reserved. | 3 * Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ight reserved. |
| 4 * Copyright (C) 2010 Google Inc. All rights reserved. | 4 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 5 * Copyright (C) 2013 Adobe Systems Incorporated. | 5 * Copyright (C) 2013 Adobe Systems Incorporated. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 return false; | 597 return false; |
| 598 if (m_width.availableWidth() <= LayoutUnit::epsilon()) | 598 if (m_width.availableWidth() <= LayoutUnit::epsilon()) |
| 599 return rewindToFirstMidWordBreak(text, style, font, breakAll, wordMeasur
ement); | 599 return rewindToFirstMidWordBreak(text, style, font, breakAll, wordMeasur
ement); |
| 600 | 600 |
| 601 TextRun run = constructTextRun(font, text, start, len, style); | 601 TextRun run = constructTextRun(font, text, start, len, style); |
| 602 run.setTabSize(!m_collapseWhiteSpace, style.getTabSize()); | 602 run.setTabSize(!m_collapseWhiteSpace, style.getTabSize()); |
| 603 run.setXPos(m_width.currentWidth()); | 603 run.setXPos(m_width.currentWidth()); |
| 604 | 604 |
| 605 // TODO(kojii): should be replaced with safe-to-break when hb is ready. | 605 // TODO(kojii): should be replaced with safe-to-break when hb is ready. |
| 606 float x = m_width.availableWidth() + LayoutUnit::epsilon() - m_width.current
Width(); | 606 float x = m_width.availableWidth() + LayoutUnit::epsilon() - m_width.current
Width(); |
| 607 if (run.rtl()) |
| 608 x = wordMeasurement.width - x; |
| 607 len = font.offsetForPosition(run, x, false); | 609 len = font.offsetForPosition(run, x, false); |
| 608 if (!len && !m_width.currentWidth()) | 610 if (!len && !m_width.currentWidth()) |
| 609 return rewindToFirstMidWordBreak(text, style, font, breakAll, wordMeasur
ement); | 611 return rewindToFirstMidWordBreak(text, style, font, breakAll, wordMeasur
ement); |
| 610 | 612 |
| 611 FloatRect rect = font.selectionRectForText(run, FloatPoint(), 0, 0, len); | |
| 612 // HarfBuzzShaper ignores includePartialGlyphs=false, so we need to find the | |
| 613 // real width that fits. Usually a few loops at maximum. | |
| 614 if (len && !m_width.fitsOnLine(rect.width())) { | |
| 615 for (; ; ) { | |
| 616 --len; | |
| 617 if (!len) { | |
| 618 rect.setWidth(0); | |
| 619 break; | |
| 620 } | |
| 621 rect = font.selectionRectForText(run, FloatPoint(), 0, 0, len); | |
| 622 if (m_width.fitsOnLine(rect.width())) | |
| 623 break; | |
| 624 } | |
| 625 } | |
| 626 | |
| 627 int end = start + len; | 613 int end = start + len; |
| 628 if (breakAll) { | 614 if (breakAll) { |
| 629 end = lastBreakablePositionForBreakAll(text, style, start, end); | 615 end = lastBreakablePositionForBreakAll(text, style, start, end); |
| 630 if (!end) | 616 if (!end) |
| 631 return false; | 617 return false; |
| 632 rect = font.selectionRectForText(run, FloatPoint(), 0, 0, end - start); | 618 len = end - start; |
| 633 } | 619 } |
| 634 | 620 FloatRect rect = font.selectionRectForText(run, FloatPoint(), 0, 0, len); |
| 621 DCHECK(m_width.fitsOnLine(rect.width() - 1)); // avoid failure when rect is
rounded up. |
| 635 return rewindToMidWordBreak(wordMeasurement, end, rect.width()); | 622 return rewindToMidWordBreak(wordMeasurement, end, rect.width()); |
| 636 } | 623 } |
| 637 | 624 |
| 638 inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, bool
& hyphenated) | 625 inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, bool
& hyphenated) |
| 639 { | 626 { |
| 640 if (!m_current.offset()) | 627 if (!m_current.offset()) |
| 641 m_appliedStartWidth = false; | 628 m_appliedStartWidth = false; |
| 642 | 629 |
| 643 LineLayoutText layoutText(m_current.getLineLayoutItem()); | 630 LineLayoutText layoutText(m_current.getLineLayoutItem()); |
| 644 | 631 |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 | 1082 |
| 1096 if (style.getTextIndentType() == TextIndentHanging) | 1083 if (style.getTextIndentType() == TextIndentHanging) |
| 1097 indentText = indentText == IndentText ? DoNotIndentText : IndentText; | 1084 indentText = indentText == IndentText ? DoNotIndentText : IndentText; |
| 1098 | 1085 |
| 1099 return indentText; | 1086 return indentText; |
| 1100 } | 1087 } |
| 1101 | 1088 |
| 1102 } // namespace blink | 1089 } // namespace blink |
| 1103 | 1090 |
| 1104 #endif // BreakingContextInlineHeaders_h | 1091 #endif // BreakingContextInlineHeaders_h |
| OLD | NEW |