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 "ppapi/c/dev/ppb_font_dev.h" | 9 #include "ppapi/c/dev/ppb_font_dev.h" |
10 #include "ppapi/proxy/connection.h" | 10 #include "ppapi/proxy/connection.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 namespace content { | 38 namespace content { |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 // Same as WebPreferences::kCommonScript. I'd use that directly here, but get an | 42 // Same as WebPreferences::kCommonScript. I'd use that directly here, but get an |
43 // undefined reference linker error. | 43 // undefined reference linker error. |
44 const char kCommonScript[] = "Zyyy"; | 44 const char kCommonScript[] = "Zyyy"; |
45 | 45 |
46 base::string16 GetFontFromMap( | 46 base::string16 GetFontFromMap( |
47 const webkit_glue::ScriptFontFamilyMap& map, | 47 const content::ScriptFontFamilyMap& map, |
48 const std::string& script) { | 48 const std::string& script) { |
49 webkit_glue::ScriptFontFamilyMap::const_iterator it = | 49 content::ScriptFontFamilyMap::const_iterator it = |
50 map.find(script); | 50 map.find(script); |
51 if (it != map.end()) | 51 if (it != map.end()) |
52 return it->second; | 52 return it->second; |
53 return base::string16(); | 53 return base::string16(); |
54 } | 54 } |
55 | 55 |
56 // Splits a PP_BrowserFont_Trusted_TextRun into a sequence or LTR and RTL | 56 // Splits a PP_BrowserFont_Trusted_TextRun into a sequence or LTR and RTL |
57 // WebTextRuns that can be used for WebKit. Normally WebKit does this for us, | 57 // WebTextRuns that can be used for WebKit. Normally WebKit does this for us, |
58 // but the font drawing and measurement routines we call happen after this | 58 // but the font drawing and measurement routines we call happen after this |
59 // step. So for correct rendering of RTL content, we need to do it ourselves. | 59 // step. So for correct rendering of RTL content, we need to do it ourselves. |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 420 |
421 // Advance to the next run. Note that we avoid doing this for the last run | 421 // Advance to the next run. Note that we avoid doing this for the last run |
422 // since it's unnecessary, measuring text is slow, and most of the time | 422 // since it's unnecessary, measuring text is slow, and most of the time |
423 // there will be only one run anyway. | 423 // there will be only one run anyway. |
424 if (i != runs.num_runs() - 1) | 424 if (i != runs.num_runs() - 1) |
425 web_position.x += font_->calculateWidth(run); | 425 web_position.x += font_->calculateWidth(run); |
426 } | 426 } |
427 } | 427 } |
428 | 428 |
429 } // namespace content | 429 } // namespace content |
OLD | NEW |