2011-08-08 10:31:32 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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 02:05:52 -08:00
|
|
|
#ifndef mozilla_dom_HTMLMenuItemElement_h
|
|
|
|
#define mozilla_dom_HTMLMenuItemElement_h
|
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-08-08 10:31:32 -07:00
|
|
|
#include "nsIDOMHTMLMenuItemElement.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
|
2013-02-18 02:05:52 -08:00
|
|
|
namespace mozilla {
|
2014-03-17 21:48:19 -07:00
|
|
|
|
|
|
|
class EventChainPreVisitor;
|
|
|
|
|
2013-02-18 02:05:52 -08:00
|
|
|
namespace dom {
|
|
|
|
|
2011-08-08 10:31:32 -07:00
|
|
|
class Visitor;
|
|
|
|
|
2013-07-11 14:26:54 -07:00
|
|
|
class HTMLMenuItemElement MOZ_FINAL : public nsGenericHTMLElement,
|
|
|
|
public nsIDOMHTMLMenuItemElement
|
2011-08-08 10:31:32 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-11-14 14:10:08 -08:00
|
|
|
using mozilla::dom::Element::GetText;
|
2012-01-09 09:58:30 -08:00
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
HTMLMenuItemElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
2013-02-18 02:05:52 -08:00
|
|
|
mozilla::dom::FromParser aFromParser);
|
2011-08-08 10:31:32 -07:00
|
|
|
|
2013-02-18 02:05:52 -08:00
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLMenuItemElement, menuitem)
|
2011-08-08 10:31:32 -07:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
// nsIDOMHTMLMenuItemElement
|
|
|
|
NS_DECL_NSIDOMHTMLMENUITEMELEMENT
|
|
|
|
|
2014-03-17 21:48:19 -07:00
|
|
|
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
|
2014-03-17 21:48:20 -07:00
|
|
|
virtual nsresult PostHandleEvent(
|
|
|
|
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
|
2011-08-08 10:31:32 -07:00
|
|
|
|
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2013-05-29 13:43:41 -07:00
|
|
|
bool aCompileEventHandlers) MOZ_OVERRIDE;
|
2011-08-08 10:31:32 -07:00
|
|
|
|
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,
|
2013-05-29 13:43:41 -07:00
|
|
|
nsAttrValue& aResult) MOZ_OVERRIDE;
|
2011-08-08 10:31:32 -07:00
|
|
|
|
2013-05-29 13:43:41 -07:00
|
|
|
virtual void DoneCreatingElement() MOZ_OVERRIDE;
|
2011-08-08 10:31:32 -07:00
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_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
|
|
|
|
|
|
|
/**
|
|
|
|
* Syntax sugar to make it easier to check for checked and checked dirty
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsChecked() const { return mChecked; }
|
|
|
|
bool IsCheckedDirty() const { return mCheckedDirty; }
|
2011-08-08 10:31:32 -07:00
|
|
|
|
2011-08-10 23:07:26 -07:00
|
|
|
void GetText(nsAString& aText);
|
|
|
|
|
2013-02-18 02:06:27 -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)
|
|
|
|
{
|
|
|
|
SetAttrHelper(nsGkAtoms::label, aLabel);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The XPCOM GetIcon is OK for us
|
|
|
|
void SetIcon(const nsAString& aIcon, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetAttrHelper(nsGkAtoms::icon, aIcon);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Disabled() const
|
|
|
|
{
|
|
|
|
return GetBoolAttr(nsGkAtoms::disabled);
|
|
|
|
}
|
|
|
|
void SetDisabled(bool aDisabled, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::disabled, aDisabled, aError);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Checked() const
|
|
|
|
{
|
|
|
|
return mChecked;
|
|
|
|
}
|
|
|
|
void SetChecked(bool aChecked, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
aError = SetChecked(aChecked);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The XPCOM GetRadiogroup is OK for us
|
|
|
|
void SetRadiogroup(const nsAString& aRadiogroup, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::radiogroup, aRadiogroup, aError);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DefaultChecked() const
|
|
|
|
{
|
|
|
|
return GetBoolAttr(nsGkAtoms::checked);
|
|
|
|
}
|
|
|
|
void SetDefaultChecked(bool aDefault, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::checked, aDefault, aError);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2014-07-08 14:23:16 -07:00
|
|
|
virtual ~HTMLMenuItemElement();
|
|
|
|
|
2014-04-08 15:27:17 -07:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE;
|
2013-02-18 02:06:27 -08:00
|
|
|
|
|
|
|
|
2011-08-08 10:31:32 -07:00
|
|
|
protected:
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
2013-05-29 13:43:41 -07:00
|
|
|
const nsAttrValue* aValue, bool aNotify) MOZ_OVERRIDE;
|
2011-08-08 10:31:32 -07:00
|
|
|
|
|
|
|
void WalkRadioGroup(Visitor* aVisitor);
|
|
|
|
|
2013-02-18 02:05:52 -08:00
|
|
|
HTMLMenuItemElement* GetSelectedRadio();
|
2011-08-08 10:31:32 -07:00
|
|
|
|
|
|
|
void AddedToRadioGroup();
|
|
|
|
|
|
|
|
void InitChecked();
|
|
|
|
|
|
|
|
friend class ClearCheckedVisitor;
|
|
|
|
friend class SetCheckedDirtyVisitor;
|
|
|
|
|
|
|
|
void ClearChecked() { mChecked = false; }
|
|
|
|
void SetCheckedDirty() { mCheckedDirty = true; }
|
|
|
|
|
|
|
|
private:
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mType : 2;
|
2011-08-08 10:31:32 -07:00
|
|
|
bool mParserCreating : 1;
|
|
|
|
bool mShouldInitChecked : 1;
|
|
|
|
bool mCheckedDirty : 1;
|
|
|
|
bool mChecked : 1;
|
|
|
|
};
|
2013-02-18 02:05:52 -08:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLMenuItemElement_h
|