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

Side by Side Diff: content/test/dwrite_font_fake_sender_win.cc

Issue 1846433005: Implement direct write fallback proxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a missing SUCCEEDED call Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « content/test/dwrite_font_fake_sender_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 73
73 std::unique_ptr<IPC::Message>& 74 std::unique_ptr<IPC::Message>&
74 FakeFontCollection::ReplySender::OnMessageReceived(const IPC::Message& msg) { 75 FakeFontCollection::ReplySender::OnMessageReceived(const IPC::Message& msg) {
75 reply_.reset(); 76 reply_.reset();
76 bool handled = true; 77 bool handled = true;
77 IPC_BEGIN_MESSAGE_MAP(ReplySender, msg) 78 IPC_BEGIN_MESSAGE_MAP(ReplySender, msg)
78 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_FindFamily, OnFindFamily) 79 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_FindFamily, OnFindFamily)
79 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFamilyCount, OnGetFamilyCount) 80 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFamilyCount, OnGetFamilyCount)
80 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFamilyNames, OnGetFamilyNames) 81 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFamilyNames, OnGetFamilyNames)
81 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFontFiles, OnGetFontFiles) 82 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_GetFontFiles, OnGetFontFiles)
83 IPC_MESSAGE_HANDLER(DWriteFontProxyMsg_MapCharacters, OnMapCharacters)
82 IPC_MESSAGE_UNHANDLED(handled = false) 84 IPC_MESSAGE_UNHANDLED(handled = false)
83 IPC_END_MESSAGE_MAP() 85 IPC_END_MESSAGE_MAP()
84 return reply_; 86 return reply_;
85 } 87 }
86 88
87 bool FakeFontCollection::ReplySender::Send(IPC::Message* msg) { 89 bool FakeFontCollection::ReplySender::Send(IPC::Message* msg) {
88 reply_.reset(msg); 90 reply_.reset(msg);
89 return true; 91 return true;
90 } 92 }
91 93
(...skipping 12 matching lines...) Expand all
104 std::vector<DWriteStringPair>* family_names) { 106 std::vector<DWriteStringPair>* family_names) {
105 collection_->OnGetFamilyNames(family_index, family_names); 107 collection_->OnGetFamilyNames(family_index, family_names);
106 } 108 }
107 109
108 void FakeFontCollection::ReplySender::OnGetFontFiles( 110 void FakeFontCollection::ReplySender::OnGetFontFiles(
109 uint32_t family_index, 111 uint32_t family_index,
110 std::vector<base::string16>* file_paths) { 112 std::vector<base::string16>* file_paths) {
111 collection_->OnGetFontFiles(family_index, file_paths); 113 collection_->OnGetFontFiles(family_index, file_paths);
112 } 114 }
113 115
116 void FakeFontCollection::ReplySender::OnMapCharacters(
117 const base::string16& text,
118 const DWriteFontStyle& font_style,
119 const base::string16& locale_name,
120 uint32_t reading_direction,
121 const base::string16& base_family_name,
122 MapCharactersResult* result) {
123 collection_->OnMapCharacters(text, font_style, locale_name, reading_direction,
124 base_family_name, result);
125 }
126
114 FakeFontCollection::FakeSender::FakeSender(FakeFontCollection* collection, 127 FakeFontCollection::FakeSender::FakeSender(FakeFontCollection* collection,
115 bool track_messages) 128 bool track_messages)
116 : track_messages_(track_messages), collection_(collection) {} 129 : track_messages_(track_messages), collection_(collection) {}
117 130
118 FakeFontCollection::FakeSender::~FakeSender() = default; 131 FakeFontCollection::FakeSender::~FakeSender() = default;
119 132
120 bool FakeFontCollection::FakeSender::Send(IPC::Message* message) { 133 bool FakeFontCollection::FakeSender::Send(IPC::Message* message) {
121 std::unique_ptr<IPC::Message> incoming_message; 134 std::unique_ptr<IPC::Message> incoming_message;
122 if (track_messages_) 135 if (track_messages_)
123 collection_->messages_.emplace_back(message); 136 collection_->messages_.emplace_back(message);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 171 }
159 172
160 void FakeFontCollection::OnGetFontFiles( 173 void FakeFontCollection::OnGetFontFiles(
161 uint32_t family_index, 174 uint32_t family_index,
162 std::vector<base::string16>* file_paths) { 175 std::vector<base::string16>* file_paths) {
163 if (family_index >= fonts_.size()) 176 if (family_index >= fonts_.size())
164 return; 177 return;
165 *file_paths = fonts_[family_index].file_paths_; 178 *file_paths = fonts_[family_index].file_paths_;
166 } 179 }
167 180
181 void FakeFontCollection::OnMapCharacters(const base::string16& text,
182 const DWriteFontStyle& font_style,
183 const base::string16& locale_name,
184 uint32_t reading_direction,
185 const base::string16& base_family_name,
186 MapCharactersResult* result) {
187 result->family_index = 0;
188 result->family_name = fonts_[0].font_name();
189 result->mapped_length = 1;
190 result->scale = 1.0;
191 result->font_style.font_weight = DWRITE_FONT_WEIGHT_NORMAL;
192 result->font_style.font_slant = DWRITE_FONT_STYLE_NORMAL;
193 result->font_style.font_stretch = DWRITE_FONT_STRETCH_NORMAL;
194 }
195
168 std::unique_ptr<FakeFontCollection::ReplySender> 196 std::unique_ptr<FakeFontCollection::ReplySender>
169 FakeFontCollection::GetReplySender() { 197 FakeFontCollection::GetReplySender() {
170 return std::unique_ptr<FakeFontCollection::ReplySender>( 198 return std::unique_ptr<FakeFontCollection::ReplySender>(
171 new FakeFontCollection::ReplySender(this)); 199 new FakeFontCollection::ReplySender(this));
172 } 200 }
173 201
174 FakeFontCollection::~FakeFontCollection() = default; 202 FakeFontCollection::~FakeFontCollection() = default;
175 203
176 } // namespace content 204 } // namespace content
OLDNEW
« no previous file with comments | « content/test/dwrite_font_fake_sender_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698