| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |