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

Unified Diff: ui/gfx/render_text_harfbuzz.cc

Issue 2853523002: [rendertext,i18n] Added flag to force RTL rendering (Closed)
Patch Set: Corrected ordering and text, added cached look-ups Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« chrome/browser/flag_descriptions.h ('K') | « ui/gfx/render_text_harfbuzz.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« chrome/browser/flag_descriptions.h ('K') | « ui/gfx/render_text_harfbuzz.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698