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

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

Issue 1846433005: Implement direct write fallback proxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #ifndef CONTENT_TEST_DWRITE_FONT_FAKE_SENDER_WIN_H_ 5 #ifndef CONTENT_TEST_DWRITE_FONT_FAKE_SENDER_WIN_H_
6 #define CONTENT_TEST_DWRITE_FONT_FAKE_SENDER_WIN_H_ 6 #define CONTENT_TEST_DWRITE_FONT_FAKE_SENDER_WIN_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <wrl.h> 10 #include <wrl.h>
11 11
12 #include <memory> 12 #include <memory>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
19 #include "ipc/ipc_message.h" 19 #include "ipc/ipc_message.h"
20 #include "ipc/ipc_sender.h" 20 #include "ipc/ipc_sender.h"
21 21
22 struct DWriteFontStyle;
23 struct MapCharactersResult;
24
22 namespace content { 25 namespace content {
23 26
24 class FakeFontCollection; 27 class FakeFontCollection;
25 28
26 // Creates a new FakeFontCollection, seeded with some basic data, and returns a 29 // Creates a new FakeFontCollection, seeded with some basic data, and returns a
27 // Sender that can be used to interact with the collection. 30 // Sender that can be used to interact with the collection.
28 IPC::Sender* CreateFakeCollectionSender(); 31 IPC::Sender* CreateFakeCollectionSender();
29 32
30 // Helper class for describing a font object. Use FakeFontCollection instead. 33 // Helper class for describing a font object. Use FakeFontCollection instead.
31 class FakeFont { 34 class FakeFont {
32 public: 35 public:
33 explicit FakeFont(const base::string16& name); 36 explicit FakeFont(const base::string16& name);
34 37
35 ~FakeFont(); 38 ~FakeFont();
36 39
37 FakeFont& AddFilePath(const base::string16& file_path) { 40 FakeFont& AddFilePath(const base::string16& file_path) {
38 file_paths_.push_back(file_path); 41 file_paths_.push_back(file_path);
39 return *this; 42 return *this;
40 } 43 }
41 44
42 FakeFont& AddFamilyName(const base::string16& locale, 45 FakeFont& AddFamilyName(const base::string16& locale,
43 const base::string16& family_name) { 46 const base::string16& family_name) {
44 family_names_.emplace_back(locale, family_name); 47 family_names_.emplace_back(locale, family_name);
45 return *this; 48 return *this;
46 } 49 }
47 50
51 const base::string16& FontName() { return font_name_; }
ananta 2016/04/12 23:44:39 Please change name to font_name()
Ilya Kulshin 2016/04/13 01:33:29 Done.
52
48 private: 53 private:
49 friend FakeFontCollection; 54 friend FakeFontCollection;
50 base::string16 font_name_; 55 base::string16 font_name_;
51 std::vector<base::string16> file_paths_; 56 std::vector<base::string16> file_paths_;
52 std::vector<std::pair<base::string16, base::string16>> family_names_; 57 std::vector<std::pair<base::string16, base::string16>> family_names_;
53 58
54 DISALLOW_ASSIGN(FakeFont); 59 DISALLOW_ASSIGN(FakeFont);
55 }; 60 };
56 61
57 // Implements a font collection that supports interaction through sending IPC 62 // Implements a font collection that supports interaction through sending IPC
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void OnFindFamily(const base::string16& family_name, uint32_t* index); 110 void OnFindFamily(const base::string16& family_name, uint32_t* index);
106 111
107 void OnGetFamilyCount(uint32_t* count); 112 void OnGetFamilyCount(uint32_t* count);
108 113
109 void OnGetFamilyNames( 114 void OnGetFamilyNames(
110 uint32_t family_index, 115 uint32_t family_index,
111 std::vector<std::pair<base::string16, base::string16>>* family_names); 116 std::vector<std::pair<base::string16, base::string16>>* family_names);
112 void OnGetFontFiles(uint32_t family_index, 117 void OnGetFontFiles(uint32_t family_index,
113 std::vector<base::string16>* file_paths_); 118 std::vector<base::string16>* file_paths_);
114 119
120 void OnMapCharacters(const base::string16& text,
121 const DWriteFontStyle& font_style,
122 const base::string16& locale_name,
123 uint32_t reading_direction,
124 const base::string16& base_family_name,
125 MapCharactersResult* result);
126
115 private: 127 private:
116 scoped_refptr<FakeFontCollection> collection_; 128 scoped_refptr<FakeFontCollection> collection_;
117 std::unique_ptr<IPC::Message> reply_; 129 std::unique_ptr<IPC::Message> reply_;
118 130
119 DISALLOW_COPY_AND_ASSIGN(ReplySender); 131 DISALLOW_COPY_AND_ASSIGN(ReplySender);
120 }; 132 };
121 133
122 // This class can be used by the "renderer" to send messages to the "browser" 134 // This class can be used by the "renderer" to send messages to the "browser"
123 class FakeSender : public IPC::Sender { 135 class FakeSender : public IPC::Sender {
124 public: 136 public:
(...skipping 14 matching lines...) Expand all
139 151
140 void OnGetFamilyCount(uint32_t* count); 152 void OnGetFamilyCount(uint32_t* count);
141 153
142 void OnGetFamilyNames( 154 void OnGetFamilyNames(
143 uint32_t family_index, 155 uint32_t family_index,
144 std::vector<std::pair<base::string16, base::string16>>* family_names); 156 std::vector<std::pair<base::string16, base::string16>>* family_names);
145 157
146 void OnGetFontFiles(uint32_t family_index, 158 void OnGetFontFiles(uint32_t family_index,
147 std::vector<base::string16>* file_paths); 159 std::vector<base::string16>* file_paths);
148 160
161 void OnMapCharacters(const base::string16& text,
162 const DWriteFontStyle& font_style,
163 const base::string16& locale_name,
164 uint32_t reading_direction,
165 const base::string16& base_family_name,
166 MapCharactersResult* result);
167
149 std::unique_ptr<ReplySender> GetReplySender(); 168 std::unique_ptr<ReplySender> GetReplySender();
150 169
151 private: 170 private:
152 friend class base::RefCounted<FakeFontCollection>; 171 friend class base::RefCounted<FakeFontCollection>;
153 ~FakeFontCollection(); 172 ~FakeFontCollection();
154 173
155 std::vector<FakeFont> fonts_; 174 std::vector<FakeFont> fonts_;
156 std::vector<std::unique_ptr<IPC::Message>> messages_; 175 std::vector<std::unique_ptr<IPC::Message>> messages_;
157 176
158 DISALLOW_COPY_AND_ASSIGN(FakeFontCollection); 177 DISALLOW_COPY_AND_ASSIGN(FakeFontCollection);
159 }; 178 };
160 179
161 } // namespace content 180 } // namespace content
162 181
163 #endif // CONTENT_TEST_DWRITE_FONT_FAKE_SENDER_WIN_H_ 182 #endif // CONTENT_TEST_DWRITE_FONT_FAKE_SENDER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698