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

Side by Side Diff: content/child/browser_font_resource_trusted.cc

Issue 1259673002: Make UTF16ToASCII and UTF16TOUTF8 take a StringPiece (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/child/browser_font_resource_trusted.h" 5 #include "content/child/browser_font_resource_trusted.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/public/common/web_preferences.h" 9 #include "content/public/common/web_preferences.h"
10 #include "ppapi/c/dev/ppb_font_dev.h" 10 #include "ppapi/c/dev/ppb_font_dev.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 265
266 PP_Bool BrowserFontResource_Trusted::Describe( 266 PP_Bool BrowserFontResource_Trusted::Describe(
267 PP_BrowserFont_Trusted_Description* description, 267 PP_BrowserFont_Trusted_Description* description,
268 PP_BrowserFont_Trusted_Metrics* metrics) { 268 PP_BrowserFont_Trusted_Metrics* metrics) {
269 if (description->face.type != PP_VARTYPE_UNDEFINED) 269 if (description->face.type != PP_VARTYPE_UNDEFINED)
270 return PP_FALSE; 270 return PP_FALSE;
271 271
272 // While converting the other way in PPFontDescToWebFontDesc we validated 272 // While converting the other way in PPFontDescToWebFontDesc we validated
273 // that the enums can be casted. 273 // that the enums can be casted.
274 WebFontDescription web_desc = font_->fontDescription(); 274 WebFontDescription web_desc = font_->fontDescription();
275 description->face = 275 description->face = StringVar::StringToPPVar(base::UTF16ToUTF8(
276 StringVar::StringToPPVar(base::UTF16ToUTF8(web_desc.family)); 276 base::StringPiece16(web_desc.family)));
277 description->family = 277 description->family =
278 static_cast<PP_BrowserFont_Trusted_Family>(web_desc.genericFamily); 278 static_cast<PP_BrowserFont_Trusted_Family>(web_desc.genericFamily);
279 description->size = static_cast<uint32_t>(web_desc.size); 279 description->size = static_cast<uint32_t>(web_desc.size);
280 description->weight = static_cast<PP_BrowserFont_Trusted_Weight>( 280 description->weight = static_cast<PP_BrowserFont_Trusted_Weight>(
281 web_desc.weight); 281 web_desc.weight);
282 description->italic = web_desc.italic ? PP_TRUE : PP_FALSE; 282 description->italic = web_desc.italic ? PP_TRUE : PP_FALSE;
283 description->small_caps = web_desc.smallCaps ? PP_TRUE : PP_FALSE; 283 description->small_caps = web_desc.smallCaps ? PP_TRUE : PP_FALSE;
284 description->letter_spacing = static_cast<int32_t>(web_desc.letterSpacing); 284 description->letter_spacing = static_cast<int32_t>(web_desc.letterSpacing);
285 description->word_spacing = static_cast<int32_t>(web_desc.wordSpacing); 285 description->word_spacing = static_cast<int32_t>(web_desc.wordSpacing);
286 286
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 438
439 // Advance to the next run. Note that we avoid doing this for the last run 439 // Advance to the next run. Note that we avoid doing this for the last run
440 // since it's unnecessary, measuring text is slow, and most of the time 440 // since it's unnecessary, measuring text is slow, and most of the time
441 // there will be only one run anyway. 441 // there will be only one run anyway.
442 if (i != runs.num_runs() - 1) 442 if (i != runs.num_runs() - 1)
443 web_position.x += font_->calculateWidth(run); 443 web_position.x += font_->calculateWidth(run);
444 } 444 }
445 } 445 }
446 446
447 } // namespace content 447 } // namespace content
OLDNEW
« no previous file with comments | « components/html_viewer/web_mime_registry_impl.cc ('k') | content/child/notifications/notification_data_conversions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698