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

Unified Diff: charted/lib/core/utils/bidi_formatter.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « charted/lib/core/utils.dart ('k') | charted/lib/core/utils/color.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: charted/lib/core/utils/bidi_formatter.dart
diff --git a/charted/lib/core/utils/bidi_formatter.dart b/charted/lib/core/utils/bidi_formatter.dart
deleted file mode 100644
index 8b729ffc37ca3ecb35e2888c273be69991ae34a5..0000000000000000000000000000000000000000
--- a/charted/lib/core/utils/bidi_formatter.dart
+++ /dev/null
@@ -1,56 +0,0 @@
-//
-// Copyright 2014 Google Inc. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file or at
-// https://developers.google.com/open-source/licenses/bsd
-//
-
-part of charted.core.utils;
-
-/// Charts are always drawn with LTR context.
-BidiFormatter _bidiFormatter = new BidiFormatter.LTR();
-
-/// Fix direction of HTML using <span dir="..."> for RTL when required
-fixMarkupDirection(String markup) =>
- _bidiFormatter.wrapWithSpan(markup, isHtml:true);
-
-/// Fix direction of text using unicode markers for RTL when required
-/// This is a simplified version of BidiFormatter.wrapWithUnicode that
-/// is meant to be used for small labels only (Eg: axis ticks).
-String fixSimpleTextDirection(String text) {
- TextDirection direction = estimateDirectionOfSimpleText(text);
- if (TextDirection.RTL == direction) {
- var marker = direction == TextDirection.RTL ? Bidi.RLE : Bidi.LRE;
- return "${marker}$text${Bidi.PDF}";
- }
- return text;
-}
-
-/// Estimates direction of simple text.
-/// This is a simplified version of Bidi.estimateDirectionOfText
-var _spaceRegExp = new RegExp(r'\s+');
-var _digitsRegExp = new RegExp(r'\d');
-TextDirection estimateDirectionOfSimpleText(String text) {
- var rtlCount = 0,
- total = 0,
- hasWeaklyLtr = false,
- tokens = text.split(_spaceRegExp);
-
- for (int i = 0, len = tokens.length; i < len; ++i) {
- var token = tokens.elementAt(i);
- if (Bidi.startsWithRtl(token)) {
- rtlCount++;
- total++;
- } else if (Bidi.hasAnyLtr(token)) {
- total++;
- } else if (_digitsRegExp.hasMatch(token)) {
- hasWeaklyLtr = true;
- }
- }
- if (total == 0) {
- return hasWeaklyLtr ? TextDirection.LTR : TextDirection.UNKNOWN;
- } else {
- return rtlCount > 0.4 * total ? TextDirection.RTL : TextDirection.LTR;
- }
-}
« no previous file with comments | « charted/lib/core/utils.dart ('k') | charted/lib/core/utils/color.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698