Fix for bug 457897 (Remove QI on 'this' object when calling from JS to C++). Patch by jorendorff and me, r/sr=jst.
authorPeter Van der Beken <peterv@propagandism.org>
Mon, 03 Nov 2008 11:31:47 +0100
changeset 21218 66aa5b4d2b31ca3214e37c940af4a24c42498465
parent 21217 132c340c09fff7730ea7b3871c8c29d8a39894db
child 21219 e1c09ee9eb9f084a9e72f9859f632ca41b9aa524
push id3416
push userpvanderbeken@mozilla.com
push dateMon, 03 Nov 2008 10:32:05 +0000
treeherdermozilla-central@66aa5b4d2b31 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs457897
milestone1.9.1b2pre
Fix for bug 457897 (Remove QI on 'this' object when calling from JS to C++). Patch by jorendorff and me, r/sr=jst.
content/base/public/nsINode.h
content/base/public/nsINodeList.h
content/base/src/nsCommentNode.cpp
content/base/src/nsContentList.cpp
content/base/src/nsDOMAttribute.cpp
content/base/src/nsDOMAttributeMap.cpp
content/base/src/nsDOMDocumentType.cpp
content/base/src/nsDOMLists.cpp
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
content/base/src/nsDocumentFragment.cpp
content/base/src/nsGenericElement.cpp
content/base/src/nsGenericElement.h
content/base/src/nsTextNode.cpp
content/html/content/src/nsGenericHTMLElement.h
content/html/content/src/nsHTMLAnchorElement.cpp
content/html/content/src/nsHTMLAreaElement.cpp
content/html/content/src/nsHTMLAudioElement.cpp
content/html/content/src/nsHTMLBRElement.cpp
content/html/content/src/nsHTMLBodyElement.cpp
content/html/content/src/nsHTMLButtonElement.cpp
content/html/content/src/nsHTMLCanvasElement.cpp
content/html/content/src/nsHTMLDelElement.cpp
content/html/content/src/nsHTMLDivElement.cpp
content/html/content/src/nsHTMLFieldSetElement.cpp
content/html/content/src/nsHTMLFontElement.cpp
content/html/content/src/nsHTMLFormElement.cpp
content/html/content/src/nsHTMLFrameElement.cpp
content/html/content/src/nsHTMLFrameSetElement.cpp
content/html/content/src/nsHTMLHRElement.cpp
content/html/content/src/nsHTMLHeadElement.cpp
content/html/content/src/nsHTMLHeadingElement.cpp
content/html/content/src/nsHTMLHtmlElement.cpp
content/html/content/src/nsHTMLIFrameElement.cpp
content/html/content/src/nsHTMLImageElement.cpp
content/html/content/src/nsHTMLInputElement.cpp
content/html/content/src/nsHTMLLIElement.cpp
content/html/content/src/nsHTMLLabelElement.cpp
content/html/content/src/nsHTMLLegendElement.cpp
content/html/content/src/nsHTMLLinkElement.cpp
content/html/content/src/nsHTMLMapElement.cpp
content/html/content/src/nsHTMLMetaElement.cpp
content/html/content/src/nsHTMLOListElement.cpp
content/html/content/src/nsHTMLObjectElement.cpp
content/html/content/src/nsHTMLOptGroupElement.cpp
content/html/content/src/nsHTMLOptionElement.cpp
content/html/content/src/nsHTMLParagraphElement.cpp
content/html/content/src/nsHTMLPreElement.cpp
content/html/content/src/nsHTMLScriptElement.cpp
content/html/content/src/nsHTMLSelectElement.cpp
content/html/content/src/nsHTMLSharedElement.cpp
content/html/content/src/nsHTMLSharedObjectElement.cpp
content/html/content/src/nsHTMLSourceElement.cpp
content/html/content/src/nsHTMLSpanElement.cpp
content/html/content/src/nsHTMLStyleElement.cpp
content/html/content/src/nsHTMLTableCaptionElement.cpp
content/html/content/src/nsHTMLTableCellElement.cpp
content/html/content/src/nsHTMLTableColElement.cpp
content/html/content/src/nsHTMLTableElement.cpp
content/html/content/src/nsHTMLTableRowElement.cpp
content/html/content/src/nsHTMLTableSectionElement.cpp
content/html/content/src/nsHTMLTextAreaElement.cpp
content/html/content/src/nsHTMLTitleElement.cpp
content/html/content/src/nsHTMLVideoElement.cpp
content/html/document/src/nsHTMLDocument.cpp
content/html/document/src/nsHTMLDocument.h
content/html/document/src/nsImageDocument.cpp
content/svg/content/src/nsSVGAElement.cpp
content/svg/content/src/nsSVGCircleElement.cpp
content/svg/content/src/nsSVGClipPathElement.cpp
content/svg/content/src/nsSVGDefsElement.cpp
content/svg/content/src/nsSVGDescElement.cpp
content/svg/content/src/nsSVGEllipseElement.cpp
content/svg/content/src/nsSVGFilterElement.cpp
content/svg/content/src/nsSVGFilters.cpp
content/svg/content/src/nsSVGForeignObjectElement.cpp
content/svg/content/src/nsSVGGElement.cpp
content/svg/content/src/nsSVGGradientElement.cpp
content/svg/content/src/nsSVGImageElement.cpp
content/svg/content/src/nsSVGLineElement.cpp
content/svg/content/src/nsSVGMarkerElement.cpp
content/svg/content/src/nsSVGMaskElement.cpp
content/svg/content/src/nsSVGMetadataElement.cpp
content/svg/content/src/nsSVGPathElement.cpp
content/svg/content/src/nsSVGPatternElement.cpp
content/svg/content/src/nsSVGPolygonElement.cpp
content/svg/content/src/nsSVGPolylineElement.cpp
content/svg/content/src/nsSVGRectElement.cpp
content/svg/content/src/nsSVGSVGElement.cpp
content/svg/content/src/nsSVGScriptElement.cpp
content/svg/content/src/nsSVGStopElement.cpp
content/svg/content/src/nsSVGStyleElement.cpp
content/svg/content/src/nsSVGSwitchElement.cpp
content/svg/content/src/nsSVGSymbolElement.cpp
content/svg/content/src/nsSVGTSpanElement.cpp
content/svg/content/src/nsSVGTextElement.cpp
content/svg/content/src/nsSVGTextPathElement.cpp
content/svg/content/src/nsSVGTitleElement.cpp
content/svg/content/src/nsSVGUseElement.cpp
content/xbl/src/nsBindingManager.cpp
content/xml/content/src/nsXMLCDATASection.cpp
content/xml/content/src/nsXMLElement.cpp
content/xml/content/src/nsXMLProcessingInstruction.cpp
content/xml/content/src/nsXMLStylesheetPI.cpp
content/xml/document/src/nsXMLDocument.cpp
content/xul/content/src/nsXULElement.cpp
content/xul/document/src/nsXULDocument.cpp
js/src/xpconnect/src/qsgen.py
js/src/xpconnect/src/xpcprivate.h
js/src/xpconnect/src/xpcquickstubs.cpp
js/src/xpconnect/src/xpcquickstubs.h
js/src/xpconnect/src/xpcwrappednative.cpp
js/src/xpconnect/src/xpcwrappednativeproto.cpp
xpcom/components/nsIClassInfo.idl
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -742,11 +742,112 @@ protected:
    * Used for either storing flags for this node or a pointer to
    * this contents nsContentSlots. See the definition of the
    * NODE_* macros for the layout of the bits in this
    * member.
    */
   PtrBits mFlagsOrSlots;
 };
 
+
+extern const nsIID kThisPtrOffsetsSID;
+
+// _implClass is the class to use to cast to nsISupports
+#define NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, _implClass)     \
+  static const QITableEntry offsetAndQITable[] = {                            \
+    NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsISupports, _implClass)
+
+#define NS_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                           \
+  NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, _class)
+
+#define NS_OFFSET_AND_INTERFACE_TABLE_END                                     \
+  { nsnull, 0 } };                                                            \
+  if (aIID.Equals(kThisPtrOffsetsSID)) {                                      \
+    *aInstancePtr =                                                           \
+      const_cast<void*>(static_cast<const void*>(&offsetAndQITable));         \
+    return NS_OK;                                                             \
+  }
+
+#define NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE                            \
+  rv = NS_TableDrivenQI(this, offsetAndQITable, aIID, aInstancePtr);          \
+  NS_INTERFACE_TABLE_TO_MAP_SEGUE
+
+// nsNodeSH::PreCreate() depends on the identity pointer being the same as
+// nsINode, so if you change the nsISupports line  below, make sure
+// nsNodeSH::PreCreate() still does the right thing!
+#define NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                      \
+  NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, nsINode)
+
+#define NS_NODE_INTERFACE_TABLE2(_class, _i1, _i2)                            \
+  NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                            \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
+  NS_OFFSET_AND_INTERFACE_TABLE_END                                           \
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
+
+#define NS_NODE_INTERFACE_TABLE3(_class, _i1, _i2, _i3)                       \
+  NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                            \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
+  NS_OFFSET_AND_INTERFACE_TABLE_END                                           \
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
+
+#define NS_NODE_INTERFACE_TABLE4(_class, _i1, _i2, _i3, _i4)                  \
+  NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                            \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
+  NS_OFFSET_AND_INTERFACE_TABLE_END                                           \
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
+
+#define NS_NODE_INTERFACE_TABLE5(_class, _i1, _i2, _i3, _i4, _i5)             \
+  NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                            \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
+  NS_OFFSET_AND_INTERFACE_TABLE_END                                           \
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
+
+#define NS_NODE_INTERFACE_TABLE6(_class, _i1, _i2, _i3, _i4, _i5, _i6)        \
+  NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                            \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
+  NS_OFFSET_AND_INTERFACE_TABLE_END                                           \
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
+
+#define NS_NODE_INTERFACE_TABLE7(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7)   \
+  NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                            \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i7)                                     \
+  NS_OFFSET_AND_INTERFACE_TABLE_END                                           \
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
+
+#define NS_NODE_INTERFACE_TABLE8(_class, _i1, _i2, _i3, _i4, _i5, _i6, _i7,   \
+                                 _i8)                                         \
+  NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                            \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i7)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i8)                                     \
+  NS_OFFSET_AND_INTERFACE_TABLE_END                                           \
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
+
+
 NS_DEFINE_STATIC_IID_ACCESSOR(nsINode, NS_INODE_IID)
 
 #endif /* nsINode_h___ */
--- a/content/base/public/nsINodeList.h
+++ b/content/base/public/nsINodeList.h
@@ -55,11 +55,14 @@ public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODELIST_IID)
 
   /**
    * Get the node at the index.  Returns null if the index is out of bounds
    */
   virtual nsINode* GetNodeAt(PRUint32 aIndex) = 0;
 };
 
+#define NS_NODELIST_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                  \
+  NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, nsINodeList)
+
 NS_DEFINE_STATIC_IID_ACCESSOR(nsINodeList, NS_INODELIST_IID)
 
 #endif /* nsINodeList_h___ */
--- a/content/base/src/nsCommentNode.cpp
+++ b/content/base/src/nsCommentNode.cpp
@@ -104,20 +104,19 @@ nsCommentNode::nsCommentNode(nsINodeInfo
 }
 
 nsCommentNode::~nsCommentNode()
 {
 }
 
 
 // QueryInterface implementation for nsCommentNode
-NS_INTERFACE_MAP_BEGIN(nsCommentNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCharacterData)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMComment)
+NS_INTERFACE_TABLE_HEAD(nsCommentNode)
+  NS_NODE_INTERFACE_TABLE3(nsCommentNode, nsIDOMNode, nsIDOMCharacterData,
+                           nsIDOMComment)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(Comment)
 NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode)
 
 
 NS_IMPL_ADDREF_INHERITED(nsCommentNode, nsGenericDOMDataNode)
 NS_IMPL_RELEASE_INHERITED(nsCommentNode, nsGenericDOMDataNode)
 
 
--- a/content/base/src/nsContentList.cpp
+++ b/content/base/src/nsContentList.cpp
@@ -77,21 +77,28 @@ nsBaseContentList::~nsBaseContentList()
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsBaseContentList)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsBaseContentList)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mElements)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsBaseContentList)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mElements)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
+#define NS_CONTENT_LIST_INTERFACES(_class)                                    \
+    NS_INTERFACE_TABLE_ENTRY(_class, nsINodeList)                             \
+    NS_INTERFACE_TABLE_ENTRY(_class, nsIDOMNodeList)
+
+
 // QueryInterface implementation for nsBaseContentList
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsBaseContentList)
-  NS_INTERFACE_MAP_ENTRY(nsINodeList)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNodeList)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsINodeList)
+NS_INTERFACE_TABLE_HEAD(nsBaseContentList)
+  NS_NODELIST_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsBaseContentList)
+    NS_CONTENT_LIST_INTERFACES(nsBaseContentList)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
+  NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsBaseContentList)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(NodeList)
 NS_INTERFACE_MAP_END
 
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsBaseContentList)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsBaseContentList)
 
 
@@ -345,20 +352,24 @@ nsContentList::~nsContentList()
   if (mDestroyFunc) {
     // Clean up mData
     (*mDestroyFunc)(mData);
   }
 }
 
 
 // QueryInterface implementation for nsContentList
-NS_INTERFACE_MAP_BEGIN(nsContentList)
-  NS_INTERFACE_MAP_ENTRY(nsIHTMLCollection)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLCollection)
-  NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
+NS_INTERFACE_TABLE_HEAD(nsContentList)
+  NS_NODELIST_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsContentList)
+    NS_CONTENT_LIST_INTERFACES(nsContentList)
+    NS_INTERFACE_TABLE_ENTRY(nsContentList, nsIHTMLCollection)
+    NS_INTERFACE_TABLE_ENTRY(nsContentList, nsIDOMHTMLCollection)
+    NS_INTERFACE_TABLE_ENTRY(nsContentList, nsIMutationObserver)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(ContentList)
 NS_INTERFACE_MAP_END_INHERITING(nsBaseContentList)
 
 
 NS_IMPL_ADDREF_INHERITED(nsContentList, nsBaseContentList)
 NS_IMPL_RELEASE_INHERITED(nsContentList, nsBaseContentList)
 
 
--- a/content/base/src/nsDOMAttribute.cpp
+++ b/content/base/src/nsDOMAttribute.cpp
@@ -95,31 +95,23 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
     static_cast<nsTextNode*>(tmp->mChild)->UnbindFromAttribute();
     NS_RELEASE(tmp->mChild);
   }
   NS_IMPL_CYCLE_COLLECTION_UNLINK_LISTENERMANAGER
   NS_IMPL_CYCLE_COLLECTION_UNLINK_USERDATA
   NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 // QueryInterface implementation for nsDOMAttribute
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMAttribute)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMAttr)
-  NS_INTERFACE_MAP_ENTRY(nsIAttribute)
-  NS_INTERFACE_MAP_ENTRY(nsINode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOM3Node)
-  NS_INTERFACE_MAP_ENTRY(nsIDOM3Attr)
-  NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
+NS_INTERFACE_TABLE_HEAD(nsDOMAttribute)
+  NS_NODE_INTERFACE_TABLE7(nsDOMAttribute, nsIDOMAttr, nsIAttribute, nsINode,
+                           nsIDOMNode, nsIDOM3Node, nsIDOM3Attr,
+                           nsPIDOMEventTarget)
+  NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsDOMAttribute)
   NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
                                  new nsNodeSupportsWeakRefTearoff(this))
-  // nsNodeSH::PreCreate() depends on the identity pointer being the
-  // same as nsINode (which nsIAttribute inherits), so if you change
-  // the below line, make sure nsNodeSH::PreCreate() still does the
-  // right thing!
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAttribute)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(Attr)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(nsDOMAttribute, nsIDOMAttr)
 NS_IMPL_CYCLE_COLLECTING_RELEASE_FULL(nsDOMAttribute, nsIDOMAttr,
                                       nsNodeUtils::LastRelease(this))
 
 void
--- a/content/base/src/nsDOMAttributeMap.cpp
+++ b/content/base/src/nsDOMAttributeMap.cpp
@@ -111,19 +111,22 @@ TraverseMapEntry(nsAttrHashKey::KeyType 
 }
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMAttributeMap)
   tmp->mAttributeCache.Enumerate(TraverseMapEntry, &cb);
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 
 // QueryInterface implementation for nsDOMAttributeMap
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMAttributeMap)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNamedNodeMap)
+NS_INTERFACE_TABLE_HEAD(nsDOMAttributeMap)
+  NS_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsDOMAttributeMap)
+    NS_INTERFACE_TABLE_ENTRY(nsDOMAttributeMap, nsIDOMNamedNodeMap)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
+  NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsDOMAttributeMap)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(NamedNodeMap)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMAttributeMap)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMAttributeMap)
 
 PLDHashOperator
 SetOwnerDocumentFunc(nsAttrHashKey::KeyType aKey, nsCOMPtr<nsIDOMNode>& aData,
--- a/content/base/src/nsDOMDocumentType.cpp
+++ b/content/base/src/nsDOMDocumentType.cpp
@@ -118,19 +118,19 @@ nsDOMDocumentType::nsDOMDocumentType(nsI
 }
 
 nsDOMDocumentType::~nsDOMDocumentType()
 {
 }
 
 
 // QueryInterface implementation for nsDOMDocumentType
-NS_INTERFACE_MAP_BEGIN(nsDOMDocumentType)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentType)
+NS_INTERFACE_TABLE_HEAD(nsDOMDocumentType)
+  NS_NODE_INTERFACE_TABLE2(nsDOMDocumentType, nsIDOMNode, nsIDOMDocumentType)
+  NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsDOMDocumentType)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(DocumentType)
 NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode)
 
 
 NS_IMPL_ADDREF_INHERITED(nsDOMDocumentType, nsGenericDOMDataNode)
 NS_IMPL_RELEASE_INHERITED(nsDOMDocumentType, nsGenericDOMDataNode)
 
 PRBool
--- a/content/base/src/nsDOMLists.cpp
+++ b/content/base/src/nsDOMLists.cpp
@@ -41,30 +41,33 @@
  * Implementations of nsIDOMDOMStringList and nsIDOMNameList, used by various
  * DOM3 stuff and some interfaces specified by WHATWG.
  */
 
 #include "nsDOMLists.h"
 #include "nsDOMError.h"
 #include "nsIDOMClassInfo.h"
 #include "nsContentUtils.h"
+#include "nsINode.h"
 
 nsDOMStringList::nsDOMStringList()
 {
 }
 
 nsDOMStringList::~nsDOMStringList()
 {
 }
 
 NS_IMPL_ADDREF(nsDOMStringList)
 NS_IMPL_RELEASE(nsDOMStringList)
-NS_INTERFACE_MAP_BEGIN(nsDOMStringList)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDOMStringList)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_TABLE_HEAD(nsDOMStringList)
+  NS_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsDOMStringList)
+    NS_INTERFACE_TABLE_ENTRY(nsDOMStringList, nsIDOMDOMStringList)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(DOMStringList)
 NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP
 nsDOMStringList::Item(PRUint32 aIndex, nsAString& aResult)
 {
   if (aIndex >= (PRUint32)mNames.Count()) {
     SetDOMStringToNull(aResult);
@@ -96,20 +99,22 @@ nsNameList::nsNameList()
 {
 }
 
 nsNameList::~nsNameList()
 {
 }
 
 NS_IMPL_ADDREF(nsNameList)
-  NS_IMPL_RELEASE(nsNameList)
-  NS_INTERFACE_MAP_BEGIN(nsNameList)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNameList)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_IMPL_RELEASE(nsNameList)
+NS_INTERFACE_TABLE_HEAD(nsNameList)
+  NS_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsNameList)
+    NS_INTERFACE_TABLE_ENTRY(nsNameList, nsIDOMNameList)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(NameList)
   NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP
 nsNameList::GetName(PRUint32 aIndex, nsAString& aResult)
 {
   if (aIndex >= (PRUint32)mNames.Count()) {
     SetDOMStringToNull(aResult);
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -1195,19 +1195,21 @@ protected:
   nsresult GetSets(nsStringArray& aStyleSets);
   
   nsIDocument* mDocument;  // Our document; weak ref.  It'll let us know if it
                            // dies.
 };
 
 NS_IMPL_ADDREF(nsDOMStyleSheetSetList)
 NS_IMPL_RELEASE(nsDOMStyleSheetSetList)
-NS_INTERFACE_MAP_BEGIN(nsDOMStyleSheetSetList)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDOMStringList)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_TABLE_HEAD(nsDOMStyleSheetSetList)
+  NS_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsDOMStyleSheetSetList)
+    NS_INTERFACE_TABLE_ENTRY(nsDOMStyleSheetSetList, nsIDOMDOMStringList)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(DOMStringList)
 NS_INTERFACE_MAP_END
 
 nsDOMStyleSheetSetList::nsDOMStyleSheetSetList(nsIDocument* aDocument)
   : mDocument(aDocument)
 {
   NS_ASSERTION(mDocument, "Must have document!");
 }
@@ -1567,49 +1569,36 @@ nsDocument::~nsDocument()
   }
 
   delete mContentWrapperHash;
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsDocument)
 
 NS_INTERFACE_TABLE_HEAD(nsDocument)
-  NS_INTERFACE_TABLE_BEGIN
+  NS_DOCUMENT_INTERFACE_TABLE_BEGIN(nsDocument)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsINode)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDocument)
-    NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocument)
-    NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNSDocument)
-    NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentEvent)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOM3DocumentEvent)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentStyle)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNSDocumentStyle)
-    NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentView)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentRange)
-    NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentTraversal)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentXBL)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIScriptObjectPrincipal)
-    NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMEventTarget)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOM3EventTarget)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNSEventTarget)
-    NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNode)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsPIDOMEventTarget)
-    NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOM3Node)
-    NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOM3Document)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsISupportsWeakReference)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIRadioGroupContainer)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIMutationObserver)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNodeSelector)
     NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIApplicationCacheContainer)
-    // nsNodeSH::PreCreate() depends on the identity pointer being the
-    // same as nsINode (which nsIDocument inherits), so if you change
-    // the below line, make sure nsNodeSH::PreCreate() still does the
-    // right thing!
-    NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(nsDocument, nsISupports, nsIDocument)
-  NS_INTERFACE_TABLE_END
-  NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsDocument)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
+  NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsDocument)
   if (aIID.Equals(NS_GET_IID(nsIDOMXPathEvaluator)) ||
       aIID.Equals(NS_GET_IID(nsIXPathEvaluatorInternal))) {
     if (!mXPathEvaluatorTearoff) {
       nsresult rv;
       mXPathEvaluatorTearoff =
         do_CreateInstance(NS_XPATH_EVALUATOR_CONTRACTID,
                           static_cast<nsIDocument *>(this), &rv);
       NS_ENSURE_SUCCESS(rv, rv);
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -1222,9 +1222,22 @@ private:
   nsTArray<nsRefPtr<nsFrameLoader> > mInitializableFrameLoaders;
   nsTArray<nsRefPtr<nsFrameLoader> > mFinalizableFrameLoaders;
 
   nsRevocableEventPtr<nsRunnableMethod<nsDocument> > mPendingTitleChangeEvent;
 
   nsExternalResourceMap mExternalResourceMap;
 };
 
+#define NS_DOCUMENT_INTERFACE_TABLE_BEGIN(_class)                             \
+  NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                            \
+  NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocument, nsDocument)      \
+  NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNSDocument, nsDocument)    \
+  NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocumentEvent, nsDocument) \
+  NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocumentView, nsDocument)  \
+  NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocumentTraversal,         \
+                                     nsDocument)                              \
+  NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMEventTarget, nsDocument)   \
+  NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNode, nsDocument)          \
+  NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOM3Node, nsDocument)         \
+  NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOM3Document, nsDocument)
+
 #endif /* nsDocument_h___ */
--- a/content/base/src/nsDocumentFragment.cpp
+++ b/content/base/src/nsDocumentFragment.cpp
@@ -190,20 +190,19 @@ nsDocumentFragment::~nsDocumentFragment(
 
 PRBool
 nsDocumentFragment::IsNodeOfType(PRUint32 aFlags) const
 {
   return !(aFlags & ~(eCONTENT | eDOCUMENT_FRAGMENT));
 }
 
 // QueryInterface implementation for nsDocumentFragment
-NS_INTERFACE_MAP_BEGIN(nsDocumentFragment)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentFragment)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, new nsNode3Tearoff(this))
+NS_INTERFACE_TABLE_HEAD(nsDocumentFragment)
+  NS_NODE_INTERFACE_TABLE2(nsDocumentFragment, nsIDOMNode,
+                           nsIDOMDocumentFragment)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(DocumentFragment)
 NS_INTERFACE_MAP_END_INHERITING(nsGenericElement)
 
 
 NS_IMPL_ADDREF_INHERITED(nsDocumentFragment, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsDocumentFragment, nsGenericElement)
 
 NS_IMETHODIMP    
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -164,16 +164,18 @@ void
 DebugListContentTree(nsIContent* aElement)
 {
   aElement->List(stdout, 0);
   printf("\n");
 }
 
 #endif
 
+NS_DEFINE_IID(kThisPtrOffsetsSID, NS_THISPTROFFSETS_SID);
+
 PRInt32 nsIContent::sTabFocusModel = eTabFocus_any;
 PRBool nsIContent::sTabFocusModelAppliesToXUL = PR_FALSE;
 nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult);
 
 //----------------------------------------------------------------------
 
 nsINode::nsSlots::~nsSlots()
 {
@@ -454,20 +456,22 @@ nsIContent::FindFirstNonNativeAnonymous(
   return nsnull;
 }
 
 //----------------------------------------------------------------------
 
 NS_IMPL_ADDREF(nsChildContentList)
 NS_IMPL_RELEASE(nsChildContentList)
 
-NS_INTERFACE_MAP_BEGIN(nsChildContentList)
-  NS_INTERFACE_MAP_ENTRY(nsINodeList)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNodeList)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsINodeList)
+NS_INTERFACE_TABLE_HEAD(nsChildContentList)
+  NS_NODELIST_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsChildContentList)
+    NS_INTERFACE_TABLE_ENTRY(nsChildContentList, nsINodeList)
+    NS_INTERFACE_TABLE_ENTRY(nsChildContentList, nsIDOMNodeList)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(NodeList)
 NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP
 nsChildContentList::GetLength(PRUint32* aLength)
 {
   *aLength = mNode ? mNode->GetChildCount() : 0;
 
--- a/content/base/src/nsGenericElement.h
+++ b/content/base/src/nsGenericElement.h
@@ -1076,9 +1076,28 @@ private:
    * @note This method flushes pending notifications (Flush_Layout).
    * @param aScrollableView the scrollable view [OUT]
    * @param aFrame (optional) the frame [OUT]
    */
   void GetScrollInfo(nsIScrollableView **aScrollableView,
                      nsIFrame **aFrame = nsnull);
 };
 
+#define NS_ELEMENT_INTERFACE_TABLE_TO_MAP_SEGUE                               \
+    rv = nsGenericElement::QueryInterface(aIID, aInstancePtr);                \
+    if (NS_SUCCEEDED(rv))                                                     \
+      return rv;                                                              \
+                                                                              \
+    NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
+
+#define NS_ELEMENT_INTERFACE_MAP_END                                          \
+    {                                                                         \
+      return PostQueryInterface(aIID, aInstancePtr);                          \
+    }                                                                         \
+                                                                              \
+    NS_ADDREF(foundInterface);                                                \
+                                                                              \
+    *aInstancePtr = foundInterface;                                           \
+                                                                              \
+    return NS_OK;                                                             \
+  }
+
 #endif /* nsGenericElement_h___ */
--- a/content/base/src/nsTextNode.cpp
+++ b/content/base/src/nsTextNode.cpp
@@ -148,21 +148,21 @@ nsTextNode::~nsTextNode()
 {
 }
 
 NS_IMPL_ADDREF_INHERITED(nsTextNode, nsGenericDOMDataNode)
 NS_IMPL_RELEASE_INHERITED(nsTextNode, nsGenericDOMDataNode)
 
 
 // QueryInterface implementation for nsTextNode
-NS_INTERFACE_MAP_BEGIN(nsTextNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMText)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCharacterData)
+NS_INTERFACE_TABLE_HEAD(nsTextNode)
+  NS_NODE_INTERFACE_TABLE3(nsTextNode, nsIDOMNode, nsIDOMText,
+                           nsIDOMCharacterData)
   NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Text, new nsText3Tearoff(this))
+  NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsTextNode)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(Text)
 NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode)
 
 NS_IMETHODIMP
 nsTextNode::GetNodeName(nsAString& aNodeName)
 {
   aNodeName.AssignLiteral("#text");
   return NS_OK;
--- a/content/html/content/src/nsGenericHTMLElement.h
+++ b/content/html/content/src/nsGenericHTMLElement.h
@@ -1104,73 +1104,45 @@ NS_NewHTML##_elementName##Element(nsINod
   {                                                                          \
     return SetAttrHelper(nsGkAtoms::_atom, aValue);                        \
   }
 
 /**
  * QueryInterface() implementation helper macros
  */
 
-#define NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGOUS_HEAD(_class, _base,          \
-                                                      _base_if)               \
-  NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr)    \
-  {                                                                           \
-    NS_PRECONDITION(aInstancePtr, "null out param");                          \
-                                                                              \
-    nsresult rv;                                                              \
-                                                                              \
-    rv = _base::QueryInterface(aIID, aInstancePtr);                           \
-                                                                              \
-    if (NS_SUCCEEDED(rv))                                                     \
-      return rv;                                                              \
-                                                                              \
-    rv = DOMQueryInterface(static_cast<_base_if *>(this), aIID,               \
-                           aInstancePtr);                                     \
-                                                                              \
-    if (NS_SUCCEEDED(rv))                                                     \
-      return rv;
+#define NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGUOUS_BEGIN(_class, _base)        \
+  NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                            \
+    NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNode, _base)             \
+    NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMElement, _base)          \
+    NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMHTMLElement, _base)
 
+#define NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                         \
+  NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGUOUS_BEGIN(_class, nsIDOMHTMLElement)
 
-#define NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(_class, _base)                   \
-  NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGOUS_HEAD(_class, _base,                \
-                                                nsIDOMHTMLElement)
-
-#define NS_HTML_CONTENT_CC_INTERFACE_TABLE_AMBIGUOUS_HEAD(_class, _base,      \
-                                                          _base_if)           \
-  NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(_class)                  \
-                                                                              \
-    rv = _base::QueryInterface(aIID, aInstancePtr);                           \
+#define NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE_AMBIGUOUS(_class, _base, \
+                                                               _base_if)      \
+  rv = _base::QueryInterface(aIID, aInstancePtr);                             \
+  if (NS_SUCCEEDED(rv))                                                       \
+    return rv;                                                                \
                                                                               \
-    if (NS_SUCCEEDED(rv))                                                     \
-      return rv;                                                              \
-                                                                              \
-    rv = DOMQueryInterface(static_cast<_base_if *>(this), aIID,               \
-                           aInstancePtr);                                     \
+  rv = DOMQueryInterface(static_cast<_base_if *>(this), aIID, aInstancePtr);  \
+  if (NS_SUCCEEDED(rv))                                                       \
+    return rv;                                                                \
                                                                               \
-    if (NS_SUCCEEDED(rv))                                                     \
-      return rv;
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
 
-#define NS_HTML_CONTENT_CC_INTERFACE_TABLE_HEAD(_class, _base)                \
-  NS_HTML_CONTENT_CC_INTERFACE_TABLE_AMBIGUOUS_HEAD(_class, _base,            \
-                                                    nsIDOMHTMLElement)
+#define NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(_class, _base)           \
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE_AMBIGUOUS(_class, _base,       \
+                                                         nsIDOMHTMLElement)
 
 #define NS_HTML_CONTENT_INTERFACE_MAP_END                                     \
-    {                                                                         \
-      return PostQueryInterface(aIID, aInstancePtr);                          \
-    }                                                                         \
-                                                                              \
-    NS_ADDREF(foundInterface);                                                \
-                                                                              \
-    *aInstancePtr = foundInterface;                                           \
-                                                                              \
-    return NS_OK;                                                             \
-  }
+  NS_ELEMENT_INTERFACE_MAP_END
 
 #define NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(_class)                \
-    NS_INTERFACE_TABLE_TO_MAP_SEGUE                                           \
     NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(_class)                          \
   NS_HTML_CONTENT_INTERFACE_MAP_END
 
 #define NS_INTERFACE_MAP_ENTRY_IF_TAG(_interface, _tag)                       \
   NS_INTERFACE_MAP_ENTRY_CONDITIONAL(_interface,                              \
                                      mNodeInfo->Equals(nsGkAtoms::_tag))
 
 
@@ -1179,16 +1151,87 @@ NS_NewHTML##_elementName##Element(nsINod
       aIID.Equals(NS_GET_IID(nsIClassInfo))) {                                \
     foundInterface = NS_GetDOMClassInfoInstance(eDOMClassInfo_##_class##_id); \
     if (!foundInterface) {                                                    \
       *aInstancePtr = nsnull;                                                 \
       return NS_ERROR_OUT_OF_MEMORY;                                          \
     }                                                                         \
   } else
 
+#define NS_HTML_CONTENT_INTERFACE_TABLE0(_class)                              \
+  NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+
+#define NS_HTML_CONTENT_INTERFACE_TABLE1(_class, _i1)                         \
+  NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+
+#define NS_HTML_CONTENT_INTERFACE_TABLE2(_class, _i1, _i2)                    \
+  NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+
+#define NS_HTML_CONTENT_INTERFACE_TABLE4(_class, _i1, _i2, _i3, _i4)          \
+  NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+
+#define NS_HTML_CONTENT_INTERFACE_TABLE5(_class, _i1, _i2, _i3, _i4, _i5)     \
+  NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+
+#define NS_HTML_CONTENT_INTERFACE_TABLE6(_class, _i1, _i2, _i3, _i4, _i5,     \
+                                         _i6)                                 \
+  NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+
+#define NS_HTML_CONTENT_INTERFACE_TABLE9(_class, _i1, _i2, _i3, _i4, _i5,     \
+                                         _i6, _i7, _i8, _i9)                  \
+  NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i7)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i8)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i9)                                     \
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+
+#define NS_HTML_CONTENT_INTERFACE_TABLE10(_class, _i1, _i2, _i3, _i4, _i5,    \
+                                          _i6, _i7, _i8, _i9, _i10)           \
+  NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class)                               \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i1)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i2)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i3)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i4)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i5)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i6)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i7)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i8)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i9)                                     \
+    NS_INTERFACE_TABLE_ENTRY(_class, _i10)                                    \
+  NS_OFFSET_AND_INTERFACE_TABLE_END
 
 
 // Element class factory methods
 
 #define NS_DECLARE_NS_NEW_HTML_ELEMENT(_elementName)              \
 nsGenericHTMLElement*                                             \
 NS_NewHTML##_elementName##Element(nsINodeInfo *aNodeInfo,         \
                                   PRBool aFromParser = PR_FALSE);
--- a/content/html/content/src/nsHTMLAnchorElement.cpp
+++ b/content/html/content/src/nsHTMLAnchorElement.cpp
@@ -152,22 +152,24 @@ nsHTMLAnchorElement::~nsHTMLAnchorElemen
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLAnchorElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLAnchorElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLAnchorElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLAnchorElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED4(nsHTMLAnchorElement,
-                                nsIDOMHTMLAnchorElement,
-                                nsIDOMNSHTMLAnchorElement,
-                                nsIDOMNSHTMLAnchorElement2,
-                                nsILink)
+NS_INTERFACE_TABLE_HEAD(nsHTMLAnchorElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE4(nsHTMLAnchorElement,
+                                   nsIDOMHTMLAnchorElement,
+                                   nsIDOMNSHTMLAnchorElement,
+                                   nsIDOMNSHTMLAnchorElement2,
+                                   nsILink)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLAnchorElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLAnchorElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLAnchorElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Charset, charset)
 NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Coords, coords)
--- a/content/html/content/src/nsHTMLAreaElement.cpp
+++ b/content/html/content/src/nsHTMLAreaElement.cpp
@@ -131,22 +131,24 @@ nsHTMLAreaElement::~nsHTMLAreaElement()
 {
 }
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLAreaElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLAreaElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLAreaElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLAreaElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED4(nsHTMLAreaElement,
-                                nsIDOMHTMLAreaElement,
-                                nsIDOMNSHTMLAreaElement,
-                                nsIDOMNSHTMLAreaElement2,
-                                nsILink)
+NS_INTERFACE_TABLE_HEAD(nsHTMLAreaElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE4(nsHTMLAreaElement,
+                                   nsIDOMHTMLAreaElement,
+                                   nsIDOMNSHTMLAreaElement,
+                                   nsIDOMNSHTMLAreaElement2,
+                                   nsILink)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLAreaElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLAreaElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLAreaElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLAreaElement, AccessKey, accesskey)
 NS_IMPL_STRING_ATTR(nsHTMLAreaElement, Alt, alt)
--- a/content/html/content/src/nsHTMLAudioElement.cpp
+++ b/content/html/content/src/nsHTMLAudioElement.cpp
@@ -68,18 +68,20 @@
 #include "nsIDOMProgressEvent.h"
 #include "nsHTMLMediaError.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Audio)
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLAudioElement, nsHTMLMediaElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLAudioElement, nsHTMLMediaElement)
 
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLAudioElement, nsHTMLMediaElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLAudioElement, nsIDOMHTMLAudioElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLAudioElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLAudioElement, nsIDOMHTMLAudioElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLAudioElement,
+                                               nsHTMLMediaElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLAudioElement)
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLAudioElement)
 
 
 nsHTMLAudioElement::nsHTMLAudioElement(nsINodeInfo *aNodeInfo, PRBool aFromParser)
   : nsHTMLMediaElement(aNodeInfo, aFromParser)
 {
--- a/content/html/content/src/nsHTMLBRElement.cpp
+++ b/content/html/content/src/nsHTMLBRElement.cpp
@@ -87,18 +87,20 @@ nsHTMLBRElement::~nsHTMLBRElement()
 {
 }
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLBRElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLBRElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLBRElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLBRElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLBRElement, nsIDOMHTMLBRElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLBRElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLBRElement, nsIDOMHTMLBRElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLBRElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLBRElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLBRElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLBRElement, Clear, clear)
 
--- a/content/html/content/src/nsHTMLBodyElement.cpp
+++ b/content/html/content/src/nsHTMLBodyElement.cpp
@@ -294,21 +294,22 @@ nsHTMLBodyElement::~nsHTMLBodyElement()
   }
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLBodyElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLBodyElement, nsGenericElement) 
 
 // QueryInterface implementation for nsHTMLBodyElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLBodyElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLBodyElement, nsIDOMHTMLBodyElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLBodyElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLBodyElement, nsIDOMHTMLBodyElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLBodyElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLBodyElement)
 
-
 NS_IMPL_ELEMENT_CLONE(nsHTMLBodyElement)
 
 
 NS_IMPL_URI_ATTR(nsHTMLBodyElement, Background, background)
 
 static nscolor
 GetDefaultColor(nsPresContext* aContext, nsIAtom* aAtom)
 {
--- a/content/html/content/src/nsHTMLButtonElement.cpp
+++ b/content/html/content/src/nsHTMLButtonElement.cpp
@@ -156,21 +156,22 @@ nsHTMLButtonElement::~nsHTMLButtonElemen
 
 // nsISupports
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLButtonElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLButtonElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLButtonElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLButtonElement,
-                                     nsGenericHTMLFormElement)
-  NS_INTERFACE_TABLE_INHERITED2(nsHTMLButtonElement,
-                                nsIDOMHTMLButtonElement,
-                                nsIDOMNSHTMLButtonElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLButtonElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLButtonElement,
+                                   nsIDOMHTMLButtonElement,
+                                   nsIDOMNSHTMLButtonElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLButtonElement,
+                                               nsGenericHTMLFormElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLButtonElement)
 
 // nsIDOMHTMLButtonElement
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLButtonElement)
 
 
--- a/content/html/content/src/nsHTMLCanvasElement.cpp
+++ b/content/html/content/src/nsHTMLCanvasElement.cpp
@@ -154,20 +154,22 @@ nsHTMLCanvasElement::~nsHTMLCanvasElemen
     internalctx->SetCanvasElement(nsnull);
     mCurrentContext = nsnull;
   }
 }
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLCanvasElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLCanvasElement, nsGenericElement)
 
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLCanvasElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED2(nsHTMLCanvasElement,
-                                nsIDOMHTMLCanvasElement,
-                                nsICanvasElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLCanvasElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLCanvasElement,
+                                   nsIDOMHTMLCanvasElement,
+                                   nsICanvasElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLCanvasElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLCanvasElement)
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLCanvasElement)
 
 nsIntSize
 nsHTMLCanvasElement::GetWidthHeight()
 {
   nsIntSize size(0,0);
--- a/content/html/content/src/nsHTMLDelElement.cpp
+++ b/content/html/content/src/nsHTMLDelElement.cpp
@@ -80,19 +80,20 @@ nsHTMLModElement::~nsHTMLModElement()
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLModElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLModElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLModElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLModElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLModElement, nsIDOMHTMLModElement)
-  NS_INTERFACE_TABLE_TO_MAP_SEGUE
+NS_INTERFACE_TABLE_HEAD(nsHTMLModElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLModElement, nsIDOMHTMLModElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLModElement,
+                                               nsGenericHTMLElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO_IF_TAG(HTMLDelElement, del)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO_IF_TAG(HTMLInsElement, ins)
 NS_HTML_CONTENT_INTERFACE_MAP_END
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLModElement)
 
 
--- a/content/html/content/src/nsHTMLDivElement.cpp
+++ b/content/html/content/src/nsHTMLDivElement.cpp
@@ -88,18 +88,20 @@ nsHTMLDivElement::~nsHTMLDivElement()
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLDivElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLDivElement, nsGenericElement) 
 
 
 
 // QueryInterface implementation for nsHTMLDivElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLDivElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLDivElement, nsIDOMHTMLDivElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLDivElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLDivElement, nsIDOMHTMLDivElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLDivElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLDivElement)
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLDivElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLDivElement, Align, align)
 
 
--- a/content/html/content/src/nsHTMLFieldSetElement.cpp
+++ b/content/html/content/src/nsHTMLFieldSetElement.cpp
@@ -91,20 +91,21 @@ nsHTMLFieldSetElement::~nsHTMLFieldSetEl
 
 // nsISupports
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLFieldSetElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLFieldSetElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLFieldSetElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLFieldSetElement,
-                                     nsGenericHTMLFormElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLFieldSetElement,
-                                nsIDOMHTMLFieldSetElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLFieldSetElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLFieldSetElement,
+                                   nsIDOMHTMLFieldSetElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLFieldSetElement,
+                                               nsGenericHTMLFormElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLFieldSetElement)
 
 
 // nsIDOMHTMLFieldSetElement
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLFieldSetElement)
 
--- a/content/html/content/src/nsHTMLFontElement.cpp
+++ b/content/html/content/src/nsHTMLFontElement.cpp
@@ -91,18 +91,20 @@ nsHTMLFontElement::~nsHTMLFontElement()
 {
 }
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLFontElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLFontElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLFontElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLFontElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLFontElement, nsIDOMHTMLFontElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLFontElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLFontElement, nsIDOMHTMLFontElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLFontElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLFontElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLFontElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLFontElement, Color, color)
 NS_IMPL_STRING_ATTR(nsHTMLFontElement, Face, face)
--- a/content/html/content/src/nsHTMLFormElement.cpp
+++ b/content/html/content/src/nsHTMLFormElement.cpp
@@ -560,24 +560,25 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   tmp->mSelectedRadioButtons.EnumerateRead(ElementTraverser, &cb);
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLFormElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLFormElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLFormElement
-NS_HTML_CONTENT_CC_INTERFACE_TABLE_HEAD(nsHTMLFormElement,
-                                        nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED5(nsHTMLFormElement,
-                                nsIDOMHTMLFormElement,
-                                nsIDOMNSHTMLFormElement,
-                                nsIForm,
-                                nsIWebProgressListener,
-                                nsIRadioGroupContainer)
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLFormElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE5(nsHTMLFormElement,
+                                   nsIDOMHTMLFormElement,
+                                   nsIDOMNSHTMLFormElement,
+                                   nsIForm,
+                                   nsIWebProgressListener,
+                                   nsIRadioGroupContainer)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLFormElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLFormElement)
 
 
 // nsIDOMHTMLFormElement
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsHTMLFormElement)
 
 NS_IMETHODIMP
--- a/content/html/content/src/nsHTMLFrameElement.cpp
+++ b/content/html/content/src/nsHTMLFrameElement.cpp
@@ -89,19 +89,20 @@ nsHTMLFrameElement::~nsHTMLFrameElement(
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLFrameElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLFrameElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLFrameElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLFrameElement,
-                                     nsGenericHTMLFrameElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLFrameElement, nsIDOMHTMLFrameElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLFrameElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLFrameElement, nsIDOMHTMLFrameElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLFrameElement,
+                                               nsGenericHTMLFrameElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLFrameElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLFrameElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLFrameElement, FrameBorder, frameborder)
 NS_IMPL_URI_ATTR(nsHTMLFrameElement, LongDesc, longdesc)
--- a/content/html/content/src/nsHTMLFrameSetElement.cpp
+++ b/content/html/content/src/nsHTMLFrameSetElement.cpp
@@ -133,21 +133,22 @@ nsHTMLFrameSetElement::~nsHTMLFrameSetEl
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLFrameSetElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLFrameSetElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLFrameSetElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLFrameSetElement,
-                                      nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED2(nsHTMLFrameSetElement,
-                                nsIDOMHTMLFrameSetElement,
-                                nsIFrameSetElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLFrameSetElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLFrameSetElement,
+                                   nsIDOMHTMLFrameSetElement,
+                                   nsIFrameSetElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLFrameSetElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLFrameSetElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLFrameSetElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLFrameSetElement, Cols, cols)
 NS_IMPL_STRING_ATTR(nsHTMLFrameSetElement, Rows, rows)
--- a/content/html/content/src/nsHTMLHRElement.cpp
+++ b/content/html/content/src/nsHTMLHRElement.cpp
@@ -93,20 +93,22 @@ nsHTMLHRElement::~nsHTMLHRElement()
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLHRElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLHRElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLHRElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLHRElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED2(nsHTMLHRElement,
-                                nsIDOMHTMLHRElement,
-                                nsIDOMNSHTMLHRElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLHRElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLHRElement,
+                                   nsIDOMHTMLHRElement,
+                                   nsIDOMNSHTMLHRElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLHRElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLHRElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLHRElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLHRElement, Align, align)
 NS_IMPL_BOOL_ATTR(nsHTMLHRElement, NoShade, noshade)
--- a/content/html/content/src/nsHTMLHeadElement.cpp
+++ b/content/html/content/src/nsHTMLHeadElement.cpp
@@ -81,17 +81,19 @@ nsHTMLHeadElement::~nsHTMLHeadElement()
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLHeadElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLHeadElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLHeadElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLHeadElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLHeadElement, nsIDOMHTMLHeadElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLHeadElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLHeadElement, nsIDOMHTMLHeadElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLHeadElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLHeadElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLHeadElement)
 
 
 NS_IMPL_URI_ATTR(nsHTMLHeadElement, Profile, profile)
--- a/content/html/content/src/nsHTMLHeadingElement.cpp
+++ b/content/html/content/src/nsHTMLHeadingElement.cpp
@@ -89,19 +89,21 @@ nsHTMLHeadingElement::~nsHTMLHeadingElem
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLHeadingElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLHeadingElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLHeadingElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLHeadingElement,
-                                     nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLHeadingElement, nsIDOMHTMLHeadingElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLHeadingElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLHeadingElement,
+                                   nsIDOMHTMLHeadingElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLHeadingElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLHeadingElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLHeadingElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLHeadingElement, Align, align)
 
--- a/content/html/content/src/nsHTMLHtmlElement.cpp
+++ b/content/html/content/src/nsHTMLHtmlElement.cpp
@@ -83,17 +83,19 @@ nsHTMLHtmlElement::~nsHTMLHtmlElement()
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLHtmlElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLHtmlElement, nsGenericElement) 
 
 
 
 // QueryInterface implementation for nsHTMLHtmlElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLHtmlElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLHtmlElement, nsIDOMHTMLHtmlElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLHtmlElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLHtmlElement, nsIDOMHTMLHtmlElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLHtmlElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLHtmlElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLHtmlElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLHtmlElement, Version, version)
--- a/content/html/content/src/nsHTMLIFrameElement.cpp
+++ b/content/html/content/src/nsHTMLIFrameElement.cpp
@@ -104,24 +104,25 @@ nsHTMLIFrameElement::~nsHTMLIFrameElemen
 {
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLIFrameElement,nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLIFrameElement,nsGenericElement)
 
 // QueryInterface implementation for nsHTMLIFrameElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLIFrameElement,
-                                     nsGenericHTMLFrameElement)
-  NS_INTERFACE_TABLE_BEGIN
+NS_INTERFACE_TABLE_HEAD(nsHTMLIFrameElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(nsHTMLIFrameElement)
     NS_INTERFACE_TABLE_ENTRY(nsHTMLIFrameElement, nsIDOMHTMLIFrameElement)
 #ifdef MOZ_SVG
     NS_INTERFACE_TABLE_ENTRY(nsHTMLIFrameElement, nsIDOMGetSVGDocument)
 #endif
-  NS_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLIFrameElement,
+                                               nsGenericHTMLFrameElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLIFrameElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLIFrameElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Align, align)
 NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, FrameBorder, frameborder)
--- a/content/html/content/src/nsHTMLImageElement.cpp
+++ b/content/html/content/src/nsHTMLImageElement.cpp
@@ -187,24 +187,26 @@ nsHTMLImageElement::~nsHTMLImageElement(
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLImageElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLImageElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLImageElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLImageElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED6(nsHTMLImageElement,
-                                nsIDOMHTMLImageElement,
-                                nsIDOMNSHTMLImageElement,
-                                nsIJSNativeInitializer,
-                                imgIDecoderObserver,
-                                nsIImageLoadingContent,
-                                imgIContainerObserver)
+NS_INTERFACE_TABLE_HEAD(nsHTMLImageElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE6(nsHTMLImageElement,
+                                   nsIDOMHTMLImageElement,
+                                   nsIDOMNSHTMLImageElement,
+                                   nsIJSNativeInitializer,
+                                   imgIDecoderObserver,
+                                   nsIImageLoadingContent,
+                                   imgIContainerObserver)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLImageElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLImageElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLImageElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLImageElement, Name, name)
 NS_IMPL_STRING_ATTR(nsHTMLImageElement, Align, align)
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -405,29 +405,30 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mControllers)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLInputElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLInputElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLInputElement
-NS_HTML_CONTENT_CC_INTERFACE_TABLE_HEAD(nsHTMLInputElement,
-                                        nsGenericHTMLFormElement)
-  NS_INTERFACE_TABLE_INHERITED10(nsHTMLInputElement,
-                                 nsIDOMHTMLInputElement,
-                                 nsIDOMNSHTMLInputElement,
-                                 nsITextControlElement,
-                                 nsIFileControlElement,
-                                 nsIRadioControlElement,
-                                 nsIPhonetic,
-                                 imgIDecoderObserver,
-                                 nsIImageLoadingContent,
-                                 imgIContainerObserver,
-                                 nsIDOMNSEditableElement)
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLInputElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE10(nsHTMLInputElement,
+                                    nsIDOMHTMLInputElement,
+                                    nsIDOMNSHTMLInputElement,
+                                    nsITextControlElement,
+                                    nsIFileControlElement,
+                                    nsIRadioControlElement,
+                                    nsIPhonetic,
+                                    imgIDecoderObserver,
+                                    nsIImageLoadingContent,
+                                    imgIContainerObserver,
+                                    nsIDOMNSEditableElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLInputElement,
+                                               nsGenericHTMLFormElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLInputElement)
 
 
 // nsIDOMNode
 
 nsresult
 nsHTMLInputElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
 {
--- a/content/html/content/src/nsHTMLLIElement.cpp
+++ b/content/html/content/src/nsHTMLLIElement.cpp
@@ -88,18 +88,20 @@ nsHTMLLIElement::~nsHTMLLIElement()
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLLIElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLLIElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLLIElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLLIElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLLIElement, nsIDOMHTMLLIElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLLIElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLLIElement, nsIDOMHTMLLIElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLLIElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLLIElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLLIElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLLIElement, Type, type)
 NS_IMPL_INT_ATTR(nsHTMLLIElement, Value, value)
--- a/content/html/content/src/nsHTMLLabelElement.cpp
+++ b/content/html/content/src/nsHTMLLabelElement.cpp
@@ -135,19 +135,20 @@ nsHTMLLabelElement::~nsHTMLLabelElement(
 // nsISupports 
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLLabelElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLLabelElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLLabelElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLLabelElement,
-                                     nsGenericHTMLFormElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLLabelElement, nsIDOMHTMLLabelElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLLabelElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLLabelElement, nsIDOMHTMLLabelElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLLabelElement,
+                                               nsGenericHTMLFormElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLLabelElement)
 
 
 // nsIDOMHTMLLabelElement
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLLabelElement)
 
--- a/content/html/content/src/nsHTMLLegendElement.cpp
+++ b/content/html/content/src/nsHTMLLegendElement.cpp
@@ -123,19 +123,20 @@ nsHTMLLegendElement::~nsHTMLLegendElemen
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLLegendElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLLegendElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLLegendElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLLegendElement,
-                                     nsGenericHTMLFormElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLLegendElement, nsIDOMHTMLLegendElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLLegendElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLLegendElement, nsIDOMHTMLLegendElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLLegendElement,
+                                               nsGenericHTMLFormElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLLegendElement)
 
 
 // nsIDOMHTMLLegendElement
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLLegendElement)
 
--- a/content/html/content/src/nsHTMLLinkElement.cpp
+++ b/content/html/content/src/nsHTMLLinkElement.cpp
@@ -142,22 +142,24 @@ nsHTMLLinkElement::~nsHTMLLinkElement()
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLLinkElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLLinkElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLLinkElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLLinkElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED4(nsHTMLLinkElement,
-                                nsIDOMHTMLLinkElement,
-                                nsIDOMLinkStyle,
-                                nsILink,
-                                nsIStyleSheetLinkingElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLLinkElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE4(nsHTMLLinkElement,
+                                   nsIDOMHTMLLinkElement,
+                                   nsIDOMLinkStyle,
+                                   nsILink,
+                                   nsIStyleSheetLinkingElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLLinkElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLLinkElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLLinkElement)
 
 
 NS_IMETHODIMP
 nsHTMLLinkElement::GetDisabled(PRBool* aDisabled)
--- a/content/html/content/src/nsHTMLMapElement.cpp
+++ b/content/html/content/src/nsHTMLMapElement.cpp
@@ -97,19 +97,20 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
                                                        nsIDOMNodeList)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLMapElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLMapElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLMapElement
-NS_HTML_CONTENT_CC_INTERFACE_TABLE_HEAD(nsHTMLMapElement,
-                                        nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLMapElement, nsIDOMHTMLMapElement)
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLMapElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLMapElement, nsIDOMHTMLMapElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLMapElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLMapElement)
 
 
 nsresult
 nsHTMLMapElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                              nsIContent* aBindingParent,
                              PRBool aCompileEventHandlers)
 {
--- a/content/html/content/src/nsHTMLMetaElement.cpp
+++ b/content/html/content/src/nsHTMLMetaElement.cpp
@@ -82,19 +82,20 @@ nsHTMLMetaElement::~nsHTMLMetaElement()
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLMetaElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLMetaElement, nsGenericElement) 
 
 
 
 // QueryInterface implementation for nsHTMLMetaElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLMetaElement,
-                                     nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLMetaElement, nsIDOMHTMLMetaElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLMetaElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLMetaElement, nsIDOMHTMLMetaElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLMetaElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLMetaElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLMetaElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLMetaElement, Content, content)
 NS_IMPL_STRING_ATTR(nsHTMLMetaElement, HttpEquiv, httpEquiv)
--- a/content/html/content/src/nsHTMLOListElement.cpp
+++ b/content/html/content/src/nsHTMLOListElement.cpp
@@ -98,20 +98,23 @@ nsHTMLSharedListElement::~nsHTMLSharedLi
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLSharedListElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLSharedListElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLSharedListElement
-NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGOUS_HEAD(nsHTMLSharedListElement,
-                                              nsGenericHTMLElement,
-                                              nsIDOMHTMLOListElement)
-  NS_INTERFACE_TABLE_TO_MAP_SEGUE
+NS_INTERFACE_TABLE_HEAD(nsHTMLSharedListElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGUOUS_BEGIN(nsHTMLSharedListElement,
+                                                  nsIDOMHTMLOListElement)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE_AMBIGUOUS(nsHTMLSharedListElement,
+                                                         nsGenericHTMLElement,
+                                                         nsIDOMHTMLOListElement)
   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLOListElement, ol)
   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLDListElement, dl)
   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLUListElement, ul)
 
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO_IF_TAG(HTMLOListElement, ol)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO_IF_TAG(HTMLDListElement, dl)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO_IF_TAG(HTMLUListElement, ul)
 NS_HTML_CONTENT_INTERFACE_MAP_END
--- a/content/html/content/src/nsHTMLObjectElement.cpp
+++ b/content/html/content/src/nsHTMLObjectElement.cpp
@@ -173,33 +173,34 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLObj
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLObjectElement,
                                                   nsGenericHTMLFormElement)
   tmp->Traverse(cb);
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLObjectElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLObjectElement, nsGenericElement) 
 
-NS_HTML_CONTENT_CC_INTERFACE_TABLE_HEAD(nsHTMLObjectElement,
-                                        nsGenericHTMLFormElement)
-  NS_INTERFACE_TABLE_BEGIN
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLObjectElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(nsHTMLObjectElement)
     NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIDOMHTMLObjectElement)
     NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, imgIDecoderObserver)
     NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIRequestObserver)
     NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIStreamListener)
     NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIFrameLoaderOwner)
     NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIObjectLoadingContent)
     NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIImageLoadingContent)
     NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, imgIContainerObserver)
     NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIInterfaceRequestor)
     NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIChannelEventSink)
 #ifdef MOZ_SVG
     NS_INTERFACE_TABLE_ENTRY(nsHTMLObjectElement, nsIDOMGetSVGDocument)
 #endif
-  NS_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLObjectElement,
+                                               nsGenericHTMLFormElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLObjectElement)
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLObjectElement)
 
 
 NS_IMETHODIMP
 nsHTMLObjectElement::GetForm(nsIDOMHTMLFormElement **aForm)
 {
--- a/content/html/content/src/nsHTMLOptGroupElement.cpp
+++ b/content/html/content/src/nsHTMLOptGroupElement.cpp
@@ -110,20 +110,21 @@ nsHTMLOptGroupElement::~nsHTMLOptGroupEl
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLOptGroupElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLOptGroupElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLOptGroupElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLOptGroupElement,
-                                     nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLOptGroupElement,
-                                nsIDOMHTMLOptGroupElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLOptGroupElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLOptGroupElement,
+                                   nsIDOMHTMLOptGroupElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLOptGroupElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLOptGroupElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLOptGroupElement)
 
 
 NS_IMPL_BOOL_ATTR(nsHTMLOptGroupElement, Disabled, disabled)
 NS_IMPL_STRING_ATTR(nsHTMLOptGroupElement, Label, label)
--- a/content/html/content/src/nsHTMLOptionElement.cpp
+++ b/content/html/content/src/nsHTMLOptionElement.cpp
@@ -174,23 +174,24 @@ nsHTMLOptionElement::~nsHTMLOptionElemen
 // ISupports
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLOptionElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLOptionElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLOptionElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLOptionElement,
-                                     nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED4(nsHTMLOptionElement,
-                                nsIDOMHTMLOptionElement,
-                                nsIDOMNSHTMLOptionElement,
-                                nsIJSNativeInitializer,
-                                nsIOptionElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLOptionElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE4(nsHTMLOptionElement,
+                                   nsIDOMHTMLOptionElement,
+                                   nsIDOMNSHTMLOptionElement,
+                                   nsIJSNativeInitializer,
+                                   nsIOptionElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLOptionElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLOptionElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLOptionElement)
 
 
 NS_IMETHODIMP
 nsHTMLOptionElement::GetForm(nsIDOMHTMLFormElement** aForm)
--- a/content/html/content/src/nsHTMLParagraphElement.cpp
+++ b/content/html/content/src/nsHTMLParagraphElement.cpp
@@ -92,20 +92,21 @@ nsHTMLParagraphElement::~nsHTMLParagraph
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLParagraphElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLParagraphElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLParagraphElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLParagraphElement,
-                                     nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLParagraphElement,
-                                nsIDOMHTMLParagraphElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLParagraphElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLParagraphElement,
+                                   nsIDOMHTMLParagraphElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLParagraphElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLParagraphElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLParagraphElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLParagraphElement, Align, align)
 
--- a/content/html/content/src/nsHTMLPreElement.cpp
+++ b/content/html/content/src/nsHTMLPreElement.cpp
@@ -94,18 +94,20 @@ nsHTMLPreElement::~nsHTMLPreElement()
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLPreElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLPreElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLPreElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLPreElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLPreElement, nsIDOMHTMLPreElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLPreElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLPreElement, nsIDOMHTMLPreElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLPreElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLPreElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLPreElement)
 
 
 NS_IMPL_INT_ATTR(nsHTMLPreElement, Width, width)
 
--- a/content/html/content/src/nsHTMLScriptElement.cpp
+++ b/content/html/content/src/nsHTMLScriptElement.cpp
@@ -380,23 +380,24 @@ nsHTMLScriptElement::~nsHTMLScriptElemen
 {
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLScriptElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLScriptElement, nsGenericElement)
 
 // QueryInterface implementation for nsHTMLScriptElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLScriptElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED4(nsHTMLScriptElement,
-                                nsIDOMHTMLScriptElement,
-                                nsIScriptLoaderObserver,
-                                nsIScriptElement,
-                                nsIMutationObserver)
-  NS_INTERFACE_TABLE_TO_MAP_SEGUE
+NS_INTERFACE_TABLE_HEAD(nsHTMLScriptElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE4(nsHTMLScriptElement,
+                                   nsIDOMHTMLScriptElement,
+                                   nsIScriptLoaderObserver,
+                                   nsIScriptElement,
+                                   nsIMutationObserver)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLScriptElement,
+                                               nsGenericHTMLElement)
   if (mScriptEventHandler && aIID.Equals(NS_GET_IID(nsIScriptEventHandler)))
     foundInterface = static_cast<nsIScriptEventHandler*>
                                 (mScriptEventHandler);
   else
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLScriptElement)
 NS_HTML_CONTENT_INTERFACE_MAP_END
 
 
--- a/content/html/content/src/nsHTMLSelectElement.cpp
+++ b/content/html/content/src/nsHTMLSelectElement.cpp
@@ -166,23 +166,24 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
                                                        nsIDOMHTMLCollection)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLSelectElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLSelectElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLSelectElement
-NS_HTML_CONTENT_CC_INTERFACE_TABLE_HEAD(nsHTMLSelectElement,
-                                        nsGenericHTMLFormElement)
-  NS_INTERFACE_TABLE_INHERITED4(nsHTMLSelectElement,
-                                nsIDOMHTMLSelectElement,
-                                nsIDOMNSHTMLSelectElement,
-                                nsIDOMNSXBLFormControl,
-                                nsISelectElement)
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLSelectElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE4(nsHTMLSelectElement,
+                                   nsIDOMHTMLSelectElement,
+                                   nsIDOMNSHTMLSelectElement,
+                                   nsIDOMNSXBLFormControl,
+                                   nsISelectElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLSelectElement,
+                                               nsGenericHTMLFormElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLSelectElement)
 
 
 // nsIDOMHTMLSelectElement
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLSelectElement)
 
--- a/content/html/content/src/nsHTMLSharedElement.cpp
+++ b/content/html/content/src/nsHTMLSharedElement.cpp
@@ -122,20 +122,23 @@ nsHTMLSharedElement::~nsHTMLSharedElemen
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLSharedElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLSharedElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLSharedElement
-NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGOUS_HEAD(nsHTMLSharedElement,
-                                              nsGenericHTMLElement,
-                                              nsIDOMHTMLParamElement)
-  NS_INTERFACE_TABLE_TO_MAP_SEGUE
+NS_INTERFACE_TABLE_HEAD(nsHTMLSharedElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGUOUS_BEGIN(nsHTMLSharedElement,
+                                                  nsIDOMHTMLParamElement)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE_AMBIGUOUS(nsHTMLSharedElement,
+                                                         nsGenericHTMLElement,
+                                                         nsIDOMHTMLParamElement)
   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLParamElement, param)
   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLIsIndexElement, isindex)
   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLBaseElement, base)
   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLDirectoryElement, dir)
   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLMenuElement, menu)
   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLQuoteElement, q)
   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLQuoteElement, blockquote)
   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLBaseFontElement, basefont)
--- a/content/html/content/src/nsHTMLSharedObjectElement.cpp
+++ b/content/html/content/src/nsHTMLSharedObjectElement.cpp
@@ -205,30 +205,32 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLSha
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLSharedObjectElement,
                                                   nsGenericHTMLElement)
   tmp->Traverse(cb);
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLSharedObjectElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLSharedObjectElement, nsGenericElement) 
 
-NS_HTML_CONTENT_CC_INTERFACE_TABLE_AMBIGUOUS_HEAD(nsHTMLSharedObjectElement,
-                                                  nsGenericHTMLElement,
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLSharedObjectElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGUOUS_BEGIN(nsHTMLSharedObjectElement,
                                                   nsIDOMHTMLAppletElement)
-  NS_INTERFACE_TABLE_INHERITED9(nsHTMLSharedObjectElement,
-                                nsIRequestObserver,
-                                nsIStreamListener,
-                                nsIFrameLoaderOwner,
-                                imgIContainerObserver,
-                                nsIObjectLoadingContent,
-                                imgIDecoderObserver,
-                                nsIImageLoadingContent,
-                                nsIInterfaceRequestor,
-                                nsIChannelEventSink)
-  NS_INTERFACE_TABLE_TO_MAP_SEGUE
+    NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIRequestObserver)
+    NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIStreamListener)
+    NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIFrameLoaderOwner)
+    NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, imgIContainerObserver)
+    NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIObjectLoadingContent)
+    NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, imgIDecoderObserver)
+    NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIImageLoadingContent)
+    NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIInterfaceRequestor)
+    NS_INTERFACE_TABLE_ENTRY(nsHTMLSharedObjectElement, nsIChannelEventSink)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE_AMBIGUOUS(nsHTMLSharedObjectElement,
+                                                         nsGenericHTMLElement,
+                                                         nsIDOMHTMLAppletElement)
   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLAppletElement, applet)
   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMHTMLEmbedElement, embed)
 #ifdef MOZ_SVG
   NS_INTERFACE_MAP_ENTRY_IF_TAG(nsIDOMGetSVGDocument, embed)
 #endif
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO_IF_TAG(HTMLAppletElement, applet)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO_IF_TAG(HTMLEmbedElement, embed)
 NS_HTML_CONTENT_INTERFACE_MAP_END
--- a/content/html/content/src/nsHTMLSourceElement.cpp
+++ b/content/html/content/src/nsHTMLSourceElement.cpp
@@ -87,18 +87,20 @@ nsHTMLSourceElement::~nsHTMLSourceElemen
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLSourceElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLSourceElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLSourceElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLSourceElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLSourceElement, nsIDOMHTMLSourceElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLSourceElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLSourceElement, nsIDOMHTMLSourceElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLSourceElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLSourceElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLSourceElement)
 
 
 NS_IMPL_URI_ATTR(nsHTMLSourceElement, Src, src)
 NS_IMPL_STRING_ATTR(nsHTMLSourceElement, Type, type)
--- a/content/html/content/src/nsHTMLSpanElement.cpp
+++ b/content/html/content/src/nsHTMLSpanElement.cpp
@@ -82,17 +82,20 @@ nsHTMLSpanElement::~nsHTMLSpanElement()
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLSpanElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLSpanElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLSpanElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLSpanElement, nsGenericHTMLElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLSpanElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE0(nsHTMLSpanElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLSpanElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLSpanElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLSpanElement)
 
 
 nsresult
 nsHTMLSpanElement::GetInnerHTML(nsAString& aInnerHTML)
--- a/content/html/content/src/nsHTMLStyleElement.cpp
+++ b/content/html/content/src/nsHTMLStyleElement.cpp
@@ -132,22 +132,24 @@ nsHTMLStyleElement::~nsHTMLStyleElement(
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLStyleElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLStyleElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLStyleElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLStyleElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED4(nsHTMLStyleElement,
-                                nsIDOMHTMLStyleElement,
-                                nsIDOMLinkStyle,
-                                nsIStyleSheetLinkingElement,
-                                nsIMutationObserver)
+NS_INTERFACE_TABLE_HEAD(nsHTMLStyleElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE4(nsHTMLStyleElement,
+                                   nsIDOMHTMLStyleElement,
+                                   nsIDOMLinkStyle,
+                                   nsIStyleSheetLinkingElement,
+                                   nsIMutationObserver)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLStyleElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLStyleElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLStyleElement)
 
 
 NS_IMETHODIMP
 nsHTMLStyleElement::GetDisabled(PRBool* aDisabled)
--- a/content/html/content/src/nsHTMLTableCaptionElement.cpp
+++ b/content/html/content/src/nsHTMLTableCaptionElement.cpp
@@ -89,20 +89,21 @@ nsHTMLTableCaptionElement::~nsHTMLTableC
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLTableCaptionElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLTableCaptionElement, nsGenericElement)
 
 
 // QueryInterface implementation for nsHTMLTableCaptionElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLTableCaptionElement,
-                                     nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLTableCaptionElement,
-                                nsIDOMHTMLTableCaptionElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLTableCaptionElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLTableCaptionElement,
+                                   nsIDOMHTMLTableCaptionElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTableCaptionElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableCaptionElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLTableCaptionElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLTableCaptionElement, Align, align)
 
--- a/content/html/content/src/nsHTMLTableCellElement.cpp
+++ b/content/html/content/src/nsHTMLTableCellElement.cpp
@@ -100,20 +100,21 @@ nsHTMLTableCellElement::~nsHTMLTableCell
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLTableCellElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLTableCellElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLTableCellElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLTableCellElement,
-                                     nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLTableCellElement,
-                                nsIDOMHTMLTableCellElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLTableCellElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLTableCellElement,
+                                   nsIDOMHTMLTableCellElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTableCellElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableCellElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLTableCellElement)
 
 
 // protected method
 void
--- a/content/html/content/src/nsHTMLTableColElement.cpp
+++ b/content/html/content/src/nsHTMLTableColElement.cpp
@@ -93,20 +93,21 @@ nsHTMLTableColElement::~nsHTMLTableColEl
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLTableColElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLTableColElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLTableColElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLTableColElement,
-                                    nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLTableColElement,
-                                nsIDOMHTMLTableColElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLTableColElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLTableColElement,
+                                   nsIDOMHTMLTableColElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTableColElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableColElement)
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLTableColElement)
 
 
 NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableColElement, Align, align, "left")
 NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableColElement, Ch, _char, ".")
 NS_IMPL_STRING_ATTR(nsHTMLTableColElement, ChOff, charoff)
--- a/content/html/content/src/nsHTMLTableElement.cpp
+++ b/content/html/content/src/nsHTMLTableElement.cpp
@@ -404,19 +404,20 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mRows)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLTableElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLTableElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLTableElement
-NS_HTML_CONTENT_CC_INTERFACE_TABLE_HEAD(nsHTMLTableElement,
-                                        nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLTableElement, nsIDOMHTMLTableElement)
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLTableElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLTableElement, nsIDOMHTMLTableElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTableElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLTableElement)
 
 
 // the DOM spec says border, cellpadding, cellSpacing are all "wstring"
 // in fact, they are integers or they are meaningless.  so we store them
--- a/content/html/content/src/nsHTMLTableRowElement.cpp
+++ b/content/html/content/src/nsHTMLTableRowElement.cpp
@@ -104,20 +104,21 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
                                                        nsIDOMNodeList)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLTableRowElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLTableRowElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLTableRowElement
-NS_HTML_CONTENT_CC_INTERFACE_TABLE_HEAD(nsHTMLTableRowElement,
-                                        nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLTableRowElement,
-                                nsIDOMHTMLTableRowElement)
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLTableRowElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLTableRowElement,
+                                   nsIDOMHTMLTableRowElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTableRowElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableRowElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLTableRowElement)
 
 
 // protected method
 nsresult
--- a/content/html/content/src/nsHTMLTableSectionElement.cpp
+++ b/content/html/content/src/nsHTMLTableSectionElement.cpp
@@ -102,20 +102,21 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
                                                        nsIDOMNodeList)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLTableSectionElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLTableSectionElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLTableSectionElement
-NS_HTML_CONTENT_CC_INTERFACE_TABLE_HEAD(nsHTMLTableSectionElement,
-                                        nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLTableSectionElement,
-                                nsIDOMHTMLTableSectionElement)
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLTableSectionElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLTableSectionElement,
+                                   nsIDOMHTMLTableSectionElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTableSectionElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTableSectionElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLTableSectionElement)
 
 
 NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableSectionElement, Align, align, "left")
 NS_IMPL_STRING_ATTR_DEFAULT_VALUE(nsHTMLTableSectionElement, VAlign, valign, "middle")
--- a/content/html/content/src/nsHTMLTextAreaElement.cpp
+++ b/content/html/content/src/nsHTMLTextAreaElement.cpp
@@ -252,24 +252,25 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mControllers)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLTextAreaElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLTextAreaElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLTextAreaElement
-NS_HTML_CONTENT_CC_INTERFACE_TABLE_HEAD(nsHTMLTextAreaElement,
-                                        nsGenericHTMLFormElement)
-  NS_INTERFACE_TABLE_INHERITED5(nsHTMLTextAreaElement,
-                                nsIDOMHTMLTextAreaElement,
-                                nsIDOMNSHTMLTextAreaElement,
-                                nsITextControlElement,
-                                nsIDOMNSEditableElement,
-                                nsIMutationObserver)
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLTextAreaElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE5(nsHTMLTextAreaElement,
+                                   nsIDOMHTMLTextAreaElement,
+                                   nsIDOMNSHTMLTextAreaElement,
+                                   nsITextControlElement,
+                                   nsIDOMNSEditableElement,
+                                   nsIMutationObserver)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTextAreaElement,
+                                               nsGenericHTMLFormElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTextAreaElement)
 
 
 // nsIDOMHTMLTextAreaElement
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLTextAreaElement)
 
--- a/content/html/content/src/nsHTMLTitleElement.cpp
+++ b/content/html/content/src/nsHTMLTitleElement.cpp
@@ -105,20 +105,22 @@ nsHTMLTitleElement::~nsHTMLTitleElement(
 }
 
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLTitleElement, nsGenericElement) 
 NS_IMPL_RELEASE_INHERITED(nsHTMLTitleElement, nsGenericElement) 
 
 
 // QueryInterface implementation for nsHTMLTitleElement
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLTitleElement, nsGenericHTMLElement)
-  NS_INTERFACE_TABLE_INHERITED2(nsHTMLTitleElement,
-                                nsIDOMHTMLTitleElement,
-                                nsIMutationObserver)
+NS_INTERFACE_TABLE_HEAD(nsHTMLTitleElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE2(nsHTMLTitleElement,
+                                   nsIDOMHTMLTitleElement,
+                                   nsIMutationObserver)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLTitleElement,
+                                               nsGenericHTMLElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLTitleElement)
 
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLTitleElement)
 
 
 NS_IMETHODIMP 
 nsHTMLTitleElement::GetText(nsAString& aTitle)
--- a/content/html/content/src/nsHTMLVideoElement.cpp
+++ b/content/html/content/src/nsHTMLVideoElement.cpp
@@ -68,18 +68,20 @@
 #include "nsIDOMProgressEvent.h"
 #include "nsHTMLMediaError.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Video)
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLVideoElement, nsHTMLMediaElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLVideoElement, nsHTMLMediaElement)
 
-NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLVideoElement, nsHTMLMediaElement)
-  NS_INTERFACE_TABLE_INHERITED1(nsHTMLVideoElement, nsIDOMHTMLVideoElement)
+NS_INTERFACE_TABLE_HEAD(nsHTMLVideoElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE1(nsHTMLVideoElement, nsIDOMHTMLVideoElement)
+  NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(nsHTMLVideoElement,
+                                               nsHTMLMediaElement)
 NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLVideoElement)
 
 NS_IMPL_ELEMENT_CLONE(nsHTMLVideoElement)
 
 // nsIDOMHTMLVideoElement
 NS_IMPL_INT_ATTR(nsHTMLVideoElement, Width, width)
 NS_IMPL_INT_ATTR(nsHTMLVideoElement, Height, height)
 NS_IMPL_URI_ATTR(nsHTMLVideoElement, Poster, poster)
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -248,21 +248,22 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsHTMLDocument, nsDocument)
 NS_IMPL_RELEASE_INHERITED(nsHTMLDocument, nsDocument)
 
 
 // QueryInterface implementation for nsHTMLDocument
 NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLDocument)
-  NS_INTERFACE_TABLE_INHERITED3(nsHTMLDocument,
-                                nsIHTMLDocument,
-                                nsIDOMHTMLDocument,
-                                nsIDOMNSHTMLDocument)
-  NS_INTERFACE_TABLE_TO_MAP_SEGUE
+  NS_DOCUMENT_INTERFACE_TABLE_BEGIN(nsHTMLDocument)
+    NS_INTERFACE_TABLE_ENTRY(nsHTMLDocument, nsIHTMLDocument)
+    NS_INTERFACE_TABLE_ENTRY(nsHTMLDocument, nsIDOMHTMLDocument)
+    NS_INTERFACE_TABLE_ENTRY(nsHTMLDocument, nsIDOMNSHTMLDocument)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLDocument)
 NS_INTERFACE_MAP_END_INHERITING(nsDocument)
 
 
 nsresult
 nsHTMLDocument::Init()
 {
   nsresult rv = nsDocument::Init();
--- a/content/html/document/src/nsHTMLDocument.h
+++ b/content/html/document/src/nsHTMLDocument.h
@@ -368,9 +368,15 @@ protected:
 
   // When false, the .cookies property is completely disabled
   PRBool mDisableCookieAccess;
 
   // Parser used for constructing document fragments.
   nsCOMPtr<nsIParser> mFragmentParser;
 };
 
+#define NS_HTML_DOCUMENT_INTERFACE_TABLE_BEGIN(_class)                        \
+    NS_DOCUMENT_INTERFACE_TABLE_BEGIN(_class)                                 \
+    NS_INTERFACE_TABLE_ENTRY(_class, nsIHTMLDocument)                         \
+    NS_INTERFACE_TABLE_ENTRY(_class, nsIDOMHTMLDocument)                      \
+    NS_INTERFACE_TABLE_ENTRY(_class, nsIDOMNSHTMLDocument)
+
 #endif /* nsHTMLDocument_h___ */
--- a/content/html/document/src/nsImageDocument.cpp
+++ b/content/html/document/src/nsImageDocument.cpp
@@ -273,22 +273,23 @@ nsImageDocument::~nsImageDocument()
 }
 
 // XXXbz shouldn't this participate in cycle collection?  It's got
 // mImageContent!
 NS_IMPL_ADDREF_INHERITED(nsImageDocument, nsMediaDocument)
 NS_IMPL_RELEASE_INHERITED(nsImageDocument, nsMediaDocument)
 
 NS_INTERFACE_TABLE_HEAD(nsImageDocument)
-  NS_INTERFACE_TABLE_INHERITED4(nsImageDocument,
-                                nsIImageDocument,
-                                imgIDecoderObserver,
-                                imgIContainerObserver,
-                                nsIDOMEventListener)
-  NS_INTERFACE_TABLE_TO_MAP_SEGUE
+  NS_HTML_DOCUMENT_INTERFACE_TABLE_BEGIN(nsImageDocument)
+    NS_INTERFACE_TABLE_ENTRY(nsImageDocument, nsIImageDocument)
+    NS_INTERFACE_TABLE_ENTRY(nsImageDocument, imgIDecoderObserver)
+    NS_INTERFACE_TABLE_ENTRY(nsImageDocument, imgIContainerObserver)
+    NS_INTERFACE_TABLE_ENTRY(nsImageDocument, nsIDOMEventListener)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(ImageDocument)
 NS_INTERFACE_MAP_END_INHERITING(nsMediaDocument)
 
 
 nsresult
 nsImageDocument::Init()
 {
   nsresult rv = nsMediaDocument::Init();
--- a/content/svg/content/src/nsSVGAElement.cpp
+++ b/content/svg/content/src/nsSVGAElement.cpp
@@ -106,22 +106,19 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(A)
 
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGAElement, nsSVGAElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGAElement, nsSVGAElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGAElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAElement)
-  NS_INTERFACE_MAP_ENTRY(nsILink)
+NS_INTERFACE_TABLE_HEAD(nsSVGAElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGAElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGAElement, nsILink)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGAElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGAElementBase)
 
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGAElement::nsSVGAElement(nsINodeInfo *aNodeInfo)
--- a/content/svg/content/src/nsSVGCircleElement.cpp
+++ b/content/svg/content/src/nsSVGCircleElement.cpp
@@ -87,21 +87,19 @@ nsSVGElement::LengthInfo nsSVGCircleElem
 NS_IMPL_NS_NEW_SVG_ELEMENT(Circle)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGCircleElement,nsSVGCircleElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGCircleElement,nsSVGCircleElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGCircleElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGCircleElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGCircleElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGCircleElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGCircleElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGCircleElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGCircleElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGCircleElement::nsSVGCircleElement(nsINodeInfo *aNodeInfo)
   : nsSVGCircleElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGClipPathElement.cpp
+++ b/content/svg/content/src/nsSVGClipPathElement.cpp
@@ -48,22 +48,20 @@ nsSVGElement::EnumInfo nsSVGClipPathElem
 NS_IMPL_NS_NEW_SVG_ELEMENT(ClipPath)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGClipPathElement,nsSVGClipPathElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGClipPathElement,nsSVGClipPathElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGClipPathElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGClipPathElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGUnitTypes)
+NS_INTERFACE_TABLE_HEAD(nsSVGClipPathElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGClipPathElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGClipPathElement,
+                           nsIDOMSVGUnitTypes)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGClipPathElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGClipPathElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGClipPathElement::nsSVGClipPathElement(nsINodeInfo *aNodeInfo)
   : nsSVGClipPathElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGDefsElement.cpp
+++ b/content/svg/content/src/nsSVGDefsElement.cpp
@@ -74,20 +74,19 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(Defs)
 
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGDefsElement,nsSVGDefsElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGDefsElement,nsSVGDefsElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGDefsElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGDefsElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGDefsElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGDefsElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGDefsElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGDefsElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGDefsElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGDefsElement::nsSVGDefsElement(nsINodeInfo *aNodeInfo)
   : nsSVGDefsElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGDescElement.cpp
+++ b/content/svg/content/src/nsSVGDescElement.cpp
@@ -68,21 +68,19 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(Desc)
 
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGDescElement, nsSVGDescElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGDescElement, nsSVGDescElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGDescElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGDescElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGDescElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGDescElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGDescElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGDescElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGDescElementBase)
 
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGDescElement::nsSVGDescElement(nsINodeInfo *aNodeInfo)
--- a/content/svg/content/src/nsSVGEllipseElement.cpp
+++ b/content/svg/content/src/nsSVGEllipseElement.cpp
@@ -89,21 +89,19 @@ nsSVGElement::LengthInfo nsSVGEllipseEle
 NS_IMPL_NS_NEW_SVG_ELEMENT(Ellipse)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGEllipseElement,nsSVGEllipseElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGEllipseElement,nsSVGEllipseElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGEllipseElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGEllipseElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGEllipseElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGEllipseElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGEllipseElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGEllipseElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGEllipseElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGEllipseElement::nsSVGEllipseElement(nsINodeInfo *aNodeInfo)
   : nsSVGEllipseElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGFilterElement.cpp
+++ b/content/svg/content/src/nsSVGFilterElement.cpp
@@ -72,22 +72,20 @@ nsSVGElement::StringInfo nsSVGFilterElem
 NS_IMPL_NS_NEW_SVG_ELEMENT(Filter)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFilterElement,nsSVGFilterElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFilterElement,nsSVGFilterElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFilterElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGURIReference)
+NS_INTERFACE_TABLE_HEAD(nsSVGFilterElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFilterElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGFilterElement,
+                           nsIDOMSVGURIReference)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFilterElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFilterElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGFilterElement::nsSVGFilterElement(nsINodeInfo *aNodeInfo)
   : nsSVGFilterElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGFilters.cpp
+++ b/content/svg/content/src/nsSVGFilters.cpp
@@ -382,22 +382,21 @@ nsSVGElement::StringInfo nsSVGFEGaussian
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEGaussianBlur)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEGaussianBlurElement,nsSVGFEGaussianBlurElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEGaussianBlurElement,nsSVGFEGaussianBlurElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEGaussianBlurElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEGaussianBlurElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEGaussianBlurElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEGaussianBlurElement, nsIDOMNode,
+                           nsIDOMElement, nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFEGaussianBlurElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEGaussianBlurElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEGaussianBlurElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEGaussianBlurElement)
@@ -841,22 +840,21 @@ nsSVGElement::StringInfo nsSVGFEBlendEle
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEBlend)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEBlendElement,nsSVGFEBlendElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEBlendElement,nsSVGFEBlendElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEBlendElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEBlendElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEBlendElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEBlendElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFEBlendElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEBlendElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEBlendElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEBlendElement)
@@ -1043,22 +1041,21 @@ nsSVGElement::StringInfo nsSVGFEColorMat
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEColorMatrix)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEColorMatrixElement,nsSVGFEColorMatrixElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEColorMatrixElement,nsSVGFEColorMatrixElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEColorMatrixElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEColorMatrixElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEColorMatrixElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEColorMatrixElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFEColorMatrixElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEColorMatrixElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEColorMatrixElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsresult
 nsSVGFEColorMatrixElement::Init()
@@ -1382,22 +1379,21 @@ nsSVGElement::StringInfo nsSVGFEComposit
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEComposite)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFECompositeElement,nsSVGFECompositeElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFECompositeElement,nsSVGFECompositeElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFECompositeElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFECompositeElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFECompositeElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFECompositeElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFECompositeElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFECompositeElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFECompositeElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFECompositeElement)
 
@@ -1642,22 +1638,21 @@ nsSVGElement::StringInfo nsSVGFEComponen
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEComponentTransfer)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEComponentTransferElement,nsSVGFEComponentTransferElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEComponentTransferElement,nsSVGFEComponentTransferElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEComponentTransferElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEComponentTransferElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEComponentTransferElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEComponentTransferElement, nsIDOMNode,
+                           nsIDOMElement, nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFEComponentTransferElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEComponentTransferElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEComponentTransferElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEComponentTransferElement)
 
@@ -2028,22 +2023,21 @@ public:
   NS_FORWARD_NSIDOMELEMENT(nsSVGComponentTransferFunctionElement::)
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 };
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEFuncRElement,nsSVGComponentTransferFunctionElement)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEFuncRElement,nsSVGComponentTransferFunctionElement)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEFuncRElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGComponentTransferFunctionElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEFuncRElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEFuncRElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEFuncRElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
+                           nsIDOMSVGComponentTransferFunctionElement,
+                           nsIDOMSVGFEFuncRElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEFuncRElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGComponentTransferFunctionElement)
 
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEFuncR)
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEFuncRElement)
 
 
 class nsSVGFEFuncGElement : public nsSVGComponentTransferFunctionElement,
@@ -2070,22 +2064,21 @@ public:
   NS_FORWARD_NSIDOMELEMENT(nsSVGComponentTransferFunctionElement::)
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 };
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEFuncGElement,nsSVGComponentTransferFunctionElement)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEFuncGElement,nsSVGComponentTransferFunctionElement)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEFuncGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGComponentTransferFunctionElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEFuncGElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEFuncGElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEFuncGElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
+                           nsIDOMSVGComponentTransferFunctionElement,
+                           nsIDOMSVGFEFuncGElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEFuncGElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGComponentTransferFunctionElement)
 
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEFuncG)
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEFuncGElement)
 
 
 class nsSVGFEFuncBElement : public nsSVGComponentTransferFunctionElement,
@@ -2112,22 +2105,21 @@ public:
   NS_FORWARD_NSIDOMELEMENT(nsSVGComponentTransferFunctionElement::)
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 };
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEFuncBElement,nsSVGComponentTransferFunctionElement)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEFuncBElement,nsSVGComponentTransferFunctionElement)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEFuncBElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGComponentTransferFunctionElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEFuncBElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEFuncBElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEFuncBElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
+                           nsIDOMSVGComponentTransferFunctionElement,
+                           nsIDOMSVGFEFuncBElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEFuncBElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGComponentTransferFunctionElement)
 
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEFuncB)
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEFuncBElement)
 
 
 class nsSVGFEFuncAElement : public nsSVGComponentTransferFunctionElement,
@@ -2154,22 +2146,21 @@ public:
   NS_FORWARD_NSIDOMELEMENT(nsSVGComponentTransferFunctionElement::)
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 };
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEFuncAElement,nsSVGComponentTransferFunctionElement)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEFuncAElement,nsSVGComponentTransferFunctionElement)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEFuncAElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGComponentTransferFunctionElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEFuncAElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEFuncAElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEFuncAElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
+                           nsIDOMSVGComponentTransferFunctionElement,
+                           nsIDOMSVGFEFuncAElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEFuncAElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGComponentTransferFunctionElement)
 
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEFuncA)
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEFuncAElement)
 
 //---------------------Merge------------------------
 
@@ -2267,22 +2258,21 @@ nsSVGElement::StringInfo nsSVGFEMergeEle
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEMerge)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEMergeElement,nsSVGFEMergeElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEMergeElement,nsSVGFEMergeElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEMergeElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEMergeElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEMergeElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEMergeElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFEMergeElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEMergeElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEMergeElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEMergeElement)
 
@@ -2338,21 +2328,19 @@ nsSVGElement::StringInfo nsSVGFEMergeNod
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEMergeNode)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEMergeNodeElement,nsSVGFEMergeNodeElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEMergeNodeElement,nsSVGFEMergeNodeElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEMergeNodeElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEMergeNodeElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEMergeNodeElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGFEMergeNodeElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGFEMergeNodeElement)
    // nsISupports is an ambiguous base of nsSVGFE so we have to work
    // around that
    if ( aIID.Equals(NS_GET_IID(nsSVGFEMergeNodeElement)) )
      foundInterface = static_cast<nsISupports*>(static_cast<void*>(this));
    else
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEMergeNodeElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEMergeNodeElementBase)
 
@@ -2453,22 +2441,21 @@ nsSVGElement::StringInfo nsSVGFEOffsetEl
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEOffset)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEOffsetElement,nsSVGFEOffsetElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEOffsetElement,nsSVGFEOffsetElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEOffsetElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEOffsetElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEOffsetElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEOffsetElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFEOffsetElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEOffsetElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEOffsetElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEOffsetElement)
@@ -2642,22 +2629,21 @@ nsSVGElement::StringInfo nsSVGFEFloodEle
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEFlood)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEFloodElement,nsSVGFEFloodElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEFloodElement,nsSVGFEFloodElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEFloodElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEFloodElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEFloodElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEFloodElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFEFloodElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEFloodElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEFloodElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEFloodElement)
 
@@ -2782,22 +2768,21 @@ nsSVGElement::StringInfo nsSVGFETileElem
 NS_IMPL_NS_NEW_SVG_ELEMENT(FETile)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFETileElement,nsSVGFETileElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFETileElement,nsSVGFETileElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFETileElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFETileElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFETileElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFETileElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFETileElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFETileElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFETileElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFETileElement)
@@ -3079,22 +3064,21 @@ nsSVGElement::StringInfo nsSVGFETurbulen
 NS_IMPL_NS_NEW_SVG_ELEMENT(FETurbulence)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFETurbulenceElement,nsSVGFETurbulenceElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFETurbulenceElement,nsSVGFETurbulenceElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFETurbulenceElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFETurbulenceElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFETurbulenceElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFETurbulenceElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFETurbulenceElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFETurbulenceElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFETurbulenceElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFETurbulenceElement)
 
@@ -3516,22 +3500,21 @@ nsSVGElement::StringInfo nsSVGFEMorpholo
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEMorphology)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEMorphologyElement,nsSVGFEMorphologyElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEMorphologyElement,nsSVGFEMorphologyElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEMorphologyElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEMorphologyElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEMorphologyElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEMorphologyElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFEMorphologyElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEMorphologyElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEMorphologyElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEMorphologyElement)
@@ -3867,22 +3850,21 @@ nsSVGElement::StringInfo nsSVGFEConvolve
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEConvolveMatrix)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEConvolveMatrixElement,nsSVGFEConvolveMatrixElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEConvolveMatrixElement,nsSVGFEConvolveMatrixElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEConvolveMatrixElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEConvolveMatrixElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEConvolveMatrixElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEConvolveMatrixElement, nsIDOMNode,
+                           nsIDOMElement, nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFEConvolveMatrixElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEConvolveMatrixElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEConvolveMatrixElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsresult
 nsSVGFEConvolveMatrixElement::Init()
@@ -4261,21 +4243,20 @@ nsSVGElement::NumberInfo nsSVGFEDistantL
 };
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEDistantLightElement,nsSVGFEDistantLightElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEDistantLightElement,nsSVGFEDistantLightElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEDistantLightElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEDistantLightElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEDistantLightElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGFEDistantLightElement, nsIDOMNode,
+                           nsIDOMElement, nsIDOMSVGElement,
+                           nsIDOMSVGFEDistantLightElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEDistantLightElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEDistantLightElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEDistantLightElement)
 
@@ -4348,21 +4329,20 @@ nsSVGElement::NumberInfo nsSVGFEPointLig
 };
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEPointLightElement,nsSVGFEPointLightElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEPointLightElement,nsSVGFEPointLightElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEPointLightElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEPointLightElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEPointLightElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGFEPointLightElement, nsIDOMNode,
+                           nsIDOMElement, nsIDOMSVGElement,
+                           nsIDOMSVGFEPointLightElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEPointLightElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEPointLightElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEPointLightElement)
 
@@ -4445,21 +4425,20 @@ nsSVGElement::NumberInfo nsSVGFESpotLigh
 };
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFESpotLightElement,nsSVGFESpotLightElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFESpotLightElement,nsSVGFESpotLightElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFESpotLightElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFESpotLightElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFESpotLightElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGFESpotLightElement, nsIDOMNode,
+                           nsIDOMElement, nsIDOMSVGElement,
+                           nsIDOMSVGFESpotLightElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFESpotLightElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFESpotLightElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFESpotLightElement)
 
@@ -4915,22 +4894,21 @@ protected:
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEDiffuseLighting)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEDiffuseLightingElement,nsSVGFEDiffuseLightingElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEDiffuseLightingElement,nsSVGFEDiffuseLightingElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEDiffuseLightingElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEDiffuseLightingElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEDiffuseLightingElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEDiffuseLightingElement, nsIDOMNode,
+                           nsIDOMElement, nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFEDiffuseLightingElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEDiffuseLightingElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEDiffuseLightingElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEDiffuseLightingElement)
 
@@ -5038,22 +5016,21 @@ protected:
 NS_IMPL_NS_NEW_SVG_ELEMENT(FESpecularLighting)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFESpecularLightingElement,nsSVGFESpecularLightingElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFESpecularLightingElement,nsSVGFESpecularLightingElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFESpecularLightingElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFESpecularLightingElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFESpecularLightingElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFESpecularLightingElement, nsIDOMNode,
+                           nsIDOMElement, nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFESpecularLightingElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFESpecularLightingElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFESpecularLightingElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFESpecularLightingElement)
 
@@ -5245,25 +5222,22 @@ nsSVGElement::StringInfo nsSVGFEImageEle
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEImage)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEImageElement,nsSVGFEImageElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEImageElement,nsSVGFEImageElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEImageElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEImageElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGURIReference)
-  NS_INTERFACE_MAP_ENTRY(imgIDecoderObserver)
-  NS_INTERFACE_MAP_ENTRY(nsIImageLoadingContent)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEImageElement)
+  NS_NODE_INTERFACE_TABLE8(nsSVGFEImageElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFEImageElement, nsIDOMSVGURIReference,
+                           imgIDecoderObserver, nsIImageLoadingContent)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEImageElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEImageElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGFEImageElement::nsSVGFEImageElement(nsINodeInfo *aNodeInfo)
   : nsSVGFEImageElementBase(aNodeInfo)
@@ -5606,22 +5580,21 @@ nsSVGElement::StringInfo nsSVGFEDisplace
 NS_IMPL_NS_NEW_SVG_ELEMENT(FEDisplacementMap)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGFEDisplacementMapElement,nsSVGFEDisplacementMapElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGFEDisplacementMapElement,nsSVGFEDisplacementMapElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGFEDisplacementMapElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFilterPrimitiveStandardAttributes)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFEDisplacementMapElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGFEDisplacementMapElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGFEDisplacementMapElement, nsIDOMNode,
+                           nsIDOMElement, nsIDOMSVGElement,
+                           nsIDOMSVGFilterPrimitiveStandardAttributes,
+                           nsIDOMSVGFEDisplacementMapElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGFEDisplacementMapElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGFEDisplacementMapElementBase)
 
 //----------------------------------------------------------------------
 // nsIDOMNode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGFEDisplacementMapElement)
 
--- a/content/svg/content/src/nsSVGForeignObjectElement.cpp
+++ b/content/svg/content/src/nsSVGForeignObjectElement.cpp
@@ -51,21 +51,19 @@ nsSVGElement::LengthInfo nsSVGForeignObj
 NS_IMPL_NS_NEW_SVG_ELEMENT(ForeignObject)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGForeignObjectElement,nsSVGForeignObjectElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGForeignObjectElement,nsSVGForeignObjectElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGForeignObjectElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGForeignObjectElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGForeignObjectElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGForeignObjectElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGForeignObjectElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGForeignObjectElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGForeignObjectElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGForeignObjectElement::nsSVGForeignObjectElement(nsINodeInfo *aNodeInfo)
   : nsSVGForeignObjectElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGGElement.cpp
+++ b/content/svg/content/src/nsSVGGElement.cpp
@@ -74,21 +74,19 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(G)
 
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGGElement,nsSVGGElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGGElement,nsSVGGElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGGElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGGElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGGElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGGElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGGElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGGElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGGElement::nsSVGGElement(nsINodeInfo *aNodeInfo)
   : nsSVGGElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGGradientElement.cpp
+++ b/content/svg/content/src/nsSVGGradientElement.cpp
@@ -192,22 +192,21 @@ nsSVGElement::LengthInfo nsSVGLinearGrad
 NS_IMPL_NS_NEW_SVG_ELEMENT(LinearGradient)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGLinearGradientElement,nsSVGLinearGradientElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGLinearGradientElement,nsSVGLinearGradientElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGLinearGradientElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGGradientElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLinearGradientElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGLinearGradientElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGLinearGradientElement, nsIDOMNode,
+                           nsIDOMElement, nsIDOMSVGElement,
+                           nsIDOMSVGGradientElement,
+                           nsIDOMSVGLinearGradientElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGLinearGradientElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGLinearGradientElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGLinearGradientElement::nsSVGLinearGradientElement(nsINodeInfo* aNodeInfo)
   : nsSVGLinearGradientElementBase(aNodeInfo)
@@ -271,22 +270,21 @@ nsSVGElement::LengthInfo nsSVGRadialGrad
 NS_IMPL_NS_NEW_SVG_ELEMENT(RadialGradient)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGRadialGradientElement,nsSVGRadialGradientElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGRadialGradientElement,nsSVGRadialGradientElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGRadialGradientElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGGradientElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGRadialGradientElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGRadialGradientElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGRadialGradientElement, nsIDOMNode,
+                           nsIDOMElement, nsIDOMSVGElement,
+                           nsIDOMSVGGradientElement,
+                           nsIDOMSVGRadialGradientElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGRadialGradientElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGRadialGradientElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGRadialGradientElement::nsSVGRadialGradientElement(nsINodeInfo* aNodeInfo)
   : nsSVGRadialGradientElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGImageElement.cpp
+++ b/content/svg/content/src/nsSVGImageElement.cpp
@@ -130,24 +130,21 @@ nsSVGElement::StringInfo nsSVGImageEleme
 NS_IMPL_NS_NEW_SVG_ELEMENT(Image)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGImageElement,nsSVGImageElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGImageElement,nsSVGImageElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGImageElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGImageElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGURIReference)
-  NS_INTERFACE_MAP_ENTRY(imgIDecoderObserver)
-  NS_INTERFACE_MAP_ENTRY(nsIImageLoadingContent)
+NS_INTERFACE_TABLE_HEAD(nsSVGImageElement)
+  NS_NODE_INTERFACE_TABLE7(nsSVGImageElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGImageElement,
+                           nsIDOMSVGURIReference, imgIDecoderObserver,
+                           nsIImageLoadingContent)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGImageElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGImageElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGImageElement::nsSVGImageElement(nsINodeInfo *aNodeInfo)
   : nsSVGImageElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGLineElement.cpp
+++ b/content/svg/content/src/nsSVGLineElement.cpp
@@ -93,21 +93,19 @@ nsSVGElement::LengthInfo nsSVGLineElemen
 NS_IMPL_NS_NEW_SVG_ELEMENT(Line)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGLineElement,nsSVGLineElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGLineElement,nsSVGLineElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGLineElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLineElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGLineElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGLineElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGLineElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGLineElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGLineElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGLineElement::nsSVGLineElement(nsINodeInfo *aNodeInfo)
   : nsSVGLineElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGMarkerElement.cpp
+++ b/content/svg/content/src/nsSVGMarkerElement.cpp
@@ -85,22 +85,20 @@ NS_INTERFACE_MAP_BEGIN(nsSVGOrientType::
   NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedEnumeration)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGAnimatedEnumeration)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF_INHERITED(nsSVGMarkerElement,nsSVGMarkerElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGMarkerElement,nsSVGMarkerElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGMarkerElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFitToViewBox)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGMarkerElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGMarkerElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGMarkerElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGFitToViewBox,
+                           nsIDOMSVGMarkerElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGMarkerElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGMarkerElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsresult
 nsSVGOrientType::SetBaseValue(PRUint16 aValue,
--- a/content/svg/content/src/nsSVGMaskElement.cpp
+++ b/content/svg/content/src/nsSVGMaskElement.cpp
@@ -63,22 +63,20 @@ nsSVGElement::EnumInfo nsSVGMaskElement:
 NS_IMPL_NS_NEW_SVG_ELEMENT(Mask)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGMaskElement,nsSVGMaskElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGMaskElement,nsSVGMaskElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGMaskElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGMaskElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGUnitTypes)
+NS_INTERFACE_TABLE_HEAD(nsSVGMaskElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGMaskElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGMaskElement,
+                           nsIDOMSVGUnitTypes)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGMaskElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGMaskElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGMaskElement::nsSVGMaskElement(nsINodeInfo* aNodeInfo)
   : nsSVGMaskElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGMetadataElement.cpp
+++ b/content/svg/content/src/nsSVGMetadataElement.cpp
@@ -68,21 +68,19 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(Metadata)
 
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGMetadataElement, nsSVGMetadataElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGMetadataElement, nsSVGMetadataElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGMetadataElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGMetadataElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGMetadataElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGMetadataElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGMetadataElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGMetadataElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGMetadataElementBase)
 
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGMetadataElement::nsSVGMetadataElement(nsINodeInfo *aNodeInfo)
--- a/content/svg/content/src/nsSVGPathElement.cpp
+++ b/content/svg/content/src/nsSVGPathElement.cpp
@@ -55,22 +55,20 @@ nsSVGElement::NumberInfo nsSVGPathElemen
 NS_IMPL_NS_NEW_SVG_ELEMENT(Path)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGPathElement,nsSVGPathElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGPathElement,nsSVGPathElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGPathElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGPathElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGAnimatedPathData)
+NS_INTERFACE_TABLE_HEAD(nsSVGPathElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGPathElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGPathElement,
+                           nsIDOMSVGAnimatedPathData)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGPathElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGPathElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGPathElement::nsSVGPathElement(nsINodeInfo* aNodeInfo)
   : nsSVGPathElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGPatternElement.cpp
+++ b/content/svg/content/src/nsSVGPatternElement.cpp
@@ -78,25 +78,21 @@ nsSVGElement::StringInfo nsSVGPatternEle
 NS_IMPL_NS_NEW_SVG_ELEMENT(Pattern)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGPatternElement,nsSVGPatternElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGPatternElement,nsSVGPatternElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGPatternElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFitToViewBox)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGURIReference)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGPatternElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGUnitTypes)
-  NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
+NS_INTERFACE_TABLE_HEAD(nsSVGPatternElement)
+  NS_NODE_INTERFACE_TABLE8(nsSVGPatternElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGFitToViewBox,
+                           nsIDOMSVGURIReference, nsIDOMSVGPatternElement,
+                           nsIDOMSVGUnitTypes, nsIMutationObserver)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGPatternElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGPatternElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGPatternElement::nsSVGPatternElement(nsINodeInfo* aNodeInfo)
   : nsSVGPatternElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGPolygonElement.cpp
+++ b/content/svg/content/src/nsSVGPolygonElement.cpp
@@ -71,21 +71,19 @@ public:
 NS_IMPL_NS_NEW_SVG_ELEMENT(Polygon)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGPolygonElement,nsSVGPolygonElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGPolygonElement,nsSVGPolygonElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGPolygonElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGPolygonElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGPolygonElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGPolygonElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGPolygonElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGPolygonElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGPolygonElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGPolygonElement::nsSVGPolygonElement(nsINodeInfo* aNodeInfo)
   : nsSVGPolygonElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGPolylineElement.cpp
+++ b/content/svg/content/src/nsSVGPolylineElement.cpp
@@ -67,21 +67,19 @@ public:
 NS_IMPL_NS_NEW_SVG_ELEMENT(Polyline)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGPolylineElement,nsSVGPolylineElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGPolylineElement,nsSVGPolylineElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGPolylineElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGPolylineElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGPolylineElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGPolylineElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGPolylineElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGPolylineElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGPolylineElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGPolylineElement::nsSVGPolylineElement(nsINodeInfo* aNodeInfo)
   : nsSVGPolylineElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGRectElement.cpp
+++ b/content/svg/content/src/nsSVGRectElement.cpp
@@ -90,21 +90,19 @@ nsSVGElement::LengthInfo nsSVGRectElemen
 NS_IMPL_NS_NEW_SVG_ELEMENT(Rect)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGRectElement,nsSVGRectElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGRectElement,nsSVGRectElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGRectElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGRectElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGRectElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGRectElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGRectElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGRectElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGRectElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGRectElement::nsSVGRectElement(nsINodeInfo *aNodeInfo)
   : nsSVGRectElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGSVGElement.cpp
+++ b/content/svg/content/src/nsSVGSVGElement.cpp
@@ -89,24 +89,21 @@ nsSVGElement::EnumInfo nsSVGSVGElement::
 NS_IMPL_NS_NEW_SVG_ELEMENT(SVG)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGSVGElement,nsSVGSVGElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGSVGElement,nsSVGSVGElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFitToViewBox)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGLocatable)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGZoomAndPan)
+NS_INTERFACE_TABLE_HEAD(nsSVGSVGElement)
+  NS_NODE_INTERFACE_TABLE7(nsSVGSVGElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGSVGElement,
+                           nsIDOMSVGFitToViewBox, nsIDOMSVGLocatable,
+                           nsIDOMSVGZoomAndPan)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGSVGElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGSVGElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGSVGElement::nsSVGSVGElement(nsINodeInfo* aNodeInfo)
   : nsSVGSVGElementBase(aNodeInfo),
--- a/content/svg/content/src/nsSVGScriptElement.cpp
+++ b/content/svg/content/src/nsSVGScriptElement.cpp
@@ -115,25 +115,21 @@ nsSVGElement::StringInfo nsSVGScriptElem
 NS_IMPL_NS_NEW_SVG_ELEMENT(Script)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGScriptElement,nsSVGScriptElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGScriptElement,nsSVGScriptElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGScriptElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGScriptElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGURIReference)
-  NS_INTERFACE_MAP_ENTRY(nsIScriptLoaderObserver)
-  NS_INTERFACE_MAP_ENTRY(nsIScriptElement)
-  NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
+NS_INTERFACE_TABLE_HEAD(nsSVGScriptElement)
+  NS_NODE_INTERFACE_TABLE8(nsSVGScriptElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGScriptElement,
+                           nsIDOMSVGURIReference, nsIScriptLoaderObserver,
+                           nsIScriptElement, nsIMutationObserver)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGScriptElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGScriptElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGScriptElement::nsSVGScriptElement(nsINodeInfo *aNodeInfo)
   : nsSVGScriptElementBase(aNodeInfo),
--- a/content/svg/content/src/nsSVGStopElement.cpp
+++ b/content/svg/content/src/nsSVGStopElement.cpp
@@ -85,21 +85,19 @@ nsSVGElement::NumberInfo nsSVGStopElemen
 NS_IMPL_NS_NEW_SVG_ELEMENT(Stop)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGStopElement,nsSVGStopElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGStopElement,nsSVGStopElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGStopElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGStopElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGStopElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGStopElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGStopElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGStopElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGStopElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGStopElement::nsSVGStopElement(nsINodeInfo* aNodeInfo)
   : nsSVGStopElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGStyleElement.cpp
+++ b/content/svg/content/src/nsSVGStyleElement.cpp
@@ -118,24 +118,21 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(Style)
 
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGStyleElement,nsSVGStyleElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGStyleElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGStyleElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMLinkStyle)
-  NS_INTERFACE_MAP_ENTRY(nsIStyleSheetLinkingElement)
-  NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
+NS_INTERFACE_TABLE_HEAD(nsSVGStyleElement)
+  NS_NODE_INTERFACE_TABLE7(nsSVGStyleElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGStyleElement,
+                           nsIDOMLinkStyle, nsIStyleSheetLinkingElement,
+                           nsIMutationObserver)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGStyleElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGStyleElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGStyleElement::nsSVGStyleElement(nsINodeInfo *aNodeInfo)
   : nsSVGStyleElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGSwitchElement.cpp
+++ b/content/svg/content/src/nsSVGSwitchElement.cpp
@@ -50,21 +50,19 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(Switch)
 
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGSwitchElement,nsSVGSwitchElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGSwitchElement,nsSVGSwitchElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGSwitchElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGSwitchElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGSwitchElement)
+  NS_NODE_INTERFACE_TABLE4(nsSVGSwitchElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGSwitchElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGSwitchElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGSwitchElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGSwitchElement::nsSVGSwitchElement(nsINodeInfo *aNodeInfo)
   : nsSVGSwitchElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGSymbolElement.cpp
+++ b/content/svg/content/src/nsSVGSymbolElement.cpp
@@ -83,22 +83,20 @@ protected:
 NS_IMPL_NS_NEW_SVG_ELEMENT(Symbol)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGSymbolElement,nsSVGSymbolElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGSymbolElement,nsSVGSymbolElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGSymbolElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGFitToViewBox)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGSymbolElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGSymbolElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGSymbolElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGFitToViewBox,
+                           nsIDOMSVGSymbolElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGSymbolElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGSymbolElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGSymbolElement::nsSVGSymbolElement(nsINodeInfo *aNodeInfo)
   : nsSVGSymbolElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGTSpanElement.cpp
+++ b/content/svg/content/src/nsSVGTSpanElement.cpp
@@ -97,23 +97,21 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(TSpan)
 
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGTSpanElement,nsSVGTSpanElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGTSpanElement,nsSVGTSpanElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGTSpanElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTSpanElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTextPositioningElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTextContentElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGTSpanElement)
+  NS_NODE_INTERFACE_TABLE6(nsSVGTSpanElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGTSpanElement,
+                           nsIDOMSVGTextPositioningElement,
+                           nsIDOMSVGTextContentElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGTSpanElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGTSpanElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGTSpanElement::nsSVGTSpanElement(nsINodeInfo *aNodeInfo)
   : nsSVGTSpanElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGTextElement.cpp
+++ b/content/svg/content/src/nsSVGTextElement.cpp
@@ -95,23 +95,21 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(Text)
 
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGTextElement,nsSVGTextElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGTextElement,nsSVGTextElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGTextElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTextElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTextPositioningElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTextContentElement)
+NS_INTERFACE_TABLE_HEAD(nsSVGTextElement)
+  NS_NODE_INTERFACE_TABLE6(nsSVGTextElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGTextElement,
+                           nsIDOMSVGTextPositioningElement,
+                           nsIDOMSVGTextContentElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGTextElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGTextElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGTextElement::nsSVGTextElement(nsINodeInfo* aNodeInfo)
   : nsSVGTextElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGTextPathElement.cpp
+++ b/content/svg/content/src/nsSVGTextPathElement.cpp
@@ -81,23 +81,20 @@ nsSVGElement::StringInfo nsSVGTextPathEl
 NS_IMPL_NS_NEW_SVG_ELEMENT(TextPath)
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGTextPathElement,nsSVGTextPathElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGTextPathElement,nsSVGTextPathElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGTextPathElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTextPathElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTextContentElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGURIReference)
+NS_INTERFACE_TABLE_HEAD(nsSVGTextPathElement)
+  NS_NODE_INTERFACE_TABLE6(nsSVGTextPathElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGTextPathElement,
+                           nsIDOMSVGTextContentElement, nsIDOMSVGURIReference)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGTextPathElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGTextPathElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGTextPathElement::nsSVGTextPathElement(nsINodeInfo *aNodeInfo)
   : nsSVGTextPathElementBase(aNodeInfo)
--- a/content/svg/content/src/nsSVGTitleElement.cpp
+++ b/content/svg/content/src/nsSVGTitleElement.cpp
@@ -87,22 +87,20 @@ NS_IMPL_NS_NEW_SVG_ELEMENT(Title)
 
 
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ADDREF_INHERITED(nsSVGTitleElement, nsSVGTitleElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGTitleElement, nsSVGTitleElementBase)
 
-NS_INTERFACE_MAP_BEGIN(nsSVGTitleElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGTitleElement)
-  NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
+NS_INTERFACE_TABLE_HEAD(nsSVGTitleElement)
+  NS_NODE_INTERFACE_TABLE5(nsSVGTitleElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGTitleElement,
+                           nsIMutationObserver)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGTitleElement)
 NS_INTERFACE_MAP_END_INHERITING(nsSVGTitleElementBase)
 
 
 //----------------------------------------------------------------------
 // Implementation
 
 nsSVGTitleElement::nsSVGTitleElement(nsINodeInfo *aNodeInfo)
--- a/content/svg/content/src/nsSVGUseElement.cpp
+++ b/content/svg/content/src/nsSVGUseElement.cpp
@@ -77,23 +77,20 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOriginal)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mClone)
   tmp->mSource.Traverse(&cb);
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsSVGUseElement,nsSVGUseElementBase)
 NS_IMPL_RELEASE_INHERITED(nsSVGUseElement,nsSVGUseElementBase)
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsSVGUseElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGURIReference)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMSVGUseElement)
-  NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
+NS_INTERFACE_TABLE_HEAD(nsSVGUseElement)
+  NS_NODE_INTERFACE_TABLE6(nsSVGUseElement, nsIDOMNode, nsIDOMElement,
+                           nsIDOMSVGElement, nsIDOMSVGURIReference,
+                           nsIDOMSVGUseElement, nsIMutationObserver)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(SVGUseElement)
   if (aIID.Equals(NS_GET_IID(nsSVGUseElement)))
     foundInterface = reinterpret_cast<nsISupports*>(this);
   else
 NS_INTERFACE_MAP_END_INHERITING(nsSVGUseElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
--- a/content/xbl/src/nsBindingManager.cpp
+++ b/content/xbl/src/nsBindingManager.cpp
@@ -132,21 +132,23 @@ nsAnonymousContentList::~nsAnonymousCont
   delete mElements;
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsAnonymousContentList)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsAnonymousContentList)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsAnonymousContentList)
 
-NS_INTERFACE_MAP_BEGIN(nsAnonymousContentList)
-  NS_INTERFACE_MAP_ENTRY(nsINodeList)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNodeList)
-  NS_INTERFACE_MAP_ENTRY(nsAnonymousContentList)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsINodeList)
+NS_INTERFACE_TABLE_HEAD(nsAnonymousContentList)
+  NS_NODELIST_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsAnonymousContentList)
+    NS_INTERFACE_TABLE_ENTRY(nsAnonymousContentList, nsINodeList)
+    NS_INTERFACE_TABLE_ENTRY(nsAnonymousContentList, nsIDOMNodeList)
+    NS_INTERFACE_TABLE_ENTRY(nsAnonymousContentList, nsAnonymousContentList)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(NodeList)
   NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsAnonymousContentList)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_0(nsAnonymousContentList)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsAnonymousContentList)
   {
     PRInt32 i, count = tmp->mElements->Length();
--- a/content/xml/content/src/nsXMLCDATASection.cpp
+++ b/content/xml/content/src/nsXMLCDATASection.cpp
@@ -102,22 +102,20 @@ nsXMLCDATASection::nsXMLCDATASection(nsI
 }
 
 nsXMLCDATASection::~nsXMLCDATASection()
 {
 }
 
 
 // QueryInterface implementation for nsXMLCDATASection
-NS_INTERFACE_MAP_BEGIN(nsXMLCDATASection)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCharacterData)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMText)
+NS_INTERFACE_TABLE_HEAD(nsXMLCDATASection)
+  NS_NODE_INTERFACE_TABLE4(nsXMLCDATASection, nsIDOMNode, nsIDOMCharacterData,
+                           nsIDOMText, nsIDOMCDATASection)
   NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Text, new nsText3Tearoff(this))
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCDATASection)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(CDATASection)
 NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode)
 
 NS_IMPL_ADDREF_INHERITED(nsXMLCDATASection, nsGenericDOMDataNode)
 NS_IMPL_RELEASE_INHERITED(nsXMLCDATASection, nsGenericDOMDataNode)
 
 
 PRBool
--- a/content/xml/content/src/nsXMLElement.cpp
+++ b/content/xml/content/src/nsXMLElement.cpp
@@ -59,45 +59,24 @@ NS_NewXMLElement(nsIContent** aInstanceP
 
 nsXMLElement::nsXMLElement(nsINodeInfo *aNodeInfo)
   : nsGenericElement(aNodeInfo)
 {
 }
 
 
 // QueryInterface implementation for nsXMLElement
-NS_IMETHODIMP 
-nsXMLElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
-{
-  NS_PRECONDITION(aInstancePtr, "null out param");
-
-  nsresult rv = nsGenericElement::QueryInterface(aIID, aInstancePtr);
-
-  if (NS_SUCCEEDED(rv))
-    return rv;
-
-  nsISupports *inst = nsnull;
-
-  if (aIID.Equals(NS_GET_IID(nsIDOMNode))) {
-    inst = static_cast<nsIDOMNode *>(this);
-  } else if (aIID.Equals(NS_GET_IID(nsIDOMElement))) {
-    inst = static_cast<nsIDOMElement *>(this);
-  } else if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
-    inst = NS_GetDOMClassInfoInstance(eDOMClassInfo_Element_id);
-    NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
-  } else {
-    return PostQueryInterface(aIID, aInstancePtr);
-  }
-
-  NS_ADDREF(inst);
-
-  *aInstancePtr = inst;
-
-  return NS_OK;
-}
+NS_INTERFACE_TABLE_HEAD(nsXMLElement)
+  NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsXMLElement)
+    NS_INTERFACE_TABLE_ENTRY(nsXMLElement, nsIDOMNode)
+    NS_INTERFACE_TABLE_ENTRY(nsXMLElement, nsIDOMElement)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_ELEMENT_INTERFACE_TABLE_TO_MAP_SEGUE
+  NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(Element)
+NS_ELEMENT_INTERFACE_MAP_END
 
 
 NS_IMPL_ADDREF_INHERITED(nsXMLElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsXMLElement, nsGenericElement)
 
 
 static nsresult
 DocShellToPresContext(nsIDocShell *aShell, nsPresContext **aPresContext)
--- a/content/xml/content/src/nsXMLProcessingInstruction.cpp
+++ b/content/xml/content/src/nsXMLProcessingInstruction.cpp
@@ -85,19 +85,23 @@ nsXMLProcessingInstruction::nsXMLProcess
 }
 
 nsXMLProcessingInstruction::~nsXMLProcessingInstruction()
 {
 }
 
 
 // QueryInterface implementation for nsXMLProcessingInstruction
-NS_INTERFACE_MAP_BEGIN(nsXMLProcessingInstruction)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMProcessingInstruction)
+NS_INTERFACE_TABLE_HEAD(nsXMLProcessingInstruction)
+  NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsXMLProcessingInstruction)
+    NS_INTERFACE_TABLE_ENTRY(nsXMLProcessingInstruction, nsIDOMNode)
+    NS_INTERFACE_TABLE_ENTRY(nsXMLProcessingInstruction,
+                             nsIDOMProcessingInstruction)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(ProcessingInstruction)
 NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode)
 
 
 NS_IMPL_ADDREF_INHERITED(nsXMLProcessingInstruction, nsGenericDOMDataNode)
 NS_IMPL_RELEASE_INHERITED(nsXMLProcessingInstruction, nsGenericDOMDataNode)
 
 
--- a/content/xml/content/src/nsXMLStylesheetPI.cpp
+++ b/content/xml/content/src/nsXMLStylesheetPI.cpp
@@ -84,19 +84,20 @@ protected:
                          nsAString& aMedia,
                          PRBool* aIsAlternate);
   virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo,
                                               PRBool aCloneText) const;
 };
 
 // nsISupports implementation
 
-NS_INTERFACE_MAP_BEGIN(nsXMLStylesheetPI)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMLinkStyle)
-  NS_INTERFACE_MAP_ENTRY(nsIStyleSheetLinkingElement)
+NS_INTERFACE_TABLE_HEAD(nsXMLStylesheetPI)
+  NS_NODE_INTERFACE_TABLE4(nsXMLStylesheetPI, nsIDOMNode,
+                           nsIDOMProcessingInstruction, nsIDOMLinkStyle,
+                           nsIStyleSheetLinkingElement)
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(XMLStylesheetProcessingInstruction)
 NS_INTERFACE_MAP_END_INHERITING(nsXMLProcessingInstruction)
 
 NS_IMPL_ADDREF_INHERITED(nsXMLStylesheetPI, nsXMLProcessingInstruction)
 NS_IMPL_RELEASE_INHERITED(nsXMLStylesheetPI, nsXMLProcessingInstruction)
 
 
 nsXMLStylesheetPI::nsXMLStylesheetPI(nsINodeInfo *aNodeInfo,
--- a/content/xml/document/src/nsXMLDocument.cpp
+++ b/content/xml/document/src/nsXMLDocument.cpp
@@ -230,21 +230,22 @@ nsXMLDocument::nsXMLDocument(const char*
 nsXMLDocument::~nsXMLDocument()
 {
   // XXX We rather crash than hang
   mLoopingForSyncLoad = PR_FALSE;
 }
 
 // QueryInterface implementation for nsXMLDocument
 NS_INTERFACE_TABLE_HEAD(nsXMLDocument)
-  NS_INTERFACE_TABLE_INHERITED3(nsXMLDocument,
-                                nsIInterfaceRequestor,
-                                nsIChannelEventSink,
-                                nsIDOMXMLDocument)
-  NS_INTERFACE_TABLE_TO_MAP_SEGUE
+  NS_DOCUMENT_INTERFACE_TABLE_BEGIN(nsXMLDocument)
+    NS_INTERFACE_TABLE_ENTRY(nsXMLDocument, nsIInterfaceRequestor)
+    NS_INTERFACE_TABLE_ENTRY(nsXMLDocument, nsIChannelEventSink)
+    NS_INTERFACE_TABLE_ENTRY(nsXMLDocument, nsIDOMXMLDocument)
+  NS_OFFSET_AND_INTERFACE_TABLE_END
+  NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
   NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(XMLDocument)
 NS_INTERFACE_MAP_END_INHERITING(nsDocument)
 
 
 NS_IMPL_ADDREF_INHERITED(nsXMLDocument, nsDocument)
 NS_IMPL_RELEASE_INHERITED(nsXMLDocument, nsDocument)
 
 
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -369,61 +369,31 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
     }
     NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mPrototype,
                                                     nsXULPrototypeElement)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ADDREF_INHERITED(nsXULElement, nsGenericElement)
 NS_IMPL_RELEASE_INHERITED(nsXULElement, nsGenericElement)
 
-NS_IMETHODIMP
-nsXULElement::QueryInterface(REFNSIID aIID, void** aInstancePtr)
-{
-    NS_PRECONDITION(aInstancePtr, "null out param");
-
-    if (aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant))) {
-      *aInstancePtr = &NS_CYCLE_COLLECTION_NAME(nsXULElement);
-      return NS_OK;
-    }
-
-    nsresult rv = nsGenericElement::QueryInterface(aIID, aInstancePtr);
-    if (NS_SUCCEEDED(rv))
-        return rv;
-
-    nsISupports *inst = nsnull;
-
-    if (aIID.Equals(NS_GET_IID(nsIDOMNode))) {
-        inst = static_cast<nsIDOMNode *>(this);
-    } else if (aIID.Equals(NS_GET_IID(nsIDOMElement))) {
-        inst = static_cast<nsIDOMElement *>(this);
-    } else if (aIID.Equals(NS_GET_IID(nsIDOMXULElement))) {
-        inst = static_cast<nsIDOMXULElement *>(this);
-    } else if (aIID.Equals(NS_GET_IID(nsIScriptEventHandlerOwner))) {
-        inst = static_cast<nsIScriptEventHandlerOwner*>
-                          (new nsScriptEventHandlerOwnerTearoff(this));
-        NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
-    } else if (aIID.Equals(NS_GET_IID(nsIDOMElementCSSInlineStyle))) {
-        inst = static_cast<nsIDOMElementCSSInlineStyle *>
-                          (new nsXULElementTearoff(this));
-        NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
-    } else if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
-        inst = NS_GetDOMClassInfoInstance(eDOMClassInfo_XULElement_id);
-        NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
-    } else if (aIID.Equals(NS_GET_IID(nsIFrameLoaderOwner))) {
-        inst = static_cast<nsIFrameLoaderOwner*>(new nsXULElementTearoff(this));
-        NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);
-    } else {
-        return PostQueryInterface(aIID, aInstancePtr);
-    }
-
-    NS_ADDREF(inst);
- 
-    *aInstancePtr = inst;
-    return NS_OK;
-}
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsXULElement)
+    NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsXULElement)
+        NS_INTERFACE_TABLE_ENTRY(nsXULElement, nsIDOMNode)
+        NS_INTERFACE_TABLE_ENTRY(nsXULElement, nsIDOMElement)
+        NS_INTERFACE_TABLE_ENTRY(nsXULElement, nsIDOMXULElement)
+    NS_OFFSET_AND_INTERFACE_TABLE_END
+    NS_ELEMENT_INTERFACE_TABLE_TO_MAP_SEGUE
+    NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIScriptEventHandlerOwner,
+                                   new nsScriptEventHandlerOwnerTearoff(this))
+    NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMElementCSSInlineStyle,
+                                   new nsXULElementTearoff(this))
+    NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIFrameLoaderOwner,
+                                   new nsXULElementTearoff(this))
+    NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(XULElement)
+NS_ELEMENT_INTERFACE_MAP_END
 
 //----------------------------------------------------------------------
 // nsIDOMNode interface
 
 nsresult
 nsXULElement::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
 {
     *aResult = nsnull;
--- a/content/xul/document/src/nsXULDocument.cpp
+++ b/content/xul/document/src/nsXULDocument.cpp
@@ -372,22 +372,23 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_IN
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_ADDREF_INHERITED(nsXULDocument, nsXMLDocument)
 NS_IMPL_RELEASE_INHERITED(nsXULDocument, nsXMLDocument)
 
 
 // QueryInterface implementation for nsXULDocument
 NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsXULDocument)
-    NS_INTERFACE_TABLE_INHERITED4(nsXULDocument,
-                                  nsIXULDocument,
-                                  nsIDOMXULDocument,
-                                  nsIStreamLoaderObserver,
-                                  nsICSSLoaderObserver)
-    NS_INTERFACE_TABLE_TO_MAP_SEGUE
+    NS_DOCUMENT_INTERFACE_TABLE_BEGIN(nsXULDocument)
+      NS_INTERFACE_TABLE_ENTRY(nsXULDocument, nsIXULDocument)
+      NS_INTERFACE_TABLE_ENTRY(nsXULDocument, nsIDOMXULDocument)
+      NS_INTERFACE_TABLE_ENTRY(nsXULDocument, nsIStreamLoaderObserver)
+      NS_INTERFACE_TABLE_ENTRY(nsXULDocument, nsICSSLoaderObserver)
+    NS_OFFSET_AND_INTERFACE_TABLE_END
+    NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
     NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(XULDocument)
 NS_INTERFACE_MAP_END_INHERITING(nsXMLDocument)
 
 
 //----------------------------------------------------------------------
 //
 // nsIDocument interface
 //
--- a/js/src/xpconnect/src/qsgen.py
+++ b/js/src/xpconnect/src/qsgen.py
@@ -110,19 +110,16 @@
 #   for an XPCOM object of the desired "proto".  For details, see the parts of
 #   XPCWrappedNative::GetWrappedNativeOfJSObject that use "proto".  Some quick
 #   stubs (methods, not getters or setters, that have XPCCallContexts) do this,
 #   but most instead look for an XPCOM object that supports the desired
 #   *interface*.  This is more lenient.  The difference is observable in some
 #   cases where a getter/setter/method is taken from one object and applied to
 #   another object.
 #
-#   Another notable difference in this area: Quick stubs don't support split
-#   objects.
-#
 # - Quick stubs never suspend the JS request.  So they are only suitable for
 #   main-thread-only interfaces.
 #
 # - Quick stubs don't call XPCContext::SetLastResult.  This is visible on the
 #   Components object.
 #
 # - Quick stubs skip a security check that XPConnect does in
 #   XPCWrappedNative::CallMethod.  This means the security manager doesn't have
@@ -348,64 +345,76 @@ def substitute(template, vals):
     def replacement(match):
         return vals[match.group(1)]
     return re.sub(r'\${(\w+)}', replacement, template)
 
 # From JSData2Native.
 argumentUnboxingTemplates = {
     'short':
         "    int32 ${name}_i32;\n"
-        "    if (!JS_ValueToECMAInt32(cx, ${argVal}, &${name}_i32)) ${failBlock}\n"
+        "    if (!JS_ValueToECMAInt32(cx, ${argVal}, &${name}_i32))\n"
+        "        return JS_FALSE;\n"
         "    int16 ${name} = (int16) ${name}_i32;\n",
 
     'unsigned short':
         "    uint32 ${name}_u32;\n"
-        "    if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}_u32)) ${failBlock}\n"
+        "    if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}_u32))\n"
+        "        return JS_FALSE;\n"
         "    uint16 ${name} = (uint16) ${name}_u32;\n",
 
     'long':
         "    int32 ${name};\n"
-        "    if (!JS_ValueToECMAInt32(cx, ${argVal}, &${name})) ${failBlock}\n",
+        "    if (!JS_ValueToECMAInt32(cx, ${argVal}, &${name}))\n"
+        "        return JS_FALSE;\n",
 
     'unsigned long':
         "    uint32 ${name};\n"
-        "    if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name})) ${failBlock}\n",
+        "    if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}))\n"
+        "        return JS_FALSE;\n",
 
     'float':
         "    jsdouble ${name}_dbl;\n"
-        "    if (!JS_ValueToNumber(cx, ${argVal}, &${name}_dbl)) ${failBlock}\n"
+        "    if (!JS_ValueToNumber(cx, ${argVal}, &${name}_dbl))\n"
+        "        return JS_FALSE;\n"
         "    float ${name} = (float) ${name}_dbl;\n",
 
     'double':
         "    jsdouble ${name};\n"
-        "    if (!JS_ValueToNumber(cx, ${argVal}, &${name})) ${failBlock}\n",
+        "    if (!JS_ValueToNumber(cx, ${argVal}, &${name}))\n"
+        "        return JS_FALSE;\n",
 
     'boolean':
         "    PRBool ${name};\n"
-        "    if (!JS_ValueToBoolean(cx, ${argVal}, &${name})) ${failBlock}\n",
+        "    if (!JS_ValueToBoolean(cx, ${argVal}, &${name}))\n"
+        "        return JS_FALSE;\n",
 
     '[astring]':
         "    xpc_qsAString ${name}(cx, ${argPtr});\n"
-        "    if (!${name}.IsValid()) ${failBlock}\n",
+        "    if (!${name}.IsValid())\n"
+        "        return JS_FALSE;\n",
 
     '[domstring]':
         "    xpc_qsDOMString ${name}(cx, ${argPtr});\n"
-        "    if (!${name}.IsValid()) ${failBlock}\n",
+        "    if (!${name}.IsValid())\n"
+        "        return JS_FALSE;\n",
 
     'string':
         "    char *${name};\n"
-        "    if (!xpc_qsJsvalToCharStr(cx, ${argPtr}, &${name})) ${failBlock}\n",
+        "    if (!xpc_qsJsvalToCharStr(cx, ${argPtr}, &${name}))\n"
+        "        return JS_FALSE;\n",
 
     'wstring':
         "    PRUnichar *${name};\n"
-        "    if (!xpc_qsJsvalToWcharStr(cx, ${argPtr}, &${name})) ${failBlock}\n",
+        "    if (!xpc_qsJsvalToWcharStr(cx, ${argPtr}, &${name}))\n"
+        "        return JS_FALSE;\n",
 
     '[cstring]':
         "    xpc_qsACString ${name}(cx, ${argPtr});\n"
-        "    if (!${name}.IsValid()) ${failBlock}\n"
+        "    if (!${name}.IsValid())\n"
+        "        return JS_FALSE;\n"
     }
 
 # From JSData2Native.
 #
 # Omitted optional arguments are treated as though the caller had passed JS
 # `null`; this behavior is from XPCWrappedNative::CallMethod.
 #
 def writeArgumentUnboxing(f, i, name, type, haveCcx, optional):
@@ -415,36 +424,30 @@ def writeArgumentUnboxing(f, i, name, ty
     #     which can only happen if optional is True, the argument is missing;
     #     use JSVAL_NULL as the source jsval instead.
     # name - str - name of the native C++ variable to create.
     # type - xpidl.{Interface,Native,Builtin} - IDL type of argument
     # optional - bool - True if the parameter is optional.
 
     isSetter = (i is None)
 
-    # Spell this out each time rather than use a goto.  The most common methods
-    # only have one parameter, and in that case the goto looks silly.
-    fail = ("        NS_RELEASE(self);\n"
-            "        return JS_FALSE;\n")
-
     if isSetter:
         argPtr = "vp"
         argVal = "*vp"
     elif optional:
         argPtr = '!  /* TODO - optional parameter of this type not supported */'
         argVal = "(%d < argc ? argv[%d] : JSVAL_NULL)" % (i, i)
     else:
         argVal = "argv[%d]" % i
         argPtr = "&" + argVal
 
     params = {
         'name': name,
         'argVal': argVal,
-        'argPtr': argPtr,
-        'failBlock': '{\n' + fail + '    }'
+        'argPtr': argPtr
         }
 
     typeName = getBuiltinOrNativeTypeName(type)
     if typeName is not None:
         template = argumentUnboxingTemplates.get(typeName)
         if template is not None:
             if optional and ("${argPtr}" in template):
                 warn("Optional parameters of type %s are not supported."
@@ -454,38 +457,38 @@ def writeArgumentUnboxing(f, i, name, ty
         # else fall through; the type isn't supported yet.
     elif isInterfaceType(type):
         if type.name == 'nsIVariant':
             # Totally custom.
             assert haveCcx
             template = (
                 "    nsCOMPtr<nsIVariant> ${name}(already_AddRefed<nsIVariant>("
                 "XPCVariant::newVariant(ccx, ${argVal})));\n"
-                "    if (!${name}) ${failBlock}\n")
+                "    if (!${name})\n"
+                "        return JS_FALSE;\n")
             f.write(substitute(template, params))
             return
         elif type.name == 'nsIAtom':
             # Should have special atomizing behavior.  Fall through.
             pass
         else:
             f.write("    nsCOMPtr<%s> %s;\n" % (type.name, name))
             f.write("    rv = xpc_qsUnwrapArg<%s>("
                     "cx, %s, getter_AddRefs(%s));\n"
                     % (type.name, argVal, name))
             f.write("    if (NS_FAILED(rv)) {\n")
             if isSetter:
                 f.write("        xpc_qsThrowBadSetterValue("
-                        "cx, rv, wrapper, id);\n")
+                        "cx, rv, JSVAL_TO_OBJECT(*tvr.addr()), id);\n")
             elif haveCcx:
                 f.write("        xpc_qsThrowBadArgWithCcx(ccx, rv, %d);\n" % i)
             else:
-                f.write("        xpc_qsThrowBadArg(cx, rv, wrapper, vp, %d);\n"
-                        % i)
-            f.write(fail);
-            f.write("    }\n")
+                f.write("        xpc_qsThrowBadArg(cx, rv, vp, %d);\n" % i)
+            f.write("        return JS_FALSE;\n"
+                    "    }\n")
             return
 
     warn("Unable to unbox argument of type %s" % type.name)
     if i is None:
         src = '*vp'
     else:
         src = 'argv[%d]' % i
     f.write("    !; // TODO - Unbox argument %s = %s\n" % (name, src))
@@ -647,38 +650,47 @@ def writeQuickStub(f, member, stubName, 
         # In some cases we emit a ccx, but it does not count as
         # "haveCcx" because it's not complete.
         if isAttr and isInterfaceType(member.realtype):
             f.write("    XPCCallContext ccx(JS_CALLER, cx, obj);\n")
 
     # Get the 'self' pointer.
     thisType = member.iface.name
     f.write("    %s *self;\n" % thisType)
+    f.write("    xpc_qsSelfRef selfref;\n")
     # Don't use FromCcx for getters or setters; the way we construct the ccx in
     # a getter/setter causes it to find the wrong wrapper in some cases.
     if isMethod and haveCcx:
-        f.write("    if (!xpc_qsUnwrapThisFromCcx(ccx, &self))\n"
-                "        return JS_FALSE;\n")
+        # Undocumented, but the interpreter puts 'this' at argv[-1],
+        # which is vp[1]; and it's ok to overwrite it.
+        f.write("    if (!xpc_qsUnwrapThisFromCcx(ccx, &self, &selfref.ptr, "
+                "&vp[1]))\n")
+        f.write("        return JS_FALSE;\n")
     else:
-        # 'wrapper' is needed only for error messages.
-        f.write("    XPCWrappedNative *wrapper;\n"
-                "    if (!xpc_qsUnwrapThis(cx, obj, &self, &wrapper))\n"
-                "        return JS_FALSE;\n")
+        if isGetter:
+            pthisval = 'vp'
+        elif isSetter:
+            f.write("    xpc_qsTempRoot tvr(cx);\n")
+            pthisval = 'tvr.addr()'
+        else:
+            pthisval = '&vp[1]' # as above, ok to overwrite vp[1]
+
+        f.write("    if (!xpc_qsUnwrapThis(cx, obj, &self, &selfref.ptr, "
+                "%s))\n" % pthisval)
+        f.write("        return JS_FALSE;\n")
 
     if isMethod:
         # If there are any required arguments, check argc.
         requiredArgs = len(member.params)
         while requiredArgs and member.params[requiredArgs-1].optional:
             requiredArgs -= 1
         if requiredArgs:
-            f.write("    if (argc < %d) {\n" % requiredArgs)
-            f.write("        NS_RELEASE(self);\n"
-                    "        return xpc_qsThrow(cx, "
-                    "NS_ERROR_XPC_NOT_ENOUGH_ARGS);\n"
-                    "    }\n")
+            f.write("    if (argc < %d)\n" % requiredArgs)
+            f.write("        return xpc_qsThrow(cx, "
+                    "NS_ERROR_XPC_NOT_ENOUGH_ARGS);\n")
 
     def pfail(msg):
         raise UserError(
             member.iface.name + '.' + member.name + ": "
             "parameter " + param.name + ": " + msg)
 
     # Convert in-parameters.
     f.write("    nsresult rv;\n")
@@ -718,37 +730,40 @@ def writeQuickStub(f, member, stubName, 
         args = ', '.join(argv)
     else:
         comName = header.attributeNativeName(member, isGetter)
         if isGetter:
             args = outParamForm("result", member.realtype)
         else:
             args = "arg0"
     f.write("    rv = self->%s(%s);\n" % (comName, args))
-    f.write("    NS_RELEASE(self);\n")
 
     # Check for errors.
     f.write("    if (NS_FAILED(rv))\n")
     if isMethod:
         if haveCcx:
             f.write("        return xpc_qsThrowMethodFailedWithCcx(ccx, rv);\n")
         else:
             f.write("        return xpc_qsThrowMethodFailed("
-                    "cx, rv, wrapper, vp);\n")
+                    "cx, rv, vp);\n")
     else:
-        f.write("        return xpc_qsThrowGetterSetterFailed("
-                "cx, rv, wrapper, id);\n")
+        if isGetter:
+            thisval = '*vp'
+        else:
+            thisval = '*tvr.addr()'
+        f.write("        return xpc_qsThrowGetterSetterFailed(cx, rv, " +
+                "JSVAL_TO_OBJECT(%s), id);\n" % thisval)
 
     # Convert the return value.
     if isMethod:
         writeResultConv(f, member.realtype, len(member.params) + 1, 'vp', '*vp')
     elif isGetter:
         writeResultConv(f, member.realtype, None, 'vp', '*vp')
     else:
-        f.write("    return JS_TRUE;\n");
+        f.write("    return JS_TRUE;\n")
 
     # Epilog.
     f.write("}\n\n")
 
 def writeAttrStubs(f, attr):
     getterName = (attr.iface.name + '_'
                   + header.attributeNativeName(attr, True))
     writeQuickStub(f, attr, getterName)
@@ -895,16 +910,17 @@ def writeDefiner(f, conf, interfaces):
     f.write("    return xpc_qsDefineQuickStubs("
             "cx, proto, flags, count, iids, %d, tableData);\n" % size)
     f.write("}\n\n\n")
 
 
 stubTopTemplate = '''\
 /* THIS FILE IS AUTOGENERATED - DO NOT EDIT */
 #include "jsapi.h"
+#include "jscntxt.h"
 #include "prtypes.h"
 #include "nsID.h"
 #include "%s"
 #include "nscore.h"
 #include "nsCOMPtr.h"
 #include "nsDependentString.h"
 #include "xpcprivate.h"  // for XPCCallContext
 #include "xpcquickstubs.h"
--- a/js/src/xpconnect/src/xpcprivate.h
+++ b/js/src/xpconnect/src/xpcprivate.h
@@ -1848,26 +1848,29 @@ private:
     nsCOMPtr<nsIXPCScriptable>  mCallback;
     XPCNativeScriptableFlags    mFlags;
 };
 
 /***********************************************/
 // XPCWrappedNativeProto hold the additional (potentially shared) wrapper data
 // for XPCWrappedNative whose native objects expose nsIClassInfo.
 
+#define UNKNOWN_OFFSETS ((QITableEntry*)1)
+
 class XPCWrappedNativeProto
 {
 public:
     static XPCWrappedNativeProto*
     GetNewOrUsed(XPCCallContext& ccx,
                  XPCWrappedNativeScope* Scope,
                  nsIClassInfo* ClassInfo,
                  const XPCNativeScriptableCreateInfo* ScriptableCreateInfo,
                  JSBool ForceNoSharing,
-                 JSBool isGlobal);
+                 JSBool isGlobal,
+                 QITableEntry* offsets = UNKNOWN_OFFSETS);
 
     XPCWrappedNativeScope*
     GetScope()   const {return mScope;}
 
     XPCJSRuntime*
     GetRuntime() const {return mScope->GetRuntime();}
 
     JSObject*
@@ -1883,16 +1886,55 @@ public:
     GetScriptableInfo()   {return mScriptableInfo;}
 
     void**
     GetSecurityInfoAddr() {return &mSecurityInfo;}
 
     JSUint32
     GetClassInfoFlags() const {return mClassInfoFlags;}
 
+    QITableEntry*
+    GetOffsets()
+    {
+        return InitedOffsets() ? mOffsets : nsnull;
+    }
+    QITableEntry*
+    GetOffsetsMasked()
+    {
+        return mOffsets;
+    }
+    void
+    CacheOffsets(nsISupports* identity)
+    {
+        static NS_DEFINE_IID(kThisPtrOffsetsSID, NS_THISPTROFFSETS_SID);
+
+#ifdef DEBUG
+        if(InitedOffsets() && mOffsets)
+        {
+            QITableEntry* offsets;
+            identity->QueryInterface(kThisPtrOffsetsSID, (void**)&offsets);
+            NS_ASSERTION(offsets == mOffsets,
+                         "We can't deal with objects that have the same "
+                         "classinfo but different offset tables.");
+        }
+#endif
+
+        if(!InitedOffsets())
+        {
+            if(mClassInfoFlags & nsIClassInfo::CONTENT_NODE)
+            {
+                identity->QueryInterface(kThisPtrOffsetsSID, (void**)&mOffsets);
+            }
+            else
+            {
+                mOffsets = nsnull;
+            }
+        }
+    }
+
 #ifdef GET_IT
 #undef GET_IT
 #endif
 #define GET_IT(f_) const {return !!(mClassInfoFlags & nsIClassInfo:: f_ );}
 
     JSBool ClassIsSingleton()           GET_IT(SINGLETON)
     JSBool ClassIsThreadSafe()          GET_IT(THREADSAFE)
     JSBool ClassIsMainThreadOnly()      GET_IT(MAIN_THREAD_ONLY)
@@ -1947,34 +1989,42 @@ protected:
     // disable copy ctor and assignment
     XPCWrappedNativeProto(const XPCWrappedNativeProto& r); // not implemented
     XPCWrappedNativeProto& operator= (const XPCWrappedNativeProto& r); // not implemented
 
     // hide ctor
     XPCWrappedNativeProto(XPCWrappedNativeScope* Scope,
                           nsIClassInfo* ClassInfo,
                           PRUint32 ClassInfoFlags,
-                          XPCNativeSet* Set);
+                          XPCNativeSet* Set,
+                          QITableEntry* offsets);
 
     JSBool Init(XPCCallContext& ccx, JSBool isGlobal,
                 const XPCNativeScriptableCreateInfo* scriptableCreateInfo);
 
 private:
 #if defined(DEBUG_xpc_hacker) || defined(DEBUG)
     static PRInt32 gDEBUG_LiveProtoCount;
 #endif
 
 private:
+    PRBool
+    InitedOffsets()
+    {
+        return mOffsets != UNKNOWN_OFFSETS;
+    }
+
     XPCWrappedNativeScope*   mScope;
     JSObject*                mJSProtoObject;
     nsCOMPtr<nsIClassInfo>   mClassInfo;
     PRUint32                 mClassInfoFlags;
     XPCNativeSet*            mSet;
     void*                    mSecurityInfo;
     XPCNativeScriptableInfo* mScriptableInfo;
+    QITableEntry*            mOffsets;
 };
 
 
 /***********************************************/
 // XPCWrappedNativeTearOff represents the info needed to make calls to one
 // interface on the underlying native object of a XPCWrappedNative.
 
 class XPCWrappedNativeTearOff
@@ -2310,16 +2360,31 @@ public:
 
     JSBool HasExternalReference() const {return mRefCnt > 1;}
 
     JSObject* GetWrapper()              { return mWrapper; }
     void      SetWrapper(JSObject *obj) { mWrapper = obj; }
 
     void NoteTearoffs(nsCycleCollectionTraversalCallback& cb);
 
+    QITableEntry* GetOffsets()
+    {
+        if(!HasProto() || !GetProto()->ClassIsDOMObject())
+            return nsnull;
+
+        XPCWrappedNativeProto* proto = GetProto();
+        QITableEntry* offsets = proto->GetOffsets();
+        if(!offsets)
+        {
+            static NS_DEFINE_IID(kThisPtrOffsetsSID, NS_THISPTROFFSETS_SID);
+            mIdentity->QueryInterface(kThisPtrOffsetsSID, (void**)&offsets);
+        }
+        return offsets;
+    }
+
     // Make ctor and dtor protected (rather than private) to placate nsCOMPtr.
 protected:
     XPCWrappedNative(); // not implemented
 
     // This ctor is used if this object will have a proto.
     XPCWrappedNative(nsISupports* aIdentity,
                      XPCWrappedNativeProto* aProto);
 
--- a/js/src/xpconnect/src/xpcquickstubs.cpp
+++ b/js/src/xpconnect/src/xpcquickstubs.cpp
@@ -173,27 +173,32 @@ xpc_qsThrow(JSContext *cx, nsresult rv)
  *
  * We could instead have each quick stub pass its name to the error-handling
  * functions, as that name is statically known.  But that would be redundant;
  * the information is handy at runtime anyway.  Also, this code often produces
  * a more specific error message, e.g. "[nsIDOMHTMLDocument.appendChild]"
  * rather than "[nsIDOMNode.appendChild]".
  */
 static void
-GetMemberInfo(XPCWrappedNative *wrapper,
+GetMemberInfo(JSObject *obj,
               jsval memberId,
               const char **ifaceName,
               const char **memberName)
 {
     // Get the interface name.  From DefinePropertyIfFound (in
     // xpcwrappednativejsops.cpp) and XPCThrower::Verbosify.
     //
     // We could instead make the quick stub could pass in its interface name,
     // but this code often produces a more specific error message, e.g.
     *ifaceName = "Unknown";
+
+    NS_ASSERTION(IS_WRAPPER_CLASS(STOBJ_GET_CLASS(obj)) ||
+                 STOBJ_GET_CLASS(obj) == &XPC_WN_Tearoff_JSClass,
+                 "obj must be an XPCWrappedNative");
+    XPCWrappedNative *wrapper = (XPCWrappedNative *) STOBJ_GET_PRIVATE(obj);
     XPCWrappedNativeProto *proto = wrapper->GetProto();
     if(proto)
     {
         XPCNativeSet *set = proto->GetSet();
         if(set)
         {
             XPCNativeMember *member;
             XPCNativeInterface *iface;
@@ -205,28 +210,27 @@ GetMemberInfo(XPCWrappedNative *wrapper,
 
     *memberName = (JSVAL_IS_STRING(memberId)
                    ? JS_GetStringBytes(JSVAL_TO_STRING(memberId))
                    : "unknown");
 }
 
 static void
 GetMethodInfo(JSContext *cx,
-              XPCWrappedNative *wrapper,
               jsval *vp,
               const char **ifaceName,
               const char **memberName)
 {
     JSObject *funobj = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
     NS_ASSERTION(JS_ObjectIsFunction(cx, funobj),
                  "JSFastNative callee should be Function object");
     JSString *str = JS_GetFunctionId((JSFunction *) JS_GetPrivate(cx, funobj));
     jsval methodId = str ? STRING_TO_JSVAL(str) : JSVAL_NULL;
 
-    GetMemberInfo(wrapper, methodId, ifaceName, memberName);
+    GetMemberInfo(JSVAL_TO_OBJECT(vp[1]), methodId, ifaceName, memberName);
 }
 
 static JSBool
 ThrowCallFailed(JSContext *cx, nsresult rv,
                 const char *ifaceName, const char *memberName)
 {
     // From XPCThrower::ThrowBadResult.
     char* sz;
@@ -267,30 +271,29 @@ ThrowCallFailed(JSContext *cx, nsresult 
 
     if(sz)
         JS_smprintf_free(sz);
 
     return JS_FALSE;
 }
 
 JSBool
-xpc_qsThrowGetterSetterFailed(JSContext *cx, nsresult rv,
-                              XPCWrappedNative *wrapper, jsval memberId)
+xpc_qsThrowGetterSetterFailed(JSContext *cx, nsresult rv, JSObject *obj,
+                              jsval memberId)
 {
     const char *ifaceName, *memberName;
-    GetMemberInfo(wrapper, memberId, &ifaceName, &memberName);
+    GetMemberInfo(obj, memberId, &ifaceName, &memberName);
     return ThrowCallFailed(cx, rv, ifaceName, memberName);
 }
 
 JSBool
-xpc_qsThrowMethodFailed(JSContext *cx, nsresult rv,
-                        XPCWrappedNative *wrapper, jsval *vp)
+xpc_qsThrowMethodFailed(JSContext *cx, nsresult rv, jsval *vp)
 {
     const char *ifaceName, *memberName;
-    GetMethodInfo(cx, wrapper, vp, &ifaceName, &memberName);
+    GetMethodInfo(cx, vp, &ifaceName, &memberName);
     return ThrowCallFailed(cx, rv, ifaceName, memberName);
 }
 
 JSBool
 xpc_qsThrowMethodFailedWithCcx(XPCCallContext &ccx, nsresult rv)
 {
     ThrowBadResult(rv, ccx);
     return JS_FALSE;
@@ -312,36 +315,35 @@ ThrowBadArg(JSContext *cx, nsresult rv,
 
     XPCThrower::BuildAndThrowException(cx, rv, sz);
 
     if(sz)
         JS_smprintf_free(sz);
 }
 
 void
-xpc_qsThrowBadArg(JSContext *cx, nsresult rv,
-                  XPCWrappedNative *wrapper, jsval *vp, uintN paramnum)
+xpc_qsThrowBadArg(JSContext *cx, nsresult rv, jsval *vp, uintN paramnum)
 {
     const char *ifaceName, *memberName;
-    GetMethodInfo(cx, wrapper, vp, &ifaceName, &memberName);
+    GetMethodInfo(cx, vp, &ifaceName, &memberName);
     ThrowBadArg(cx, rv, ifaceName, memberName, paramnum);
 }
 
 void
 xpc_qsThrowBadArgWithCcx(XPCCallContext &ccx, nsresult rv, uintN paramnum)
 {
     XPCThrower::ThrowBadParam(rv, paramnum, ccx);
 }
 
 void
 xpc_qsThrowBadSetterValue(JSContext *cx, nsresult rv,
-                          XPCWrappedNative *wrapper, jsval propId)
+                          JSObject *obj, jsval propId)
 {
     const char *ifaceName, *memberName;
-    GetMemberInfo(wrapper, propId, &ifaceName, &memberName);
+    GetMemberInfo(obj, propId, &ifaceName, &memberName);
     ThrowBadArg(cx, rv, ifaceName, memberName, 0);
 }
 
 xpc_qsDOMString::xpc_qsDOMString(JSContext *cx, jsval *pval)
 {
     // From the T_DOMSTRING case in XPCConvert::JSData2Native.
     typedef implementation_type::char_traits traits;
     jsval v;
@@ -448,36 +450,68 @@ xpc_qsACString::xpc_qsACString(JSContext
     }
 
     const char *bytes = JS_GetStringBytes(s);
     size_t len = JS_GetStringLength(s);
     new(mBuf) implementation_type(bytes, len);
     mValid = JS_TRUE;
 }
 
+static nsresult
+getNativeFromWrapper(XPCWrappedNative *wrapper,
+                     const nsIID &iid,
+                     void **ppThis,
+                     nsISupports **pThisRef,
+                     jsval *vp)
+{
+    nsISupports *idobj = wrapper->GetIdentityObject();
+
+    // Try using the QITableEntry to avoid the extra AddRef and Release.
+    QITableEntry* entries = wrapper->GetOffsets();
+    if(entries)
+    {
+        for(QITableEntry* e = entries; e->iid; e++)
+        {
+            if(e->iid->Equals(iid))
+            {
+                *ppThis = (char*) idobj + e->offset - entries[0].offset;
+                *vp = OBJECT_TO_JSVAL(wrapper->GetFlatJSObject());
+                *pThisRef = nsnull;
+                return NS_OK;
+            }
+        }
+    }
+
+    nsresult rv = idobj->QueryInterface(iid, ppThis);
+    *pThisRef = static_cast<nsISupports*>(*ppThis);
+    if(NS_SUCCEEDED(rv))
+        *vp = OBJECT_TO_JSVAL(wrapper->GetFlatJSObject());
+    return rv;
+}
+
 JSBool
 xpc_qsUnwrapThisImpl(JSContext *cx,
                      JSObject *obj,
                      const nsIID &iid,
                      void **ppThis,
-                     XPCWrappedNative **ppWrapper)
+                     nsISupports **pThisRef,
+                     jsval *vp)
 {
     // From XPCWrappedNative::GetWrappedNativeOfJSObject.
     //
     // Usually IS_WRAPPER_CLASS is true the first time through the while loop,
     // and the QueryInterface then succeeds.
 
     NS_ASSERTION(obj, "this == null");
 
     JSObject *cur = obj;
     while(cur)
     {
         JSClass *clazz;
         XPCWrappedNative *wrapper;
-        nsISupports *idobj;
         nsresult rv;
 
         clazz = STOBJ_GET_CLASS(cur);
         if(IS_WRAPPER_CLASS(clazz))
         {
             wrapper = (XPCWrappedNative*) xpc_GetJSPrivate(cur);
             NS_ASSERTION(wrapper, "XPCWN wrapping nothing");
         }
@@ -509,23 +543,19 @@ xpc_qsUnwrapThisImpl(JSContext *cx,
             cur = STOBJ_GET_PARENT(cur);
             NS_ASSERTION(cur, "SJOW wrapping nothing");
             continue;
         }
         else {
             goto next;
         }
 
-        idobj = wrapper->GetIdentityObject();
-        rv = idobj->QueryInterface(iid, ppThis);
+        rv = getNativeFromWrapper(wrapper, iid, ppThis, pThisRef, vp);
         if(NS_SUCCEEDED(rv))
-        {
-            *ppWrapper = wrapper;
             return JS_TRUE;
-        }
         if(rv != NS_ERROR_NO_INTERFACE)
             return xpc_qsThrow(cx, rv);
 
     next:
         cur = STOBJ_GET_PROTO(cur);
     }
 
     // If we didn't find a wrapper using the given obj, try again with obj's
@@ -543,35 +573,37 @@ xpc_qsUnwrapThisImpl(JSContext *cx,
         clazz = STOBJ_GET_CLASS(outer);
         if(clazz == &sXPC_XOW_JSClass.base &&
            (unsafeObj = XPCWrapper::Unwrap(cx, outer)))
         {
             outer = unsafeObj;
         }
 
         if(outer && outer != obj)
-            return xpc_qsUnwrapThisImpl(cx, outer, iid, ppThis, ppWrapper);
+            return xpc_qsUnwrapThisImpl(cx, outer, iid, ppThis, pThisRef, vp);
     }
 
+    *pThisRef = nsnull;
     return xpc_qsThrow(cx, NS_ERROR_XPC_BAD_OP_ON_WN_PROTO);
 }
 
 JSBool
 xpc_qsUnwrapThisFromCcxImpl(XPCCallContext &ccx,
                             const nsIID &iid,
-                            void **ppThis)
+                            void **ppThis,
+                            nsISupports **pThisRef,
+                            jsval *vp)
 {
     XPCWrappedNative *wrapper = ccx.GetWrapper();
     if(!wrapper)
         return xpc_qsThrow(ccx.GetJSContext(), NS_ERROR_XPC_BAD_OP_ON_WN_PROTO);
     if(!wrapper->IsValid())
         return xpc_qsThrow(ccx.GetJSContext(), NS_ERROR_XPC_HAS_BEEN_SHUTDOWN);
 
-    nsISupports *idobj = wrapper->GetIdentityObject();
-    nsresult rv = idobj->QueryInterface(iid, ppThis);
+    nsresult rv = getNativeFromWrapper(wrapper, iid, ppThis, pThisRef, vp);
     if(NS_FAILED(rv))
         return xpc_qsThrow(ccx.GetJSContext(), rv);
     return JS_TRUE;
 }
 
 nsresult
 xpc_qsUnwrapArgImpl(JSContext *cx,
                     jsval v,
--- a/js/src/xpconnect/src/xpcquickstubs.h
+++ b/js/src/xpconnect/src/xpcquickstubs.h
@@ -73,39 +73,63 @@ JSBool
 xpc_qsDefineQuickStubs(JSContext *cx, JSObject *proto, uintN extraFlags,
                        PRUint32 ifacec, const nsIID **interfaces,
                        PRUint32 tableSize, const xpc_qsHashEntry *table);
 
 /** Raise an exception on @a cx and return JS_FALSE. */
 JSBool
 xpc_qsThrow(JSContext *cx, nsresult rv);
 
-/** Elaborately fail after an XPCOM method returned rv. */
+/**
+ * Fail after an XPCOM getter or setter returned rv.
+ *
+ * NOTE: Here @a obj must be the JSObject whose private data field points to an
+ * XPCWrappedNative, not merely an object that has an XPCWrappedNative
+ * somewhere along the prototype chain!  The same applies to @a obj in
+ * xpc_qsThrowBadSetterValue and <code>vp[1]</code> in xpc_qsThrowMethodFailed
+ * and xpc_qsThrowBadArg.
+ *
+ * This is one reason the UnwrapThis functions below have an out parameter that
+ * receives the wrapper JSObject.  (The other reason is to help the caller keep
+ * that JSObject GC-reachable.)
+ */
 JSBool
 xpc_qsThrowGetterSetterFailed(JSContext *cx, nsresult rv,
-                              XPCWrappedNative *wrapper, jsval memberId);
+                              JSObject *obj, jsval memberId);
 
+/**
+ * Fail after an XPCOM method returned rv.
+ *
+ * See NOTE at xpc_qsThrowGetterSetterFailed.
+ */
 JSBool
-xpc_qsThrowMethodFailed(JSContext *cx, nsresult rv,
-                        XPCWrappedNative *wrapper, jsval *vp);
+xpc_qsThrowMethodFailed(JSContext *cx, nsresult rv, jsval *vp);
 
 JSBool
 xpc_qsThrowMethodFailedWithCcx(XPCCallContext &ccx, nsresult rv);
 
-/** Elaborately fail after converting an argument fails. */
+/**
+ * Fail after converting a method argument fails.
+ *
+ * See NOTE at xpc_qsThrowGetterSetterFailed.
+ */
 void
-xpc_qsThrowBadArg(JSContext *cx, nsresult rv,
-                  XPCWrappedNative *wrapper, jsval *vp, uintN paramnum);
+xpc_qsThrowBadArg(JSContext *cx, nsresult rv, jsval *vp, uintN paramnum);
 
 void
 xpc_qsThrowBadArgWithCcx(XPCCallContext &ccx, nsresult rv, uintN paramnum);
 
+/**
+ * Fail after converting a setter argument fails.
+ *
+ * See NOTE at xpc_qsThrowGetterSetterFailed.
+ */
 void
-xpc_qsThrowBadSetterValue(JSContext *cx, nsresult rv,
-                          XPCWrappedNative *wrapper, jsval propId);
+xpc_qsThrowBadSetterValue(JSContext *cx, nsresult rv, JSObject *obj,
+                          jsval propId);
 
 
 /* Functions for converting values between COM and JS. */
 
 inline JSBool
 xpc_qsInt32ToJsval(JSContext *cx, PRInt32 i, jsval *rv)
 {
     if(INT_FITS_IN_JSVAL(i))
@@ -235,16 +259,46 @@ public:
  * with [cstring] rather than [domstring] or [astring].
  */
 class xpc_qsACString : public xpc_qsBasicString<nsACString, nsCString>
 {
 public:
     xpc_qsACString(JSContext *cx, jsval *pval);
 };
 
+struct xpc_qsSelfRef
+{
+    xpc_qsSelfRef() {}
+    explicit xpc_qsSelfRef(nsISupports *p) : ptr(p) {}
+    ~xpc_qsSelfRef() { NS_IF_RELEASE(ptr); }
+
+    nsISupports* ptr;
+};
+
+struct xpc_qsTempRoot
+{
+  public:
+    explicit xpc_qsTempRoot(JSContext *cx)
+        : mContext(cx) {
+        JS_PUSH_SINGLE_TEMP_ROOT(cx, JSVAL_NULL, &mTvr);
+    }
+
+    ~xpc_qsTempRoot() {
+        JS_POP_TEMP_ROOT(mContext, &mTvr);
+    }
+
+    jsval * addr() {
+        return &mTvr.u.value;
+    }
+
+  private:
+    JSContext *mContext;
+    JSTempValueRooter mTvr;
+};
+
 /**
  * Convert a jsval to char*, returning JS_TRUE on success.
  *
  * @param cx
  *      A context.
  * @param pval
  *     In/out. *pval is the jsval to convert; the function may write to *pval,
  *     using it as a GC root (like xpc_qsDOMString's constructor).
@@ -263,61 +317,74 @@ xpc_qsJsvalToWcharStr(JSContext *cx, jsv
 JSBool
 xpc_qsStringToJsval(JSContext *cx, const nsAString &str, jsval *rval);
 
 JSBool
 xpc_qsUnwrapThisImpl(JSContext *cx,
                      JSObject *obj,
                      const nsIID &iid,
                      void **ppThis,
-                     XPCWrappedNative **ppWrapper);
+                     nsISupports **ppThisRef,
+                     jsval *vp);
 
 /**
  * Search @a obj and its prototype chain for an XPCOM object that implements
  * the interface T.
  *
- * If an object implementing T is found, AddRef it, store the pointer in
- * @a *ppThis, store a pointer to the wrapper in @a *ppWrapper, and return
+ * If an object implementing T is found, store a reference to the wrapper
+ * JSObject in @a *pThisVal, store a pointer to the T in @a *ppThis, and return
  * JS_TRUE. Otherwise, raise an exception on @a cx and return JS_FALSE.
  *
- * This does not consult inner objects. It does support XPConnect tear-offs
- * and it sees through XOWs, XPCNativeWrappers, and SafeJSObjectWrappers.
+ * @a *pThisRef receives the same pointer as *ppThis if the T was AddRefed.
+ * Otherwise it receives null (even on error).
+ *
+ * This supports split objects and XPConnect tear-offs and it sees through
+ * XOWs, XPCNativeWrappers, and SafeJSObjectWrappers.
  *
  * Requires a request on @a cx.
  */
 template <class T>
 inline JSBool
 xpc_qsUnwrapThis(JSContext *cx,
                  JSObject *obj,
                  T **ppThis,
-                 XPCWrappedNative **ppWrapper)
+                 nsISupports **pThisRef,
+                 jsval *pThisVal)
 {
     return xpc_qsUnwrapThisImpl(cx,
                                 obj,
                                 NS_GET_TEMPLATE_IID(T),
                                 reinterpret_cast<void **>(ppThis),
-                                ppWrapper);
+                                pThisRef,
+                                pThisVal);
 }
 
 JSBool
 xpc_qsUnwrapThisFromCcxImpl(XPCCallContext &ccx,
                             const nsIID &iid,
-                            void **ppThis);
+                            void **ppThis,
+                            nsISupports **pThisRef,
+                            jsval *vp);
 
 /**
  * Alternate implementation of xpc_qsUnwrapThis using information already
  * present in the given XPCCallContext.
  */
 template <class T>
 inline JSBool
 xpc_qsUnwrapThisFromCcx(XPCCallContext &ccx,
-                        T **ppThis)
+                        T **ppThis,
+                        nsISupports **pThisRef,
+                        jsval *pThisVal)
 {
-    return xpc_qsUnwrapThisFromCcxImpl(ccx, NS_GET_TEMPLATE_IID(T),
-                                       reinterpret_cast<void **>(ppThis));
+    return xpc_qsUnwrapThisFromCcxImpl(ccx,
+                                       NS_GET_TEMPLATE_IID(T),
+                                       reinterpret_cast<void **>(ppThis),
+                                       pThisRef,
+                                       pThisVal);
 }
 
 nsresult
 xpc_qsUnwrapArgImpl(JSContext *cx, jsval v, const nsIID &iid, void **ppArg);
 
 /** Convert a jsval to an XPCOM pointer. */
 template <class T>
 inline nsresult
--- a/js/src/xpconnect/src/xpcwrappednative.cpp
+++ b/js/src/xpconnect/src/xpcwrappednative.cpp
@@ -450,16 +450,18 @@ XPCWrappedNative::GetNewOrUsed(XPCCallCo
 
     if(info && !isClassInfo)
     {
         proto = XPCWrappedNativeProto::GetNewOrUsed(ccx, Scope, info, &sciProto,
                                                     JS_FALSE, isGlobal);
         if(!proto)
             return NS_ERROR_FAILURE;
 
+        proto->CacheOffsets(identity);
+
         wrapper = new XPCWrappedNative(identity, proto);
         if(!wrapper)
             return NS_ERROR_FAILURE;
     }
     else
     {
         AutoMarkingNativeSetPtr set(ccx);
         set = XPCNativeSet::GetNewOrUsed(ccx, nsnull, Interface, 0);
@@ -1226,17 +1228,18 @@ XPCWrappedNative::ReparentWrapperIfFound
             oldProto = wrapper->GetProto();
             XPCNativeScriptableInfo *info = oldProto->GetScriptableInfo();
             XPCNativeScriptableCreateInfo ci(*info);
             newProto =
                 XPCWrappedNativeProto::GetNewOrUsed(ccx, aNewScope,
                                                     oldProto->GetClassInfo(),
                                                     &ci,
                                                     !oldProto->IsShared(),
-                                                    (info->GetJSClass()->flags & JSCLASS_IS_GLOBAL));
+                                                    (info->GetJSClass()->flags & JSCLASS_IS_GLOBAL),
+                                                    oldProto->GetOffsetsMasked());
             if(!newProto)
             {
                 NS_RELEASE(wrapper);
                 return NS_ERROR_FAILURE;
             }
         }
 
         if(!XPC_XOW_WrapperMoved(ccx, wrapper, aNewScope))
@@ -2708,17 +2711,18 @@ NS_IMETHODIMP XPCWrappedNative::RefreshP
     oldProto = GetProto();
 
     XPCNativeScriptableInfo *info = oldProto->GetScriptableInfo();
     XPCNativeScriptableCreateInfo ci(*info);
     newProto = XPCWrappedNativeProto::GetNewOrUsed(ccx, oldProto->GetScope(),
                                                    oldProto->GetClassInfo(),
                                                    &ci,
                                                    !oldProto->IsShared(),
-                                                   (info->GetJSClass()->flags & JSCLASS_IS_GLOBAL));
+                                                   (info->GetJSClass()->flags & JSCLASS_IS_GLOBAL),
+                                                   oldProto->GetOffsetsMasked());
     if(!newProto)
         return UnexpectedFailure(NS_ERROR_FAILURE);
 
     // If nothing needs to change then we're done.
 
     if(newProto.get() == oldProto.get())
         return NS_OK;
 
--- a/js/src/xpconnect/src/xpcwrappednativeproto.cpp
+++ b/js/src/xpconnect/src/xpcwrappednativeproto.cpp
@@ -44,24 +44,26 @@
 
 #if defined(DEBUG_xpc_hacker) || defined(DEBUG)
 PRInt32 XPCWrappedNativeProto::gDEBUG_LiveProtoCount = 0;
 #endif
 
 XPCWrappedNativeProto::XPCWrappedNativeProto(XPCWrappedNativeScope* Scope,
                                              nsIClassInfo* ClassInfo,
                                              PRUint32 ClassInfoFlags,
-                                             XPCNativeSet* Set)
+                                             XPCNativeSet* Set,
+                                             QITableEntry* offsets)
     : mScope(Scope),
       mJSProtoObject(nsnull),
       mClassInfo(ClassInfo),
       mClassInfoFlags(ClassInfoFlags),
       mSet(Set),
       mSecurityInfo(nsnull),
-      mScriptableInfo(nsnull)
+      mScriptableInfo(nsnull),
+      mOffsets(offsets)
 {
     // This native object lives as long as its associated JSObject - killed
     // by finalization of the JSObject (or explicitly if Init fails).
 
     MOZ_COUNT_CTOR(XPCWrappedNativeProto);
 
 #ifdef DEBUG
     PR_AtomicIncrement(&gDEBUG_LiveProtoCount);
@@ -200,17 +202,18 @@ XPCWrappedNativeProto::SystemIsBeingShut
 
 // static
 XPCWrappedNativeProto*
 XPCWrappedNativeProto::GetNewOrUsed(XPCCallContext& ccx,
                                     XPCWrappedNativeScope* Scope,
                                     nsIClassInfo* ClassInfo,
                                     const XPCNativeScriptableCreateInfo* ScriptableCreateInfo,
                                     JSBool ForceNoSharing,
-                                    JSBool isGlobal)
+                                    JSBool isGlobal,
+                                    QITableEntry* offsets)
 {
     NS_ASSERTION(Scope, "bad param");
     NS_ASSERTION(ClassInfo, "bad param");
 
     AutoMarkingWrappedNativeProtoPtr proto(ccx);
     ClassInfo2WrappedNativeProtoMap* map;
     XPCLock* lock;
     JSBool shared;
@@ -249,17 +252,17 @@ XPCWrappedNativeProto::GetNewOrUsed(XPCC
         }
     }
 
     AutoMarkingNativeSetPtr set(ccx);
     set = XPCNativeSet::GetNewOrUsed(ccx, ClassInfo);
     if(!set)
         return nsnull;
 
-    proto = new XPCWrappedNativeProto(Scope, ClassInfo, ciFlags, set);
+    proto = new XPCWrappedNativeProto(Scope, ClassInfo, ciFlags, set, offsets);
 
     if(!proto || !proto->Init(ccx, isGlobal, ScriptableCreateInfo))
     {
         delete proto.get();
         return nsnull;
     }
 
     if(shared)
--- a/xpcom/components/nsIClassInfo.idl
+++ b/xpcom/components/nsIClassInfo.idl
@@ -35,16 +35,28 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 
+%{C++
+/**
+ * Calling QueryInterface with this special IID will return a null-terminated
+ * table of QITableEntry's. Not all objects support this.
+ * Note that this breaks XPCOM rules a bit (the table doesn't derive from
+ * nsISupports).
+ */
+#define NS_THISPTROFFSETS_SID \
+    { 0x23e017cc, 0x5d6f, 0x430c, \
+      { 0xb3, 0xe6, 0x9d, 0x32, 0x65, 0x70, 0xd6, 0xb8 } }
+%}
+
 /**
  * Provides information about a specific implementation class
  * @status FROZEN
  */
 
 [scriptable, uuid(986c11d0-f340-11d4-9075-0010a4e73d9a)]
 interface nsIClassInfo : nsISupports
 {