Bug 942706 - Remove nsIPluginTagInfo and unused associated methods. r=johns.

This commit is contained in:
Henri Sivonen 2013-12-03 10:36:13 +02:00
parent 0859359284
commit c7538c0c16
7 changed files with 70 additions and 331 deletions

View File

@ -14,7 +14,6 @@ XPIDL_SOURCES += [
'nsIPluginInputStream.idl',
'nsIPluginInstanceOwner.idl',
'nsIPluginTag.idl',
'nsIPluginTagInfo.idl',
'nspluginroot.idl',
]

View File

@ -13,6 +13,13 @@ interface nsIDocument;
#include "npapi.h"
#include "mozilla/EventForwards.h"
class nsNPAPIPluginInstance;
enum nsPluginTagType {
nsPluginTagType_Unknown,
nsPluginTagType_Embed,
nsPluginTagType_Object,
nsPluginTagType_Applet
};
%}
[ptr] native nsNPAPIPluginInstancePtr(nsNPAPIPluginInstance);

View File

@ -1,125 +0,0 @@
/* -*- 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"
%{C++
enum nsPluginTagType {
nsPluginTagType_Unknown,
nsPluginTagType_Embed,
nsPluginTagType_Object,
nsPluginTagType_Applet
};
%}
native nsPluginTagType(nsPluginTagType);
interface nsIDOMElement;
/**
* Plugin Tag Info Interface
* This interface provides information about the HTML tag on the page.
* Some day this might get superseded by a DOM API.
*/
[uuid(759a955e-c590-419a-b5f3-e54bb67e24b8)]
interface nsIPluginTagInfo : nsISupports
{
/**
* QueryInterface on nsIPluginInstancePeer to get this.
*
* (Corresponds to NPP_New's argc, argn, and argv arguments.)
* Get a ptr to the paired list of attribute names and values,
* returns the length of the array.
*
* Each name or value is a null-terminated string.
*/
void getAttributes(in PRUint16Ref aCount,
in constCharStarConstStar aNames,
in constCharStarConstStar aValues);
/**
* Gets the value for the named attribute.
*
* @param aName - the name of the attribute to find
* @param aResult - the resulting attribute
* @result - NS_OK if this operation was successful, NS_ERROR_FAILURE if
* this operation failed. result is set to NULL if the attribute is not found
* else to the found value.
*/
void getAttribute(in string aName, out constCharPtr aResult);
/**
* Get the type of the HTML tag that was used ot instantiate this
* plugin. Currently supported tags are EMBED, OBJECT and APPLET.
*/
readonly attribute nsPluginTagType tagType;
/**
* Get a ptr to the paired list of parameter names and values,
* returns the length of the array.
*
* Each name or value is a null-terminated string.
*/
void getParameters(in PRUint16Ref aCount,
in constCharStarConstStar aNames,
in constCharStarConstStar aValues);
/**
* Get the value for the named parameter. Returns null
* if the parameter was not set.
*
* @param aName - name of the parameter
* @param aResult - parameter value
* @result - NS_OK if this operation was successful
*/
void getParameter(in string aName, out constCharPtr aResult);
/**
* Get the document base
*/
void getDocumentBase(out constCharPtr aDocumentBase);
/**
* Return an encoding whose name is specified in:
* http://java.sun.com/products/jdk/1.1/docs/guide/intl/intl.doc.html#25303
*/
void getDocumentEncoding(out constCharPtr aDocumentEncoding);
/**
* Get object alignment
*/
void getAlignment(out constCharPtr aElignment);
/**
* Get object width
*/
readonly attribute unsigned long width;
/**
* Get object height
*/
readonly attribute unsigned long height;
/**
* Get border vertical space
*/
readonly attribute unsigned long borderVertSpace;
/**
* Get border horizontal space
*/
readonly attribute unsigned long borderHorizSpace;
/**
* Returns the DOM element corresponding to the tag which references
* this plugin in the document.
*
* @param aDOMElement - resulting DOM element
* @result - NS_OK if this operation was successful
*/
readonly attribute nsIDOMElement DOMElement;
};

View File

@ -10,7 +10,7 @@
#include "nsTArray.h"
#include "nsPIDOMWindow.h"
#include "nsITimer.h"
#include "nsIPluginTagInfo.h"
#include "nsIPluginInstanceOwner.h"
#include "nsIURI.h"
#include "nsIChannel.h"
#include "nsInterfaceHashtable.h"

View File

@ -147,7 +147,6 @@ static const char *kPluginRegistryVersion = "0.16";
// The minimum registry version we know how to read
static const char *kMinimumRegistryVersion = "0.9";
static NS_DEFINE_IID(kIPluginTagInfoIID, NS_IPLUGINTAGINFO_IID);
static const char kDirectoryServiceContractID[] = "@mozilla.org/file/directory_service;1";
#define kPluginRegistryFilename NS_LITERAL_CSTRING("pluginreg.dat")
@ -788,14 +787,8 @@ nsPluginHost::InstantiatePluginInstance(const char *aMimeType, nsIURI* aURL,
return rv;
}
nsCOMPtr<nsIPluginTagInfo> pti;
rv = instanceOwner->QueryInterface(kIPluginTagInfoIID, getter_AddRefs(pti));
if (NS_FAILED(rv)) {
return rv;
}
nsPluginTagType tagType;
rv = pti->GetTagType(&tagType);
rv = instanceOwner->GetTagType(&tagType);
if (NS_FAILED(rv)) {
return rv;
}

View File

@ -361,9 +361,8 @@ nsPluginInstanceOwner::~nsPluginInstanceOwner()
}
}
NS_IMPL_ISUPPORTS5(nsPluginInstanceOwner,
NS_IMPL_ISUPPORTS4(nsPluginInstanceOwner,
nsIPluginInstanceOwner,
nsIPluginTagInfo,
nsIDOMEventListener,
nsIPrivacyTransitionObserver,
nsISupportsWeakReference)
@ -824,7 +823,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetParameter(const char* name, const char*
{
NS_ENSURE_ARG_POINTER(name);
NS_ENSURE_ARG_POINTER(result);
nsresult rv = EnsureCachedAttrParamArrays();
NS_ENSURE_SUCCESS(rv, rv);
@ -840,195 +839,6 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetParameter(const char* name, const char*
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentBase(const char* *result)
{
NS_ENSURE_ARG_POINTER(result);
nsresult rv = NS_OK;
if (mDocumentBase.IsEmpty()) {
if (!mObjectFrame) {
*result = nullptr;
return NS_ERROR_FAILURE;
}
nsIDocument* doc = mContent->OwnerDoc();
NS_ASSERTION(doc, "Must have an owner doc");
rv = doc->GetDocBaseURI()->GetSpec(mDocumentBase);
}
if (NS_SUCCEEDED(rv))
*result = ToNewCString(mDocumentBase);
return rv;
}
static nsDataHashtable<nsDepCharHashKey, const char *> * gCharsetMap;
typedef struct {
char mozName[16];
char javaName[12];
} moz2javaCharset;
/* XXX If you add any strings longer than
* {"x-mac-cyrillic", "MacCyrillic"},
* {"x-mac-ukrainian", "MacUkraine"},
* to the following array then you MUST update the
* sizes of the arrays in the moz2javaCharset struct
*/
static const moz2javaCharset charsets[] =
{
{"windows-1252", "Cp1252"},
{"IBM850", "Cp850"},
{"IBM852", "Cp852"},
{"IBM855", "Cp855"},
{"IBM857", "Cp857"},
{"IBM828", "Cp862"},
{"IBM866", "Cp866"},
{"windows-1250", "Cp1250"},
{"windows-1251", "Cp1251"},
{"windows-1253", "Cp1253"},
{"windows-1254", "Cp1254"},
{"windows-1255", "Cp1255"},
{"windows-1256", "Cp1256"},
{"windows-1257", "Cp1257"},
{"windows-1258", "Cp1258"},
{"EUC-JP", "EUC_JP"},
{"EUC-KR", "MS949"},
{"x-euc-tw", "EUC_TW"},
{"gb18030", "GB18030"},
{"gbk", "GBK"},
{"ISO-2022-JP", "ISO2022JP"},
{"ISO-2022-KR", "ISO2022KR"},
{"ISO-8859-2", "ISO8859_2"},
{"ISO-8859-3", "ISO8859_3"},
{"ISO-8859-4", "ISO8859_4"},
{"ISO-8859-5", "ISO8859_5"},
{"ISO-8859-6", "ISO8859_6"},
{"ISO-8859-7", "ISO8859_7"},
{"ISO-8859-8", "ISO8859_8"},
{"ISO-8859-9", "ISO8859_9"},
{"ISO-8859-13", "ISO8859_13"},
{"x-johab", "Johab"},
{"KOI8-R", "KOI8_R"},
{"TIS-620", "MS874"},
{"x-mac-arabic", "MacArabic"},
{"x-mac-croatian", "MacCroatia"},
{"x-mac-cyrillic", "MacCyrillic"},
{"x-mac-greek", "MacGreek"},
{"x-mac-hebrew", "MacHebrew"},
{"x-mac-icelandic", "MacIceland"},
{"macintosh", "MacRoman"},
{"x-mac-romanian", "MacRomania"},
{"x-mac-ukrainian", "MacUkraine"},
{"Shift_JIS", "SJIS"},
{"TIS-620", "TIS620"}
};
NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result)
{
NS_ENSURE_ARG_POINTER(result);
*result = nullptr;
nsresult rv;
// XXX sXBL/XBL2 issue: current doc or owner doc?
nsCOMPtr<nsIDocument> doc;
rv = GetDocument(getter_AddRefs(doc));
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get document");
if (NS_FAILED(rv))
return rv;
const nsCString &charset = doc->GetDocumentCharacterSet();
if (charset.IsEmpty())
return NS_OK;
// common charsets and those not requiring conversion first
if (charset.EqualsLiteral("us-ascii")) {
*result = PL_strdup("US_ASCII");
} else if (charset.EqualsLiteral("ISO-8859-1") ||
!nsCRT::strncmp(charset.get(), "UTF", 3)) {
*result = ToNewCString(charset);
} else {
if (!gCharsetMap) {
const int NUM_CHARSETS = sizeof(charsets) / sizeof(moz2javaCharset);
gCharsetMap = new nsDataHashtable<nsDepCharHashKey, const char*>(NUM_CHARSETS);
if (!gCharsetMap)
return NS_ERROR_OUT_OF_MEMORY;
for (uint16_t i = 0; i < NUM_CHARSETS; i++) {
gCharsetMap->Put(charsets[i].mozName, charsets[i].javaName);
}
}
// if found mapping, return it; otherwise return original charset
const char *mapping;
*result = gCharsetMap->Get(charset.get(), &mapping) ? PL_strdup(mapping) :
ToNewCString(charset);
}
return (*result) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetAlignment(const char* *result)
{
return GetAttribute("ALIGN", result);
}
NS_IMETHODIMP nsPluginInstanceOwner::GetWidth(uint32_t *result)
{
NS_ENSURE_ARG_POINTER(result);
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
*result = mPluginWindow->width;
return NS_OK;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetHeight(uint32_t *result)
{
NS_ENSURE_ARG_POINTER(result);
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
*result = mPluginWindow->height;
return NS_OK;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetBorderVertSpace(uint32_t *result)
{
nsresult rv;
const char *vspace;
rv = GetAttribute("VSPACE", &vspace);
if (NS_OK == rv) {
if (*result != 0)
*result = (uint32_t)atol(vspace);
else
*result = 0;
}
else
*result = 0;
return rv;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetBorderHorizSpace(uint32_t *result)
{
nsresult rv;
const char *hspace;
rv = GetAttribute("HSPACE", &hspace);
if (NS_OK == rv) {
if (*result != 0)
*result = (uint32_t)atol(hspace);
else
*result = 0;
}
else
*result = 0;
return rv;
}
// Cache the attributes and/or parameters of our tag into a single set
// of arrays to be compatible with Netscape 4.x. The attributes go first,

View File

@ -11,7 +11,6 @@
#include "npapi.h"
#include "nsCOMPtr.h"
#include "nsIPluginInstanceOwner.h"
#include "nsIPluginTagInfo.h"
#include "nsIPrivacyTransitionObserver.h"
#include "nsIDOMEventListener.h"
#include "nsPluginHost.h"
@ -46,7 +45,6 @@ class gfxXlibSurface;
#endif
class nsPluginInstanceOwner : public nsIPluginInstanceOwner,
public nsIPluginTagInfo,
public nsIDOMEventListener,
public nsIPrivacyTransitionObserver,
public nsSupportsWeakReference
@ -75,8 +73,65 @@ public:
virtual NPError FinalizeAsyncSurface(NPAsyncSurface *surface) MOZ_OVERRIDE;
virtual void SetCurrentAsyncSurface(NPAsyncSurface *surface, NPRect *changed) MOZ_OVERRIDE;
//nsIPluginTagInfo interface
NS_DECL_NSIPLUGINTAGINFO
/**
* Get the type of the HTML tag that was used ot instantiate this
* plugin. Currently supported tags are EMBED, OBJECT and APPLET.
*/
NS_IMETHOD GetTagType(nsPluginTagType *aResult);
/**
* Get a ptr to the paired list of parameter names and values,
* returns the length of the array.
*
* Each name or value is a null-terminated string.
*/
NS_IMETHOD GetParameters(uint16_t& aCount,
const char*const*& aNames,
const char*const*& aValues);
/**
* Get the value for the named parameter. Returns null
* if the parameter was not set.
*
* @param aName - name of the parameter
* @param aResult - parameter value
* @result - NS_OK if this operation was successful
*/
NS_IMETHOD GetParameter(const char* aName, const char* *aResult);
/**
* QueryInterface on nsIPluginInstancePeer to get this.
*
* (Corresponds to NPP_New's argc, argn, and argv arguments.)
* Get a ptr to the paired list of attribute names and values,
* returns the length of the array.
*
* Each name or value is a null-terminated string.
*/
NS_IMETHOD GetAttributes(uint16_t& aCount,
const char*const*& aNames,
const char*const*& aValues);
/**
* Gets the value for the named attribute.
*
* @param aName - the name of the attribute to find
* @param aResult - the resulting attribute
* @result - NS_OK if this operation was successful, NS_ERROR_FAILURE if
* this operation failed. result is set to NULL if the attribute is not found
* else to the found value.
*/
NS_IMETHOD GetAttribute(const char* aName, const char* *aResult);
/**
* Returns the DOM element corresponding to the tag which references
* this plugin in the document.
*
* @param aDOMElement - resulting DOM element
* @result - NS_OK if this operation was successful
*/
NS_IMETHOD GetDOMElement(nsIDOMElement* * aResult);
// nsIDOMEventListener interfaces
NS_DECL_NSIDOMEVENTLISTENER