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
|
|
|
|
2018-09-21 23:45:49 +03: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;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
|
2011-08-08 21:31:32 +04:00
|
|
|
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
|
2011-08-08 21:31:32 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID, 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) {
|
|
|
|
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
|