michael@0: /* ***** BEGIN LICENSE BLOCK ***** michael@0: * michael@0: * Copyright (c) 2008, Mozilla Corporation michael@0: * All rights reserved. michael@0: * michael@0: * Redistribution and use in source and binary forms, with or without michael@0: * modification, are permitted provided that the following conditions are met: michael@0: * michael@0: * * Redistributions of source code must retain the above copyright notice, this michael@0: * list of conditions and the following disclaimer. michael@0: * * Redistributions in binary form must reproduce the above copyright notice, michael@0: * this list of conditions and the following disclaimer in the documentation michael@0: * and/or other materials provided with the distribution. michael@0: * * Neither the name of the Mozilla Corporation nor the names of its michael@0: * contributors may be used to endorse or promote products derived from this michael@0: * software without specific prior written permission. michael@0: * michael@0: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND michael@0: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED michael@0: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE michael@0: * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR michael@0: * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES michael@0: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; michael@0: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON michael@0: * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT michael@0: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS michael@0: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: * michael@0: * Contributor(s): michael@0: * Josh Aas michael@0: * michael@0: * ***** END LICENSE BLOCK ***** */ michael@0: michael@0: #ifndef nptest_platform_h_ michael@0: #define nptest_platform_h_ michael@0: michael@0: #include "nptest.h" michael@0: michael@0: /** michael@0: * Returns true if the plugin supports windowed mode michael@0: */ michael@0: bool pluginSupportsWindowMode(); michael@0: michael@0: /** michael@0: * Returns true if the plugin supports windowless mode. At least one of michael@0: * "pluginSupportsWindowMode" and "pluginSupportsWindowlessMode" must michael@0: * return true. michael@0: */ michael@0: bool pluginSupportsWindowlessMode(); michael@0: michael@0: /** michael@0: * Returns true if the plugin supports async bitmap drawing. michael@0: */ michael@0: bool pluginSupportsAsyncBitmapDrawing(); michael@0: michael@0: /** michael@0: * Returns true if the plugin supports DXGI bitmap drawing. michael@0: */ michael@0: inline bool pluginSupportsAsyncDXGIDrawing() michael@0: { michael@0: #ifdef XP_WIN michael@0: return true; michael@0: #else michael@0: return false; michael@0: #endif michael@0: } michael@0: michael@0: /** michael@0: * Initialize the plugin instance. Returning an error here will cause the michael@0: * plugin instantiation to fail. michael@0: */ michael@0: NPError pluginInstanceInit(InstanceData* instanceData); michael@0: michael@0: /** michael@0: * Shutdown the plugin instance. michael@0: */ michael@0: void pluginInstanceShutdown(InstanceData* instanceData); michael@0: michael@0: /** michael@0: * Set the instanceData's window to newWindow. michael@0: */ michael@0: void pluginDoSetWindow(InstanceData* instanceData, NPWindow* newWindow); michael@0: michael@0: /** michael@0: * Initialize the window for a windowed plugin. oldWindow is the old michael@0: * native window value. This will never be called for windowless plugins. michael@0: */ michael@0: void pluginWidgetInit(InstanceData* instanceData, void* oldWindow); michael@0: michael@0: /** michael@0: * Handle an event for a windowless plugin. (Windowed plugins are michael@0: * responsible for listening for their own events.) michael@0: */ michael@0: int16_t pluginHandleEvent(InstanceData* instanceData, void* event); michael@0: michael@0: #ifdef XP_WIN michael@0: void pluginDrawAsyncDxgiColor(InstanceData* instanceData); michael@0: #endif michael@0: michael@0: enum RectEdge { michael@0: EDGE_LEFT = 0, michael@0: EDGE_TOP = 1, michael@0: EDGE_RIGHT = 2, michael@0: EDGE_BOTTOM = 3 michael@0: }; michael@0: michael@0: enum { michael@0: NPTEST_INT32_ERROR = 0x7FFFFFFF michael@0: }; michael@0: michael@0: /** michael@0: * Return the coordinate of the given edge of the plugin's area, relative michael@0: * to the top-left corner of the toplevel window containing the plugin, michael@0: * including window decorations. Only works for window-mode plugins michael@0: * and Mac plugins. michael@0: * Returns NPTEST_ERROR on error. michael@0: */ michael@0: int32_t pluginGetEdge(InstanceData* instanceData, RectEdge edge); michael@0: michael@0: /** michael@0: * Return the number of rectangles in the plugin's clip region. Only michael@0: * works for window-mode plugins and Mac plugins. michael@0: * Returns NPTEST_ERROR on error. michael@0: */ michael@0: int32_t pluginGetClipRegionRectCount(InstanceData* instanceData); michael@0: michael@0: /** michael@0: * Return the coordinate of the given edge of a rectangle in the plugin's michael@0: * clip region, relative to the top-left corner of the toplevel window michael@0: * containing the plugin, including window decorations. Only works for michael@0: * window-mode plugins and Mac plugins. michael@0: * Returns NPTEST_ERROR on error. michael@0: */ michael@0: int32_t pluginGetClipRegionRectEdge(InstanceData* instanceData, michael@0: int32_t rectIndex, RectEdge edge); michael@0: michael@0: /** michael@0: * Check that the platform-specific plugin state is internally consistent. michael@0: * Just return if everything is OK, otherwise append error messages michael@0: * to 'error' separated by \n. michael@0: */ michael@0: void pluginDoInternalConsistencyCheck(InstanceData* instanceData, std::string& error); michael@0: michael@0: /** michael@0: * Get the current clipboard item as text. If the clipboard item michael@0: * isn't text, the returned value is undefined. michael@0: */ michael@0: std::string pluginGetClipboardText(InstanceData* instanceData); michael@0: michael@0: /** michael@0: * Crash while in a nested event loop. The goal is to catch the michael@0: * browser processing the XPCOM event generated from the plugin's michael@0: * crash while other plugin code is still on the stack. michael@0: * See https://bugzilla.mozilla.org/show_bug.cgi?id=550026. michael@0: */ michael@0: bool pluginCrashInNestedLoop(InstanceData* instanceData); michael@0: michael@0: /** michael@0: * Destroy gfx things that might be shared with the parent process michael@0: * when we're run out-of-process. It's not expected that this michael@0: * function will be called when the test plugin is loaded in-process, michael@0: * and bad things will happen if it is called. michael@0: * michael@0: * This call leaves the plugin subprocess in an undefined state. It michael@0: * must not be used after this call or weird things will happen. michael@0: */ michael@0: bool pluginDestroySharedGfxStuff(InstanceData* instanceData); michael@0: michael@0: #endif // nptest_platform_h_