Fix for bug 824907 (Convert HTML table elements to WebIDL) - convert HTMLTableColElement to WebIDL. r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Sat, 29 Dec 2012 15:07:57 +0100
changeset 126851 0a67f83f18cb05a991401d82bdae8197bb15ae37
parent 126850 abd3e75c995cbe2c96a6f181b9563f430abc93d0
child 126852 1367089491f9e5cf9704f09396fdf1cef00be97a
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs824907
milestone20.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
Fix for bug 824907 (Convert HTML table elements to WebIDL) - convert HTMLTableColElement to WebIDL. r=bz.
content/html/content/src/HTMLTableCaptionElement.cpp
content/html/content/src/HTMLTableCaptionElement.h
content/html/content/src/HTMLTableCellElement.cpp
content/html/content/src/HTMLTableCellElement.h
content/html/content/src/HTMLTableColElement.cpp
content/html/content/src/HTMLTableColElement.h
content/html/content/src/HTMLTableElement.cpp
content/html/content/src/HTMLTableElement.h
content/html/content/src/HTMLTableRowElement.cpp
content/html/content/src/HTMLTableRowElement.h
content/html/content/src/HTMLTableSectionElement.cpp
content/html/content/src/HTMLTableSectionElement.h
content/html/content/test/reflect.js
dom/bindings/Bindings.conf
dom/interfaces/html/nsIDOMHTMLTableSectionElement.idl
dom/webidl/HTMLTableColElement.webidl
dom/webidl/WebIDL.mk
js/xpconnect/src/dom_quickstubs.qsconf
--- a/content/html/content/src/HTMLTableColElement.cpp
+++ b/content/html/content/src/HTMLTableColElement.cpp
@@ -3,55 +3,152 @@
  * 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/Util.h"
 
 #include "mozilla/dom/HTMLTableColElement.h"
 #include "nsMappedAttributes.h"
 #include "nsAttrValueInlines.h"
-#include "nsGkAtoms.h"
-#include "nsStyleConsts.h"
 #include "nsRuleData.h"
+#include "mozilla/dom/HTMLTableColElementBinding.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(TableCol)
 DOMCI_NODE_DATA(HTMLTableColElement, mozilla::dom::HTMLTableColElement)
 
 namespace mozilla {
 namespace dom {
 
 // use the same protection as ancient code did 
 // http://lxr.mozilla.org/classic/source/lib/layout/laytable.c#46
 #define MAX_COLSPAN 1000
 
 HTMLTableColElement::~HTMLTableColElement()
 {
 }
 
+JSObject*
+HTMLTableColElement::WrapNode(JSContext *aCx, JSObject *aScope,
+                              bool *aTriedToWrap)
+{
+  return HTMLTableColElementBinding::Wrap(aCx, aScope, this, aTriedToWrap);
+}
+
 NS_IMPL_ADDREF_INHERITED(HTMLTableColElement, Element)
 NS_IMPL_RELEASE_INHERITED(HTMLTableColElement, Element)
 
 // QueryInterface implementation for HTMLTableColElement
 NS_INTERFACE_TABLE_HEAD(HTMLTableColElement)
   NS_HTML_CONTENT_INTERFACE_TABLE1(HTMLTableColElement,
                                    nsIDOMHTMLTableColElement)
   NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(HTMLTableColElement,
                                                nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableColElement)
 
 NS_IMPL_ELEMENT_CLONE(HTMLTableColElement)
 
+NS_IMETHODIMP
+HTMLTableColElement::SetSpan(int32_t aSpan)
+{
+  ErrorResult rv;
+  SetSpan(aSpan, rv);
+  return rv.ErrorCode();
+}
 
-NS_IMPL_STRING_ATTR(HTMLTableColElement, Align, align)
-NS_IMPL_STRING_ATTR(HTMLTableColElement, Ch, _char)
-NS_IMPL_STRING_ATTR(HTMLTableColElement, ChOff, charoff)
-NS_IMPL_INT_ATTR_DEFAULT_VALUE(HTMLTableColElement, Span, span, 1)
-NS_IMPL_STRING_ATTR(HTMLTableColElement, VAlign, valign)
-NS_IMPL_STRING_ATTR(HTMLTableColElement, Width, width)
+NS_IMETHODIMP
+HTMLTableColElement::GetSpan(int32_t* aSpan)
+{
+  *aSpan = Span();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+HTMLTableColElement::SetAlign(const nsAString& aAlign)
+{
+  ErrorResult rv;
+  SetAlign(aAlign, rv);
+  return rv.ErrorCode();
+}
+
+NS_IMETHODIMP
+HTMLTableColElement::GetAlign(nsAString& aAlign)
+{
+  nsString align;
+  GetAlign(align);
+  aAlign = align;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+HTMLTableColElement::SetVAlign(const nsAString& aVAlign)
+{
+  ErrorResult rv;
+  SetVAlign(aVAlign, rv);
+  return rv.ErrorCode();
+}
+
+NS_IMETHODIMP
+HTMLTableColElement::GetVAlign(nsAString& aVAlign)
+{
+  nsString vAlign;
+  GetVAlign(vAlign);
+  aVAlign = vAlign;
+  return NS_OK;
+}
 
+NS_IMETHODIMP
+HTMLTableColElement::SetCh(const nsAString& aCh)
+{
+  ErrorResult rv;
+  SetCh(aCh, rv);
+  return rv.ErrorCode();
+}
+
+NS_IMETHODIMP
+HTMLTableColElement::GetCh(nsAString& aCh)
+{
+  nsString ch;
+  GetCh(ch);
+  aCh = ch;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+HTMLTableColElement::SetChOff(const nsAString& aChOff)
+{
+  ErrorResult rv;
+  SetChOff(aChOff, rv);
+  return rv.ErrorCode();
+}
+
+NS_IMETHODIMP
+HTMLTableColElement::GetChOff(nsAString& aChOff)
+{
+  nsString chOff;
+  GetChOff(chOff);
+  aChOff = chOff;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+HTMLTableColElement::SetWidth(const nsAString& aWidth)
+{
+  ErrorResult rv;
+  SetWidth(aWidth, rv);
+  return rv.ErrorCode();
+}
+
+NS_IMETHODIMP
+HTMLTableColElement::GetWidth(nsAString& aWidth)
+{
+  nsString width;
+  GetWidth(width);
+  aWidth = width;
+  return NS_OK;
+}
 
 bool
 HTMLTableColElement::ParseAttribute(int32_t aNamespaceID,
                                     nsIAtom* aAttribute,
                                     const nsAString& aValue,
                                     nsAttrValue& aResult)
 {
   if (aNamespaceID == kNameSpaceID_None) {
--- a/content/html/content/src/HTMLTableColElement.h
+++ b/content/html/content/src/HTMLTableColElement.h
@@ -13,16 +13,17 @@ namespace dom {
 
 class HTMLTableColElement : public nsGenericHTMLElement,
                             public nsIDOMHTMLTableColElement
 {
 public:
   HTMLTableColElement(already_AddRefed<nsINodeInfo> aNodeInfo)
     : nsGenericHTMLElement(aNodeInfo)
   {
+    SetIsDOMBinding();
   }
   virtual ~HTMLTableColElement();
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMNode
   NS_FORWARD_NSIDOMNODE_TO_NSINODE
@@ -31,26 +32,80 @@ public:
   NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
 
   // nsIDOMHTMLElement
   NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
 
   // nsIDOMHTMLTableColElement
   NS_DECL_NSIDOMHTMLTABLECOLELEMENT
 
+  uint32_t Span() const
+  {
+    return GetIntAttr(nsGkAtoms::span, 1);
+  }
+  void SetSpan(uint32_t aSpan, ErrorResult& aError)
+  {
+    SetHTMLIntAttr(nsGkAtoms::span, aSpan, aError);
+  }
+
+  void GetAlign(nsString& aAlign)
+  {
+    GetHTMLAttr(nsGkAtoms::align, aAlign);
+  }
+  void SetAlign(const nsAString& aAlign, ErrorResult& aError)
+  {
+    SetHTMLAttr(nsGkAtoms::align, aAlign, aError);
+  }
+  void GetCh(nsString& aCh)
+  {
+    GetHTMLAttr(nsGkAtoms::_char, aCh);
+  }
+  void SetCh(const nsAString& aCh, ErrorResult& aError)
+  {
+    SetHTMLAttr(nsGkAtoms::_char, aCh, aError);
+  }
+  void GetChOff(nsString& aChOff)
+  {
+    GetHTMLAttr(nsGkAtoms::charoff, aChOff);
+  }
+  void SetChOff(const nsAString& aChOff, ErrorResult& aError)
+  {
+    SetHTMLAttr(nsGkAtoms::charoff, aChOff, aError);
+  }
+  void GetVAlign(nsString& aVAlign)
+  {
+    GetHTMLAttr(nsGkAtoms::valign, aVAlign);
+  }
+  void SetVAlign(const nsAString& aVAlign, ErrorResult& aError)
+  {
+    SetHTMLAttr(nsGkAtoms::valign, aVAlign, aError);
+  }
+  void GetWidth(nsString& aWidth)
+  {
+    GetHTMLAttr(nsGkAtoms::width, aWidth);
+  }
+  void SetWidth(const nsAString& aWidth, ErrorResult& aError)
+  {
+    SetHTMLAttr(nsGkAtoms::width, aWidth, aError);
+  }
+
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsIAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsAttrValue& aResult);
   nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual nsXPCClassInfo* GetClassInfo();
 
   virtual nsIDOMNode* AsDOMNode() { return this; }
+
+protected:
+  virtual JSObject* WrapNode(JSContext *aCx, JSObject *aScope,
+                             bool *aTriedToWrap) MOZ_OVERRIDE;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif /* mozilla_dom_HTMLTableColElement_h */
--- a/content/html/content/test/reflect.js
+++ b/content/html/content/test/reflect.js
@@ -52,18 +52,16 @@ function reflectString(aParameters)
      "null should have been stringified to 'null'");
   is(element[idlAttr], "null",
      "null should have been stringified to 'null'");
   element.removeAttribute(contentAttr);
 
   element[idlAttr] = null;
   // TODO: remove this ugly hack when null stringification will work as expected.
   var todoAttrs = {
-    col: [ "align", "vAlign", "ch" ],
-    colgroup: [ "align", "vAlign", "ch" ],
     form: [ "acceptCharset", "name", "target" ],
     img: [ "align" ],
     input: [ "accept", "alt", "formTarget", "max", "min", "name", "pattern", "placeholder", "step", "defaultValue" ],
     link: [ "crossOrigin" ],
     source: [ "media" ],
     textarea: [ "name", "placeholder" ],
   };
   if (!(element.localName in todoAttrs) || todoAttrs[element.localName].indexOf(idlAttr) == -1) {
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -421,16 +421,20 @@ DOMInterfaces = {
 'HTMLScriptElement': {
   'hasInstanceInterface': 'nsIDOMHTMLScriptElement',
 },
 
 'HTMLTableCellElement': {
     'hasInstanceInterface': 'nsIDOMHTMLTableCellElement'
 },
 
+'HTMLTableColElement': {
+    'hasInstanceInterface': 'nsIDOMHTMLTableColElement'
+},
+
 'HTMLTableElement': {
     'hasInstanceInterface': 'nsIDOMHTMLTableElement',
     'resultNotAddRefed': [
         'caption', 'tHead', 'tFoot', 'tBodies', 'rows'
     ]
 },
 
 'HTMLTableRowElement': {
new file mode 100644
--- /dev/null
+++ b/dom/webidl/HTMLTableColElement.webidl
@@ -0,0 +1,26 @@
+/* -*- 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/
+ *
+ * © 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.
+ */
+
+interface HTMLTableColElement : HTMLElement {
+           attribute unsigned long span;
+/*
+};
+
+partial interface HTMLTableColElement {
+*/
+           attribute DOMString align;
+           attribute DOMString ch;
+           attribute DOMString chOff;
+           attribute DOMString vAlign;
+           attribute DOMString width;
+};
--- a/dom/webidl/WebIDL.mk
+++ b/dom/webidl/WebIDL.mk
@@ -70,16 +70,17 @@ webidl_files = \
   HTMLOptionsCollection.webidl \
   HTMLParagraphElement.webidl \
   HTMLPreElement.webidl \
   HTMLPropertiesCollection.webidl \
   HTMLScriptElement.webidl \
   HTMLSpanElement.webidl \
   HTMLTableCaptionElement.webidl \
   HTMLTableCellElement.webidl \
+  HTMLTableColElement.webidl \
   HTMLTableElement.webidl \
   HTMLTableRowElement.webidl \
   HTMLTableSectionElement.webidl \
   HTMLTitleElement.webidl \
   HTMLUListElement.webidl \
   ImageData.webidl \
   Location.webidl \
   MutationObserver.webidl \
--- a/js/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/xpconnect/src/dom_quickstubs.qsconf
@@ -175,18 +175,16 @@ members = [
     'nsIDOMHTMLSelectElement.length',
     'nsIDOMHTMLSelectElement.remove',
     'nsIDOMHTMLSelectElement.selectedIndex',
     'nsIDOMHTMLSelectElement.item',
     'nsIDOMHTMLSelectElement.type',
     'nsIDOMHTMLSelectElement.options',
     'nsIDOMHTMLSelectElement.size',
     'nsIDOMHTMLStyleElement.disabled',
-    'nsIDOMHTMLTableColElement.span',
-    'nsIDOMHTMLTableColElement.width',
     'nsIDOMHTMLTextAreaElement.rows',
     'nsIDOMHTMLTextAreaElement.name',
     'nsIDOMHTMLTextAreaElement.form',
     'nsIDOMHTMLTextAreaElement.defaultValue',
     'nsIDOMHTMLTextAreaElement.cols',
     'nsIDOMHTMLTextAreaElement.value',
     'nsIDOMHTMLTextAreaElement.type',
     'nsIDOMHTMLTextAreaElement.select',