Chromium Code Reviews| 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 | 5 |
| 6 /** | 6 /** |
| 7 * Defines the <code>PPB_View</code> struct representing the state of the | 7 * This file defines the <code>PPB_View</code> struct representing the state |
| 8 * view of an instance. | 8 * of the view of an instance. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 label Chrome { | 11 label Chrome { |
| 12 M18 = 1.0 | 12 M18 = 1.0 |
| 13 }; | 13 }; |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * <code>PPB_View</code> represents the state of the view of an instance. | 16 * <code>PPB_View</code> represents the state of the view of an instance. |
| 17 * You will receive new view information via | 17 * You will receive new view information using |
| 18 * <code>PPP_Instance.DidChangeView</code>. | 18 * <code>PPP_Instance.DidChangeView</code>. |
| 19 */ | 19 */ |
| 20 [macro="PPB_VIEW_INTERFACE"] | 20 [macro="PPB_VIEW_INTERFACE"] |
| 21 interface PPB_View { | 21 interface PPB_View { |
| 22 /** | 22 /** |
| 23 * <code>IsView()</code> determines if the given resource is a valid | 23 * IsView() determines if the given resource is a valid |
| 24 * <code>PPB_View</code> resource. Note that <code>PPB_ViewChanged</code> | 24 * <code>PPB_View</code> resource. Note that <code>PPB_ViewChanged</code> |
| 25 * resources derive from <code>PPB_View</code> and will return true here | 25 * resources derive from <code>PPB_View</code> and will return true here |
| 26 * as well. | 26 * as well. |
| 27 * | 27 * |
| 28 * @param resource A <code>PP_Resource</code> corresponding to a | |
| 29 * <code>PPB_View</code> resource. | |
| 30 * | |
| 28 * @return <code>PP_TRUE</code> if the given resource supports | 31 * @return <code>PP_TRUE</code> if the given resource supports |
| 29 * <code>PPB_View</code> or <code>PP_FALSE</code> if it is an invalid | 32 * <code>PPB_View</code> or <code>PP_FALSE</code> if it is an invalid |
| 30 * resource or is a resource of another type. | 33 * resource or is a resource of another type. |
| 31 */ | 34 */ |
| 32 PP_Bool IsView([in] PP_Resource resource); | 35 PP_Bool IsView([in] PP_Resource resource); |
| 33 | 36 |
| 34 /** | 37 /** |
| 35 * <code>GetRect()</code> retrieves the rectangle of the instance | 38 * GetRect() retrieves the rectangle of the module instance associated |
| 36 * associated with the view changed notification relative to the upper left | 39 * with a view changed notification relative to the upper-left of the browser |
| 37 * of the browser viewport. This position changes when the page is scrolled. | 40 * viewport. This position changes when the page is scrolled. |
| 38 * | 41 * |
| 39 * The returned rectangle may not be inside the visible portion of the | 42 * The returned rectangle may not be inside the visible portion of the |
| 40 * viewport if the instance is scrolled off the page. Therefore, the position | 43 * viewport if the module instance is scrolled off the page. Therefore, the |
| 41 * may be negative or larger than the size of the page. The size will always | 44 * position may be negative or larger than the size of the page. The size will |
| 42 * reflect the size of the plugin were it to be scrolled entirely into view. | 45 * always reflect the size of the module were it to be scrolled entirely into |
| 46 * view. | |
| 43 * | 47 * |
| 44 * In general, most plugins will not need to worry about the position of the | 48 * In general, most modules will not need to worry about the position of the |
| 45 * instance in the viewport, and only need to use the size. | 49 * module instance in the viewport, and only need to use the size. |
| 46 * | 50 * |
| 47 * @param rect Output argument receiving the rectangle on success. | 51 * @param resource A <code>PP_Resource</code> corresponding to a |
| 52 * <code>PPB_View</code> resource. | |
| 53 * | |
| 54 * @param rect A <code>PP_Rect</code> receiving the rectangle on success. | |
| 48 * | 55 * |
| 49 * @return Returns <code>PP_TRUE</code> if the resource was valid and the | 56 * @return Returns <code>PP_TRUE</code> if the resource was valid and the |
| 50 * viewport rect was filled in, <code>PP_FALSE</code> if not. | 57 * viewport rectangle was filled in, <code>PP_FALSE</code> if not. |
| 51 */ | 58 */ |
| 52 PP_Bool GetRect([in] PP_Resource resource, | 59 PP_Bool GetRect([in] PP_Resource resource, |
| 53 [out] PP_Rect rect); | 60 [out] PP_Rect rect); |
| 54 | 61 |
| 55 /** | 62 /** |
| 56 * <code>IsFullscreen()</code> returns whether the instance is currently | 63 * IsFullscreen() returns whether the instance is currently |
| 57 * displaying in fullscreen mode. | 64 * displaying in fullscreen mode. |
| 58 * | 65 * |
| 66 * @param resource A <code>PP_Resource</code> corresponding to a | |
| 67 * <code>PPB_View</code> resource. | |
| 68 * | |
| 59 * @return <code>PP_TRUE</code> if the instance is in full screen mode, | 69 * @return <code>PP_TRUE</code> if the instance is in full screen mode, |
| 60 * or <code>PP_FALSE</code> if it's not or the resource is invalid. | 70 * or <code>PP_FALSE</code> if it's not or the resource is invalid. |
| 61 */ | 71 */ |
| 62 PP_Bool IsFullscreen([in] PP_Resource resource); | 72 PP_Bool IsFullscreen([in] PP_Resource resource); |
| 63 | 73 |
| 64 /** | 74 /** |
| 65 * <code>IsVisible()</code> returns whether the instance is plausibly | 75 * IsVisible() determines whether the module instance is visible to the user. |
|
brettw
2012/02/15 20:39:35
The plausibly part is important here, though maybe
jond
2012/02/16 20:43:21
Done.
| |
| 66 * visible to the user. You should use this flag to throttle or stop updates | 76 * Use the result to speed up or stop updates for invisible module instances. |
| 67 * for invisible plugins. | |
| 68 * | 77 * |
| 69 * Thie measure incorporates both whether the instance is scrolled into | 78 * This functions performs the duties of GetRect() (determining whether the |
| 70 * view (whether the clip rect is nonempty) and whether the page is plausibly | 79 * module instance is scrolled into view and the clip rectangle is nonempty) |
| 71 * visible to the user (<code>IsPageVisible()</code>). | 80 * and IsPageVisible() (whether the page is visible to the user). |
| 81 * | |
| 82 * @param resource A <code>PP_Resource</code> corresponding to a | |
| 83 * <code>PPB_View</code> resource. | |
| 72 * | 84 * |
| 73 * @return <code>PP_TRUE</code> if the instance is plausibly visible to the | 85 * @return <code>PP_TRUE</code> if the instance is plausibly visible to the |
| 74 * user, <code>PP_FALSE</code> if it is definitely not visible. | 86 * user, <code>PP_FALSE</code> if it is definitely not visible. |
| 75 */ | 87 */ |
| 76 PP_Bool IsVisible([in] PP_Resource resource); | 88 PP_Bool IsVisible([in] PP_Resource resource); |
| 77 | 89 |
| 78 /** | 90 /** |
| 79 * <code>IsPageVisible()</code> determines if the page that contains the | 91 * IsPageVisible() determines if the page that contains the module instance |
| 80 * instance is visible. The most common cause of invisible pages is that | 92 * is visible. The most common cause of invisible pages is that |
| 81 * the page is in a background tab in the browser. | 93 * the page is in a background tab in the browser. |
| 82 * | 94 * |
| 83 * Most applications should use <code>IsVisible()</code> rather than | 95 * Most applications should use IsVisible() instead of this function since |
| 84 * this function since the instance could be scrolled off of a visible | 96 * the module instance could be scrolled off of a visible page, and this |
| 85 * page, and this function will still return true. However, depending on | 97 * function will still return true. However, depending on how your module |
| 86 * how your plugin interacts with the page, there may be certain updates | 98 * interacts with the page, there may be certain updates that you may want to |
| 87 * that you may want to perform when the page is visible even if your | 99 * perform when the page is visible even if your specific module instance is |
| 88 * specific instance isn't. | 100 * not visible. |
| 101 * | |
| 102 * @param resource A <code>PP_Resource</code> corresponding to a | |
| 103 * <code>PPB_View</code> resource. | |
| 89 * | 104 * |
| 90 * @return <code>PP_TRUE</code> if the instance is plausibly visible to the | 105 * @return <code>PP_TRUE</code> if the instance is plausibly visible to the |
| 91 * user, <code>PP_FALSE</code> if it is definitely not visible. | 106 * user, <code>PP_FALSE</code> if it is definitely not visible. |
| 92 */ | 107 */ |
| 93 PP_Bool IsPageVisible([in] PP_Resource resource); | 108 PP_Bool IsPageVisible([in] PP_Resource resource); |
| 94 | 109 |
| 95 /** | 110 /** |
| 96 * <code>GetClipRect()</code> returns the clip rectangle relative to the | 111 * GetClipRect() returns the clip rectangle relative to the upper-left corner |
| 97 * upper left corner of the instance. This rectangle indicates which parts of | 112 * of the module instance. This rectangle indicates the portions of the module |
| 98 * the instance are scrolled into view. | 113 * instance that are scrolled into view. |
| 99 * | 114 * |
| 100 * If the instance is scrolled off the view, the return value will be | 115 * If the module instance is scrolled off the view, the return value will be |
| 101 * (0, 0, 0, 0). This clip rect does <i>not</i> take into account page | 116 * (0, 0, 0, 0). This clip rectangle does <i>not</i> take into account page |
| 102 * visibility. This means if the instance is scrolled into view but the page | 117 * visibility. This means if the module instance is scrolled into view, but |
| 103 * itself is in an invisible tab, the return rect will contain the visible | 118 * the page itself is in an invisible tab, the return rectangle will contain |
| 104 * rect assuming the page was visible. See <code>IsPageVisible()</code> and | 119 * the visible rectangle (assuming the page was visible). Refer to |
|
brettw
2012/02/15 20:39:35
I think this was better without the parens. The "a
jond
2012/02/16 20:43:21
Done.
| |
| 105 * <code>IsVisible()</code> if you want to handle this case. | 120 * IsPageVisible() and IsVisible() if you want to handle this case. |
| 106 * | 121 * |
| 107 * Most applications will not need to worry about the clip. The recommended | 122 * Most applications will not need to worry about the clip rectangle. The |
| 108 * behavior is to do full updates if the instance is visible as determined by | 123 * recommended behavior is to do full updates if the module instance is |
| 109 * <code>IsVisible()</code> and do no updates if not. | 124 * visible, as determined by IsVisible(), and do no updates if it is not |
| 125 * visible. | |
| 110 * | 126 * |
| 111 * However, if the cost for computing pixels is very high for your | 127 * However, if the cost for computing pixels is very high for your |
| 112 * application or the pages you're targeting frequently have very large | 128 * application, or the pages you're targeting frequently have very large |
| 113 * instances with small visible portions, you may wish to optimize further. | 129 * module instances with small visible portions, you may wish to optimize |
| 114 * In this case, the clip rect will tell you which parts of the plugin to | 130 * further. In this case, the clip rectangle will tell you which parts of |
| 115 * update. | 131 * the module to update. |
| 116 * | 132 * |
| 117 * Note that painting of the page and sending of view changed updates | 133 * Note that painting of the page and sending of view changed updates |
| 118 * happens asynchronously. This means when the user scrolls, for example, | 134 * happens asynchronously. This means when the user scrolls, for example, |
| 119 * it is likely that the previous backing store of the instance will be used | 135 * it is likely that the previous backing store of the module instance will |
| 120 * for the first paint, and will be updated later when your application | 136 * be used for the first paint, and will be updated later when your applicatio n |
|
brettw
2012/02/15 20:39:35
80 cols.
jond
2012/02/16 20:43:21
Done.
| |
| 121 * generates new content with the new clip. This may cause flickering at the | 137 * generates new content with the new clip. This may cause flickering at the |
| 122 * boundaries when scrolling. If you do choose to do partial updates, you may | 138 * boundaries when scrolling. If you do choose to do partial updates, you may |
| 123 * want to think about what color the invisible portions of your backing | 139 * want to think about what color the invisible portions of your backing |
| 124 * store contain (be it transparent or some background color) or to paint | 140 * store contain (be it transparent or some background color) or to paint |
| 125 * a certain region outside the clip to reduce the visual distraction when | 141 * a certain region outside the clip to reduce the visual distraction when |
| 126 * this happens. | 142 * this happens. |
| 127 * | 143 * |
| 144 * @param resource A <code>PP_Resource</code> corresponding to a | |
| 145 * <code>PPB_View</code> resource. | |
| 146 * | |
| 128 * @param clip Output argument receiving the clip rect on success. | 147 * @param clip Output argument receiving the clip rect on success. |
| 129 * | 148 * |
| 130 * @return Returns <code>PP_TRUE</code> if the resource was valid and the | 149 * @return Returns <code>PP_TRUE</code> if the resource was valid and the |
| 131 * clip rect was filled in, <code>PP_FALSE</code> if not. | 150 * clip rect was filled in, <code>PP_FALSE</code> if not. |
| 132 */ | 151 */ |
| 133 PP_Bool GetClipRect([in] PP_Resource resource, | 152 PP_Bool GetClipRect([in] PP_Resource resource, |
| 134 [out] PP_Rect clip); | 153 [out] PP_Rect clip); |
| 135 }; | 154 }; |
| 136 | 155 |
| OLD | NEW |