2011-08-08 17:31:32 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +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/. */
|
2011-08-08 17:31:32 +00:00
|
|
|
|
2013-02-18 11:59:08 +00:00
|
|
|
#ifndef mozilla_dom_HTMLMenuElement_h
|
|
|
|
#define mozilla_dom_HTMLMenuElement_h
|
|
|
|
|
2013-05-29 20:43:41 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-08-08 17:31:32 +00:00
|
|
|
#include "nsIDOMHTMLMenuElement.h"
|
|
|
|
#include "nsIHTMLMenu.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
|
2013-02-18 11:59:08 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class HTMLMenuElement final : public nsGenericHTMLElement,
|
2015-03-27 18:52:19 +00:00
|
|
|
public nsIDOMHTMLMenuElement,
|
|
|
|
public nsIHTMLMenu
|
2011-08-08 17:31:32 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-09-02 00:49:25 +00:00
|
|
|
explicit HTMLMenuElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2011-08-08 17:31:32 +00:00
|
|
|
|
2013-02-18 11:59:08 +00:00
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLMenuElement, menu)
|
2011-08-08 17:31:32 +00:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
// nsIDOMHTMLMenuElement
|
|
|
|
NS_DECL_NSIDOMHTMLMENUELEMENT
|
|
|
|
|
|
|
|
// nsIHTMLMenu
|
|
|
|
NS_DECL_NSIHTMLMENU
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
2011-08-08 17:31:32 +00:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2015-03-21 16:28:04 +00:00
|
|
|
nsAttrValue& aResult) override;
|
2011-08-08 17:31:32 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
|
2011-08-08 17:31:32 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t GetType() const { return mType; }
|
2011-08-08 17:31:32 +00:00
|
|
|
|
2013-02-18 11:59:08 +00:00
|
|
|
// WebIDL
|
|
|
|
|
|
|
|
// The XPCOM GetType is OK for us
|
|
|
|
void SetType(const nsAString& aType, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::type, aType, aError);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The XPCOM GetLabel is OK for us
|
|
|
|
void SetLabel(const nsAString& aLabel, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::label, aLabel, aError);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Compact() const
|
|
|
|
{
|
|
|
|
return GetBoolAttr(nsGkAtoms::compact);
|
|
|
|
}
|
|
|
|
void SetCompact(bool aCompact, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::compact, aCompact, aError);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The XPCOM SendShowEvent is OK for us
|
|
|
|
|
|
|
|
already_AddRefed<nsIMenuBuilder> CreateBuilder();
|
|
|
|
|
|
|
|
// The XPCOM Build is OK for us
|
|
|
|
|
|
|
|
protected:
|
2014-07-08 21:23:16 +00:00
|
|
|
virtual ~HTMLMenuElement();
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-02-18 11:59:08 +00:00
|
|
|
|
|
|
|
|
2011-08-08 17:31:32 +00:00
|
|
|
protected:
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool CanLoadIcon(nsIContent* aContent, const nsAString& aIcon);
|
2011-08-08 17:31:32 +00:00
|
|
|
|
|
|
|
void BuildSubmenu(const nsAString& aLabel,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsIMenuBuilder* aBuilder);
|
|
|
|
|
|
|
|
void TraverseContent(nsIContent* aContent,
|
|
|
|
nsIMenuBuilder* aBuilder,
|
2012-08-22 15:56:38 +00:00
|
|
|
int8_t& aSeparator);
|
2011-08-08 17:31:32 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
void AddSeparator(nsIMenuBuilder* aBuilder, int8_t& aSeparator);
|
2011-08-08 17:31:32 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t mType;
|
2011-08-08 17:31:32 +00:00
|
|
|
};
|
2013-02-18 11:59:08 +00:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLMenuElement_h
|