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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 inline void ensureLineBoxInsideIgnoredSpaces(LineMidpointState& lineMidpointStat
e, RenderObject* renderer) | 107 inline void ensureLineBoxInsideIgnoredSpaces(LineMidpointState& lineMidpointStat
e, RenderObject* renderer) |
108 { | 108 { |
109 InlineIterator midpoint(0, renderer, 0); | 109 InlineIterator midpoint(0, renderer, 0); |
110 stopIgnoringSpaces(lineMidpointState, midpoint); | 110 stopIgnoringSpaces(lineMidpointState, midpoint); |
111 startIgnoringSpaces(lineMidpointState, midpoint); | 111 startIgnoringSpaces(lineMidpointState, midpoint); |
112 } | 112 } |
113 | 113 |
114 // Adding a pair of midpoints before a character will split it out into a new li
ne box. | 114 // Adding a pair of midpoints before a character will split it out into a new li
ne box. |
115 inline void ensureCharacterGetsLineBox(LineMidpointState& lineMidpointState, Inl
ineIterator& textParagraphSeparator) | 115 inline void ensureCharacterGetsLineBox(LineMidpointState& lineMidpointState, Inl
ineIterator& textParagraphSeparator) |
116 { | 116 { |
117 InlineIterator midpoint(0, textParagraphSeparator.object(), textParagraphSep
arator.m_pos); | 117 InlineIterator midpoint(0, textParagraphSeparator.object(), textParagraphSep
arator.offset()); |
118 startIgnoringSpaces(lineMidpointState, InlineIterator(0, textParagraphSepara
tor.object(), textParagraphSeparator.m_pos - 1)); | 118 startIgnoringSpaces(lineMidpointState, InlineIterator(0, textParagraphSepara
tor.object(), textParagraphSeparator.offset() - 1)); |
119 stopIgnoringSpaces(lineMidpointState, InlineIterator(0, textParagraphSeparat
or.object(), textParagraphSeparator.m_pos)); | 119 stopIgnoringSpaces(lineMidpointState, InlineIterator(0, textParagraphSeparat
or.object(), textParagraphSeparator.offset())); |
120 } | 120 } |
121 | 121 |
122 class TrailingObjects { | 122 class TrailingObjects { |
123 public: | 123 public: |
124 TrailingObjects(); | 124 TrailingObjects(); |
125 void setTrailingWhitespace(RenderText*); | 125 void setTrailingWhitespace(RenderText*); |
126 void clear(); | 126 void clear(); |
127 void appendBoxIfNeeded(RenderBox*); | 127 void appendBoxIfNeeded(RenderBox*); |
128 | 128 |
129 enum CollapseFirstSpaceOrNot { DoNotCollapseFirstSpace, CollapseFirstSpace }
; | 129 enum CollapseFirstSpaceOrNot { DoNotCollapseFirstSpace, CollapseFirstSpace }
; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 return; | 167 return; |
168 | 168 |
169 // This object is either going to be part of the last midpoint, or it is goi
ng to be the actual endpoint. | 169 // This object is either going to be part of the last midpoint, or it is goi
ng to be the actual endpoint. |
170 // In both cases we just decrease our pos by 1 level to exclude the space, a
llowing it to - in effect - collapse into the newline. | 170 // In both cases we just decrease our pos by 1 level to exclude the space, a
llowing it to - in effect - collapse into the newline. |
171 if (lineMidpointState.numMidpoints % 2) { | 171 if (lineMidpointState.numMidpoints % 2) { |
172 // Find the trailing space object's midpoint. | 172 // Find the trailing space object's midpoint. |
173 int trailingSpaceMidpoint = lineMidpointState.numMidpoints - 1; | 173 int trailingSpaceMidpoint = lineMidpointState.numMidpoints - 1; |
174 for ( ; trailingSpaceMidpoint > 0 && lineMidpointState.midpoints[trailin
gSpaceMidpoint].object() != m_whitespace; --trailingSpaceMidpoint) { } | 174 for ( ; trailingSpaceMidpoint > 0 && lineMidpointState.midpoints[trailin
gSpaceMidpoint].object() != m_whitespace; --trailingSpaceMidpoint) { } |
175 ASSERT(trailingSpaceMidpoint >= 0); | 175 ASSERT(trailingSpaceMidpoint >= 0); |
176 if (collapseFirstSpace == CollapseFirstSpace) | 176 if (collapseFirstSpace == CollapseFirstSpace) |
177 lineMidpointState.midpoints[trailingSpaceMidpoint].m_pos--; | 177 lineMidpointState.midpoints[trailingSpaceMidpoint].setOffset(lineMid
pointState.midpoints[trailingSpaceMidpoint].offset() -1); |
178 | 178 |
179 // Now make sure every single trailingPositionedBox following the traili
ngSpaceMidpoint properly stops and starts | 179 // Now make sure every single trailingPositionedBox following the traili
ngSpaceMidpoint properly stops and starts |
180 // ignoring spaces. | 180 // ignoring spaces. |
181 size_t currentMidpoint = trailingSpaceMidpoint + 1; | 181 size_t currentMidpoint = trailingSpaceMidpoint + 1; |
182 for (size_t i = 0; i < m_boxes.size(); ++i) { | 182 for (size_t i = 0; i < m_boxes.size(); ++i) { |
183 if (currentMidpoint >= lineMidpointState.numMidpoints) { | 183 if (currentMidpoint >= lineMidpointState.numMidpoints) { |
184 // We don't have a midpoint for this box yet. | 184 // We don't have a midpoint for this box yet. |
185 ensureLineBoxInsideIgnoredSpaces(lineMidpointState, m_boxes[i]); | 185 ensureLineBoxInsideIgnoredSpaces(lineMidpointState, m_boxes[i]); |
186 } else { | 186 } else { |
187 ASSERT(lineMidpointState.midpoints[currentMidpoint].object() ==
m_boxes[i]); | 187 ASSERT(lineMidpointState.midpoints[currentMidpoint].object() ==
m_boxes[i]); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 { | 520 { |
521 RenderBox* floatBox = toRenderBox(m_current.object()); | 521 RenderBox* floatBox = toRenderBox(m_current.object()); |
522 FloatingObject* floatingObject = m_block->insertFloatingObject(floatBox); | 522 FloatingObject* floatingObject = m_block->insertFloatingObject(floatBox); |
523 // check if it fits in the current line. | 523 // check if it fits in the current line. |
524 // If it does, position it now, otherwise, position | 524 // If it does, position it now, otherwise, position |
525 // it after moving to next line (in newLine() func) | 525 // it after moving to next line (in newLine() func) |
526 // FIXME: Bug 110372: Properly position multiple stacked floats with non-rec
tangular shape outside. | 526 // FIXME: Bug 110372: Properly position multiple stacked floats with non-rec
tangular shape outside. |
527 if (m_floatsFitOnLine && m_width.fitsOnLine(m_block->logicalWidthForFloat(fl
oatingObject))) { | 527 if (m_floatsFitOnLine && m_width.fitsOnLine(m_block->logicalWidthForFloat(fl
oatingObject))) { |
528 m_block->positionNewFloatOnLine(floatingObject, m_lastFloatFromPreviousL
ine, m_lineInfo, m_width); | 528 m_block->positionNewFloatOnLine(floatingObject, m_lastFloatFromPreviousL
ine, m_lineInfo, m_width); |
529 if (m_lineBreak.object() == m_current.object()) { | 529 if (m_lineBreak.object() == m_current.object()) { |
530 ASSERT(!m_lineBreak.m_pos); | 530 ASSERT(!m_lineBreak.offset()); |
531 m_lineBreak.increment(); | 531 m_lineBreak.increment(); |
532 } | 532 } |
533 } else { | 533 } else { |
534 m_floatsFitOnLine = false; | 534 m_floatsFitOnLine = false; |
535 } | 535 } |
536 // Update prior line break context characters, using U+FFFD (OBJECT REPLACEM
ENT CHARACTER) for floating element. | 536 // Update prior line break context characters, using U+FFFD (OBJECT REPLACEM
ENT CHARACTER) for floating element. |
537 m_renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter
); | 537 m_renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter
); |
538 } | 538 } |
539 | 539 |
540 // This is currently just used for list markers and inline flows that have line
boxes. Neither should | 540 // This is currently just used for list markers and inline flows that have line
boxes. Neither should |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 m_width.addUncommittedWidth(replacedLogicalWidth); | 626 m_width.addUncommittedWidth(replacedLogicalWidth); |
627 } | 627 } |
628 if (m_current.object()->isRubyRun()) | 628 if (m_current.object()->isRubyRun()) |
629 m_width.applyOverhang(toRenderRubyRun(m_current.object()), m_lastObject,
m_nextObject); | 629 m_width.applyOverhang(toRenderRubyRun(m_current.object()), m_lastObject,
m_nextObject); |
630 // Update prior line break context characters, using U+FFFD (OBJECT REPLACEM
ENT CHARACTER) for replaced element. | 630 // Update prior line break context characters, using U+FFFD (OBJECT REPLACEM
ENT CHARACTER) for replaced element. |
631 m_renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter
); | 631 m_renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter
); |
632 } | 632 } |
633 | 633 |
634 inline bool iteratorIsBeyondEndOfRenderCombineText(const InlineIterator& iter, R
enderCombineText* renderer) | 634 inline bool iteratorIsBeyondEndOfRenderCombineText(const InlineIterator& iter, R
enderCombineText* renderer) |
635 { | 635 { |
636 return iter.object() == renderer && iter.m_pos >= renderer->textLength(); | 636 return iter.object() == renderer && iter.offset() >= renderer->textLength(); |
637 } | 637 } |
638 | 638 |
639 inline void nextCharacter(UChar& currentCharacter, UChar& lastCharacter, UChar&
secondToLastCharacter) | 639 inline void nextCharacter(UChar& currentCharacter, UChar& lastCharacter, UChar&
secondToLastCharacter) |
640 { | 640 { |
641 secondToLastCharacter = lastCharacter; | 641 secondToLastCharacter = lastCharacter; |
642 lastCharacter = currentCharacter; | 642 lastCharacter = currentCharacter; |
643 } | 643 } |
644 | 644 |
645 inline float firstPositiveWidth(const WordMeasurements& wordMeasurements) | 645 inline float firstPositiveWidth(const WordMeasurements& wordMeasurements) |
646 { | 646 { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 ASSERT(run.charactersLength() >= run.length()); | 712 ASSERT(run.charactersLength() >= run.length()); |
713 | 713 |
714 run.setCharacterScanForCodePath(!text->canUseSimpleFontCodePath()); | 714 run.setCharacterScanForCodePath(!text->canUseSimpleFontCodePath()); |
715 run.setTabSize(!collapseWhiteSpace, text->style()->tabSize()); | 715 run.setTabSize(!collapseWhiteSpace, text->style()->tabSize()); |
716 run.setXPos(xPos); | 716 run.setXPos(xPos); |
717 return font.width(run, fallbackFonts, &glyphOverflow); | 717 return font.width(run, fallbackFonts, &glyphOverflow); |
718 } | 718 } |
719 | 719 |
720 inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, bool
& hyphenated) | 720 inline bool BreakingContext::handleText(WordMeasurements& wordMeasurements, bool
& hyphenated) |
721 { | 721 { |
722 if (!m_current.m_pos) | 722 if (!m_current.offset()) |
723 m_appliedStartWidth = false; | 723 m_appliedStartWidth = false; |
724 | 724 |
725 RenderText* renderText = toRenderText(m_current.object()); | 725 RenderText* renderText = toRenderText(m_current.object()); |
726 | 726 |
727 bool isSVGText = renderText->isSVGInlineText(); | 727 bool isSVGText = renderText->isSVGInlineText(); |
728 | 728 |
729 if (renderText->style()->hasTextCombine() && m_current.object()->isCombineTe
xt() && !toRenderCombineText(m_current.object())->isCombined()) { | 729 if (renderText->style()->hasTextCombine() && m_current.object()->isCombineTe
xt() && !toRenderCombineText(m_current.object())->isCombined()) { |
730 RenderCombineText* combineRenderer = toRenderCombineText(m_current.objec
t()); | 730 RenderCombineText* combineRenderer = toRenderCombineText(m_current.objec
t()); |
731 combineRenderer->combineText(); | 731 combineRenderer->combineText(); |
732 // The length of the renderer's text may have changed. Increment stale i
terator positions | 732 // The length of the renderer's text may have changed. Increment stale i
terator positions |
733 if (iteratorIsBeyondEndOfRenderCombineText(m_lineBreak, combineRenderer)
) { | 733 if (iteratorIsBeyondEndOfRenderCombineText(m_lineBreak, combineRenderer)
) { |
734 ASSERT(iteratorIsBeyondEndOfRenderCombineText(m_resolver.position(),
combineRenderer)); | 734 ASSERT(iteratorIsBeyondEndOfRenderCombineText(m_resolver.position(),
combineRenderer)); |
735 m_lineBreak.increment(); | 735 m_lineBreak.increment(); |
736 m_resolver.position().increment(&m_resolver); | 736 m_resolver.position().increment(&m_resolver); |
737 } | 737 } |
738 } | 738 } |
739 | 739 |
740 RenderStyle* style = renderText->style(m_lineInfo.isFirstLine()); | 740 RenderStyle* style = renderText->style(m_lineInfo.isFirstLine()); |
741 const Font& font = style->font(); | 741 const Font& font = style->font(); |
742 bool isFixedPitch = font.isFixedPitch(); | 742 bool isFixedPitch = font.isFixedPitch(); |
743 | 743 |
744 unsigned lastSpace = m_current.m_pos; | 744 unsigned lastSpace = m_current.offset(); |
745 float wordSpacing = m_currentStyle->wordSpacing(); | 745 float wordSpacing = m_currentStyle->wordSpacing(); |
746 float lastSpaceWordSpacing = 0; | 746 float lastSpaceWordSpacing = 0; |
747 float wordSpacingForWordMeasurement = 0; | 747 float wordSpacingForWordMeasurement = 0; |
748 | 748 |
749 float wrapW = m_width.uncommittedWidth() + inlineLogicalWidth(m_current.obje
ct(), !m_appliedStartWidth, true); | 749 float wrapW = m_width.uncommittedWidth() + inlineLogicalWidth(m_current.obje
ct(), !m_appliedStartWidth, true); |
750 float charWidth = 0; | 750 float charWidth = 0; |
751 // Auto-wrapping text should wrap in the middle of a word only if it could n
ot wrap before the word, | 751 // Auto-wrapping text should wrap in the middle of a word only if it could n
ot wrap before the word, |
752 // which is only possible if the word is the first thing on the line, that i
s, if |w| is zero. | 752 // which is only possible if the word is the first thing on the line, that i
s, if |w| is zero. |
753 bool breakWords = m_currentStyle->breakWords() && ((m_autoWrap && !m_width.c
ommittedWidth()) || m_currWS == PRE); | 753 bool breakWords = m_currentStyle->breakWords() && ((m_autoWrap && !m_width.c
ommittedWidth()) || m_currWS == PRE); |
754 bool midWordBreak = false; | 754 bool midWordBreak = false; |
755 bool breakAll = m_currentStyle->wordBreak() == BreakAllWordBreak && m_autoWr
ap; | 755 bool breakAll = m_currentStyle->wordBreak() == BreakAllWordBreak && m_autoWr
ap; |
756 float hyphenWidth = 0; | 756 float hyphenWidth = 0; |
757 | 757 |
758 if (isSVGText) { | 758 if (isSVGText) { |
759 breakWords = false; | 759 breakWords = false; |
760 breakAll = false; | 760 breakAll = false; |
761 } | 761 } |
762 | 762 |
763 if (renderText->isWordBreak()) { | 763 if (renderText->isWordBreak()) { |
764 m_width.commit(); | 764 m_width.commit(); |
765 m_lineBreak.moveToStartOf(m_current.object()); | 765 m_lineBreak.moveToStartOf(m_current.object()); |
766 ASSERT(m_current.m_pos == renderText->textLength()); | 766 ASSERT(m_current.offset() == renderText->textLength()); |
767 } | 767 } |
768 | 768 |
769 if (m_renderTextInfo.m_text != renderText) { | 769 if (m_renderTextInfo.m_text != renderText) { |
770 m_renderTextInfo.m_text = renderText; | 770 m_renderTextInfo.m_text = renderText; |
771 m_renderTextInfo.m_font = &font; | 771 m_renderTextInfo.m_font = &font; |
772 m_renderTextInfo.createLayout(renderText, m_width.currentWidth(), m_coll
apseWhiteSpace); | 772 m_renderTextInfo.createLayout(renderText, m_width.currentWidth(), m_coll
apseWhiteSpace); |
773 m_renderTextInfo.m_lineBreakIterator.resetStringAndReleaseIterator(rende
rText->text(), style->locale()); | 773 m_renderTextInfo.m_lineBreakIterator.resetStringAndReleaseIterator(rende
rText->text(), style->locale()); |
774 } else if (m_renderTextInfo.m_layout && m_renderTextInfo.m_font != &font) { | 774 } else if (m_renderTextInfo.m_layout && m_renderTextInfo.m_font != &font) { |
775 m_renderTextInfo.m_font = &font; | 775 m_renderTextInfo.m_font = &font; |
776 m_renderTextInfo.createLayout(renderText, m_width.currentWidth(), m_coll
apseWhiteSpace); | 776 m_renderTextInfo.createLayout(renderText, m_width.currentWidth(), m_coll
apseWhiteSpace); |
777 } | 777 } |
778 | 778 |
779 TextLayout* textLayout = m_renderTextInfo.m_layout.get(); | 779 TextLayout* textLayout = m_renderTextInfo.m_layout.get(); |
780 | 780 |
781 // Non-zero only when kerning is enabled and TextLayout isn't used, in which
case we measure | 781 // Non-zero only when kerning is enabled and TextLayout isn't used, in which
case we measure |
782 // words with their trailing space, then subtract its width. | 782 // words with their trailing space, then subtract its width. |
783 float wordTrailingSpaceWidth = (font.typesettingFeatures() & Kerning) && !te
xtLayout ? font.width(RenderBlockFlow::constructTextRun(renderText, font, &space
, 1, style)) + wordSpacing : 0; | 783 float wordTrailingSpaceWidth = (font.typesettingFeatures() & Kerning) && !te
xtLayout ? font.width(RenderBlockFlow::constructTextRun(renderText, font, &space
, 1, style)) + wordSpacing : 0; |
784 | 784 |
785 UChar lastCharacter = m_renderTextInfo.m_lineBreakIterator.lastCharacter(); | 785 UChar lastCharacter = m_renderTextInfo.m_lineBreakIterator.lastCharacter(); |
786 UChar secondToLastCharacter = m_renderTextInfo.m_lineBreakIterator.secondToL
astCharacter(); | 786 UChar secondToLastCharacter = m_renderTextInfo.m_lineBreakIterator.secondToL
astCharacter(); |
787 for (; m_current.m_pos < renderText->textLength(); m_current.fastIncrementIn
TextNode()) { | 787 for (; m_current.offset() < renderText->textLength(); m_current.fastIncremen
tInTextNode()) { |
788 bool previousCharacterIsSpace = m_currentCharacterIsSpace; | 788 bool previousCharacterIsSpace = m_currentCharacterIsSpace; |
789 bool previousCharacterShouldCollapseIfPreWap = m_currentCharacterShouldC
ollapseIfPreWap; | 789 bool previousCharacterShouldCollapseIfPreWap = m_currentCharacterShouldC
ollapseIfPreWap; |
790 UChar c = m_current.current(); | 790 UChar c = m_current.current(); |
791 m_currentCharacterShouldCollapseIfPreWap = m_currentCharacterIsSpace = c
== ' ' || c == '\t' || (!m_preservesNewline && (c == '\n')); | 791 m_currentCharacterShouldCollapseIfPreWap = m_currentCharacterIsSpace = c
== ' ' || c == '\t' || (!m_preservesNewline && (c == '\n')); |
792 | 792 |
793 if (!m_collapseWhiteSpace || !m_currentCharacterIsSpace) | 793 if (!m_collapseWhiteSpace || !m_currentCharacterIsSpace) |
794 m_lineInfo.setEmpty(false, m_block, &m_width); | 794 m_lineInfo.setEmpty(false, m_block, &m_width); |
795 | 795 |
796 if (c == softHyphen && m_autoWrap && !hyphenWidth) { | 796 if (c == softHyphen && m_autoWrap && !hyphenWidth) { |
797 hyphenWidth = measureHyphenWidth(renderText, font); | 797 hyphenWidth = measureHyphenWidth(renderText, font); |
798 m_width.addUncommittedWidth(hyphenWidth); | 798 m_width.addUncommittedWidth(hyphenWidth); |
799 } | 799 } |
800 | 800 |
801 bool applyWordSpacing = false; | 801 bool applyWordSpacing = false; |
802 | 802 |
803 if ((breakAll || breakWords) && !midWordBreak) { | 803 if ((breakAll || breakWords) && !midWordBreak) { |
804 wrapW += charWidth; | 804 wrapW += charWidth; |
805 bool midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && m_current
.m_pos + 1 < renderText->textLength() && U16_IS_TRAIL((*renderText)[m_current.m_
pos + 1]); | 805 bool midWordBreakIsBeforeSurrogatePair = U16_IS_LEAD(c) && m_current
.offset() + 1 < renderText->textLength() && U16_IS_TRAIL((*renderText)[m_current
.offset() + 1]); |
806 charWidth = textWidth(renderText, m_current.m_pos, midWordBreakIsBef
oreSurrogatePair ? 2 : 1, font, m_width.committedWidth() + wrapW, isFixedPitch,
m_collapseWhiteSpace, 0, textLayout); | 806 charWidth = textWidth(renderText, m_current.offset(), midWordBreakIs
BeforeSurrogatePair ? 2 : 1, font, m_width.committedWidth() + wrapW, isFixedPitc
h, m_collapseWhiteSpace, 0, textLayout); |
807 midWordBreak = m_width.committedWidth() + wrapW + charWidth > m_widt
h.availableWidth(); | 807 midWordBreak = m_width.committedWidth() + wrapW + charWidth > m_widt
h.availableWidth(); |
808 } | 808 } |
809 | 809 |
810 bool betweenWords = c == '\n' || (m_currWS != PRE && !m_atStart && isBre
akable(m_renderTextInfo.m_lineBreakIterator, m_current.m_pos, m_current.m_nextBr
eakablePosition)); | 810 bool betweenWords = c == '\n' || (m_currWS != PRE && !m_atStart && isBre
akable(m_renderTextInfo.m_lineBreakIterator, m_current.offset(), m_current.m_nex
tBreakablePosition)); |
811 | 811 |
812 if (betweenWords || midWordBreak) { | 812 if (betweenWords || midWordBreak) { |
813 bool stoppedIgnoringSpaces = false; | 813 bool stoppedIgnoringSpaces = false; |
814 if (m_ignoringSpaces) { | 814 if (m_ignoringSpaces) { |
815 lastSpaceWordSpacing = 0; | 815 lastSpaceWordSpacing = 0; |
816 if (!m_currentCharacterIsSpace) { | 816 if (!m_currentCharacterIsSpace) { |
817 // Stop ignoring spaces and begin at this | 817 // Stop ignoring spaces and begin at this |
818 // new point. | 818 // new point. |
819 m_ignoringSpaces = false; | 819 m_ignoringSpaces = false; |
820 wordSpacingForWordMeasurement = 0; | 820 wordSpacingForWordMeasurement = 0; |
821 lastSpace = m_current.m_pos; // e.g., "Foo goo", don't ad
d in any of the ignored spaces. | 821 lastSpace = m_current.offset(); // e.g., "Foo goo", don't
add in any of the ignored spaces. |
822 stopIgnoringSpaces(m_lineMidpointState, InlineIterator(0, m_
current.object(), m_current.m_pos)); | 822 stopIgnoringSpaces(m_lineMidpointState, InlineIterator(0, m_
current.object(), m_current.offset())); |
823 stoppedIgnoringSpaces = true; | 823 stoppedIgnoringSpaces = true; |
824 } else { | 824 } else { |
825 // Just keep ignoring these spaces. | 825 // Just keep ignoring these spaces. |
826 nextCharacter(c, lastCharacter, secondToLastCharacter); | 826 nextCharacter(c, lastCharacter, secondToLastCharacter); |
827 continue; | 827 continue; |
828 } | 828 } |
829 } | 829 } |
830 | 830 |
831 wordMeasurements.grow(wordMeasurements.size() + 1); | 831 wordMeasurements.grow(wordMeasurements.size() + 1); |
832 WordMeasurement& wordMeasurement = wordMeasurements.last(); | 832 WordMeasurement& wordMeasurement = wordMeasurements.last(); |
833 | 833 |
834 wordMeasurement.renderer = renderText; | 834 wordMeasurement.renderer = renderText; |
835 wordMeasurement.endOffset = m_current.m_pos; | 835 wordMeasurement.endOffset = m_current.offset(); |
836 wordMeasurement.startOffset = lastSpace; | 836 wordMeasurement.startOffset = lastSpace; |
837 | 837 |
838 float additionalTmpW; | 838 float additionalTmpW; |
839 if (wordTrailingSpaceWidth && c == ' ') | 839 if (wordTrailingSpaceWidth && c == ' ') |
840 additionalTmpW = textWidth(renderText, lastSpace, m_current.m_po
s + 1 - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSp
ace, &wordMeasurement.fallbackFonts, textLayout) - wordTrailingSpaceWidth; | 840 additionalTmpW = textWidth(renderText, lastSpace, m_current.offs
et() + 1 - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhit
eSpace, &wordMeasurement.fallbackFonts, textLayout) - wordTrailingSpaceWidth; |
841 else | 841 else |
842 additionalTmpW = textWidth(renderText, lastSpace, m_current.m_po
s - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpace,
&wordMeasurement.fallbackFonts, textLayout); | 842 additionalTmpW = textWidth(renderText, lastSpace, m_current.offs
et() - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpa
ce, &wordMeasurement.fallbackFonts, textLayout); |
843 | 843 |
844 wordMeasurement.width = additionalTmpW + wordSpacingForWordMeasureme
nt; | 844 wordMeasurement.width = additionalTmpW + wordSpacingForWordMeasureme
nt; |
845 additionalTmpW += lastSpaceWordSpacing; | 845 additionalTmpW += lastSpaceWordSpacing; |
846 m_width.addUncommittedWidth(additionalTmpW); | 846 m_width.addUncommittedWidth(additionalTmpW); |
847 if (!m_appliedStartWidth) { | 847 if (!m_appliedStartWidth) { |
848 m_width.addUncommittedWidth(inlineLogicalWidth(m_current.object(
), true, false)); | 848 m_width.addUncommittedWidth(inlineLogicalWidth(m_current.object(
), true, false)); |
849 m_appliedStartWidth = true; | 849 m_appliedStartWidth = true; |
850 } | 850 } |
851 | 851 |
852 if (m_lastFloatFromPreviousLine) | 852 if (m_lastFloatFromPreviousLine) |
853 updateSegmentsForShapes(m_block, m_lastFloatFromPreviousLine, wo
rdMeasurements, m_width, m_lineInfo.isFirstLine()); | 853 updateSegmentsForShapes(m_block, m_lastFloatFromPreviousLine, wo
rdMeasurements, m_width, m_lineInfo.isFirstLine()); |
854 | 854 |
855 applyWordSpacing = wordSpacing && m_currentCharacterIsSpace; | 855 applyWordSpacing = wordSpacing && m_currentCharacterIsSpace; |
856 | 856 |
857 if (!m_width.committedWidth() && m_autoWrap && !m_width.fitsOnLine()
) | 857 if (!m_width.committedWidth() && m_autoWrap && !m_width.fitsOnLine()
) |
858 m_width.fitBelowFloats(); | 858 m_width.fitBelowFloats(); |
859 | 859 |
860 if (m_autoWrap || breakWords) { | 860 if (m_autoWrap || breakWords) { |
861 // If we break only after white-space, consider the current char
acter | 861 // If we break only after white-space, consider the current char
acter |
862 // as candidate width for this line. | 862 // as candidate width for this line. |
863 bool lineWasTooWide = false; | 863 bool lineWasTooWide = false; |
864 if (m_width.fitsOnLine() && m_currentCharacterIsSpace && m_curre
ntStyle->breakOnlyAfterWhiteSpace() && !midWordBreak) { | 864 if (m_width.fitsOnLine() && m_currentCharacterIsSpace && m_curre
ntStyle->breakOnlyAfterWhiteSpace() && !midWordBreak) { |
865 float charWidth = textWidth(renderText, m_current.m_pos, 1,
font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpace, &wordMeasureme
nt.fallbackFonts, textLayout) + (applyWordSpacing ? wordSpacing : 0); | 865 float charWidth = textWidth(renderText, m_current.offset(),
1, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpace, &wordMeasur
ement.fallbackFonts, textLayout) + (applyWordSpacing ? wordSpacing : 0); |
866 // Check if line is too big even without the extra space | 866 // Check if line is too big even without the extra space |
867 // at the end of the line. If it is not, do nothing. | 867 // at the end of the line. If it is not, do nothing. |
868 // If the line needs the extra whitespace to be too long, | 868 // If the line needs the extra whitespace to be too long, |
869 // then move the line break to the space and skip all | 869 // then move the line break to the space and skip all |
870 // additional whitespace. | 870 // additional whitespace. |
871 if (!m_width.fitsOnLine(charWidth)) { | 871 if (!m_width.fitsOnLine(charWidth)) { |
872 lineWasTooWide = true; | 872 lineWasTooWide = true; |
873 m_lineBreak.moveTo(m_current.object(), m_current.m_pos,
m_current.m_nextBreakablePosition); | 873 m_lineBreak.moveTo(m_current.object(), m_current.offset(
), m_current.m_nextBreakablePosition); |
874 skipTrailingWhitespace(m_lineBreak, m_lineInfo); | 874 skipTrailingWhitespace(m_lineBreak, m_lineInfo); |
875 } | 875 } |
876 } | 876 } |
877 if (lineWasTooWide || !m_width.fitsOnLine()) { | 877 if (lineWasTooWide || !m_width.fitsOnLine()) { |
878 if (m_lineBreak.atTextParagraphSeparator()) { | 878 if (m_lineBreak.atTextParagraphSeparator()) { |
879 if (!stoppedIgnoringSpaces && m_current.m_pos > 0) | 879 if (!stoppedIgnoringSpaces && m_current.offset() > 0) |
880 ensureCharacterGetsLineBox(m_lineMidpointState, m_cu
rrent); | 880 ensureCharacterGetsLineBox(m_lineMidpointState, m_cu
rrent); |
881 m_lineBreak.increment(); | 881 m_lineBreak.increment(); |
882 m_lineInfo.setPreviousLineBrokeCleanly(true); | 882 m_lineInfo.setPreviousLineBrokeCleanly(true); |
883 wordMeasurement.endOffset = m_lineBreak.m_pos; | 883 wordMeasurement.endOffset = m_lineBreak.offset(); |
884 } | 884 } |
885 if (m_lineBreak.object() && m_lineBreak.m_pos && m_lineBreak
.object()->isText() && toRenderText(m_lineBreak.object())->textLength() && toRen
derText(m_lineBreak.object())->characterAt(m_lineBreak.m_pos - 1) == softHyphen) | 885 if (m_lineBreak.object() && m_lineBreak.offset() && m_lineBr
eak.object()->isText() && toRenderText(m_lineBreak.object())->textLength() && to
RenderText(m_lineBreak.object())->characterAt(m_lineBreak.offset() - 1) == softH
yphen) |
886 hyphenated = true; | 886 hyphenated = true; |
887 if (m_lineBreak.m_pos && m_lineBreak.m_pos != (unsigned)word
Measurement.endOffset && !wordMeasurement.width) { | 887 if (m_lineBreak.offset() && m_lineBreak.offset() != (unsigne
d)wordMeasurement.endOffset && !wordMeasurement.width) { |
888 if (charWidth) { | 888 if (charWidth) { |
889 wordMeasurement.endOffset = m_lineBreak.m_pos; | 889 wordMeasurement.endOffset = m_lineBreak.offset(); |
890 wordMeasurement.width = charWidth; | 890 wordMeasurement.width = charWidth; |
891 } | 891 } |
892 } | 892 } |
893 // Didn't fit. Jump to the end unless there's still an oppor
tunity to collapse whitespace. | 893 // Didn't fit. Jump to the end unless there's still an oppor
tunity to collapse whitespace. |
894 if (m_ignoringSpaces || !m_collapseWhiteSpace || !m_currentC
haracterIsSpace || !previousCharacterIsSpace) { | 894 if (m_ignoringSpaces || !m_collapseWhiteSpace || !m_currentC
haracterIsSpace || !previousCharacterIsSpace) { |
895 m_atEnd = true; | 895 m_atEnd = true; |
896 return false; | 896 return false; |
897 } | 897 } |
898 } else { | 898 } else { |
899 if (!betweenWords || (midWordBreak && !m_autoWrap)) | 899 if (!betweenWords || (midWordBreak && !m_autoWrap)) |
900 m_width.addUncommittedWidth(-additionalTmpW); | 900 m_width.addUncommittedWidth(-additionalTmpW); |
901 if (hyphenWidth) { | 901 if (hyphenWidth) { |
902 // Subtract the width of the soft hyphen out since we fi
t on a line. | 902 // Subtract the width of the soft hyphen out since we fi
t on a line. |
903 m_width.addUncommittedWidth(-hyphenWidth); | 903 m_width.addUncommittedWidth(-hyphenWidth); |
904 hyphenWidth = 0; | 904 hyphenWidth = 0; |
905 } | 905 } |
906 } | 906 } |
907 } | 907 } |
908 | 908 |
909 if (c == '\n' && m_preservesNewline) { | 909 if (c == '\n' && m_preservesNewline) { |
910 if (!stoppedIgnoringSpaces && m_current.m_pos > 0) | 910 if (!stoppedIgnoringSpaces && m_current.offset()) |
911 ensureCharacterGetsLineBox(m_lineMidpointState, m_current); | 911 ensureCharacterGetsLineBox(m_lineMidpointState, m_current); |
912 m_lineBreak.moveTo(m_current.object(), m_current.m_pos, m_curren
t.m_nextBreakablePosition); | 912 m_lineBreak.moveTo(m_current.object(), m_current.offset(), m_cur
rent.m_nextBreakablePosition); |
913 m_lineBreak.increment(); | 913 m_lineBreak.increment(); |
914 m_lineInfo.setPreviousLineBrokeCleanly(true); | 914 m_lineInfo.setPreviousLineBrokeCleanly(true); |
915 return true; | 915 return true; |
916 } | 916 } |
917 | 917 |
918 if (m_autoWrap && betweenWords) { | 918 if (m_autoWrap && betweenWords) { |
919 m_width.commit(); | 919 m_width.commit(); |
920 wrapW = 0; | 920 wrapW = 0; |
921 m_lineBreak.moveTo(m_current.object(), m_current.m_pos, m_curren
t.m_nextBreakablePosition); | 921 m_lineBreak.moveTo(m_current.object(), m_current.offset(), m_cur
rent.m_nextBreakablePosition); |
922 // Auto-wrapping text should not wrap in the middle of a word on
ce it has had an | 922 // Auto-wrapping text should not wrap in the middle of a word on
ce it has had an |
923 // opportunity to break after a word. | 923 // opportunity to break after a word. |
924 breakWords = false; | 924 breakWords = false; |
925 } | 925 } |
926 | 926 |
927 if (midWordBreak && !U16_IS_TRAIL(c) && !(category(c) & (Mark_NonSpa
cing | Mark_Enclosing | Mark_SpacingCombining))) { | 927 if (midWordBreak && !U16_IS_TRAIL(c) && !(category(c) & (Mark_NonSpa
cing | Mark_Enclosing | Mark_SpacingCombining))) { |
928 // Remember this as a breakable position in case | 928 // Remember this as a breakable position in case |
929 // adding the end width forces a break. | 929 // adding the end width forces a break. |
930 m_lineBreak.moveTo(m_current.object(), m_current.m_pos, m_curren
t.m_nextBreakablePosition); | 930 m_lineBreak.moveTo(m_current.object(), m_current.offset(), m_cur
rent.m_nextBreakablePosition); |
931 midWordBreak &= (breakWords || breakAll); | 931 midWordBreak &= (breakWords || breakAll); |
932 } | 932 } |
933 | 933 |
934 if (betweenWords) { | 934 if (betweenWords) { |
935 lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0; | 935 lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0; |
936 wordSpacingForWordMeasurement = (applyWordSpacing && wordMeasure
ment.width) ? wordSpacing : 0; | 936 wordSpacingForWordMeasurement = (applyWordSpacing && wordMeasure
ment.width) ? wordSpacing : 0; |
937 lastSpace = m_current.m_pos; | 937 lastSpace = m_current.offset(); |
938 } | 938 } |
939 | 939 |
940 if (!m_ignoringSpaces && m_currentStyle->collapseWhiteSpace()) { | 940 if (!m_ignoringSpaces && m_currentStyle->collapseWhiteSpace()) { |
941 // If we encounter a newline, or if we encounter a | 941 // If we encounter a newline, or if we encounter a |
942 // second space, we need to go ahead and break up this | 942 // second space, we need to go ahead and break up this |
943 // run and enter a mode where we start collapsing spaces. | 943 // run and enter a mode where we start collapsing spaces. |
944 if (m_currentCharacterIsSpace && previousCharacterIsSpace) { | 944 if (m_currentCharacterIsSpace && previousCharacterIsSpace) { |
945 m_ignoringSpaces = true; | 945 m_ignoringSpaces = true; |
946 | 946 |
947 // We just entered a mode where we are ignoring | 947 // We just entered a mode where we are ignoring |
948 // spaces. Create a midpoint to terminate the run | 948 // spaces. Create a midpoint to terminate the run |
949 // before the second space. | 949 // before the second space. |
950 startIgnoringSpaces(m_lineMidpointState, m_startOfIgnoredSpa
ces); | 950 startIgnoringSpaces(m_lineMidpointState, m_startOfIgnoredSpa
ces); |
951 m_trailingObjects.updateMidpointsForTrailingBoxes(m_lineMidp
ointState, InlineIterator(), TrailingObjects::DoNotCollapseFirstSpace); | 951 m_trailingObjects.updateMidpointsForTrailingBoxes(m_lineMidp
ointState, InlineIterator(), TrailingObjects::DoNotCollapseFirstSpace); |
952 } | 952 } |
953 } | 953 } |
954 } else if (m_ignoringSpaces) { | 954 } else if (m_ignoringSpaces) { |
955 // Stop ignoring spaces and begin at this | 955 // Stop ignoring spaces and begin at this |
956 // new point. | 956 // new point. |
957 m_ignoringSpaces = false; | 957 m_ignoringSpaces = false; |
958 lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0; | 958 lastSpaceWordSpacing = applyWordSpacing ? wordSpacing : 0; |
959 wordSpacingForWordMeasurement = (applyWordSpacing && wordMeasurement
s.last().width) ? wordSpacing : 0; | 959 wordSpacingForWordMeasurement = (applyWordSpacing && wordMeasurement
s.last().width) ? wordSpacing : 0; |
960 lastSpace = m_current.m_pos; // e.g., "Foo goo", don't add in any
of the ignored spaces. | 960 lastSpace = m_current.offset(); // e.g., "Foo goo", don't add in
any of the ignored spaces. |
961 stopIgnoringSpaces(m_lineMidpointState, InlineIterator(0, m_current.
object(), m_current.m_pos)); | 961 stopIgnoringSpaces(m_lineMidpointState, InlineIterator(0, m_current.
object(), m_current.offset())); |
962 } | 962 } |
963 | 963 |
964 if (isSVGText && m_current.m_pos > 0) { | 964 if (isSVGText && m_current.offset()) { |
965 // Force creation of new InlineBoxes for each absolute positioned ch
aracter (those that start new text chunks). | 965 // Force creation of new InlineBoxes for each absolute positioned ch
aracter (those that start new text chunks). |
966 if (toRenderSVGInlineText(renderText)->characterStartsNewTextChunk(m
_current.m_pos)) | 966 if (toRenderSVGInlineText(renderText)->characterStartsNewTextChunk(m
_current.offset())) |
967 ensureCharacterGetsLineBox(m_lineMidpointState, m_current); | 967 ensureCharacterGetsLineBox(m_lineMidpointState, m_current); |
968 } | 968 } |
969 | 969 |
970 if (m_currentCharacterIsSpace && !previousCharacterIsSpace) { | 970 if (m_currentCharacterIsSpace && !previousCharacterIsSpace) { |
971 m_startOfIgnoredSpaces.setObject(m_current.object()); | 971 m_startOfIgnoredSpaces.setObject(m_current.object()); |
972 m_startOfIgnoredSpaces.m_pos = m_current.m_pos; | 972 m_startOfIgnoredSpaces.setOffset(m_current.offset()); |
973 } | 973 } |
974 | 974 |
975 if (!m_currentCharacterIsSpace && previousCharacterShouldCollapseIfPreWa
p) { | 975 if (!m_currentCharacterIsSpace && previousCharacterShouldCollapseIfPreWa
p) { |
976 if (m_autoWrap && m_currentStyle->breakOnlyAfterWhiteSpace()) | 976 if (m_autoWrap && m_currentStyle->breakOnlyAfterWhiteSpace()) |
977 m_lineBreak.moveTo(m_current.object(), m_current.m_pos, m_curren
t.m_nextBreakablePosition); | 977 m_lineBreak.moveTo(m_current.object(), m_current.offset(), m_cur
rent.m_nextBreakablePosition); |
978 } | 978 } |
979 | 979 |
980 if (m_collapseWhiteSpace && m_currentCharacterIsSpace && !m_ignoringSpac
es) | 980 if (m_collapseWhiteSpace && m_currentCharacterIsSpace && !m_ignoringSpac
es) |
981 m_trailingObjects.setTrailingWhitespace(toRenderText(m_current.objec
t())); | 981 m_trailingObjects.setTrailingWhitespace(toRenderText(m_current.objec
t())); |
982 else if (!m_currentStyle->collapseWhiteSpace() || !m_currentCharacterIsS
pace) | 982 else if (!m_currentStyle->collapseWhiteSpace() || !m_currentCharacterIsS
pace) |
983 m_trailingObjects.clear(); | 983 m_trailingObjects.clear(); |
984 | 984 |
985 m_atStart = false; | 985 m_atStart = false; |
986 nextCharacter(c, lastCharacter, secondToLastCharacter); | 986 nextCharacter(c, lastCharacter, secondToLastCharacter); |
987 } | 987 } |
988 | 988 |
989 m_renderTextInfo.m_lineBreakIterator.setPriorContext(lastCharacter, secondTo
LastCharacter); | 989 m_renderTextInfo.m_lineBreakIterator.setPriorContext(lastCharacter, secondTo
LastCharacter); |
990 | 990 |
991 wordMeasurements.grow(wordMeasurements.size() + 1); | 991 wordMeasurements.grow(wordMeasurements.size() + 1); |
992 WordMeasurement& wordMeasurement = wordMeasurements.last(); | 992 WordMeasurement& wordMeasurement = wordMeasurements.last(); |
993 wordMeasurement.renderer = renderText; | 993 wordMeasurement.renderer = renderText; |
994 | 994 |
995 // IMPORTANT: current.m_pos is > length here! | 995 // IMPORTANT: current.m_pos is > length here! |
996 float additionalTmpW = m_ignoringSpaces ? 0 : textWidth(renderText, lastSpac
e, m_current.m_pos - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_co
llapseWhiteSpace, &wordMeasurement.fallbackFonts, textLayout); | 996 float additionalTmpW = m_ignoringSpaces ? 0 : textWidth(renderText, lastSpac
e, m_current.offset() - lastSpace, font, m_width.currentWidth(), isFixedPitch, m
_collapseWhiteSpace, &wordMeasurement.fallbackFonts, textLayout); |
997 wordMeasurement.startOffset = lastSpace; | 997 wordMeasurement.startOffset = lastSpace; |
998 wordMeasurement.endOffset = m_current.m_pos; | 998 wordMeasurement.endOffset = m_current.offset(); |
999 wordMeasurement.width = m_ignoringSpaces ? 0 : additionalTmpW + wordSpacingF
orWordMeasurement; | 999 wordMeasurement.width = m_ignoringSpaces ? 0 : additionalTmpW + wordSpacingF
orWordMeasurement; |
1000 additionalTmpW += lastSpaceWordSpacing; | 1000 additionalTmpW += lastSpaceWordSpacing; |
1001 m_width.addUncommittedWidth(additionalTmpW + inlineLogicalWidth(m_current.ob
ject(), !m_appliedStartWidth, m_includeEndWidth)); | 1001 m_width.addUncommittedWidth(additionalTmpW + inlineLogicalWidth(m_current.ob
ject(), !m_appliedStartWidth, m_includeEndWidth)); |
1002 m_includeEndWidth = false; | 1002 m_includeEndWidth = false; |
1003 | 1003 |
1004 if (!m_width.fitsOnLine()) { | 1004 if (!m_width.fitsOnLine()) { |
1005 if (!hyphenated && m_lineBreak.previousInSameNode() == softHyphen) { | 1005 if (!hyphenated && m_lineBreak.previousInSameNode() == softHyphen) { |
1006 hyphenated = true; | 1006 hyphenated = true; |
1007 m_atEnd = true; | 1007 m_atEnd = true; |
1008 } | 1008 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 InlineIterator* midpoints = lineMidpointState.midpoints.data(); | 1084 InlineIterator* midpoints = lineMidpointState.midpoints.data(); |
1085 InlineIterator& endpoint = midpoints[lineMidpointState.numMidpoints - 2]
; | 1085 InlineIterator& endpoint = midpoints[lineMidpointState.numMidpoints - 2]
; |
1086 const InlineIterator& startpoint = midpoints[lineMidpointState.numMidpoi
nts - 1]; | 1086 const InlineIterator& startpoint = midpoints[lineMidpointState.numMidpoi
nts - 1]; |
1087 InlineIterator currpoint = endpoint; | 1087 InlineIterator currpoint = endpoint; |
1088 while (!currpoint.atEnd() && currpoint != startpoint && currpoint != lBr
eak) | 1088 while (!currpoint.atEnd() && currpoint != startpoint && currpoint != lBr
eak) |
1089 currpoint.increment(); | 1089 currpoint.increment(); |
1090 if (currpoint == lBreak) { | 1090 if (currpoint == lBreak) { |
1091 // We hit the line break before the start point. Shave off the start
point. | 1091 // We hit the line break before the start point. Shave off the start
point. |
1092 lineMidpointState.numMidpoints--; | 1092 lineMidpointState.numMidpoints--; |
1093 if (endpoint.object()->style()->collapseWhiteSpace() && endpoint.obj
ect()->isText()) | 1093 if (endpoint.object()->style()->collapseWhiteSpace() && endpoint.obj
ect()->isText()) |
1094 endpoint.m_pos--; | 1094 endpoint.setOffset(endpoint.offset() - 1); |
1095 } | 1095 } |
1096 } | 1096 } |
1097 } | 1097 } |
1098 | 1098 |
1099 InlineIterator BreakingContext::handleEndOfLine() | 1099 InlineIterator BreakingContext::handleEndOfLine() |
1100 { | 1100 { |
1101 ShapeInsideInfo* shapeInfo = m_block->layoutShapeInsideInfo(); | 1101 ShapeInsideInfo* shapeInfo = m_block->layoutShapeInsideInfo(); |
1102 bool segmentAllowsOverflow = !shapeInfo || !shapeInfo->hasSegments(); | 1102 bool segmentAllowsOverflow = !shapeInfo || !shapeInfo->hasSegments(); |
1103 | 1103 |
1104 if (m_lineBreak == m_resolver.position() && (!m_lineBreak.object() || !m_lin
eBreak.object()->isBR()) && segmentAllowsOverflow) { | 1104 if (m_lineBreak == m_resolver.position() && (!m_lineBreak.object() || !m_lin
eBreak.object()->isBR()) && segmentAllowsOverflow) { |
1105 // we just add as much as possible | 1105 // we just add as much as possible |
1106 if (m_blockStyle->whiteSpace() == PRE && !m_current.m_pos) { | 1106 if (m_blockStyle->whiteSpace() == PRE && !m_current.offset()) { |
1107 m_lineBreak.moveTo(m_lastObject, m_lastObject->isText() ? m_lastObje
ct->length() : 0); | 1107 m_lineBreak.moveTo(m_lastObject, m_lastObject->isText() ? m_lastObje
ct->length() : 0); |
1108 } else if (m_lineBreak.object()) { | 1108 } else if (m_lineBreak.object()) { |
1109 // Don't ever break in the middle of a word if we can help it. | 1109 // Don't ever break in the middle of a word if we can help it. |
1110 // There's no room at all. We just have to be on this line, | 1110 // There's no room at all. We just have to be on this line, |
1111 // even though we'll spill out. | 1111 // even though we'll spill out. |
1112 m_lineBreak.moveTo(m_current.object(), m_current.m_pos); | 1112 m_lineBreak.moveTo(m_current.object(), m_current.offset()); |
1113 } | 1113 } |
1114 } | 1114 } |
1115 | 1115 |
1116 // FIXME Bug 100049: We do not need to consume input in a multi-segment line | 1116 // FIXME Bug 100049: We do not need to consume input in a multi-segment line |
1117 // unless no segment will. | 1117 // unless no segment will. |
1118 // make sure we consume at least one char/object. | 1118 // make sure we consume at least one char/object. |
1119 if (m_lineBreak == m_resolver.position() && segmentAllowsOverflow) | 1119 if (m_lineBreak == m_resolver.position() && segmentAllowsOverflow) |
1120 m_lineBreak.increment(); | 1120 m_lineBreak.increment(); |
1121 | 1121 |
1122 // Sanity check our midpoints. | 1122 // Sanity check our midpoints. |
1123 checkMidpoints(m_lineMidpointState, m_lineBreak); | 1123 checkMidpoints(m_lineMidpointState, m_lineBreak); |
1124 | 1124 |
1125 m_trailingObjects.updateMidpointsForTrailingBoxes(m_lineMidpointState, m_lin
eBreak, TrailingObjects::CollapseFirstSpace); | 1125 m_trailingObjects.updateMidpointsForTrailingBoxes(m_lineMidpointState, m_lin
eBreak, TrailingObjects::CollapseFirstSpace); |
1126 | 1126 |
1127 // We might have made lineBreak an iterator that points past the end | 1127 // We might have made lineBreak an iterator that points past the end |
1128 // of the object. Do this adjustment to make it point to the start | 1128 // of the object. Do this adjustment to make it point to the start |
1129 // of the next object instead to avoid confusing the rest of the | 1129 // of the next object instead to avoid confusing the rest of the |
1130 // code. | 1130 // code. |
1131 if (m_lineBreak.m_pos > 0) { | 1131 if (m_lineBreak.offset()) { |
1132 // This loop enforces the invariant that line breaks should never point | 1132 // This loop enforces the invariant that line breaks should never point |
1133 // at an empty inline. See http://crbug.com/305904. | 1133 // at an empty inline. See http://crbug.com/305904. |
1134 do { | 1134 do { |
1135 m_lineBreak.m_pos--; | 1135 m_lineBreak.setOffset(m_lineBreak.offset() - 1); |
1136 m_lineBreak.increment(); | 1136 m_lineBreak.increment(); |
1137 } while (!m_lineBreak.atEnd() && isEmptyInline(m_lineBreak.object())); | 1137 } while (!m_lineBreak.atEnd() && isEmptyInline(m_lineBreak.object())); |
1138 } | 1138 } |
1139 | 1139 |
1140 return m_lineBreak; | 1140 return m_lineBreak; |
1141 } | 1141 } |
1142 | 1142 |
1143 } | 1143 } |
1144 | 1144 |
1145 #endif // BreakingContextInlineHeaders_h | 1145 #endif // BreakingContextInlineHeaders_h |
OLD | NEW |