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/. */
|
2010-07-15 22:07:21 +04:00
|
|
|
|
2013-02-18 16:24:58 +04:00
|
|
|
#ifndef mozilla_dom_HTMLOptionElement_h__
|
|
|
|
#define mozilla_dom_HTMLOptionElement_h__
|
2010-07-15 22:07:21 +04:00
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2010-07-15 22:07:21 +04:00
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsIDOMHTMLOptionElement.h"
|
2013-06-19 18:24:37 +04:00
|
|
|
#include "mozilla/dom/HTMLFormElement.h"
|
2010-07-15 22:07:21 +04:00
|
|
|
|
2013-02-18 16:24:58 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2013-04-04 11:03:33 +04:00
|
|
|
class HTMLSelectElement;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class HTMLOptionElement final : public nsGenericHTMLElement,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIDOMHTMLOptionElement
|
2010-07-15 22:07:21 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-09-02 04:49:25 +04:00
|
|
|
explicit HTMLOptionElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
|
2010-07-15 22:07:21 +04:00
|
|
|
|
2013-01-22 14:53:13 +04:00
|
|
|
static already_AddRefed<HTMLOptionElement>
|
2013-08-23 09:17:08 +04:00
|
|
|
Option(const GlobalObject& aGlobal,
|
|
|
|
const Optional<nsAString>& aText,
|
2013-01-22 14:53:13 +04:00
|
|
|
const Optional<nsAString>& aValue,
|
|
|
|
const Optional<bool>& aDefaultSelected,
|
|
|
|
const Optional<bool>& aSelected, ErrorResult& aError);
|
|
|
|
|
2013-02-18 16:24:58 +04:00
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLOptionElement, option)
|
2010-05-09 22:32:57 +04:00
|
|
|
|
2010-07-15 22:07:21 +04:00
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
// nsIDOMHTMLOptionElement
|
2012-11-15 02:10:08 +04:00
|
|
|
using mozilla::dom::Element::SetText;
|
|
|
|
using mozilla::dom::Element::GetText;
|
2010-07-15 22:07:21 +04:00
|
|
|
NS_DECL_NSIDOMHTMLOPTIONELEMENT
|
|
|
|
|
2011-06-28 14:45:51 +04:00
|
|
|
bool Selected() const;
|
|
|
|
bool DefaultSelected() const;
|
|
|
|
|
2010-07-15 22:07:21 +04:00
|
|
|
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
int32_t aModType) const override;
|
2010-07-15 22:07:21 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
2015-08-01 08:14:06 +03:00
|
|
|
nsAttrValueOrString* aValue,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aNotify) override;
|
2014-05-06 21:19:00 +04:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
2015-03-21 19:28:04 +03:00
|
|
|
const nsAttrValue* aValue, bool aNotify) override;
|
2012-02-14 06:00:56 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
void SetSelectedInternal(bool aValue, bool aNotify);
|
2010-07-15 22:07:21 +04:00
|
|
|
|
2012-06-01 13:46:43 +04:00
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aCompileEventHandlers) override;
|
2012-06-01 13:46:43 +04:00
|
|
|
virtual void UnbindFromTree(bool aDeep = true,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool aNullParent = true) override;
|
2012-06-01 13:46:43 +04:00
|
|
|
|
2010-07-15 22:07:21 +04:00
|
|
|
// nsIContent
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual EventStates IntrinsicState() const override;
|
2010-07-15 22:07:21 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const override;
|
2010-07-15 22:07:21 +04:00
|
|
|
|
2012-11-15 02:10:08 +04:00
|
|
|
nsresult CopyInnerTo(mozilla::dom::Element* aDest);
|
2010-07-15 22:07:21 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsDisabled() const override {
|
2012-03-10 14:57:19 +04:00
|
|
|
return HasAttr(kNameSpaceID_None, nsGkAtoms::disabled);
|
|
|
|
}
|
2013-02-18 16:26:57 +04:00
|
|
|
|
|
|
|
bool Disabled() const
|
|
|
|
{
|
|
|
|
return GetBoolAttr(nsGkAtoms::disabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetDisabled(bool aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::disabled, aValue, aRv);
|
|
|
|
}
|
|
|
|
|
2013-06-19 18:24:37 +04:00
|
|
|
HTMLFormElement* GetForm();
|
2013-02-18 16:26:57 +04:00
|
|
|
|
|
|
|
// The XPCOM GetLabel is OK for us
|
|
|
|
void SetLabel(const nsAString& aLabel, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::label, aLabel, aError);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The XPCOM DefaultSelected is OK for us
|
|
|
|
void SetDefaultSelected(bool aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::selected, aValue, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The XPCOM Selected is OK for us
|
|
|
|
void SetSelected(bool aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = SetSelected(aValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The XPCOM GetValue is OK for us
|
|
|
|
void SetValue(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
SetHTMLAttr(nsGkAtoms::value, aValue, aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The XPCOM GetText is OK for us
|
|
|
|
void SetText(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = SetText(aValue);
|
|
|
|
}
|
|
|
|
|
2013-08-14 10:57:04 +04:00
|
|
|
int32_t Index();
|
2013-02-18 16:26:57 +04:00
|
|
|
|
2010-07-15 22:07:21 +04:00
|
|
|
protected:
|
2014-07-09 01:23:16 +04:00
|
|
|
virtual ~HTMLOptionElement();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-02-18 16:26:57 +04:00
|
|
|
|
2010-07-15 22:07:21 +04:00
|
|
|
/**
|
|
|
|
* Get the select content element that contains this option, this
|
|
|
|
* intentionally does not return nsresult, all we care about is if
|
|
|
|
* there's a select associated with this option or not.
|
|
|
|
*/
|
2013-04-04 11:03:33 +04:00
|
|
|
HTMLSelectElement* GetSelect();
|
2010-07-15 22:07:21 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mSelectedChanged;
|
|
|
|
bool mIsSelected;
|
2010-07-15 22:07:21 +04:00
|
|
|
|
|
|
|
// True only while we're under the SetOptionsSelectedByIndex call when our
|
|
|
|
// "selected" attribute is changing and mSelectedChanged is false.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsInSetDefaultSelected;
|
2010-07-15 22:07:21 +04:00
|
|
|
};
|
|
|
|
|
2013-02-18 16:24:58 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_HTMLOptionElement_h__
|