author | Andrea Marchesini <amarchesini@mozilla.com> |
Mon, 18 Feb 2013 13:26:57 +0100 | |
changeset 122240 | 68cb1f5270a8a7e7f16c94200b4bd77c941657de |
parent 122239 | ea6e27e21be80a32f4151a2e235eebbeae23fc45 |
child 122241 | 323f90679193965b5f0302e314088a14e3733a4d |
push id | 24327 |
push user | gszorc@mozilla.com |
push date | Tue, 19 Feb 2013 05:22:32 +0000 |
treeherder | mozilla-central@e8f8a3f6f1f6 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | Ms2ger |
bugs | 839447 |
milestone | 21.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/content/html/content/src/HTMLOptionElement.cpp +++ b/content/html/content/src/HTMLOptionElement.cpp @@ -1,15 +1,16 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=2 sw=2 et tw=78: */ /* 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/. */ #include "mozilla/dom/HTMLOptionElement.h" +#include "mozilla/dom/HTMLOptionElementBinding.h" #include "nsHTMLSelectElement.h" #include "nsIDOMHTMLOptGroupElement.h" #include "nsIDOMHTMLFormElement.h" #include "nsIDOMEventTarget.h" #include "nsGkAtoms.h" #include "nsStyleConsts.h" #include "nsIFormControl.h" #include "nsIForm.h" @@ -61,16 +62,18 @@ namespace mozilla { namespace dom { HTMLOptionElement::HTMLOptionElement(already_AddRefed<nsINodeInfo> aNodeInfo) : nsGenericHTMLElement(aNodeInfo), mSelectedChanged(false), mIsSelected(false), mIsInSetDefaultSelected(false) { + SetIsDOMBinding(); + // We start off enabled AddStatesSilently(NS_EVENT_STATE_ENABLED); } HTMLOptionElement::~HTMLOptionElement() { } @@ -93,25 +96,25 @@ NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLA NS_IMPL_ELEMENT_CLONE(HTMLOptionElement) NS_IMETHODIMP HTMLOptionElement::GetForm(nsIDOMHTMLFormElement** aForm) { NS_ENSURE_ARG_POINTER(aForm); - *aForm = nullptr; - - nsHTMLSelectElement* selectControl = GetSelect(); + *aForm = GetForm(); + return NS_OK; +} - if (selectControl) { - selectControl->GetForm(aForm); - } - - return NS_OK; +nsHTMLFormElement* +HTMLOptionElement::GetForm() +{ + nsHTMLSelectElement* selectControl = GetSelect(); + return selectControl ? selectControl->GetForm() : nullptr; } void HTMLOptionElement::SetSelectedInternal(bool aValue, bool aNotify) { mSelectedChanged = true; mIsSelected = aValue; @@ -453,10 +456,16 @@ HTMLOptionElement::CopyInnerTo(Element* NS_ENSURE_SUCCESS(rv, rv); if (aDest->OwnerDoc()->IsStaticDocument()) { static_cast<HTMLOptionElement*>(aDest)->SetSelected(Selected()); } return NS_OK; } +JSObject* +HTMLOptionElement::WrapNode(JSContext* aCx, JSObject* aScope, bool* aTriedToWrap) +{ + return HTMLOptionElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + } // namespace dom } // namespace mozilla
--- a/content/html/content/src/HTMLOptionElement.h +++ b/content/html/content/src/HTMLOptionElement.h @@ -5,16 +5,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef mozilla_dom_HTMLOptionElement_h__ #define mozilla_dom_HTMLOptionElement_h__ #include "nsGenericHTMLElement.h" #include "nsIDOMHTMLOptionElement.h" #include "nsIJSNativeInitializer.h" +#include "nsHTMLFormElement.h" class nsHTMLSelectElement; namespace mozilla { namespace dom { class HTMLOptionElement : public nsGenericHTMLElement, public nsIDOMHTMLOptionElement, @@ -43,17 +44,17 @@ public: using mozilla::dom::Element::GetText; NS_DECL_NSIDOMHTMLOPTIONELEMENT bool Selected() const; bool DefaultSelected() const; // nsIJSNativeInitializer NS_IMETHOD Initialize(nsISupports* aOwner, JSContext* aContext, - JSObject *aObj, uint32_t argc, jsval *argv); + JSObject* aObj, uint32_t argc, jsval* argv); virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, int32_t aModType) const; virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValueOrString* aValue, bool aNotify); @@ -63,28 +64,81 @@ public: nsIContent* aBindingParent, bool aCompileEventHandlers); virtual void UnbindFromTree(bool aDeep = true, bool aNullParent = true); // nsIContent virtual nsEventStates IntrinsicState() const; - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; + virtual nsresult Clone(nsINodeInfo* aNodeInfo, nsINode** aResult) const; nsresult CopyInnerTo(mozilla::dom::Element* aDest); virtual nsXPCClassInfo* GetClassInfo(); virtual nsIDOMNode* AsDOMNode() { return this; } virtual bool IsDisabled() const { return HasAttr(kNameSpaceID_None, nsGkAtoms::disabled); } + + bool Disabled() const + { + return GetBoolAttr(nsGkAtoms::disabled); + } + + void SetDisabled(bool aValue, ErrorResult& aRv) + { + SetHTMLBoolAttr(nsGkAtoms::disabled, aValue, aRv); + } + + nsHTMLFormElement* GetForm(); + + // 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); + } + + int32_t GetIndex(ErrorResult& aRv) + { + int32_t id = 0; + aRv = GetIndex(&id); + return id; + } + protected: + virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope, + bool* aTriedToWrap) MOZ_OVERRIDE; + /** * 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. */ nsHTMLSelectElement* GetSelect(); bool mSelectedChanged;
--- a/content/html/content/src/nsHTMLSelectElement.h +++ b/content/html/content/src/nsHTMLSelectElement.h @@ -730,17 +730,17 @@ protected: void nsHTMLOptionCollection::Add(const HTMLOptionOrOptGroupElement& aElement, const Nullable<HTMLElementOrLong>& aBefore, mozilla::ErrorResult& aError) { nsGenericHTMLElement& element = aElement.IsHTMLOptionElement() ? - static_cast<nsGenericHTMLElement&>(*aElement.GetAsHTMLOptionElement()) : + static_cast<nsGenericHTMLElement&>(aElement.GetAsHTMLOptionElement()) : static_cast<nsGenericHTMLElement&>(aElement.GetAsHTMLOptGroupElement()); if (aBefore.IsNull()) { mSelect->Add(element, (nsGenericHTMLElement*)nullptr, aError); } else if (aBefore.Value().IsHTMLElement()) { mSelect->Add(element, &aBefore.Value().GetAsHTMLElement(), aError); } else { mSelect->Add(element, aBefore.Value().GetAsLong(), aError);
--- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1172,17 +1172,16 @@ def addExternalIface(iface, nativeType=N # If you add one of these, you need to make sure nsDOMQS.h has the relevant # macros added for it def addExternalHTMLElement(element): nativeElement = 'ns' + element addExternalIface(element, nativeType=nativeElement, headerFile=nativeElement + '.h') addExternalHTMLElement('HTMLFormElement') -addExternalIface('HTMLOptionElement', nativeType='mozilla::dom::HTMLOptionElement') addExternalHTMLElement('HTMLVideoElement') addExternalIface('Attr') addExternalIface('CanvasGradient', headerFile='nsIDOMCanvasRenderingContext2D.h') addExternalIface('CanvasPattern', headerFile='nsIDOMCanvasRenderingContext2D.h') addExternalIface('ClientRect') addExternalIface("Counter") addExternalIface('CSSRule') addExternalIface('DOMRequest')
new file mode 100644 --- /dev/null +++ b/dom/webidl/HTMLOptionElement.webidl @@ -0,0 +1,38 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. + * + * The origin of this IDL file is + * http://www.whatwg.org/specs/web-apps/current-work/#the-option-element + * + * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and + * Opera Software ASA. You are granted a license to use, reproduce + * and create derivative works of this document. + */ + +/* TODO: Bug 842276 + * [NamedConstructor=Option(), + * NamedConstructor=Option(DOMString text), + * NamedConstructor=Option(DOMString text, DOMString value), + * NamedConstructor=Option(DOMString text, DOMString value, boolean defaultSelected), + * NamedConstructor=Option(DOMString text, DOMString value, boolean defaultSelected, boolean selected)] + */ +interface HTMLOptionElement : HTMLElement { + [SetterThrows] + attribute boolean disabled; + readonly attribute HTMLFormElement? form; + [SetterThrows] + attribute DOMString label; + [SetterThrows] + attribute boolean defaultSelected; + [SetterThrows] + attribute boolean selected; + [SetterThrows] + attribute DOMString value; + + [SetterThrows] + attribute DOMString text; + [GetterThrows] + readonly attribute long index; +};
--- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -85,16 +85,17 @@ webidl_files = \ HTMLMapElement.webidl \ HTMLMenuElement.webidl \ HTMLMenuItemElement.webidl \ HTMLMetaElement.webidl \ HTMLMeterElement.webidl \ HTMLModElement.webidl \ HTMLOListElement.webidl \ HTMLOptGroupElement.webidl \ + HTMLOptionElement.webidl \ HTMLOptionsCollection.webidl \ HTMLOutputElement.webidl \ HTMLParagraphElement.webidl \ HTMLParamElement.webidl \ HTMLPreElement.webidl \ HTMLProgressElement.webidl \ HTMLPropertiesCollection.webidl \ HTMLQuoteElement.webidl \