OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ppapi/shared_impl/ppb_font_shared.h" | |
6 | |
7 #include "ppapi/c/dev/ppb_font_dev.h" | |
8 | |
9 namespace ppapi { | |
10 | |
11 // static | |
12 bool PPB_Font_Shared::IsPPFontDescriptionValid( | |
13 const PP_FontDescription_Dev& desc) { | |
14 // Check validity of string. We can't check the actual text since we could | |
15 // be on the wrong thread and don't know if we're in the plugin or the host. | |
16 if (desc.face.type != PP_VARTYPE_STRING && | |
17 desc.face.type != PP_VARTYPE_UNDEFINED) | |
18 return false; | |
19 | |
20 // Check enum ranges. | |
21 if (static_cast<int>(desc.family) < PP_FONTFAMILY_DEFAULT || | |
22 static_cast<int>(desc.family) > PP_FONTFAMILY_MONOSPACE) | |
23 return false; | |
24 if (static_cast<int>(desc.weight) < PP_FONTWEIGHT_100 || | |
25 static_cast<int>(desc.weight) > PP_FONTWEIGHT_900) | |
26 return false; | |
27 | |
28 // Check for excessive sizes which may cause layout to get confused. | |
29 if (desc.size > 200) | |
30 return false; | |
31 | |
32 return true; | |
33 } | |
34 | |
35 } // namespace ppapi | |
OLD | NEW |