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

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