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

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

Issue 1204783002: Fix glyph overflow with word-spacing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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
« no previous file with comments | « LayoutTests/fast/text/glyph-overflow-with-word-spacing-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 wordMeasurement.endOffset = m_current.offset(); 637 wordMeasurement.endOffset = m_current.offset();
638 wordMeasurement.startOffset = lastSpace; 638 wordMeasurement.startOffset = lastSpace;
639 639
640 float additionalTempWidth; 640 float additionalTempWidth;
641 if (wordTrailingSpaceWidth && c == spaceCharacter) 641 if (wordTrailingSpaceWidth && c == spaceCharacter)
642 additionalTempWidth = textWidth(layoutText, lastSpace, m_current .offset() + 1 - lastSpace, font, m_width.currentWidth(), m_collapseWhiteSpace, & wordMeasurement.fallbackFonts, &wordMeasurement.glyphBounds) - wordTrailingSpace Width; 642 additionalTempWidth = textWidth(layoutText, lastSpace, m_current .offset() + 1 - lastSpace, font, m_width.currentWidth(), m_collapseWhiteSpace, & wordMeasurement.fallbackFonts, &wordMeasurement.glyphBounds) - wordTrailingSpace Width;
643 else 643 else
644 additionalTempWidth = textWidth(layoutText, lastSpace, m_current .offset() - lastSpace, font, m_width.currentWidth(), m_collapseWhiteSpace, &word Measurement.fallbackFonts, &wordMeasurement.glyphBounds); 644 additionalTempWidth = textWidth(layoutText, lastSpace, m_current .offset() - lastSpace, font, m_width.currentWidth(), m_collapseWhiteSpace, &word Measurement.fallbackFonts, &wordMeasurement.glyphBounds);
645 645
646 wordMeasurement.width = additionalTempWidth + wordSpacingForWordMeas urement; 646 wordMeasurement.width = additionalTempWidth + wordSpacingForWordMeas urement;
647 wordMeasurement.glyphBounds.move(wordSpacingForWordMeasurement, 0);
647 additionalTempWidth += lastSpaceWordSpacing; 648 additionalTempWidth += lastSpaceWordSpacing;
648 m_width.addUncommittedWidth(additionalTempWidth); 649 m_width.addUncommittedWidth(additionalTempWidth);
649 650
650 if (m_collapseWhiteSpace && previousCharacterIsSpace && m_currentCha racterIsSpace && additionalTempWidth) 651 if (m_collapseWhiteSpace && previousCharacterIsSpace && m_currentCha racterIsSpace && additionalTempWidth)
651 m_width.setTrailingWhitespaceWidth(additionalTempWidth); 652 m_width.setTrailingWhitespaceWidth(additionalTempWidth);
652 653
653 if (!m_appliedStartWidth) { 654 if (!m_appliedStartWidth) {
654 m_width.addUncommittedWidth(inlineLogicalWidth(m_current.object( ), true, false).toFloat()); 655 m_width.addUncommittedWidth(inlineLogicalWidth(m_current.object( ), true, false).toFloat());
655 m_appliedStartWidth = true; 656 m_appliedStartWidth = true;
656 } 657 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 nextCharacter(c, lastCharacter, secondToLastCharacter); 795 nextCharacter(c, lastCharacter, secondToLastCharacter);
795 } 796 }
796 797
797 m_layoutTextInfo.m_lineBreakIterator.setPriorContext(lastCharacter, secondTo LastCharacter); 798 m_layoutTextInfo.m_lineBreakIterator.setPriorContext(lastCharacter, secondTo LastCharacter);
798 799
799 wordMeasurements.grow(wordMeasurements.size() + 1); 800 wordMeasurements.grow(wordMeasurements.size() + 1);
800 WordMeasurement& wordMeasurement = wordMeasurements.last(); 801 WordMeasurement& wordMeasurement = wordMeasurements.last();
801 wordMeasurement.layoutText = layoutText; 802 wordMeasurement.layoutText = layoutText;
802 803
803 // IMPORTANT: current.m_pos is > length here! 804 // IMPORTANT: current.m_pos is > length here!
804 float additionalTempWidth = m_ignoringSpaces ? 0 : textWidth(layoutText, las tSpace, m_current.offset() - lastSpace, font, m_width.currentWidth(), m_collapse WhiteSpace, &wordMeasurement.fallbackFonts, &wordMeasurement.glyphBounds); 805 float additionalTempWidth = 0;
805 wordMeasurement.startOffset = lastSpace; 806 wordMeasurement.startOffset = lastSpace;
806 wordMeasurement.endOffset = m_current.offset(); 807 wordMeasurement.endOffset = m_current.offset();
807 wordMeasurement.width = m_ignoringSpaces ? 0 : additionalTempWidth + wordSpa cingForWordMeasurement; 808 if (!m_ignoringSpaces) {
809 additionalTempWidth = textWidth(layoutText, lastSpace, m_current.offset( ) - lastSpace, font, m_width.currentWidth(), m_collapseWhiteSpace, &wordMeasurem ent.fallbackFonts, &wordMeasurement.glyphBounds);
810 wordMeasurement.width = additionalTempWidth + wordSpacingForWordMeasurem ent;
811 wordMeasurement.glyphBounds.move(wordSpacingForWordMeasurement, 0);
812 }
808 additionalTempWidth += lastSpaceWordSpacing; 813 additionalTempWidth += lastSpaceWordSpacing;
809 814
810 LayoutUnit inlineLogicalTempWidth = inlineLogicalWidth(m_current.object(), ! m_appliedStartWidth, m_includeEndWidth); 815 LayoutUnit inlineLogicalTempWidth = inlineLogicalWidth(m_current.object(), ! m_appliedStartWidth, m_includeEndWidth);
811 m_width.addUncommittedWidth(additionalTempWidth + inlineLogicalTempWidth); 816 m_width.addUncommittedWidth(additionalTempWidth + inlineLogicalTempWidth);
812 817
813 if (m_collapseWhiteSpace && m_currentCharacterIsSpace && additionalTempWidth ) 818 if (m_collapseWhiteSpace && m_currentCharacterIsSpace && additionalTempWidth )
814 m_width.setTrailingWhitespaceWidth(additionalTempWidth + inlineLogicalTe mpWidth); 819 m_width.setTrailingWhitespaceWidth(additionalTempWidth + inlineLogicalTe mpWidth);
815 820
816 m_includeEndWidth = false; 821 m_includeEndWidth = false;
817 822
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 903
899 if (style.textIndentType() == TextIndentHanging) 904 if (style.textIndentType() == TextIndentHanging)
900 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In dentText; 905 shouldIndentText = shouldIndentText == IndentText ? DoNotIndentText : In dentText;
901 906
902 return shouldIndentText; 907 return shouldIndentText;
903 } 908 }
904 909
905 } 910 }
906 911
907 #endif // BreakingContextInlineHeaders_h 912 #endif // BreakingContextInlineHeaders_h
OLDNEW
« no previous file with comments | « LayoutTests/fast/text/glyph-overflow-with-word-spacing-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698