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

Unified Diff: Source/platform/fonts/WidthIterator.cpp

Issue 54743004: Rendering text-justify:distribute for 8 bit characters. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: use const parameter Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/fonts/WidthIterator.h ('k') | Source/platform/fonts/mac/ComplexTextController.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « Source/platform/fonts/WidthIterator.h ('k') | Source/platform/fonts/mac/ComplexTextController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698