From c6c00b063d52920e7415dc225b3132591a48f96e Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Fri, 15 Feb 2013 11:55:53 -0500 Subject: [PATCH] Bug 838532 - Convert HTMLLegendElement to WebIDL. r=Ms2ger --- .../html/content/src/HTMLLegendElement.cpp | 17 ++++++++++++++ content/html/content/src/HTMLLegendElement.h | 23 +++++++++++++++++++ dom/webidl/HTMLLegendElement.webidl | 23 +++++++++++++++++++ dom/webidl/WebIDL.mk | 1 + 4 files changed, 64 insertions(+) create mode 100644 dom/webidl/HTMLLegendElement.webidl diff --git a/content/html/content/src/HTMLLegendElement.cpp b/content/html/content/src/HTMLLegendElement.cpp index 7b06880da07..05d6ebf13c3 100644 --- a/content/html/content/src/HTMLLegendElement.cpp +++ b/content/html/content/src/HTMLLegendElement.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/dom/HTMLLegendElement.h" +#include "mozilla/dom/HTMLLegendElementBinding.h" #include "nsIDOMHTMLFormElement.h" #include "nsFocusManager.h" #include "nsIFrame.h" @@ -170,5 +171,21 @@ HTMLLegendElement::PerformAccesskey(bool aKeyCausesActivation, Focus(rv); } +already_AddRefed +HTMLLegendElement::GetForm() +{ + Element* form = GetFormElement(); + MOZ_ASSERT_IF(form, form->IsHTML(nsGkAtoms::form)); + nsRefPtr ret = static_cast(form); + return ret.forget(); +} + +JSObject* +HTMLLegendElement::WrapNode(JSContext* aCx, JSObject* aScope, + bool* aTriedToWrap) +{ + return HTMLLegendElementBinding::Wrap(aCx, aScope, this, aTriedToWrap); +} + } // namespace dom } // namespace mozilla diff --git a/content/html/content/src/HTMLLegendElement.h b/content/html/content/src/HTMLLegendElement.h index cecb44ca5e9..8a8838a5cdf 100644 --- a/content/html/content/src/HTMLLegendElement.h +++ b/content/html/content/src/HTMLLegendElement.h @@ -8,6 +8,7 @@ #include "nsIDOMHTMLLegendElement.h" #include "nsGenericHTMLElement.h" +#include "nsHTMLFormElement.h" namespace mozilla { namespace dom { @@ -76,7 +77,29 @@ public: virtual nsXPCClassInfo* GetClassInfo(); virtual nsIDOMNode* AsDOMNode() { return this; } + + /** + * WebIDL Interface + */ + + already_AddRefed GetForm(); + + // The XPCOM GetAlign is OK for us + void SetAlign(const nsAString& aAlign, ErrorResult& aError) + { + SetHTMLAttr(nsGkAtoms::align, aAlign, aError); + } + + nsINode* GetParentObject() { + Element* form = GetFormElement(); + return form ? static_cast(form) + : nsGenericHTMLElement::GetParentObject(); + } + protected: + virtual JSObject* WrapNode(JSContext* aCx, JSObject* aScope, + bool* aTriedToWrap) MOZ_OVERRIDE; + /** * Get the fieldset content element that contains this legend. * Returns null if there is no fieldset containing this legend. diff --git a/dom/webidl/HTMLLegendElement.webidl b/dom/webidl/HTMLLegendElement.webidl new file mode 100644 index 00000000000..b13da7e54e5 --- /dev/null +++ b/dom/webidl/HTMLLegendElement.webidl @@ -0,0 +1,23 @@ +/* -*- 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-legend-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-legend-element +interface HTMLLegendElement : HTMLElement { + readonly attribute HTMLFormElement? form; +}; + +// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis +partial interface HTMLLegendElement { + attribute DOMString align; +}; diff --git a/dom/webidl/WebIDL.mk b/dom/webidl/WebIDL.mk index e47083bad9d..f67b6954642 100644 --- a/dom/webidl/WebIDL.mk +++ b/dom/webidl/WebIDL.mk @@ -78,6 +78,7 @@ webidl_files = \ HTMLHtmlElement.webidl \ HTMLImageElement.webidl \ HTMLLabelElement.webidl \ + HTMLLegendElement.webidl \ HTMLLIElement.webidl \ HTMLLinkElement.webidl \ HTMLMapElement.webidl \