dom/plugins/test/testplugin/nptest_platform.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/test/testplugin/nptest_platform.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,169 @@
     1.4 +/* ***** BEGIN LICENSE BLOCK *****
     1.5 + * 
     1.6 + * Copyright (c) 2008, Mozilla Corporation
     1.7 + * All rights reserved.
     1.8 + * 
     1.9 + * Redistribution and use in source and binary forms, with or without
    1.10 + * modification, are permitted provided that the following conditions are met:
    1.11 + * 
    1.12 + * * Redistributions of source code must retain the above copyright notice, this
    1.13 + *   list of conditions and the following disclaimer.
    1.14 + * * Redistributions in binary form must reproduce the above copyright notice,
    1.15 + *   this list of conditions and the following disclaimer in the documentation
    1.16 + *   and/or other materials provided with the distribution.
    1.17 + * * Neither the name of the Mozilla Corporation nor the names of its
    1.18 + *   contributors may be used to endorse or promote products derived from this
    1.19 + *   software without specific prior written permission.
    1.20 + * 
    1.21 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    1.22 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    1.23 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    1.24 + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
    1.25 + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    1.26 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    1.27 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    1.28 + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    1.29 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    1.30 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.31 + * 
    1.32 + * Contributor(s):
    1.33 + *   Josh Aas <josh@mozilla.com>
    1.34 + * 
    1.35 + * ***** END LICENSE BLOCK ***** */
    1.36 +
    1.37 +#ifndef nptest_platform_h_
    1.38 +#define nptest_platform_h_
    1.39 +
    1.40 +#include "nptest.h"
    1.41 +
    1.42 +/**
    1.43 + * Returns true if the plugin supports windowed mode
    1.44 + */
    1.45 +bool    pluginSupportsWindowMode();
    1.46 +
    1.47 +/**
    1.48 + * Returns true if the plugin supports windowless mode. At least one of
    1.49 + * "pluginSupportsWindowMode" and "pluginSupportsWindowlessMode" must
    1.50 + * return true.
    1.51 + */
    1.52 +bool    pluginSupportsWindowlessMode();
    1.53 +
    1.54 +/**
    1.55 + * Returns true if the plugin supports async bitmap drawing.
    1.56 + */
    1.57 +bool    pluginSupportsAsyncBitmapDrawing();
    1.58 +
    1.59 +/**
    1.60 + * Returns true if the plugin supports DXGI bitmap drawing.
    1.61 + */
    1.62 +inline bool    pluginSupportsAsyncDXGIDrawing()
    1.63 +{
    1.64 +#ifdef XP_WIN
    1.65 +  return true;
    1.66 +#else
    1.67 +  return false;
    1.68 +#endif
    1.69 +}
    1.70 +
    1.71 +/**
    1.72 + * Initialize the plugin instance. Returning an error here will cause the
    1.73 + * plugin instantiation to fail.
    1.74 + */
    1.75 +NPError pluginInstanceInit(InstanceData* instanceData);
    1.76 +
    1.77 +/**
    1.78 + * Shutdown the plugin instance.
    1.79 + */
    1.80 +void    pluginInstanceShutdown(InstanceData* instanceData);
    1.81 +
    1.82 +/**
    1.83 + * Set the instanceData's window to newWindow.
    1.84 + */
    1.85 +void    pluginDoSetWindow(InstanceData* instanceData, NPWindow* newWindow);
    1.86 +
    1.87 +/**
    1.88 + * Initialize the window for a windowed plugin. oldWindow is the old
    1.89 + * native window value. This will never be called for windowless plugins.
    1.90 + */
    1.91 +void    pluginWidgetInit(InstanceData* instanceData, void* oldWindow);
    1.92 +
    1.93 +/**
    1.94 + * Handle an event for a windowless plugin. (Windowed plugins are
    1.95 + * responsible for listening for their own events.)
    1.96 + */
    1.97 +int16_t pluginHandleEvent(InstanceData* instanceData, void* event);
    1.98 +
    1.99 +#ifdef XP_WIN
   1.100 +void    pluginDrawAsyncDxgiColor(InstanceData* instanceData);
   1.101 +#endif
   1.102 +
   1.103 +enum RectEdge {
   1.104 +  EDGE_LEFT = 0,
   1.105 +  EDGE_TOP = 1,
   1.106 +  EDGE_RIGHT = 2,
   1.107 +  EDGE_BOTTOM = 3
   1.108 +};
   1.109 +
   1.110 +enum {
   1.111 +  NPTEST_INT32_ERROR = 0x7FFFFFFF
   1.112 +};
   1.113 +
   1.114 +/**
   1.115 + * Return the coordinate of the given edge of the plugin's area, relative
   1.116 + * to the top-left corner of the toplevel window containing the plugin,
   1.117 + * including window decorations. Only works for window-mode plugins
   1.118 + * and Mac plugins.
   1.119 + * Returns NPTEST_ERROR on error.
   1.120 + */
   1.121 +int32_t pluginGetEdge(InstanceData* instanceData, RectEdge edge);
   1.122 +
   1.123 +/**
   1.124 + * Return the number of rectangles in the plugin's clip region. Only
   1.125 + * works for window-mode plugins and Mac plugins.
   1.126 + * Returns NPTEST_ERROR on error.
   1.127 + */
   1.128 +int32_t pluginGetClipRegionRectCount(InstanceData* instanceData);
   1.129 +
   1.130 +/**
   1.131 + * Return the coordinate of the given edge of a rectangle in the plugin's
   1.132 + * clip region, relative to the top-left corner of the toplevel window
   1.133 + * containing the plugin, including window decorations. Only works for
   1.134 + * window-mode plugins and Mac plugins.
   1.135 + * Returns NPTEST_ERROR on error.
   1.136 + */
   1.137 +int32_t pluginGetClipRegionRectEdge(InstanceData* instanceData, 
   1.138 +    int32_t rectIndex, RectEdge edge);
   1.139 +
   1.140 +/**
   1.141 + * Check that the platform-specific plugin state is internally consistent.
   1.142 + * Just return if everything is OK, otherwise append error messages
   1.143 + * to 'error' separated by \n.
   1.144 + */
   1.145 +void pluginDoInternalConsistencyCheck(InstanceData* instanceData, std::string& error);
   1.146 +
   1.147 +/**
   1.148 + * Get the current clipboard item as text.  If the clipboard item
   1.149 + * isn't text, the returned value is undefined.
   1.150 + */
   1.151 +std::string pluginGetClipboardText(InstanceData* instanceData);
   1.152 +
   1.153 +/**
   1.154 + * Crash while in a nested event loop.  The goal is to catch the
   1.155 + * browser processing the XPCOM event generated from the plugin's
   1.156 + * crash while other plugin code is still on the stack. 
   1.157 + * See https://bugzilla.mozilla.org/show_bug.cgi?id=550026.
   1.158 + */
   1.159 +bool pluginCrashInNestedLoop(InstanceData* instanceData);
   1.160 +
   1.161 +/**
   1.162 + * Destroy gfx things that might be shared with the parent process
   1.163 + * when we're run out-of-process.  It's not expected that this
   1.164 + * function will be called when the test plugin is loaded in-process,
   1.165 + * and bad things will happen if it is called.
   1.166 + *
   1.167 + * This call leaves the plugin subprocess in an undefined state.  It
   1.168 + * must not be used after this call or weird things will happen.
   1.169 + */
   1.170 +bool pluginDestroySharedGfxStuff(InstanceData* instanceData);
   1.171 +
   1.172 +#endif // nptest_platform_h_

mercurial