2013-03-17 07:42:01 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
// vim:set et sw=2 sts=2 cin:
|
|
|
|
/* 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 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-03-17 07:42:01 -07:00
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsObjectLoadingContent.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsIDOMHTMLAppletElement.h"
|
|
|
|
#include "nsIDOMHTMLEmbedElement.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2013-07-11 14:26:54 -07:00
|
|
|
class HTMLSharedObjectElement MOZ_FINAL : public nsGenericHTMLElement
|
|
|
|
, public nsObjectLoadingContent
|
|
|
|
, public nsIDOMHTMLAppletElement
|
|
|
|
, public nsIDOMHTMLEmbedElement
|
2013-03-17 07:42:01 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit HTMLSharedObjectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
|
|
|
mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
|
2013-03-17 07:42:01 -07:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
virtual int32_t TabIndexDefault() MOZ_OVERRIDE;
|
|
|
|
|
2015-02-20 08:37:02 -08:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// nsIDOMEventTarget
|
|
|
|
NS_IMETHOD PostHandleEvent(EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
|
|
|
|
#endif
|
|
|
|
|
2013-03-17 07:42:01 -07:00
|
|
|
// nsIDOMHTMLAppletElement
|
|
|
|
NS_DECL_NSIDOMHTMLAPPLETELEMENT
|
|
|
|
|
|
|
|
// Can't use macro for nsIDOMHTMLEmbedElement because it has conflicts with
|
|
|
|
// NS_DECL_NSIDOMHTMLAPPLETELEMENT.
|
|
|
|
|
|
|
|
// nsIDOMHTMLEmbedElement
|
2013-05-29 13:43:41 -07:00
|
|
|
NS_IMETHOD GetSrc(nsAString &aSrc) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD SetSrc(const nsAString &aSrc) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD GetType(nsAString &aType) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD SetType(const nsAString &aType) MOZ_OVERRIDE;
|
2013-03-17 07:42:01 -07:00
|
|
|
|
|
|
|
virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent,
|
|
|
|
nsIContent *aBindingParent,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aCompileEventHandlers) MOZ_OVERRIDE;
|
2013-03-17 07:42:01 -07:00
|
|
|
virtual void UnbindFromTree(bool aDeep = true,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aNullParent = true) MOZ_OVERRIDE;
|
2013-03-17 07:42:01 -07:00
|
|
|
virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom *aName,
|
|
|
|
nsIAtom *aPrefix, const nsAString &aValue,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aNotify) MOZ_OVERRIDE;
|
2013-03-17 07:42:01 -07:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) MOZ_OVERRIDE;
|
|
|
|
virtual IMEState GetDesiredIMEState() MOZ_OVERRIDE;
|
2013-03-17 07:42:01 -07:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual void DoneAddingChildren(bool aHaveNotified) MOZ_OVERRIDE;
|
|
|
|
virtual bool IsDoneAddingChildren() MOZ_OVERRIDE;
|
2013-03-17 07:42:01 -07:00
|
|
|
|
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
|
|
|
nsIAtom *aAttribute,
|
|
|
|
const nsAString &aValue,
|
2013-05-29 13:43:41 -07:00
|
|
|
nsAttrValue &aResult) MOZ_OVERRIDE;
|
|
|
|
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom *aAttribute) const MOZ_OVERRIDE;
|
2014-04-02 21:18:36 -07:00
|
|
|
virtual EventStates IntrinsicState() const MOZ_OVERRIDE;
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual void DestroyContent() MOZ_OVERRIDE;
|
2013-03-17 07:42:01 -07:00
|
|
|
|
|
|
|
// nsObjectLoadingContent
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual uint32_t GetCapabilities() const MOZ_OVERRIDE;
|
2013-03-17 07:42:01 -07:00
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_OVERRIDE;
|
2013-03-17 07:42:01 -07:00
|
|
|
|
|
|
|
nsresult CopyInnerTo(Element* aDest);
|
|
|
|
|
|
|
|
void StartObjectLoad() { StartObjectLoad(true); }
|
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(HTMLSharedObjectElement,
|
|
|
|
nsGenericHTMLElement)
|
|
|
|
|
2013-03-17 07:42:03 -07: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 00:03:50 -07:00
|
|
|
return GetUnsignedIntAttr(nsGkAtoms::hspace, 0);
|
2013-03-17 07:42:03 -07:00
|
|
|
}
|
|
|
|
void SetHspace(uint32_t aValue, ErrorResult& aRv)
|
|
|
|
{
|
2013-04-04 00:03:50 -07:00
|
|
|
SetUnsignedIntAttr(nsGkAtoms::hspace, aValue, aRv);
|
2013-03-17 07:42:03 -07: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 00:03:50 -07:00
|
|
|
uint32_t Vspace()
|
2013-03-17 07:42:03 -07:00
|
|
|
{
|
2013-04-04 00:03:50 -07:00
|
|
|
return GetUnsignedIntAttr(nsGkAtoms::vspace, 0);
|
2013-03-17 07:42:03 -07:00
|
|
|
}
|
|
|
|
void SetVspace(uint32_t aValue, ErrorResult& aRv)
|
|
|
|
{
|
2013-04-04 00:03:50 -07:00
|
|
|
SetUnsignedIntAttr(nsGkAtoms::vspace, aValue, aRv);
|
2013-03-17 07:42:03 -07: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 07:42:01 -07:00
|
|
|
private:
|
2014-07-08 14:23:16 -07:00
|
|
|
virtual ~HTMLSharedObjectElement();
|
|
|
|
|
2013-03-17 07:42:01 -07:00
|
|
|
/**
|
|
|
|
* Calls LoadObject with the correct arguments to start the plugin load.
|
|
|
|
*/
|
2014-06-02 05:08:21 -07:00
|
|
|
void StartObjectLoad(bool aNotify);
|
2013-03-17 07:42:01 -07:00
|
|
|
|
|
|
|
nsIAtom *URIAttrName() const
|
|
|
|
{
|
|
|
|
return mNodeInfo->Equals(nsGkAtoms::applet) ?
|
|
|
|
nsGkAtoms::code :
|
|
|
|
nsGkAtoms::src;
|
|
|
|
}
|
|
|
|
|
|
|
|
// mIsDoneAddingChildren is only really used for <applet>. This boolean is
|
|
|
|
// always true for <embed>, per the documentation in nsIContent.h.
|
|
|
|
bool mIsDoneAddingChildren;
|
|
|
|
|
2015-02-12 17:27:39 -08:00
|
|
|
virtual void GetItemValueText(DOMString& text) MOZ_OVERRIDE;
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual void SetItemValueText(const nsAString& text) MOZ_OVERRIDE;
|
2013-03-17 07:42:05 -07:00
|
|
|
|
2014-04-08 15:27:17 -07:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE;
|
2013-11-19 11:21:29 -08:00
|
|
|
|
|
|
|
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|
|
|
nsRuleData* aData);
|
2013-03-17 07:42:01 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLSharedObjectElement_h
|