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 14:05:52 +04:00
|
|
|
#ifndef mozilla_dom_HTMLMenuItemElement_h
|
|
|
|
#define mozilla_dom_HTMLMenuItemElement_h
|
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2011-08-08 21:31:32 +04:00
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
|
2013-02-18 14:05:52 +04:00
|
|
|
namespace mozilla {
|
2014-03-18 08:48:19 +04:00
|
|
|
|
|
|
|
class EventChainPreVisitor;
|
|
|
|
|
2013-02-18 14:05:52 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2011-08-08 21:31:32 +04:00
|
|
|
class Visitor;
|
|
|
|
|
2017-10-13 01:10:50 +03:00
|
|
|
class HTMLMenuItemElement final : public nsGenericHTMLElement
|
2011-08-08 21:31:32 +04:00
|
|
|
{
|
|
|
|
public:
|
2012-11-15 02:10:08 +04:00
|
|
|
using mozilla::dom::Element::GetText;
|
2012-01-09 21:58:30 +04:00
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
HTMLMenuItemElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
2013-02-18 14:05:52 +04:00
|
|
|
mozilla::dom::FromParser aFromParser);
|
2011-08-08 21:31:32 +04:00
|
|
|
|
2018-03-22 00:39:04 +03:00
|
|
|
NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLMenuItemElement, menuitem)
|
2011-08-08 21:31:32 +04:00
|
|
|
|
|
|
|
// nsISupports
|
2018-02-12 23:44:40 +03:00
|
|
|
NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLMenuItemElement,
|
|
|
|
nsGenericHTMLElement)
|
2011-08-08 21:31:32 +04:00
|
|
|
|
2018-04-05 20:42:41 +03:00
|
|
|
void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
|
2014-03-18 08:48:20 +04:00
|
|
|
virtual nsresult PostHandleEvent(
|
2015-03-21 19:28:04 +03:00
|
|
|
EventChainPostVisitor& aVisitor) override;
|
2011-08-08 21:31:32 +04:00
|
|
|
|
2018-07-31 21:18:38 +03:00
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument,
|
|
|
|
nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent) override;
|
2011-08-08 21:31:32 +04:00
|
|
|
|
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
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DoneCreatingElement() override;
|
2011-08-08 21:31:32 +04:00
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) 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
|
|
|
|
|
|
|
/**
|
|
|
|
* Syntax sugar to make it easier to check for checked and checked dirty
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsChecked() const { return mChecked; }
|
|
|
|
bool IsCheckedDirty() const { return mCheckedDirty; }
|
2011-08-08 21:31:32 +04:00
|
|
|
|
2011-08-11 10:07:26 +04:00
|
|
|
void GetText(nsAString& aText);
|
|
|
|
|
2013-02-18 14:06:27 +04:00
|
|
|
// WebIDL
|
|
|
|
|
2017-10-13 01:10:50 +03:00
|
|
|
void GetType(DOMString& aValue);
|
2013-02-18 14:06:27 +04:00
|
|
|
void SetType(const nsAString& aType, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::type, aType, aError);
|
|
|
|
}
|
|
|
|
|
2017-10-13 01:10:50 +03:00
|
|
|
// nsAString needed for HTMLMenuElement
|
|
|
|
void GetLabel(nsAString& aValue)
|
|
|
|
{
|
|
|
|
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::label, aValue)) {
|
|
|
|
GetText(aValue);
|
|
|
|
}
|
|
|
|
}
|
2013-02-18 14:06:27 +04:00
|
|
|
void SetLabel(const nsAString& aLabel, ErrorResult& aError)
|
|
|
|
{
|
2017-10-13 01:10:50 +03:00
|
|
|
SetHTMLAttr(nsGkAtoms::label, aLabel, aError);
|
2013-02-18 14:06:27 +04:00
|
|
|
}
|
|
|
|
|
2017-10-13 01:10:50 +03:00
|
|
|
// nsAString needed for HTMLMenuElement
|
|
|
|
void GetIcon(nsAString& aValue)
|
|
|
|
{
|
|
|
|
GetURIAttr(nsGkAtoms::icon, nullptr, aValue);
|
|
|
|
}
|
2013-02-18 14:06:27 +04:00
|
|
|
void SetIcon(const nsAString& aIcon, ErrorResult& aError)
|
|
|
|
{
|
2017-10-13 01:10:50 +03:00
|
|
|
SetHTMLAttr(nsGkAtoms::icon, aIcon, aError);
|
2013-02-18 14:06:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Disabled() const
|
|
|
|
{
|
|
|
|
return GetBoolAttr(nsGkAtoms::disabled);
|
|
|
|
}
|
|
|
|
void SetDisabled(bool aDisabled, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::disabled, aDisabled, aError);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Checked() const
|
|
|
|
{
|
|
|
|
return mChecked;
|
|
|
|
}
|
2017-10-13 01:10:50 +03:00
|
|
|
void SetChecked(bool aChecked);
|
|
|
|
|
|
|
|
void GetRadiogroup(DOMString& aValue)
|
2013-02-18 14:06:27 +04:00
|
|
|
{
|
2017-10-13 01:10:50 +03:00
|
|
|
GetHTMLAttr(nsGkAtoms::radiogroup, aValue);
|
2013-02-18 14:06:27 +04:00
|
|
|
}
|
|
|
|
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-09 01:23:16 +04:00
|
|
|
virtual ~HTMLMenuItemElement();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-02-18 14:06:27 +04:00
|
|
|
|
|
|
|
|
2011-08-08 21:31:32 +04:00
|
|
|
protected:
|
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;
|
2011-08-08 21:31:32 +04:00
|
|
|
|
|
|
|
void WalkRadioGroup(Visitor* aVisitor);
|
|
|
|
|
2013-02-18 14:05:52 +04:00
|
|
|
HTMLMenuItemElement* GetSelectedRadio();
|
2011-08-08 21:31:32 +04:00
|
|
|
|
|
|
|
void AddedToRadioGroup();
|
|
|
|
|
|
|
|
void InitChecked();
|
|
|
|
|
|
|
|
friend class ClearCheckedVisitor;
|
|
|
|
friend class SetCheckedDirtyVisitor;
|
|
|
|
|
|
|
|
void ClearChecked() { mChecked = false; }
|
|
|
|
void SetCheckedDirty() { mCheckedDirty = true; }
|
|
|
|
|
|
|
|
private:
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t mType : 2;
|
2011-08-08 21:31:32 +04:00
|
|
|
bool mParserCreating : 1;
|
|
|
|
bool mShouldInitChecked : 1;
|
|
|
|
bool mCheckedDirty : 1;
|
|
|
|
bool mChecked : 1;
|
|
|
|
};
|
2013-02-18 14:05:52 +04:00
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLMenuItemElement_h
|