OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/test/dwrite_font_fake_sender_win.h" | 5 #include "content/test/dwrite_font_fake_sender_win.h" |
6 | 6 |
| 7 #include <dwrite.h> |
7 #include <shlobj.h> | 8 #include <shlobj.h> |
8 | 9 |
9 #include "content/common/dwrite_font_proxy_messages.h" | 10 #include "content/common/dwrite_font_proxy_messages.h" |
10 | 11 |
11 namespace content { | 12 namespace content { |
12 | 13 |
13 void AddFamily(const base::string16& font_path, | 14 void AddFamily(const base::string16& font_path, |
14 const base::string16& family_name, | 15 const base::string16& family_name, |
15 const base::string16& base_family_name, | 16 const base::string16& base_family_name, |
16 FakeFontCollection* collection) { | 17 FakeFontCollection* collection) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 71 |
71 std::unique_ptr<IPC::Message>& | 72 std::unique_ptr<IPC::Message>& |
72 FakeFontCollection::ReplySender::OnMessageReceived(const IPC::Message& msg) { | 73 FakeFontCollection::ReplySender::OnMessageReceived(const IPC::Message& msg) { |
73 reply_.reset(); | 74 reply_.reset(); |
74 bool handled = true; | 75 bool handled = true; |
75 IPC_BEGIN_MESSAGE_MAP(ReplySender, msg) | 76 IPC_BEGIN_MESSAGE_MAP(ReplySender, msg) |
76 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_FindFamily, OnFindFamily) | 77 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_FindFamily, OnFindFamily) |
77 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFamilyCount, OnGetFamilyCount) | 78 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFamilyCount, OnGetFamilyCount) |
78 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFamilyNames, OnGetFamilyNames) | 79 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFamilyNames, OnGetFamilyNames) |
79 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFontFiles, OnGetFontFiles) | 80 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFontFiles, OnGetFontFiles) |
| 81 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_MapCharacters, OnMapCharacters) |
80 IPC_MESSAGE_UNHANDLED(handled = false) | 82 IPC_MESSAGE_UNHANDLED(handled = false) |
81 IPC_END_MESSAGE_MAP() | 83 IPC_END_MESSAGE_MAP() |
82 return reply_; | 84 return reply_; |
83 } | 85 } |
84 | 86 |
85 bool FakeFontCollection::ReplySender::Send(IPC::Message* msg) { | 87 bool FakeFontCollection::ReplySender::Send(IPC::Message* msg) { |
86 reply_.reset(msg); | 88 reply_.reset(msg); |
87 return true; | 89 return true; |
88 } | 90 } |
89 | 91 |
(...skipping 12 matching lines...) Expand all Loading... |
102 std::vector<DWriteStringPair>* family_names) { | 104 std::vector<DWriteStringPair>* family_names) { |
103 collection_->OnGetFamilyNames(family_index, family_names); | 105 collection_->OnGetFamilyNames(family_index, family_names); |
104 } | 106 } |
105 | 107 |
106 void FakeFontCollection::ReplySender::OnGetFontFiles( | 108 void FakeFontCollection::ReplySender::OnGetFontFiles( |
107 uint32_t family_index, | 109 uint32_t family_index, |
108 std::vector<base::string16>* file_paths) { | 110 std::vector<base::string16>* file_paths) { |
109 collection_->OnGetFontFiles(family_index, file_paths); | 111 collection_->OnGetFontFiles(family_index, file_paths); |
110 } | 112 } |
111 | 113 |
| 114 void FakeFontCollection::ReplySender::OnMapCharacters( |
| 115 const base::string16& text, |
| 116 const DWriteFontStyle& font_style, |
| 117 const base::string16& locale_name, |
| 118 uint32_t reading_direction, |
| 119 const base::string16& base_family_name, |
| 120 MapCharactersResult* result) { |
| 121 collection_->OnMapCharacters(text, font_style, locale_name, reading_direction, |
| 122 base_family_name, result); |
| 123 } |
| 124 |
112 FakeFontCollection::FakeSender::FakeSender(FakeFontCollection* collection, | 125 FakeFontCollection::FakeSender::FakeSender(FakeFontCollection* collection, |
113 bool track_messages) | 126 bool track_messages) |
114 : track_messages_(track_messages), collection_(collection) {} | 127 : track_messages_(track_messages), collection_(collection) {} |
115 | 128 |
116 FakeFontCollection::FakeSender::~FakeSender() = default; | 129 FakeFontCollection::FakeSender::~FakeSender() = default; |
117 | 130 |
118 bool FakeFontCollection::FakeSender::Send(IPC::Message* message) { | 131 bool FakeFontCollection::FakeSender::Send(IPC::Message* message) { |
119 std::unique_ptr<IPC::Message> incoming_message; | 132 std::unique_ptr<IPC::Message> incoming_message; |
120 if (track_messages_) | 133 if (track_messages_) |
121 collection_->messages_.emplace_back(message); | 134 collection_->messages_.emplace_back(message); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 169 } |
157 | 170 |
158 void FakeFontCollection::OnGetFontFiles( | 171 void FakeFontCollection::OnGetFontFiles( |
159 uint32_t family_index, | 172 uint32_t family_index, |
160 std::vector<base::string16>* file_paths) { | 173 std::vector<base::string16>* file_paths) { |
161 if (family_index >= fonts_.size()) | 174 if (family_index >= fonts_.size()) |
162 return; | 175 return; |
163 *file_paths = fonts_[family_index].file_paths_; | 176 *file_paths = fonts_[family_index].file_paths_; |
164 } | 177 } |
165 | 178 |
| 179 void FakeFontCollection::OnMapCharacters(const base::string16& text, |
| 180 const DWriteFontStyle& font_style, |
| 181 const base::string16& locale_name, |
| 182 uint32_t reading_direction, |
| 183 const base::string16& base_family_name, |
| 184 MapCharactersResult* result) { |
| 185 result->family_index = 0; |
| 186 result->family_name = fonts_[0].FontName(); |
| 187 result->mapped_length = 1; |
| 188 result->scale = 1.0; |
| 189 result->font_style.font_weight = DWRITE_FONT_WEIGHT_NORMAL; |
| 190 result->font_style.font_slant = DWRITE_FONT_STYLE_NORMAL; |
| 191 result->font_style.font_stretch = DWRITE_FONT_STRETCH_NORMAL; |
| 192 } |
| 193 |
166 std::unique_ptr<FakeFontCollection::ReplySender> | 194 std::unique_ptr<FakeFontCollection::ReplySender> |
167 FakeFontCollection::GetReplySender() { | 195 FakeFontCollection::GetReplySender() { |
168 return std::unique_ptr<FakeFontCollection::ReplySender>( | 196 return std::unique_ptr<FakeFontCollection::ReplySender>( |
169 new FakeFontCollection::ReplySender(this)); | 197 new FakeFontCollection::ReplySender(this)); |
170 } | 198 } |
171 | 199 |
172 FakeFontCollection::~FakeFontCollection() = default; | 200 FakeFontCollection::~FakeFontCollection() = default; |
173 | 201 |
174 } // namespace content | 202 } // namespace content |
OLD | NEW |