Bug 824823 part 11. Switch HTMLParagraphElement to WebIDL. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 04 Jan 2013 12:02:15 -0500
changeset 126737 5ae68b7b5126b88ba3c9b994f294cce5b346c2f5
parent 126736 595031ea34975a07e3c54f414f693c93b629f9e7
child 126738 dacf95e8cfcdadaeab0a26239b95107cc9f93683
push idunknown
push userunknown
push dateunknown
reviewerspeterv
bugs824823
milestone20.0a1
Bug 824823 part 11. Switch HTMLParagraphElement to WebIDL. r=peterv
content/html/content/src/HTMLParagraphElement.cpp
content/html/content/src/HTMLParagraphElement.h
dom/bindings/Bindings.conf
dom/webidl/HTMLParagraphElement.webidl
dom/webidl/WebIDL.mk
--- a/content/html/content/src/HTMLParagraphElement.cpp
+++ b/content/html/content/src/HTMLParagraphElement.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/HTMLParagraphElement.h"
+#include "mozilla/dom/HTMLParagraphElementBinding.h"
 
 #include "nsStyleConsts.h"
 #include "nsMappedAttributes.h"
 #include "nsRuleData.h"
 
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Paragraph)
 DOMCI_NODE_DATA(HTMLParagraphElement, mozilla::dom::HTMLParagraphElement)
@@ -69,10 +70,16 @@ HTMLParagraphElement::IsAttributeMapped(
 
 
 nsMapRuleToAttributesFunc
 HTMLParagraphElement::GetAttributeMappingFunction() const
 {
   return &MapAttributesIntoRule;
 }
 
+JSObject*
+HTMLParagraphElement::WrapNode(JSContext *aCx, JSObject *aScope, bool *aTriedToWrap)
+{
+  return HTMLParagraphElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
+
 } // namespace dom
 } // namespace mozilla
--- a/content/html/content/src/HTMLParagraphElement.h
+++ b/content/html/content/src/HTMLParagraphElement.h
@@ -16,16 +16,17 @@ namespace dom {
 
 class HTMLParagraphElement : public nsGenericHTMLElement,
                              public nsIDOMHTMLParagraphElement
 {
 public:
   HTMLParagraphElement(already_AddRefed<nsINodeInfo> aNodeInfo)
     : nsGenericHTMLElement(aNodeInfo)
   {
+    SetIsDOMBinding();
   }
   virtual ~HTMLParagraphElement();
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
@@ -46,14 +47,25 @@ public:
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
+
+  // WebIDL API
+  // The XPCOM GetAlign is fine for our purposes
+  void SetAlign(const nsAString& aValue, mozilla::ErrorResult& rv)
+  {
+    SetHTMLAttr(nsGkAtoms::align, aValue, rv);
+  }
+
+protected:
+  virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
+                             bool *aTriedToWrap) MOZ_OVERRIDE;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_HTMLParagraphElement_h
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -390,16 +390,20 @@ DOMInterfaces = {
     'nativeType': 'nsHTMLOptionCollection',
     'headerFile': 'nsHTMLSelectElement.h',
     'resultNotAddRefed': [ 'item' ],
     'binaryNames': {
         '__indexedsettercreator': 'SetOption'
     }
 },
 
+'HTMLParagraphElement': {
+    'hasInstanceInterface': 'nsIDOMHTMLParagraphElement',
+},
+
 'HTMLPropertiesCollection': {
     'headerFile': 'HTMLPropertiesCollection.h',
     'resultNotAddRefed': [ 'item', 'namedItem', 'names' ]
 },
 
 'HTMLUListElement': {
     'headerFile' : 'mozilla/dom/HTMLSharedListElement.h'
 },
new file mode 100644
--- /dev/null
+++ b/dom/webidl/HTMLParagraphElement.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-p-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-p-element
+interface HTMLParagraphElement : HTMLElement {
+/*};
+
+// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
+partial interface HTMLParagraphElement {
+*/
+           [SetterThrows]
+           attribute DOMString align;
+};
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -62,16 +62,17 @@ webidl_files = \
   HTMLFontElement.webidl \
   HTMLFrameSetElement.webidl \
   HTMLHeadingElement.webidl \
   HTMLImageElement.webidl \
   HTMLLabelElement.webidl \
   HTMLLIElement.webidl \
   HTMLOListElement.webidl \
   HTMLOptionsCollection.webidl \
+  HTMLParagraphElement.webidl \
   HTMLPropertiesCollection.webidl \
   HTMLTitleElement.webidl \
   HTMLUListElement.webidl \
   ImageData.webidl \
   Location.webidl \
   MutationObserver.webidl \
   Node.webidl \
   NodeFilter.webidl \