Add Wi-FI SSID to captive portal interstitial.
[chromium-blink-merge.git] / ppapi / cpp / trusted / browser_font_trusted.h
blob7225b269ee545a0006ccb2942606cc4d2ff22961
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.
5 #ifndef PPAPI_CPP_TRUSTED_BROWSER_FONT_TRUSTED_H_
6 #define PPAPI_CPP_TRUSTED_BROWSER_FONT_TRUSTED_H_
8 #include <string>
10 #include "ppapi/c/trusted/ppb_browser_font_trusted.h"
11 #include "ppapi/cpp/resource.h"
12 #include "ppapi/cpp/var.h"
14 namespace pp {
16 class ImageData;
17 class InstanceHandle;
18 class Point;
19 class Rect;
21 // BrowserFontDescription ------------------------------------------------------
23 class BrowserFontDescription {
24 public:
25 BrowserFontDescription();
26 BrowserFontDescription(const BrowserFontDescription& other);
27 ~BrowserFontDescription();
29 BrowserFontDescription& operator=(const BrowserFontDescription& other);
31 const PP_BrowserFont_Trusted_Description& pp_font_description() const {
32 return pp_font_description_;
35 Var face() const { return face_; }
36 void set_face(const Var& face) {
37 face_ = face;
38 pp_font_description_.face = face_.pp_var();
41 PP_BrowserFont_Trusted_Family family() const {
42 return pp_font_description_.family;
44 void set_family(PP_BrowserFont_Trusted_Family f) {
45 pp_font_description_.family = f;
48 uint32_t size() const { return pp_font_description_.size; }
49 void set_size(uint32_t s) { pp_font_description_.size = s; }
51 PP_BrowserFont_Trusted_Weight weight() const {
52 return pp_font_description_.weight;
54 void set_weight(PP_BrowserFont_Trusted_Weight w) {
55 pp_font_description_.weight = w;
58 bool italic() const { return PP_ToBool(pp_font_description_.italic); }
59 void set_italic(bool i) { pp_font_description_.italic = PP_FromBool(i); }
61 bool small_caps() const {
62 return PP_ToBool(pp_font_description_.small_caps);
64 void set_small_caps(bool s) {
65 pp_font_description_.small_caps = PP_FromBool(s);
68 int letter_spacing() const { return pp_font_description_.letter_spacing; }
69 void set_letter_spacing(int s) { pp_font_description_.letter_spacing = s; }
71 int word_spacing() const { return pp_font_description_.word_spacing; }
72 void set_word_spacing(int w) { pp_font_description_.word_spacing = w; }
74 private:
75 friend class BrowserFont_Trusted;
77 Var face_; // Manages memory for pp_font_description_.face
78 PP_BrowserFont_Trusted_Description pp_font_description_;
81 // BrowserFontTextRun ----------------------------------------------------------
83 class BrowserFontTextRun {
84 public:
85 BrowserFontTextRun();
86 BrowserFontTextRun(const std::string& text,
87 bool rtl = false,
88 bool override_direction = false);
89 BrowserFontTextRun(const BrowserFontTextRun& other);
90 ~BrowserFontTextRun();
92 BrowserFontTextRun& operator=(const BrowserFontTextRun& other);
94 const PP_BrowserFont_Trusted_TextRun& pp_text_run() const {
95 return pp_text_run_;
98 private:
99 Var text_; // Manages memory for the reference in pp_text_run_.
100 PP_BrowserFont_Trusted_TextRun pp_text_run_;
103 // BrowserFont_Trusted ---------------------------------------------------------
105 // Provides access to system fonts.
106 class BrowserFont_Trusted : public Resource {
107 public:
108 // Creates an is_null() Font object.
109 BrowserFont_Trusted();
111 explicit BrowserFont_Trusted(PP_Resource resource);
112 BrowserFont_Trusted(const InstanceHandle& instance,
113 const BrowserFontDescription& description);
114 BrowserFont_Trusted(const BrowserFont_Trusted& other);
116 BrowserFont_Trusted& operator=(const BrowserFont_Trusted& other);
118 // PPB_Font methods:
119 static Var GetFontFamilies(const InstanceHandle& instance);
120 bool Describe(BrowserFontDescription* description,
121 PP_BrowserFont_Trusted_Metrics* metrics) const;
122 bool DrawTextAt(ImageData* dest,
123 const BrowserFontTextRun& text,
124 const Point& position,
125 uint32_t color,
126 const Rect& clip,
127 bool image_data_is_opaque) const;
128 int32_t MeasureText(const BrowserFontTextRun& text) const;
129 uint32_t CharacterOffsetForPixel(const BrowserFontTextRun& text,
130 int32_t pixel_position) const;
131 int32_t PixelOffsetForCharacter(const BrowserFontTextRun& text,
132 uint32_t char_offset) const;
134 // Convenience function that assumes a left-to-right string with no clipping.
135 bool DrawSimpleText(ImageData* dest,
136 const std::string& text,
137 const Point& position,
138 uint32_t color,
139 bool image_data_is_opaque = false) const;
141 // Convenience function that assumes a left-to-right string.
142 int32_t MeasureSimpleText(const std::string& text) const;
145 } // namespace pp
147 #endif // PPAPI_CPP_TRUSTED_BROWSER_FONT_TRUSTED_H_