| 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..cc3d092329ed0f37365b89f333ed6dcd3aa253a7 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 isExpansionOpportunity = Font::treatAsSpace(character) || m_distributeJustification;
|
| + if (isExpansionOpportunity || (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 (!isExpansionOpportunity && !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 (isExpansionOpportunity && (character != '\t' || !m_run.allowTabs()) && (textIterator.currentCharacter() || character == noBreakSpace) && m_font->wordSpacing())
|
| width += m_font->wordSpacing();
|
| } else
|
| m_isAfterExpansion = false;
|
|
|