From a9158b022aea66b178a29e149b5891c4f532619a Mon Sep 17 00:00:00 2001 From: "peterlubczynski%netscape.com" Date: Thu, 27 Jun 2002 01:51:34 +0000 Subject: [PATCH] Fixing some plugins don't understand the DATA attribute on the OBJECT tag so in those cases copy that value to an appened "SRC" entry to the array of attributes/parameters plugins are passed. Bug 152334 r=av sr=waterson --- layout/generic/nsObjectFrame.cpp | 25 +++++++++++++++++--- layout/html/base/src/nsObjectFrame.cpp | 25 +++++++++++++++++--- modules/plugin/base/src/nsPluginHostImpl.cpp | 6 ++--- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index e2ff4732639..89ef5d643c4 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -2894,10 +2894,9 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays() if (cattrs < 0x0000FFFF) { // signed 32 bits to unsigned 16 bits conversion - mNumCachedAttrs = NS_STATIC_CAST(PRUint16, cattrs); } else { - mNumCachedParams = 0xFFFF; + mNumCachedAttrs = 0xFFFE; // minus one in case we add an extra "src" entry below } // now, we need to find all the PARAM tags that are children of us @@ -2997,6 +2996,20 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays() else mNumCachedParams = 0xFFFF; + // 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. + PRInt16 numRealAttrs = mNumCachedAttrs; + nsAutoString data; + nsCOMPtr tag; + content->GetTag(*getter_AddRefs(tag)); + if (nsHTMLAtoms::object == tag.get() && + !content->HasAttr(kNameSpaceID_None, nsHTMLAtoms::src) && + NS_SUCCEEDED(content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data))) + mNumCachedAttrs++; + // now lets make the arrays mCachedAttrParamNames = (char **)PR_Calloc(sizeof(char *) * (mNumCachedAttrs + 1 + mNumCachedParams), 1); NS_ENSURE_TRUE(mCachedAttrParamNames, NS_ERROR_OUT_OF_MEMORY); @@ -3005,7 +3018,7 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays() // let's fill in our attributes PRInt16 c = 0; - for (PRInt16 index = 0; index < mNumCachedAttrs; index++) { + for (PRInt16 index = 0; index < numRealAttrs; index++) { PRInt32 nameSpaceID; nsCOMPtr atom; nsCOMPtr prefix; @@ -3022,6 +3035,12 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays() } } + // if the conditions above were met, copy the "data" attribute to a "src" array entry + if (data.Length()) { + mCachedAttrParamNames [mNumCachedAttrs-1] = ToNewUTF8String(NS_LITERAL_STRING("SRC")); + mCachedAttrParamValues[mNumCachedAttrs-1] = ToNewUTF8String(data); + } + // add our PARAM and null seperator mCachedAttrParamNames [mNumCachedAttrs] = ToNewUTF8String(NS_LITERAL_STRING("PARAM")); mCachedAttrParamValues[mNumCachedAttrs] = nsnull; diff --git a/layout/html/base/src/nsObjectFrame.cpp b/layout/html/base/src/nsObjectFrame.cpp index e2ff4732639..89ef5d643c4 100644 --- a/layout/html/base/src/nsObjectFrame.cpp +++ b/layout/html/base/src/nsObjectFrame.cpp @@ -2894,10 +2894,9 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays() if (cattrs < 0x0000FFFF) { // signed 32 bits to unsigned 16 bits conversion - mNumCachedAttrs = NS_STATIC_CAST(PRUint16, cattrs); } else { - mNumCachedParams = 0xFFFF; + mNumCachedAttrs = 0xFFFE; // minus one in case we add an extra "src" entry below } // now, we need to find all the PARAM tags that are children of us @@ -2997,6 +2996,20 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays() else mNumCachedParams = 0xFFFF; + // 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. + PRInt16 numRealAttrs = mNumCachedAttrs; + nsAutoString data; + nsCOMPtr tag; + content->GetTag(*getter_AddRefs(tag)); + if (nsHTMLAtoms::object == tag.get() && + !content->HasAttr(kNameSpaceID_None, nsHTMLAtoms::src) && + NS_SUCCEEDED(content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::data, data))) + mNumCachedAttrs++; + // now lets make the arrays mCachedAttrParamNames = (char **)PR_Calloc(sizeof(char *) * (mNumCachedAttrs + 1 + mNumCachedParams), 1); NS_ENSURE_TRUE(mCachedAttrParamNames, NS_ERROR_OUT_OF_MEMORY); @@ -3005,7 +3018,7 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays() // let's fill in our attributes PRInt16 c = 0; - for (PRInt16 index = 0; index < mNumCachedAttrs; index++) { + for (PRInt16 index = 0; index < numRealAttrs; index++) { PRInt32 nameSpaceID; nsCOMPtr atom; nsCOMPtr prefix; @@ -3022,6 +3035,12 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays() } } + // if the conditions above were met, copy the "data" attribute to a "src" array entry + if (data.Length()) { + mCachedAttrParamNames [mNumCachedAttrs-1] = ToNewUTF8String(NS_LITERAL_STRING("SRC")); + mCachedAttrParamValues[mNumCachedAttrs-1] = ToNewUTF8String(data); + } + // add our PARAM and null seperator mCachedAttrParamNames [mNumCachedAttrs] = ToNewUTF8String(NS_LITERAL_STRING("PARAM")); mCachedAttrParamValues[mNumCachedAttrs] = nsnull; diff --git a/modules/plugin/base/src/nsPluginHostImpl.cpp b/modules/plugin/base/src/nsPluginHostImpl.cpp index 84538941545..0a1d1de8d8d 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -3489,10 +3489,8 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateEmbededPlugin(const char *aMimeType, if(pti) { const char *value; - if(tagType == nsPluginTagType_Embed) - havedata = NS_SUCCEEDED(pti->GetAttribute("SRC", &value)); - if(tagType == nsPluginTagType_Object) - havedata = NS_SUCCEEDED(pti->GetAttribute("DATA", &value)); + havedata = NS_SUCCEEDED(pti->GetAttribute("SRC", &value)); + // no need to check for "data" as it would have been converted to "src" } if(havedata && !isJava && bCanHandleInternally)