2015-05-03 12:32:37 -07: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: */
|
2012-05-21 04:12:37 -07: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 10:31:32 -07:00
|
|
|
|
2013-02-18 03:59:08 -08:00
|
|
|
#ifndef mozilla_dom_HTMLMenuElement_h
|
|
|
|
#define mozilla_dom_HTMLMenuElement_h
|
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-08-08 10:31:32 -07:00
|
|
|
#include "nsIDOMHTMLMenuElement.h"
|
|
|
|
#include "nsIHTMLMenu.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
|
2013-02-18 03:59:08 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
class HTMLMenuElement final : public nsGenericHTMLElement,
|
2015-03-27 11:52:19 -07:00
|
|
|
public nsIDOMHTMLMenuElement,
|
|
|
|
public nsIHTMLMenu
|
2011-08-08 10:31:32 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit HTMLMenuElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2011-08-08 10:31:32 -07:00
|
|
|
|
2013-02-18 03:59:08 -08:00
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLMenuElement, menu)
|
2011-08-08 10:31:32 -07:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
// nsIDOMHTMLMenuElement
|
|
|
|
NS_DECL_NSIDOMHTMLMENUELEMENT
|
|
|
|
|
|
|
|
// nsIHTMLMenu
|
|
|
|
NS_DECL_NSIHTMLMENU
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
2011-08-08 10:31:32 -07:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2015-03-21 09:28:04 -07:00
|
|
|
nsAttrValue& aResult) override;
|
2011-08-08 10:31:32 -07:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
|
2011-08-08 10:31:32 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t GetType() const { return mType; }
|
2011-08-08 10:31:32 -07:00
|
|
|
|
2013-02-18 03:59:08 -08: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 14:23:16 -07:00
|
|
|
virtual ~HTMLMenuElement();
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-02-18 03:59:08 -08:00
|
|
|
|
|
|
|
|
2011-08-08 10:31:32 -07:00
|
|
|
protected:
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool CanLoadIcon(nsIContent* aContent, const nsAString& aIcon);
|
2011-08-08 10:31:32 -07:00
|
|
|
|
|
|
|
void BuildSubmenu(const nsAString& aLabel,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsIMenuBuilder* aBuilder);
|
|
|
|
|
|
|
|
void TraverseContent(nsIContent* aContent,
|
|
|
|
nsIMenuBuilder* aBuilder,
|
2012-08-22 08:56:38 -07:00
|
|
|
int8_t& aSeparator);
|
2011-08-08 10:31:32 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
void AddSeparator(nsIMenuBuilder* aBuilder, int8_t& aSeparator);
|
2011-08-08 10:31:32 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mType;
|
2011-08-08 10:31:32 -07:00
|
|
|
};
|
2013-02-18 03:59:08 -08:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLMenuElement_h
|