2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-03-17 14:42:01 +00:00
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_HTMLSharedObjectElement_h
|
|
|
|
#define mozilla_dom_HTMLSharedObjectElement_h
|
|
|
|
|
2013-05-29 20:43:41 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-03-17 14:42:01 +00:00
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsObjectLoadingContent.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsIDOMHTMLAppletElement.h"
|
|
|
|
#include "nsIDOMHTMLEmbedElement.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class HTMLSharedObjectElement final : public nsGenericHTMLElement
|
2015-03-27 18:52:19 +00:00
|
|
|
, public nsObjectLoadingContent
|
|
|
|
, public nsIDOMHTMLAppletElement
|
|
|
|
, public nsIDOMHTMLEmbedElement
|
2013-03-17 14:42:01 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-09-02 00:49:25 +00:00
|
|
|
explicit HTMLSharedObjectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
|
|
|
mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
|
2013-03-17 14:42:01 +00:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual int32_t TabIndexDefault() override;
|
2013-03-17 14:42:01 +00:00
|
|
|
|
2015-02-20 16:37:02 +00:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// nsIDOMEventTarget
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD PostHandleEvent(EventChainPostVisitor& aVisitor) override;
|
2015-02-20 16:37:02 +00:00
|
|
|
#endif
|
|
|
|
|
2013-03-17 14:42:01 +00:00
|
|
|
// nsIDOMHTMLAppletElement
|
|
|
|
NS_DECL_NSIDOMHTMLAPPLETELEMENT
|
|
|
|
|
|
|
|
// Can't use macro for nsIDOMHTMLEmbedElement because it has conflicts with
|
|
|
|
// NS_DECL_NSIDOMHTMLAPPLETELEMENT.
|
|
|
|
|
|
|
|
// nsIDOMHTMLEmbedElement
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetSrc(nsAString &aSrc) override;
|
|
|
|
NS_IMETHOD SetSrc(const nsAString &aSrc) override;
|
|
|
|
NS_IMETHOD GetType(nsAString &aType) override;
|
|
|
|
NS_IMETHOD SetType(const nsAString &aType) override;
|
2013-03-17 14:42:01 +00:00
|
|
|
|
|
|
|
virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent,
|
|
|
|
nsIContent *aBindingParent,
|
2015-03-21 16:28:04 +00:00
|
|
|
bool aCompileEventHandlers) override;
|
2013-03-17 14:42:01 +00:00
|
|
|
virtual void UnbindFromTree(bool aDeep = true,
|
2015-03-21 16:28:04 +00:00
|
|
|
bool aNullParent = true) override;
|
2013-03-17 14:42:01 +00:00
|
|
|
virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom *aName,
|
|
|
|
nsIAtom *aPrefix, const nsAString &aValue,
|
2015-03-21 16:28:04 +00:00
|
|
|
bool aNotify) override;
|
2013-03-17 14:42:01 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) override;
|
|
|
|
virtual IMEState GetDesiredIMEState() override;
|
2013-03-17 14:42:01 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void DoneAddingChildren(bool aHaveNotified) override;
|
|
|
|
virtual bool IsDoneAddingChildren() override;
|
2013-03-17 14:42:01 +00:00
|
|
|
|
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom *aAttribute,
|
|
|
|
const nsAString &aValue,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsAttrValue &aResult) override;
|
|
|
|
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
|
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom *aAttribute) const override;
|
|
|
|
virtual EventStates IntrinsicState() const override;
|
|
|
|
virtual void DestroyContent() override;
|
2013-03-17 14:42:01 +00:00
|
|
|
|
|
|
|
// nsObjectLoadingContent
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual uint32_t GetCapabilities() const override;
|
2013-03-17 14:42:01 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
|
2013-03-17 14:42:01 +00:00
|
|
|
|
|
|
|
nsresult CopyInnerTo(Element* aDest);
|
|
|
|
|
|
|
|
void StartObjectLoad() { StartObjectLoad(true); }
|
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(HTMLSharedObjectElement,
|
|
|
|
nsGenericHTMLElement)
|
|
|
|
|
2013-03-17 14:42:03 +00:00
|
|
|
// WebIDL API for <applet>
|
|
|
|
void GetAlign(DOMString& aValue)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::align, aValue);
|
|
|
|
}
|
|
|
|
void SetAlign(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::align, aValue, aRv);
|
|
|
|
}
|
|
|
|
void GetAlt(DOMString& aValue)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::alt, aValue);
|
|
|
|
}
|
|
|
|
void SetAlt(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::alt, aValue, aRv);
|
|
|
|
}
|
|
|
|
void GetArchive(DOMString& aValue)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::archive, aValue);
|
|
|
|
}
|
|
|
|
void SetArchive(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::archive, aValue, aRv);
|
|
|
|
}
|
|
|
|
void GetCode(DOMString& aValue)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::code, aValue);
|
|
|
|
}
|
|
|
|
void SetCode(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::code, aValue, aRv);
|
|
|
|
}
|
|
|
|
// XPCOM GetCodebase is ok; note that it's a URI attribute
|
|
|
|
void SetCodeBase(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::codebase, aValue, aRv);
|
|
|
|
}
|
|
|
|
void GetHeight(DOMString& aValue)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::height, aValue);
|
|
|
|
}
|
|
|
|
void SetHeight(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::height, aValue, aRv);
|
|
|
|
}
|
|
|
|
uint32_t Hspace()
|
|
|
|
{
|
2013-04-04 07:03:50 +00:00
|
|
|
return GetUnsignedIntAttr(nsGkAtoms::hspace, 0);
|
2013-03-17 14:42:03 +00:00
|
|
|
}
|
|
|
|
void SetHspace(uint32_t aValue, ErrorResult& aRv)
|
|
|
|
{
|
2013-04-04 07:03:50 +00:00
|
|
|
SetUnsignedIntAttr(nsGkAtoms::hspace, aValue, aRv);
|
2013-03-17 14:42:03 +00:00
|
|
|
}
|
|
|
|
void GetName(DOMString& aValue)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::name, aValue);
|
|
|
|
}
|
|
|
|
void SetName(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::name, aValue, aRv);
|
|
|
|
}
|
|
|
|
// XPCOM GetObject is ok; note that it's a URI attribute with a weird base URI
|
|
|
|
void SetObject(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::object, aValue, aRv);
|
|
|
|
}
|
2013-04-04 07:03:50 +00:00
|
|
|
uint32_t Vspace()
|
2013-03-17 14:42:03 +00:00
|
|
|
{
|
2013-04-04 07:03:50 +00:00
|
|
|
return GetUnsignedIntAttr(nsGkAtoms::vspace, 0);
|
2013-03-17 14:42:03 +00:00
|
|
|
}
|
|
|
|
void SetVspace(uint32_t aValue, ErrorResult& aRv)
|
|
|
|
{
|
2013-04-04 07:03:50 +00:00
|
|
|
SetUnsignedIntAttr(nsGkAtoms::vspace, aValue, aRv);
|
2013-03-17 14:42:03 +00:00
|
|
|
}
|
|
|
|
void GetWidth(DOMString& aValue)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::width, aValue);
|
|
|
|
}
|
|
|
|
void SetWidth(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::width, aValue, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
// WebIDL <embed> api
|
|
|
|
// XPCOM GetSrc is ok; note that it's a URI attribute
|
|
|
|
void SetSrc(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::src, aValue, aRv);
|
|
|
|
}
|
|
|
|
void GetType(DOMString& aValue)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::type, aValue);
|
|
|
|
}
|
|
|
|
void SetType(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::type, aValue, aRv);
|
|
|
|
}
|
|
|
|
// width covered by <applet>
|
|
|
|
// height covered by <applet>
|
|
|
|
// align covered by <applet>
|
|
|
|
// name covered by <applet>
|
|
|
|
nsIDocument* GetSVGDocument()
|
|
|
|
{
|
|
|
|
return GetContentDocument();
|
|
|
|
}
|
|
|
|
|
2013-03-17 14:42:01 +00:00
|
|
|
private:
|
2014-07-08 21:23:16 +00:00
|
|
|
virtual ~HTMLSharedObjectElement();
|
|
|
|
|
2013-03-17 14:42:01 +00:00
|
|
|
/**
|
|
|
|
* Calls LoadObject with the correct arguments to start the plugin load.
|
|
|
|
*/
|
2014-06-02 12:08:21 +00:00
|
|
|
void StartObjectLoad(bool aNotify);
|
2013-03-17 14:42:01 +00:00
|
|
|
|
|
|
|
nsIAtom *URIAttrName() const
|
|
|
|
{
|
|
|
|
return mNodeInfo->Equals(nsGkAtoms::applet) ?
|
|
|
|
nsGkAtoms::code :
|
|
|
|
nsGkAtoms::src;
|
|
|
|
}
|
|
|
|
|
2015-07-18 15:51:00 +00:00
|
|
|
nsContentPolicyType GetContentPolicyType() const override;
|
|
|
|
|
2013-03-17 14:42:01 +00:00
|
|
|
// mIsDoneAddingChildren is only really used for <applet>. This boolean is
|
|
|
|
// always true for <embed>, per the documentation in nsIContent.h.
|
|
|
|
bool mIsDoneAddingChildren;
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void GetItemValueText(DOMString& text) override;
|
|
|
|
virtual void SetItemValueText(const nsAString& text) override;
|
2013-03-17 14:42:05 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-11-19 19:21:29 +00:00
|
|
|
|
|
|
|
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|
|
|
nsRuleData* aData);
|
2013-03-17 14:42:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLSharedObjectElement_h
|