summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/WidthIterator.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-24 11:24:40 +0100
committerBen Murdoch <benm@google.com>2011-06-02 09:53:15 +0100
commit81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch)
tree7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebCore/platform/graphics/WidthIterator.cpp
parent94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff)
downloadexternal_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebCore/platform/graphics/WidthIterator.cpp')
-rw-r--r--Source/WebCore/platform/graphics/WidthIterator.cpp63
1 files changed, 6 insertions, 57 deletions
diff --git a/Source/WebCore/platform/graphics/WidthIterator.cpp b/Source/WebCore/platform/graphics/WidthIterator.cpp
index a1a88da..27b0627 100644
--- a/Source/WebCore/platform/graphics/WidthIterator.cpp
+++ b/Source/WebCore/platform/graphics/WidthIterator.cpp
@@ -48,7 +48,6 @@ WidthIterator::WidthIterator(const Font* font, const TextRun& run, HashSet<const
, m_currentCharacter(0)
, m_runWidthSoFar(0)
, m_isAfterExpansion(true)
- , m_finalRoundingWidth(0)
, m_fallbackFonts(fallbackFonts)
, m_accountForGlyphBounds(accountForGlyphBounds)
, m_maxGlyphBoundingBoxY(numeric_limits<float>::min())
@@ -86,11 +85,6 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
bool rtl = m_run.rtl();
bool hasExtraSpacing = (m_font->letterSpacing() || m_font->wordSpacing() || m_expansion) && !m_run.spacingDisabled();
- float widthSinceLastRounding = m_runWidthSoFar;
- m_runWidthSoFar = floorf(m_runWidthSoFar);
- widthSinceLastRounding -= m_runWidthSoFar;
-
- float lastRoundingWidth = m_finalRoundingWidth;
FloatRect bounds;
const SimpleFontData* primaryFont = m_font->primaryFont();
@@ -136,7 +130,7 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
float width;
if (c == '\t' && m_run.allowTabs()) {
float tabWidth = m_font->tabWidth(*fontData);
- width = tabWidth - fmodf(m_run.xPos() + m_runWidthSoFar + widthSinceLastRounding, tabWidth);
+ width = tabWidth - fmodf(m_run.xPos() + m_runWidthSoFar, tabWidth);
} else {
width = fontData->widthForGlyph(glyph);
@@ -144,13 +138,6 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
// SVG uses horizontalGlyphStretch(), when textLength is used to stretch/squeeze text.
width *= m_run.horizontalGlyphStretch();
#endif
-
- // We special case spaces in two ways when applying word rounding.
- // First, we round spaces to an adjusted width in all fonts.
- // Second, in fixed-pitch fonts we ensure that all characters that
- // match the width of the space character have the same width as the space character.
- if (width == fontData->spaceWidth() && (fontData->pitch() == FixedPitch || glyph == fontData->spaceGlyph()) && m_run.applyWordRounding())
- width = fontData->adjustedSpaceWidth();
}
if (fontData != lastFontData && width) {
@@ -179,18 +166,15 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
// Distribute the run's total expansion evenly over all expansion opportunities in the run.
if (m_expansion && (m_run.allowsTrailingExpansion() || (m_run.ltr() && currentCharacter + clusterLength < static_cast<size_t>(m_run.length()))
|| (m_run.rtl() && currentCharacter))) {
- float previousExpansion = m_expansion;
if (!treatAsSpace && !m_isAfterExpansion) {
// Take the expansion opportunity before this ideograph.
m_expansion -= m_expansionPerOpportunity;
- int expansion = roundf(previousExpansion) - roundf(m_expansion);
- m_runWidthSoFar += expansion;
+ m_runWidthSoFar += m_expansionPerOpportunity;
if (glyphBuffer)
- glyphBuffer->expandLastAdvance(expansion);
- previousExpansion = m_expansion;
+ glyphBuffer->expandLastAdvance(m_expansionPerOpportunity);
}
m_expansion -= m_expansionPerOpportunity;
- width += roundf(previousExpansion) - roundf(m_expansion);
+ width += m_expansionPerOpportunity;
m_isAfterExpansion = true;
} else
m_isAfterExpansion = false;
@@ -216,43 +200,10 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
cp += clusterLength;
currentCharacter += clusterLength;
- // Account for float/integer impedance mismatch between CG and KHTML. "Words" (characters
- // followed by a character defined by isRoundingHackCharacter()) are always an integer width.
- // We adjust the width of the last character of a "word" to ensure an integer width.
- // If we move KHTML to floats we can remove this (and related) hacks.
-
- float oldWidth = width;
-
- // Force characters that are used to determine word boundaries for the rounding hack
- // to be integer width, so following words will start on an integer boundary.
- if (m_run.applyWordRounding() && Font::isRoundingHackCharacter(c)) {
- width = ceilf(width);
-
- // Since widthSinceLastRounding can lose precision if we include measurements for
- // preceding whitespace, we bypass it here.
- m_runWidthSoFar += width;
-
- // Since this is a rounding hack character, we should have reset this sum on the previous
- // iteration.
- ASSERT(!widthSinceLastRounding);
- } else {
- // Check to see if the next character is a "rounding hack character", if so, adjust
- // width so that the total run width will be on an integer boundary.
- if ((m_run.applyWordRounding() && currentCharacter < m_run.length() && Font::isRoundingHackCharacter(*cp))
- || (m_run.applyRunRounding() && currentCharacter >= m_end)) {
- float totalWidth = widthSinceLastRounding + width;
- widthSinceLastRounding = ceilf(totalWidth);
- width += widthSinceLastRounding - totalWidth;
- m_runWidthSoFar += widthSinceLastRounding;
- widthSinceLastRounding = 0;
- } else
- widthSinceLastRounding += width;
- }
+ m_runWidthSoFar += width;
if (glyphBuffer)
- glyphBuffer->add(glyph, fontData, (rtl ? oldWidth + lastRoundingWidth : width));
-
- lastRoundingWidth = width - oldWidth;
+ glyphBuffer->add(glyph, fontData, width);
if (m_accountForGlyphBounds) {
m_maxGlyphBoundingBoxY = max(m_maxGlyphBoundingBoxY, bounds.maxY());
@@ -262,8 +213,6 @@ void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
}
m_currentCharacter = currentCharacter;
- m_runWidthSoFar += widthSinceLastRounding;
- m_finalRoundingWidth = lastRoundingWidth;
}
bool WidthIterator::advanceOneCharacter(float& width, GlyphBuffer* glyphBuffer)