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

Side by Side Diff: ppapi/cpp/instance.h

Issue 7565017: New instance.h documentation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 #ifndef PPAPI_CPP_INSTANCE_H_ 5 #ifndef PPAPI_CPP_INSTANCE_H_
6 #define PPAPI_CPP_INSTANCE_H_ 6 #define PPAPI_CPP_INSTANCE_H_
7 7
8 /// @file 8 /// @file
9 /// Defines the C++ wrapper for a plugin instance. 9 /// Defines the C++ wrapper for a module instance.
dmichael (off chromium) 2011/08/04 17:00:14 can we just say 'an instance' instead of 'a module
jond 2011/08/04 19:36:38 Done.
10 ///
11 /// @addtogroup CPP
12 /// @{
13 10
14 #include <map> 11 #include <map>
15 #include <string> 12 #include <string>
16 13
17 #include "ppapi/c/pp_instance.h" 14 #include "ppapi/c/pp_instance.h"
18 #include "ppapi/c/pp_resource.h" 15 #include "ppapi/c/pp_resource.h"
19 #include "ppapi/c/pp_stdint.h" 16 #include "ppapi/c/pp_stdint.h"
20 17
21 struct PP_InputEvent; 18 struct PP_InputEvent;
22 19
23 /// The C++ interface to the Pepper API. 20 /// The C++ interface to the Pepper API.
24 namespace pp { 21 namespace pp {
25 22
26 class Graphics2D; 23 class Graphics2D;
27 class Graphics3D_Dev; 24 class Graphics3D_Dev;
28 class InputEvent; 25 class InputEvent;
29 class ImageData; 26 class ImageData;
30 class Point; 27 class Point;
31 class Rect; 28 class Rect;
32 class Rect; 29 class Rect;
33 class Resource; 30 class Resource;
34 class Surface3D_Dev; 31 class Surface3D_Dev;
35 class URLLoader; 32 class URLLoader;
36 class Var; 33 class Var;
37 class Widget_Dev; 34 class Widget_Dev;
38 35
39 class Instance { 36 class Instance {
40 public: 37 public:
41 /// Construction of an instance should only be done in response to a browser 38 /// Default constructor. Construction of an instance should only be done in
42 /// request in Module::CreateInstance. Otherwise, the instance will lack the 39 /// response to a browser request in <code>Module::CreateInstance</code>.
43 /// proper bookkeeping in the browser and in the C++ wrapper. 40 /// Otherwise, the instance will lack the proper bookkeeping in the browser
41 /// and in the C++ wrapper.
44 /// 42 ///
45 /// Init() will be called immediately after the constructor. This allows you 43 /// Init() will be called immediately after the constructor. This allows you
46 /// to perform initialization tasks that can fail and to report that failure 44 /// to perform initialization tasks that can fail and to report that failure
47 /// to the browser. 45 /// to the browser.
48 explicit Instance(PP_Instance instance); 46 explicit Instance(PP_Instance instance);
49 47
50 /// When the instance is removed from the web page, the pp::Instance object 48 /// Destructor. When the instance is removed from the web page,
51 /// will be deleted. You should never delete the Instance object yourself 49 /// the <code>pp::Instance</code> object will be deleted. You should never
52 /// since the lifetime is handled by the C++ wrapper and is controlled by the 50 /// delete the <code>Instance</code> object yourself since the lifetime is
53 /// browser's calls to the PPP_Instance interface. 51 /// handled by the C++ wrapper and is controlled by the browser's calls to
52 /// the <code>PPP_Instance</code> interface.
54 /// 53 ///
55 /// The PP_Instance identifier will still be valid during this call so the 54 /// The <code>PP_Instance</code> identifier will still be valid during this
56 /// plugin can perform cleanup-related tasks. Once this function returns, the 55 /// call so the instance can perform cleanup-related tasks. Once this function
57 /// PP_Instance handle will be invalid. This means that you can't do any 56 /// returns, the <code>PP_Instance</code> handle will be invalid. This means
58 /// asynchronous operations like network requests or file writes from this 57 /// that you can't do any asynchronous operations such as network requests or
59 /// destructor since they will be immediately canceled. 58 /// file writes from this destructor since they will be immediately canceled.
60 /// 59 ///
61 /// <strong>Important note:</strong> This function may be skipped in certain 60 /// <strong>Note:</strong> This function may be skipped in certain
62 /// circumstances when Chrome does "fast shutdown". Fast shutdown will happen 61 /// call so the instance can perform cleanup-related tasks. Once this function
63 /// in some cases when all plugin instances are being deleted, and no cleanup 62 /// returns, the <code>PP_Instance</code> handle will be invalid. This means
64 /// functions will be called. The module will just be unloaded and the process 63 /// that you can't do any asynchronous operations such as network requests or
65 /// terminated. 64 /// file writes from this destructor since they will be immediately canceled.
66 virtual ~Instance(); 65 virtual ~Instance();
67 66
68 /// Returns the PP_Instance identifying this object. When using the PPAPI C++ 67 /// This function returns the <code>PP_Instance</code> identifying this
69 /// wrappers this is not normally necessary, but is required when using the 68 /// object. When using the PPAPI C++ wrappers this is not normally necessary,
70 /// lower-level C APIs. 69 /// but is required when using the lower-level C APIs.
71 PP_Instance pp_instance() const { return pp_instance_; } 70 PP_Instance pp_instance() const { return pp_instance_; }
72 71
73 /// Initializes this plugin with the given arguments. This will be called 72 /// Init() initializes this instance with the provided arguments. This
74 /// immediately after the instance object is constructed. 73 /// function will be called immediately after the instance object is created.
dmichael (off chromium) 2011/08/04 17:00:14 created->constructed I know it's not as nice sound
jond 2011/08/04 19:36:38 Done.
75 /// 74 ///
76 /// @param[in] argc The number of arguments contained in @a argn and @a argv. 75 /// @param[in] argc The number of arguments contained in <code>argn</code>
76 /// and <code>argv</code>.
77 /// 77 ///
78 /// @param[in] argn An array of argument names. These argument names are 78 /// @param[in] argn An array of argument names. These argument names are
79 /// supplied in the <embed> tag, for example: 79 /// supplied in the \<embed\> tag, for example:
80 /// <embed id="nacl_module" dimensions="2"> will produce two argument 80 /// <code>\<embed id="nacl_module" dimensions="2"\></code> will produce two
81 /// names: "id" and "dimensions." 81 /// argument names: "id" and "dimensions".
82 /// 82 ///
83 /// @param[in] argv An array of argument values. These are the values of the 83 /// @param[in] argv An array of argument values. These are the values of the
84 /// arguments listed in the <embed> tag, for example 84 /// arguments listed in the \<embed\> tag, for example
85 /// <embed id="nacl_module" dimensions="2"> will produce two argument 85 /// <code>\<embed id="nacl_module" dimensions="2"\></code> will produce two
86 /// values: "nacl_module" and "2". The indices of these values match the 86 /// argument values: "nacl_module" and "2". The indices of these values
87 /// indices of the corresponding names in @a argn. 87 /// match the indices of the corresponding names in <code>argn</code>.
88 /// 88 ///
89 /// @return True on success. Returning false causes the plugin 89 /// @return True on success. Returning false causes the instance to be
90 /// instance to be deleted and no other functions to be called. 90 /// instance to be deleted and no other functions to be called.
91 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]); 91 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]);
92 92
93 /// @{ 93 /// @{
94 /// @name PPP_Instance methods for the plugin to override: 94 /// @name PPP_Instance methods for the module to override:
95 95
96 /// Notification that the position, the size, or the clip rectangle of the 96 /// DidChangeView() is called when the position, the size, of the clip
dmichael (off chromium) 2011/08/04 17:00:14 'of'->'or'
jond 2011/08/04 19:36:38 Done.
97 /// element in the browser that corresponds to this instance has changed. 97 /// rectangle of the element in the browser that corresponds to this
98 /// instance has changed.
98 /// 99 ///
99 /// A typical implementation will check the size of the @a position argument 100 /// A typical implementation will check the size of the <code>position</code>
100 /// and reallocate the graphics context when a different size is received. 101 /// argument and reallocate the graphics context when a different size is
101 /// Note that this function will be called for scroll events where the size 102 /// received. Note that this function will be called for scroll events where
102 /// doesn't change, so you should always check that the size is actually 103 /// the size doesn't change, so you should always check that the size is
103 /// different before doing any reallocations. 104 /// actually different before doing any reallocations.
104 /// 105 ///
105 /// @param[in] position The location on the page of the instance. This is 106 /// @param[in] position The location on the page of the instance. The
106 /// relative to the top left corner of the viewport, which changes as the 107 /// position is relative to the top left corner of the viewport, which changes
107 /// page is scrolled. Generally the size of this value will be used to create 108 /// as the page is scrolled. Generally the size of this value will be used to
108 /// a graphics device, and the position is ignored (most things are relative 109 /// create a graphics device, and the position is ignored (most things are
109 /// to the instance so the absolute position isn't useful in most cases). 110 /// relative to the instance so the absolute position isn't useful in most
111 /// cases).
110 /// 112 ///
111 /// @param[in] clip The visible region of the instance. This is relative to 113 /// @param[in] clip The visible region of the instance. This is relative to
112 /// the top left of the plugin's coordinate system (not the page). If the 114 /// the top left of the module's coordinate system (not the page). If the
dmichael (off chromium) 2011/08/04 17:00:14 module->instance
jond 2011/08/04 19:36:38 Done.
jond 2011/08/04 19:36:38 Done.
113 /// plugin is invisible, @a clip will be (0, 0, 0, 0). 115 /// module is invisible, <code>clip</code> will be (0, 0, 0, 0).
dmichael (off chromium) 2011/08/04 17:00:14 module->instance
jond 2011/08/04 19:36:38 Done.
114 /// 116 ///
115 /// It's recommended to check for invisible instances and to stop 117 /// It's recommended to check for invisible instances and to stop
116 /// generating graphics updates in this case to save system resources. It's 118 /// generating graphics updates in this case to save system resources. It's
117 /// not usually worthwhile, however, to generate partial updates according to 119 /// not usually worthwhile, however, to generate partial updates according to
118 /// the clip when the instance is partially visible. Instead, update the 120 /// the clip when the instance is partially visible. Instead, update the
119 /// entire region. The time saved doing partial paints is usually not 121 /// entire region. The time saved doing partial paints is usually not
120 /// significant and it can create artifacts when scrolling (this notification 122 /// significant and it can create artifacts when scrolling (this notification
121 /// is sent asynchronously from scolling so there can be flashes of old 123 /// is sent asynchronously from scolling so there can be flashes of old
122 /// content in the exposed regions). 124 /// content in the exposed regions).
123 virtual void DidChangeView(const Rect& position, const Rect& clip); 125 virtual void DidChangeView(const Rect& position, const Rect& clip);
124 126
125 /// Notification that the instance has gained or lost focus. Having focus 127 /// DidChangeFocus() is called when an instance has gained or lost focus.
126 /// means that keyboard events will be sent to the instance. An instance's 128 /// Having focus means that keyboard events will be sent to the instance.
127 /// default condition is that it will not have focus. 129 /// An instance's default condition is that it will not have focus.
128 /// 130 ///
129 /// Note: clicks on instances will give focus only if you handle the 131 /// <strong>Note:</strong>Clicks on instances will give focus only if you
130 /// click event. Return @a true from HandleInputEvent to signal that the click 132 /// handle the click event. Return <code>true</code> from HandleInputEvent to
131 /// event was handled. Otherwise the browser will bubble the event and give 133 /// signal that the click event was handled. Otherwise the browser will bubble
132 /// focus to the element on the page that actually did end up consuming it. 134 /// the event and give focus to the element on the page that actually did end
133 /// If you're not getting focus, check to make sure you're returning true from 135 /// up consuming it. If you're not getting focus, check to make sure you're
134 /// the mouse click in HandleInputEvent. 136 /// returning true from the mouse click in <code>HandleInputEvent</code>.
135 /// 137 ///
136 /// @param[in] has_focus Indicates the new focused state of the instance. 138 /// @param[in] has_focus Indicates the new focused state of the instance.
137 virtual void DidChangeFocus(bool has_focus); 139 virtual void DidChangeFocus(bool has_focus);
138 140
139 /// Function for receiving input events from the browser. The default 141 /// HandleInputEvent() handles input events from the browser. The default
140 /// implementation does nothing and returns false. 142 /// implementation does nothing and returns false.
141 /// 143 ///
142 /// In order to receive input events, you must register for them by calling 144 /// In order to receive input events, you must register for them by calling
143 /// RequestInputEvents() or RequestFilteringInputEvents(). By 145 /// RequestInputEvents() or RequestFilteringInputEvents(). By
144 /// default, no events are delivered. 146 /// default, no events are delivered.
145 /// 147 ///
146 /// If the event was handled, it will not be forwarded to the web page or 148 /// If the event was handled, it will not be forwarded to the web page or
147 /// browser. If it was not handled, it will bubble according to the normal 149 /// browser. If it was not handled, it will bubble according to the normal
148 /// rules. So it is important that an instance respond accurately with whether 150 /// rules. So it is important that an instance respond accurately with whether
149 /// event propagation should continue. 151 /// event propagation should continue.
150 /// 152 ///
151 /// Event propagation also controls focus. If you handle an event like a mouse 153 /// Event propagation also controls focus. If you handle an event like a mouse
152 /// event, typically the instance will be given focus. Returning false from 154 /// event, typically the instance will be given focus. Returning false from
153 /// a filtered event handler or not registering for an event type means that 155 /// a filtered event handler or not registering for an event type means that
154 /// the click will be given to a lower part of the page and your instance will 156 /// the click will be given to a lower part of the page and your instance will
155 /// not receive focus. This allows an instance to be partially transparent, 157 /// not receive focus. This allows an instance to be partially transparent,
156 /// where clicks on the transparent areas will behave like clicks to the 158 /// where clicks on the transparent areas will behave like clicks to the
157 /// underlying page. 159 /// underlying page.
158 /// 160 ///
159 /// In general, you should try to keep input event handling short. Especially 161 /// In general, you should try to keep input event handling short. Especially
160 /// for filtered input events, the browser or page may be blocked waiting for 162 /// for filtered input events, the browser or page may be blocked waiting for
161 /// you to respond. 163 /// you to respond.
162 /// 164 ///
163 /// The caller of this function will maintain a reference to the input event 165 /// The caller of this function will maintain a reference to the input event
164 /// resource during this call. Unless you take a reference to the resource 166 /// resource during this call. Unless you take a reference to the resource
165 /// to hold it for later, you don't need to release it. 167 /// to hold it for later, you don't need to release it.
166 /// 168 ///
167 /// \note If you're not receiving input events, make sure you register for the 169 /// <strong>Note: </strong>If you're not receiving input events, make sure
168 /// event classes you want by calling RequestInputEvents or 170 /// you register for the event classes you want by calling
169 /// RequestFilteringInputEvents. If you're still not receiving keyboard input 171 /// <code>RequestInputEvents</code> or
170 /// events, make sure you're returning true (or using a non-filtered event 172 /// <code>RequestFilteringInputEvents</code>. If you're still not receiving
171 /// handler) for mouse events. Otherwise, the instance will not receive focus 173 /// keyboard input events, make sure you're returning true (or using a
172 /// and keyboard events will not be sent. 174 /// non-filtered event handler) for mouse events. Otherwise, the instance will
175 /// not receive focus and keyboard events will not be sent.
173 /// 176 ///
174 /// \see RequestInputEvents and RequestFilteringInputEvents 177 /// Refer to <code>RequestInputEvents</code> and
178 /// <code>RequestFilteringInputEvents</code> for further information.
175 /// 179 ///
176 /// @return true if the event was handled, false if not. If you have 180 /// @return true if the event was handled, false if not. If you have
177 /// registered to filter this class of events by calling 181 /// registered to filter this class of events by calling
178 /// RequestFilteringInputEvents, and you return false, the event will 182 /// <code>RequestFilteringInputEvents</code>, and you return false,
179 /// be forwarded to the page (and eventually the browser) for the default 183 /// the event will be forwarded to the page (and eventually the browser)
180 /// handling. For non-filtered events, the return value will be ignored. 184 /// for the default handling. For non-filtered events, the return value
185 /// will be ignored.
181 virtual bool HandleInputEvent(const pp::InputEvent& event); 186 virtual bool HandleInputEvent(const pp::InputEvent& event);
182 187
183 /// Notification of a data stream available after an instance was created 188 /// HandleDocumentLoad() is called after initialize for a full-frame
dmichael (off chromium) 2011/08/04 17:00:14 initialize->Init() ?
jond 2011/08/04 19:36:38 Done.
jond 2011/08/04 19:36:38 Done.
184 /// based on the MIME type of a DOMWindow navigation. This only applies to 189 /// module that was instantiated based on the MIME type of a DOMWindow
dmichael (off chromium) 2011/08/04 17:00:14 module->instance
jond 2011/08/04 19:36:38 Done.
185 /// modules that are pre-registered to handle certain MIME types. If you 190 /// navigation. This situation only applies to modules that are
186 /// haven't specifically registered to handle a MIME type or aren't positive 191 /// pre-registered to handle certain MIME types. If you haven't specifically
187 /// this applies to you, you can ignore this function. The default 192 /// registered to handle a MIME type or aren't positive this applies to you,
188 /// implementation just returns false. 193 /// your implementation of this function can just return false.
189 /// 194 ///
190 /// The given url_loader corresponds to a URLLoader object that is 195 /// The given url_loader corresponds to a <code>URLLoader</code> object that
191 /// already opened. Its response headers may be queried using GetResponseInfo. 196 /// is already opened. Its response headers may be queried using
192 /// If you want to use the URLLoader to read data, you will need to save a 197 /// GetResponseInfo(). If you want to use the <code>URLLoader</code> to read
193 /// copy of it or the underlying resource will be freed when this function 198 /// data, you will need to save a copy of it or the underlying resource will
194 /// returns and the load will be canceled. 199 /// be freed when this function returns and the load will be canceled.
195 /// 200 ///
196 /// This method returns false if the module cannot handle the data. In 201 /// This method returns false if the module cannot handle the data. In
197 /// response to this method, the module should call ReadResponseBody to read 202 /// response to this method, the module should call ReadResponseBody() to read
198 /// the incoming data. 203 /// the incoming data.
199 /// 204 ///
200 /// @param[in] url_loader A PP_Resource an open PPB_URLLoader instance. 205 /// @param[in] url_loader An open <code>URLLoader</code> instance.
201 /// 206 ///
202 /// @return true if the data was handled, false otherwise. 207 /// @return true if the data was handled, false otherwise.
203 virtual bool HandleDocumentLoad(const URLLoader& url_loader); 208 virtual bool HandleDocumentLoad(const URLLoader& url_loader);
204 209
205 /// HandleMessage() is a function that the browser calls when PostMessage() 210 /// HandleMessage() is a function that the browser calls when PostMessage()
206 /// is invoked on the DOM element for the instance in JavaScript. Note 211 /// is invoked on the DOM element for the instance in JavaScript. Note
207 /// that PostMessage() in the JavaScript interface is asynchronous, meaning 212 /// that PostMessage() in the JavaScript interface is asynchronous, meaning
208 /// JavaScript execution will not be blocked while HandleMessage() is 213 /// JavaScript execution will not be blocked while HandleMessage() is
209 /// processing the message. 214 /// processing the message.
210 /// 215 ///
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 /// will return <code>true</code> and will do nothing. 253 /// will return <code>true</code> and will do nothing.
249 /// 254 ///
250 /// Any previously-bound device will be released. It is an error to bind 255 /// Any previously-bound device will be released. It is an error to bind
251 /// a device when it is already bound to another instance. If you want 256 /// a device when it is already bound to another instance. If you want
252 /// to move a device between instances, first unbind it from the old one, and 257 /// to move a device between instances, first unbind it from the old one, and
253 /// then rebind it to the new one. 258 /// then rebind it to the new one.
254 /// 259 ///
255 /// Binding a device will invalidate that portion of the web page to flush the 260 /// Binding a device will invalidate that portion of the web page to flush the
256 /// contents of the new device to the screen. 261 /// contents of the new device to the screen.
257 /// 262 ///
258 /// @param[in] graphics A Graphics2D object to bind. 263 /// @param[in] graphics A <code>Graphics2D</code> to bind.
259 /// 264 ///
260 /// @return true if bind was successful or false if the device was not the 265 /// @return true if bind was successful or false if the device was not the
261 /// correct type. On success, a reference to the device will be held by the 266 /// correct type. On success, a reference to the device will be held by the
262 /// instance, so the caller can release its reference if it chooses. 267 /// instance, so the caller can release its reference if it chooses.
263 bool BindGraphics(const Graphics2D& graphics); 268 bool BindGraphics(const Graphics2D& graphics);
264 269
265 /// Binds the given Graphics3D as the current display surface. 270 /// Binds the given Graphics3D as the current display surface.
266 /// See BindGraphics(const Graphics2D& graphics). 271 /// See BindGraphics(const Graphics2D& graphics).
267 bool BindGraphics(const Graphics3D_Dev& graphics); 272 bool BindGraphics(const Graphics3D_Dev& graphics);
268 273
269 /// Binds the given Surface3D as the current display surface. 274 /// Binds the given Surface3D as the current display surface.
270 /// See BindGraphics(const Graphics2D& graphics). 275 /// See BindGraphics(const Graphics2D& graphics).
271 bool BindGraphics(const Surface3D_Dev& graphics); 276 bool BindGraphics(const Surface3D_Dev& graphics);
272 277
273 /// IsFullFrame() determines if the instance is full-frame (repr). 278 /// IsFullFrame() determines if the instance is full-frame (repr).
274 /// Such an instance represents the entire document in a frame rather than an 279 /// Such an instance represents the entire document in a frame rather than an
275 /// embedded resource. This can happen if the user does a top-level 280 /// embedded resource. This can happen if the user does a top-level
276 /// navigation or the page specifies an iframe to a resource with a MIME 281 /// navigation or the page specifies an iframe to a resource with a MIME
277 /// type registered by the module. 282 /// type registered by the module.
278 /// 283 ///
279 /// @return True if the instance is full-frame, false if not. 284 /// @return true if the instance is full-frame, false if not.
280 bool IsFullFrame(); 285 bool IsFullFrame();
281 286
282 /// Request that input events corresponding to the given input events are 287 /// RequestInputEvents() requests that input events corresponding to the
283 /// delivered to the instance. 288 /// given input events are delivered to the instance.
284 /// 289 ///
285 /// You can not use this function to request keyboard events 290 /// You can not use this function to request keyboard events
286 /// (PP_INPUTEVENT_CLASS_KEYBOARD). You must use RequestFilteringInputEvents() 291 /// (<code>PP_INPUTEVENT_CLASS_KEYBOARD</code>). You must use
287 /// for this class of input. 292 /// RequestFilteringInputEvents() for this class of input.
dmichael (off chromium) 2011/08/04 17:00:14 Oops, this part is no longer true. Could you remov
jond 2011/08/04 19:36:38 Done.
288 /// 293 ///
289 /// By default, no input events are delivered. Call this function with the 294 /// By default, no input events are delivered. Call this function with the
290 /// classes of events you are interested in to have them be delivered to 295 /// classes of events you are interested in to have them be delivered to
291 /// the instance. Calling this function will override any previous setting for 296 /// the instance. Calling this function will override any previous setting for
292 /// each specified class of input events (for example, if you previously 297 /// each specified class of input events (for example, if you previously
293 /// called RequestFilteringInputEvents(), this function will set those events 298 /// called RequestFilteringInputEvents(), this function will set those events
294 /// to non-filtering mode). 299 /// to non-filtering mode).
295 /// 300 ///
296 /// Input events may have high overhead, so you should only request input 301 /// Input events may have high overhead, so you should only request input
297 /// events that your plugin will actually handle. For example, the browser may 302 /// events that your plugin will actually handle. For example, the browser may
298 /// do optimizations for scroll or touch events that can be processed 303 /// do optimizations for scroll or touch events that can be processed
299 /// substantially faster if it knows there are no non-default receivers for 304 /// substantially faster if it knows there are no non-default receivers for
300 /// that message. Requesting that such messages be delivered, even if they are 305 /// that message. Requesting that such messages be delivered, even if they are
301 /// processed very quickly, may have a noticable effect on the performance of 306 /// processed very quickly, may have a noticable effect on the performance of
302 /// the page. 307 /// the page.
303 /// 308 ///
304 /// When requesting input events through this function, the events will be 309 /// When requesting input events through this function, the events will be
305 /// delivered and <i>not</i> bubbled to the page. This means that even if you 310 /// delivered and not bubbled to the page. This means that even if you
dmichael (off chromium) 2011/08/04 17:00:14 could you leave some kind of emphasis on 'not'? If
jond 2011/08/04 19:36:38 Done.
jond 2011/08/04 19:36:38 Done.
306 /// aren't interested in the message, no other parts of the page will get 311 /// aren't interested in the message, no other parts of the page will get
307 /// a crack at the message. 312 /// a the message.
dmichael (off chromium) 2011/08/04 17:00:14 remove 'a' (Didn't like 'a crack at'? :-p)
jond 2011/08/04 19:36:38 Done.
jond 2011/08/04 19:36:38 Done.
308 /// 313 ///
309 /// Example: 314 /// <strong>Example:</code>
dmichael (off chromium) 2011/08/04 17:00:14 I think you meant </strong>
jond 2011/08/04 19:36:38 Done.
315 ///
316 /// @code
dmichael (off chromium) 2011/08/04 17:00:14 I would rather use <code> everywhere instead of @c
jond 2011/08/04 19:36:38 Let me look into that. Its @code in many other pla
310 /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); 317 /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
311 /// RequestFilteringInputEvents( 318 /// RequestFilteringInputEvents(
312 /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); 319 /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
313 /// 320 ///
314 /// @param event_classes A combination of flags from PP_InputEvent_Class that 321 /// @endcode
dmichael (off chromium) 2011/08/04 17:00:14 </code>
jond 2011/08/04 19:36:38 I'll take "a crack at this" later. ;) On 2011/08/
315 /// identifies the classes of events the instance is requesting. The flags
316 /// are combined by logically ORing their values.
317 /// 322 ///
318 /// @return PP_OK if the operation succeeded, PP_ERROR_BADARGUMENT if instance 323 /// @param event_classes A combination of flags from
319 /// is invalid, or PP_ERROR_NOTSUPPORTED if one of the event class bits were 324 /// <code>PP_InputEvent_Class</code> that identifies the classes of events
325 /// the instance is requesting. The flags are combined by logically ORing
326 /// their values.
327 ///
328 /// @return <code>PP_OK</code> if the operation succeeded,
329 /// <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or
330 /// <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were
320 /// illegal. In the case of an invalid bit, all valid bits will be applied 331 /// illegal. In the case of an invalid bit, all valid bits will be applied
321 /// and only the illegal bits will be ignored. The most common cause of a 332 /// and only the illegal bits will be ignored. The most common cause of a
322 /// PP_ERROR_NOTSUPPORTED return value is requesting keyboard events, these 333 /// <code>PP_ERROR_NOTSUPPORTED</code> return value is requesting keyboard
323 /// must use RequestFilteringInputEvents(). 334 /// events, these must use RequestFilteringInputEvents().
dmichael (off chromium) 2011/08/04 17:00:14 The last sentence is no longer true; please delete
jond 2011/08/04 19:36:38 Done.
jond 2011/08/04 19:36:38 Done.
324 int32_t RequestInputEvents(uint32_t event_classes); 335 int32_t RequestInputEvents(uint32_t event_classes);
325 336
326 /// Request that input events corresponding to the given input events are 337 /// RequestFilteringInputEvents() requests that input events corresponding
327 /// delivered to the instance for filtering. 338 /// to the given input events are delivered to the instance for filtering.
328 /// 339 ///
329 /// By default, no input events are delivered. In most cases you would 340 /// By default, no input events are delivered. In most cases you would
330 /// register to receive events by calling RequestInputEvents(). In some cases, 341 /// register to receive events by calling RequestInputEvents(). In some cases,
331 /// however, you may wish to filter events such that they can be bubbled up 342 /// however, you may wish to filter events such that they can be bubbled up
332 /// to the DOM. In this case, register for those classes of events using 343 /// to the DOM. In this case, register for those classes of events using
333 /// this function instead of RequestInputEvents(). Keyboard events must always 344 /// this function instead of RequestInputEvents(). Keyboard events must always
334 /// be registered in filtering mode. 345 /// be registered in filtering mode.
335 /// 346 ///
336 /// Filtering input events requires significantly more overhead than just 347 /// Filtering input events requires significantly more overhead than just
337 /// delivering them to the instance. As such, you should only request 348 /// delivering them to the instance. As such, you should only request
338 /// filtering in those cases where it's absolutely necessary. The reason is 349 /// filtering in those cases where it's absolutely necessary. The reason is
339 /// that it requires the browser to stop and block for the instance to handle 350 /// that it requires the browser to stop and block for the instance to handle
340 /// the input event, rather than sending the input event asynchronously. This 351 /// the input event, rather than sending the input event asynchronously. This
341 /// can have significant overhead. 352 /// can have significant overhead.
342 /// 353 ///
343 /// Example: 354 /// <strong>Example:</strong>
355 ///
356 /// @code
dmichael (off chromium) 2011/08/04 17:00:14 <code>
jond 2011/08/04 19:36:38 Later man. On 2011/08/04 17:00:14, dmichael wrote
357 ///
344 /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE); 358 /// RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
345 /// RequestFilteringInputEvents( 359 /// RequestFilteringInputEvents(
346 /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD); 360 /// PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_KEYBOARD);
347 /// 361 ///
348 /// @return PP_OK if the operation succeeded, PP_ERROR_BADARGUMENT if instance 362 /// @endcode
dmichael (off chromium) 2011/08/04 17:00:14 </code>
jond 2011/08/04 19:36:38 Later man. On 2011/08/04 17:00:14, dmichael wrote
349 /// is invalid, or PP_ERROR_NOTSUPPORTED if one of the event class bits were 363 ////
364 /// @return <code>PP_OK</code> if the operation succeeded,
365 /// <code>PP_ERROR_BADARGUMENT</code> if instance is invalid, or
366 /// <code>PP_ERROR_NOTSUPPORTED</code> if one of the event class bits were
350 /// illegal. In the case of an invalid bit, all valid bits will be applied 367 /// illegal. In the case of an invalid bit, all valid bits will be applied
351 /// and only the illegal bits will be ignored. 368 /// and only the illegal bits will be ignored.
352 int32_t RequestFilteringInputEvents(uint32_t event_classes); 369 int32_t RequestFilteringInputEvents(uint32_t event_classes);
353 370
354 /// Request that input events corresponding to the given input classes no 371 /// ClearInputEventRequest() requests that input events corresponding to the
355 /// longer be delivered to the instance. 372 /// given input classes no longer be delivered to the instance.
356 /// 373 ///
357 /// By default, no input events are delivered. If you have previously 374 /// By default, no input events are delivered. If you have previously
358 /// requested input events via RequestInputEvents() or 375 /// requested input events using RequestInputEvents() or
359 /// RequestFilteringInputEvents(), this function will unregister handling 376 /// RequestFilteringInputEvents(), this function will unregister handling
360 /// for the given instance. This will allow greater browser performance for 377 /// for the given instance. This will allow greater browser performance for
361 /// those events. 378 /// those events.
362 /// 379 ///
363 /// Note that you may still get some input events after clearing the flag if 380 /// <strong>Note: </strong> You may still get some input events after
364 /// they were dispatched before the request was cleared. For example, if 381 /// clearing the flag if they were dispatched before the request was cleared.
365 /// there are 3 mouse move events waiting to be delivered, and you clear the 382 /// For example, if there are 3 mouse move events waiting to be delivered,
366 /// mouse event class during the processing of the first one, you'll still 383 /// and you clear the mouse event class during the processing of the first
367 /// receive the next two. You just won't get more events generated. 384 /// one, you'll still receive the next two. You just won't get more events
385 /// generated.
368 /// 386 ///
369 /// @param event_classes A combination of flags from PP_InputEvent_Class that 387 /// @param event_classes A combination of flags from
370 /// identifies the classes of events the instance is no longer interested in. 388 /// <code>PP_InputEvent_Class</code> that identifies the classes of events the
389 /// instance is no longer interested in.
371 void ClearInputEventRequest(uint32_t event_classes); 390 void ClearInputEventRequest(uint32_t event_classes);
372 391
373 /// PostMessage() asynchronously invokes any listeners for message events on 392 /// PostMessage() asynchronously invokes any listeners for message events on
374 /// the DOM element for the given instance. A call to PostMessage() will 393 /// the DOM element for the given instance. A call to PostMessage() will
375 // /not block while the message is processed. 394 /// not block while the message is processed.
376 /// 395 ///
377 /// @param[in] message A <code>Var</code> containing the data to be sent to 396 /// @param[in] message A <code>Var</code> containing the data to be sent to
378 /// JavaScript. 397 /// JavaScript.
379 /// Message can have a numeric, boolean, or string value; arrays and 398 /// Message can have a numeric, boolean, or string value; arrays and
380 /// dictionaries are not yet supported. Ref-counted var types are copied, and 399 /// dictionaries are not yet supported. Ref-counted var types are copied, and
381 /// are therefore not shared between the instance and the browser. 400 /// are therefore not shared between the instance and the browser.
382 /// 401 ///
383 /// Listeners for message events in JavaScript code will receive an object 402 /// Listeners for message events in JavaScript code will receive an object
384 /// conforming to the HTML 5 <code>MessageEvent</code> interface. 403 /// conforming to the HTML 5 <code>MessageEvent</code> interface.
385 /// Specifically, the value of message will be contained as a property called 404 /// Specifically, the value of message will be contained as a property called
386 /// data in the received <code>MessageEvent</code>. 405 /// data in the received <code>MessageEvent</code>.
387 /// 406 ///
388 /// This messaging system is similar to the system used for listening for 407 /// This messaging system is similar to the system used for listening for
389 /// messages from Web Workers. Refer to 408 /// messages from Web Workers. Refer to
390 /// <code>http://www.whatwg.org/specs/web-workers/current-work/</code> for 409 /// <code>http://www.whatwg.org/specs/web-workers/current-work/</code> for
391 /// further information. 410 /// further information.
392 /// 411 ///
393 /// @see HandleMessage() for receiving events from JavaScript.
dmichael (off chromium) 2011/08/04 17:00:14 What was wrong with this? I thought it was useful.
jond 2011/08/04 19:36:38 I'll put it back for now. But, I believe that anyt
394 ///
395 /// <strong>Example:</strong> 412 /// <strong>Example:</strong>
396 /// 413 ///
397 /// @code 414 /// @code
398 /// 415 ///
399 /// <body> 416 /// <body>
400 /// <object id="plugin" 417 /// <object id="plugin"
401 /// type="application/x-ppapi-postMessage-example"/> 418 /// type="application/x-ppapi-postMessage-example"/>
402 /// <script type="text/javascript"> 419 /// <script type="text/javascript">
403 /// var plugin = document.getElementById('plugin'); 420 /// var plugin = document.getElementById('plugin');
404 /// plugin.AddEventListener("message", 421 /// plugin.AddEventListener("message",
(...skipping 10 matching lines...) Expand all
415 /// 432 ///
416 /// PostMessage(pp::Var("Hello world!")); 433 /// PostMessage(pp::Var("Hello world!"));
417 /// 434 ///
418 /// @endcode 435 /// @endcode
419 /// 436 ///
420 /// The browser will pop-up an alert saying "Hello world!" 437 /// The browser will pop-up an alert saying "Hello world!"
421 void PostMessage(const Var& message); 438 void PostMessage(const Var& message);
422 439
423 /// @} 440 /// @}
424 441
425 /// Associates a plugin instance with an interface, 442 /// AddPerInstanceObject() associates an instance with an interface,
426 /// creating an object... {PENDING: clarify!} 443 /// creating an object... {PENDING: clarify!}
427 /// 444 ///
428 /// Many optional interfaces are associated with a plugin instance. For 445 /// Many optional interfaces are associated with a plugin instance. For
429 /// example, the find in PPP_Find interface receives updates on a per-instance 446 /// example, the find in PPP_Find interface receives updates on a per-instance
430 /// basis. This "per-instance" tracking allows such objects to associate 447 /// basis. This "per-instance" tracking allows such objects to associate
431 /// themselves with an instance as "the" handler for that interface name. 448 /// themselves with an instance as "the" handler for that interface name.
432 /// 449 ///
433 /// In the case of the find example, the find object registers with its 450 /// In the case of the find example, the find object registers with its
434 /// associated instance in its constructor and unregisters in its destructor. 451 /// associated instance in its constructor and unregisters in its destructor.
435 /// Then whenever it gets updates with a PP_Instance parameter, it can 452 /// Then whenever it gets updates with a PP_Instance parameter, it can
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 typedef std::map<std::string, void*> InterfaceNameToObjectMap; 484 typedef std::map<std::string, void*> InterfaceNameToObjectMap;
468 InterfaceNameToObjectMap interface_name_to_objects_; 485 InterfaceNameToObjectMap interface_name_to_objects_;
469 }; 486 };
470 487
471 } // namespace pp 488 } // namespace pp
472 489
473 /// @} 490 /// @}
474 /// End addtogroup CPP 491 /// End addtogroup CPP
475 492
476 #endif // PPAPI_CPP_INSTANCE_H_ 493 #endif // PPAPI_CPP_INSTANCE_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698