diff --git a/content/html/content/src/HTMLMenuElement.cpp b/content/html/content/src/HTMLMenuElement.cpp index d4115d351fdc..ae3c7002cb99 100644 --- a/content/html/content/src/HTMLMenuElement.cpp +++ b/content/html/content/src/HTMLMenuElement.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "HTMLMenuElement.h" +#include "mozilla/dom/HTMLMenuElementBinding.h" #include "nsXULContextMenuBuilder.h" #include "nsEventDispatcher.h" #include "nsHTMLMenuItemElement.h" @@ -44,6 +45,7 @@ enum SeparatorType HTMLMenuElement::HTMLMenuElement(already_AddRefed aNodeInfo) : nsGenericHTMLElement(aNodeInfo), mType(MENU_TYPE_LIST) { + SetIsDOMBinding(); } HTMLMenuElement::~HTMLMenuElement() @@ -256,5 +258,12 @@ HTMLMenuElement::AddSeparator(nsIMenuBuilder* aBuilder, int8_t& aSeparator) aSeparator = ST_TRUE; } +JSObject* +HTMLMenuElement::WrapNode(JSContext* aCx, JSObject* aScope, + bool* aTriedToWrap) +{ + return HTMLMenuElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + } // namespace dom } // namespace mozilla diff --git a/content/html/content/src/HTMLMenuElement.h b/content/html/content/src/HTMLMenuElement.h index 3f1dbd954079..e41a9b9db7c6 100644 --- a/content/html/content/src/HTMLMenuElement.h +++ b/content/html/content/src/HTMLMenuElement.h @@ -54,6 +54,35 @@ public: uint8_t GetType() const { return mType; } + // 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) + { + SetHTMLAttr(nsGkAtoms::label, aLabel, aError); + } + + bool Compact() const + { + return GetBoolAttr(nsGkAtoms::compact); + } + void SetCompact(bool aCompact, ErrorResult& aError) + { + SetHTMLBoolAttr(nsGkAtoms::compact, aCompact, aError); + } + + +protected: + virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope, + bool *aTriedToWrap) MOZ_OVERRIDE; + + protected: static bool CanLoadIcon(nsIContent* aContent, const nsAString& aIcon); diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 8f8e8d805725..259392c2e62e 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -419,6 +419,10 @@ DOMInterfaces = { 'hasInstanceInterface': 'nsIDOMHTMLLIElement', }, +'HTMLMenuElement': { + 'hasInstanceInterface': 'nsIDOMHTMLMenuElement', +}, + 'HTMLOListElement': { 'headerFile' : 'mozilla/dom/HTMLSharedListElement.h', 'hasInstanceInterface': 'nsIDOMHTMLOListElement' @@ -1220,7 +1224,6 @@ def addExternalHTMLElement(element): headerFile=nativeElement + '.h') addExternalHTMLElement('HTMLFormElement') -addExternalIface('HTMLMenuElement', nativeType='mozilla::dom::HTMLMenuElement', headerFile='HTMLMenuElement.h') addExternalHTMLElement('HTMLOptionElement') addExternalHTMLElement('HTMLOptGroupElement') addExternalHTMLElement('HTMLVideoElement') diff --git a/dom/webidl/HTMLElement.webidl b/dom/webidl/HTMLElement.webidl index c39c8a9528dd..9638b7de7b8c 100644 --- a/dom/webidl/HTMLElement.webidl +++ b/dom/webidl/HTMLElement.webidl @@ -13,7 +13,6 @@ */ interface DOMStringMap; -interface HTMLMenuElement; // Hack to make sure that we initialize the touch prefs properly [PrefControlled] diff --git a/dom/webidl/HTMLMenuElement.webidl b/dom/webidl/HTMLMenuElement.webidl new file mode 100644 index 000000000000..a695278462b6 --- /dev/null +++ b/dom/webidl/HTMLMenuElement.webidl @@ -0,0 +1,27 @@ +/* -*- 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-menu-element + * http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis + * + * © 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. + */ + +// http://www.whatwg.org/specs/web-apps/current-work/#the-menu-element +interface HTMLMenuElement : HTMLElement { + [SetterThrows] + attribute DOMString type; + [SetterThrows] + attribute DOMString label; +}; + +// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis +partial interface HTMLMenuElement { + [SetterThrows] + attribute boolean compact; +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index 6d9c4f10ea96..670cc07d26fb 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -71,6 +71,7 @@ webidl_files = \ HTMLImageElement.webidl \ HTMLLabelElement.webidl \ HTMLLIElement.webidl \ + HTMLMenuElement.webidl \ HTMLOListElement.webidl \ HTMLOptionsCollection.webidl \ HTMLParagraphElement.webidl \