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

Side by Side Diff: content/child/dwrite_font_proxy/dwrite_localized_strings_win.cc

Issue 1507063004: Revert "Create direct write font proxy classes and unit tests." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/child/dwrite_font_proxy/dwrite_localized_strings_win.h"
6
7 #include "base/logging.h"
8
9 namespace content {
10
11 DWriteLocalizedStrings::~DWriteLocalizedStrings() {}
12
13 HRESULT DWriteLocalizedStrings::FindLocaleName(const WCHAR* locale_name,
14 UINT32* index,
15 BOOL* exists) {
16 for (size_t n = 0; n < strings_.size(); ++n) {
17 if (_wcsicmp(strings_[n].first.data(), locale_name) == 0) {
18 *index = n;
19 *exists = TRUE;
20 return S_OK;
21 }
22 }
23
24 *index = UINT_MAX;
25 *exists = FALSE;
26 return S_OK;
27 }
28
29 UINT32 DWriteLocalizedStrings::GetCount() {
30 return strings_.size();
31 }
32
33 HRESULT DWriteLocalizedStrings::GetLocaleName(UINT32 index,
34 WCHAR* locale_name,
35 UINT32 size) {
36 if (index >= strings_.size())
37 return E_INVALIDARG;
38 // string16::size does not count the null terminator as part of the string,
39 // but GetLocaleName requires the caller to reserve space for the null
40 // terminator, so we need to ensure |size| is greater than the count of
41 // characters.
42 if (size <= strings_[index].first.size())
43 return E_INVALIDARG;
44 wcsncpy(locale_name, strings_[index].first.c_str(), size);
45 return S_OK;
46 }
47
48 HRESULT DWriteLocalizedStrings::GetLocaleNameLength(UINT32 index,
49 UINT32* length) {
50 if (index >= strings_.size())
51 return E_INVALIDARG;
52 // Oddly, GetLocaleNameLength requires the length to not count the null
53 // terminator, even though GetLocaleName requires the output to be null
54 // terminated.
55 *length = strings_[index].first.size();
56 return S_OK;
57 }
58
59 HRESULT DWriteLocalizedStrings::GetString(UINT32 index,
60 WCHAR* string_buffer,
61 UINT32 size) {
62 if (index >= strings_.size())
63 return E_INVALIDARG;
64 // string16::size does not count the null terminator as part of the string,
65 // but GetString requires the caller to reserve space for the null terminator,
66 // so we need to ensure |size| is greater than the count of characters.
67 if (size <= strings_[index].second.size())
68 return E_INVALIDARG;
69 wcsncpy(string_buffer, strings_[index].second.c_str(), size);
70 return S_OK;
71 }
72
73 HRESULT DWriteLocalizedStrings::GetStringLength(UINT32 index, UINT32* length) {
74 if (index >= strings_.size())
75 return E_INVALIDARG;
76 // Oddly, GetStringLength requires the length to not count the null
77 // terminator, even though GetString requires the output to be null
78 // terminated.
79 *length = strings_[index].second.size();
80 return S_OK;
81 }
82
83 HRESULT DWriteLocalizedStrings::RuntimeClassInitialize(
84 std::vector<std::pair<base::string16, base::string16>>* strings) {
85 strings_.swap(*strings);
86 return S_OK;
87 }
88
89 } // namespace content
OLDNEW
« no previous file with comments | « content/child/dwrite_font_proxy/dwrite_localized_strings_win.h ('k') | content/common/content_message_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698