Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 0b4c3ab

Browse files
committed
Migrate UTF16ToWide as well
1 parent baa16c8 commit 0b4c3ab

File tree

5 files changed

+21
-31
lines changed

5 files changed

+21
-31
lines changed

fml/platform/win/wstring_conversion_unittests.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace fml {
1010
namespace testing {
1111

12-
TEST(StringConversion, Utf16ToWideStringEmpty) {
12+
TEST(StringConversion, Utf8ToWideStringEmpty) {
1313
EXPECT_EQ(Utf8ToWideString(""), L"");
1414
}
1515

third_party/accessibility/ax/platform/ax_platform_node_textrangeprovider_win.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ HRESULT AXPlatformNodeTextRangeProviderWin::GetText(int max_count, BSTR* text) {
704704
if (max_count < -1)
705705
return E_INVALIDARG;
706706

707-
std::wstring full_text = base::UTF16ToWide(GetString(max_count));
707+
std::wstring full_text = fml::Utf16ToWideString(GetString(max_count));
708708
if (!full_text.empty()) {
709709
size_t length = full_text.length();
710710

third_party/accessibility/ax/platform/ax_platform_node_win.cc

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ IFACEMETHODIMP AXPlatformNodeWin::get_accDefaultAction(VARIANT var_id,
964964
return S_FALSE;
965965
}
966966

967-
*def_action = ::SysAllocString(base::UTF16ToWide(action_verb).c_str());
967+
*def_action = ::SysAllocString(fml::Utf16ToWideString(action_verb).c_str());
968968
BASE_DCHECK(def_action);
969969
return S_OK;
970970
}
@@ -1055,7 +1055,7 @@ IFACEMETHODIMP AXPlatformNodeWin::get_accName(VARIANT var_id, BSTR* name_bstr) {
10551055
if (name.empty() && !has_name)
10561056
return S_FALSE;
10571057

1058-
*name_bstr = ::SysAllocString(base::UTF16ToWide(name).c_str());
1058+
*name_bstr = ::SysAllocString(fml::Utf16ToWideString(name).c_str());
10591059
return S_OK;
10601060
}
10611061

@@ -2123,20 +2123,20 @@ HRESULT AXPlatformNodeWin::GetPropertyValueImpl(PROPERTYID property_id,
21232123
switch (property_id) {
21242124
case UIA_AriaPropertiesPropertyId:
21252125
result->vt = VT_BSTR;
2126-
result->bstrVal =
2127-
::SysAllocString(base::UTF16ToWide(ComputeUIAProperties()).c_str());
2126+
result->bstrVal = ::SysAllocString(
2127+
fml::Utf16ToWideString(ComputeUIAProperties()).c_str());
21282128
break;
21292129

21302130
case UIA_AriaRolePropertyId:
21312131
result->vt = VT_BSTR;
21322132
result->bstrVal =
2133-
::SysAllocString(base::UTF16ToWide(UIAAriaRole()).c_str());
2133+
::SysAllocString(fml::Utf16ToWideString(UIAAriaRole()).c_str());
21342134
break;
21352135

21362136
case UIA_AutomationIdPropertyId:
21372137
V_VT(result) = VT_BSTR;
21382138
V_BSTR(result) = ::SysAllocString(
2139-
base::UTF16ToWide(GetDelegate()->GetAuthorUniqueId()).c_str());
2139+
fml::Utf16ToWideString(GetDelegate()->GetAuthorUniqueId()).c_str());
21402140
break;
21412141

21422142
case UIA_ClassNamePropertyId:
@@ -2305,8 +2305,8 @@ HRESULT AXPlatformNodeWin::GetPropertyValueImpl(PROPERTYID property_id,
23052305
std::u16string localized_control_type = GetRoleDescription();
23062306
if (!localized_control_type.empty()) {
23072307
result->vt = VT_BSTR;
2308-
result->bstrVal =
2309-
::SysAllocString(base::UTF16ToWide(localized_control_type).c_str());
2308+
result->bstrVal = ::SysAllocString(
2309+
fml::Utf16ToWideString(localized_control_type).c_str());
23102310
}
23112311
// If a role description has not been provided, leave as VT_EMPTY.
23122312
// UIA core handles Localized Control type for some built-in types and
@@ -2457,7 +2457,7 @@ HRESULT AXPlatformNodeWin::GetPropertyValueImpl(PROPERTYID property_id,
24572457
if (!localized_landmark_type.empty()) {
24582458
result->vt = VT_BSTR;
24592459
result->bstrVal = ::SysAllocString(
2460-
base::UTF16ToWide(localized_landmark_type).c_str());
2460+
fml::Utf16ToWideString(localized_landmark_type).c_str());
24612461
}
24622462
break;
24632463
}
@@ -2516,7 +2516,7 @@ HRESULT AXPlatformNodeWin::GetPropertyValueImpl(PROPERTYID property_id,
25162516
// convention here and when we fire events via ::NotifyWinEvent().
25172517
result->vt = VT_BSTR;
25182518
result->bstrVal = ::SysAllocString(
2519-
base::UTF16ToWide(base::NumberToString16(-GetUniqueId())).c_str());
2519+
fml::Utf16ToWideString(base::NumberToString16(-GetUniqueId())).c_str());
25202520
}
25212521

25222522
return S_OK;
@@ -5305,7 +5305,7 @@ BSTR AXPlatformNodeWin::GetValueAttributeAsBstr(AXPlatformNodeWin* target) {
53055305
value_text = base::NumberToString16(red * 100 / 255) + u"% red " +
53065306
base::NumberToString16(green * 100 / 255) + u"% green " +
53075307
base::NumberToString16(blue * 100 / 255) + u"% blue";
5308-
BSTR value = ::SysAllocString(base::UTF16ToWide(value_text).c_str());
5308+
BSTR value = ::SysAllocString(fml::Utf16ToWideString(value_text).c_str());
53095309
BASE_DCHECK(value);
53105310
return value;
53115311
}
@@ -5316,7 +5316,7 @@ BSTR AXPlatformNodeWin::GetValueAttributeAsBstr(AXPlatformNodeWin* target) {
53165316
if (target->GetData().role == ax::mojom::Role::kRootWebArea ||
53175317
target->GetData().role == ax::mojom::Role::kWebArea) {
53185318
result = base::UTF8ToUTF16(target->GetDelegate()->GetTreeData().url);
5319-
BSTR value = ::SysAllocString(base::UTF16ToWide(result).c_str());
5319+
BSTR value = ::SysAllocString(fml::Utf16ToWideString(result).c_str());
53205320
BASE_DCHECK(value);
53215321
return value;
53225322
}
@@ -5326,7 +5326,7 @@ BSTR AXPlatformNodeWin::GetValueAttributeAsBstr(AXPlatformNodeWin* target) {
53265326
//
53275327
if (target->GetData().role == ax::mojom::Role::kLink) {
53285328
result = target->GetString16Attribute(ax::mojom::StringAttribute::kUrl);
5329-
BSTR value = ::SysAllocString(base::UTF16ToWide(result).c_str());
5329+
BSTR value = ::SysAllocString(fml::Utf16ToWideString(result).c_str());
53305330
BASE_DCHECK(value);
53315331
return value;
53325332
}
@@ -5341,7 +5341,7 @@ BSTR AXPlatformNodeWin::GetValueAttributeAsBstr(AXPlatformNodeWin* target) {
53415341
if (target->GetFloatAttribute(ax::mojom::FloatAttribute::kValueForRange,
53425342
&fval)) {
53435343
result = base::NumberToString16(fval);
5344-
BSTR value = ::SysAllocString(base::UTF16ToWide(result).c_str());
5344+
BSTR value = ::SysAllocString(fml::Utf16ToWideString(result).c_str());
53455345
BASE_DCHECK(value);
53465346
return value;
53475347
}
@@ -5350,7 +5350,7 @@ BSTR AXPlatformNodeWin::GetValueAttributeAsBstr(AXPlatformNodeWin* target) {
53505350
if (result.empty() && target->IsRichTextField())
53515351
result = target->GetInnerText();
53525352

5353-
BSTR value = ::SysAllocString(base::UTF16ToWide(result).c_str());
5353+
BSTR value = ::SysAllocString(fml::Utf16ToWideString(result).c_str());
53545354
BASE_DCHECK(value);
53555355
return value;
53565356
}
@@ -5363,15 +5363,15 @@ HRESULT AXPlatformNodeWin::GetStringAttributeAsBstr(
53635363
if (!GetString16Attribute(attribute, &str))
53645364
return S_FALSE;
53655365

5366-
*value_bstr = ::SysAllocString(base::UTF16ToWide(str).c_str());
5366+
*value_bstr = ::SysAllocString(fml::Utf16ToWideString(str).c_str());
53675367
BASE_DCHECK(*value_bstr);
53685368

53695369
return S_OK;
53705370
}
53715371

53725372
HRESULT AXPlatformNodeWin::GetNameAsBstr(BSTR* value_bstr) const {
53735373
std::u16string str = GetNameAsString16();
5374-
*value_bstr = ::SysAllocString(base::UTF16ToWide(str).c_str());
5374+
*value_bstr = ::SysAllocString(fml::Utf16ToWideString(str).c_str());
53755375
BASE_DCHECK(*value_bstr);
53765376
return S_OK;
53775377
}
@@ -5481,14 +5481,14 @@ BSTR AXPlatformNodeWin::GetFontNameAttributeAsBSTR() const {
54815481
const std::u16string string =
54825482
GetInheritedString16Attribute(ax::mojom::StringAttribute::kFontFamily);
54835483

5484-
return ::SysAllocString(base::UTF16ToWide(string).c_str());
5484+
return ::SysAllocString(fml::Utf16ToWideString(string).c_str());
54855485
}
54865486

54875487
BSTR AXPlatformNodeWin::GetStyleNameAttributeAsBSTR() const {
54885488
std::u16string style_name =
54895489
GetDelegate()->GetStyleNameAttributeAsLocalizedString();
54905490

5491-
return ::SysAllocString(base::UTF16ToWide(style_name).c_str());
5491+
return ::SysAllocString(fml::Utf16ToWideString(style_name).c_str());
54925492
}
54935493

54945494
TextDecorationLineStyle AXPlatformNodeWin::GetUIATextDecorationStyle(

third_party/accessibility/base/string_utils.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,6 @@ std::string UTF16ToUTF8(std::u16string src) {
7272
return fml::Utf16ToUtf8(src);
7373
}
7474

75-
std::u16string WideToUTF16(const std::wstring& src) {
76-
return std::u16string(src.begin(), src.end());
77-
}
78-
79-
std::wstring UTF16ToWide(const std::u16string& src) {
80-
return std::wstring(src.begin(), src.end());
81-
}
82-
8375
std::u16string NumberToString16(float number) {
8476
return ASCIIToUTF16(NumberToString(number));
8577
}

third_party/accessibility/base/string_utils.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ std::string StringPrintf(const std::string& format, Args... args) {
2626
std::u16string ASCIIToUTF16(std::string src);
2727
std::u16string UTF8ToUTF16(std::string src);
2828
std::string UTF16ToUTF8(std::u16string src);
29-
std::u16string WideToUTF16(const std::wstring& src);
30-
std::wstring UTF16ToWide(const std::u16string& src);
3129

3230
std::u16string NumberToString16(unsigned int number);
3331
std::u16string NumberToString16(int32_t number);

0 commit comments

Comments
 (0)