Skip to content

Commit

Permalink
Revert "Bug 1279218 - Additional applet tag logic removal; r=bz"
Browse files Browse the repository at this point in the history
This reverts commit d812ac4.
  • Loading branch information
MrAlex94 committed Dec 3, 2017
1 parent 6e8cf50 commit fe409da
Show file tree
Hide file tree
Showing 33 changed files with 76 additions and 183 deletions.
3 changes: 2 additions & 1 deletion accessible/html/HTMLTableAccessible.cpp
Expand Up @@ -1109,8 +1109,9 @@ HTMLTableAccessible::IsProbablyLayoutTable()

if (HasDescendant(NS_LITERAL_STRING("embed")) ||
HasDescendant(NS_LITERAL_STRING("object")) ||
HasDescendant(NS_LITERAL_STRING("applet")) ||
HasDescendant(NS_LITERAL_STRING("iframe"))) {
RETURN_LAYOUT_ANSWER(true, "Has no borders, and has iframe, object, or iframe, typical of advertisements");
RETURN_LAYOUT_ANSWER(true, "Has no borders, and has iframe, object, applet or iframe, typical of advertisements");
}

RETURN_LAYOUT_ANSWER(false, "no layout factor strong enough, so will guess data");
Expand Down
5 changes: 3 additions & 2 deletions dom/base/Element.cpp
Expand Up @@ -489,10 +489,11 @@ Element::GetBindingURL(nsIDocument *aDocument, css::URLValue **aResult)
// If we have a frame the frame has already loaded the binding. And
// otherwise, don't do anything else here unless we're dealing with
// XUL or an HTML element that may have a plugin-related overlay
// (i.e. object or embed).
// (i.e. object, embed, or applet).
bool isXULorPluginElement = (IsXULElement() ||
IsHTMLElement(nsGkAtoms::object) ||
IsHTMLElement(nsGkAtoms::embed));
IsHTMLElement(nsGkAtoms::embed) ||
IsHTMLElement(nsGkAtoms::applet));
nsIPresShell* shell = aDocument->GetShell();
if (!shell || GetPrimaryFrame() || !isXULorPluginElement) {
*aResult = nullptr;
Expand Down
61 changes: 0 additions & 61 deletions dom/base/nsContentList.cpp
Expand Up @@ -152,67 +152,6 @@ nsSimpleContentList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto
return NodeListBinding::Wrap(cx, this, aGivenProto);
}

NS_IMPL_CYCLE_COLLECTION_INHERITED(nsEmptyContentList, nsBaseContentList, mRoot)

NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsEmptyContentList)
NS_INTERFACE_MAP_END_INHERITING(nsBaseContentList)


NS_IMPL_ADDREF_INHERITED(nsEmptyContentList, nsBaseContentList)
NS_IMPL_RELEASE_INHERITED(nsEmptyContentList, nsBaseContentList)

JSObject*
nsEmptyContentList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
{
return NodeListBinding::Wrap(cx, this, aGivenProto);
}

NS_IMETHODIMP
nsEmptyContentList::GetLength(uint32_t* aLength)
{
*aLength = 0;

return NS_OK;
}

NS_IMETHODIMP
nsEmptyContentList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
{
*aReturn = nullptr;
return NS_OK;
}

NS_IMETHODIMP
nsEmptyContentList::NamedItem(const nsAString& aName, nsIDOMNode** aReturn)
{
*aReturn = nullptr;
return NS_OK;
}

mozilla::dom::Element*
nsEmptyContentList::GetElementAt(uint32_t index)
{
return nullptr;
}

mozilla::dom::Element*
nsEmptyContentList::GetFirstNamedElement(const nsAString& aName, bool& aFound)
{
aFound = false;
return nullptr;
}

void
nsEmptyContentList::GetSupportedNames(nsTArray<nsString>& aNames)
{
}

nsIContent*
nsEmptyContentList::Item(uint32_t aIndex)
{
return nullptr;
}

// Hashtable for storing nsContentLists
static PLDHashTable* gContentListHashTable;

Expand Down
46 changes: 0 additions & 46 deletions dom/base/nsContentList.h
Expand Up @@ -139,52 +139,6 @@ class nsSimpleContentList : public nsBaseContentList
nsCOMPtr<nsINode> mRoot;
};

// Used for returning lists that will always be empty, such as the applets list
// in HTML Documents
class nsEmptyContentList: public nsBaseContentList,
public nsIHTMLCollection
{
public:
explicit nsEmptyContentList(nsINode* aRoot) : nsBaseContentList(),
mRoot(aRoot)
{
}

// nsIDOMHTMLCollection
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsEmptyContentList,
nsBaseContentList)
NS_DECL_NSIDOMHTMLCOLLECTION

virtual nsINode* GetParentObject() override
{
return mRoot;
}

virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;

virtual JSObject* GetWrapperPreserveColorInternal() override
{
return nsWrapperCache::GetWrapperPreserveColor();
}
virtual void PreserveWrapperInternal(nsISupports* aScriptObjectHolder) override
{
nsWrapperCache::PreserveWrapper(aScriptObjectHolder);
}

virtual nsIContent* Item(uint32_t aIndex) override;
virtual mozilla::dom::Element* GetElementAt(uint32_t index) override;
virtual mozilla::dom::Element*
GetFirstNamedElement(const nsAString& aName, bool& aFound) override;
virtual void GetSupportedNames(nsTArray<nsString>& aNames) override;

protected:
virtual ~nsEmptyContentList() {}
private:
// This has to be a strong reference, the root might go away before the list.
nsCOMPtr<nsINode> mRoot;
};

/**
* Class that's used as the key to hash nsContentList implementations
* for fast retrieval
Expand Down
7 changes: 4 additions & 3 deletions dom/base/nsHTMLContentSerializer.cpp
Expand Up @@ -118,9 +118,10 @@ nsHTMLContentSerializer::SerializeHTMLAttributes(nsIContent* aContent,
(attrName == nsGkAtoms::src && namespaceID == kNameSpaceID_None))) {
// Make all links absolute when converting only the selection:
if (mFlags & nsIDocumentEncoder::OutputAbsoluteLinks) {
// Would be nice to handle OBJECT tags, but that gets more complicated
// since we have to search the tag list for CODEBASE as well. For now,
// just leave them relative.
// Would be nice to handle OBJECT and APPLET tags,
// but that gets more complicated since we have to
// search the tag list for CODEBASE as well.
// For now, just leave them relative.
nsCOMPtr<nsIURI> uri = aContent->GetBaseURI();
if (uri) {
nsAutoString absURI;
Expand Down
18 changes: 8 additions & 10 deletions dom/base/nsIContent.h
Expand Up @@ -822,10 +822,10 @@ class nsIContent : public nsINode {
* This method is called when the parser finishes creating the element's children,
* if any are present.
*
* NOTE: this is currently only called for textarea, select, and object
* elements in the HTML content sink. If you want to call it on your element,
* modify the content sink of your choice to do so. This is an efficiency
* measure.
* NOTE: this is currently only called for textarea, select, applet, and
* object elements in the HTML content sink. If you want
* to call it on your element, modify the content sink of your
* choice to do so. This is an efficiency measure.
*
* If you also need to determine whether the parser is the one creating your
* element (through createElement() or cloneNode() generally) then add a
Expand All @@ -842,14 +842,12 @@ class nsIContent : public nsINode {
}

/**
* For HTML textarea, select, and object elements, returns true if all
* children have been added OR if the element was not created by the parser.
* Returns true for all other elements.
*
* For HTML textarea, select, applet, and object elements, returns
* true if all children have been added OR if the element was not
* created by the parser. Returns true for all other elements.
* @returns false if the element was created by the parser and
* it is an HTML textarea, select, or object
* it is an HTML textarea, select, applet, or object
* element and not all children have been added.
*
* @returns true otherwise.
*/
virtual bool IsDoneAddingChildren()
Expand Down
7 changes: 3 additions & 4 deletions dom/base/nsIDocument.h
Expand Up @@ -3185,10 +3185,9 @@ class nsIDocument : public nsINode,
// Tracking for images in the document.
RefPtr<mozilla::dom::ImageTracker> mImageTracker;

// The set of all object, embed, video/audio elements or
// nsIObjectLoadingContent or nsIDocumentActivity for which this is the owner
// document. (They might not be in the document.)
//
// The set of all object, embed, applet, video/audio elements or
// nsIObjectLoadingContent or nsIDocumentActivity for which this is the
// owner document. (They might not be in the document.)
// These are non-owning pointers, the elements are responsible for removing
// themselves when they go away.
nsAutoPtr<nsTHashtable<nsPtrHashKey<nsISupports> > > mActivityObservers;
Expand Down
8 changes: 7 additions & 1 deletion dom/base/nsObjectLoadingContent.cpp
Expand Up @@ -2942,7 +2942,8 @@ nsObjectLoadingContent::LoadFallback(FallbackType aType, bool aNotify) {
// Do a depth-first traverse of node tree with the current element as root,
// looking for <embed> or <object> elements that might now need to load.
nsTArray<nsINodeList*> childNodes;
if (thisContent->IsHTMLElement(nsGkAtoms::object) &&
if ((thisContent->IsHTMLElement(nsGkAtoms::object) ||
thisContent->IsHTMLElement(nsGkAtoms::applet)) &&
(aType == eFallbackUnsupported ||
aType == eFallbackDisabled ||
aType == eFallbackBlocklisted ||
Expand Down Expand Up @@ -3773,6 +3774,11 @@ nsObjectLoadingContent::BlockEmbedOrObjectContentLoading()
{
nsCOMPtr<nsIContent> thisContent =
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
if (!thisContent->IsHTMLElement(nsGkAtoms::embed) &&
!thisContent->IsHTMLElement(nsGkAtoms::object)) {
// Doesn't apply to other elements (i.e. <applet>)
return false;
}

// Traverse up the node tree to see if we have any ancestors that may block us
// from loading
Expand Down
6 changes: 3 additions & 3 deletions dom/base/nsObjectLoadingContent.h
Expand Up @@ -7,7 +7,7 @@
/*
* A base class implementing nsIObjectLoadingContent for use by
* various content nodes that want to provide plugin/document/image
* loading functionality (eg <embed>, <object>, etc).
* loading functionality (eg <embed>, <object>, <applet>, etc).
*/

#ifndef NSOBJECTLOADINGCONTENT_H_
Expand Down Expand Up @@ -262,8 +262,8 @@ class nsObjectLoadingContent : public nsImageLoadingContent
* Begins loading the object when called
*
* Attributes of |this| QI'd to nsIContent will be inspected, depending on
* the node type. This function currently assumes it is a <object> or
* <embed> tag.
* the node type. This function currently assumes it is a <applet>,
* <object>, or <embed> tag.
*
* The instantiated plugin depends on:
* - The URI (<embed src>, <object data>)
Expand Down
5 changes: 3 additions & 2 deletions dom/base/nsSandboxFlags.h
Expand Up @@ -42,8 +42,9 @@ const unsigned long SANDBOXED_TOPLEVEL_NAVIGATION = 0x4;

/**
* This flag prevents content from instantiating plugins, whether using the
* embed element, the object element, or through navigation of a nested browsing
* context, unless those plugins can be secured.
* embed element, the object element, the applet element, or through
* navigation of a nested browsing context, unless those plugins can be
* secured.
*/
const unsigned long SANDBOXED_PLUGINS = 0x8;

Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsXHTMLContentSerializer.cpp
Expand Up @@ -299,7 +299,7 @@ nsXHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
(attrName == nsGkAtoms::src))) {
// Make all links absolute when converting only the selection:
if (mFlags & nsIDocumentEncoder::OutputAbsoluteLinks) {
// Would be nice to handle OBJECT tags,
// Would be nice to handle OBJECT and APPLET tags,
// but that gets more complicated since we have to
// search the tag list for CODEBASE as well.
// For now, just leave them relative.
Expand Down
3 changes: 2 additions & 1 deletion dom/events/EventStateManager.cpp
Expand Up @@ -1572,7 +1572,8 @@ EventStateManager::FireContextClick()
allowedToDispatch = formCtrl->IsTextOrNumberControl(/*aExcludePassword*/ false) ||
formCtrl->ControlType() == NS_FORM_INPUT_FILE;
}
else if (mGestureDownContent->IsAnyOfHTMLElements(nsGkAtoms::embed,
else if (mGestureDownContent->IsAnyOfHTMLElements(nsGkAtoms::applet,
nsGkAtoms::embed,
nsGkAtoms::object,
nsGkAtoms::label)) {
allowedToDispatch = false;
Expand Down
1 change: 1 addition & 0 deletions dom/html/HTMLAllCollection.cpp
Expand Up @@ -70,6 +70,7 @@ static bool
IsAllNamedElement(nsIContent* aContent)
{
return aContent->IsAnyOfHTMLElements(nsGkAtoms::a,
nsGkAtoms::applet,
nsGkAtoms::button,
nsGkAtoms::embed,
nsGkAtoms::form,
Expand Down
9 changes: 8 additions & 1 deletion dom/html/HTMLSharedObjectElement.cpp
Expand Up @@ -388,7 +388,14 @@ HTMLSharedObjectElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenPr
nsContentPolicyType
HTMLSharedObjectElement::GetContentPolicyType() const
{
return nsIContentPolicy::TYPE_INTERNAL_EMBED;
if (mNodeInfo->Equals(nsGkAtoms::applet)) {
// We use TYPE_INTERNAL_OBJECT for applet too, since it is not exposed
// through RequestContext yet.
return nsIContentPolicy::TYPE_INTERNAL_OBJECT;
} else {
MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::embed));
return nsIContentPolicy::TYPE_INTERNAL_EMBED;
}
}

NS_IMPL_STRING_ATTR(HTMLSharedObjectElement, Align, align)
Expand Down
4 changes: 3 additions & 1 deletion dom/html/nsGenericHTMLElement.h
Expand Up @@ -696,6 +696,7 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase,
{
return aTag == nsGkAtoms::img ||
aTag == nsGkAtoms::form ||
aTag == nsGkAtoms::applet ||
aTag == nsGkAtoms::embed ||
aTag == nsGkAtoms::object;
}
Expand All @@ -708,7 +709,8 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase,
static inline bool
ShouldExposeIdAsHTMLDocumentProperty(Element* aElement)
{
if (aElement->IsAnyOfHTMLElements(nsGkAtoms::embed,
if (aElement->IsAnyOfHTMLElements(nsGkAtoms::applet,
nsGkAtoms::embed,
nsGkAtoms::object)) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion dom/html/nsHTMLDocument.cpp
Expand Up @@ -1187,7 +1187,7 @@ nsIHTMLCollection*
nsHTMLDocument::Applets()
{
if (!mApplets) {
mApplets = new nsEmptyContentList(this);
mApplets = new nsContentList(this, kNameSpaceID_XHTML, nsGkAtoms::applet, nsGkAtoms::applet);
}
return mApplets;
}
Expand Down
2 changes: 1 addition & 1 deletion dom/html/nsHTMLDocument.h
Expand Up @@ -309,7 +309,7 @@ class nsHTMLDocument : public nsDocument,
void *GenerateParserKey(void);

RefPtr<nsContentList> mImages;
RefPtr<nsEmptyContentList> mApplets;
RefPtr<nsContentList> mApplets;
RefPtr<nsContentList> mEmbeds;
RefPtr<nsContentList> mLinks;
RefPtr<nsContentList> mAnchors;
Expand Down
1 change: 0 additions & 1 deletion dom/html/test/mochitest.ini
Expand Up @@ -612,4 +612,3 @@ support-files =
file_script_module.html
file_script_nomodule.html
[test_getElementsByName_after_mutation.html]
[test_bug1279218.html]
23 changes: 0 additions & 23 deletions dom/html/test/test_bug1279218.html

This file was deleted.

3 changes: 3 additions & 0 deletions dom/html/test/test_bug579079.html
Expand Up @@ -22,13 +22,16 @@
<script class="testbody" type="text/javascript">
var img = document.img1;
var form = document.form1;
var applet = document.applet1;
var embed = document.embed1;
var object = document.object1;
$("foo").innerHTML = $("foo").innerHTML;
isnot(document.img1, img);
ok(document.img1 instanceof HTMLImageElement);
isnot(document.form1, form);
ok(document.form1 instanceof HTMLFormElement);
isnot(document.applet1, applet);
ok(document.applet1 instanceof HTMLUnknownElement);
isnot(document.embed1, embed);
ok(document.embed1 instanceof HTMLEmbedElement);
isnot(document.object1, object);
Expand Down

0 comments on commit fe409da

Please sign in to comment.