Bug 838532 - Convert HTMLLegendElement to WebIDL. r=Ms2ger
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 15 Feb 2013 11:55:53 -0500
changeset 122044 5c6692663f05ef82a532c2fc4ab84fe84c7d1061
parent 122043 152576e8d44e7d1d3e8ddb236b4cb3cbde2aa542
child 122045 7bd555e2acfa1116d5dde68578511f85f7ac06cf
push id24315
push userryanvm@gmail.com
push dateFri, 15 Feb 2013 21:34:37 +0000
treeherdermozilla-central@7bd555e2acfa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
bugs838532
milestone21.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
Bug 838532 - Convert HTMLLegendElement to WebIDL. r=Ms2ger
content/html/content/src/HTMLLegendElement.cpp
content/html/content/src/HTMLLegendElement.h
dom/webidl/HTMLLegendElement.webidl
dom/webidl/WebIDL.mk
--- a/content/html/content/src/HTMLLegendElement.cpp
+++ b/content/html/content/src/HTMLLegendElement.cpp
@@ -1,14 +1,15 @@
 /* -*- Mode: C++; 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/. */
 
 #include "mozilla/dom/HTMLLegendElement.h"
+#include "mozilla/dom/HTMLLegendElementBinding.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsFocusManager.h"
 #include "nsIFrame.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Legend)
 DOMCI_NODE_DATA(HTMLLegendElement, mozilla::dom::HTMLLegendElement)
 
 
@@ -165,10 +166,26 @@ void
 HTMLLegendElement::PerformAccesskey(bool aKeyCausesActivation,
                                     bool aIsTrustedEvent)
 {
   // just use the same behaviour as the focus method
   ErrorResult rv;
   Focus(rv);
 }
 
+already_AddRefed<nsHTMLFormElement>
+HTMLLegendElement::GetForm()
+{
+  Element* form = GetFormElement();
+  MOZ_ASSERT_IF(form, form->IsHTML(nsGkAtoms::form));
+  nsRefPtr<nsHTMLFormElement> ret = static_cast<nsHTMLFormElement*>(form);
+  return ret.forget();
+}
+
+JSObject*
+HTMLLegendElement::WrapNode(JSContext* aCx, JSObject* aScope,
+                            bool* aTriedToWrap)
+{
+  return HTMLLegendElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/content/html/content/src/HTMLLegendElement.h
+++ b/content/html/content/src/HTMLLegendElement.h
@@ -3,16 +3,17 @@
  * 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/. */
 
 #ifndef mozilla_dom_HTMLLegendElement_h
 #define mozilla_dom_HTMLLegendElement_h
 
 #include "nsIDOMHTMLLegendElement.h"
 #include "nsGenericHTMLElement.h"
+#include "nsHTMLFormElement.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLLegendElement : public nsGenericHTMLElement,
                           public nsIDOMHTMLLegendElement
 {
 public:
@@ -71,17 +72,39 @@ public:
     nsCOMPtr<nsIFormControl> fieldsetControl = do_QueryInterface(GetFieldSet());
 
     return fieldsetControl ? fieldsetControl->GetFormElement() : nullptr;
   }
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
+
+  /**
+   * WebIDL Interface
+   */
+
+  already_AddRefed<nsHTMLFormElement> 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<nsINode*>(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.
    */
   nsIContent* GetFieldSet();
 };
 
 } // namespace dom
new file mode 100644
--- /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;
+};
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -73,16 +73,17 @@ webidl_files = \
   HTMLFontElement.webidl \
   HTMLFrameSetElement.webidl \
   HTMLHeadElement.webidl \
   HTMLHeadingElement.webidl \
   HTMLHRElement.webidl \
   HTMLHtmlElement.webidl \
   HTMLImageElement.webidl \
   HTMLLabelElement.webidl \
+  HTMLLegendElement.webidl \
   HTMLLIElement.webidl \
   HTMLLinkElement.webidl \
   HTMLMapElement.webidl \
   HTMLMetaElement.webidl \
   HTMLMeterElement.webidl \
   HTMLModElement.webidl \
   HTMLOListElement.webidl \
   HTMLOptGroupElement.webidl \