dom/plugins/test/testplugin/nptest_platform.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* ***** BEGIN LICENSE BLOCK *****
     2  * 
     3  * Copyright (c) 2008, Mozilla Corporation
     4  * All rights reserved.
     5  * 
     6  * Redistribution and use in source and binary forms, with or without
     7  * modification, are permitted provided that the following conditions are met:
     8  * 
     9  * * Redistributions of source code must retain the above copyright notice, this
    10  *   list of conditions and the following disclaimer.
    11  * * Redistributions in binary form must reproduce the above copyright notice,
    12  *   this list of conditions and the following disclaimer in the documentation
    13  *   and/or other materials provided with the distribution.
    14  * * Neither the name of the Mozilla Corporation nor the names of its
    15  *   contributors may be used to endorse or promote products derived from this
    16  *   software without specific prior written permission.
    17  * 
    18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    21  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
    22  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    25  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    28  * 
    29  * Contributor(s):
    30  *   Josh Aas <josh@mozilla.com>
    31  * 
    32  * ***** END LICENSE BLOCK ***** */
    34 #ifndef nptest_platform_h_
    35 #define nptest_platform_h_
    37 #include "nptest.h"
    39 /**
    40  * Returns true if the plugin supports windowed mode
    41  */
    42 bool    pluginSupportsWindowMode();
    44 /**
    45  * Returns true if the plugin supports windowless mode. At least one of
    46  * "pluginSupportsWindowMode" and "pluginSupportsWindowlessMode" must
    47  * return true.
    48  */
    49 bool    pluginSupportsWindowlessMode();
    51 /**
    52  * Returns true if the plugin supports async bitmap drawing.
    53  */
    54 bool    pluginSupportsAsyncBitmapDrawing();
    56 /**
    57  * Returns true if the plugin supports DXGI bitmap drawing.
    58  */
    59 inline bool    pluginSupportsAsyncDXGIDrawing()
    60 {
    61 #ifdef XP_WIN
    62   return true;
    63 #else
    64   return false;
    65 #endif
    66 }
    68 /**
    69  * Initialize the plugin instance. Returning an error here will cause the
    70  * plugin instantiation to fail.
    71  */
    72 NPError pluginInstanceInit(InstanceData* instanceData);
    74 /**
    75  * Shutdown the plugin instance.
    76  */
    77 void    pluginInstanceShutdown(InstanceData* instanceData);
    79 /**
    80  * Set the instanceData's window to newWindow.
    81  */
    82 void    pluginDoSetWindow(InstanceData* instanceData, NPWindow* newWindow);
    84 /**
    85  * Initialize the window for a windowed plugin. oldWindow is the old
    86  * native window value. This will never be called for windowless plugins.
    87  */
    88 void    pluginWidgetInit(InstanceData* instanceData, void* oldWindow);
    90 /**
    91  * Handle an event for a windowless plugin. (Windowed plugins are
    92  * responsible for listening for their own events.)
    93  */
    94 int16_t pluginHandleEvent(InstanceData* instanceData, void* event);
    96 #ifdef XP_WIN
    97 void    pluginDrawAsyncDxgiColor(InstanceData* instanceData);
    98 #endif
   100 enum RectEdge {
   101   EDGE_LEFT = 0,
   102   EDGE_TOP = 1,
   103   EDGE_RIGHT = 2,
   104   EDGE_BOTTOM = 3
   105 };
   107 enum {
   108   NPTEST_INT32_ERROR = 0x7FFFFFFF
   109 };
   111 /**
   112  * Return the coordinate of the given edge of the plugin's area, relative
   113  * to the top-left corner of the toplevel window containing the plugin,
   114  * including window decorations. Only works for window-mode plugins
   115  * and Mac plugins.
   116  * Returns NPTEST_ERROR on error.
   117  */
   118 int32_t pluginGetEdge(InstanceData* instanceData, RectEdge edge);
   120 /**
   121  * Return the number of rectangles in the plugin's clip region. Only
   122  * works for window-mode plugins and Mac plugins.
   123  * Returns NPTEST_ERROR on error.
   124  */
   125 int32_t pluginGetClipRegionRectCount(InstanceData* instanceData);
   127 /**
   128  * Return the coordinate of the given edge of a rectangle in the plugin's
   129  * clip region, relative to the top-left corner of the toplevel window
   130  * containing the plugin, including window decorations. Only works for
   131  * window-mode plugins and Mac plugins.
   132  * Returns NPTEST_ERROR on error.
   133  */
   134 int32_t pluginGetClipRegionRectEdge(InstanceData* instanceData, 
   135     int32_t rectIndex, RectEdge edge);
   137 /**
   138  * Check that the platform-specific plugin state is internally consistent.
   139  * Just return if everything is OK, otherwise append error messages
   140  * to 'error' separated by \n.
   141  */
   142 void pluginDoInternalConsistencyCheck(InstanceData* instanceData, std::string& error);
   144 /**
   145  * Get the current clipboard item as text.  If the clipboard item
   146  * isn't text, the returned value is undefined.
   147  */
   148 std::string pluginGetClipboardText(InstanceData* instanceData);
   150 /**
   151  * Crash while in a nested event loop.  The goal is to catch the
   152  * browser processing the XPCOM event generated from the plugin's
   153  * crash while other plugin code is still on the stack. 
   154  * See https://bugzilla.mozilla.org/show_bug.cgi?id=550026.
   155  */
   156 bool pluginCrashInNestedLoop(InstanceData* instanceData);
   158 /**
   159  * Destroy gfx things that might be shared with the parent process
   160  * when we're run out-of-process.  It's not expected that this
   161  * function will be called when the test plugin is loaded in-process,
   162  * and bad things will happen if it is called.
   163  *
   164  * This call leaves the plugin subprocess in an undefined state.  It
   165  * must not be used after this call or weird things will happen.
   166  */
   167 bool pluginDestroySharedGfxStuff(InstanceData* instanceData);
   169 #endif // nptest_platform_h_

mercurial