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 10:05:52 +00:00
|
|
|
#ifndef mozilla_dom_HTMLMenuItemElement_h
|
|
|
|
#define mozilla_dom_HTMLMenuItemElement_h
|
|
|
|
|
2013-05-29 20:43:41 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-08-08 17:31:32 +00:00
|
|
|
#include "nsIDOMHTMLMenuItemElement.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
|
2013-02-18 10:05:52 +00:00
|
|
|
namespace mozilla {
|
2014-03-18 04:48:19 +00:00
|
|
|
|
|
|
|
class EventChainPreVisitor;
|
|
|
|
|
2013-02-18 10:05:52 +00:00
|
|
|
namespace dom {
|
|
|
|
|
2011-08-08 17:31:32 +00:00
|
|
|
class Visitor;
|
|
|
|
|
2013-07-11 21:26:54 +00:00
|
|
|
class HTMLMenuItemElement MOZ_FINAL : public nsGenericHTMLElement,
|
|
|
|
public nsIDOMHTMLMenuItemElement
|
2011-08-08 17:31:32 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-11-14 22:10:08 +00:00
|
|
|
using mozilla::dom::Element::GetText;
|
2012-01-09 17:58:30 +00:00
|
|
|
|
2014-06-20 02:01:40 +00:00
|
|
|
HTMLMenuItemElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
2013-02-18 10:05:52 +00:00
|
|
|
mozilla::dom::FromParser aFromParser);
|
2011-08-08 17:31:32 +00:00
|
|
|
|
2013-02-18 10:05:52 +00:00
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLMenuItemElement, menuitem)
|
2011-08-08 17:31:32 +00:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
// nsIDOMHTMLMenuItemElement
|
|
|
|
NS_DECL_NSIDOMHTMLMENUITEMELEMENT
|
|
|
|
|
2014-03-18 04:48:19 +00:00
|
|
|
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
|
2014-03-18 04:48:20 +00:00
|
|
|
virtual nsresult PostHandleEvent(
|
|
|
|
EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
|
2011-08-08 17:31:32 +00:00
|
|
|
|
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2013-05-29 20:43:41 +00:00
|
|
|
bool aCompileEventHandlers) MOZ_OVERRIDE;
|
2011-08-08 17:31:32 +00:00
|
|
|
|
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,
|
2013-05-29 20:43:41 +00:00
|
|
|
nsAttrValue& aResult) MOZ_OVERRIDE;
|
2011-08-08 17:31:32 +00:00
|
|
|
|
2013-05-29 20:43:41 +00:00
|
|
|
virtual void DoneCreatingElement() MOZ_OVERRIDE;
|
2011-08-08 17:31:32 +00:00
|
|
|
|
2014-06-20 02:01:40 +00:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const MOZ_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
|
|
|
|
|
|
|
/**
|
|
|
|
* Syntax sugar to make it easier to check for checked and checked dirty
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsChecked() const { return mChecked; }
|
|
|
|
bool IsCheckedDirty() const { return mCheckedDirty; }
|
2011-08-08 17:31:32 +00:00
|
|
|
|
2011-08-11 06:07:26 +00:00
|
|
|
void GetText(nsAString& aText);
|
|
|
|
|
2013-02-18 10:06:27 +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)
|
|
|
|
{
|
|
|
|
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 21:23:16 +00:00
|
|
|
virtual ~HTMLMenuItemElement();
|
|
|
|
|
2014-04-08 22:27:17 +00:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx) MOZ_OVERRIDE;
|
2013-02-18 10:06:27 +00:00
|
|
|
|
|
|
|
|
2011-08-08 17:31:32 +00:00
|
|
|
protected:
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
2013-05-29 20:43:41 +00:00
|
|
|
const nsAttrValue* aValue, bool aNotify) MOZ_OVERRIDE;
|
2011-08-08 17:31:32 +00:00
|
|
|
|
|
|
|
void WalkRadioGroup(Visitor* aVisitor);
|
|
|
|
|
2013-02-18 10:05:52 +00:00
|
|
|
HTMLMenuItemElement* GetSelectedRadio();
|
2011-08-08 17:31:32 +00:00
|
|
|
|
|
|
|
void AddedToRadioGroup();
|
|
|
|
|
|
|
|
void InitChecked();
|
|
|
|
|
|
|
|
friend class ClearCheckedVisitor;
|
|
|
|
friend class SetCheckedDirtyVisitor;
|
|
|
|
|
|
|
|
void ClearChecked() { mChecked = false; }
|
|
|
|
void SetCheckedDirty() { mCheckedDirty = true; }
|
|
|
|
|
|
|
|
private:
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t mType : 2;
|
2011-08-08 17:31:32 +00:00
|
|
|
bool mParserCreating : 1;
|
|
|
|
bool mShouldInitChecked : 1;
|
|
|
|
bool mCheckedDirty : 1;
|
|
|
|
bool mChecked : 1;
|
|
|
|
};
|
2013-02-18 10:05:52 +00:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLMenuItemElement_h
|