mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 853995 - Move plugin parameters array from nsPluginInstanceOwner to content. r=johns,jst
This commit is contained in:
parent
b364e001aa
commit
e92b05a6af
@ -12,6 +12,7 @@
|
||||
// Interface headers
|
||||
#include "imgLoader.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentInlines.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMCustomEvent.h"
|
||||
@ -82,6 +83,7 @@
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventStates.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/dom/HTMLObjectElementBinding.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
// Thanks so much, Microsoft! :(
|
||||
@ -915,6 +917,167 @@ nsObjectLoadingContent::InstantiatePluginInstance(bool aIsLoading)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsObjectLoadingContent::GetPluginAttributes(nsTArray<MozPluginParameter>& aAttributes)
|
||||
{
|
||||
aAttributes = mCachedAttributes;
|
||||
}
|
||||
|
||||
void
|
||||
nsObjectLoadingContent::GetPluginParameters(nsTArray<MozPluginParameter>& aParameters)
|
||||
{
|
||||
aParameters = mCachedParameters;
|
||||
}
|
||||
|
||||
void
|
||||
nsObjectLoadingContent::GetNestedParams(nsTArray<MozPluginParameter>& aParams,
|
||||
bool aIgnoreCodebase)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> domElement =
|
||||
do_QueryInterface(static_cast<nsIObjectLoadingContent*>(this));
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> allParams;
|
||||
NS_NAMED_LITERAL_STRING(xhtml_ns, "http://www.w3.org/1999/xhtml");
|
||||
domElement->GetElementsByTagNameNS(xhtml_ns,
|
||||
NS_LITERAL_STRING("param"), getter_AddRefs(allParams));
|
||||
|
||||
if (!allParams)
|
||||
return;
|
||||
|
||||
uint32_t numAllParams;
|
||||
allParams->GetLength(&numAllParams);
|
||||
for (uint32_t i = 0; i < numAllParams; i++) {
|
||||
nsCOMPtr<nsIDOMNode> pNode;
|
||||
allParams->Item(i, getter_AddRefs(pNode));
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(pNode);
|
||||
|
||||
if (!element)
|
||||
continue;
|
||||
|
||||
nsAutoString name;
|
||||
element->GetAttribute(NS_LITERAL_STRING("name"), name);
|
||||
|
||||
if (name.IsEmpty())
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
nsCOMPtr<nsIDOMHTMLObjectElement> domObject;
|
||||
nsCOMPtr<nsIDOMHTMLAppletElement> domApplet;
|
||||
pNode->GetParentNode(getter_AddRefs(parent));
|
||||
while (!(domObject || domApplet) && parent) {
|
||||
domObject = do_QueryInterface(parent);
|
||||
domApplet = do_QueryInterface(parent);
|
||||
nsCOMPtr<nsIDOMNode> temp;
|
||||
parent->GetParentNode(getter_AddRefs(temp));
|
||||
parent = temp;
|
||||
}
|
||||
|
||||
if (domApplet) {
|
||||
parent = do_QueryInterface(domApplet);
|
||||
} else if (domObject) {
|
||||
parent = do_QueryInterface(domObject);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(domElement);
|
||||
if (parent == domNode) {
|
||||
MozPluginParameter param;
|
||||
element->GetAttribute(NS_LITERAL_STRING("name"), param.mName);
|
||||
element->GetAttribute(NS_LITERAL_STRING("value"), param.mValue);
|
||||
|
||||
param.mName.Trim(" \n\r\t\b", true, true, false);
|
||||
param.mValue.Trim(" \n\r\t\b", true, true, false);
|
||||
|
||||
// ignore codebase param if it was already added in the attributes array.
|
||||
if (aIgnoreCodebase && param.mName.EqualsIgnoreCase("codebase")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
aParams.AppendElement(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsObjectLoadingContent::BuildParametersArray()
|
||||
{
|
||||
if (mCachedAttributes.Length() || mCachedParameters.Length()) {
|
||||
MOZ_ASSERT(false, "Parameters array should be empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> content =
|
||||
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
||||
|
||||
int32_t start = 0, end = content->GetAttrCount(), step = 1;
|
||||
// HTML attributes are stored in reverse order.
|
||||
if (content->IsHTML() && content->IsInHTMLDocument()) {
|
||||
start = end - 1;
|
||||
end = -1;
|
||||
step = -1;
|
||||
}
|
||||
|
||||
for (int32_t i = start; i != end; i += step) {
|
||||
MozPluginParameter param;
|
||||
const nsAttrName* attrName = content->GetAttrNameAt(i);
|
||||
nsIAtom* atom = attrName->LocalName();
|
||||
content->GetAttr(attrName->NamespaceID(), atom, param.mValue);
|
||||
atom->ToString(param.mName);
|
||||
mCachedAttributes.AppendElement(param);
|
||||
}
|
||||
|
||||
bool isJava = nsPluginHost::IsJavaMIMEType(mContentType.get());
|
||||
|
||||
nsCString codebase;
|
||||
if (isJava) {
|
||||
mBaseURI->GetSpec(codebase);
|
||||
}
|
||||
|
||||
nsAdoptingCString wmodeOverride = Preferences::GetCString("plugins.force.wmode");
|
||||
|
||||
for (uint32_t i = 0; i < mCachedAttributes.Length(); i++) {
|
||||
if (!wmodeOverride.IsEmpty() && mCachedAttributes[i].mName.EqualsIgnoreCase("wmode")) {
|
||||
CopyASCIItoUTF16(wmodeOverride, mCachedAttributes[i].mValue);
|
||||
wmodeOverride.Truncate();
|
||||
} else if (!codebase.IsEmpty() && mCachedAttributes[i].mName.EqualsIgnoreCase("codebase")) {
|
||||
CopyASCIItoUTF16(codebase, mCachedAttributes[i].mValue);
|
||||
codebase.Truncate();
|
||||
}
|
||||
}
|
||||
|
||||
if (!wmodeOverride.IsEmpty()) {
|
||||
MozPluginParameter param;
|
||||
param.mName = NS_LITERAL_STRING("wmode");
|
||||
CopyASCIItoUTF16(wmodeOverride, param.mValue);
|
||||
mCachedAttributes.AppendElement(param);
|
||||
}
|
||||
|
||||
if (!codebase.IsEmpty()) {
|
||||
MozPluginParameter param;
|
||||
param.mName = NS_LITERAL_STRING("codebase");
|
||||
CopyASCIItoUTF16(codebase, param.mValue);
|
||||
mCachedAttributes.AppendElement(param);
|
||||
}
|
||||
|
||||
// Some plugins were never written to understand the "data" attribute of the OBJECT tag.
|
||||
// Real and WMP will not play unless they find a "src" attribute, see bug 152334.
|
||||
// Nav 4.x would simply replace the "data" with "src". Because some plugins correctly
|
||||
// look for "data", lets instead copy the "data" attribute and add another entry
|
||||
// to the bottom of the array if there isn't already a "src" specified.
|
||||
if (content->Tag() == nsGkAtoms::object &&
|
||||
!content->HasAttr(kNameSpaceID_None, nsGkAtoms::src)) {
|
||||
MozPluginParameter param;
|
||||
content->GetAttr(kNameSpaceID_None, nsGkAtoms::data, param.mValue);
|
||||
if (!param.mValue.IsEmpty()) {
|
||||
param.mName = NS_LITERAL_STRING("SRC");
|
||||
mCachedAttributes.AppendElement(param);
|
||||
}
|
||||
}
|
||||
|
||||
GetNestedParams(mCachedParameters, isJava);
|
||||
}
|
||||
|
||||
void
|
||||
nsObjectLoadingContent::NotifyOwnerDocumentActivityChanged()
|
||||
{
|
||||
@ -1502,59 +1665,15 @@ nsObjectLoadingContent::UpdateObjectParameters(bool aJavaURI)
|
||||
|
||||
|
||||
// Java wants the codebase attribute even if it occurs in <param> tags
|
||||
// XXX(johns): This duplicates a chunk of code from nsInstanceOwner, see
|
||||
// bug 853995
|
||||
if (isJava) {
|
||||
// Find all <param> tags that are nested beneath us, but not beneath another
|
||||
// object/applet tag.
|
||||
nsCOMArray<nsIDOMElement> ourParams;
|
||||
nsCOMPtr<nsIDOMElement> mydomElement = do_QueryInterface(thisContent);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> allParams;
|
||||
NS_NAMED_LITERAL_STRING(xhtml_ns, "http://www.w3.org/1999/xhtml");
|
||||
mydomElement->GetElementsByTagNameNS(xhtml_ns, NS_LITERAL_STRING("param"),
|
||||
getter_AddRefs(allParams));
|
||||
if (allParams) {
|
||||
uint32_t numAllParams;
|
||||
allParams->GetLength(&numAllParams);
|
||||
for (uint32_t i = 0; i < numAllParams; i++) {
|
||||
nsCOMPtr<nsIDOMNode> pnode;
|
||||
allParams->Item(i, getter_AddRefs(pnode));
|
||||
nsCOMPtr<nsIDOMElement> domelement = do_QueryInterface(pnode);
|
||||
if (domelement) {
|
||||
nsAutoString name;
|
||||
domelement->GetAttribute(NS_LITERAL_STRING("name"), name);
|
||||
name.Trim(" \n\r\t\b", true, true, false);
|
||||
if (name.EqualsIgnoreCase("codebase")) {
|
||||
// Find the first plugin element parent
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
nsCOMPtr<nsIDOMHTMLObjectElement> domobject;
|
||||
nsCOMPtr<nsIDOMHTMLAppletElement> domapplet;
|
||||
pnode->GetParentNode(getter_AddRefs(parent));
|
||||
while (!(domobject || domapplet) && parent) {
|
||||
domobject = do_QueryInterface(parent);
|
||||
domapplet = do_QueryInterface(parent);
|
||||
nsCOMPtr<nsIDOMNode> temp;
|
||||
parent->GetParentNode(getter_AddRefs(temp));
|
||||
parent = temp;
|
||||
}
|
||||
if (domapplet || domobject) {
|
||||
if (domapplet) {
|
||||
parent = do_QueryInterface(domapplet);
|
||||
}
|
||||
else {
|
||||
parent = do_QueryInterface(domobject);
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> mydomNode = do_QueryInterface(mydomElement);
|
||||
if (parent == mydomNode) {
|
||||
hasCodebase = true;
|
||||
domelement->GetAttribute(NS_LITERAL_STRING("value"),
|
||||
codebaseStr);
|
||||
codebaseStr.Trim(" \n\r\t\b", true, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nsTArray<MozPluginParameter> params;
|
||||
GetNestedParams(params, false);
|
||||
for (uint32_t i = 0; i < params.Length(); i++) {
|
||||
if (params[i].mName.EqualsIgnoreCase("codebase")) {
|
||||
hasCodebase = true;
|
||||
codebaseStr = params[i].mValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2121,6 +2240,12 @@ nsObjectLoadingContent::LoadObject(bool aNotify,
|
||||
/// Attempt to load new type
|
||||
///
|
||||
|
||||
|
||||
// Cache the current attributes and parameters.
|
||||
if (mType == eType_Plugin || mType == eType_Null) {
|
||||
BuildParametersArray();
|
||||
}
|
||||
|
||||
// We don't set mFinalListener until OnStartRequest has been called, to
|
||||
// prevent re-entry ugliness with CloseChannel()
|
||||
nsCOMPtr<nsIStreamListener> finalListener;
|
||||
@ -2477,6 +2602,9 @@ nsObjectLoadingContent::UnloadObject(bool aResetState)
|
||||
mIsStopping = false;
|
||||
}
|
||||
|
||||
mCachedAttributes.Clear();
|
||||
mCachedParameters.Clear();
|
||||
|
||||
// This call should be last as it may re-enter
|
||||
StopPluginInstance();
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ class nsPluginInstanceOwner;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
template<typename T> class Sequence;
|
||||
struct MozPluginParameter;
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,6 +120,19 @@ class nsObjectLoadingContent : public nsImageLoadingContent
|
||||
mNetworkCreated = aNetworkCreated;
|
||||
}
|
||||
|
||||
/**
|
||||
* When the object is loaded, the attributes and all nested <param>
|
||||
* elements are cached as name:value string pairs to be passed as
|
||||
* parameters when instantiating the plugin.
|
||||
*
|
||||
* Note: these cached values can be overriden for different quirk cases.
|
||||
*/
|
||||
// Returns the cached attributes array.
|
||||
void GetPluginAttributes(nsTArray<mozilla::dom::MozPluginParameter>& aAttributes);
|
||||
|
||||
// Returns the cached <param> array.
|
||||
void GetPluginParameters(nsTArray<mozilla::dom::MozPluginParameter>& aParameters);
|
||||
|
||||
/**
|
||||
* Immediately instantiate a plugin instance. This is a no-op if mType !=
|
||||
* eType_Plugin or a plugin is already running.
|
||||
@ -322,6 +336,26 @@ class nsObjectLoadingContent : public nsImageLoadingContent
|
||||
eParamContentTypeChanged = 1u << 2
|
||||
};
|
||||
|
||||
/**
|
||||
* Getter for child <param> elements that are not nested in another plugin
|
||||
* dom element.
|
||||
* This is an internal helper function and should not be used directly for
|
||||
* passing parameters to the plugin instance.
|
||||
*
|
||||
* See GetPluginParameters and GetPluginAttributes, which also handle
|
||||
* quirk-overrides.
|
||||
*
|
||||
* @param aParameters The array containing pairs of name/value strings
|
||||
* from nested <param> objects.
|
||||
* @param aIgnoreCodebase Flag for ignoring the "codebase" param when
|
||||
* building the array. This is useful when loading
|
||||
* java.
|
||||
*/
|
||||
void GetNestedParams(nsTArray<mozilla::dom::MozPluginParameter>& aParameters,
|
||||
bool aIgnoreCodebase);
|
||||
|
||||
void BuildParametersArray();
|
||||
|
||||
/**
|
||||
* Loads fallback content with the specified FallbackType
|
||||
*
|
||||
@ -579,6 +613,8 @@ class nsObjectLoadingContent : public nsImageLoadingContent
|
||||
nsWeakFrame mPrintFrame;
|
||||
|
||||
nsRefPtr<nsPluginInstanceOwner> mInstanceOwner;
|
||||
nsTArray<mozilla::dom::MozPluginParameter> mCachedAttributes;
|
||||
nsTArray<mozilla::dom::MozPluginParameter> mCachedParameters;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -39,8 +39,10 @@
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "nsILoadContext.h"
|
||||
#include "mozilla/dom/HTMLObjectElementBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "ANPBase.h"
|
||||
@ -196,6 +198,9 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance()
|
||||
, mOnScreen(true)
|
||||
#endif
|
||||
, mHaveJavaC2PJSObjectQuirk(false)
|
||||
, mCachedParamLength(0)
|
||||
, mCachedParamNames(nullptr)
|
||||
, mCachedParamValues(nullptr)
|
||||
{
|
||||
mNPP.pdata = nullptr;
|
||||
mNPP.ndata = this;
|
||||
@ -219,6 +224,28 @@ nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
|
||||
PR_Free((void *)mMIMEType);
|
||||
mMIMEType = nullptr;
|
||||
}
|
||||
|
||||
if (!mCachedParamValues || !mCachedParamNames) {
|
||||
return;
|
||||
}
|
||||
MOZ_ASSERT(mCachedParamValues && mCachedParamNames);
|
||||
|
||||
for (uint32_t i = 0; i < mCachedParamLength; i++) {
|
||||
if (mCachedParamNames[i]) {
|
||||
NS_Free(mCachedParamNames[i]);
|
||||
mCachedParamNames[i] = nullptr;
|
||||
}
|
||||
if (mCachedParamValues[i]) {
|
||||
NS_Free(mCachedParamValues[i]);
|
||||
mCachedParamValues[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
NS_Free(mCachedParamNames);
|
||||
mCachedParamNames = nullptr;
|
||||
|
||||
NS_Free(mCachedParamValues);
|
||||
mCachedParamValues = nullptr;
|
||||
}
|
||||
|
||||
uint32_t nsNPAPIPluginInstance::gInUnsafePluginCalls = 0;
|
||||
@ -377,28 +404,6 @@ nsNPAPIPluginInstance::GetTagType(nsPluginTagType *result)
|
||||
return mOwner->GetTagType(result);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNPAPIPluginInstance::GetAttributes(uint16_t& n, const char*const*& names,
|
||||
const char*const*& values)
|
||||
{
|
||||
if (!mOwner) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return mOwner->GetAttributes(n, names, values);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNPAPIPluginInstance::GetParameters(uint16_t& n, const char*const*& names,
|
||||
const char*const*& values)
|
||||
{
|
||||
if (!mOwner) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return mOwner->GetParameters(n, names, values);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsNPAPIPluginInstance::GetMode(int32_t *result)
|
||||
{
|
||||
@ -427,39 +432,53 @@ nsNPAPIPluginInstance::Start()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!mOwner) {
|
||||
MOZ_ASSERT(false, "Should not be calling Start() on unowned plugin.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PluginDestructionGuard guard(this);
|
||||
|
||||
uint16_t count = 0;
|
||||
const char* const* names = nullptr;
|
||||
const char* const* values = nullptr;
|
||||
nsTArray<MozPluginParameter> attributes;
|
||||
nsTArray<MozPluginParameter> params;
|
||||
|
||||
nsPluginTagType tagtype;
|
||||
nsresult rv = GetTagType(&tagtype);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Note: If we failed to get the tag type, we may be a full page plugin, so no arguments
|
||||
rv = GetAttributes(count, names, values);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mOwner->GetAttributes(attributes);
|
||||
mOwner->GetParameters(params);
|
||||
} else {
|
||||
MOZ_ASSERT(false, "Failed to get tag type.");
|
||||
}
|
||||
|
||||
// nsPluginTagType_Object or Applet may also have PARAM tags
|
||||
// Note: The arrays handed back by GetParameters() are
|
||||
// crafted specially to be directly behind the arrays from GetAttributes()
|
||||
// with a null entry as a separator. This is for 4.x backwards compatibility!
|
||||
// see bug 111008 for details
|
||||
if (tagtype != nsPluginTagType_Embed) {
|
||||
uint16_t pcount = 0;
|
||||
const char* const* pnames = nullptr;
|
||||
const char* const* pvalues = nullptr;
|
||||
if (NS_SUCCEEDED(GetParameters(pcount, pnames, pvalues))) {
|
||||
// Android expects an empty string as the separator instead of null
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
NS_ASSERTION(PL_strcmp(values[count], "") == 0, "attribute/parameter array not setup correctly for Android NPAPI plugins");
|
||||
#else
|
||||
NS_ASSERTION(!values[count], "attribute/parameter array not setup correctly for NPAPI plugins");
|
||||
#endif
|
||||
if (pcount)
|
||||
count += ++pcount; // if it's all setup correctly, then all we need is to
|
||||
// change the count (attrs + PARAM/blank + params)
|
||||
}
|
||||
}
|
||||
mCachedParamLength = attributes.Length() + 1 + params.Length();
|
||||
|
||||
// We add an extra entry "PARAM" as a separator between the attribute
|
||||
// and param values, but we don't count it if there are no <param> entries.
|
||||
// Legacy behavior quirk.
|
||||
uint32_t quirkParamLength = params.Length() ?
|
||||
mCachedParamLength : attributes.Length();
|
||||
|
||||
mCachedParamNames = (char**)NS_Alloc(sizeof(char*) * mCachedParamLength);
|
||||
mCachedParamValues = (char**)NS_Alloc(sizeof(char*) * mCachedParamLength);
|
||||
|
||||
for (uint32_t i = 0; i < attributes.Length(); i++) {
|
||||
mCachedParamNames[i] = ToNewUTF8String(attributes[i].mName);
|
||||
mCachedParamValues[i] = ToNewUTF8String(attributes[i].mValue);
|
||||
}
|
||||
|
||||
// Android expects and empty string instead of null.
|
||||
mCachedParamNames[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING("PARAM"));
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
mCachedParamValues[attributes.Length()] = ToNewUTF8String(NS_LITERAL_STRING(""));
|
||||
#else
|
||||
mCachedParamValues[attributes.Length()] = nullptr;
|
||||
#endif
|
||||
|
||||
for (uint32_t i = 0, pos = attributes.Length() + 1; i < params.Length(); i ++) {
|
||||
mCachedParamNames[pos] = ToNewUTF8String(params[i].mName);
|
||||
mCachedParamValues[pos] = ToNewUTF8String(params[i].mValue);
|
||||
pos++;
|
||||
}
|
||||
|
||||
int32_t mode;
|
||||
@ -469,57 +488,7 @@ nsNPAPIPluginInstance::Start()
|
||||
GetMode(&mode);
|
||||
GetMIMEType(&mimetype);
|
||||
|
||||
CheckJavaC2PJSObjectQuirk(count, names, values);
|
||||
|
||||
// Some older versions of Flash have a bug in them
|
||||
// that causes the stack to become currupt if we
|
||||
// pass swliveconnect=1 in the NPP_NewProc arrays.
|
||||
// See bug 149336 (UNIX), bug 186287 (Mac)
|
||||
//
|
||||
// The code below disables the attribute unless
|
||||
// the environment variable:
|
||||
// MOZILLA_PLUGIN_DISABLE_FLASH_SWLIVECONNECT_HACK
|
||||
// is set.
|
||||
//
|
||||
// It is okay to disable this attribute because
|
||||
// back in 4.x, scripting required liveconnect to
|
||||
// start Java which was slow. Scripting no longer
|
||||
// requires starting Java and is quick plus controled
|
||||
// from the browser, so Flash now ignores this attribute.
|
||||
//
|
||||
// This code can not be put at the time of creating
|
||||
// the array because we may need to examine the
|
||||
// stream header to determine we want Flash.
|
||||
|
||||
static const char flashMimeType[] = "application/x-shockwave-flash";
|
||||
static const char blockedParam[] = "swliveconnect";
|
||||
if (count && !PL_strcasecmp(mimetype, flashMimeType)) {
|
||||
static int cachedDisableHack = 0;
|
||||
if (!cachedDisableHack) {
|
||||
if (PR_GetEnv("MOZILLA_PLUGIN_DISABLE_FLASH_SWLIVECONNECT_HACK"))
|
||||
cachedDisableHack = -1;
|
||||
else
|
||||
cachedDisableHack = 1;
|
||||
}
|
||||
if (cachedDisableHack > 0) {
|
||||
for (uint16_t i=0; i<count; i++) {
|
||||
if (!PL_strcasecmp(names[i], blockedParam)) {
|
||||
// BIG FAT WARNIG:
|
||||
// I'm ugly casting |const char*| to |char*| and altering it
|
||||
// because I know we do malloc it values in
|
||||
// http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/layout/html/base/src/nsObjectFrame.cpp&rev=1.349&root=/cvsroot#3020
|
||||
// and free it at line #2096, so it couldn't be a const ptr to string literal
|
||||
char *val = (char*) values[i];
|
||||
if (val && *val) {
|
||||
// we cannot just *val=0, it won't be free properly in such case
|
||||
val[0] = '0';
|
||||
val[1] = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckJavaC2PJSObjectQuirk(quirkParamLength, mCachedParamNames, mCachedParamValues);
|
||||
|
||||
bool oldVal = mInPluginInitCall;
|
||||
mInPluginInitCall = true;
|
||||
@ -541,13 +510,13 @@ nsNPAPIPluginInstance::Start()
|
||||
mRunning = RUNNING;
|
||||
|
||||
nsresult newResult = library->NPP_New((char*)mimetype, &mNPP, (uint16_t)mode,
|
||||
count, (char**)names, (char**)values,
|
||||
nullptr, &error);
|
||||
quirkParamLength, mCachedParamNames,
|
||||
mCachedParamValues, nullptr, &error);
|
||||
mInPluginInitCall = oldVal;
|
||||
|
||||
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
||||
("NPP New called: this=%p, npp=%p, mime=%s, mode=%d, argc=%d, return=%d\n",
|
||||
this, &mNPP, mimetype, mode, count, error));
|
||||
this, &mNPP, mimetype, mode, quirkParamLength, error));
|
||||
|
||||
if (NS_FAILED(newResult) || error != NPERR_NO_ERROR) {
|
||||
mRunning = DESTROYED;
|
||||
|
@ -305,10 +305,6 @@ protected:
|
||||
virtual ~nsNPAPIPluginInstance();
|
||||
|
||||
nsresult GetTagType(nsPluginTagType *result);
|
||||
nsresult GetAttributes(uint16_t& n, const char*const*& names,
|
||||
const char*const*& values);
|
||||
nsresult GetParameters(uint16_t& n, const char*const*& names,
|
||||
const char*const*& values);
|
||||
nsresult GetMode(int32_t *result);
|
||||
|
||||
// check if this is a Java applet and affected by bug 750480
|
||||
@ -398,6 +394,12 @@ private:
|
||||
bool mHaveJavaC2PJSObjectQuirk;
|
||||
|
||||
static uint32_t gInUnsafePluginCalls;
|
||||
|
||||
// The arrays can only be released when the plugin instance is destroyed,
|
||||
// because the plugin, in in-process mode, might keep a reference to them.
|
||||
uint32_t mCachedParamLength;
|
||||
char **mCachedParamNames;
|
||||
char **mCachedParamValues;
|
||||
};
|
||||
|
||||
// On Android, we need to guard against plugin code leaking entries in the local
|
||||
|
@ -39,6 +39,7 @@ using mozilla::DefaultXDisplay;
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsIDOMHTMLAppletElement.h"
|
||||
#include "nsIObjectLoadingContent.h"
|
||||
#include "nsObjectLoadingContent.h"
|
||||
#include "nsAttrName.h"
|
||||
#include "nsIFocusManager.h"
|
||||
#include "nsFocusManager.h"
|
||||
@ -53,6 +54,7 @@ using mozilla::DefaultXDisplay;
|
||||
#include "mozilla/MiscEvents.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/dom/HTMLObjectElementBinding.h"
|
||||
|
||||
#include "nsContentCID.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
@ -88,6 +90,7 @@ using namespace mozilla::dom;
|
||||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::layers;
|
||||
|
||||
// special class for handeling DOM context menu events because for
|
||||
@ -280,10 +283,6 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
|
||||
mWidgetVisible = true;
|
||||
mPluginWindowVisible = false;
|
||||
mPluginDocumentActiveState = true;
|
||||
mNumCachedAttrs = 0;
|
||||
mNumCachedParams = 0;
|
||||
mCachedAttrParamNames = nullptr;
|
||||
mCachedAttrParamValues = nullptr;
|
||||
mLastMouseDownButtonType = -1;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
@ -306,8 +305,6 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
|
||||
|
||||
nsPluginInstanceOwner::~nsPluginInstanceOwner()
|
||||
{
|
||||
int32_t cnt;
|
||||
|
||||
if (mWaitingForPaint) {
|
||||
// We don't care when the event is dispatched as long as it's "soon",
|
||||
// since whoever needs it will be waiting for it.
|
||||
@ -317,28 +314,6 @@ nsPluginInstanceOwner::~nsPluginInstanceOwner()
|
||||
|
||||
mObjectFrame = nullptr;
|
||||
|
||||
for (cnt = 0; cnt < (mNumCachedAttrs + 1 + mNumCachedParams); cnt++) {
|
||||
if (mCachedAttrParamNames && mCachedAttrParamNames[cnt]) {
|
||||
NS_Free(mCachedAttrParamNames[cnt]);
|
||||
mCachedAttrParamNames[cnt] = nullptr;
|
||||
}
|
||||
|
||||
if (mCachedAttrParamValues && mCachedAttrParamValues[cnt]) {
|
||||
NS_Free(mCachedAttrParamValues[cnt]);
|
||||
mCachedAttrParamValues[cnt] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (mCachedAttrParamNames) {
|
||||
NS_Free(mCachedAttrParamNames);
|
||||
mCachedAttrParamNames = nullptr;
|
||||
}
|
||||
|
||||
if (mCachedAttrParamValues) {
|
||||
NS_Free(mCachedAttrParamValues);
|
||||
mCachedAttrParamValues = nullptr;
|
||||
}
|
||||
|
||||
PLUG_DeletePluginNativeWindow(mPluginWindow);
|
||||
mPluginWindow = nullptr;
|
||||
|
||||
@ -411,38 +386,13 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetMode(int32_t *aMode)
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPluginInstanceOwner::GetAttributes(uint16_t& n,
|
||||
const char*const*& names,
|
||||
const char*const*& values)
|
||||
void nsPluginInstanceOwner::GetAttributes(nsTArray<MozPluginParameter>& attributes)
|
||||
{
|
||||
nsresult rv = EnsureCachedAttrParamArrays();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIObjectLoadingContent> content = do_QueryInterface(mContent);
|
||||
nsObjectLoadingContent *loadingContent =
|
||||
static_cast<nsObjectLoadingContent*>(content.get());
|
||||
|
||||
n = mNumCachedAttrs;
|
||||
names = (const char **)mCachedAttrParamNames;
|
||||
values = (const char **)mCachedAttrParamValues;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPluginInstanceOwner::GetAttribute(const char* name, const char* *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(name);
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
|
||||
nsresult rv = EnsureCachedAttrParamArrays();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*result = nullptr;
|
||||
|
||||
for (int i = 0; i < mNumCachedAttrs; i++) {
|
||||
if (0 == PL_strcasecmp(mCachedAttrParamNames[i], name)) {
|
||||
*result = mCachedAttrParamValues[i];
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
loadingContent->GetPluginAttributes(attributes);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPluginInstanceOwner::GetDOMElement(nsIDOMElement* *result)
|
||||
@ -789,326 +739,13 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetTagType(nsPluginTagType *result)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPluginInstanceOwner::GetParameters(uint16_t& n, const char*const*& names, const char*const*& values)
|
||||
void nsPluginInstanceOwner::GetParameters(nsTArray<MozPluginParameter>& parameters)
|
||||
{
|
||||
nsresult rv = EnsureCachedAttrParamArrays();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIObjectLoadingContent> content = do_QueryInterface(mContent);
|
||||
nsObjectLoadingContent *loadingContent =
|
||||
static_cast<nsObjectLoadingContent*>(content.get());
|
||||
|
||||
n = mNumCachedParams;
|
||||
if (n) {
|
||||
names = (const char **)(mCachedAttrParamNames + mNumCachedAttrs + 1);
|
||||
values = (const char **)(mCachedAttrParamValues + mNumCachedAttrs + 1);
|
||||
} else
|
||||
names = values = nullptr;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPluginInstanceOwner::GetParameter(const char* name, const char* *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(name);
|
||||
NS_ENSURE_ARG_POINTER(result);
|
||||
|
||||
nsresult rv = EnsureCachedAttrParamArrays();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*result = nullptr;
|
||||
|
||||
for (int i = mNumCachedAttrs + 1; i < (mNumCachedParams + 1 + mNumCachedAttrs); i++) {
|
||||
if (0 == PL_strcasecmp(mCachedAttrParamNames[i], name)) {
|
||||
*result = mCachedAttrParamValues[i];
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
// 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,
|
||||
// followed by a PARAM/null and then any PARAM tags. Also, hold the
|
||||
// cached array around for the duration of the life of the instance
|
||||
// because Netscape 4.x did. See bug 111008.
|
||||
nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays()
|
||||
{
|
||||
if (mCachedAttrParamValues)
|
||||
return NS_OK;
|
||||
|
||||
NS_PRECONDITION(((mNumCachedAttrs + mNumCachedParams) == 0) &&
|
||||
!mCachedAttrParamNames,
|
||||
"re-cache of attrs/params not implemented! use the DOM "
|
||||
"node directy instead");
|
||||
|
||||
// Convert to a 16-bit count. Subtract 3 in case we add an extra
|
||||
// "src", "wmode", or "codebase" entry below.
|
||||
uint32_t cattrs = mContent->GetAttrCount();
|
||||
if (cattrs < 0x0000FFFC) {
|
||||
mNumCachedAttrs = static_cast<uint16_t>(cattrs);
|
||||
} else {
|
||||
mNumCachedAttrs = 0xFFFC;
|
||||
}
|
||||
|
||||
// Check if we are java for special codebase handling
|
||||
const char* mime = nullptr;
|
||||
bool isJava = NS_SUCCEEDED(mInstance->GetMIMEType(&mime)) && mime &&
|
||||
nsPluginHost::IsJavaMIMEType(mime);
|
||||
|
||||
// now, we need to find all the PARAM tags that are children of us
|
||||
// however, be careful not to include any PARAMs that don't have us
|
||||
// as a direct parent. For nested object (or applet) tags, be sure
|
||||
// to only round up the param tags that coorespond with THIS
|
||||
// instance. And also, weed out any bogus tags that may get in the
|
||||
// way, see bug 39609. Then, with any param tag that meet our
|
||||
// qualification, temporarly cache them in an nsCOMArray until
|
||||
// we can figure out what size to make our fixed char* array.
|
||||
nsCOMArray<nsIDOMElement> ourParams;
|
||||
|
||||
// Get all dependent PARAM tags, even if they are not direct children.
|
||||
nsCOMPtr<nsIDOMElement> mydomElement = do_QueryInterface(mContent);
|
||||
NS_ENSURE_TRUE(mydomElement, NS_ERROR_NO_INTERFACE);
|
||||
|
||||
// Making DOM method calls can cause our frame to go away.
|
||||
nsCOMPtr<nsIPluginInstanceOwner> kungFuDeathGrip(this);
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLCollection> allParams;
|
||||
NS_NAMED_LITERAL_STRING(xhtml_ns, "http://www.w3.org/1999/xhtml");
|
||||
mydomElement->GetElementsByTagNameNS(xhtml_ns, NS_LITERAL_STRING("param"),
|
||||
getter_AddRefs(allParams));
|
||||
if (allParams) {
|
||||
uint32_t numAllParams;
|
||||
allParams->GetLength(&numAllParams);
|
||||
for (uint32_t i = 0; i < numAllParams; i++) {
|
||||
nsCOMPtr<nsIDOMNode> pnode;
|
||||
allParams->Item(i, getter_AddRefs(pnode));
|
||||
nsCOMPtr<nsIDOMElement> domelement = do_QueryInterface(pnode);
|
||||
if (domelement) {
|
||||
// Ignore params without a name attribute.
|
||||
nsAutoString name;
|
||||
domelement->GetAttribute(NS_LITERAL_STRING("name"), name);
|
||||
if (!name.IsEmpty()) {
|
||||
// Find the first object or applet parent.
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
nsCOMPtr<nsIDOMHTMLObjectElement> domobject;
|
||||
nsCOMPtr<nsIDOMHTMLAppletElement> domapplet;
|
||||
pnode->GetParentNode(getter_AddRefs(parent));
|
||||
while (!(domobject || domapplet) && parent) {
|
||||
domobject = do_QueryInterface(parent);
|
||||
domapplet = do_QueryInterface(parent);
|
||||
nsCOMPtr<nsIDOMNode> temp;
|
||||
parent->GetParentNode(getter_AddRefs(temp));
|
||||
parent = temp;
|
||||
}
|
||||
if (domapplet || domobject) {
|
||||
if (domapplet) {
|
||||
parent = do_QueryInterface(domapplet);
|
||||
}
|
||||
else {
|
||||
parent = do_QueryInterface(domobject);
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> mydomNode = do_QueryInterface(mydomElement);
|
||||
if (parent == mydomNode) {
|
||||
ourParams.AppendObject(domelement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert to a 16-bit count.
|
||||
uint32_t cparams = ourParams.Count();
|
||||
if (cparams < 0x0000FFFF) {
|
||||
mNumCachedParams = static_cast<uint16_t>(cparams);
|
||||
} else {
|
||||
mNumCachedParams = 0xFFFF;
|
||||
}
|
||||
|
||||
uint16_t numRealAttrs = mNumCachedAttrs;
|
||||
|
||||
// Some plugins were never written to understand the "data" attribute of the OBJECT tag.
|
||||
// Real and WMP will not play unless they find a "src" attribute, see bug 152334.
|
||||
// Nav 4.x would simply replace the "data" with "src". Because some plugins correctly
|
||||
// look for "data", lets instead copy the "data" attribute and add another entry
|
||||
// to the bottom of the array if there isn't already a "src" specified.
|
||||
nsAutoString data;
|
||||
if (mContent->Tag() == nsGkAtoms::object &&
|
||||
!mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::src) &&
|
||||
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::data, data) &&
|
||||
!data.IsEmpty()) {
|
||||
mNumCachedAttrs++;
|
||||
}
|
||||
|
||||
// "plugins.force.wmode" forces us to send a specific "wmode" parameter,
|
||||
// used by flash to select a rendering mode. Common values include
|
||||
// "opaque", "transparent", "windowed", "direct"
|
||||
nsCString wmodeType;
|
||||
nsAdoptingCString wmodePref = Preferences::GetCString("plugins.force.wmode");
|
||||
if (!wmodePref.IsEmpty()) {
|
||||
mNumCachedAttrs++;
|
||||
wmodeType = wmodePref;
|
||||
}
|
||||
#if defined(XP_WIN) || defined(XP_LINUX)
|
||||
// Bug 923745 - Until we support windowed mode plugins in content processes,
|
||||
// force flash to use a windowless rendering mode. This hack should go away
|
||||
// when bug 923746 lands. (OS X plugins always use some native widgets, so
|
||||
// unfortunately this does not help there)
|
||||
else if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
mNumCachedAttrs++;
|
||||
wmodeType.AssignLiteral("transparent");
|
||||
}
|
||||
#endif
|
||||
|
||||
// (Bug 738396) java has quirks in its codebase parsing, pass the
|
||||
// absolute codebase URI as content sees it.
|
||||
bool addCodebase = false;
|
||||
nsAutoCString codebaseStr;
|
||||
if (isJava) {
|
||||
nsCOMPtr<nsIObjectLoadingContent> objlc = do_QueryInterface(mContent);
|
||||
NS_ENSURE_TRUE(objlc, NS_ERROR_UNEXPECTED);
|
||||
nsCOMPtr<nsIURI> codebaseURI;
|
||||
nsresult rv = objlc->GetBaseURI(getter_AddRefs(codebaseURI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
codebaseURI->GetSpec(codebaseStr);
|
||||
if (!mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::codebase)) {
|
||||
mNumCachedAttrs++;
|
||||
addCodebase = true;
|
||||
}
|
||||
}
|
||||
|
||||
mCachedAttrParamNames = (char**)NS_Alloc(sizeof(char*) * (mNumCachedAttrs + 1 + mNumCachedParams));
|
||||
NS_ENSURE_TRUE(mCachedAttrParamNames, NS_ERROR_OUT_OF_MEMORY);
|
||||
mCachedAttrParamValues = (char**)NS_Alloc(sizeof(char*) * (mNumCachedAttrs + 1 + mNumCachedParams));
|
||||
NS_ENSURE_TRUE(mCachedAttrParamValues, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// Some plugins (eg Flash, see bug 234675.) are actually sensitive to the
|
||||
// attribute order. So we want to make sure we give the plugin the
|
||||
// attributes in the order they came in in the source, to be compatible with
|
||||
// other browsers. Now in HTML, the storage order is the reverse of the
|
||||
// source order, while in XML and XHTML it's the same as the source order
|
||||
// (see the AddAttributes functions in the HTML and XML content sinks).
|
||||
int32_t start, end, increment;
|
||||
if (mContent->IsHTML() &&
|
||||
mContent->IsInHTMLDocument()) {
|
||||
// HTML. Walk attributes in reverse order.
|
||||
start = numRealAttrs - 1;
|
||||
end = -1;
|
||||
increment = -1;
|
||||
} else {
|
||||
// XHTML or XML. Walk attributes in forward order.
|
||||
start = 0;
|
||||
end = numRealAttrs;
|
||||
increment = 1;
|
||||
}
|
||||
|
||||
// Set to the next slot to fill in name and value cache arrays.
|
||||
uint32_t nextAttrParamIndex = 0;
|
||||
|
||||
// Whether or not we force the wmode below while traversing
|
||||
// the name/value pairs.
|
||||
bool wmodeSet = false;
|
||||
|
||||
// Add attribute name/value pairs.
|
||||
for (int32_t index = start; index != end; index += increment) {
|
||||
const nsAttrName* attrName = mContent->GetAttrNameAt(index);
|
||||
nsIAtom* atom = attrName->LocalName();
|
||||
nsAutoString value;
|
||||
mContent->GetAttr(attrName->NamespaceID(), atom, value);
|
||||
nsAutoString name;
|
||||
atom->ToString(name);
|
||||
|
||||
FixUpURLS(name, value);
|
||||
|
||||
mCachedAttrParamNames [nextAttrParamIndex] = ToNewUTF8String(name);
|
||||
if (!wmodeType.IsEmpty() &&
|
||||
0 == PL_strcasecmp(mCachedAttrParamNames[nextAttrParamIndex], "wmode")) {
|
||||
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(NS_ConvertUTF8toUTF16(wmodeType));
|
||||
|
||||
if (!wmodeSet) {
|
||||
// We allocated space to add a wmode attr, but we don't need it now.
|
||||
mNumCachedAttrs--;
|
||||
wmodeSet = true;
|
||||
}
|
||||
} else if (isJava && 0 == PL_strcasecmp(mCachedAttrParamNames[nextAttrParamIndex], "codebase")) {
|
||||
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(NS_ConvertUTF8toUTF16(codebaseStr));
|
||||
} else {
|
||||
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(value);
|
||||
}
|
||||
nextAttrParamIndex++;
|
||||
}
|
||||
|
||||
// Potentially add CODEBASE attribute
|
||||
if (addCodebase) {
|
||||
mCachedAttrParamNames [nextAttrParamIndex] = ToNewUTF8String(NS_LITERAL_STRING("codebase"));
|
||||
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(NS_ConvertUTF8toUTF16(codebaseStr));
|
||||
nextAttrParamIndex++;
|
||||
}
|
||||
|
||||
// Potentially add WMODE attribute.
|
||||
if (!wmodeType.IsEmpty() && !wmodeSet) {
|
||||
mCachedAttrParamNames [nextAttrParamIndex] = ToNewUTF8String(NS_LITERAL_STRING("wmode"));
|
||||
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(NS_ConvertUTF8toUTF16(wmodeType));
|
||||
nextAttrParamIndex++;
|
||||
}
|
||||
|
||||
// Potentially add SRC attribute.
|
||||
if (!data.IsEmpty()) {
|
||||
mCachedAttrParamNames [nextAttrParamIndex] = ToNewUTF8String(NS_LITERAL_STRING("SRC"));
|
||||
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(data);
|
||||
nextAttrParamIndex++;
|
||||
}
|
||||
|
||||
// Add PARAM and null separator.
|
||||
mCachedAttrParamNames [nextAttrParamIndex] = ToNewUTF8String(NS_LITERAL_STRING("PARAM"));
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
// Flash expects an empty string on android
|
||||
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(NS_LITERAL_STRING(""));
|
||||
#else
|
||||
mCachedAttrParamValues[nextAttrParamIndex] = nullptr;
|
||||
#endif
|
||||
nextAttrParamIndex++;
|
||||
|
||||
// Add PARAM name/value pairs.
|
||||
|
||||
// We may decrement mNumCachedParams below
|
||||
uint16_t totalParams = mNumCachedParams;
|
||||
for (uint16_t i = 0; i < totalParams; i++) {
|
||||
nsIDOMElement* param = ourParams.ObjectAt(i);
|
||||
if (!param) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsAutoString name;
|
||||
nsAutoString value;
|
||||
param->GetAttribute(NS_LITERAL_STRING("name"), name); // check for empty done above
|
||||
param->GetAttribute(NS_LITERAL_STRING("value"), value);
|
||||
|
||||
FixUpURLS(name, value);
|
||||
|
||||
/*
|
||||
* According to the HTML 4.01 spec, at
|
||||
* http://www.w3.org/TR/html4/types.html#type-cdata
|
||||
* ''User agents may ignore leading and trailing
|
||||
* white space in CDATA attribute values (e.g., "
|
||||
* myval " may be interpreted as "myval"). Authors
|
||||
* should not declare attribute values with
|
||||
* leading or trailing white space.''
|
||||
* However, do not trim consecutive spaces as in bug 122119
|
||||
*/
|
||||
name.Trim(" \n\r\t\b", true, true, false);
|
||||
value.Trim(" \n\r\t\b", true, true, false);
|
||||
if (isJava && name.EqualsIgnoreCase("codebase")) {
|
||||
// We inserted normalized codebase above, don't include other versions in
|
||||
// params
|
||||
mNumCachedParams--;
|
||||
continue;
|
||||
}
|
||||
mCachedAttrParamNames [nextAttrParamIndex] = ToNewUTF8String(name);
|
||||
mCachedAttrParamValues[nextAttrParamIndex] = ToNewUTF8String(value);
|
||||
nextAttrParamIndex++;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
loadingContent->GetPluginParameters(parameters);
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
@ -3168,19 +2805,6 @@ nsObjectFrame* nsPluginInstanceOwner::GetFrame()
|
||||
return mObjectFrame;
|
||||
}
|
||||
|
||||
// Little helper function to resolve relative URL in
|
||||
// |value| for certain inputs of |name|
|
||||
void nsPluginInstanceOwner::FixUpURLS(const nsString &name, nsAString &value)
|
||||
{
|
||||
if (name.LowerCaseEqualsLiteral("pluginspage")) {
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
nsAutoString newURL;
|
||||
NS_MakeAbsoluteURI(newURL, value, baseURI);
|
||||
if (!newURL.IsEmpty())
|
||||
value = newURL;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPluginInstanceOwner::PrivateModeChanged(bool aEnabled)
|
||||
{
|
||||
return mInstance ? mInstance->PrivateModeStateChanged(aEnabled) : NS_OK;
|
||||
|
@ -29,6 +29,12 @@ class nsPluginDOMContextMenuListener;
|
||||
class nsObjectFrame;
|
||||
class nsDisplayListBuilder;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
struct MozPluginParameter;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_X11
|
||||
class gfxXlibSurface;
|
||||
#ifdef MOZ_WIDGET_QT
|
||||
@ -72,50 +78,8 @@ public:
|
||||
*/
|
||||
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);
|
||||
void GetParameters(nsTArray<mozilla::dom::MozPluginParameter>& parameters);
|
||||
void GetAttributes(nsTArray<mozilla::dom::MozPluginParameter>& attributes);
|
||||
|
||||
/**
|
||||
* Returns the DOM element corresponding to the tag which references
|
||||
@ -300,8 +264,7 @@ private:
|
||||
return NS_SUCCEEDED(mInstance->GetImageSize(&size)) &&
|
||||
size == nsIntSize(mPluginWindow->width, mPluginWindow->height);
|
||||
}
|
||||
|
||||
void FixUpURLS(const nsString &name, nsAString &value);
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
mozilla::LayoutDeviceRect GetPluginRect();
|
||||
bool AddPluginView(const mozilla::LayoutDeviceRect& aRect = mozilla::LayoutDeviceRect(0, 0, 0, 0));
|
||||
@ -347,11 +310,6 @@ private:
|
||||
bool mPluginWindowVisible;
|
||||
bool mPluginDocumentActiveState;
|
||||
|
||||
uint16_t mNumCachedAttrs;
|
||||
uint16_t mNumCachedParams;
|
||||
char **mCachedAttrParamNames;
|
||||
char **mCachedAttrParamValues;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
NPEventModel mEventModel;
|
||||
// This is a hack! UseAsyncRendering() can incorrectly return false
|
||||
@ -370,9 +328,7 @@ private:
|
||||
nsresult DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent);
|
||||
|
||||
int mLastMouseDownButtonType;
|
||||
|
||||
nsresult EnsureCachedAttrParamArrays();
|
||||
|
||||
|
||||
#ifdef MOZ_X11
|
||||
class Renderer
|
||||
#if defined(MOZ_WIDGET_QT)
|
||||
|
@ -155,6 +155,13 @@ interface MozObjectLoadingContent {
|
||||
[ChromeOnly]
|
||||
unsigned long getContentTypeForMIMEType(DOMString aMimeType);
|
||||
|
||||
|
||||
[ChromeOnly]
|
||||
sequence<MozPluginParameter> getPluginAttributes();
|
||||
|
||||
[ChromeOnly]
|
||||
sequence<MozPluginParameter> getPluginParameters();
|
||||
|
||||
/**
|
||||
* This method will play a plugin that has been stopped by the
|
||||
* click-to-play plugins or play-preview features.
|
||||
@ -206,6 +213,15 @@ interface MozObjectLoadingContent {
|
||||
void cancelPlayPreview();
|
||||
};
|
||||
|
||||
/**
|
||||
* Name:Value pair type used for passing parameters to NPAPI or javascript
|
||||
* plugins.
|
||||
*/
|
||||
dictionary MozPluginParameter {
|
||||
DOMString name = "";
|
||||
DOMString value = "";
|
||||
};
|
||||
|
||||
HTMLObjectElement implements MozImageLoadingContent;
|
||||
HTMLObjectElement implements MozFrameLoaderOwner;
|
||||
HTMLObjectElement implements MozObjectLoadingContent;
|
||||
|
Loading…
Reference in New Issue
Block a user