OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/proxy/ppb_font_proxy.h" | 5 #include "ppapi/proxy/ppb_font_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "ppapi/c/dev/ppb_font_dev.h" | 9 #include "ppapi/c/dev/ppb_font_dev.h" |
10 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 using ppapi::thunk::PPB_Font_FunctionAPI; | 23 using ppapi::thunk::PPB_Font_FunctionAPI; |
24 using ppapi::thunk::PPB_ImageData_API; | 24 using ppapi::thunk::PPB_ImageData_API; |
25 | 25 |
26 namespace ppapi { | 26 namespace ppapi { |
27 namespace proxy { | 27 namespace proxy { |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 bool PPTextRunToTextRun(const PP_TextRun_Dev* run, | 31 bool PPTextRunToTextRun(const PP_TextRun_Dev* run, |
32 WebKitForwarding::Font::TextRun* output) { | 32 WebKitForwarding::Font::TextRun* output) { |
33 scoped_refptr<StringVar> str(StringVar::FromPPVar(run->text)); | 33 StringVar* str = StringVar::FromPPVar(run->text); |
34 if (!str) | 34 if (!str) |
35 return false; | 35 return false; |
36 | 36 |
37 output->text = str->value(); | 37 output->text = str->value(); |
38 output->rtl = PP_ToBool(run->rtl); | 38 output->rtl = PP_ToBool(run->rtl); |
39 output->override_direction = PP_ToBool(run->override_direction); | 39 output->override_direction = PP_ToBool(run->override_direction); |
40 return true; | 40 return true; |
41 } | 41 } |
42 | 42 |
43 InterfaceProxy* CreateFontProxy(Dispatcher* dispatcher, | 43 InterfaceProxy* CreateFontProxy(Dispatcher* dispatcher, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // There aren't any font messages. | 90 // There aren't any font messages. |
91 NOTREACHED(); | 91 NOTREACHED(); |
92 return false; | 92 return false; |
93 } | 93 } |
94 | 94 |
95 Font::Font(const HostResource& resource, | 95 Font::Font(const HostResource& resource, |
96 const PP_FontDescription_Dev& desc) | 96 const PP_FontDescription_Dev& desc) |
97 : Resource(resource), | 97 : Resource(resource), |
98 webkit_event_(false, false) { | 98 webkit_event_(false, false) { |
99 TRACE_EVENT0("ppapi proxy", "Font::Font"); | 99 TRACE_EVENT0("ppapi proxy", "Font::Font"); |
100 scoped_refptr<StringVar> face(StringVar::FromPPVar(desc.face)); | 100 StringVar* face = StringVar::FromPPVar(desc.face); |
101 | 101 |
102 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this); | 102 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource(this); |
103 WebKitForwarding* forwarding = dispatcher->GetWebKitForwarding(); | 103 WebKitForwarding* forwarding = dispatcher->GetWebKitForwarding(); |
104 | 104 |
105 RunOnWebKitThread(true, | 105 RunOnWebKitThread(true, |
106 base::Bind(&WebKitForwarding::CreateFontForwarding, | 106 base::Bind(&WebKitForwarding::CreateFontForwarding, |
107 base::Unretained(forwarding), | 107 base::Unretained(forwarding), |
108 &webkit_event_, desc, | 108 &webkit_event_, desc, |
109 face.get() ? face->value() : std::string(), | 109 face ? face->value() : std::string(), |
110 dispatcher->preferences(), | 110 dispatcher->preferences(), |
111 &font_forwarding_)); | 111 &font_forwarding_)); |
112 } | 112 } |
113 | 113 |
114 Font::~Font() { | 114 Font::~Font() { |
115 RunOnWebKitThread(false, base::Bind(&DeleteFontForwarding, font_forwarding_)); | 115 RunOnWebKitThread(false, base::Bind(&DeleteFontForwarding, font_forwarding_)); |
116 } | 116 } |
117 | 117 |
118 PPB_Font_API* Font::AsPPB_Font_API() { | 118 PPB_Font_API* Font::AsPPB_Font_API() { |
119 return this; | 119 return this; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 webkit_event_.Wait(); | 226 webkit_event_.Wait(); |
227 } | 227 } |
228 | 228 |
229 // static | 229 // static |
230 void Font::DeleteFontForwarding(WebKitForwarding::Font* font_forwarding) { | 230 void Font::DeleteFontForwarding(WebKitForwarding::Font* font_forwarding) { |
231 delete font_forwarding; | 231 delete font_forwarding; |
232 } | 232 } |
233 | 233 |
234 } // namespace proxy | 234 } // namespace proxy |
235 } // namespace ppapi | 235 } // namespace ppapi |
OLD | NEW |