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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 } | 357 } |
358 | 358 |
359 inline void BreakingContext::handleFloat() | 359 inline void BreakingContext::handleFloat() |
360 { | 360 { |
361 RenderBox* floatBox = toRenderBox(m_current.object()); | 361 RenderBox* floatBox = toRenderBox(m_current.object()); |
362 FloatingObject* floatingObject = m_block->insertFloatingObject(floatBox); | 362 FloatingObject* floatingObject = m_block->insertFloatingObject(floatBox); |
363 // check if it fits in the current line. | 363 // check if it fits in the current line. |
364 // If it does, position it now, otherwise, position | 364 // If it does, position it now, otherwise, position |
365 // it after moving to next line (in newLine() func) | 365 // it after moving to next line (in newLine() func) |
366 // FIXME: Bug 110372: Properly position multiple stacked floats with non-rec
tangular shape outside. | 366 // FIXME: Bug 110372: Properly position multiple stacked floats with non-rec
tangular shape outside. |
367 if (m_floatsFitOnLine && m_width.fitsOnLine(m_block->logicalWidthForFloat(fl
oatingObject).toFloat())) { | 367 if (m_floatsFitOnLine && m_width.fitsOnLine(m_block->logicalWidthForFloat(fl
oatingObject).toFloat(), true)) { |
368 m_block->positionNewFloatOnLine(floatingObject, m_lastFloatFromPreviousL
ine, m_lineInfo, m_width); | 368 m_block->positionNewFloatOnLine(floatingObject, m_lastFloatFromPreviousL
ine, m_lineInfo, m_width); |
369 if (m_lineBreak.object() == m_current.object()) { | 369 if (m_lineBreak.object() == m_current.object()) { |
370 ASSERT(!m_lineBreak.offset()); | 370 ASSERT(!m_lineBreak.offset()); |
371 m_lineBreak.increment(); | 371 m_lineBreak.increment(); |
372 } | 372 } |
373 } else { | 373 } else { |
374 m_floatsFitOnLine = false; | 374 m_floatsFitOnLine = false; |
375 } | 375 } |
376 // Update prior line break context characters, using U+FFFD (OBJECT REPLACEM
ENT CHARACTER) for floating element. | 376 // Update prior line break context characters, using U+FFFD (OBJECT REPLACEM
ENT CHARACTER) for floating element. |
377 m_renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter
); | 377 m_renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter
); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 } | 639 } |
640 } | 640 } |
641 | 641 |
642 wordMeasurements.grow(wordMeasurements.size() + 1); | 642 wordMeasurements.grow(wordMeasurements.size() + 1); |
643 WordMeasurement& wordMeasurement = wordMeasurements.last(); | 643 WordMeasurement& wordMeasurement = wordMeasurements.last(); |
644 | 644 |
645 wordMeasurement.renderer = renderText; | 645 wordMeasurement.renderer = renderText; |
646 wordMeasurement.endOffset = m_current.offset(); | 646 wordMeasurement.endOffset = m_current.offset(); |
647 wordMeasurement.startOffset = lastSpace; | 647 wordMeasurement.startOffset = lastSpace; |
648 | 648 |
649 float additionalTmpW; | 649 float additionalTempWidth; |
650 if (wordTrailingSpaceWidth && c == ' ') | 650 if (wordTrailingSpaceWidth && c == ' ') |
651 additionalTmpW = textWidth(renderText, lastSpace, m_current.offs
et() + 1 - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhit
eSpace, &wordMeasurement.fallbackFonts) - wordTrailingSpaceWidth; | 651 additionalTempWidth = textWidth(renderText, lastSpace, m_current
.offset() + 1 - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collaps
eWhiteSpace, &wordMeasurement.fallbackFonts) - wordTrailingSpaceWidth; |
652 else | 652 else |
653 additionalTmpW = textWidth(renderText, lastSpace, m_current.offs
et() - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpa
ce, &wordMeasurement.fallbackFonts); | 653 additionalTempWidth = textWidth(renderText, lastSpace, m_current
.offset() - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhi
teSpace, &wordMeasurement.fallbackFonts); |
654 | 654 |
655 wordMeasurement.width = additionalTmpW + wordSpacingForWordMeasureme
nt; | 655 wordMeasurement.width = additionalTempWidth + wordSpacingForWordMeas
urement; |
656 additionalTmpW += lastSpaceWordSpacing; | 656 additionalTempWidth += lastSpaceWordSpacing; |
657 m_width.addUncommittedWidth(additionalTmpW); | 657 m_width.addUncommittedWidth(additionalTempWidth); |
| 658 |
| 659 if (m_collapseWhiteSpace && previousCharacterIsSpace && m_currentCha
racterIsSpace && additionalTempWidth) |
| 660 m_width.setTrailingWhitespaceWidth(additionalTempWidth); |
| 661 |
658 if (!m_appliedStartWidth) { | 662 if (!m_appliedStartWidth) { |
659 m_width.addUncommittedWidth(inlineLogicalWidth(m_current.object(
), true, false).toFloat()); | 663 m_width.addUncommittedWidth(inlineLogicalWidth(m_current.object(
), true, false).toFloat()); |
660 m_appliedStartWidth = true; | 664 m_appliedStartWidth = true; |
661 } | 665 } |
662 | 666 |
663 applyWordSpacing = wordSpacing && m_currentCharacterIsSpace; | 667 applyWordSpacing = wordSpacing && m_currentCharacterIsSpace; |
664 | 668 |
665 if (!m_width.committedWidth() && m_autoWrap && !m_width.fitsOnLine()
) | 669 if (!m_width.committedWidth() && m_autoWrap && !m_width.fitsOnLine()
) |
666 m_width.fitBelowFloats(m_lineInfo.isFirstLine()); | 670 m_width.fitBelowFloats(m_lineInfo.isFirstLine()); |
667 | 671 |
(...skipping 30 matching lines...) Expand all Loading... |
698 wordMeasurement.width = charWidth; | 702 wordMeasurement.width = charWidth; |
699 } | 703 } |
700 } | 704 } |
701 // Didn't fit. Jump to the end unless there's still an oppor
tunity to collapse whitespace. | 705 // Didn't fit. Jump to the end unless there's still an oppor
tunity to collapse whitespace. |
702 if (m_ignoringSpaces || !m_collapseWhiteSpace || !m_currentC
haracterIsSpace || !previousCharacterIsSpace) { | 706 if (m_ignoringSpaces || !m_collapseWhiteSpace || !m_currentC
haracterIsSpace || !previousCharacterIsSpace) { |
703 m_atEnd = true; | 707 m_atEnd = true; |
704 return false; | 708 return false; |
705 } | 709 } |
706 } else { | 710 } else { |
707 if (!betweenWords || (midWordBreak && !m_autoWrap)) | 711 if (!betweenWords || (midWordBreak && !m_autoWrap)) |
708 m_width.addUncommittedWidth(-additionalTmpW); | 712 m_width.addUncommittedWidth(-additionalTempWidth); |
709 if (hyphenWidth) { | 713 if (hyphenWidth) { |
710 // Subtract the width of the soft hyphen out since we fi
t on a line. | 714 // Subtract the width of the soft hyphen out since we fi
t on a line. |
711 m_width.addUncommittedWidth(-hyphenWidth); | 715 m_width.addUncommittedWidth(-hyphenWidth); |
712 hyphenWidth = 0; | 716 hyphenWidth = 0; |
713 } | 717 } |
714 } | 718 } |
715 } | 719 } |
716 | 720 |
717 if (c == '\n' && m_preservesNewline) { | 721 if (c == '\n' && m_preservesNewline) { |
718 if (!stoppedIgnoringSpaces && m_current.offset()) | 722 if (!stoppedIgnoringSpaces && m_current.offset()) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 nextCharacter(c, lastCharacter, secondToLastCharacter); | 798 nextCharacter(c, lastCharacter, secondToLastCharacter); |
795 } | 799 } |
796 | 800 |
797 m_renderTextInfo.m_lineBreakIterator.setPriorContext(lastCharacter, secondTo
LastCharacter); | 801 m_renderTextInfo.m_lineBreakIterator.setPriorContext(lastCharacter, secondTo
LastCharacter); |
798 | 802 |
799 wordMeasurements.grow(wordMeasurements.size() + 1); | 803 wordMeasurements.grow(wordMeasurements.size() + 1); |
800 WordMeasurement& wordMeasurement = wordMeasurements.last(); | 804 WordMeasurement& wordMeasurement = wordMeasurements.last(); |
801 wordMeasurement.renderer = renderText; | 805 wordMeasurement.renderer = renderText; |
802 | 806 |
803 // IMPORTANT: current.m_pos is > length here! | 807 // IMPORTANT: current.m_pos is > length here! |
804 float additionalTmpW = m_ignoringSpaces ? 0 : textWidth(renderText, lastSpac
e, m_current.offset() - lastSpace, font, m_width.currentWidth(), isFixedPitch, m
_collapseWhiteSpace, &wordMeasurement.fallbackFonts); | 808 float additionalTempWidth = m_ignoringSpaces ? 0 : textWidth(renderText, las
tSpace, m_current.offset() - lastSpace, font, m_width.currentWidth(), isFixedPit
ch, m_collapseWhiteSpace, &wordMeasurement.fallbackFonts); |
805 wordMeasurement.startOffset = lastSpace; | 809 wordMeasurement.startOffset = lastSpace; |
806 wordMeasurement.endOffset = m_current.offset(); | 810 wordMeasurement.endOffset = m_current.offset(); |
807 wordMeasurement.width = m_ignoringSpaces ? 0 : additionalTmpW + wordSpacingF
orWordMeasurement; | 811 wordMeasurement.width = m_ignoringSpaces ? 0 : additionalTempWidth + wordSpa
cingForWordMeasurement; |
808 additionalTmpW += lastSpaceWordSpacing; | 812 additionalTempWidth += lastSpaceWordSpacing; |
809 m_width.addUncommittedWidth(additionalTmpW + inlineLogicalWidth(m_current.ob
ject(), !m_appliedStartWidth, m_includeEndWidth)); | 813 |
| 814 LayoutUnit inlineLogicalTempWidth = inlineLogicalWidth(m_current.object(), !
m_appliedStartWidth, m_includeEndWidth); |
| 815 m_width.addUncommittedWidth(additionalTempWidth + inlineLogicalTempWidth); |
| 816 |
| 817 if (m_collapseWhiteSpace && m_currentCharacterIsSpace && additionalTempWidth
) |
| 818 m_width.setTrailingWhitespaceWidth(additionalTempWidth + inlineLogicalTe
mpWidth); |
| 819 |
810 m_includeEndWidth = false; | 820 m_includeEndWidth = false; |
811 | 821 |
812 if (!m_width.fitsOnLine()) { | 822 if (!m_width.fitsOnLine()) { |
813 if (!hyphenated && m_lineBreak.previousInSameNode() == softHyphen) { | 823 if (!hyphenated && m_lineBreak.previousInSameNode() == softHyphen) { |
814 hyphenated = true; | 824 hyphenated = true; |
815 m_atEnd = true; | 825 m_atEnd = true; |
816 } | 826 } |
817 } | 827 } |
818 return false; | 828 return false; |
819 } | 829 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 | 902 |
893 if (style->textIndentType() == TextIndentHanging) | 903 if (style->textIndentType() == TextIndentHanging) |
894 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In
dentText; | 904 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In
dentText; |
895 | 905 |
896 return shouldIndentText; | 906 return shouldIndentText; |
897 } | 907 } |
898 | 908 |
899 } | 909 } |
900 | 910 |
901 #endif // BreakingContextInlineHeaders_h | 911 #endif // BreakingContextInlineHeaders_h |
OLD | NEW |