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

Side by Side Diff: Source/core/rendering/line/BreakingContextInlineHeaders.h

Issue 343663004: Floats following inlines break to next line unncessarily (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 years, 6 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 | Annotate | Revision Log
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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(), ExcludeWhitespace)) {
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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 } 637 }
638 } 638 }
639 639
640 wordMeasurements.grow(wordMeasurements.size() + 1); 640 wordMeasurements.grow(wordMeasurements.size() + 1);
641 WordMeasurement& wordMeasurement = wordMeasurements.last(); 641 WordMeasurement& wordMeasurement = wordMeasurements.last();
642 642
643 wordMeasurement.renderer = renderText; 643 wordMeasurement.renderer = renderText;
644 wordMeasurement.endOffset = m_current.offset(); 644 wordMeasurement.endOffset = m_current.offset();
645 wordMeasurement.startOffset = lastSpace; 645 wordMeasurement.startOffset = lastSpace;
646 646
647 float additionalTmpW; 647 float additionalTempWidth;
648 if (wordTrailingSpaceWidth && c == ' ') 648 if (wordTrailingSpaceWidth && c == ' ')
649 additionalTmpW = textWidth(renderText, lastSpace, m_current.offs et() + 1 - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhit eSpace, &wordMeasurement.fallbackFonts) - wordTrailingSpaceWidth; 649 additionalTempWidth = textWidth(renderText, lastSpace, m_current .offset() + 1 - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collaps eWhiteSpace, &wordMeasurement.fallbackFonts) - wordTrailingSpaceWidth;
650 else 650 else
651 additionalTmpW = textWidth(renderText, lastSpace, m_current.offs et() - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpa ce, &wordMeasurement.fallbackFonts); 651 additionalTempWidth = textWidth(renderText, lastSpace, m_current .offset() - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhi teSpace, &wordMeasurement.fallbackFonts);
652 652
653 wordMeasurement.width = additionalTmpW + wordSpacingForWordMeasureme nt; 653 wordMeasurement.width = additionalTempWidth + wordSpacingForWordMeas urement;
654 additionalTmpW += lastSpaceWordSpacing; 654 additionalTempWidth += lastSpaceWordSpacing;
655 m_width.addUncommittedWidth(additionalTmpW); 655 m_width.addUncommittedWidth(additionalTempWidth);
656
657 if (m_collapseWhiteSpace && previousCharacterIsSpace && m_currentCha racterIsSpace && additionalTempWidth)
658 m_width.setTrailingWhitespaceWidth(additionalTempWidth);
659
656 if (!m_appliedStartWidth) { 660 if (!m_appliedStartWidth) {
657 m_width.addUncommittedWidth(inlineLogicalWidth(m_current.object( ), true, false).toFloat()); 661 m_width.addUncommittedWidth(inlineLogicalWidth(m_current.object( ), true, false).toFloat());
658 m_appliedStartWidth = true; 662 m_appliedStartWidth = true;
659 } 663 }
660 664
661 applyWordSpacing = wordSpacing && m_currentCharacterIsSpace; 665 applyWordSpacing = wordSpacing && m_currentCharacterIsSpace;
662 666
663 if (!m_width.committedWidth() && m_autoWrap && !m_width.fitsOnLine() ) 667 if (!m_width.committedWidth() && m_autoWrap && !m_width.fitsOnLine() )
664 m_width.fitBelowFloats(m_lineInfo.isFirstLine()); 668 m_width.fitBelowFloats(m_lineInfo.isFirstLine());
665 669
(...skipping 30 matching lines...) Expand all
696 wordMeasurement.width = charWidth; 700 wordMeasurement.width = charWidth;
697 } 701 }
698 } 702 }
699 // Didn't fit. Jump to the end unless there's still an oppor tunity to collapse whitespace. 703 // Didn't fit. Jump to the end unless there's still an oppor tunity to collapse whitespace.
700 if (m_ignoringSpaces || !m_collapseWhiteSpace || !m_currentC haracterIsSpace || !previousCharacterIsSpace) { 704 if (m_ignoringSpaces || !m_collapseWhiteSpace || !m_currentC haracterIsSpace || !previousCharacterIsSpace) {
701 m_atEnd = true; 705 m_atEnd = true;
702 return false; 706 return false;
703 } 707 }
704 } else { 708 } else {
705 if (!betweenWords || (midWordBreak && !m_autoWrap)) 709 if (!betweenWords || (midWordBreak && !m_autoWrap))
706 m_width.addUncommittedWidth(-additionalTmpW); 710 m_width.addUncommittedWidth(-additionalTempWidth);
707 if (hyphenWidth) { 711 if (hyphenWidth) {
708 // Subtract the width of the soft hyphen out since we fi t on a line. 712 // Subtract the width of the soft hyphen out since we fi t on a line.
709 m_width.addUncommittedWidth(-hyphenWidth); 713 m_width.addUncommittedWidth(-hyphenWidth);
710 hyphenWidth = 0; 714 hyphenWidth = 0;
711 } 715 }
712 } 716 }
713 } 717 }
714 718
715 if (c == '\n' && m_preservesNewline) { 719 if (c == '\n' && m_preservesNewline) {
716 if (!stoppedIgnoringSpaces && m_current.offset()) 720 if (!stoppedIgnoringSpaces && m_current.offset())
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 nextCharacter(c, lastCharacter, secondToLastCharacter); 796 nextCharacter(c, lastCharacter, secondToLastCharacter);
793 } 797 }
794 798
795 m_renderTextInfo.m_lineBreakIterator.setPriorContext(lastCharacter, secondTo LastCharacter); 799 m_renderTextInfo.m_lineBreakIterator.setPriorContext(lastCharacter, secondTo LastCharacter);
796 800
797 wordMeasurements.grow(wordMeasurements.size() + 1); 801 wordMeasurements.grow(wordMeasurements.size() + 1);
798 WordMeasurement& wordMeasurement = wordMeasurements.last(); 802 WordMeasurement& wordMeasurement = wordMeasurements.last();
799 wordMeasurement.renderer = renderText; 803 wordMeasurement.renderer = renderText;
800 804
801 // IMPORTANT: current.m_pos is > length here! 805 // IMPORTANT: current.m_pos is > length here!
802 float additionalTmpW = m_ignoringSpaces ? 0 : textWidth(renderText, lastSpac e, m_current.offset() - lastSpace, font, m_width.currentWidth(), isFixedPitch, m _collapseWhiteSpace, &wordMeasurement.fallbackFonts); 806 float additionalTempWidth = m_ignoringSpaces ? 0 : textWidth(renderText, las tSpace, m_current.offset() - lastSpace, font, m_width.currentWidth(), isFixedPit ch, m_collapseWhiteSpace, &wordMeasurement.fallbackFonts);
803 wordMeasurement.startOffset = lastSpace; 807 wordMeasurement.startOffset = lastSpace;
804 wordMeasurement.endOffset = m_current.offset(); 808 wordMeasurement.endOffset = m_current.offset();
805 wordMeasurement.width = m_ignoringSpaces ? 0 : additionalTmpW + wordSpacingF orWordMeasurement; 809 wordMeasurement.width = m_ignoringSpaces ? 0 : additionalTempWidth + wordSpa cingForWordMeasurement;
806 additionalTmpW += lastSpaceWordSpacing; 810 additionalTempWidth += lastSpaceWordSpacing;
807 m_width.addUncommittedWidth(additionalTmpW + inlineLogicalWidth(m_current.ob ject(), !m_appliedStartWidth, m_includeEndWidth)); 811
812 LayoutUnit inlineLogicalTempWidth = inlineLogicalWidth(m_current.object(), ! m_appliedStartWidth, m_includeEndWidth);
813 m_width.addUncommittedWidth(additionalTempWidth + inlineLogicalTempWidth);
814
815 if (m_collapseWhiteSpace && m_currentCharacterIsSpace && additionalTempWidth )
816 m_width.setTrailingWhitespaceWidth(additionalTempWidth + inlineLogicalTe mpWidth);
817
808 m_includeEndWidth = false; 818 m_includeEndWidth = false;
809 819
810 if (!m_width.fitsOnLine()) { 820 if (!m_width.fitsOnLine()) {
811 if (!hyphenated && m_lineBreak.previousInSameNode() == softHyphen) { 821 if (!hyphenated && m_lineBreak.previousInSameNode() == softHyphen) {
812 hyphenated = true; 822 hyphenated = true;
813 m_atEnd = true; 823 m_atEnd = true;
814 } 824 }
815 } 825 }
816 return false; 826 return false;
817 } 827 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 900
891 if (style->textIndentType() == TextIndentHanging) 901 if (style->textIndentType() == TextIndentHanging)
892 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In dentText; 902 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In dentText;
893 903
894 return shouldIndentText; 904 return shouldIndentText;
895 } 905 }
896 906
897 } 907 }
898 908
899 #endif // BreakingContextInlineHeaders_h 909 #endif // BreakingContextInlineHeaders_h
OLDNEW
« no previous file with comments | « LayoutTests/fast/multicol/vertical-rl/float-truncation.html ('k') | Source/core/rendering/line/LineWidth.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698