Index: Source/platform/fonts/WidthIterator.cpp |
diff --git a/Source/platform/fonts/WidthIterator.cpp b/Source/platform/fonts/WidthIterator.cpp |
index 6c24af03e14873e82114d52a087d00611a64f9fa..cc45414ae547e800d065bc7fef0c5b1947fcb8f6 100644 |
--- a/Source/platform/fonts/WidthIterator.cpp |
+++ b/Source/platform/fonts/WidthIterator.cpp |
@@ -51,15 +51,17 @@ 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() ? Character::expansionOpportunityCount(m_run.characters8(), m_run.length(), m_run.ltr() ? LTR : RTL, isAfterExpansion) : Character::expansionOpportunityCount(m_run.characters16(), m_run.length(), m_run.ltr() ? LTR : RTL, isAfterExpansion); |
+ unsigned expansionOpportunityCount = m_run.is8Bit() ? Character::expansionOpportunityCount(m_run.characters8(), m_run.length(), m_run.ltr() ? LTR : RTL, isAfterExpansion, m_distributeJustification) : Character::expansionOpportunityCount(m_run.characters16(), m_run.length(), m_run.ltr() ? LTR : RTL, isAfterExpansion, m_distributeJustification); |
if (isAfterExpansion && !m_run.allowsTrailingExpansion()) |
expansionOpportunityCount--; |
@@ -208,12 +210,12 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph |
width += m_font->fontDescription().letterSpacing(); |
static bool expandAroundIdeographs = FontPlatformFeatures::canExpandAroundIdeographsInComplexText(); |
- bool treatAsSpace = Character::treatAsSpace(character); |
- if (treatAsSpace || (expandAroundIdeographs && Character::isCJKIdeographOrSymbol(character))) { |
+ bool isExpansionOpportunity = Character::treatAsSpace(character) || m_distributeJustification; |
+ if (isExpansionOpportunity || (expandAroundIdeographs && Character::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); |
@@ -240,7 +242,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->fontDescription().wordSpacing()) |
+ if (isExpansionOpportunity && (character != '\t' || !m_run.allowTabs()) && (textIterator.currentCharacter() || character == noBreakSpace) && m_font->fontDescription().wordSpacing()) |
width += m_font->fontDescription().wordSpacing(); |
} else |
m_isAfterExpansion = false; |