Skip to content

Commit

Permalink
Bug 1875466 - Bonus: Remove unused parameter/attribute code. r=webidl…
Browse files Browse the repository at this point in the history
…,saschanaz

Depends on D199117

Differential Revision: https://phabricator.services.mozilla.com/D199118
  • Loading branch information
evilpie committed Jan 22, 2024
1 parent 4b312e7 commit cf9660e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 175 deletions.
125 changes: 0 additions & 125 deletions dom/base/nsObjectLoadingContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,122 +285,6 @@ nsObjectLoadingContent::~nsObjectLoadingContent() {
nsImageLoadingContent::Destroy();
}

void nsObjectLoadingContent::GetPluginAttributes(
nsTArray<MozPluginParameter>& aAttributes) {
aAttributes = mCachedAttributes.Clone();
}

void nsObjectLoadingContent::GetPluginParameters(
nsTArray<MozPluginParameter>& aParameters) {
aParameters = mCachedParameters.Clone();
}

void nsObjectLoadingContent::GetNestedParams(
nsTArray<MozPluginParameter>& aParameters) {
nsCOMPtr<Element> ourElement =
do_QueryInterface(static_cast<nsIObjectLoadingContent*>(this));

nsCOMPtr<nsIHTMLCollection> allParams;
constexpr auto xhtml_ns = u"http://www.w3.org/1999/xhtml"_ns;
ErrorResult rv;
allParams = ourElement->GetElementsByTagNameNS(xhtml_ns, u"param"_ns, rv);
if (rv.Failed()) {
return;
}
MOZ_ASSERT(allParams);

uint32_t numAllParams = allParams->Length();
for (uint32_t i = 0; i < numAllParams; i++) {
RefPtr<Element> element = allParams->Item(i);

nsAutoString name;
element->GetAttr(nsGkAtoms::name, name);

if (name.IsEmpty()) continue;

nsCOMPtr<nsIContent> parent = element->GetParent();
RefPtr<HTMLObjectElement> objectElement;
while (!objectElement && parent) {
objectElement = HTMLObjectElement::FromNode(parent);
parent = parent->GetParent();
}

if (objectElement) {
parent = objectElement;
} else {
continue;
}

if (parent == ourElement) {
MozPluginParameter param;
element->GetAttr(nsGkAtoms::name, param.mName);
element->GetAttr(nsGkAtoms::value, param.mValue);

param.mName.Trim(" \n\r\t\b", true, true, false);
param.mValue.Trim(" \n\r\t\b", true, true, false);

aParameters.AppendElement(param);
}
}
}

nsresult nsObjectLoadingContent::BuildParametersArray() {
if (mCachedAttributes.Length() || mCachedParameters.Length()) {
MOZ_ASSERT(false, "Parameters array should be empty.");
return NS_OK;
}

nsCOMPtr<Element> element =
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));

for (uint32_t i = 0; i != element->GetAttrCount(); i += 1) {
MozPluginParameter param;
const nsAttrName* attrName = element->GetAttrNameAt(i);
nsAtom* atom = attrName->LocalName();
element->GetAttr(attrName->NamespaceID(), atom, param.mValue);
atom->ToString(param.mName);
mCachedAttributes.AppendElement(param);
}

nsAutoCString wmodeOverride;
Preferences::GetCString("plugins.force.wmode", wmodeOverride);

for (uint32_t i = 0; i < mCachedAttributes.Length(); i++) {
if (!wmodeOverride.IsEmpty() &&
mCachedAttributes[i].mName.EqualsIgnoreCase("wmode")) {
CopyASCIItoUTF16(wmodeOverride, mCachedAttributes[i].mValue);
wmodeOverride.Truncate();
}
}

if (!wmodeOverride.IsEmpty()) {
MozPluginParameter param;
param.mName = u"wmode"_ns;
CopyASCIItoUTF16(wmodeOverride, 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 (element->IsHTMLElement(nsGkAtoms::object) &&
!element->HasAttr(nsGkAtoms::src)) {
MozPluginParameter param;
element->GetAttr(nsGkAtoms::data, param.mValue);
if (!param.mValue.IsEmpty()) {
param.mName = u"SRC"_ns;
mCachedAttributes.AppendElement(param);
}
}

GetNestedParams(mCachedParameters);

return NS_OK;
}

void nsObjectLoadingContent::NotifyOwnerDocumentActivityChanged() {
// XXX(johns): We cannot touch plugins or run arbitrary script from this call,
// as Document is in a non-reentrant state.
Expand Down Expand Up @@ -1427,12 +1311,6 @@ nsresult nsObjectLoadingContent::LoadObject(bool aNotify, bool aForceLoad,
/// Attempt to load new type
///

// Cache the current attributes and parameters.
if (mType == eType_Null) {
rv = BuildParametersArray();
NS_ENSURE_SUCCESS(rv, rv);
}

// We don't set mFinalListener until OnStartRequest has been called, to
// prevent re-entry ugliness with CloseChannel()
nsCOMPtr<nsIStreamListener> finalListener;
Expand Down Expand Up @@ -1814,9 +1692,6 @@ void nsObjectLoadingContent::UnloadObject(bool aResetState) {

mIsStopping = false;

mCachedAttributes.Clear();
mCachedParameters.Clear();

mSubdocumentIntrinsicSize.reset();
mSubdocumentIntrinsicRatio.reset();
}
Expand Down
35 changes: 0 additions & 35 deletions dom/base/nsObjectLoadingContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace mozilla::dom {
struct BindContext;
template <typename T>
class Sequence;
struct MozPluginParameter;
class HTMLIFrameElement;
template <typename T>
struct Nullable;
Expand Down Expand Up @@ -82,21 +81,6 @@ 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);

/**
* Notify this class the document state has changed
* Called by Document so we may suspend plugins in inactive documents)
Expand Down Expand Up @@ -289,22 +273,6 @@ 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.
*/
void GetNestedParams(nsTArray<mozilla::dom::MozPluginParameter>& aParameters);

[[nodiscard]] nsresult BuildParametersArray();

/**
* Configure fallback for deprecated plugin and broken elements.
*/
Expand Down Expand Up @@ -536,9 +504,6 @@ class nsObjectLoadingContent : public nsImageLoadingContent,

bool mLoadingSyntheticDocument : 1;

nsTArray<mozilla::dom::MozPluginParameter> mCachedAttributes;
nsTArray<mozilla::dom::MozPluginParameter> mCachedParameters;

// The intrinsic size and aspect ratio from a child SVG document that
// we should use. These are only set when we are an <object> or <embed>
// and the inner document is SVG.
Expand Down
15 changes: 0 additions & 15 deletions dom/webidl/HTMLObjectElement.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ interface mixin MozObjectLoadingContent {
[ChromeOnly]
readonly attribute unsigned long displayedType;

[ChromeOnly]
sequence<MozPluginParameter> getPluginAttributes();

[ChromeOnly]
sequence<MozPluginParameter> getPluginParameters();

/**
* Forces a re-evaluation and reload of the tag, optionally invalidating its
* click-to-play state. This can be used when the MIME type that provides a
Expand All @@ -140,15 +134,6 @@ interface mixin MozObjectLoadingContent {
readonly attribute unsigned long runID;
};

/**
* Name:Value pair type used for passing parameters to NPAPI or javascript
* plugins.
*/
dictionary MozPluginParameter {
DOMString name = "";
DOMString value = "";
};

HTMLObjectElement includes MozImageLoadingContent;
HTMLObjectElement includes MozFrameLoaderOwner;
HTMLObjectElement includes MozObjectLoadingContent;

0 comments on commit cf9660e

Please sign in to comment.