Chromium Code Reviews| Index: Source/core/platform/graphics/WidthIterator.cpp |
| diff --git a/Source/core/platform/graphics/WidthIterator.cpp b/Source/core/platform/graphics/WidthIterator.cpp |
| index b82b500263ef5013bc593619aa2d5f466ddda99b..bd1f9c283ec042ccaae4c3910bfce476b57eb20f 100644 |
| --- a/Source/core/platform/graphics/WidthIterator.cpp |
| +++ b/Source/core/platform/graphics/WidthIterator.cpp |
| @@ -50,15 +50,18 @@ WidthIterator::WidthIterator(const Font* font, const TextRun& run, HashSet<const |
| , m_firstGlyphOverflow(0) |
| , m_lastGlyphOverflow(0) |
| , m_forTextEmphasis(forTextEmphasis) |
| + , m_distributeJustification(false) |
| { |
| // If the padding is non-zero, count the number of spaces in the run |
| // and divide that by the padding for per space addition. |
| m_expansion = m_run.expansion(); |
| + m_distributeJustification = m_run.isDistributeJustification(); |
| if (!m_expansion) |
| m_expansionPerOpportunity = 0; |
| else { |
| bool isAfterExpansion = m_isAfterExpansion; |
| - unsigned expansionOpportunityCount = m_run.is8Bit() ? Font::expansionOpportunityCount(m_run.characters8(), m_run.length(), m_run.ltr() ? LTR : RTL, isAfterExpansion) : Font::expansionOpportunityCount(m_run.characters16(), m_run.length(), m_run.ltr() ? LTR : RTL, isAfterExpansion); |
| + unsigned expansionOpportunityCount = m_run.is8Bit() ? Font::expansionOpportunityCount(m_run.characters8(), m_run.length(), m_run.ltr() ? LTR : RTL, isAfterExpansion, m_distributeJustification) : Font::expansionOpportunityCount(m_run.characters16(), m_run.length(), m_run.ltr() ? LTR : RTL, isAfterExpansion, m_distributeJustification); |
| + |
| if (isAfterExpansion && !m_run.allowsTrailingExpansion()) |
| expansionOpportunityCount--; |
| @@ -210,12 +213,12 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph |
| width += m_font->letterSpacing(); |
| static bool expandAroundIdeographs = Font::canExpandAroundIdeographsInComplexText(); |
| - bool treatAsSpace = Font::treatAsSpace(character); |
| - if (treatAsSpace || (expandAroundIdeographs && Font::isCJKIdeographOrSymbol(character))) { |
| + bool needExpansion = Font::treatAsSpace(character) || m_distributeJustification; |
|
leviw_travelin_and_unemployed
2013/11/01 20:39:14
how about something like isExpansionOpportunity in
dw.im
2013/11/02 03:13:01
could be better name.. :)
dw.im
2013/11/04 02:11:09
Done.
|
| + if (needExpansion || (expandAroundIdeographs && Font::isCJKIdeographOrSymbol(character))) { |
| // Distribute the run's total expansion evenly over all expansion opportunities in the run. |
| if (m_expansion) { |
| float previousExpansion = m_expansion; |
| - if (!treatAsSpace && !m_isAfterExpansion) { |
| + if (!needExpansion && !m_isAfterExpansion) { |
| // Take the expansion opportunity before this ideograph. |
| m_expansion -= m_expansionPerOpportunity; |
| float expansionAtThisOpportunity = !m_run.applyWordRounding() ? m_expansionPerOpportunity : roundf(previousExpansion) - roundf(m_expansion); |
| @@ -242,7 +245,7 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph |
| // Account for word spacing. |
| // We apply additional space between "words" by adding width to the space character. |
| - if (treatAsSpace && (character != '\t' || !m_run.allowTabs()) && (textIterator.currentCharacter() || character == noBreakSpace) && m_font->wordSpacing()) |
| + if (needExpansion && (character != '\t' || !m_run.allowTabs()) && (textIterator.currentCharacter() || character == noBreakSpace) && m_font->wordSpacing()) |
| width += m_font->wordSpacing(); |
| } else |
| m_isAfterExpansion = false; |