Commit 64b07866 authored by eae@chromium.org's avatar eae@chromium.org

Init BidiResolver with Neutral directionality in RenderText

Set the initial directionality to Neutral in
RenderText::computePreferredLogicalWidths. This ensures that leading and
trailing SCRIPT_COMMON characters gets the correct directionality and
thus the correct width.

TEST=fast/text/international/rtl-space-in-ltr-element.html
BUG=333004
R=leviw@chromium.org

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

git-svn-id: svn://svn.chromium.org/blink/trunk@168339 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c2b99220
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
div { font-size: 64px; display: inline-block; border: 1px solid red; }
</style>
</head>
<body>
<div dir="rtl"><span>نه</span> با</div>
<div dir="rtl"><span>نه</span> با</div>
<p>
The two blocks above should be identical.
</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
div { font-size: 64px; display: inline-block; border: 1px solid red; }
</style>
</head>
<body>
<div dir="ltr"><span>نه</span> با</div>
<div dir="rtl"><span>نه</span> با</div>
<p>
The two blocks above should be identical.
</p>
</body>
</html>
......@@ -937,9 +937,10 @@ void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
bool breakAll = (styleToUse->wordBreak() == BreakAllWordBreak || styleToUse->wordBreak() == BreakWordBreak) && styleToUse->autoWrap();
TextRun textRun(text());
textRun.setDirection(textDirection);
BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver;
bidiResolver.setStatus(BidiStatus(textRun.direction(), textRun.directionalOverride()));
BidiStatus status(LTR, false);
status.last = status.lastStrong = WTF::Unicode::OtherNeutral;
bidiResolver.setStatus(status);
bidiResolver.setPositionIgnoringNestedIsolates(TextRunIterator(&textRun, 0));
bool hardLineBreak = false;
bool reorderRuns = false;
......@@ -950,11 +951,14 @@ void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si
for (int i = 0; i < len; i++) {
UChar c = uncheckedCharacterAt(i);
while (i > run->stop())
// Treat adjacent runs with the same resolved directionality
// (TextDirection as opposed to WTF::Unicode::Direction) as belonging
// to the same run to avoid breaking unnecessarily.
while (i > run->stop() || (run->next() && run->next()->direction() == run->direction()))
run = run->next();
ASSERT(run);
ASSERT(i >= run->start() && i <= run->stop());
ASSERT(i <= run->stop());
TextDirection textDirection = run->direction();
bool previousCharacterIsSpace = isSpace;
......
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