Changeset 152313 in webkit
- Timestamp:
- Jul 2, 2013 12:30:32 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r152303 r152313 1 2013-06-26 Robert Hogan <robert@webkit.org> 2 3 empty inlines should not affect line-wrapping 4 https://bugs.webkit.org/show_bug.cgi?id=25638 5 6 Reviewed by David Hyatt. 7 8 * fast/text/whitespace/inline-whitespace-wrapping-11-expected.html: Added. 9 * fast/text/whitespace/inline-whitespace-wrapping-11.html: Added. 10 1 11 2013-07-02 Tim Horton <timothy_horton@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r152307 r152313 1 2013-06-26 Robert Hogan <robert@webkit.org> 2 3 empty inlines should not affect line-wrapping 4 https://bugs.webkit.org/show_bug.cgi?id=25638 5 6 Reviewed by David Hyatt. 7 8 Don't break on empty inlines if we're in the middle of a word. I took this opportunity to 9 refactor the series of checks we perform to establish if we can break at the current position. 10 11 Test: fast/text/whitespace/inline-whitespace-wrapping-11.html 12 13 * rendering/RenderBlockLineLayout.cpp: 14 (WebCore::textBeginsWithBreakablePosition): 15 (WebCore::canBreakAtThisPosition): 16 (WebCore::RenderBlock::LineBreaker::nextSegmentBreak): 17 1 18 2013-07-02 Jae Hyun Park <jae.park@company100.net> 2 19 -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r152122 r152313 2868 2868 width.commit(); 2869 2869 lBreak.moveTo(object, offset, nextBreak); 2870 } 2871 2872 static bool textBeginsWithBreakablePosition(RenderObject* next) 2873 { 2874 ASSERT(next->isText()); 2875 RenderText* nextText = toRenderText(next); 2876 if (nextText->isWordBreak()) 2877 return true; 2878 if (!nextText->textLength()) 2879 return false; 2880 UChar c = nextText->characterAt(0); 2881 return c == ' ' || c == '\t' || (c == '\n' && !nextText->preservesNewline()); 2882 } 2883 2884 static bool canBreakAtThisPosition(bool autoWrap, LineWidth& width, InlineIterator& lBreak, RenderObject* next, const InlineIterator& current, EWhiteSpace currWS, bool currentCharacterIsSpace, bool autoWrapWasEverTrueOnLine) 2885 { 2886 // If we are no-wrap and have found a line-breaking opportunity already then we should take it. 2887 if (width.committedWidth() && !width.fitsOnLine(currentCharacterIsSpace) && currWS == NOWRAP) 2888 return true; 2889 2890 // Avoid breaking before empty inlines. 2891 if (next && isEmptyInline(next)) 2892 return false; 2893 2894 // Return early if we autowrap and the current character is a space as we will always want to break at such a position. 2895 if (autoWrap && currentCharacterIsSpace) 2896 return true; 2897 2898 bool nextIsText = (next && (current.m_obj->isText() || isEmptyInline(current.m_obj)) && next->isText() && !next->isBR() && (autoWrap || next->style()->autoWrap())); 2899 if (!nextIsText) 2900 return autoWrap; 2901 2902 bool canBreakHere = !currentCharacterIsSpace && textBeginsWithBreakablePosition(next); 2903 2904 // See if attempting to fit below floats creates more available width on the line. 2905 if (!width.fitsOnLine() && !width.committedWidth()) 2906 width.fitBelowFloats(); 2907 2908 bool canPlaceOnLine = width.fitsOnLine() || !autoWrapWasEverTrueOnLine; 2909 2910 // If we are an empty inline in the middle of a word and don't fit on the line then clear any line break we have and find 2911 // one in the following text instead. 2912 if (!canPlaceOnLine && !canBreakHere && isEmptyInline(current.m_obj)) 2913 lBreak.clear(); 2914 else if (canPlaceOnLine && canBreakHere) 2915 commitLineBreakAtCurrentWidth(width, lBreak, next); 2916 2917 return canBreakHere; 2870 2918 } 2871 2919 … … 3409 3457 ASSERT_NOT_REACHED(); 3410 3458 3411 bool checkForBreak = autoWrap; 3412 if (width.committedWidth() && !width.fitsOnLine(currentCharacterIsSpace) && lBreak.m_obj && currWS == NOWRAP) 3413 checkForBreak = true; 3414 else if (next && current.m_obj->isText() && next->isText() && !next->isBR() && (autoWrap || next->style()->autoWrap())) { 3415 if (autoWrap && currentCharacterIsSpace) 3416 checkForBreak = true; 3417 else { 3418 RenderText* nextText = toRenderText(next); 3419 if (nextText->textLength()) { 3420 UChar c = nextText->characterAt(0); 3421 checkForBreak = !currentCharacterIsSpace && (c == ' ' || c == '\t' || (c == '\n' && !next->preservesNewline())); 3422 } else if (nextText->isWordBreak()) 3423 checkForBreak = true; 3424 3425 if (!width.fitsOnLine() && !width.committedWidth()) 3426 width.fitBelowFloats(); 3427 3428 bool canPlaceOnLine = width.fitsOnLine() || !autoWrapWasEverTrueOnLine; 3429 if (canPlaceOnLine && checkForBreak) 3430 commitLineBreakAtCurrentWidth(width, lBreak, next); 3431 } 3432 } 3433 3434 if (checkForBreak && !width.fitsOnLine(ignoringSpaces)) { 3459 bool canBreakHere = canBreakAtThisPosition(autoWrap, width, lBreak, next, current, currWS, currentCharacterIsSpace, autoWrapWasEverTrueOnLine); 3460 if (canBreakHere && !width.fitsOnLine(ignoringSpaces)) { 3435 3461 // if we have floats, try to get below them. 3436 3462 if (currentCharacterIsSpace && !ignoringSpaces && currentStyle->collapseWhiteSpace())
Note: See TracChangeset
for help on using the changeset viewer.