Skip to content

Commit 2b96c20

Browse files
committed
[a11y] Revert "Accessibility number formatting improvements for Windows"
1 parent c13a0c5 commit 2b96c20

File tree

1 file changed

+6
-46
lines changed

1 file changed

+6
-46
lines changed

flutter/third_party/accessibility/base/string_utils.cc

+6-46
Original file line numberDiff line numberDiff line change
@@ -5,64 +5,20 @@
55
#include "string_utils.h"
66

77
#include <algorithm>
8-
#include <array>
98
#include <cctype>
109
#include <codecvt>
1110
#include <locale>
1211
#include <regex>
1312
#include <sstream>
1413

1514
#include "flutter/fml/string_conversion.h"
16-
#include "third_party/dart/runtime/third_party/double-conversion/src/double-conversion.h"
1715

1816
#include "base/logging.h"
1917
#include "icu_utf.h"
2018
#include "no_destructor.h"
2119

2220
namespace base {
2321

24-
using double_conversion::DoubleToStringConverter;
25-
using double_conversion::StringBuilder;
26-
27-
namespace {
28-
constexpr char kExponentChar = 'e';
29-
constexpr char kInfinitySymbol[] = "Infinity";
30-
constexpr char kNaNSymbol[] = "NaN";
31-
32-
// The number of digits after the decimal we allow before switching to
33-
// exponential representation.
34-
constexpr int kDecimalInShortestLow = -6;
35-
// The number of digits before the decimal we allow before switching to
36-
// exponential representation.
37-
constexpr int kDecimalInShortestHigh = 12;
38-
constexpr int kConversionFlags =
39-
DoubleToStringConverter::EMIT_POSITIVE_EXPONENT_SIGN;
40-
41-
const DoubleToStringConverter& GetDoubleToStringConverter() {
42-
static DoubleToStringConverter converter(
43-
kConversionFlags, kInfinitySymbol, kNaNSymbol, kExponentChar,
44-
kDecimalInShortestLow, kDecimalInShortestHigh, 0, 0);
45-
return converter;
46-
}
47-
48-
std::string NumberToStringImpl(double number, bool is_single_precision) {
49-
if (number == 0.0) {
50-
return "0";
51-
}
52-
53-
constexpr int kBufferSize = 128;
54-
std::array<char, kBufferSize> char_buffer;
55-
StringBuilder builder(char_buffer.data(), char_buffer.size());
56-
if (is_single_precision) {
57-
GetDoubleToStringConverter().ToShortestSingle(static_cast<float>(number),
58-
&builder);
59-
} else {
60-
GetDoubleToStringConverter().ToShortest(number, &builder);
61-
}
62-
return std::string(char_buffer.data(), builder.position());
63-
}
64-
} // namespace
65-
6622
std::u16string ASCIIToUTF16(std::string src) {
6723
return std::u16string(src.begin(), src.end());
6824
}
@@ -108,11 +64,15 @@ std::string NumberToString(unsigned int number) {
10864
}
10965

11066
std::string NumberToString(float number) {
111-
return NumberToStringImpl(number, true);
67+
// TODO(gw280): Format decimals to the shortest reasonable representation.
68+
// See: https://github.com/flutter/flutter/issues/78460
69+
return std::to_string(number);
11270
}
11371

11472
std::string NumberToString(double number) {
115-
return NumberToStringImpl(number, false);
73+
// TODO(gw280): Format decimals to the shortest reasonable representation.
74+
// See: https://github.com/flutter/flutter/issues/78460
75+
return std::to_string(number);
11676
}
11777

11878
std::string NumberToString(int64_t number) {

0 commit comments

Comments
 (0)