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

Side by Side Diff: ppapi/shared_impl/private/ppb_font_shared.cc

Issue 9317100: Use the correct Resource constructor for PPB_Font_Shared in the plugin process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/shared_impl/private/ppb_font_shared.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 (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/shared_impl/private/ppb_font_shared.h" 5 #include "ppapi/shared_impl/private/ppb_font_shared.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "ppapi/c/dev/ppb_font_dev.h" 10 #include "ppapi/c/dev/ppb_font_dev.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 return true; 301 return true;
302 } 302 }
303 303
304 // static 304 // static
305 PP_Resource PPB_Font_Shared::CreateAsImpl( 305 PP_Resource PPB_Font_Shared::CreateAsImpl(
306 PP_Instance instance, 306 PP_Instance instance,
307 const PP_FontDescription_Dev& description, 307 const PP_FontDescription_Dev& description,
308 const ::ppapi::Preferences& prefs) { 308 const ::ppapi::Preferences& prefs) {
309 if (!::ppapi::PPB_Font_Shared::IsPPFontDescriptionValid(description)) 309 if (!::ppapi::PPB_Font_Shared::IsPPFontDescriptionValid(description))
310 return 0; 310 return 0;
311 return (new PPB_Font_Shared(instance, description, prefs))->GetReference(); 311 return (new PPB_Font_Shared(InitAsImpl(), instance, description,
312 prefs))->GetReference();
312 } 313 }
313 314
314 // static 315 // static
315 PP_Resource PPB_Font_Shared::CreateAsProxy( 316 PP_Resource PPB_Font_Shared::CreateAsProxy(
316 PP_Instance instance, 317 PP_Instance instance,
317 const PP_FontDescription_Dev& description, 318 const PP_FontDescription_Dev& description,
318 const ::ppapi::Preferences& prefs) { 319 const ::ppapi::Preferences& prefs) {
319 return CreateAsImpl(instance, description, prefs); 320 if (!::ppapi::PPB_Font_Shared::IsPPFontDescriptionValid(description))
321 return 0;
322 return (new PPB_Font_Shared(InitAsProxy(), instance, description,
323 prefs))->GetReference();
320 } 324 }
321 325
322 PPB_Font_Shared::PPB_Font_Shared(PP_Instance pp_instance, 326 PPB_Font_Shared::PPB_Font_Shared(const InitAsImpl&,
327 PP_Instance pp_instance,
323 const PP_FontDescription_Dev& desc, 328 const PP_FontDescription_Dev& desc,
324 const ::ppapi::Preferences& prefs) 329 const ::ppapi::Preferences& prefs)
325 : Resource(pp_instance) { 330 : Resource(pp_instance) {
326 StringVar* face_name = StringVar::FromPPVar(desc.face); 331 Initialize(desc, prefs);
332 }
327 333
328 font_impl_.reset(new FontImpl( 334 PPB_Font_Shared::PPB_Font_Shared(const InitAsProxy&,
329 desc, face_name ? face_name->value() : std::string(), prefs)); 335 PP_Instance pp_instance,
336 const PP_FontDescription_Dev& desc,
337 const ::ppapi::Preferences& prefs)
338 : Resource(HostResource::MakeInstanceOnly(pp_instance)) {
339 Initialize(desc, prefs);
330 } 340 }
331 341
332 PPB_Font_Shared::~PPB_Font_Shared() { 342 PPB_Font_Shared::~PPB_Font_Shared() {
333 } 343 }
334 344
335 ::ppapi::thunk::PPB_Font_API* PPB_Font_Shared::AsPPB_Font_API() { 345 ::ppapi::thunk::PPB_Font_API* PPB_Font_Shared::AsPPB_Font_API() {
336 return this; 346 return this;
337 } 347 }
338 348
339 PP_Bool PPB_Font_Shared::Describe(PP_FontDescription_Dev* description, 349 PP_Bool PPB_Font_Shared::Describe(PP_FontDescription_Dev* description,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 int32_t PPB_Font_Shared::PixelOffsetForCharacter(const PP_TextRun_Dev* text, 418 int32_t PPB_Font_Shared::PixelOffsetForCharacter(const PP_TextRun_Dev* text,
409 uint32_t char_offset) { 419 uint32_t char_offset) {
410 int32_t result = -1; 420 int32_t result = -1;
411 WebKitForwarding::Font::TextRun run; 421 WebKitForwarding::Font::TextRun run;
412 if (PPTextRunToTextRun(text, &run)) { 422 if (PPTextRunToTextRun(text, &run)) {
413 font_impl_->PixelOffsetForCharacter(run, char_offset, &result); 423 font_impl_->PixelOffsetForCharacter(run, char_offset, &result);
414 } 424 }
415 return result; 425 return result;
416 } 426 }
417 427
428 void PPB_Font_Shared::Initialize(const PP_FontDescription_Dev& desc,
429 const ::ppapi::Preferences& prefs) {
430 StringVar* face_name = StringVar::FromPPVar(desc.face);
431
432 font_impl_.reset(new FontImpl(
433 desc, face_name ? face_name->value() : std::string(), prefs));
434 }
435
418 } // namespace ppapi 436 } // namespace ppapi
419 437
OLDNEW
« no previous file with comments | « ppapi/shared_impl/private/ppb_font_shared.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698