Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h

Issue 1920293003: Fix line wrappiing when break-word/break-all and float with 100% width (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 lastSpaceWordSpacing = 0; 777 lastSpaceWordSpacing = 0;
778 wordSpacingForWordMeasurement = 0; 778 wordSpacingForWordMeasurement = 0;
779 stoppedIgnoringSpaces = true; 779 stoppedIgnoringSpaces = true;
780 stopIgnoringSpaces(lastSpace); 780 stopIgnoringSpaces(lastSpace);
781 } 781 }
782 782
783 // Update our tally of the width since the last breakable position with the width of the word we're now at the end of. 783 // Update our tally of the width since the last breakable position with the width of the word we're now at the end of.
784 float lastWidthMeasurement; 784 float lastWidthMeasurement;
785 WordMeasurement& wordMeasurement = calculateWordWidth(wordMeasurements, layoutText, lastSpace, lastWidthMeasurement, wordSpacingForWordMeasurement, font , wordTrailingSpaceWidth, c); 785 WordMeasurement& wordMeasurement = calculateWordWidth(wordMeasurements, layoutText, lastSpace, lastWidthMeasurement, wordSpacingForWordMeasurement, font , wordTrailingSpaceWidth, c);
786 lastWidthMeasurement += lastSpaceWordSpacing; 786 lastWidthMeasurement += lastSpaceWordSpacing;
787
788 midWordBreak = false;
789 if (canBreakMidWord && !m_width.fitsOnLine(lastWidthMeasurement)
790 && rewindToMidWordBreak(layoutText, style, font, breakAll, wordMeasu rement)) {
791 lastWidthMeasurement = wordMeasurement.width;
792 midWordBreak = true;
793 }
794
795 m_width.addUncommittedWidth(lastWidthMeasurement); 787 m_width.addUncommittedWidth(lastWidthMeasurement);
796 788
797 // We keep track of the total width contributed by trailing space as we often want to exclude it when determining 789 // We keep track of the total width contributed by trailing space as we often want to exclude it when determining
798 // if a run fits on a line. 790 // if a run fits on a line.
799 if (m_collapseWhiteSpace && previousCharacterIsSpace && m_currentCharact erIsSpace && lastWidthMeasurement) 791 if (m_collapseWhiteSpace && previousCharacterIsSpace && m_currentCharact erIsSpace && lastWidthMeasurement)
800 m_width.setTrailingWhitespaceWidth(lastWidthMeasurement); 792 m_width.setTrailingWhitespaceWidth(lastWidthMeasurement);
801 793
802 // If this is the end of the first word in run of text then make sure we apply the width from any leading inlines. 794 // If this is the end of the first word in run of text then make sure we apply the width from any leading inlines.
803 // For example: '<span style="margin-left: 5px;"><span style="margin-lef t: 10px;">FirstWord</span></span>' would 795 // For example: '<span style="margin-left: 5px;"><span style="margin-lef t: 10px;">FirstWord</span></span>' would
804 // apply a width of 15px from the two span ancestors. 796 // apply a width of 15px from the two span ancestors.
805 if (!m_appliedStartWidth) { 797 if (!m_appliedStartWidth) {
806 m_width.addUncommittedWidth(inlineLogicalWidthFromAncestorsIfNeeded( m_current.getLineLayoutItem(), true, false).toFloat()); 798 m_width.addUncommittedWidth(inlineLogicalWidthFromAncestorsIfNeeded( m_current.getLineLayoutItem(), true, false).toFloat());
807 m_appliedStartWidth = true; 799 m_appliedStartWidth = true;
808 } 800 }
809 801
810 // If we haven't hit a breakable position yet and already don't fit on t he line try to move below any floats. 802 // If we haven't hit a breakable position yet and already don't fit on t he line try to move below any floats.
811 if (!m_width.committedWidth() && m_autoWrap && !m_width.fitsOnLine() && !widthMeasurementAtLastBreakOpportunity) 803 if (!m_width.committedWidth() && m_autoWrap && !m_width.fitsOnLine() && !widthMeasurementAtLastBreakOpportunity)
812 m_width.fitBelowFloats(m_lineInfo.isFirstLine()); 804 m_width.fitBelowFloats(m_lineInfo.isFirstLine());
813 805
806 midWordBreak = false;
807 if (canBreakMidWord && !m_width.fitsOnLine()) {
808 m_width.addUncommittedWidth(-wordMeasurement.width);
809 if (rewindToMidWordBreak(layoutText, style, font, breakAll, wordMeas urement)) {
810 lastWidthMeasurement = wordMeasurement.width + lastSpaceWordSpac ing;
811 midWordBreak = true;
812 }
813 m_width.addUncommittedWidth(wordMeasurement.width);
814 }
815
814 // If there is a soft-break available at this whitespace position then t ake it. 816 // If there is a soft-break available at this whitespace position then t ake it.
815 applyWordSpacing = wordSpacing && m_currentCharacterIsSpace; 817 applyWordSpacing = wordSpacing && m_currentCharacterIsSpace;
816 if (canBreakAtWhitespace(breakWords, wordMeasurement, stoppedIgnoringSpa ces, hyphenated, charWidth, hyphenWidth, betweenWords, midWordBreak, canBreakMid Word, previousCharacterIsSpace, lastWidthMeasurement, layoutText, font, applyWor dSpacing, wordSpacing)) 818 if (canBreakAtWhitespace(breakWords, wordMeasurement, stoppedIgnoringSpa ces, hyphenated, charWidth, hyphenWidth, betweenWords, midWordBreak, canBreakMid Word, previousCharacterIsSpace, lastWidthMeasurement, layoutText, font, applyWor dSpacing, wordSpacing))
817 return false; 819 return false;
818 820
819 // If there is a hard-break available at this whitespace position then t ake it. 821 // If there is a hard-break available at this whitespace position then t ake it.
820 if (c == newlineCharacter && m_preservesNewline) { 822 if (c == newlineCharacter && m_preservesNewline) {
821 if (!stoppedIgnoringSpaces && m_current.offset()) 823 if (!stoppedIgnoringSpaces && m_current.offset())
822 m_lineMidpointState.ensureCharacterGetsLineBox(m_current); 824 m_lineMidpointState.ensureCharacterGetsLineBox(m_current);
823 m_lineBreak.moveTo(m_current.getLineLayoutItem(), m_current.offset() , m_current.nextBreakablePosition()); 825 m_lineBreak.moveTo(m_current.getLineLayoutItem(), m_current.offset() , m_current.nextBreakablePosition());
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 1098
1097 if (style.getTextIndentType() == TextIndentHanging) 1099 if (style.getTextIndentType() == TextIndentHanging)
1098 indentText = indentText == IndentText ? DoNotIndentText : IndentText; 1100 indentText = indentText == IndentText ? DoNotIndentText : IndentText;
1099 1101
1100 return indentText; 1102 return indentText;
1101 } 1103 }
1102 1104
1103 } // namespace blink 1105 } // namespace blink
1104 1106
1105 #endif // BreakingContextInlineHeaders_h 1107 #endif // BreakingContextInlineHeaders_h
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/css3-text/css3-word-break/word-break-all-wrap-with-100percent-floats.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698