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..4f2a9ee3c9b9f27a292e482c14f4a79d3b07752a 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" |
@@ -606,6 +608,12 @@ struct CaseInsensitiveCompare { |
} |
}; |
+bool HasForcedTextDirectionSwitch() { |
msw
2017/05/01 20:56:18
ditto nit: "// Get the cached switch presence; avo
Kevin Bailey
2017/05/01 21:21:42
Done. Again, absorbed code.
|
+ static bool value = base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kForceTextDirection); |
+ return value; |
+} |
+ |
} // namespace |
namespace internal { |
@@ -1339,6 +1347,22 @@ SelectionModel RenderTextHarfBuzz::LastSelectionModelInsideRun( |
return SelectionModel(position, CURSOR_FORWARD); |
} |
+void RenderTextHarfBuzz::CheckForcedDirection(UBiDiLevel* level) { |
msw
2017/05/01 20:56:18
nit: "// Applies a forced direction if specified b
Kevin Bailey
2017/05/01 21:21:42
Done.
|
+ if (!HasForcedTextDirectionSwitch()) |
+ return; |
+ |
+ 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::kForceDirectionRTL) |
+ *level = UBIDI_RTL; |
+ if (force_flag == switches::kForceDirectionLTR) |
+ *level = UBIDI_LTR; |
+ } |
+} |
+ |
void RenderTextHarfBuzz::ItemizeTextToRuns( |
const base::string16& text, |
internal::TextRunList* run_list_out) { |
@@ -1382,6 +1406,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); |
// Odd BiDi embedding levels correspond to RTL runs. |
run->is_rtl = (run->level % 2) == 1; |
// Find the length and script of this script run. |