2015-05-03 22:32:37 +03: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 15:12:37 +04: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 21:31:32 +04:00
|
|
|
|
2013-02-18 15:59:08 +04:00
|
|
|
#ifndef mozilla_dom_HTMLMenuElement_h
|
|
|
|
#define mozilla_dom_HTMLMenuElement_h
|
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-08-08 21:31:32 +04:00
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
|
2016-11-15 08:18:33 +03:00
|
|
|
class nsIMenuBuilder;
|
|
|
|
|
2013-02-18 15:59:08 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2017-08-14 19:31:47 +03:00
|
|
|
class HTMLMenuElement final : public nsGenericHTMLElement
|
2011-08-08 21:31:32 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit HTMLMenuElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2011-08-08 21:31:32 +04:00
|
|
|
|
2018-03-22 00:39:04 +03:00
|
|
|
NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLMenuElement, menu)
|
2011-08-08 21:31:32 +04:00
|
|
|
|
|
|
|
// nsISupports
|
2018-02-12 23:44:40 +03:00
|
|
|
NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLMenuElement, nsGenericHTMLElement)
|
2011-08-08 21:31:32 +04:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
|
2017-05-19 00:09:01 +03:00
|
|
|
const nsAttrValue* aValue,
|
|
|
|
const nsAttrValue* aOldValue,
|
2017-10-10 00:33:38 +03:00
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
2017-05-19 00:09:01 +03:00
|
|
|
bool aNotify) override;
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2011-08-08 21:31:32 +04:00
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsAttrValue& aResult) override;
|
2011-08-08 21:31:32 +04:00
|
|
|
|
2017-04-20 22:57:48 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
|
|
|
bool aPreallocateChildren) const override;
|
2011-08-08 21:31:32 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t GetType() const { return mType; }
|
2011-08-08 21:31:32 +04:00
|
|
|
|
2013-02-18 15:59:08 +04:00
|
|
|
// WebIDL
|
|
|
|
|
2017-08-14 19:31:47 +03:00
|
|
|
void GetType(nsAString& aValue)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::type, aValue);
|
|
|
|
}
|
2013-02-18 15:59:08 +04:00
|
|
|
void SetType(const nsAString& aType, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::type, aType, aError);
|
|
|
|
}
|
|
|
|
|
2017-08-14 19:31:47 +03:00
|
|
|
void GetLabel(nsAString& aValue)
|
|
|
|
{
|
|
|
|
GetHTMLAttr(nsGkAtoms::label, aValue);
|
|
|
|
}
|
2013-02-18 15:59:08 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-11-15 08:18:33 +03:00
|
|
|
void SendShowEvent();
|
2013-02-18 15:59:08 +04:00
|
|
|
|
|
|
|
already_AddRefed<nsIMenuBuilder> CreateBuilder();
|
|
|
|
|
2016-11-15 08:18:33 +03:00
|
|
|
void Build(nsIMenuBuilder* aBuilder);
|
2013-02-18 15:59:08 +04:00
|
|
|
|
|
|
|
protected:
|
2014-07-09 01:23:16 +04:00
|
|
|
virtual ~HTMLMenuElement();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-02-18 15:59:08 +04:00
|
|
|
|
|
|
|
|
2011-08-08 21:31:32 +04:00
|
|
|
protected:
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool CanLoadIcon(nsIContent* aContent, const nsAString& aIcon);
|
2011-08-08 21:31:32 +04:00
|
|
|
|
|
|
|
void BuildSubmenu(const nsAString& aLabel,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsIMenuBuilder* aBuilder);
|
|
|
|
|
|
|
|
void TraverseContent(nsIContent* aContent,
|
|
|
|
nsIMenuBuilder* aBuilder,
|
2012-08-22 19:56:38 +04:00
|
|
|
int8_t& aSeparator);
|
2011-08-08 21:31:32 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void AddSeparator(nsIMenuBuilder* aBuilder, int8_t& aSeparator);
|
2011-08-08 21:31:32 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t mType;
|
2011-08-08 21:31:32 +04:00
|
|
|
};
|
2013-02-18 15:59:08 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLMenuElement_h
|