Chromium Code Reviews| Index: ui/gfx/render_text_harfbuzz.cc |
| diff --git a/ui/gfx/render_text_harfbuzz.cc b/ui/gfx/render_text_harfbuzz.cc |
| index 042986f882721ba5c7876a7342d650335558d941..5de3cd6aa1257a54774754e5b5455f639c4efebc 100644 |
| --- a/ui/gfx/render_text_harfbuzz.cc |
| +++ b/ui/gfx/render_text_harfbuzz.cc |
| @@ -7,6 +7,8 @@ |
| #include <limits> |
| #include <set> |
| +#include "base/command_line.h" |
| +#include "base/i18n/base_i18n_switches.h" |
| #include "base/i18n/bidi_line_iterator.h" |
| #include "base/i18n/break_iterator.h" |
| #include "base/i18n/char_iterator.h" |
| @@ -1339,6 +1341,19 @@ SelectionModel RenderTextHarfBuzz::LastSelectionModelInsideRun( |
| return SelectionModel(position, CURSOR_FORWARD); |
| } |
| +void RenderTextHarfBuzz::CheckForcedDirection(UBiDiLevel* level) { |
| + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| + if (command_line->HasSwitch(switches::kForceTextDirection)) { |
| + std::string force_flag = |
| + command_line->GetSwitchValueASCII(switches::kForceTextDirection); |
| + |
| + if (force_flag == switches::kForceUIDirectionRTL) |
| + *level = UBIDI_RTL; |
| + if (force_flag == switches::kForceUIDirectionLTR) |
| + *level = UBIDI_LTR; |
| + } |
| +} |
| + |
| void RenderTextHarfBuzz::ItemizeTextToRuns( |
| const base::string16& text, |
| internal::TextRunList* run_list_out) { |
| @@ -1382,6 +1397,7 @@ void RenderTextHarfBuzz::ItemizeTextToRuns( |
| int32_t script_item_break = 0; |
| bidi_iterator.GetLogicalRun(run_break, &script_item_break, &run->level); |
| CHECK_GT(static_cast<size_t>(script_item_break), run_break); |
| + CheckForcedDirection(&run->level); |
|
msw
2017/04/28 22:04:03
I'm not sure this is needed; doesn't the underlyin
Kevin Bailey
2017/04/29 04:24:03
'GetTextDirection()' is returning RTL, but, when t
msw
2017/05/01 20:56:18
Acknowledged.
|
| // Odd BiDi embedding levels correspond to RTL runs. |
| run->is_rtl = (run->level % 2) == 1; |
| // Find the length and script of this script run. |