/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"
#include "nspluginroot.idl"
#include "nsIInputStream.idl"

interface nsIDocument;

%{C++
#include "npapi.h"
#include "mozilla/EventForwards.h"
class nsNPAPIPluginInstance;

enum nsPluginTagType {
  nsPluginTagType_Unknown,
  nsPluginTagType_Embed,
  nsPluginTagType_Object,
  nsPluginTagType_Applet
};
%}

[ptr] native nsNPAPIPluginInstancePtr(nsNPAPIPluginInstance);

// Do not make this interface scriptable, because the virtual functions in C++
// blocks will make script call the wrong functions.
[uuid(59BE4CA5-3CB0-40E6-A111-9A88C8477610)]
interface nsIPluginInstanceOwner : nsISupports
{
  /**
   * Let the owner know what its instance is
   */
  void setInstance(in nsNPAPIPluginInstancePtr aInstance);

  /**
   * Get the instance associated with this owner.
   */
  nsNPAPIPluginInstancePtr getInstance();

  /**
   * Get a handle to the window structure of the owner.
   * This pointer cannot be made persistent by the caller.
   */
  void getWindow(in NPWindowStarRef aWindow);

  /**
   * Get the display mode for the plugin instance.
   */
  readonly attribute int32_t mode;

  /**
   * Create a place for the plugin to live in the owner's
   * environment. this may or may not create a window
   * depending on the windowless state of the plugin instance.
   */
  void createWidget();

%{C++
  /**
   * Called when there is a valid target so that the proper
   * frame can be updated with new content. will not be called
   * with nullptr aTarget.
   */
  NS_IMETHOD
  GetURL(const char *aURL, const char *aTarget, 
         nsIInputStream *aPostStream,
         void *aHeadersData, uint32_t aHeadersDataLen) = 0;
%}

  /**
   * Show a status message in the host environment.
   */
  void showStatus(in string aStatusMsg);

%{C++
  NS_IMETHOD ShowStatus(const char16_t *aStatusMsg) = 0;
%}

  /**
   * Get the associated document.
   */
  readonly attribute nsIDocument document;

  /**
   * Invalidate the rectangle
   */
  void invalidateRect(in NPRectPtr aRect);

  /**
   * Invalidate the region
   */
  void invalidateRegion(in NPRegion aRegion);

  /**
   * Have the plugin recomposited.
   */
  void redrawPlugin();

  /**
   * Get NetscapeWindow, corresponds to NPNVnetscapeWindow
   */
  void getNetscapeWindow(in voidPtr aValue);

  /**
   * Show native context menu
   */
%{C++
  virtual NPError ShowNativeContextMenu(NPMenu* menu, void* event) = 0;
  virtual NPBool  ConvertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
                               double *destX, double *destY, NPCoordinateSpace destSpace) = 0;
  virtual NPError InitAsyncSurface(NPSize *size, NPImageFormat format,
                                   void *initData, NPAsyncSurface *surface) = 0;
  virtual NPError FinalizeAsyncSurface(NPAsyncSurface *surface) = 0;
  virtual void SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed) = 0;
%}

  void setEventModel(in int32_t eventModel);

  /**
   * Call NPP_SetWindow on the plugin.
   */
  void callSetWindow();

  /**
   * Get the contents scale factor for the screen the plugin is
   * drawn on.
   */
  double getContentsScaleFactor();
};
