Commit 3e944d87 authored by eae@chromium.org's avatar eae@chromium.org

Fix handling of word-spacing and nbsp for complex text

Shange HarfBuzzShaper to not normalize non breaking space and update the
logic in adjustSpacing to correctly handle non breaking space characters
during word-space adjustments. The logic for word spacing adjustments is
based on the implementation in SimpleShaper which has been proven right.

R=pdr@chromium.org
BUG=523548
TEST=fast/text/word-spacing-nbsp.html

Review URL: https://codereview.chromium.org/1310803003

git-svn-id: svn://svn.chromium.org/blink/trunk@201041 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 29323d23
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test word-spacing and nbsp</title>
<style type="text/css">
div {
word-spacing: 20px;
float: left;
border: solid;
clear: both;
text-rendering: optimizeLegibility;
white-space: nowrap;
position: relative;
overflow: hidden;
}
</style>
</head>
<body>
<p>Neither line below should wrap or expand outside the box</p>
<div>Should &nbsp;not wrap</div>
<div>Should &nbsp;not wrap</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test word-spacing and nbsp</title>
<style type="text/css">
div {
word-spacing: 20px;
float: left;
border: solid;
clear: both;
text-rendering: optimizeLegibility;
}
</style>
</head>
<body>
<p>Neither line below should wrap or expand outside the box</p>
<div>Should &nbsp;not wrap</div>
<div style="white-space: nowrap;">Should &nbsp;not wrap</div>
</body>
</html>
...@@ -602,7 +602,7 @@ static void normalizeCharacters(const TextRun& run, unsigned length, UChar* dest ...@@ -602,7 +602,7 @@ static void normalizeCharacters(const TextRun& run, unsigned length, UChar* dest
// Don't normalize tabs as they are not treated as spaces for word-end. // Don't normalize tabs as they are not treated as spaces for word-end.
if (run.normalizeSpace() && Character::isNormalizedCanvasSpaceCharacter(character)) if (run.normalizeSpace() && Character::isNormalizedCanvasSpaceCharacter(character))
character = spaceCharacter; character = spaceCharacter;
else if (Character::treatAsSpace(character)) else if (Character::treatAsSpace(character) && character != noBreakSpaceCharacter)
character = spaceCharacter; character = spaceCharacter;
else if (Character::treatAsZeroWidthSpaceInComplexScript(character)) else if (Character::treatAsZeroWidthSpaceInComplexScript(character))
character = zeroWidthSpaceCharacter; character = zeroWidthSpaceCharacter;
...@@ -1172,7 +1172,7 @@ float HarfBuzzShaper::adjustSpacing(ShapeResult::RunInfo* run, size_t glyphIndex ...@@ -1172,7 +1172,7 @@ float HarfBuzzShaper::adjustSpacing(ShapeResult::RunInfo* run, size_t glyphIndex
spacing += m_letterSpacing; spacing += m_letterSpacing;
bool treatAsSpace = Character::treatAsSpace(character); bool treatAsSpace = Character::treatAsSpace(character);
if (treatAsSpace && currentCharacterIndex && (character != '\t' || !m_textRun.allowTabs())) if (treatAsSpace && (currentCharacterIndex || character == noBreakSpaceCharacter) && (character != '\t' || !m_textRun.allowTabs()))
spacing += m_wordSpacingAdjustment; spacing += m_wordSpacingAdjustment;
if (!m_expansionOpportunityCount) if (!m_expansionOpportunityCount)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment