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

Issue 104813005: Explicitly set text direction for TextRuns (Closed)

Created:
6 years, 11 months ago by eae
Modified:
6 years, 11 months ago
CC:
blink-reviews, jamesr, krit, bemjb+rendering_chromium.org, dsinclair, zoltan1, eae+blinkwatch, leviw+renderwatch, jbroman, danakj, Rik, jchaffraix+rendering, Stephen Chennney, pdr., rwlbuis
Visibility:
Public.

Description

Explicitly set text direction for TextRuns Currently we do test measurement on TextRuns without directionality information, by assuming that it is left to right. For some scripts and character combinations the measurements are different in rtl and ltr. To handle that we currently have HarfBuzz guess the direction based on the script and content. This is unreliable and fails in many cases. With this patch the directionality information from the BidiResolver is plumbed through and used to correctly set the text direction thereby eliminating the need to for HarfBuzz to guess. This fixes a whole slew of subtle repainting and selection bidi bugs on all platforms using HarfBuzz for text shaping (win, linux, chromeos, android). * Source/core/rendering/InlineTextBox.cpp: Pass direction to RenderText::width method based on element directionality. * Source/core/rendering/RenderBR.h: Add TextDirection argument to overriden width method. * Source/core/rendering/RenderBlockFlow.cpp, Source/core/rendering/RenderBlockFlow.h: Add direction argument to constructTextRun method. * Source/core/rendering/RenderBlockLineLayout.cpp: Pass directionality to RenderText::width method based on bidi run direction. * Source/core/rendering/RenderCombineText.cpp, Source/core/rendering/RenderCombineText.h: Pass direction through. * Source/core/rendering/RenderText.cpp, Source/core/rendering/RenderText.h: (RenderText::widthFromCache): Add textDirection argument and pass it through to constructTextRun. (RenderText::trimmedPrefWidths): Assume LTR in trimmedPrefWidths for now, this matches the current behavior. (RenderText::computePreferredLogicalWidths): As preferred widths are computed before layout we do not yet have the bidi runs for the text (nor the line boxes). Use the BidiResolver to construct bidi runs for the entire text content and use the direction information for those runs when computing the width by passing it to widthFromCache. (RenderText::width): Change width methods to take a text direction argument. * Source/core/rendering/line/BreakingContextInlineHeaders.h: Add text direction argument to textWidth method and change the handleText method to pass the direction based on the BidiResolver. * Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp, Source/platform/fonts/harfbuzz/HarfBuzzShaper.h: (HarfBuzzShaper::shape): Remove tge shouldSetDirection logic as it is no longer needed (see shapeHarfBuzzRuns). (HarfBuzzShaper::shapeHarfBuzzRuns): Remove shouldSetDirection argument and always set the direction as the direction information is now avalible when calculating widths. * Source/platform/text/BidiResolver.h: (BidiResolver::createBidiRunsForLine): Add reorderRuns argument (defaults to true) to allow the reorder in visual order to be bypassed as the width calculation logic RenderText::computePreferredLogicalWidths requires the runs to be in logical order. R=eseidel@chromium.org, behdad@chromium.org, leviw@chromium.org BUG=327465 TEST=fast/text/international/mixed-directionality-selection.html Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=164788

Patch Set 1 #

Total comments: 3

Patch Set 2 : addressing leviws comments #

Patch Set 3 : Use BidiResolver in RenderText #

Total comments: 4

Patch Set 4 : Patch for landing #

Unified diffs Side-by-side diffs Delta from patch set Stats (+126 lines, -55 lines) Patch
M LayoutTests/TestExpectations View 1 2 3 1 chunk +24 lines, -0 lines 0 comments Download
A LayoutTests/fast/text/international/mixed-directionality-selection.html View 1 chunk +23 lines, -0 lines 0 comments Download
M Source/core/rendering/InlineTextBox.cpp View 1 2 5 chunks +5 lines, -5 lines 0 comments Download
M Source/core/rendering/RenderBR.h View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/rendering/RenderBlockFlow.h View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M Source/core/rendering/RenderBlockFlow.cpp View 1 2 3 2 chunks +10 lines, -4 lines 0 comments Download
M Source/core/rendering/RenderBlockLineLayout.cpp View 1 2 3 2 chunks +2 lines, -2 lines 0 comments Download
M Source/core/rendering/RenderCombineText.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M Source/core/rendering/RenderCombineText.cpp View 1 2 2 chunks +2 lines, -2 lines 0 comments Download
M Source/core/rendering/RenderText.h View 1 2 2 chunks +3 lines, -3 lines 0 comments Download
M Source/core/rendering/RenderText.cpp View 1 2 3 11 chunks +33 lines, -14 lines 0 comments Download
M Source/core/rendering/line/BreakingContextInlineHeaders.h View 5 chunks +10 lines, -8 lines 0 comments Download
M Source/platform/fonts/harfbuzz/HarfBuzzShaper.h View 1 chunk +1 line, -1 line 0 comments Download
M Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp View 3 chunks +3 lines, -9 lines 0 comments Download
M Source/platform/text/BidiResolver.h View 1 2 3 4 chunks +6 lines, -4 lines 0 comments Download

Messages

Total messages: 17 (0 generated)
eae
6 years, 11 months ago (2014-01-07 01:53:44 UTC) #1
leviw_travelin_and_unemployed
https://codereview.chromium.org/104813005/diff/1/Source/core/rendering/RenderBlockLineLayout.cpp File Source/core/rendering/RenderBlockLineLayout.cpp (right): https://codereview.chromium.org/104813005/diff/1/Source/core/rendering/RenderBlockLineLayout.cpp#newcode498 Source/core/rendering/RenderBlockLineLayout.cpp:498: measuredWidth += renderer->width(wordMeasurement.startOffset, wordLength, xPos, LTR, lineInfo.isFirstLine()); Why is ...
6 years, 11 months ago (2014-01-07 01:57:33 UTC) #2
behdad
lgtm
6 years, 11 months ago (2014-01-07 02:22:30 UTC) #3
eseidel
What's a "sleeve" of bugs?
6 years, 11 months ago (2014-01-07 02:50:47 UTC) #4
eseidel
lgtm https://codereview.chromium.org/104813005/diff/1/Source/core/rendering/InlineTextBox.cpp File Source/core/rendering/InlineTextBox.cpp (right): https://codereview.chromium.org/104813005/diff/1/Source/core/rendering/InlineTextBox.cpp#newcode310 Source/core/rendering/InlineTextBox.cpp:310: float widthOfVisibleText = toRenderText(renderer())->width(m_start, offset, textPos(), flowIsLTR ? ...
6 years, 11 months ago (2014-01-07 02:52:57 UTC) #5
eae
On Mon, Jan 6, 2014 at 6:50 PM, <eseidel@chromium.org> wrote: > What's a "sleeve" of ...
6 years, 11 months ago (2014-01-07 03:07:54 UTC) #6
eae
On 2014/01/07 02:52:57, eseidel wrote: > lgtm > > https://codereview.chromium.org/104813005/diff/1/Source/core/rendering/InlineTextBox.cpp > File Source/core/rendering/InlineTextBox.cpp (right): > ...
6 years, 11 months ago (2014-01-07 18:24:23 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/eae@chromium.org/104813005/190001
6 years, 11 months ago (2014-01-07 18:36:10 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/eae@chromium.org/104813005/290001
6 years, 11 months ago (2014-01-07 19:43:31 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/eae@chromium.org/104813005/410001
6 years, 11 months ago (2014-01-07 21:20:23 UTC) #10
commit-bot: I haz the power
Retried try job too often on linux_blink_rel for step(s) webkit_tests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=linux_blink_rel&number=16646
6 years, 11 months ago (2014-01-07 23:35:43 UTC) #11
leviw_travelin_and_unemployed
Typo 'oni' in description: "Pass directionality to RenderText::width method based oni bidi run direction." https://codereview.chromium.org/104813005/diff/670001/Source/core/rendering/RenderBlockLineLayout.cpp ...
6 years, 11 months ago (2014-01-09 00:49:53 UTC) #12
eae
On 2014/01/09 00:49:53, Levi wrote: > Typo 'oni' in description: "Pass directionality to RenderText::width method ...
6 years, 11 months ago (2014-01-09 01:06:24 UTC) #13
leviw_travelin_and_unemployed
On 2014/01/09 01:06:24, eae wrote: > On 2014/01/09 00:49:53, Levi wrote: > > Typo 'oni' ...
6 years, 11 months ago (2014-01-09 01:56:10 UTC) #14
leviw_travelin_and_unemployed
LGTM. I also award you the "Change description that looks most likely to be generated ...
6 years, 11 months ago (2014-01-09 02:45:45 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/eae@chromium.org/104813005/820001
6 years, 11 months ago (2014-01-09 15:40:32 UTC) #16
commit-bot: I haz the power
6 years, 11 months ago (2014-01-09 16:35:23 UTC) #17
Message was sent while issue was closed.
Change committed as 164788

Powered by Google App Engine
This is Rietveld 408576698