Word spacing in RTL for segments

Removed m_stop and length comparison as they carry different units i.e. if there are two char text then m_stop will be 1 and length 2. As do not compare, needWordSpace does not set correct value.  

Also by default condition for needSpacing has been changed to true because if first character is space it was getting omitted. 

BUG=344873
R=leviw, eae
TEST=Word spacing in RTL with different segments handling.

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

git-svn-id: svn://svn.chromium.org/blink/trunk@176416 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 343109bd
......@@ -79,6 +79,9 @@ crbug.com/310679 [ Mac ] fast/events/scale-and-scroll-iframe-window.html [ Image
crbug.com/310679 [ Mac ] fast/frames/frame-set-rotation-hit.html [ Failure ImageOnlyFailure Pass ]
crbug.com/310679 [ Mac ] fast/frames/frame-set-scaling-hit.html [ Failure ImageOnlyFailure Pass ]
crbug.com/344873 fast/text/international/bidi-word-spacing-rtl.html [ NeedsRebaseline ]
crbug.com/344873 virtual/antialiasedtext/fast/text/international/bidi-word-spacing-rtl.html [ NeedsRebaseline ]
# Tests failing since applyPageScaleFactorInCompositor enabled
crbug.com/225184 fast/repaint/relayout-fixed-position-after-scale.html [ ImageOnlyFailure ]
......
<!DOCTYPE html>
<style>
body {
font-size: 40px;
}
div {
margin: 10px 300px;
border: thin solid black;
}
</style>
<div dir="rtl">!<span style="word-spacing:100px" dir="rtl"> @</span> </div>
<div dir="rtl">!<span style="word-spacing:100px"> </span>@ </div>
<div dir="rtl"><span style="word-spacing:100px">! </span>@ </div>
<div dir="rtl">!<span style="word-spacing:100px"> </span>@ &rlm;</div>
<div dir="rtl">!<span style="word-spacing:100px"> </span>@</div>
<div dir="ltr" style="text-align:right">@<span style="word-spacing:100px"> </span>! </div>
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x370
RenderBlock {HTML} at (0,0) size 800x370
RenderBody {BODY} at (8,10) size 784x350
RenderBlock {DIV} at (300,0) size 184x50 [border: (1px solid #000000)]
RenderText {#text} at (72,2) size 11x46
text run at (72,2) width 11 RTL: "!"
RenderInline {SPAN} at (0,0) size 47x46
RenderText {#text} at (25,2) size 47x46
text run at (25,2) width 47 RTL: " @"
RenderText {#text} at (0,0) size 0x0
RenderBlock {DIV} at (300,60) size 184x50 [border: (1px solid #000000)]
RenderText {#text} at (172,2) size 11x46
text run at (172,2) width 11 RTL: "!"
RenderInline {SPAN} at (0,0) size 110x46
RenderText {#text} at (162,2) size 10x46
text run at (162,2) width 10 RTL: " "
RenderText {#text} at (25,2) size 37x46
text run at (25,2) width 37 RTL: "@"
RenderBlock {DIV} at (300,120) size 184x50 [border: (1px solid #000000)]
RenderInline {SPAN} at (0,0) size 121x46
RenderText {#text} at (62,2) size 121x46
text run at (62,2) width 121 RTL: "! "
RenderText {#text} at (25,2) size 37x46
text run at (25,2) width 37 RTL: "@"
RenderBlock {DIV} at (300,180) size 184x50 [border: (1px solid #000000)]
RenderText {#text} at (172,2) size 11x46
text run at (172,2) width 11 RTL: "!"
RenderInline {SPAN} at (0,0) size 110x46
RenderText {#text} at (162,2) size 10x46
text run at (162,2) width 10 RTL: " "
RenderText {#text} at (15,2) size 47x46
text run at (15,2) width 47 RTL: "@ \x{200F}"
RenderBlock {DIV} at (300,240) size 184x50 [border: (1px solid #000000)]
RenderText {#text} at (172,2) size 11x46
text run at (172,2) width 11 RTL: "!"
RenderInline {SPAN} at (0,0) size 110x46
RenderText {#text} at (162,2) size 10x46
text run at (162,2) width 10 RTL: " "
RenderText {#text} at (25,2) size 37x46
text run at (25,2) width 37 RTL: "@"
RenderBlock {DIV} at (300,300) size 184x50 [border: (1px solid #000000)]
RenderText {#text} at (25,2) size 37x46
text run at (25,2) width 37: "@"
RenderInline {SPAN} at (0,0) size 110x46
RenderText {#text} at (162,2) size 10x46
text run at (162,2) width 10: " "
RenderText {#text} at (172,2) size 11x46
text run at (172,2) width 11: "!"
......@@ -626,7 +626,7 @@ BidiRun* RenderBlockFlow::computeInlineDirectionPositionsForSegment(RootInlineBo
float& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingSpaceRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& verticalPositionCache,
WordMeasurements& wordMeasurements)
{
bool needsWordSpacing = false;
bool needsWordSpacing = true;
float totalLogicalWidth = lineBox->getFlowSpacingLogicalWidth().toFloat();
unsigned expansionOpportunityCount = 0;
bool isAfterExpansion = true;
......@@ -654,10 +654,10 @@ BidiRun* RenderBlockFlow::computeInlineDirectionPositionsForSegment(RootInlineBo
expansionOpportunityCount += opportunitiesInRun;
}
if (int length = rt->textLength()) {
if (rt->textLength()) {
if (!r->m_start && needsWordSpacing && isSpaceOrNewline(rt->characterAt(r->m_start)))
totalLogicalWidth += rt->style(lineInfo.isFirstLine())->font().fontDescription().wordSpacing();
needsWordSpacing = !isSpaceOrNewline(rt->characterAt(r->m_stop - 1)) && r->m_stop == length;
needsWordSpacing = !isSpaceOrNewline(rt->characterAt(r->m_stop - 1));
}
setLogicalWidthForTextRun(lineBox, r, rt, totalLogicalWidth, lineInfo, textBoxDataMap, verticalPositionCache, wordMeasurements);
......
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