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

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

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