Back out bug 412320 and various followups because the perf impact was minimal and the code is more complicated
authorbenjamin@smedbergs.us
Thu, 21 Feb 2008 12:39:20 -0800
changeset 12033 506b9ff63a1d46ea62f772a760ba62a89905f2b8
parent 12032 7da3c2a97e3e94441cc23c16275ca2ab5181eb8b
child 12034 930fe19db9d07d1b2bd7e4b6adccafc567a6cfb3
push idunknown
push userunknown
push dateunknown
bugs412320
milestone1.9b4pre
Back out bug 412320 and various followups because the perf impact was minimal and the code is more complicated
config/rules.mk
content/base/src/contentbase.gqi
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
content/base/src/nsGenericElement.cpp
content/html/content/public/nsIFrameSetElement.h
content/html/content/src/Makefile.in
content/html/content/src/htmlcontent.gqi
content/html/content/src/htmlgenericelement.gqi
content/html/content/src/nsGenericHTMLElement.cpp
content/html/content/src/nsGenericHTMLElement.h
content/html/content/src/nsHTMLAnchorElement.cpp
content/html/content/src/nsHTMLAnchorElement.h
content/html/content/src/nsHTMLDivElement.cpp
content/html/content/src/nsHTMLDivElement.h
content/html/content/src/nsHTMLFrameElement.cpp
content/html/content/src/nsHTMLFrameElement.h
content/html/content/src/nsHTMLFrameSetElement.cpp
content/html/content/src/nsHTMLFrameSetElement.h
content/html/content/src/nsHTMLIFrameElement.cpp
content/html/content/src/nsHTMLIFrameElement.h
content/html/content/src/nsHTMLSpanElement.cpp
content/html/content/src/nsHTMLSpanElement.h
content/html/document/src/Makefile.in
content/html/document/src/htmldocument.gqi
content/html/document/src/nsHTMLDocument.cpp
content/xml/document/src/Makefile.in
content/xml/document/src/nsXMLDocument.cpp
content/xml/document/src/xmldocument.gqi
content/xul/document/src/Makefile.in
content/xul/document/src/nsXULDocument.cpp
content/xul/document/src/xuldocument.gqi
dom/src/base/Makefile.in
dom/src/base/dombase.gqi
dom/src/base/nsGlobalWindow.cpp
netwerk/base/src/Makefile.in
netwerk/base/src/neckobase.gqi
netwerk/base/src/nsBaseChannel.cpp
netwerk/base/src/nsIOService.cpp
netwerk/base/src/nsSocketTransport2.cpp
netwerk/base/src/nsSocketTransport2.h
netwerk/base/src/nsSocketTransportService2.cpp
netwerk/base/src/nsStandardURL.cpp
netwerk/base/src/nsStandardURL.h
xpcom/base/gqi.py
xpcom/components/Makefile.in
xpcom/components/nsCategoryManager.cpp
xpcom/components/nsCategoryManager.h
xpcom/components/nsComponentManager.cpp
xpcom/components/nsComponentManager.h
xpcom/components/nsNativeComponentLoader.cpp
xpcom/components/xpcomcomponents.gqi
xpcom/ds/Makefile.in
xpcom/ds/nsArray.cpp
xpcom/ds/nsAtomTable.cpp
xpcom/ds/nsByteBuffer.cpp
xpcom/ds/nsHashPropertyBag.cpp
xpcom/ds/nsHashPropertyBag.h
xpcom/ds/nsIByteBuffer.h
xpcom/ds/nsINIParserImpl.cpp
xpcom/ds/nsINIParserImpl.h
xpcom/ds/nsIUnicharBuffer.h
xpcom/ds/nsObserverList.cpp
xpcom/ds/nsPersistentProperties.cpp
xpcom/ds/nsStaticAtom.h
xpcom/ds/nsStringEnumerator.cpp
xpcom/ds/nsStringEnumerator.h
xpcom/ds/nsSupportsArray.cpp
xpcom/ds/nsSupportsArray.h
xpcom/ds/nsSupportsArrayEnumerator.cpp
xpcom/ds/nsSupportsPrimitives.cpp
xpcom/ds/nsUnicharBuffer.cpp
xpcom/ds/nsVariant.cpp
xpcom/ds/xpcomds.gqi
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -112,21 +112,16 @@ EXPAND_LIBNAME = $(addprefix -l,$(1))
 EXPAND_LIBNAME_PATH = -L$(2) $(addprefix -l,$(1))
 EXPAND_MOZLIBNAME = $(addprefix -l,$(1))
 endif
 
 ifdef EXTRA_DSO_LIBS
 EXTRA_DSO_LIBS	:= $(call EXPAND_MOZLIBNAME,$(EXTRA_DSO_LIBS))
 endif
 
-ifdef GQI_SRCS
-CPPSRCS += $(GQI_SRCS:.gqi=QI.cpp)
-GARBAGE += $(GQI_SRCS:.gqi=QI.cpp)
-endif
-
 #
 # Library rules
 #
 # If BUILD_STATIC_LIBS or FORCE_STATIC_LIB is set, build a static library.
 # Otherwise, build a shared library.
 #
 
 ifndef LIBRARY
@@ -1224,19 +1219,16 @@ endef
 
 MAKE_DEPS_AUTO_CC = $(MAKE_DEPS_AUTO)
 MAKE_DEPS_AUTO_CXX = $(MAKE_DEPS_AUTO)
 
 endif # COMPILER_DEPEND
 
 endif # MOZ_AUTO_DEPS
 
-%QI.cpp: %.gqi $(topsrcdir)/xpcom/base/gqi.py
-	$(PYTHON) $(topsrcdir)/xpcom/base/gqi.py $(GQIFLAGS) $(INCLUDES) -I $(IDL_DIR) -o $@ -D $(MDDEPDIR)/$(@F).pp $<
-
 # Rules for building native targets must come first because of the host_ prefix
 host_%.$(OBJ_SUFFIX): %.c Makefile Makefile.in
 	$(REPORT_BUILD)
 	$(ELOG) $(HOST_CC) $(HOST_OUTOPTION)$@ -c $(HOST_CFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
 
 host_%.$(OBJ_SUFFIX): %.cpp Makefile Makefile.in
 	$(REPORT_BUILD)
 	$(ELOG) $(HOST_CXX) $(HOST_OUTOPTION)$@ -c $(HOST_CXXFLAGS) $(INCLUDES) $(NSPR_CFLAGS) $(_VPATH_SRCS)
deleted file mode 100644
--- a/content/base/src/contentbase.gqi
+++ /dev/null
@@ -1,99 +0,0 @@
-%import-idl "nsIDOM3Node.idl"
-%import-idl "nsIDOMNSElement.idl"
-%import-idl "nsIDOMEventTarget.idl"
-%import-idl "nsIDOM3EventTarget.idl"
-%import-idl "nsIDOMNSEventTarget.idl"
-%import-idl "nsIWeakReference.idl"
-%import-idl "nsIDOMDocument.idl"
-%import-idl "nsIDOM3Document.idl"
-%import-idl "nsIDOMNSDocument.idl"
-%import-idl "nsIDOMDocumentEvent.idl"
-%import-idl "nsIDOM3DocumentEvent.idl"
-%import-idl "nsIDOMDocumentStyle.idl"
-%import-idl "nsIDOMNSDocumentStyle.idl"
-%import-idl "nsIDOMDocumentView.idl"
-%import-idl "nsIDOMDocumentRange.idl"
-%import-idl "nsIDOMDocumentTraversal.idl"
-%import-idl "nsIDOMDocumentXBL.idl"
-%import-idl "nsIDOMXPathEvaluator.idl"
-
-%pseudo-iid nsIContent fba9aa39-016e-4d5d-ab62-22a1b84a3c7b
-%pseudo-iid nsINode 6f69dd90-318d-40ac-b8b8-99b8a7bb9a58
-%pseudo-iid nsPIDOMEventTarget 44a6597b-9fc3-4a8d-b7a4-d9009abf9d15
-%pseudo-iid nsIDocument 626d86d2-615f-4a12-94d8-e3db3a298372
-%pseudo-iid nsIScriptObjectPrincipal 3eedba38-8d22-41e1-817a-0e43e165b664
-%pseudo-iid nsIMutationObserver 32e68316-67d4-44a5-8d35-0d390fa9df11
-%pseudo-iid nsIXPathEvaluatorInternal  b4b72daa-65d6-440f-b608-e2ee9a82f313
-%pseudo-iid nsIRadioGroupContainer 06de7839-d0db-47d3-8290-3cb8622ed966
-
-%{C++
-#include "nsGenericElement.h"
-#include "nsDocument.h"
-#include "nsIXPathEvaluatorInternal.h"
-#include "nsDOMCID.h"
-#include "nsComponentManagerUtils.h"
-%}
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGenericElement)
-  NS_INTERFACE_MAP_ENTRY(nsIContent)
-  NS_INTERFACE_MAP_ENTRY(nsINode)
-  NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
-  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, new nsNode3Tearoff(this))
-  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSElement, new nsNSElementTearoff(this))
-  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMEventTarget,
-                                 nsDOMEventRTTearoff::Create(this))
-  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3EventTarget,
-                                 nsDOMEventRTTearoff::Create(this))
-  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSEventTarget,
-                                 nsDOMEventRTTearoff::Create(this))
-  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
-                                 new nsNodeSupportsWeakRefTearoff(this))
-  // nsNodeSH::PreCreate() depends on the identity pointer being the
-  // same as nsINode (which nsIContent inherits), so if you change the
-  // below line, make sure nsNodeSH::PreCreate() still does the right
-  // thing!
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
-NS_INTERFACE_MAP_END
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDocument)
-  NS_INTERFACE_MAP_ENTRY(nsINode)
-  NS_INTERFACE_MAP_ENTRY(nsIDocument)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDocument)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNSDocument)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOM3DocumentEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentStyle)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNSDocumentStyle)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentView)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentRange)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentTraversal)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentXBL)
-  NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
-  NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNSEventTarget)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
-  NS_INTERFACE_MAP_ENTRY(nsIDOM3Node)
-  NS_INTERFACE_MAP_ENTRY(nsIDOM3Document)
-  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
-  NS_INTERFACE_MAP_ENTRY(nsIRadioGroupContainer)
-  NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
-  // 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_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocument)
-
-  NS_INTERFACE_MAP_ENTRY_LITERAL(nsIDOMXPathEvaluator, nsIXPathEvaluatorInternal)
-    if (!mXPathEvaluatorTearoff) {
-      nsresult rv;
-      mXPathEvaluatorTearoff =
-        do_CreateInstance(NS_XPATH_EVALUATOR_CONTRACTID,
-                          static_cast<nsIDocument *>(this), &rv);
-      NS_ENSURE_SUCCESS(rv, rv);
-    }
-
-    return mXPathEvaluatorTearoff->QueryInterface(aIID, aResult);
-  END
-NS_INTERFACE_MAP_END
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -891,16 +891,64 @@ nsDocument::~nsDocument()
     delete mBoxObjectTable;
   }
 
   delete mContentWrapperHash;
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsDocument)
 
+NS_INTERFACE_TABLE_HEAD(nsDocument)
+  NS_INTERFACE_TABLE_BEGIN
+    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)
+    // 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)
+  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);
+    }
+
+    return mXPathEvaluatorTearoff->QueryInterface(aIID, aInstancePtr);
+  }
+  else
+NS_INTERFACE_MAP_END
+
+
 NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(nsDocument, nsIDocument)
 NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS_WITH_DESTROY(nsDocument, 
                                                         nsIDocument,
                                                         nsNodeUtils::LastRelease(this))
 
 
 PR_STATIC_CALLBACK(PLDHashOperator)
 SubDocTraverser(PLDHashTable *table, PLDHashEntryHdr *hdr, PRUint32 number,
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -793,17 +793,17 @@ protected:
 
   nsCOMPtr<nsIScriptEventManager> mScriptEventManager;
 
   nsString mBaseTarget;
 
   // Our update nesting level
   PRUint32 mUpdateNestLevel;
 
-protected:
+private:
   friend class nsUnblockOnloadEvent;
 
   void PostUnblockOnloadEvent();
   void DoUnblockOnload();
 
   /**
    * See if aDocument is a child of this.  If so, return the frame element in
    * this document that holds currentDoc (or an ancestor).
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -3549,16 +3549,38 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
     if (slots) {
       cb.NoteXPCOMChild(slots->mAttributeMap.get());
       if (tmp->IsNodeOfType(nsINode::eXUL))
         cb.NoteXPCOMChild(slots->mControllers);
     }
   }
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGenericElement)
+  NS_INTERFACE_MAP_ENTRY(nsIContent)
+  NS_INTERFACE_MAP_ENTRY(nsINode)
+  NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
+  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, new nsNode3Tearoff(this))
+  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSElement, new nsNSElementTearoff(this))
+  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMEventTarget,
+                                 nsDOMEventRTTearoff::Create(this))
+  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3EventTarget,
+                                 nsDOMEventRTTearoff::Create(this))
+  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSEventTarget,
+                                 nsDOMEventRTTearoff::Create(this))
+  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
+                                 new nsNodeSupportsWeakRefTearoff(this))
+  // nsNodeSH::PreCreate() depends on the identity pointer being the
+  // same as nsINode (which nsIContent inherits), so if you change the
+  // below line, make sure nsNodeSH::PreCreate() still does the right
+  // thing!
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
+NS_INTERFACE_MAP_END
+
 NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(nsGenericElement, nsIContent)
 NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS_WITH_DESTROY(nsGenericElement, 
 							nsIContent,
 							nsNodeUtils::LastRelease(this))
 
 nsresult
 nsGenericElement::PostQueryInterface(REFNSIID aIID, void** aInstancePtr)
 {
--- a/content/html/content/public/nsIFrameSetElement.h
+++ b/content/html/content/public/nsIFrameSetElement.h
@@ -35,17 +35,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsIFramesetElement_h___
 #define nsIFramesetElement_h___
 
 #include "nsISupports.h"
-#include "nsCoord.h"
 
 // IID for the nsIFramesetElement interface
 #define NS_IFRAMESETELEMENT_IID \
 { 0xeefe0fe5, 0x44ac, 0x4d7f, \
   { 0xa7, 0x51, 0xf4, 0xaa, 0x5f, 0x22, 0xb0, 0xbf } }
 
 /**
  * The nsFramesetUnit enum is used to denote the type of each entry
--- a/content/html/content/src/Makefile.in
+++ b/content/html/content/src/Makefile.in
@@ -128,18 +128,16 @@ CPPSRCS		= \
 		nsHTMLTableColElement.cpp \
 		nsHTMLTableRowElement.cpp \
 		nsHTMLTableSectionElement.cpp \
 		nsHTMLTextAreaElement.cpp \
 		nsHTMLTitleElement.cpp \
                 nsTextRectangle.cpp \
 		$(NULL)
 
-GQI_SRCS = htmlcontent.gqi
-
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
 INCLUDES	+= \
 		-I$(srcdir)/../../../base/src \
 		-I$(srcdir)/../../../events/src \
deleted file mode 100644
--- a/content/html/content/src/htmlcontent.gqi
+++ /dev/null
@@ -1,55 +0,0 @@
-%import "htmlgenericelement.gqi"
-
-%import-idl "nsIDOMHTMLAnchorElement.idl"
-%import-idl "nsIDOMNSHTMLAnchorElement2.idl"
-%import-idl "nsIDOMHTMLDivElement.idl"
-%import-idl "nsIDOMHTMLFrameElement.idl"
-%import-idl "nsIDOMHTMLFrameSetElement.idl"
-%import-idl "nsIDOMHTMLIFrameElement.idl"
-
-%{C++
-#include "nsHTMLAnchorElement.h"
-#include "nsHTMLDivElement.h"
-#include "nsHTMLSpanElement.h"
-#include "nsHTMLFrameElement.h"
-#include "nsHTMLFrameSetElement.h"
-#include "nsHTMLIFrameElement.h"
-%}
-
-%pseudo-iid nsILink 0c212bc4-fcd7-479d-8c3f-3be8e6787450
-%pseudo-iid nsIFrameSetElement eefe0fe5-44ac-4d7f-a751-f4aa5f22b0bf
-
-NS_INTERFACE_MAP_BEGIN(nsHTMLAnchorElement, nsGenericHTMLElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLAnchorElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLAnchorElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLAnchorElement2)
-  NS_INTERFACE_MAP_ENTRY(nsILink)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(HTMLAnchorElement)
-NS_INTERFACE_MAP_END
-
-NS_INTERFACE_MAP_BEGIN(nsHTMLDivElement, nsGenericHTMLElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLDivElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(HTMLDivElement)
-NS_INTERFACE_MAP_END
-
-NS_INTERFACE_MAP_BEGIN(nsHTMLSpanElement, nsGenericHTMLElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(HTMLSpanElement)
-NS_INTERFACE_MAP_END
-
-NS_INTERFACE_MAP_BEGIN(nsHTMLFrameElement, nsGenericHTMLFrameElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLFrameElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(HTMLFrameElement)
-NS_INTERFACE_MAP_END
-
-NS_INTERFACE_MAP_BEGIN(nsHTMLFrameSetElement, nsGenericHTMLElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLFrameSetElement)
-  NS_INTERFACE_MAP_ENTRY(nsIFrameSetElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(HTMLFrameSetElement)
-NS_INTERFACE_MAP_END
-
-NS_INTERFACE_MAP_BEGIN(nsHTMLIFrameElement, nsGenericHTMLFrameElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLIFrameElement)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(HTMLIFrameElement)
-NS_INTERFACE_MAP_END
-
-
deleted file mode 100644
--- a/content/html/content/src/htmlgenericelement.gqi
+++ /dev/null
@@ -1,35 +0,0 @@
-// Note: nsGenericHTMLElement does not implement QI directly... this declaration is here only
-// so that subclasses have the correct list
-
-%import "contentbase.gqi"
-
-%import-idl "nsIDOMNSHTMLElement.idl"
-%import-idl "nsIDOMElementCSSInlineStyle.idl"
-%import-idl "nsIDOMHTMLElement.idl"
-%import-idl "nsIDOMNSHTMLFrameElement.idl"
-%import-idl "nsIFrameLoader.idl"
-
-%{C++
-#include "nsGenericHTMLElement.h"
-%}
-
-NS_INTERFACE_MAP_BEGIN(nsGenericHTMLElement, nsGenericElement)
-  // nsGenericHTMLElement doesn't implement nsIDOMHTMLElement, but all
-  // subclasses do, and we only use this declaration for subclasses
-  NS_FUTURE_INTERFACE_MAP_ENTRY(nsIDOMHTMLElement)
-  NS_FUTURE_INTERFACE_MAP_ENTRY(nsIDOMNode)
-  NS_FUTURE_INTERFACE_MAP_ENTRY(nsIDOMElement)
-
-  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSHTMLElement,
-                                 new nsGenericHTMLElementTearoff(this))
-  NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMElementCSSInlineStyle,
-                                 new nsGenericHTMLElementTearoff(this))
-  NS_INTERFACE_MAP_UNFOUND
-    return PostQueryInterface(aIID, aResult);
-  END
-NS_INTERFACE_MAP_END
-
-NS_INTERFACE_MAP_BEGIN(nsGenericHTMLFrameElement, nsGenericHTMLElement)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLFrameElement)
-  NS_INTERFACE_MAP_ENTRY(nsIFrameLoaderOwner)
-NS_INTERFACE_MAP_END
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -174,16 +174,40 @@ nsGenericHTMLElement::Init(nsINodeInfo *
   GEUS_ElementCreated(aNodeInfo);
 
   return nsGenericHTMLElementBase::Init(aNodeInfo);
 }
 
 #endif
 
 
+class nsGenericHTMLElementTearoff : public nsIDOMNSHTMLElement,
+                                    public nsIDOMElementCSSInlineStyle
+{
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+
+  nsGenericHTMLElementTearoff(nsGenericHTMLElement *aElement)
+    : mElement(aElement)
+  {
+  }
+
+  virtual ~nsGenericHTMLElementTearoff()
+  {
+  }
+
+  NS_FORWARD_NSIDOMNSHTMLELEMENT(mElement->)
+  NS_FORWARD_NSIDOMELEMENTCSSINLINESTYLE(mElement->)
+
+  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsGenericHTMLElementTearoff,
+                                           nsIDOMNSHTMLElement)
+
+private:
+  nsCOMPtr<nsGenericHTMLElement> mElement;
+};
+
 NS_IMPL_CYCLE_COLLECTION_1(nsGenericHTMLElementTearoff, mElement)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(nsGenericHTMLElementTearoff,
                                           nsIDOMNSHTMLElement)
 NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS(nsGenericHTMLElementTearoff,
                                            nsIDOMNSHTMLElement)
 
 NS_INTERFACE_TABLE_HEAD(nsGenericHTMLElementTearoff)
@@ -2850,16 +2874,23 @@ nsGenericHTMLFrameElement::~nsGenericHTM
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsGenericHTMLFrameElement)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsGenericHTMLFrameElement,
                                                   nsGenericHTMLElement)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFrameLoader)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
+NS_INTERFACE_TABLE_HEAD(nsGenericHTMLFrameElement)
+  NS_INTERFACE_TABLE_INHERITED2(nsGenericHTMLFrameElement,
+                                nsIDOMNSHTMLFrameElement,
+                                nsIFrameLoaderOwner)
+  NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsGenericHTMLFrameElement)
+NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
+
 nsresult
 nsGenericHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument)
 {
   NS_PRECONDITION(aContentDocument, "Null out param");
   *aContentDocument = nsnull;
 
   nsCOMPtr<nsIDOMWindow> win;
   GetContentWindow(getter_AddRefs(win));
--- a/content/html/content/src/nsGenericHTMLElement.h
+++ b/content/html/content/src/nsGenericHTMLElement.h
@@ -40,18 +40,16 @@
 
 #include "nsMappedAttributeElement.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsINameSpaceManager.h"  // for kNameSpaceID_None
 #include "nsIFormControl.h"
 #include "nsIDOMNSHTMLFrameElement.h"
 #include "nsFrameLoader.h"
 #include "nsGkAtoms.h"
-#include "nsIDOMElementCSSInlineStyle.h"
-#include "nsIDOMNSHTMLElement.h"
 
 class nsIDOMAttr;
 class nsIDOMEventListener;
 class nsIDOMNodeList;
 class nsIFrame;
 class nsIStyleRule;
 class nsChildContentList;
 class nsDOMCSSDeclaration;
@@ -895,16 +893,19 @@ class nsGenericHTMLFrameElement : public
 {
 public:
   nsGenericHTMLFrameElement(nsINodeInfo *aNodeInfo)
     : nsGenericHTMLElement(aNodeInfo)
   {
   }
   virtual ~nsGenericHTMLFrameElement();
 
+  // nsISupports
+  NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
+
   // nsIDOMNSHTMLFrameElement
   NS_DECL_NSIDOMNSHTMLFRAMEELEMENT
 
   // nsIFrameLoaderOwner
   NS_DECL_NSIFRAMELOADEROWNER
 
   // nsIContent
   virtual PRBool IsFocusable(PRInt32 *aTabIndex = nsnull);
@@ -935,40 +936,16 @@ protected:
   // it makes sense.
   nsresult EnsureFrameLoader();
   nsresult LoadSrc();
   nsresult GetContentDocument(nsIDOMDocument** aContentDocument);
 
   nsCOMPtr<nsIFrameLoader> mFrameLoader;
 };
 
-class nsGenericHTMLElementTearoff : public nsIDOMNSHTMLElement,
-                                    public nsIDOMElementCSSInlineStyle
-{
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-
-  nsGenericHTMLElementTearoff(nsGenericHTMLElement *aElement)
-    : mElement(aElement)
-  {
-  }
-
-  virtual ~nsGenericHTMLElementTearoff()
-  {
-  }
-
-  NS_FORWARD_NSIDOMNSHTMLELEMENT(mElement->)
-  NS_FORWARD_NSIDOMELEMENTCSSINLINESTYLE(mElement->)
-
-  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsGenericHTMLElementTearoff,
-                                           nsIDOMNSHTMLElement)
-
-private:
-  nsCOMPtr<nsGenericHTMLElement> mElement;
-};
-
 //----------------------------------------------------------------------
 
 /**
  * A macro to implement the NS_NewHTMLXXXElement() functions.
  */
 #define NS_IMPL_NS_NEW_HTML_ELEMENT(_elementName)                            \
 nsGenericHTMLElement*                                                        \
 NS_NewHTML##_elementName##Element(nsINodeInfo *aNodeInfo, PRBool aFromParser)\
--- a/content/html/content/src/nsHTMLAnchorElement.cpp
+++ b/content/html/content/src/nsHTMLAnchorElement.cpp
@@ -31,18 +31,16 @@
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * 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 "nsHTMLAnchorElement.h"
 #include "nsCOMPtr.h"
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsIDOMHTMLAnchorElement.h"
 #include "nsIDOMNSHTMLAnchorElement2.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIHTMLDocument.h"
 #include "nsGenericHTMLElement.h"
@@ -60,20 +58,88 @@
 // For GetText().
 #include "nsIContentIterator.h"
 #include "nsIDOMText.h"
 #include "nsIEnumerator.h"
 
 #include "nsCOMPtr.h"
 #include "nsIPresShell.h"
 #include "nsIDocument.h"
-#include "nsHTMLAnchorElement.h"
 
 nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult);
 
+class nsHTMLAnchorElement : public nsGenericHTMLElement,
+                            public nsIDOMHTMLAnchorElement,
+                            public nsIDOMNSHTMLAnchorElement2,
+                            public nsILink
+{
+public:
+  nsHTMLAnchorElement(nsINodeInfo *aNodeInfo);
+  virtual ~nsHTMLAnchorElement();
+
+  // nsISupports
+  NS_DECL_ISUPPORTS_INHERITED
+
+  // nsIDOMNode
+  NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
+
+  // nsIDOMElement
+  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
+
+  // nsIDOMHTMLElement
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
+
+  // nsIDOMHTMLAnchorElement
+  NS_DECL_NSIDOMHTMLANCHORELEMENT  
+
+  // nsIDOMNSHTMLAnchorElement
+  NS_DECL_NSIDOMNSHTMLANCHORELEMENT
+
+  // nsIDOMNSHTMLAnchorElement2
+  NS_DECL_NSIDOMNSHTMLANCHORELEMENT2
+
+  // nsILink
+  NS_IMETHOD GetLinkState(nsLinkState &aState);
+  NS_IMETHOD SetLinkState(nsLinkState aState);
+  NS_IMETHOD GetHrefURI(nsIURI** aURI);
+  NS_IMETHOD LinkAdded() { return NS_OK; }
+  NS_IMETHOD LinkRemoved() { return NS_OK; }
+
+  virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
+                              nsIContent* aBindingParent,
+                              PRBool aCompileEventHandlers);
+  virtual void UnbindFromTree(PRBool aDeep = PR_TRUE,
+                              PRBool aNullParent = PR_TRUE);
+  virtual void SetFocus(nsPresContext* aPresContext);
+  virtual PRBool IsFocusable(PRBool *aTabIndex = nsnull);
+
+  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
+  virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
+  virtual PRBool IsLink(nsIURI** aURI) const;
+  virtual void GetLinkTarget(nsAString& aTarget);
+
+  nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
+                   const nsAString& aValue, PRBool aNotify)
+  {
+    return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
+  }
+  virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
+                           nsIAtom* aPrefix, const nsAString& aValue,
+                           PRBool aNotify);
+  virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
+                             PRBool aNotify);
+
+  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+
+protected:
+  // The cached visited state
+  nsLinkState mLinkState;
+};
+
+
 NS_IMPL_NS_NEW_HTML_ELEMENT(Anchor)
 
 
 nsHTMLAnchorElement::nsHTMLAnchorElement(nsINodeInfo *aNodeInfo)
   : nsGenericHTMLElement(aNodeInfo),
     mLinkState(eLinkState_Unknown)
 {
 }
@@ -82,18 +148,29 @@ 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_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)
 NS_IMPL_URI_ATTR(nsHTMLAnchorElement, Href, href)
 NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Hreflang, hreflang)
 NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Name, name)
 NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Rel, rel)
 NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Rev, rev)
 NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Shape, shape)
deleted file mode 100644
--- a/content/html/content/src/nsHTMLAnchorElement.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:set tw=80 expandtab softtabstop=2 ts=2 sw=2: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Daniel Glazman <glazman@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * 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 ***** */
-
-#ifndef nsHTMLAnchorElement_h__
-#define nsHTMLAnchorElement_h__
-
-#include "nsGenericHTMLElement.h"
-#include "nsIDOMHTMLAnchorElement.h"
-#include "nsIDOMNSHTMLAnchorElement2.h"
-#include "nsILink.h"
-
-class nsHTMLAnchorElement : public nsGenericHTMLElement,
-                            public nsIDOMHTMLAnchorElement,
-                            public nsIDOMNSHTMLAnchorElement2,
-                            public nsILink
-{
-public:
-  nsHTMLAnchorElement(nsINodeInfo *aNodeInfo);
-  virtual ~nsHTMLAnchorElement();
-
-  // nsISupports
-  NS_DECL_ISUPPORTS_INHERITED
-
-  // nsIDOMNode
-  NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
-
-  // nsIDOMElement
-  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
-
-  // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
-
-  // nsIDOMHTMLAnchorElement
-  NS_DECL_NSIDOMHTMLANCHORELEMENT  
-
-  // nsIDOMNSHTMLAnchorElement
-  NS_DECL_NSIDOMNSHTMLANCHORELEMENT
-
-  // nsIDOMNSHTMLAnchorElement2
-  NS_DECL_NSIDOMNSHTMLANCHORELEMENT2
-
-  // nsILink
-  NS_IMETHOD GetLinkState(nsLinkState &aState);
-  NS_IMETHOD SetLinkState(nsLinkState aState);
-  NS_IMETHOD GetHrefURI(nsIURI** aURI);
-  NS_IMETHOD LinkAdded() { return NS_OK; }
-  NS_IMETHOD LinkRemoved() { return NS_OK; }
-
-  virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
-                              nsIContent* aBindingParent,
-                              PRBool aCompileEventHandlers);
-  virtual void UnbindFromTree(PRBool aDeep = PR_TRUE,
-                              PRBool aNullParent = PR_TRUE);
-  virtual void SetFocus(nsPresContext* aPresContext);
-  virtual PRBool IsFocusable(PRBool *aTabIndex = nsnull);
-
-  virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
-  virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
-  virtual PRBool IsLink(nsIURI** aURI) const;
-  virtual void GetLinkTarget(nsAString& aTarget);
-
-  nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
-                   const nsAString& aValue, PRBool aNotify)
-  {
-    return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
-  }
-  virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
-                           nsIAtom* aPrefix, const nsAString& aValue,
-                           PRBool aNotify);
-  virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
-                             PRBool aNotify);
-
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-
-protected:
-  // The cached visited state
-  nsLinkState mLinkState;
-};
-
-#endif
--- a/content/html/content/src/nsHTMLDivElement.cpp
+++ b/content/html/content/src/nsHTMLDivElement.cpp
@@ -29,40 +29,79 @@
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * 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 "nsHTMLDivElement.h"
+#include "nsIDOMHTMLDivElement.h"
 #include "nsIDOMEventTarget.h"
+#include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsMappedAttributes.h"
 
+class nsHTMLDivElement : public nsGenericHTMLElement,
+                         public nsIDOMHTMLDivElement
+{
+public:
+  nsHTMLDivElement(nsINodeInfo *aNodeInfo);
+  virtual ~nsHTMLDivElement();
+
+  // nsISupports
+  NS_DECL_ISUPPORTS_INHERITED
+
+  // nsIDOMNode
+  NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
+
+  // nsIDOMElement
+  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
+
+  // nsIDOMHTMLElement
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
+
+  // nsIDOMHTMLDivElement
+  NS_DECL_NSIDOMHTMLDIVELEMENT
+
+  virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
+                                nsIAtom* aAttribute,
+                                const nsAString& aValue,
+                                nsAttrValue& aResult);
+  NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
+  virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
+  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+};
+
+
 NS_IMPL_NS_NEW_HTML_ELEMENT(Div)
 
 
 nsHTMLDivElement::nsHTMLDivElement(nsINodeInfo *aNodeInfo)
   : nsGenericHTMLElement(aNodeInfo)
 {
 }
 
 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_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLDivElement)
+
 NS_IMPL_ELEMENT_CLONE(nsHTMLDivElement)
 
 
 NS_IMPL_STRING_ATTR(nsHTMLDivElement, Align, align)
 
 
 PRBool
 nsHTMLDivElement::ParseAttribute(PRInt32 aNamespaceID,
deleted file mode 100644
--- a/content/html/content/src/nsHTMLDivElement.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * 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 ***** */
-
-#ifndef nsHTMLDivElement_h__
-#define nsHTMLDivElement_h__
-
-#include "nsIDOMHTMLDivElement.h"
-#include "nsGenericHTMLElement.h"
-
-class nsHTMLDivElement : public nsGenericHTMLElement,
-                         public nsIDOMHTMLDivElement
-{
-public:
-  nsHTMLDivElement(nsINodeInfo *aNodeInfo);
-  virtual ~nsHTMLDivElement();
-
-  // nsISupports
-  NS_DECL_ISUPPORTS_INHERITED
-
-  // nsIDOMNode
-  NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
-
-  // nsIDOMElement
-  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
-
-  // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
-
-  // nsIDOMHTMLDivElement
-  NS_DECL_NSIDOMHTMLDIVELEMENT
-
-  virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
-                                nsIAtom* aAttribute,
-                                const nsAString& aValue,
-                                nsAttrValue& aResult);
-  NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
-  virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-};
-
-#endif
--- a/content/html/content/src/nsHTMLFrameElement.cpp
+++ b/content/html/content/src/nsHTMLFrameElement.cpp
@@ -29,40 +29,82 @@
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * 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 "nsHTMLFrameElement.h"
+#include "nsIDOMHTMLFrameElement.h"
+#include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsIPresShell.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsDOMError.h"
 
+
+class nsHTMLFrameElement : public nsGenericHTMLFrameElement,
+                           public nsIDOMHTMLFrameElement
+{
+public:
+  nsHTMLFrameElement(nsINodeInfo *aNodeInfo);
+  virtual ~nsHTMLFrameElement();
+
+  // nsISupports
+  NS_DECL_ISUPPORTS_INHERITED
+
+  // nsIDOMNode
+  NS_FORWARD_NSIDOMNODE(nsGenericHTMLFrameElement::)
+
+  // nsIDOMElement
+  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFrameElement::)
+
+  // nsIDOMHTMLElement
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFrameElement::)
+
+  // nsIDOMHTMLFrameElement
+  NS_DECL_NSIDOMHTMLFRAMEELEMENT
+
+  // nsIContent
+  virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
+                                nsIAtom* aAttribute,
+                                const nsAString& aValue,
+                                nsAttrValue& aResult);
+  NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
+  nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
+  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+};
+
+
 NS_IMPL_NS_NEW_HTML_ELEMENT(Frame)
 
 
 nsHTMLFrameElement::nsHTMLFrameElement(nsINodeInfo *aNodeInfo)
   : nsGenericHTMLFrameElement(aNodeInfo)
 {
 }
 
 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_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)
 NS_IMPL_STRING_ATTR(nsHTMLFrameElement, MarginHeight, marginheight)
 NS_IMPL_STRING_ATTR(nsHTMLFrameElement, MarginWidth, marginwidth)
 NS_IMPL_STRING_ATTR(nsHTMLFrameElement, Name, name)
deleted file mode 100644
--- a/content/html/content/src/nsHTMLFrameElement.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * 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 ***** */
-
-#ifndef nsHTMLFrameElement_h__
-#define nsHTMLFrameElement_h__
-
-#include "nsIDOMHTMLFrameElement.h"
-#include "nsGenericHTMLElement.h"
-
-class nsHTMLFrameElement : public nsGenericHTMLFrameElement,
-                           public nsIDOMHTMLFrameElement
-{
-public:
-  nsHTMLFrameElement(nsINodeInfo *aNodeInfo);
-  virtual ~nsHTMLFrameElement();
-
-  // nsISupports
-  NS_DECL_ISUPPORTS_INHERITED
-
-  // nsIDOMNode
-  NS_FORWARD_NSIDOMNODE(nsGenericHTMLFrameElement::)
-
-  // nsIDOMElement
-  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFrameElement::)
-
-  // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFrameElement::)
-
-  // nsIDOMHTMLFrameElement
-  NS_DECL_NSIDOMHTMLFRAMEELEMENT
-
-  // nsIContent
-  virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
-                                nsIAtom* aAttribute,
-                                const nsAString& aValue,
-                                nsAttrValue& aResult);
-  NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
-  nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-};
-
-#endif
--- a/content/html/content/src/nsHTMLFrameSetElement.cpp
+++ b/content/html/content/src/nsHTMLFrameSetElement.cpp
@@ -29,25 +29,101 @@
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * 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 "nsHTMLFrameSetElement.h"
+#include "nsIDOMHTMLFrameSetElement.h"
 #include "nsIDOMEventTarget.h"
+#include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
+#include "nsIFrameSetElement.h"
 #include "nsIHTMLDocument.h"
 #include "nsIDocument.h"
 
+class nsHTMLFrameSetElement : public nsGenericHTMLElement,
+                              public nsIDOMHTMLFrameSetElement,
+                              public nsIFrameSetElement
+{
+public:
+  nsHTMLFrameSetElement(nsINodeInfo *aNodeInfo);
+  virtual ~nsHTMLFrameSetElement();
+
+  // nsISupports
+  NS_DECL_ISUPPORTS_INHERITED
+
+  // nsIDOMNode
+  NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
+
+  // nsIDOMElement
+  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
+
+  // nsIDOMHTMLElement
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
+
+  // nsIDOMHTMLFrameSetElement
+  NS_DECL_NSIDOMHTMLFRAMESETELEMENT
+
+  // These override the SetAttr methods in nsGenericHTMLElement (need
+  // both here to silence compiler warnings).
+  nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
+                   const nsAString& aValue, PRBool aNotify)
+  {
+    return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
+  }
+  virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
+                           nsIAtom* aPrefix, const nsAString& aValue,
+                           PRBool aNotify);
+
+  // nsIFramesetElement
+  NS_IMETHOD GetRowSpec(PRInt32 *aNumValues, const nsFramesetSpec** aSpecs);
+  NS_IMETHOD GetColSpec(PRInt32 *aNumValues, const nsFramesetSpec** aSpecs);
+
+  virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
+                                nsIAtom* aAttribute,
+                                const nsAString& aValue,
+                                nsAttrValue& aResult);
+  virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
+                                              PRInt32 aModType) const;
+
+  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+
+private:
+  nsresult ParseRowCol(const nsAString& aValue,
+                       PRInt32&         aNumSpecs,
+                       nsFramesetSpec** aSpecs);
+
+  /**
+   * The number of size specs in our "rows" attr
+   */
+  PRInt32          mNumRows;
+  /**
+   * The number of size specs in our "cols" attr
+   */
+  PRInt32          mNumCols;
+  /**
+   * The style hint to return for the rows/cols attrs in
+   * GetAttributeChangeHint
+   */
+  nsChangeHint      mCurrentRowColHint;
+  /**
+   * The parsed representation of the "rows" attribute
+   */
+  nsAutoArrayPtr<nsFramesetSpec>  mRowSpecs; // parsed, non-computed dimensions
+  /**
+   * The parsed representation of the "cols" attribute
+   */
+  nsAutoArrayPtr<nsFramesetSpec>  mColSpecs; // parsed, non-computed dimensions
+};
+
 NS_IMPL_NS_NEW_HTML_ELEMENT(FrameSet)
 
 
 nsHTMLFrameSetElement::nsHTMLFrameSetElement(nsINodeInfo *aNodeInfo)
   : nsGenericHTMLElement(aNodeInfo), mNumRows(0), mNumCols(0),
     mCurrentRowColHint(NS_STYLE_HINT_REFLOW)
 {
 }
@@ -56,16 +132,25 @@ 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_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)
 
 nsresult
 nsHTMLFrameSetElement::SetAttr(PRInt32 aNameSpaceID,
deleted file mode 100644
--- a/content/html/content/src/nsHTMLFrameSetElement.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * 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 ***** */
-
-#ifndef nsHTMLFrameSetElement_h__
-#define nsHTMLFrameSetElement_h__
-
-#include "nsIDOMHTMLFrameSetElement.h"
-#include "nsIFrameSetElement.h"
-#include "nsGenericHTMLElement.h"
-
-class nsHTMLFrameSetElement : public nsGenericHTMLElement,
-                              public nsIDOMHTMLFrameSetElement,
-                              public nsIFrameSetElement
-{
-public:
-  nsHTMLFrameSetElement(nsINodeInfo *aNodeInfo);
-  virtual ~nsHTMLFrameSetElement();
-
-  // nsISupports
-  NS_DECL_ISUPPORTS_INHERITED
-
-  // nsIDOMNode
-  NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
-
-  // nsIDOMElement
-  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
-
-  // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
-
-  // nsIDOMHTMLFrameSetElement
-  NS_DECL_NSIDOMHTMLFRAMESETELEMENT
-
-  // These override the SetAttr methods in nsGenericHTMLElement (need
-  // both here to silence compiler warnings).
-  nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
-                   const nsAString& aValue, PRBool aNotify)
-  {
-    return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify);
-  }
-  virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
-                           nsIAtom* aPrefix, const nsAString& aValue,
-                           PRBool aNotify);
-
-  // nsIFramesetElement
-  NS_IMETHOD GetRowSpec(PRInt32 *aNumValues, const nsFramesetSpec** aSpecs);
-  NS_IMETHOD GetColSpec(PRInt32 *aNumValues, const nsFramesetSpec** aSpecs);
-
-  virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
-                                nsIAtom* aAttribute,
-                                const nsAString& aValue,
-                                nsAttrValue& aResult);
-  virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
-                                              PRInt32 aModType) const;
-
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-
-private:
-  nsresult ParseRowCol(const nsAString& aValue,
-                       PRInt32&         aNumSpecs,
-                       nsFramesetSpec** aSpecs);
-
-  /**
-   * The number of size specs in our "rows" attr
-   */
-  PRInt32          mNumRows;
-  /**
-   * The number of size specs in our "cols" attr
-   */
-  PRInt32          mNumCols;
-  /**
-   * The style hint to return for the rows/cols attrs in
-   * GetAttributeChangeHint
-   */
-  nsChangeHint      mCurrentRowColHint;
-  /**
-   * The parsed representation of the "rows" attribute
-   */
-  nsAutoArrayPtr<nsFramesetSpec>  mRowSpecs; // parsed, non-computed dimensions
-  /**
-   * The parsed representation of the "cols" attribute
-   */
-  nsAutoArrayPtr<nsFramesetSpec>  mColSpecs; // parsed, non-computed dimensions
-};
-
-#endif
--- a/content/html/content/src/nsHTMLIFrameElement.cpp
+++ b/content/html/content/src/nsHTMLIFrameElement.cpp
@@ -29,43 +29,84 @@
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * 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 "nsHTMLIFrameElement.h"
+#include "nsIDOMHTMLIFrameElement.h"
+#include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsIDocument.h"
 #include "nsMappedAttributes.h"
 #include "nsDOMError.h"
 #include "nsRuleData.h"
 #include "nsStyleConsts.h"
 
+class nsHTMLIFrameElement : public nsGenericHTMLFrameElement,
+                            public nsIDOMHTMLIFrameElement
+{
+public:
+  nsHTMLIFrameElement(nsINodeInfo *aNodeInfo);
+  virtual ~nsHTMLIFrameElement();
+
+  // nsISupports
+  NS_DECL_ISUPPORTS_INHERITED
+
+  // nsIDOMNode
+  NS_FORWARD_NSIDOMNODE(nsGenericHTMLFrameElement::)
+
+  // nsIDOMElement
+  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFrameElement::)
+
+  // nsIDOMHTMLElement
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFrameElement::)
+
+  // nsIDOMHTMLIFrameElement
+  NS_DECL_NSIDOMHTMLIFRAMEELEMENT
+
+  // nsIContent
+  virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
+                                nsIAtom* aAttribute,
+                                const nsAString& aValue,
+                                nsAttrValue& aResult);
+  NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
+  virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
+
+  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+};
+
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(IFrame)
 
+
 nsHTMLIFrameElement::nsHTMLIFrameElement(nsINodeInfo *aNodeInfo)
   : nsGenericHTMLFrameElement(aNodeInfo)
 {
 }
 
 nsHTMLIFrameElement::~nsHTMLIFrameElement()
 {
 }
 
 
 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_INHERITED1(nsHTMLIFrameElement, nsIDOMHTMLIFrameElement)
+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)
 NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, Height, height)
 NS_IMPL_URI_ATTR(nsHTMLIFrameElement, LongDesc, longdesc)
 NS_IMPL_STRING_ATTR(nsHTMLIFrameElement, MarginHeight, marginheight)
deleted file mode 100644
--- a/content/html/content/src/nsHTMLIFrameElement.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * 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 ***** */
-
-#ifndef nsHTMLIFrameElement_h__
-#define nsHTMLIFrameElement_h__
-
-#include "nsIFrameSetElement.h"
-#include "nsGenericHTMLElement.h"
-#include "nsIDOMHTMLIFrameElement.h"
-
-class nsHTMLIFrameElement : public nsGenericHTMLFrameElement,
-                            public nsIDOMHTMLIFrameElement
-{
-public:
-  nsHTMLIFrameElement(nsINodeInfo *aNodeInfo);
-  virtual ~nsHTMLIFrameElement();
-
-  // nsISupports
-  NS_DECL_ISUPPORTS_INHERITED
-
-  // nsIDOMNode
-  NS_FORWARD_NSIDOMNODE(nsGenericHTMLFrameElement::)
-
-  // nsIDOMElement
-  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFrameElement::)
-
-  // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFrameElement::)
-
-  // nsIDOMHTMLIFrameElement
-  NS_DECL_NSIDOMHTMLIFRAMEELEMENT
-
-  // nsIContent
-  virtual PRBool ParseAttribute(PRInt32 aNamespaceID,
-                                nsIAtom* aAttribute,
-                                const nsAString& aValue,
-                                nsAttrValue& aResult);
-  NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const;
-  virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
-
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-};
-
-#endif
--- a/content/html/content/src/nsHTMLSpanElement.cpp
+++ b/content/html/content/src/nsHTMLSpanElement.cpp
@@ -29,40 +29,73 @@
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * 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 "nsHTMLSpanElement.h"
+#include "nsIDOMHTMLElement.h"
 #include "nsIDOMEventTarget.h"
+#include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 #include "nsStyleConsts.h"
 #include "nsPresContext.h"
 #include "nsIAtom.h"
 #include "nsRuleData.h"
 
+class nsHTMLSpanElement : public nsGenericHTMLElement,
+                          public nsIDOMHTMLElement
+{
+public:
+  nsHTMLSpanElement(nsINodeInfo *aNodeInfo);
+  virtual ~nsHTMLSpanElement();
+
+  // nsISupports
+  NS_DECL_ISUPPORTS_INHERITED
+
+  // nsIDOMNode
+  NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
+
+  // nsIDOMElement
+  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
+
+  // nsIDOMHTMLElement
+  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
+
+  virtual nsresult GetInnerHTML(nsAString& aInnerHTML);
+  virtual nsresult SetInnerHTML(const nsAString& aInnerHTML);
+
+  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
+};
+
+
 NS_IMPL_NS_NEW_HTML_ELEMENT(Span)
 
+
 nsHTMLSpanElement::nsHTMLSpanElement(nsINodeInfo *aNodeInfo)
   : nsGenericHTMLElement(aNodeInfo)
 {
 }
 
 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_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLSpanElement)
+
+
 NS_IMPL_ELEMENT_CLONE(nsHTMLSpanElement)
 
 
 nsresult
 nsHTMLSpanElement::GetInnerHTML(nsAString& aInnerHTML)
 {
   if (mNodeInfo->Equals(nsGkAtoms::xmp) ||
       mNodeInfo->Equals(nsGkAtoms::plaintext)) {
deleted file mode 100644
--- a/content/html/content/src/nsHTMLSpanElement.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * 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 ***** */
-
-#ifndef nsHTMLSpanElement_h__
-#define nsHTMLSpanElement_h__
-
-#include "nsIDOMHTMLElement.h"
-#include "nsGenericHTMLElement.h"
-
-class nsHTMLSpanElement : public nsGenericHTMLElement,
-                          public nsIDOMHTMLElement
-{
-public:
-  nsHTMLSpanElement(nsINodeInfo *aNodeInfo);
-  virtual ~nsHTMLSpanElement();
-
-  // nsISupports
-  NS_DECL_ISUPPORTS_INHERITED
-
-  // nsIDOMNode
-  NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::)
-
-  // nsIDOMElement
-  NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::)
-
-  // nsIDOMHTMLElement
-  NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::)
-
-  virtual nsresult GetInnerHTML(nsAString& aInnerHTML);
-  virtual nsresult SetInnerHTML(const nsAString& aInnerHTML);
-
-  virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
-};
-
-#endif
--- a/content/html/document/src/Makefile.in
+++ b/content/html/document/src/Makefile.in
@@ -83,18 +83,16 @@ CPPSRCS		= \
 		nsHTMLDocument.cpp \
 		nsMediaDocument.cpp \
 		nsPluginDocument.cpp \
 		nsImageDocument.cpp \
 		nsWyciwygChannel.cpp \
 		nsWyciwygProtocolHandler.cpp \
 		$(NULL)
 
-GQI_SRCS = htmldocument.gqi
-
 EXPORTS		= \
 		nsIHTMLDocument.h \
 		$(NULL)
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/content/html/document/src/htmldocument.gqi
+++ /dev/null
@@ -1,17 +0,0 @@
-%import "contentbase.gqi"
-
-%import-idl "nsIDOMHTMLDocument.idl"
-%import-idl "nsIDOMNSHTMLDocument.idl"
-
-%{C++
-#include "nsHTMLDocument.h"
-%}
-
-%pseudo-iid nsIHTMLDocument bfd644d6-92cc-4560-a329-f02ba0c91ca5
-
-NS_INTERFACE_MAP_BEGIN(nsHTMLDocument, nsDocument)
-  NS_INTERFACE_MAP_ENTRY(nsIHTMLDocument)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLDocument)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLDocument)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(HTMLDocument)
-NS_INTERFACE_MAP_END
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -412,16 +412,28 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mForms, nsIDOMNodeList)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mFormControls,
                                                        nsIDOMNodeList)
 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_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLDocument)
+NS_INTERFACE_MAP_END_INHERITING(nsDocument)
+
+
 nsresult
 nsHTMLDocument::Init()
 {
   nsresult rv = nsDocument::Init();
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Now reset the case-sensitivity of the CSSLoader, since we default
   // to being HTML, not XHTML.  Also, reset the compatibility mode to
--- a/content/xml/document/src/Makefile.in
+++ b/content/xml/document/src/Makefile.in
@@ -73,18 +73,16 @@ REQUIRES	= xpcom \
 
 CPPSRCS		= \
 		nsXMLContentSink.cpp \
 		nsXMLFragmentContentSink.cpp \
 		nsXMLDocument.cpp \
 		nsXMLPrettyPrinter.cpp \
 		$(NULL)
 
-GQI_SRCS = xmldocument.gqi
-
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES	= \
 		-I$(srcdir) \
 		-I$(srcdir)/../../../xsl/document/src \
--- a/content/xml/document/src/nsXMLDocument.cpp
+++ b/content/xml/document/src/nsXMLDocument.cpp
@@ -188,16 +188,27 @@ 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_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(XMLDocument)
+NS_INTERFACE_MAP_END_INHERITING(nsDocument)
+
+
 NS_IMPL_ADDREF_INHERITED(nsXMLDocument, nsDocument)
 NS_IMPL_RELEASE_INHERITED(nsXMLDocument, nsDocument)
 
 
 nsresult
 nsXMLDocument::Init()
 {
   nsresult rv = nsDocument::Init();
deleted file mode 100644
--- a/content/xml/document/src/xmldocument.gqi
+++ /dev/null
@@ -1,16 +0,0 @@
-%import "contentbase.gqi"
-
-%import-idl "nsIDOMXMLDocument.idl"
-%import-idl "nsIInterfaceRequestor.idl"
-%import-idl "nsIChannelEventSink.idl"
-
-%{C++
-#include "nsXMLDocument.h"
-%}
-
-NS_INTERFACE_MAP_BEGIN(nsXMLDocument, nsDocument)
-  NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
-  NS_INTERFACE_MAP_ENTRY(nsIChannelEventSink)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMXMLDocument)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XMLDocument)
-NS_INTERFACE_MAP_END
--- a/content/xul/document/src/Makefile.in
+++ b/content/xul/document/src/Makefile.in
@@ -70,18 +70,16 @@ REQUIRES	= xpcom \
 		  webshell \
 		  unicharutil \
 		  appshell \
 		  util \
 		  $(NULL)
 
 CPPSRCS		= nsXULControllers.cpp
 
-GQI_SRCS        = xuldocument.gqi
-
 ifdef MOZ_XUL
 CPPSRCS		+= \
 		nsElementMap.cpp \
 		nsXULCommandDispatcher.cpp \
 		nsXULContentSink.cpp \
 		nsXULDocument.cpp \
 		nsXULPrototypeCache.cpp \
 		nsXULPrototypeDocument.cpp \
--- a/content/xul/document/src/nsXULDocument.cpp
+++ b/content/xul/document/src/nsXULDocument.cpp
@@ -352,16 +352,29 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
         tmp->mOverlayLoadObservers.EnumerateRead(TraverseObservers, &cb);
     if (tmp->mPendingOverlayLoadNotifications.IsInitialized())
         tmp->mPendingOverlayLoadNotifications.EnumerateRead(TraverseObservers, &cb);
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_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_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(XULDocument)
+NS_INTERFACE_MAP_END_INHERITING(nsXMLDocument)
+
+
 //----------------------------------------------------------------------
 //
 // nsIDocument interface
 //
 
 void
 nsXULDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
 {
deleted file mode 100644
--- a/content/xul/document/src/xuldocument.gqi
+++ /dev/null
@@ -1,19 +0,0 @@
-%import "xmldocument.gqi"
-
-%import-idl "nsIDOMXULDocument.idl"
-%import-idl "nsIStreamLoader.idl"
-
-%pseudo-iid nsICSSLoaderObserver  f5e8eb0f-4c44-49d5-b1e9-ab392393c0f8
-%pseudo-iid nsIXULDocument 57314526-f749-4cf0-b6b6-3723eba21480
-
-%{C++
-#include "nsXULDocument.h"
-%}
-
-NS_INTERFACE_MAP_BEGIN(nsXULDocument, nsXMLDocument)
-  NS_INTERFACE_MAP_ENTRY(nsIXULDocument)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMXULDocument)
-  NS_INTERFACE_MAP_ENTRY(nsIStreamLoaderObserver)
-  NS_INTERFACE_MAP_ENTRY(nsICSSLoaderObserver)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XULDocument)
-NS_INTERFACE_MAP_END
--- a/dom/src/base/Makefile.in
+++ b/dom/src/base/Makefile.in
@@ -111,18 +111,16 @@ CPPSRCS =			\
 	nsMimeTypeArray.cpp	\
 	nsPluginArray.cpp	\
 	nsWindowRoot.cpp	\
 	nsDOMClassInfo.cpp	\
 	nsScriptNameSpaceManager.cpp \
 	nsDOMScriptObjectFactory.cpp \
 	$(NULL)
 
-GQI_SRCS = dombase.gqi
-
 # we don't want the shared lib, but we want to force the creation of a
 # static lib.
 FORCE_STATIC_LIB = 1
 
 LOCAL_INCLUDES = \
 		-I$(srcdir)/../events \
 		-I$(srcdir)/../storage \
 		-I$(srcdir)/../offline \
deleted file mode 100644
--- a/dom/src/base/dombase.gqi
+++ /dev/null
@@ -1,44 +0,0 @@
-%import-idl "nsIDOMWindowInternal.idl"
-%import-idl "nsIDOMWindow2.idl"
-%import-idl "nsIDOMJSWindow.idl"
-%import-idl "nsIDOMEventTarget.idl"
-%import-idl "nsIDOM3EventTarget.idl"
-%import-idl "nsIDOMNSEventTarget.idl"
-%import-idl "nsIDOMViewCSS.idl"
-%import-idl "nsIDOMAbstractView.idl"
-%import-idl "nsIDOMStorageWindow.idl"
-%import-idl "nsIWeakReference.idl"
-%import-idl "nsIInterfaceRequestor.idl"
-
-%pseudo-iid nsIScriptGlobalObject 6afecd40-0b9a-4cfd-8c42-0f645cd91829
-%pseudo-iid nsIScriptObjectPrincipal  3eedba38-8d22-41e1-817a-0e43e165b664
-%pseudo-iid nsPIDOMEventTarget  44a6597b-9fc3-4a8d-b7a4-d9009abf9d15
-%pseudo-iid nsPIDOMWindow 909852b5-b9e6-4d94-8de3-051634800b73
-
-%{C++
-#include "nsGlobalWindow.h"
-#include "nsDOMClassInfo.h"
-%}
-
-// QueryInterface implementation for nsGlobalWindow
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindow)
-  // Make sure this matches the cast in nsGlobalWindow::FromWrapper()
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIScriptGlobalObject)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMWindowInternal)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMWindow)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMWindow2)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMJSWindow)
-  NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObject)
-  NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
-  NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
-  NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMNSEventTarget)
-  NS_INTERFACE_MAP_ENTRY(nsPIDOMWindow)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMViewCSS)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMAbstractView)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMStorageWindow)
-  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
-  NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Window)
-NS_INTERFACE_MAP_END
--- a/dom/src/base/nsGlobalWindow.cpp
+++ b/dom/src/base/nsGlobalWindow.cpp
@@ -919,16 +919,40 @@ nsGlobalWindow::FreeInnerObjects(PRBool 
 }
 
 //*****************************************************************************
 // nsGlobalWindow::nsISupports
 //*****************************************************************************
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalWindow)
 
+// QueryInterface implementation for nsGlobalWindow
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindow)
+  // Make sure this matches the cast in nsGlobalWindow::FromWrapper()
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIScriptGlobalObject)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMWindowInternal)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMWindow)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMWindow2)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMJSWindow)
+  NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObject)
+  NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
+  NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
+  NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMNSEventTarget)
+  NS_INTERFACE_MAP_ENTRY(nsPIDOMWindow)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMViewCSS)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMAbstractView)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMStorageWindow)
+  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
+  NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
+  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Window)
+NS_INTERFACE_MAP_END
+
+
 NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(nsGlobalWindow, nsIScriptGlobalObject)
 NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS(nsGlobalWindow,
                                            nsIScriptGlobalObject)
 
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsGlobalWindow)
   if (tmp->mDoc && nsCCUncollectableMarker::InGeneration(
                      tmp->mDoc->GetMarkedCCGeneration())) {
--- a/netwerk/base/src/Makefile.in
+++ b/netwerk/base/src/Makefile.in
@@ -90,19 +90,16 @@ CPPSRCS		= \
 		nsURIChecker.cpp \
 		nsURLHelper.cpp \
 		nsURLParsers.cpp \
 		nsNetStrings.cpp \
 		nsBase64Encoder.cpp \
 		nsSerializationHelper.cpp \
 		$(NULL)
 
-GQI_SRCS = neckobase.gqi
-LOCAL_INCLUDES = -I$(topsrcdir)/xpcom/ds
-
 ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
 	CPPSRCS += nsURLHelperOS2.cpp
 else
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 	CPPSRCS += nsURLHelperWin.cpp
 ifneq ($(OS_ARCH), WINCE)
 	CPPSRCS += nsNativeConnectionHelper.cpp
 	CPPSRCS += nsAutodialWin.cpp
deleted file mode 100644
--- a/netwerk/base/src/neckobase.gqi
+++ /dev/null
@@ -1,82 +0,0 @@
-%import-idl "nsIStandardURL.idl"
-%import-idl "nsIURL.idl"
-%import-idl "nsIFileURL.idl"
-%import-idl "nsISerializable.idl"
-%import-idl "nsIClassInfo.idl"
-%import-idl "nsIIOService2.idl"
-%import-idl "nsINetUtil.idl"
-%import-idl "nsIObserver.idl"
-%import-idl "nsIWeakReference.idl"
-%import-idl "nsIChannel.idl"
-%import-idl "nsIInterfaceRequestor.idl"
-%import-idl "nsITransport.idl"
-%import-idl "nsIStreamListener.idl"
-%import-idl "nsISocketTransportService.idl"
-%import-idl "nsIEventTarget.idl"
-%import-idl "nsIThreadInternal.idl"
-%import-idl "nsIRunnable.idl"
-%import-idl "nsPISocketTransportService.idl"
-%import-idl "nsISocketTransport.idl"
-%import-idl "nsIDNSListener.idl"
-
-%import "xpcomds.gqi"
-
-%{C++
-#include "nsStandardURL.h"
-#include "nsIOService.h"
-#include "nsBaseChannel.h"
-#include "nsSocketTransportService2.h"
-#include "nsSocketTransport2.h"
-%}
-
-// See nsStandardURL.h
-%pseudo-cid nsStandardURL b8e3e97b-1ccd-4b45-af5a-79596770f5d7 NS_THIS_STANDARDURL_IMPL_CID
-
-NS_INTERFACE_MAP_BEGIN(nsStandardURL)
-    NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStandardURL)
-    NS_INTERFACE_MAP_ENTRY(nsIURI)
-    NS_INTERFACE_MAP_ENTRY(nsIURL)
-    NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIFileURL, mSupportsFileURL)
-    NS_INTERFACE_MAP_ENTRY(nsIStandardURL)
-    NS_INTERFACE_MAP_ENTRY(nsISerializable)
-    NS_INTERFACE_MAP_ENTRY(nsIClassInfo)
-    NS_INTERFACE_MAP_ENTRY(nsIMutable)
-    NS_INTERFACE_MAP_ENTRY(NS_THIS_STANDARDURL_IMPL_CID)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_THREADSAFE_ISUPPORTS5(nsIOService,
-                              nsIIOService,
-                              nsIIOService2,
-                              nsINetUtil,
-                              nsIObserver,
-                              nsISupportsWeakReference)
-
-NS_IMPL_ISUPPORTS_INHERITED6(nsBaseChannel,
-                             nsHashPropertyBag,
-                             nsIRequest,
-                             nsIChannel,
-                             nsIInterfaceRequestor,
-                             nsITransportEventSink,
-                             nsIRequestObserver,
-                             nsIStreamListener)
-
-NS_IMPL_THREADSAFE_ISUPPORTS5(nsSocketTransportService,
-                              nsISocketTransportService,
-                              nsIEventTarget,
-                              nsIThreadObserver,
-                              nsIRunnable,
-                              nsPISocketTransportService)
-
-NS_IMPL_THREADSAFE_ISUPPORTS4(nsSocketTransport,
-                              nsISocketTransport,
-                              nsITransport,
-                              nsIDNSListener,
-                              nsIClassInfo)
-
-%{C++
-NS_IMPL_CI_INTERFACE_GETTER3(nsSocketTransport,
-                             nsISocketTransport,
-                             nsITransport,
-                             nsIDNSListener)
-
-%}
--- a/netwerk/base/src/nsBaseChannel.cpp
+++ b/netwerk/base/src/nsBaseChannel.cpp
@@ -230,16 +230,28 @@ nsBaseChannel::BeginPumpingData()
                                  PR_TRUE);
   if (NS_SUCCEEDED(rv))
     rv = mPump->AsyncRead(this, nsnull);
 
   return rv;
 }
 
 //-----------------------------------------------------------------------------
+// nsBaseChannel::nsISupports
+
+NS_IMPL_ISUPPORTS_INHERITED6(nsBaseChannel,
+                             nsHashPropertyBag,
+                             nsIRequest,
+                             nsIChannel,
+                             nsIInterfaceRequestor,
+                             nsITransportEventSink,
+                             nsIRequestObserver,
+                             nsIStreamListener)
+
+//-----------------------------------------------------------------------------
 // nsBaseChannel::nsIRequest
 
 NS_IMETHODIMP
 nsBaseChannel::GetName(nsACString &result)
 {
   if (!mURI) {
     result.Truncate();
     return NS_OK;
--- a/netwerk/base/src/nsIOService.cpp
+++ b/netwerk/base/src/nsIOService.cpp
@@ -273,16 +273,23 @@ nsIOService::GetInstance() {
             return nsnull;
         }
         return gIOService;
     }
     NS_ADDREF(gIOService);
     return gIOService;
 }
 
+NS_IMPL_THREADSAFE_ISUPPORTS5(nsIOService,
+                              nsIIOService,
+                              nsIIOService2,
+                              nsINetUtil,
+                              nsIObserver,
+                              nsISupportsWeakReference)
+
 ////////////////////////////////////////////////////////////////////////////////
 
 nsresult
 nsIOService::OnChannelRedirect(nsIChannel* oldChan, nsIChannel* newChan,
                                PRUint32 flags)
 {
     nsCOMPtr<nsIChannelEventSink> sink =
         do_GetService(NS_GLOBAL_CHANNELEVENTSINK_CONTRACTID);
--- a/netwerk/base/src/nsSocketTransport2.cpp
+++ b/netwerk/base/src/nsSocketTransport2.cpp
@@ -1595,16 +1595,26 @@ nsSocketTransport::OnSocketDetached(PRFi
         mCallbacks = nsnull;
         mEventSink = nsnull;
     }
 }
 
 //-----------------------------------------------------------------------------
 // xpcom api
 
+NS_IMPL_THREADSAFE_ISUPPORTS4(nsSocketTransport,
+                              nsISocketTransport,
+                              nsITransport,
+                              nsIDNSListener,
+                              nsIClassInfo)
+NS_IMPL_CI_INTERFACE_GETTER3(nsSocketTransport,
+                             nsISocketTransport,
+                             nsITransport,
+                             nsIDNSListener)
+
 NS_IMETHODIMP
 nsSocketTransport::OpenInputStream(PRUint32 flags,
                                    PRUint32 segsize,
                                    PRUint32 segcount,
                                    nsIInputStream **result)
 {
     LOG(("nsSocketTransport::OpenInputStream [this=%x flags=%x]\n",
         this, flags));
--- a/netwerk/base/src/nsSocketTransport2.h
+++ b/netwerk/base/src/nsSocketTransport2.h
@@ -49,17 +49,17 @@
 
 #include "nsISocketTransport.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIAsyncInputStream.h"
 #include "nsIAsyncOutputStream.h"
 #include "nsIDNSListener.h"
 #include "nsIDNSRecord.h"
 #include "nsICancelable.h"
-#include "nsIClassInfoImpl.h"
+#include "nsIClassInfo.h"
 
 class nsSocketTransport;
 
 //-----------------------------------------------------------------------------
 
 // after this short interval, we will return to PR_Poll
 #define NS_SOCKET_CONNECT_TIMEOUT PR_MillisecondsToInterval(20)
 
@@ -314,11 +314,9 @@ private:
     }
 
 #ifdef ENABLE_SOCKET_TRACING
     void TraceInBuf(const char *buf, PRInt32 n);
     void TraceOutBuf(const char *buf, PRInt32 n);
 #endif
 };
 
-NS_DECL_CI_INTERFACE_GETTER(nsSocketTransport)
-
 #endif // !nsSocketTransport_h__
--- a/netwerk/base/src/nsSocketTransportService2.cpp
+++ b/netwerk/base/src/nsSocketTransportService2.cpp
@@ -349,16 +349,26 @@ nsSocketTransportService::Poll(PRBool wa
 
     LOG(("    ...returned after %i milliseconds\n",
          PR_IntervalToMilliseconds(passedInterval))); 
 
     *interval = PR_IntervalToSeconds(passedInterval);
     return rv;
 }
 
+//-----------------------------------------------------------------------------
+// xpcom api
+
+NS_IMPL_THREADSAFE_ISUPPORTS5(nsSocketTransportService,
+                              nsISocketTransportService,
+                              nsIEventTarget,
+                              nsIThreadObserver,
+                              nsIRunnable,
+                              nsPISocketTransportService)
+
 // called from main thread only
 NS_IMETHODIMP
 nsSocketTransportService::Init()
 {
     NS_ENSURE_TRUE(mLock, NS_ERROR_OUT_OF_MEMORY);
 
     if (!NS_IsMainThread()) {
         NS_ERROR("wrong thread");
--- a/netwerk/base/src/nsStandardURL.cpp
+++ b/netwerk/base/src/nsStandardURL.cpp
@@ -843,16 +843,31 @@ nsStandardURL::PrefsChanged(nsIPrefBranc
 
 //----------------------------------------------------------------------------
 // nsStandardURL::nsISupports
 //----------------------------------------------------------------------------
 
 NS_IMPL_ADDREF(nsStandardURL)
 NS_IMPL_RELEASE(nsStandardURL)
 
+NS_INTERFACE_MAP_BEGIN(nsStandardURL)
+    NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStandardURL)
+    NS_INTERFACE_MAP_ENTRY(nsIURI)
+    NS_INTERFACE_MAP_ENTRY(nsIURL)
+    NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIFileURL, mSupportsFileURL)
+    NS_INTERFACE_MAP_ENTRY(nsIStandardURL)
+    NS_INTERFACE_MAP_ENTRY(nsISerializable)
+    NS_INTERFACE_MAP_ENTRY(nsIClassInfo)
+    NS_INTERFACE_MAP_ENTRY(nsIMutable)
+    // see nsStandardURL::Equals
+    if (aIID.Equals(kThisImplCID))
+        foundInterface = static_cast<nsIURI *>(this);
+    else
+NS_INTERFACE_MAP_END
+
 //----------------------------------------------------------------------------
 // nsStandardURL::nsIURI
 //----------------------------------------------------------------------------
 
 // result may contain unescaped UTF-8 characters
 NS_IMETHODIMP
 nsStandardURL::GetSpec(nsACString &result)
 {
--- a/netwerk/base/src/nsStandardURL.h
+++ b/netwerk/base/src/nsStandardURL.h
@@ -268,17 +268,16 @@ private:
     static nsIIDNService               *gIDN;
     static nsICharsetConverterManager  *gCharsetMgr;
     static PRBool                       gInitialized;
     static PRBool                       gEscapeUTF8;
     static PRBool                       gAlwaysEncodeInUTF8;
     static PRBool                       gEncodeQueryInUTF8;
 };
 
-/* If you change this CID, make sure you also update neckobase.gqi */
 #define NS_THIS_STANDARDURL_IMPL_CID                 \
 { /* b8e3e97b-1ccd-4b45-af5a-79596770f5d7 */         \
     0xb8e3e97b,                                      \
     0x1ccd,                                          \
     0x4b45,                                          \
     {0xaf, 0x5a, 0x79, 0x59, 0x67, 0x70, 0xf5, 0xd7} \
 }
 
deleted file mode 100644
--- a/xpcom/base/gqi.py
+++ /dev/null
@@ -1,883 +0,0 @@
-# -*- Mode: Python: tab-width: 8; indent-tabs-mode: nil; python-indent: 4 -*-
-
-"""Implement QueryInterface using optimized generated code."""
-
-import os, posixpath, errno, re, sys, sets
-
-# Global controlling debug output to sys.stderr
-debug = False
-
-def findfile(f, curfile, includedirs):
-    """Find a file 'f' by looking in the directory of the current file
-    and then in all directories specified by -I until it is found. Returns
-    the path of the file that was found.
-
-    @raises IOError is the file is not found."""
-
-    sdirs = [os.path.dirname(curfile)]
-    sdirs.extend(includedirs)
-
-    for dir in sdirs:
-        t = posixpath.join(dir, f)
-        if os.path.exists(t):
-            return t
-
-    raise IOError(errno.ENOENT, "File not found", f)
-
-# Giant parsing loop: parse input files into the internal representation,
-# keeping track of file/line numbering information. This iterator automatically
-# skips blank lines and lines beginning with //
-
-class IterFile(object):
-    def __init__(self, file):
-        self._file = file
-        self._iter = open(file)
-        self._lineno = 0
-
-    def __iter__(self):
-        return self
-
-    def next(self):
-        self._lineno += 1
-        line = self._iter.next().strip()
-        if line == '' or line.startswith('//'):
-            return self.next()
-        return line
-
-    def loc(self):
-        return "%s:%i" % (self._file, self._lineno)
-
-class uniqdict(dict):
-    """A subclass of dict that will throw an error if you attempt to set the same key to different values."""
-    def __setitem__(self, key, value):
-        if key in self and not value == self[key]:
-            raise IndexError('Key "%s" already present in uniqdict' % key)
-
-        dict.__setitem__(self, key, value)
-
-    def update(self, d):
-        for key, value in d.iteritems():
-            if key in self and not value == self[key]:
-                raise IndexError('Key "%s" already present in uniqdict' % key)
-
-        dict.update(self, d)
-
-def dump_hex_tuple(t):
-    return "(%s)" % ", ".join(["%#x" % i for i in t])
-
-class UUID(object):
-    type = 'UUID'
-
-    def __init__(self, name, iidstr, base=None):
-        """This method *assumes* that the UUID is validly formed."""
-        self.name = name
-        self.base = base
-
-        # iid is in 32-16-16-8*8 format, as hex *strings*
-        iid = (iidstr[0:8], iidstr[9:13], iidstr[14:18],
-               iidstr[19:21], iidstr[21:23], iidstr[24:26], iidstr[26:28],
-               iidstr[28:30], iidstr[30:32], iidstr[32:34], iidstr[34:36])
-
-        self.iid = iid
-
-        # (big_endian_words, little_endian_words)
-        self.words = (
-            (int(iid[0], 16),
-             int(iid[1] + iid[2], 16),
-             int("".join([iid[i] for i in xrange(3, 7)]), 16),
-             int("".join([iid[i] for i in xrange(7, 11)]), 16)),
-            (int(iid[0], 16),
-             int(iid[2] + iid[1], 16),
-             int("".join([iid[i] for i in xrange(6, 2, -1)]), 16),
-             int("".join([iid[i] for i in xrange(10, 6, -1)]), 16)))
-
-        if debug:
-            print >>sys.stderr, "%r" % self
-            print >>sys.stderr, "  bigendian: %s" % dump_hex_tuple(self.words[False])
-            print >>sys.stderr, "  littleendian: %r" % dump_hex_tuple(self.words[True])
-
-    def __eq__(self, uuid):
-        return self.iid == uuid.iid and self.name == uuid.name
-
-    def __repr__(self):
-        return """%s(%r, "%s-%s-%s-%s-%s", base=%r)""" % (
-            self.type, self.name,
-            self.iid[0], self.iid[1], self.iid[2], self.iid[3] + self.iid[4],
-            "".join([self.iid[i] for i in xrange(5, 11)]), self.base)
-
-    def asstruct(self):
-        return "{ 0x%s, 0x%s, 0x%s, { 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s } }" % self.iid
-
-    def decl(self):
-        return ""
-
-    def ref(self):
-        return "NS_GET_IID(%s)" % self.name
-
-class PseudoUUID(UUID):
-    type = 'PseudoUUID'
-
-    # No special init method needed
-
-    def decl(self):
-        return """
-        #ifdef DEBUG
-        static const nsID kGQI_%(iname)s = %(struct)s;
-        NS_ASSERTION(NS_GET_IID(%(iname)s).Equals(kGQI_%(iname)s),
-                     "GQI pseudo-IID doesn't match reality.");
-        #endif
-        """ % {
-            'iname': self.name,
-            'struct': self.asstruct()
-            }
-
-class CID(UUID):
-    type = 'CID'
-
-    def __init__(self, name, iid, decl):
-        UUID.__init__(self, name, iid)
-        self.pdecl = decl
-
-    def decl(self):
-        return """
-        static const nsID kGQI_%(pdecl)s = %(struct)s;
-        #ifdef DEBUG
-        static const nsID kGQI_TEST_%(pdecl)s = %(pdecl)s;
-        #endif
-        NS_ASSERTION(kGQI_%(pdecl)s.Equals(kGQI_TEST_%(pdecl)s),
-                     "GQI pseudo-IID doesn't match reality.");
-        """ % {
-            'pdecl': self.pdecl,
-            'struct': self.asstruct()
-            }
-
-    def ref(self):
-        return "kGQI_%s" % self.pdecl
-
-_uuid_pattern_string = r'[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}'
-
-_includefinder = re.compile(r'#include\s+(?:"|\<)(?P<filename>[a-z\.\-\_0-9]+)(?:"|\>)\s*$', re.I)
-_uuidfinder = re.compile(r'uuid\((?P<iid>' + _uuid_pattern_string + r')\)', re.I)
-_namefinder = re.compile(r'interface\s+(?P<interface>[A-Za-z_0-9]+)\s+:\s+(?P<base>[A-Za-z]+)')
-
-def importidl(file, includedirs):
-    """Parse an IDL file. Returns (mapofiids, setofdeps)"""
-
-    iids = {}
-    deps = sets.Set()
-    deps.add(file)
-
-    f = IterFile(file)
-    for line in f:
-        if line.startswith('%{'):
-            # Skip literal IDL blocks such as %{C++ %}
-            for line in f:
-                if line.startswith('%}'):
-                    break
-            continue
-
-        m = _includefinder.match(line)
-        if m is not None:
-            importediids, importeddeps = importidl(findfile(m.group('filename'), file, includedirs), includedirs)
-            iids.update(importediids)
-            deps |= importeddeps
-            continue
-
-        m = _uuidfinder.search(line)
-        if m is not None:
-            iid = m.group('iid')
-            line = f.next()
-            if line == 'interface nsISupports {':
-                iids['nsISupports'] = UUID('nsISupports', iid)
-            else:
-                m = _namefinder.match(line)
-                if m is None:
-                    raise Exception("%s: expected interface" % f.loc())
-
-                iids[m.group('interface')] = \
-                    UUID(m.group('interface'), iid, base=m.group('base'))
-
-    return iids, deps
-
-def gqi(ifaces, endian):
-    """Find an algorithm that uniquely identifies interfaces by a single
-    word. Returns (indexfunction, table)"""
-    for bits in xrange(3, 11):
-        bitmask = (1 << bits) - 1
-        for word in xrange(0, 4):
-            for sh in xrange(0, 33 - bits):
-                shmask = bitmask << sh
-
-                if debug:
-                    print "Trying word: %i, bits: %i, shift: %i" % (word, bits, sh)
-
-                l = list([None for i in xrange(0, 1 << bits)])
-                try:
-                    for i in xrange(0, len(ifaces)):
-                        n = (ifaces[i].uuid.words[endian][word] & shmask) >> sh
-                        if l[n] is not None:
-                            if debug:
-                                print "found conflict, index %i" % n
-                                print "old iface: %s" % ifaces[l[n]].uuid
-                                print "new iface: %s" % ifaces[i].uuid
-                            raise IndexError()
-
-                        l[n] = i
-
-                except IndexError:
-                    continue
-    
-                # If we got here, we're ok... create the table we want
-                indexfunc = "(reinterpret_cast<const PRUint32*>(&aIID)[%i] & 0x%x) >> %i" % (word, shmask, sh)
-                return indexfunc, l
-
-    raise Exception("No run of 10 bits within a word was unique!: interfaces: %s" % [i.uuid for i in ifaces])
-
-def basecast(item, baselist):
-    """Returns a string where an item is static_cast through a list of bases."""
-    for base in baselist:
-        item = "static_cast<%s*>(%s)" % (base, item)
-
-    return item
-
-class QIImpl(object):
-    _default_unfound = """
-      *aResult = nsnull;
-      return NS_NOINTERFACE;
-    """
-
-    _qiimpl = """
-    enum %(cname)s_QIActionType {
-      %(actionenums)s
-    };
-
-    struct %(cname)s_QIAction {
-      const nsID *iid;
-      %(actiontype)s
-      union {
-        void *ptr;
-        %(actiondata)s
-      } data;
-    };
-
-    NS_IMETHODIMP %(cname)s::QueryInterface(REFNSIID aIID, void **aResult)
-    {
-      %(uuiddecls)s
-
-      static const PRUint8 kLookupTable[] = {
-#ifdef IS_BIG_ENDIAN
-        %(biglookup)s
-#else
-        %(littlelookup)s
-#endif
-      };
-
-      static const %(cname)s_QIAction kActionTable[] = {
-        %(actiontable)s
-      };
-
-      nsISupports* found = nsnull;
-      const %(cname)s_QIAction *entry;
-      PRUint32 index =
-#ifdef IS_BIG_ENDIAN
-        %(bigindexfunc)s;
-#else
-        %(littleindexfunc)s;
-#endif
-
-      PRUint8 action = kLookupTable[index];
-      if (action == 0xFF)
-        goto unfound;
-
-      entry = kActionTable + action;
-      if (!entry->iid->Equals(aIID))
-        goto unfound;
-
-      %(actioncode)s
-
-      NS_NOTREACHED("Unhandled case?");
-
-      %(nullcheck)s
-
-    exit_addref:
-      NS_ASSERTION(found, "Interface should have been found by now.");
-      found->AddRef();
-      *aResult = found;
-      return NS_OK;
-
-    unfound:
-      %(unfound)s
-    }"""
-
-    _datatypes = """
-        %(type)s %(name)s;
-    """
-
-    _actiontable_entry = """
-        {
-          &(%(iref)s),
-          %(enumtype)s
-          %(emitTable)s
-        },
-    """
-
-    _actioncode_multi = """
-      switch (entry->action) {
-      %s
-      }
-    """
-
-    _actioncode_multi_entry = """
-      case %(cname)s_%(enumtype)s:
-        %(setResult)s
-    """
-
-    _nullcheck = """
-    exit_nullcheck_addref:
-      if (!found)
-        return NS_ERROR_OUT_OF_MEMORY;
-    """
-
-    _refcounting = """
-    NS_IMPL_%(threadsafe)sADDREF(%(cname)s)
-    NS_IMPL_%(threadsafe)sRELEASE(%(cname)s)
-    """
-
-    def __init__(self, cname, ifaces, emitrefcount=False,
-                 threadsafe="", unfound=None, base=None):
-        self.cname = cname
-        self.emitrefcount = emitrefcount
-        self.threadsafe = threadsafe
-        self.base = base
-        self.ifaces = ifaces
-        self.unfound = unfound
-
-    def iter_self_and_bases(self):
-        """yields (impl, baselist) for all bases"""
-        impl = self
-        baselist = []
-        
-        while impl is not None:
-            baselist = list(baselist)
-            baselist.append(impl.cname)
-            yield impl, baselist
-            impl = impl.base
-
-    def iter_all_ifaces(self):
-        """yields (iface, baselist) for all interfaces"""
-        for impl, baselist in self.iter_self_and_bases():
-            for i in impl.ifaces:
-                if len(baselist) == 1 or i.inherit:
-                    yield i, baselist
-
-    def output(self, fd):
-        unfound = None
-        for impl, baselist in self.iter_self_and_bases():
-            if impl.unfound is not None:
-                unfound = impl.unfound
-                break
-
-        if unfound is None:
-            unfound = self._default_unfound
-
-        needsnullcheck = False
-        actions = sets.Set()
-        types = uniqdict()
-        for i, baselist in self.iter_all_ifaces():
-            action = i.action
-            actions.add(action)
-            if action.needsnullcheck:
-                needsnullcheck = True
-
-            if action.datatype:
-                types[action.varname] = action.datatype
-
-        actionenums = ", ".join(["%s_%s" % (self.cname, action.enumtype)
-                                 for action in actions])
-
-        # types.ptr is explicitly first (for initialization), so delete it
-        types.pop('ptr', None)
-
-        actiondata = "".join([self._datatypes % {'type': type,
-                                                 'name': name}
-                              for name, type in types.iteritems()])
-
-        # ensure that interfaces are not duplicated
-        # maps name -> (uuid, baselist)
-        ifdict = uniqdict()
-        for i, baselist in self.iter_all_ifaces():
-            if i.uuid.name in ifdict:
-                print >>sys.stderr, "warning: interface '%s' from derived class '%s' overrides base class '%s'" % (i.uuid.name, baselist[0], baselist[len(baselist) - 1])
-            else:
-                ifdict[i.uuid.name] = (i, baselist)
-
-        # list of (i, baselist)
-        ilist = [i for i in ifdict.itervalues()]
-
-        uuiddecls = "".join([i.uuid.decl()
-                             for i, baselist in ilist])
-
-        bigindexfunc, bigitable = gqi([iface for iface, baselist in ilist], False)
-        littleindexfunc, littleitable = gqi([iface for iface, baselist in ilist], True)
-
-        # (falseval, trueval)[conditional expression] is the python
-        # ternary operator
-        biglookup = ",\n".join([(str(i), "0xFF")[i is None]
-                                for i in bigitable])
-        littlelookup = ",\n".join([(str(i), "0xFF")[i is None]
-                                   for i in littleitable])
-
-        if len(actions) > 1:
-            actiontype = "%s_QIActionType action;" % self.cname
-            enumtype = "%(cname)s_%(enumtype)s,"
-        else:
-            actiontype = ""
-            enumtype = ""
-
-        actiontable = "".join([self._actiontable_entry %
-               {'enumtype': enumtype % {'cname': self.cname, 
-                                        'enumtype': iface.action.enumtype},
-                'iname': iface.uuid.name,
-                'iref': iface.uuid.ref(),
-                'emitTable': iface.emitTable(self.cname, baselist)}
-                               for iface, baselist in ilist])
-
-        if len(actions) == 1:
-            actioncode = iter(actions).next().setResult % {
-                'classname': self.cname
-                }
-        else:
-            actioncode = self._actioncode_multi % (
-                "".join([self._actioncode_multi_entry % {
-                            'cname': self.cname,
-                            'enumtype': action.enumtype,
-                            'setResult': action.setResult % {'classname': self.cname}}
-                         for action in actions])
-                )
-                
-        if needsnullcheck:
-            nullcheck = self._nullcheck
-        else:
-            nullcheck = ""
-
-        print >>fd, self._qiimpl % {
-            'cname': self.cname,
-            'actionenums': actionenums,
-            'actiontype': actiontype,
-            'actiondata': actiondata,
-            'uuiddecls': uuiddecls,
-            'biglookup': biglookup,
-            'littlelookup': littlelookup,
-            'actiontable': actiontable,
-            'bigindexfunc': bigindexfunc,
-            'littleindexfunc': littleindexfunc,
-            'actioncode': actioncode,
-            'nullcheck': nullcheck,
-            'unfound': unfound
-            }
-
-        if self.emitrefcount:
-            print >>fd, self._refcounting % {
-                'threadsafe': self.threadsafe,
-                'cname': self.cname
-                }
-
-class PointerAction(object):
-    enumtype = "STATIC_POINTER"
-    datatype = "void*"
-    varname  = "ptr"
-    setResult = """*aResult = entry->data.ptr;
-                   return NS_OK;"""
-    needsnullcheck = False
-
-nsCycleCollectionParticipant = PseudoUUID("nsCycleCollectionParticipant", "9674489b-1f6f-4550-a730-ccaedd104cf9")
-
-class CCParticipantResponse(object):
-    action = PointerAction
-    inherit = True
-
-    def __init__(self, classname):
-        self.classname = classname
-        self.uuid = nsCycleCollectionParticipant
-
-    def emitTable(self, classname, baselist):
-        return "{ &NS_CYCLE_COLLECTION_NAME(%s) }" % classname
-
-class TearoffResponse(object):
-    """Because each tearoff is different, this response is its own action."""
-    datatype = None
-    needsnullcheck = True
-    inherit = True
-
-    def __init__(self, uuid, allocator):
-        self.setResult = """
-            found = static_cast<%s*>(%s);
-            goto exit_nullcheck_addref;
-    """ % (uuid.name, allocator)
-        self.uuid = uuid
-        self.action = self
-        self.enumtype = "NS_TEAROFF_%s" % uuid.name
-
-    def emitTable(self, classname, baselist):
-        return "{0}"
-
-class ConditionalResponse(object):
-    """Because each condition is different, this response is its own action."""
-    datatype = None
-    needsnullcheck = False
-    inherit = True
-
-    def __init__(self, uuid, condition):
-        self.setResult = """
-        if (!(%s)) {
-            goto unfound;
-        }
-        found = static_cast<%s*>(this);
-        goto exit_addref;
-        """ % (condition, uuid.name);
-
-        self.uuid = uuid
-        self.action = self
-        self.enumtype = "NS_CONDITIONAL_%s" % uuid.name
-
-    def emitTable(self, classname, baselist):
-        return "{0}"
-
-nsCycleCollectionISupports = PseudoUUID("nsCycleCollectionISupports", "c61eac14-5f7a-4481-965e-7eaa6effa85f")
-
-class CCSupportsAction(object):
-    enumtype = "CC_ISUPPORTS"
-    datatype = None
-    setResult = """
-        found = NS_CYCLE_COLLECTION_CLASSNAME(%(classname)s)::Upcast(this);
-        goto exit_nullcheck_addref;
-    """
-    needsnullcheck = True
-
-class CCISupportsResponse(object):
-    action = CCSupportsAction
-    inherit = True
-
-    def __init__(self, classname):
-        self.classname = classname
-        self.uuid = nsCycleCollectionISupports
-
-    def emitTable(self, classname, baselist):
-        return "{ 0 }"
-
-nsIClassInfo = PseudoUUID("nsIClassInfo", "986c11d0-f340-11d4-9075-0010a4e73d9a")
-
-class DOMCIResult(object):
-    datatype = None
-    enumtype = "DOMCI"
-    needsnullcheck = True
-    inherit = False
-
-    def __init__(self, domciname):
-        self.action = self
-        self.uuid = nsIClassInfo
-        self.setResult = """
-      found = NS_GetDOMClassInfoInstance(eDOMClassInfo_%s_id);
-      goto exit_nullcheck_addref;
-    """ % domciname
-
-    def emitTable(self, classname, baselist):
-        return "{ 0 }"
-
-class OffsetAction(object):
-    enumtype = "OFFSET_THIS_ADDREF"
-    datatype = "PRUint32"
-    varname  = "offset"
-    setResult = """
-        found = reinterpret_cast<nsISupports*>(reinterpret_cast<char*>(this) + entry->data.offset);
-        goto exit_addref;
-    """
-    needsnullcheck = False
-
-class OffsetThisQIResponse(object):
-    action = OffsetAction
-    inherit = True
-
-    def __init__(self, uuid):
-        self.uuid = uuid
-
-    def emitTable(self, classname, baselist):
-        casted = basecast("((%s*) 0x1000)" % classname, baselist)
-
-        return """
-   { reinterpret_cast<void*>(
-       reinterpret_cast<char*>(
-         static_cast<%(iname)s*>(%(casted)s)) -
-       reinterpret_cast<char*>(%(casted)s))
-   }""" % { 'casted': casted,
-            'iname': self.uuid.name }
-
-class OffsetFutureThisQIResponse(OffsetThisQIResponse):
-    action = OffsetAction
-    inherit = True
-
-    def __init__(self, uuid):
-        self.uuid = uuid
-
-    def emitTable(self, classname, baselist):
-        casted = "((%s*) 0x1000)" % classname
-
-        return """
-   { reinterpret_cast<void*>(
-       reinterpret_cast<char*>(
-         static_cast<%(iname)s*>(%(casted)s)) -
-       reinterpret_cast<char*>(%(casted)s))
-   }""" % { 'casted': casted,
-            'iname': self.uuid.name }
-
-class OffsetThisQIResponseAmbiguous(OffsetThisQIResponse):
-    def __init__(self, uuid, intermediate):
-        self.intermediate = intermediate
-        OffsetThisQIResponse.__init__(self, uuid)
-
-    def emitTable(self, classname, baselist):
-        casted = basecast("((%s*) 0x1000)" % classname, baselist)
-
-        return """
-   { reinterpret_cast<void*>(
-       reinterpret_cast<char*>(
-         static_cast<%(iname)s*>(
-           static_cast<%(intermediate)s*>(%(casted)s))) -
-       reinterpret_cast<char*>(%(casted)s))
-   }""" % \
-            { 'casted': casted,
-              'iname': self.uuid.name,
-              'intermediate': self.intermediate.name }
-
-class LiteralAction(object):
-    datatype = None
-    def __init__(self, uname, code):
-        self.enumtype = "LITERAL_CODE_%s" % uname
-        self.setResult = code
-        self.needsnullcheck = code.find('exit_nullcheck_addref') != -1
-
-class LiteralResponse(object):
-    inherit = True
-
-    def __init__(self, action, uuid):
-        self.action = action
-        self.uuid = uuid
-
-    def emitTable(self, cname, baselist):
-        return "{0}"
-
-_map_entry = re.compile(r'(?P<action>[A-Z_]+)\((?P<list>.*)\)$')
-_split_commas = re.compile(r'\s*,\s*')
-
-def build_map(f, cname, iids):
-    """Parse the body of an NS_INTERFACE_MAP and return (members, unfound)"""
-    unfound = None
-    members = []
-    for line in f:
-        if line == 'NS_INTERFACE_MAP_END':
-            return (members, unfound)
-
-        if line == 'NS_INTERFACE_MAP_UNFOUND':
-            unfound = ''
-            for line in f:
-                if line == 'END':
-                    break
-                unfound += line
-            continue
-
-        if line.find(')') == -1:
-            for line2 in f:
-                line += line2
-                if line.find(')') != -1:
-                    break
-
-        m = _map_entry.match(line)
-        if m is None:
-            raise Exception("%s: Unparseable interface map entry" % f.loc())
-
-        items = _split_commas.split(m.group('list'))
-
-        action = m.group('action')
-        if action == 'NS_INTERFACE_MAP_ENTRY':
-            iname, = items
-            members.append(OffsetThisQIResponse(iids[iname]))
-        elif action == 'NS_FUTURE_INTERFACE_MAP_ENTRY':
-            iname, = items
-            members.append(OffsetFutureThisQIResponse(iids[iname]))
-        elif action == 'NS_INTERFACE_MAP_ENTRY_AMBIGUOUS':
-            iname, intermediate = items
-            members.append(OffsetThisQIResponseAmbiguous(iids[iname], iids[intermediate]))
-        elif action == 'NS_INTERFACE_MAP_ENTRY_TEAROFF':
-            iname, allocator = items
-            members.append(TearoffResponse(iids[iname], allocator))
-        elif action == 'NS_INTERFACE_MAP_ENTRY_CONDITIONAL':
-            iname, condition = items
-            members.append(ConditionalResponse(iids[iname], condition))
-        elif action == 'NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO':
-            domciname, = items
-            members.append(DOMCIResult(domciname))
-        elif action == 'NS_INTERFACE_MAP_ENTRY_LITERAL':
-            code = ''
-            for line in f:
-                if line == 'END':
-                    break
-                code += line
-            
-            a = LiteralAction(items[0], code)
-            for iname in items:
-                iface = iids[iname]
-                members.append(LiteralResponse(a, iface))
-        else:
-            raise Exception("%s: Unexpected interface map entry" % f.loc())
-
-    raise Exception("%s: Unexpected EOF" % f.loc())
-
-_import = re.compile(r'%(?P<type>import|import-idl)\s+(?:"|\<)(?P<filename>[a-z\.\-\_0-9]+)(?:"|\>)\s*$', re.I)
-_impl_qi = re.compile(r'NS_IMPL_(?P<threadsafe>THREADSAFE_)?(?P<type>QUERY_INTERFACE|ISUPPORTS)(?P<inherited>_INHERITED)?(?:\d+)\((?P<bases>.*)\)\s*$')
-_pseudoiid = re.compile(r'%pseudo-iid\s+(?P<name>[a-z_0-9]+)\s+(?P<iid>' + _uuid_pattern_string + r')\s*$', re.I)
-_pseudocid = re.compile(r'%pseudo-cid\s+(?P<name>[a-z_0-9]+)\s+(?P<iid>' + _uuid_pattern_string + r')\s+(?P<decl>[a-z_0-9]+)$', re.I)
-_map_begin = re.compile(r'NS_INTERFACE_MAP_BEGIN(?P<cc>_CYCLE_COLLECTION)?\((?P<classname>[A-Za-z0-9+]+)(?:\s*,\s*(?P<base>[A-Za-z0-9+]+))?\)$')
-
-def parsefile(file, fd, includedirs):
-    """Parse a file, returning a (map of name->QIImpls, set of deps)
-    %{C++ blocks are printed immediately to fd."""
-
-    iids = uniqdict()
-    impls = uniqdict()
-    imported = uniqdict()
-    deps = sets.Set()
-    deps.add(file)
-
-    f = IterFile(file)
-    for line in f:
-        if len(line) == 0:
-            continue
-
-        if line == "%{C++":
-            for line in f:
-                if line == "%}":
-                    break
-                print >>fd, line
-            continue
-
-        m = _pseudoiid.match(line)
-        if m is not None:
-            uuid = PseudoUUID(m.group('name'), m.group('iid'))
-            iids[m.group('name')] = uuid
-            continue
-
-        m = _pseudocid.match(line)
-        if m is not None:
-            uuid = CID(m.group('name'), m.group('iid'), m.group('decl'))
-            iids[m.group('decl')] = uuid
-            continue
-
-        m = _import.match(line)
-        if m is not None:
-            if m.group('type') == 'import':
-                newimpls, newdeps = parsefile(findfile(m.group('filename'), file, includedirs), fd, includedirs)
-                imported.update(newimpls)
-                deps |= newdeps
-            else:
-                newiids, newdeps = importidl(findfile(m.group('filename'), file, includedirs), includedirs)
-                iids.update(newiids)
-                deps |= newdeps
-                print >>fd, '#include "%s"' % m.group('filename').replace('.idl', '.h')
-            continue
-
-        if line.find('NS_IMPL_') != -1:
-            if line.find(')') == -1:
-                for follow in f:
-                    line += follow
-                    if follow.find(')') != -1:
-                        break
-
-                if line.find(')') == -1:
-                    raise Exception("%s: Unterminated NS_IMPL_ call" % f.loc())
-
-            m = _impl_qi.match(line)
-            if m is None:
-                raise Exception("%s: Unparseable NS_IMPL_ call" % f.loc())
-
-            bases = _split_commas.split(m.group('bases'))
-            cname = bases.pop(0)
-            if m.group('inherited'):
-                inherited = bases.pop(0)
-                if inherited in impls:
-                    base = impls[inherited]
-                else:
-                    base = imported[inherited]
-            else:
-                base = None
-
-            baseuuids = [iids[name] for name in bases]
-            ifaces = [OffsetThisQIResponse(uuid) for uuid in baseuuids]
-            ifaces.append(OffsetThisQIResponseAmbiguous(iids['nsISupports'], ifaces[0].uuid))
-            q = QIImpl(cname, ifaces,
-                       emitrefcount=(m.group('type') == 'ISUPPORTS'),
-                       threadsafe=m.group('threadsafe') or '',
-                       base=base)
-            impls[cname] = q
-            continue
-
-        m = _map_begin.match(line)
-        if m is not None:
-            members, unfound = build_map(f, m.group('classname'), iids)
-            if m.group('cc') is not None:
-                members.append(CCParticipantResponse(m.group('classname')))
-                members.append(CCISupportsResponse(m.group('classname')))
-            base = None
-            if m.group('base') is not None:
-                if m.group('base') in impls:
-                    base = impls[m.group('base')]
-                else:
-                    base = imported[m.group('base')]
-            q = QIImpl(m.group('classname'), members, unfound=unfound, base=base)
-            impls[m.group('classname')] = q
-            continue
-
-        raise Exception("%s: unexpected input line" % f.loc())
-
-    return impls, deps
-
-def main():
-    from optparse import OptionParser
-
-    o = OptionParser()
-    o.add_option("-I", action="append", dest="include_dirs", default=[],
-                 help="Directory to search for included files.")
-    o.add_option("-D", dest="deps_file",
-                 help="Write dependencies to a file")
-    o.add_option("-o", dest="out_file",
-                 help="Write output to file. Required")
-    o.add_option("-v", dest="verbose", action="store_true",
-                 help="Print verbose debugging output.")
-
-    (options, files) = o.parse_args()
-
-    if options.verbose:
-        global debug
-        debug = True
-
-    if options.out_file is None:
-        o.print_help()
-        sys.exit(1)
-
-    outfd = open(options.out_file, 'w')
-
-    deps = sets.Set()
-
-    for file in files:
-        impls, newdeps = parsefile(file, outfd, options.include_dirs)
-        for q in impls.itervalues():
-            q.output(outfd)
-        deps |= newdeps
-
-        if options.deps_file is not None:
-            depsfd = open(options.deps_file, 'w')
-            print >>depsfd, "%s: %s" % (options.out_file,
-                                        " \\\n   ".join(deps))
-
-if __name__ == '__main__':
-    main()
-
--- a/xpcom/components/Makefile.in
+++ b/xpcom/components/Makefile.in
@@ -54,20 +54,16 @@ REQUIRES	= string \
 CPPSRCS		= \
 		nsCategoryManager.cpp \
 		nsComponentManager.cpp \
 		nsNativeComponentLoader.cpp \
 		nsStaticComponentLoader.cpp \
 		nsServiceManagerObsolete.cpp \
 		$(NULL)
 
-GQI_SRCS = \
-  xpcomcomponents.gqi \
-  $(NULL)
-
 EXPORTS		= \
 		nsCategoryManagerUtils.h \
 		nsIServiceManagerObsolete.h \
 		nsModule.h \
 		nsObsoleteModuleLoading.h \
 		$(NULL)
 
 XPIDLSRCS	= \
--- a/xpcom/components/nsCategoryManager.cpp
+++ b/xpcom/components/nsCategoryManager.cpp
@@ -75,16 +75,58 @@ class nsIComponentLoaderManager;
   going to change much ;)
 */
 
 #define NS_CATEGORYMANAGER_ARENA_SIZE (1024 * 8)
 
 // pulled in from nsComponentManager.cpp
 char* ArenaStrdup(const char* s, PLArenaPool* aArena);
 
+//
+// BaseStringEnumerator is subclassed by EntryEnumerator and
+// CategoryEnumerator
+//
+class BaseStringEnumerator
+  : public nsISimpleEnumerator,
+           nsIUTF8StringEnumerator
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSISIMPLEENUMERATOR
+  NS_DECL_NSIUTF8STRINGENUMERATOR
+
+protected:
+  // Callback function for NS_QuickSort to sort mArray
+  static int SortCallback(const void *, const void *, void *);
+
+  BaseStringEnumerator()
+    : mArray(nsnull),
+      mCount(0),
+      mSimpleCurItem(0),
+      mStringCurItem(0) { }
+
+  // A virtual destructor is needed here because subclasses of
+  // BaseStringEnumerator do not implement their own Release() method.
+
+  virtual ~BaseStringEnumerator()
+  {
+    if (mArray)
+      delete[] mArray;
+  }
+
+  void Sort();
+
+  const char** mArray;
+  PRUint32 mCount;
+  PRUint32 mSimpleCurItem;
+  PRUint32 mStringCurItem;
+};
+
+NS_IMPL_ISUPPORTS2(BaseStringEnumerator, nsISimpleEnumerator, nsIUTF8StringEnumerator)
+
 NS_IMETHODIMP
 BaseStringEnumerator::HasMoreElements(PRBool *_retval)
 {
   *_retval = (mSimpleCurItem < mCount);
 
   return NS_OK;
 }
 
@@ -436,16 +478,18 @@ CategoryEnumerator::enumfunc_createenume
   return PL_DHASH_NEXT;
 }
 
 
 //
 // nsCategoryManager implementations
 //
 
+NS_IMPL_THREADSAFE_ISUPPORTS1(nsCategoryManager, nsICategoryManager)
+
 nsCategoryManager*
 nsCategoryManager::Create()
 {
   nsCategoryManager* manager = new nsCategoryManager();
   
   if (!manager)
     return nsnull;
 
@@ -737,16 +781,27 @@ nsCategoryManager::WriteCategoryManagerT
 
 NS_METHOD
 nsCategoryManager::SuppressNotifications(PRBool aSuppress)
 {
   mSuppressNotifications = aSuppress;
   return NS_OK;
 }
 
+class nsCategoryManagerFactory : public nsIFactory
+   {
+     public:
+       nsCategoryManagerFactory() { }
+
+       NS_DECL_ISUPPORTS
+       NS_DECL_NSIFACTORY
+   };
+
+NS_IMPL_ISUPPORTS1(nsCategoryManagerFactory, nsIFactory)
+
 NS_IMETHODIMP
 nsCategoryManagerFactory::CreateInstance( nsISupports* aOuter, const nsIID& aIID, void** aResult )
   {
     NS_ENSURE_ARG_POINTER(aResult);
 
     *aResult = 0;
 
     nsresult status = NS_OK;
--- a/xpcom/components/nsCategoryManager.h
+++ b/xpcom/components/nsCategoryManager.h
@@ -39,19 +39,16 @@
 #ifndef NSCATEGORYMANAGER_H
 #define NSCATEGORYMANAGER_H
 
 #include "prio.h"
 #include "prlock.h"
 #include "plarena.h"
 #include "nsClassHashtable.h"
 #include "nsICategoryManager.h"
-#include "nsIFactory.h"
-#include "nsISimpleEnumerator.h"
-#include "nsIStringEnumerator.h"
 
 #define NS_CATEGORYMANAGER_CLASSNAME     "Category Manager"
 
 /* 16d222a6-1dd2-11b2-b693-f38b02c021b2 */
 #define NS_CATEGORYMANAGER_CID \
 { 0x16d222a6, 0x1dd2, 0x11b2, \
   {0xb6, 0x93, 0xf3, 0x8b, 0x02, 0xc0, 0x21, 0xb2} }
 
@@ -166,58 +163,9 @@ private:
                        const char* aEntryName);
 
   PLArenaPool mArena;
   nsClassHashtable<nsDepCharHashKey, CategoryNode> mTable;
   PRLock* mLock;
   PRBool mSuppressNotifications;
 };
 
-class nsCategoryManagerFactory : public nsIFactory
-   {
-     public:
-       nsCategoryManagerFactory() { }
-
-       NS_DECL_ISUPPORTS
-       NS_DECL_NSIFACTORY
-   };
-
-//
-// BaseStringEnumerator is subclassed by EntryEnumerator and
-// CategoryEnumerator
-//
-class BaseStringEnumerator
-  : public nsISimpleEnumerator,
-           nsIUTF8StringEnumerator
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSISIMPLEENUMERATOR
-  NS_DECL_NSIUTF8STRINGENUMERATOR
-
-protected:
-  // Callback function for NS_QuickSort to sort mArray
-  static int SortCallback(const void *, const void *, void *);
-
-  BaseStringEnumerator()
-    : mArray(nsnull),
-      mCount(0),
-      mSimpleCurItem(0),
-      mStringCurItem(0) { }
-
-  // A virtual destructor is needed here because subclasses of
-  // BaseStringEnumerator do not implement their own Release() method.
-
-  virtual ~BaseStringEnumerator()
-  {
-    if (mArray)
-      delete[] mArray;
-  }
-
-  void Sort();
-
-  const char** mArray;
-  PRUint32 mCount;
-  PRUint32 mSimpleCurItem;
-  PRUint32 mStringCurItem;
-};
-
 #endif
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -298,16 +298,56 @@ static const PLDHashTableOps contractID_
     PL_DHashMoveEntryStub,
     contractID_ClearEntry,
     PL_DHashFinalizeStub,
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 // Hashtable Enumeration
 ////////////////////////////////////////////////////////////////////////////////
+typedef NS_CALLBACK(EnumeratorConverter)(PLDHashTable *table,
+                                         const PLDHashEntryHdr *hdr,
+                                         void *data,
+                                         nsISupports **retval);
+
+class PLDHashTableEnumeratorImpl : public nsIBidirectionalEnumerator,
+                                   public nsISimpleEnumerator
+{
+public:
+    NS_DECL_ISUPPORTS
+    NS_DECL_NSIENUMERATOR
+    NS_DECL_NSIBIDIRECTIONALENUMERATOR
+    NS_DECL_NSISIMPLEENUMERATOR
+
+    PLDHashTableEnumeratorImpl(PLDHashTable *table,
+                               EnumeratorConverter converter,
+                               void *converterData);
+    PRInt32 Count() { return mCount; }
+private:
+    PLDHashTableEnumeratorImpl(); /* no implementation */
+
+    ~PLDHashTableEnumeratorImpl();
+    void ReleaseElements();
+
+    nsVoidArray   mElements;
+    PRInt32       mCount, mCurrent;
+    PRMonitor*    mMonitor;
+
+    struct Closure {
+        PRBool                        succeeded;
+        EnumeratorConverter           converter;
+        void                          *data;
+        PLDHashTableEnumeratorImpl    *impl;
+    };
+
+    static PLDHashOperator PR_CALLBACK Enumerator(PLDHashTable *table,
+                                                  PLDHashEntryHdr *hdr,
+                                                  PRUint32 number,
+                                                  void *data);
+};
 
 // static
 PLDHashOperator PR_CALLBACK
 PLDHashTableEnumeratorImpl::Enumerator(PLDHashTable *table,
                                        PLDHashEntryHdr *hdr,
                                        PRUint32 number,
                                        void *data)
 {
@@ -336,16 +376,21 @@ PLDHashTableEnumeratorImpl::PLDHashTable
     Closure c = { PR_FALSE, converter, converterData, this };
     mCount = PL_DHashTableEnumerate(table, Enumerator, &c);
     if (!c.succeeded) {
         ReleaseElements();
         mCount = 0;
     }
 }
 
+NS_IMPL_ISUPPORTS3(PLDHashTableEnumeratorImpl,
+                   nsIBidirectionalEnumerator,
+                   nsIEnumerator,
+                   nsISimpleEnumerator)
+
 PLDHashTableEnumeratorImpl::~PLDHashTableEnumeratorImpl()
 {
     ReleaseElements();
 
     // Destroy the Lock
     if (mMonitor)
         nsAutoMonitor::DestroyMonitor(mMonitor);
 }
@@ -719,16 +764,26 @@ nsComponentManagerImpl::~nsComponentMana
         Shutdown();
 
     if (mMon) {
         nsAutoMonitor::DestroyMonitor(mMon);
     }
     PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Destroyed."));
 }
 
+NS_IMPL_THREADSAFE_ISUPPORTS7(nsComponentManagerImpl,
+                              nsIComponentManager,
+                              nsIServiceManager,
+                              nsISupportsWeakReference,
+                              nsIInterfaceRequestor,
+                              nsIComponentRegistrar,
+                              nsIServiceManagerObsolete,
+                              nsIComponentManagerObsolete)
+
+
 nsresult
 nsComponentManagerImpl::GetInterface(const nsIID & uuid, void **result)
 {
     NS_WARNING("This isn't supported");
     // fall through to QI as anything QIable is a superset of what can be
     // got via the GetInterface()
     return  QueryInterface(uuid, result);
 }
--- a/xpcom/components/nsComponentManager.h
+++ b/xpcom/components/nsComponentManager.h
@@ -59,17 +59,16 @@
 #include "prmon.h"
 #include "nsCOMPtr.h"
 #include "nsWeakReference.h"
 #include "nsIFile.h"
 #include "plarena.h"
 #include "nsCOMArray.h"
 #include "nsDataHashtable.h"
 #include "nsTArray.h"
-#include "nsIEnumerator.h"
 
 struct nsFactoryEntry;
 class nsIServiceManager;
 
 #define NS_COMPONENTMANAGER_CID                      \
 { /* 91775d60-d5dc-11d2-92fb-00e09805570f */         \
     0x91775d60,                                      \
     0xd5dc,                                          \
@@ -330,51 +329,10 @@ struct nsFactoryTableEntry : public PLDH
 };
 
 struct nsContractIDTableEntry : public PLDHashEntryHdr {
     char           *mContractID;
     PRUint32        mContractIDLen;
     nsFactoryEntry *mFactoryEntry;    
 };
 
-typedef NS_CALLBACK(EnumeratorConverter)(PLDHashTable *table,
-                                         const PLDHashEntryHdr *hdr,
-                                         void *data,
-                                         nsISupports **retval);
-
-class PLDHashTableEnumeratorImpl : public nsIBidirectionalEnumerator,
-                                   public nsISimpleEnumerator
-{
-public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIENUMERATOR
-    NS_DECL_NSIBIDIRECTIONALENUMERATOR
-    NS_DECL_NSISIMPLEENUMERATOR
-
-    PLDHashTableEnumeratorImpl(PLDHashTable *table,
-                               EnumeratorConverter converter,
-                               void *converterData);
-    PRInt32 Count() { return mCount; }
-private:
-    PLDHashTableEnumeratorImpl(); /* no implementation */
-
-    ~PLDHashTableEnumeratorImpl();
-    void ReleaseElements();
-
-    nsVoidArray   mElements;
-    PRInt32       mCount, mCurrent;
-    PRMonitor*    mMonitor;
-
-    struct Closure {
-        PRBool                        succeeded;
-        EnumeratorConverter           converter;
-        void                          *data;
-        PLDHashTableEnumeratorImpl    *impl;
-    };
-
-    static PLDHashOperator PR_CALLBACK Enumerator(PLDHashTable *table,
-                                                  PLDHashEntryHdr *hdr,
-                                                  PRUint32 number,
-                                                  void *data);
-};
-
 #endif // nsComponentManager_h__
 
--- a/xpcom/components/nsNativeComponentLoader.cpp
+++ b/xpcom/components/nsNativeComponentLoader.cpp
@@ -82,16 +82,19 @@
 #define IMPLEMENT_BREAK_AFTER_LOAD
 #endif
 
 static PRLogModuleInfo *nsNativeModuleLoaderLog =
     PR_NewLogModule("nsNativeModuleLoader");
 
 #define LOG(level, args) PR_LOG(nsNativeModuleLoaderLog, level, args)
 
+NS_IMPL_QUERY_INTERFACE1(nsNativeModuleLoader, 
+                         nsIModuleLoader)
+
 NS_IMPL_ADDREF_USING_AGGREGATOR(nsNativeModuleLoader,
                                 nsComponentManagerImpl::gComponentManager)
 NS_IMPL_RELEASE_USING_AGGREGATOR(nsNativeModuleLoader,
                                  nsComponentManagerImpl::gComponentManager)
 
 nsresult
 nsNativeModuleLoader::Init()
 {
deleted file mode 100644
--- a/xpcom/components/xpcomcomponents.gqi
+++ /dev/null
@@ -1,41 +0,0 @@
-%import-idl "nsIEnumerator.idl"
-%import-idl "nsIComponentManager.idl"
-%import-idl "nsIServiceManager.idl"
-%import-idl "nsIWeakReference.idl"
-%import-idl "nsIInterfaceRequestor.idl"
-%import-idl "nsIComponentRegistrar.idl"
-%import-idl "nsIComponentManagerObsolete.idl"
-%import-idl "nsIStringEnumerator.idl"
-%import-idl "nsIModuleLoader.idl"
-%import-idl "nsICategoryManager.idl"
-
-%{C++
-#include "nsComponentManager.h"
-#include "nsCategoryManager.h"
-#include "nsNativeComponentLoader.h"
-%}
-
-%pseudo-iid nsIServiceManagerObsolete cf0df3b0-3401-11d2-8163-006008119d7a
-
-NS_IMPL_ISUPPORTS3(PLDHashTableEnumeratorImpl,
-                   nsIBidirectionalEnumerator,
-                   nsIEnumerator,
-                   nsISimpleEnumerator)
-
-NS_IMPL_THREADSAFE_ISUPPORTS7(nsComponentManagerImpl,
-                              nsIComponentManager,
-                              nsIServiceManager,
-                              nsISupportsWeakReference,
-                              nsIInterfaceRequestor,
-                              nsIComponentRegistrar,
-                              nsIServiceManagerObsolete,
-                              nsIComponentManagerObsolete)
-
-NS_IMPL_ISUPPORTS1(nsCategoryManagerFactory, nsIFactory)
-
-NS_IMPL_ISUPPORTS2(BaseStringEnumerator, nsISimpleEnumerator, nsIUTF8StringEnumerator)
-
-NS_IMPL_QUERY_INTERFACE1(nsNativeModuleLoader, 
-                         nsIModuleLoader)
-
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsCategoryManager, nsICategoryManager)
--- a/xpcom/ds/Makefile.in
+++ b/xpcom/ds/Makefile.in
@@ -74,20 +74,16 @@ CPPSRCS		= \
 		nsSupportsPrimitives.cpp \
 		nsUnicharBuffer.cpp \
 		nsVariant.cpp \
 		nsTimelineService.cpp \
 		nsArray.cpp \
 		nsHashPropertyBag.cpp \
 		$(NULL)
 
-GQI_SRCS = \
-  xpcomds.gqi \
-  $(NULL)
-
 EXPORTS		= \
 		nsAtomService.h \
 		nsCheapSets.h \
 		nsCppSharedAllocator.h \
 		nsCRT.h \
 		nsDoubleHashtable.h \
 		nsExpirationTracker.h \
 		nsFixedSizeAllocator.h \
--- a/xpcom/ds/nsArray.cpp
+++ b/xpcom/ds/nsArray.cpp
@@ -45,16 +45,22 @@ struct findIndexOfClosure
 {
     nsISupports *targetElement;
     PRUint32 startIndex;
     PRUint32 resultIndex;
 };
 
 PR_STATIC_CALLBACK(PRBool) FindElementCallback(void* aElement, void* aClosure);
 
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsArray)
+  NS_INTERFACE_MAP_ENTRY(nsIArray)
+  NS_INTERFACE_MAP_ENTRY(nsIMutableArray)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMutableArray)
+NS_INTERFACE_MAP_END
+
 nsArray::~nsArray()
 {
     Clear();
 }
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsArray)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsArray)
 
--- a/xpcom/ds/nsAtomTable.cpp
+++ b/xpcom/ds/nsAtomTable.cpp
@@ -61,16 +61,55 @@ class nsStaticAtomWrapper;
  * If |gAtomTable.ops| is 0, then the table is uninitialized.
  */
 static PLDHashTable gAtomTable;
 
 // this is where we keep the nsStaticAtomWrapper objects
 
 static PLArenaPool* gStaticAtomArena = 0;
 
+class nsStaticAtomWrapper : public nsIAtom
+{
+public:
+  nsStaticAtomWrapper(const nsStaticAtom* aAtom, PRUint32 aLength) :
+    mStaticAtom(aAtom), mLength(aLength)
+  {
+    MOZ_COUNT_CTOR(nsStaticAtomWrapper);
+  }
+  ~nsStaticAtomWrapper() {   // no subclasses -> not virtual
+    // this is arena allocated and won't be called except in debug
+    // builds. If this function ever does anything non-debug, be sure
+    // to get rid of the ifdefs in AtomTableClearEntry!
+    MOZ_COUNT_DTOR(nsStaticAtomWrapper);
+  }
+
+  NS_IMETHOD QueryInterface(REFNSIID aIID,
+                            void** aInstancePtr);
+  NS_IMETHOD_(nsrefcnt) AddRef(void);
+  NS_IMETHOD_(nsrefcnt) Release(void);
+
+  NS_DECL_NSIATOM
+
+  const nsStaticAtom* GetStaticAtom() const {
+    return mStaticAtom;
+  }
+
+  PRUint32 getLength() const {
+    return mLength;
+  }
+
+private:
+  const nsStaticAtom* mStaticAtom;
+
+  // The length of the string in the static atom. The static atom
+  // (nsStaticAtom) doesn't hold a length, so we keep it here in the
+  // wrapper instead.
+  PRUint32 mLength;
+};
+
 // The |key| pointer in the various PLDHashTable callbacks we use is an
 // AtomTableClearEntry*.  These pointers can come from two places: either a
 // (probably stack-allocated) string key being passed to PL_DHashTableOperate,
 // or an actual entry in the atom table. PLDHashTable reseves the keyHash
 // values 0 and 1 for internal use, which means that the *PLDHashTable code*
 // will never pass an entry whose keyhash is 0 or 1 to our hooks. That means we
 // can use those values to tell whether an AtomTableEntry is a string key
 // created by a PLDHashTable code caller or an actual live AtomTableEntry used
@@ -400,16 +439,18 @@ AtomImpl::~AtomImpl()
     if (gAtomTable.entryCount == 0) {
       PL_DHashTableFinish(&gAtomTable);
       NS_ASSERTION(gAtomTable.entryCount == 0,
                    "PL_DHashTableFinish changed the entry count");
     }
   }
 }
 
+NS_IMPL_ISUPPORTS1(AtomImpl, nsIAtom)
+
 PermanentAtomImpl::PermanentAtomImpl()
   : AtomImpl()
 {
 }
 
 PermanentAtomImpl::~PermanentAtomImpl()
 {
   // So we can tell if we were permanent while running the base class dtor.
@@ -520,16 +561,18 @@ nsStaticAtomWrapper::AddRef()
 
 NS_IMETHODIMP_(nsrefcnt)
 nsStaticAtomWrapper::Release()
 {
   NS_ASSERTION(NS_IsMainThread(), "wrong thread");
   return 1;
 }
 
+NS_IMPL_QUERY_INTERFACE1(nsStaticAtomWrapper, nsIAtom)
+
 NS_IMETHODIMP
 nsStaticAtomWrapper::GetUTF8String(const char** aResult)
 {
   *aResult = mStaticAtom->mString;
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/xpcom/ds/nsByteBuffer.cpp
+++ b/xpcom/ds/nsByteBuffer.cpp
@@ -54,16 +54,18 @@ ByteBufferImpl::Init(PRUint32 aBufferSiz
     aBufferSize = MIN_BUFFER_SIZE;
   }
   mSpace = aBufferSize;
   mLength = 0;
   mBuffer = new char[aBufferSize];
   return mBuffer ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
+NS_IMPL_ISUPPORTS1(ByteBufferImpl,nsIByteBuffer)
+
 ByteBufferImpl::~ByteBufferImpl()
 {
   if (nsnull != mBuffer) {
     delete[] mBuffer;
     mBuffer = nsnull;
   }
   mLength = 0;
 }
--- a/xpcom/ds/nsHashPropertyBag.cpp
+++ b/xpcom/ds/nsHashPropertyBag.cpp
@@ -65,16 +65,23 @@ NS_NewHashPropertyBag(nsIWritablePropert
 }
 
 /*
  * nsHashPropertyBag impl
  */
 
 NS_IMPL_THREADSAFE_ADDREF(nsHashPropertyBag)
 NS_IMPL_THREADSAFE_RELEASE(nsHashPropertyBag)
+NS_INTERFACE_MAP_BEGIN(nsHashPropertyBag)
+  NS_INTERFACE_MAP_ENTRY(nsIWritablePropertyBag)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIPropertyBag, nsIWritablePropertyBag)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWritablePropertyBag)
+  NS_INTERFACE_MAP_ENTRY(nsIPropertyBag2)
+  NS_INTERFACE_MAP_ENTRY(nsIWritablePropertyBag2)
+NS_INTERFACE_MAP_END
 
 nsresult
 nsHashPropertyBag::Init()
 {
     // we can only assume that Init will fail only due to OOM.
     if (!mPropertyHash.Init())
         return NS_ERROR_OUT_OF_MEMORY;
     return NS_OK;
@@ -134,16 +141,32 @@ nsHashPropertyBag::DeleteProperty(const 
     return NS_OK;
 }
 
 
 //
 // nsSimpleProperty class and impl; used for GetEnumerator
 //
 
+class nsSimpleProperty : public nsIProperty {
+public:
+    nsSimpleProperty(const nsAString& aName, nsIVariant* aValue)
+        : mName(aName), mValue(aValue)
+    {
+    }
+
+    NS_DECL_ISUPPORTS
+    NS_DECL_NSIPROPERTY
+protected:
+    nsString mName;
+    nsCOMPtr<nsIVariant> mValue;
+};
+
+NS_IMPL_ISUPPORTS1(nsSimpleProperty, nsIProperty)
+
 NS_IMETHODIMP
 nsSimpleProperty::GetName(nsAString& aName)
 {
     aName.Assign(mName);
     return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/xpcom/ds/nsHashPropertyBag.h
+++ b/xpcom/ds/nsHashPropertyBag.h
@@ -43,17 +43,16 @@
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 #include "nsVoidArray.h"
 
 #include "nsIVariant.h"
 #include "nsIWritablePropertyBag.h"
 #include "nsIWritablePropertyBag2.h"
 #include "nsInterfaceHashtable.h"
-#include "nsIProperty.h"
 
 // Set IMETHOD_VISIBILITY to empty so that the class-level NS_COM declaration
 // controls member method visibility.
 #undef  IMETHOD_VISIBILITY
 #define IMETHOD_VISIBILITY
 
 class NS_COM nsHashPropertyBag : public nsIWritablePropertyBag
                                , public nsIWritablePropertyBag2
@@ -82,23 +81,9 @@ protected:
 #undef  IMETHOD_VISIBILITY
 #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
 
 // Note: NS_NewHashPropertyBag returns a HPB that
 // uses a non-thread-safe internal hash
 extern "C" NS_COM nsresult
 NS_NewHashPropertyBag(nsIWritablePropertyBag* *_retval);
 
-class nsSimpleProperty : public nsIProperty {
-public:
-    nsSimpleProperty(const nsAString& aName, nsIVariant* aValue)
-        : mName(aName), mValue(aValue)
-    {
-    }
-
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIPROPERTY
-protected:
-    nsString mName;
-    nsCOMPtr<nsIVariant> mValue;
-};
-
 #endif /* nsHashPropertyBag_h___ */
--- a/xpcom/ds/nsIByteBuffer.h
+++ b/xpcom/ds/nsIByteBuffer.h
@@ -38,16 +38,19 @@
 #ifndef nsIByteBuffer_h___
 #define nsIByteBuffer_h___
 
 #include "nscore.h"
 #include "nsISupports.h"
 
 class nsIInputStream;
 
+#define NS_IBYTE_BUFFER_IID    \
+{ 0xe4a6e4b0, 0x93b4, 0x11d1, \
+  {0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
 #define NS_IBYTEBUFFER_IID    \
 { 0xe4a6e4b0, 0x93b4, 0x11d1, \
   {0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
 #define NS_BYTEBUFFER_CONTRACTID "@mozilla.org/byte-buffer;1"
 #define NS_BYTEBUFFER_CLASSNAME "Byte Buffer"
 
 /** Interface to a buffer that holds bytes */
 class nsIByteBuffer : public nsISupports {
--- a/xpcom/ds/nsINIParserImpl.cpp
+++ b/xpcom/ds/nsINIParserImpl.cpp
@@ -38,16 +38,35 @@
 #include "nsINIParserImpl.h"
 
 #include "nsILocalFile.h"
 
 #include "nsINIParser.h"
 #include "nsStringEnumerator.h"
 #include "nsVoidArray.h"
 
+class nsINIParserImpl :
+  public nsIINIParser
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIINIPARSER
+
+  nsresult Init(nsILocalFile* aINIFile) {
+    return mParser.Init(aINIFile);
+  }
+
+private:
+  nsINIParser mParser;
+};
+
+NS_IMPL_ISUPPORTS2(nsINIParserFactory,
+                   nsIINIParserFactory,
+                   nsIFactory)
+
 NS_IMETHODIMP
 nsINIParserFactory::CreateINIParser(nsILocalFile* aINIFile,
                                     nsIINIParser* *aResult)
 {
   *aResult = nsnull;
 
   nsCOMPtr<nsINIParserImpl> p(new nsINIParserImpl());
   if (!p)
@@ -73,16 +92,19 @@ nsINIParserFactory::CreateInstance(nsISu
 }
 
 NS_IMETHODIMP
 nsINIParserFactory::LockFactory(PRBool aLock)
 {
   return NS_OK;
 }
 
+NS_IMPL_ISUPPORTS1(nsINIParserImpl,
+                   nsIINIParser)
+
 static PRBool
 SectionCB(const char* aSection, void *aClosure)
 {
   nsCStringArray *strings = static_cast<nsCStringArray*>(aClosure);
 
   strings->AppendCString(nsDependentCString(aSection));
   return PR_TRUE;
 }
--- a/xpcom/ds/nsINIParserImpl.h
+++ b/xpcom/ds/nsINIParserImpl.h
@@ -34,17 +34,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsINIParserImpl_h__
 #define nsINIParserImpl_h__
 
 #include "nsIINIParser.h"
-#include "nsINIParser.h"
 #include "nsIFactory.h"
 
 #define NS_INIPARSERFACTORY_CID \
 { 0xdfac10a9, 0xdd24, 0x43cf, \
   { 0xa0, 0x95, 0x6f, 0xfa, 0x2e, 0x4b, 0x6a, 0x6c } }
 
 #define NS_INIPARSERFACTORY_CONTRACTID \
   "@mozilla.org/xpcom/ini-parser-factory;1"
@@ -54,24 +53,9 @@ class nsINIParserFactory :
   public nsIFactory
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIINIPARSERFACTORY
   NS_DECL_NSIFACTORY
 };
 
-class nsINIParserImpl :
-  public nsIINIParser
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIINIPARSER
-
-  nsresult Init(nsILocalFile* aINIFile) {
-    return mParser.Init(aINIFile);
-  }
-
-private:
-  nsINIParser mParser;
-};
-
 #endif // nsINIParserImpl_h__
--- a/xpcom/ds/nsIUnicharBuffer.h
+++ b/xpcom/ds/nsIUnicharBuffer.h
@@ -34,17 +34,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #ifndef nsIUnicharBuffer_h___
 #define nsIUnicharBuffer_h___
 
 #include "nscore.h"
 #include "nsISupports.h"
-#include "prlog.h"
 
 #define NS_IUNICHARBUFFER_IID \
 { 0x14cf6970, 0x93b5, 0x11d1, \
   {0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
 
 /// Interface to a buffer that holds unicode characters
 class nsIUnicharBuffer : public nsISupports {
 public:
--- a/xpcom/ds/nsObserverList.cpp
+++ b/xpcom/ds/nsObserverList.cpp
@@ -124,16 +124,18 @@ nsObserverList::NotifyObservers(nsISuppo
     nsCOMArray<nsIObserver> observers;
     FillObserverArray(observers);
 
     for (PRInt32 i = 0; i < observers.Count(); ++i) {
         observers[i]->Observe(aSubject, aTopic, someData);
     }
 }
 
+NS_IMPL_ISUPPORTS1(nsObserverEnumerator, nsISimpleEnumerator)
+
 nsObserverEnumerator::nsObserverEnumerator(nsObserverList* aObserverList)
     : mIndex(0)
 {
     aObserverList->FillObserverArray(mObservers);
 }
 
 NS_IMETHODIMP
 nsObserverEnumerator::HasMoreElements(PRBool *aResult)
--- a/xpcom/ds/nsPersistentProperties.cpp
+++ b/xpcom/ds/nsPersistentProperties.cpp
@@ -136,16 +136,18 @@ nsPersistentProperties::Create(nsISuppor
   nsresult rv = props->Init();
   if (NS_SUCCEEDED(rv))
     rv = props->QueryInterface(aIID, aResult);
 
   NS_RELEASE(props);
   return rv;
 }
 
+NS_IMPL_THREADSAFE_ISUPPORTS2(nsPersistentProperties, nsIPersistentProperties, nsIProperties)
+
 NS_IMETHODIMP
 nsPersistentProperties::Load(nsIInputStream *aIn)
 {
   PRInt32  c;
   nsresult ret = nsSimpleUnicharStreamFactory::GetInstance()->
     CreateInstanceFromUTF8Stream(aIn, &mIn);
 
   if (ret != NS_OK) {
@@ -471,16 +473,18 @@ nsPropertyElement::Create(nsISupports *a
   if (propElem == nsnull)
     return NS_ERROR_OUT_OF_MEMORY;
   NS_ADDREF(propElem);
   nsresult rv = propElem->QueryInterface(aIID, aResult);
   NS_RELEASE(propElem);
   return rv;
 }
 
+NS_IMPL_ISUPPORTS1(nsPropertyElement, nsIPropertyElement)
+
 NS_IMETHODIMP
 nsPropertyElement::GetKey(nsACString& aReturnKey)
 {
   aReturnKey = mKey;
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/xpcom/ds/nsStaticAtom.h
+++ b/xpcom/ds/nsStaticAtom.h
@@ -51,53 +51,15 @@
 // mAtom:   a convienience pointer - if you want to store the value of
 //          the atom created by this structure somewhere, put its
 //          address here
 struct nsStaticAtom {
     const char* mString;
     nsIAtom ** mAtom;
 };
 
-class nsStaticAtomWrapper : public nsIAtom
-{
-public:
-  nsStaticAtomWrapper(const nsStaticAtom* aAtom, PRUint32 aLength) :
-    mStaticAtom(aAtom), mLength(aLength)
-  {
-    MOZ_COUNT_CTOR(nsStaticAtomWrapper);
-  }
-  ~nsStaticAtomWrapper() {   // no subclasses -> not virtual
-    // this is arena allocated and won't be called except in debug
-    // builds. If this function ever does anything non-debug, be sure
-    // to get rid of the ifdefs in AtomTableClearEntry!
-    MOZ_COUNT_DTOR(nsStaticAtomWrapper);
-  }
-
-  NS_IMETHOD QueryInterface(REFNSIID aIID,
-                            void** aInstancePtr);
-  NS_IMETHOD_(nsrefcnt) AddRef(void);
-  NS_IMETHOD_(nsrefcnt) Release(void);
-
-  NS_DECL_NSIATOM
-
-  const nsStaticAtom* GetStaticAtom() const {
-    return mStaticAtom;
-  }
-
-  PRUint32 getLength() const {
-    return mLength;
-  }
-
-private:
-  const nsStaticAtom* mStaticAtom;
-
-  // The length of the string in the static atom. The static atom
-  // (nsStaticAtom) doesn't hold a length, so we keep it here in the
-  // wrapper instead.
-  PRUint32 mLength;
-};
 
 // register your lookup function with the atom table. Your function
 // will be called when at atom is not found in the main atom table.
 NS_COM nsresult
 NS_RegisterStaticAtoms(const nsStaticAtom*, PRUint32 aAtomCount);
 
 #endif
--- a/xpcom/ds/nsStringEnumerator.cpp
+++ b/xpcom/ds/nsStringEnumerator.cpp
@@ -44,16 +44,83 @@
 #include "nsReadableUtils.h"
 #include "nsISimpleEnumerator.h"
 #include "nsSupportsPrimitives.h"
 
 //
 // nsStringEnumerator
 //
 
+class nsStringEnumerator : public nsIStringEnumerator,
+                           public nsIUTF8StringEnumerator,
+                           public nsISimpleEnumerator
+{
+public:
+    nsStringEnumerator(const nsStringArray* aArray, PRBool aOwnsArray) :
+        mArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_TRUE)
+    {}
+    
+    nsStringEnumerator(const nsCStringArray* aArray, PRBool aOwnsArray) :
+        mCArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_FALSE)
+    {}
+
+    nsStringEnumerator(const nsStringArray* aArray, nsISupports* aOwner) :
+        mArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_TRUE)
+    {}
+    
+    nsStringEnumerator(const nsCStringArray* aArray, nsISupports* aOwner) :
+        mCArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_FALSE)
+    {}
+
+    NS_DECL_ISUPPORTS
+    NS_DECL_NSIUTF8STRINGENUMERATOR
+
+    // have to declare nsIStringEnumerator manually, because of
+    // overlapping method names
+    NS_IMETHOD GetNext(nsAString& aResult);
+    NS_DECL_NSISIMPLEENUMERATOR
+
+private:
+    ~nsStringEnumerator() {
+        if (mOwnsArray) {
+            // const-casting is safe here, because the NS_New*
+            // constructors make sure mOwnsArray is consistent with
+            // the constness of the objects
+            if (mIsUnicode)
+                delete const_cast<nsStringArray*>(mArray);
+            else
+                delete const_cast<nsCStringArray*>(mCArray);
+        }
+    }
+
+    union {
+        const nsStringArray* mArray;
+        const nsCStringArray* mCArray;
+    };
+
+    inline PRUint32 Count() {
+        return mIsUnicode ? mArray->Count() : mCArray->Count();
+    }
+    
+    PRUint32 mIndex;
+
+    // the owner allows us to hold a strong reference to the object
+    // that owns the array. Having a non-null value in mOwner implies
+    // that mOwnsArray is PR_FALSE, because we rely on the real owner
+    // to release the array
+    nsCOMPtr<nsISupports> mOwner;
+    PRPackedBool mOwnsArray;
+    PRPackedBool mIsUnicode;
+};
+
+NS_IMPL_ISUPPORTS3(nsStringEnumerator,
+                   nsIStringEnumerator,
+                   nsIUTF8StringEnumerator,
+                   nsISimpleEnumerator)
+
 NS_IMETHODIMP
 nsStringEnumerator::HasMore(PRBool* aResult)
 {
     NS_ENSURE_ARG_POINTER(aResult);
     *aResult = mIndex < Count();
     return NS_OK;
 }
 
--- a/xpcom/ds/nsStringEnumerator.h
+++ b/xpcom/ds/nsStringEnumerator.h
@@ -33,18 +33,16 @@
  * 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 "nsIStringEnumerator.h"
 #include "nsVoidArray.h"
-#include "nsISimpleEnumerator.h"
-#include "nsCOMPtr.h"
 
 // nsIStringEnumerator/nsIUTF8StringEnumerator implementations
 //
 // Currently all implementations support both interfaces. The
 // constructors below provide the most common interface for the given
 // type (i.e. nsIStringEnumerator for PRUnichar* strings, and so
 // forth) but any resulting enumerators can be queried to the other
 // type. Internally, the enumerators will hold onto the type that was
@@ -117,70 +115,8 @@ NS_NewAdoptingUTF8StringEnumerator(nsIUT
 NS_COM nsresult
 NS_NewStringEnumerator(nsIStringEnumerator** aResult,
                        const nsStringArray* aArray,
                        nsISupports* aOwner);
 NS_COM nsresult
 NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
                            const nsCStringArray* aArray,
                            nsISupports* aOwner);
-
-class nsStringEnumerator : public nsIStringEnumerator,
-                           public nsIUTF8StringEnumerator,
-                           public nsISimpleEnumerator
-{
-public:
-    nsStringEnumerator(const nsStringArray* aArray, PRBool aOwnsArray) :
-        mArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_TRUE)
-    {}
-    
-    nsStringEnumerator(const nsCStringArray* aArray, PRBool aOwnsArray) :
-        mCArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_FALSE)
-    {}
-
-    nsStringEnumerator(const nsStringArray* aArray, nsISupports* aOwner) :
-        mArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_TRUE)
-    {}
-    
-    nsStringEnumerator(const nsCStringArray* aArray, nsISupports* aOwner) :
-        mCArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_FALSE)
-    {}
-
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIUTF8STRINGENUMERATOR
-
-    // have to declare nsIStringEnumerator manually, because of
-    // overlapping method names
-    NS_IMETHOD GetNext(nsAString& aResult);
-    NS_DECL_NSISIMPLEENUMERATOR
-
-private:
-    ~nsStringEnumerator() {
-        if (mOwnsArray) {
-            // const-casting is safe here, because the NS_New*
-            // constructors make sure mOwnsArray is consistent with
-            // the constness of the objects
-            if (mIsUnicode)
-                delete const_cast<nsStringArray*>(mArray);
-            else
-                delete const_cast<nsCStringArray*>(mCArray);
-        }
-    }
-
-    union {
-        const nsStringArray* mArray;
-        const nsCStringArray* mCArray;
-    };
-
-    inline PRUint32 Count() {
-        return mIsUnicode ? mArray->Count() : mCArray->Count();
-    }
-    
-    PRUint32 mIndex;
-
-    // the owner allows us to hold a strong reference to the object
-    // that owns the array. Having a non-null value in mOwner implies
-    // that mOwnsArray is PR_FALSE, because we rely on the real owner
-    // to release the array
-    nsCOMPtr<nsISupports> mOwner;
-    PRPackedBool mOwnsArray;
-    PRPackedBool mIsUnicode;
-};
--- a/xpcom/ds/nsSupportsArray.cpp
+++ b/xpcom/ds/nsSupportsArray.cpp
@@ -211,16 +211,18 @@ nsSupportsArray::Create(nsISupports *aOu
 
   nsCOMPtr<nsISupportsArray> it = new nsSupportsArray();
   if (!it)
     return NS_ERROR_OUT_OF_MEMORY;
 
   return it->QueryInterface(aIID, aResult);
 }
 
+NS_IMPL_THREADSAFE_ISUPPORTS3(nsSupportsArray, nsISupportsArray, nsICollection, nsISerializable)
+
 NS_IMETHODIMP
 nsSupportsArray::Read(nsIObjectInputStream *aStream)
 {
   nsresult rv;
 
   PRUint32 newArraySize;
   rv = aStream->Read32(&newArraySize);
 
@@ -675,28 +677,51 @@ NS_COM nsresult
 NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult)
 {
   nsresult rv;
   rv = nsSupportsArray::Create(NULL, NS_GET_IID(nsISupportsArray),
                                (void**)aInstancePtrResult);
   return rv;
 }
 
+class nsArrayEnumerator : public nsISimpleEnumerator
+{
+public:
+    // nsISupports interface
+    NS_DECL_ISUPPORTS
+
+    // nsISimpleEnumerator interface
+    NS_IMETHOD HasMoreElements(PRBool* aResult);
+    NS_IMETHOD GetNext(nsISupports** aResult);
+
+    // nsArrayEnumerator methods
+    nsArrayEnumerator(nsISupportsArray* aValueArray);
+
+private:
+    ~nsArrayEnumerator(void);
+
+protected:
+    nsISupportsArray* mValueArray;
+    PRInt32 mIndex;
+};
+
 nsArrayEnumerator::nsArrayEnumerator(nsISupportsArray* aValueArray)
     : mValueArray(aValueArray),
       mIndex(0)
 {
     NS_IF_ADDREF(mValueArray);
 }
 
 nsArrayEnumerator::~nsArrayEnumerator(void)
 {
     NS_IF_RELEASE(mValueArray);
 }
 
+NS_IMPL_ISUPPORTS1(nsArrayEnumerator, nsISimpleEnumerator)
+
 NS_IMETHODIMP
 nsArrayEnumerator::HasMoreElements(PRBool* aResult)
 {
     NS_PRECONDITION(aResult != 0, "null ptr");
     if (! aResult)
         return NS_ERROR_NULL_POINTER;
 
     if (!mValueArray) {
--- a/xpcom/ds/nsSupportsArray.h
+++ b/xpcom/ds/nsSupportsArray.h
@@ -163,30 +163,9 @@ protected:
   PRUint32 mMaxSize;
 #endif
 
 private:
   // Copy constructors are not allowed
   nsSupportsArray(const nsISupportsArray& other);
 };
 
-class nsArrayEnumerator : public nsISimpleEnumerator
-{
-public:
-    // nsISupports interface
-    NS_DECL_ISUPPORTS
-
-    // nsISimpleEnumerator interface
-    NS_IMETHOD HasMoreElements(PRBool* aResult);
-    NS_IMETHOD GetNext(nsISupports** aResult);
-
-    // nsArrayEnumerator methods
-    nsArrayEnumerator(nsISupportsArray* aValueArray);
-
-private:
-    ~nsArrayEnumerator(void);
-
-protected:
-    nsISupportsArray* mValueArray;
-    PRInt32 mIndex;
-};
-
 #endif // nsSupportsArray_h__
--- a/xpcom/ds/nsSupportsArrayEnumerator.cpp
+++ b/xpcom/ds/nsSupportsArrayEnumerator.cpp
@@ -45,16 +45,18 @@ nsSupportsArrayEnumerator::nsSupportsArr
   NS_ADDREF(mArray);
 }
 
 nsSupportsArrayEnumerator::~nsSupportsArrayEnumerator()
 {
   NS_RELEASE(mArray);
 }
 
+NS_IMPL_ISUPPORTS2(nsSupportsArrayEnumerator, nsIBidirectionalEnumerator, nsIEnumerator)
+
 NS_IMETHODIMP
 nsSupportsArrayEnumerator::First()
 {
   mCursor = 0;
   PRUint32 cnt;
   nsresult rv = mArray->Count(&cnt);
   if (NS_FAILED(rv)) return rv;
   PRInt32 end = (PRInt32)cnt;
--- a/xpcom/ds/nsSupportsPrimitives.cpp
+++ b/xpcom/ds/nsSupportsPrimitives.cpp
@@ -42,16 +42,18 @@
 #include "prprf.h"
 #include "nsIInterfaceInfoManager.h"
 #include "nsDependentString.h"
 #include "nsReadableUtils.h"
 #include "nsPromiseFlatString.h"
 
 /***************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsIDImpl, nsISupportsID, nsISupportsPrimitive)
+
 nsSupportsIDImpl::nsSupportsIDImpl()
     : mData(nsnull)
 {
 }
 
 NS_IMETHODIMP nsSupportsIDImpl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
@@ -100,16 +102,19 @@ NS_IMETHODIMP nsSupportsIDImpl::ToString
     *_retval = result;
     return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /*****************************************************************************
  * nsSupportsCStringImpl
  *****************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsCStringImpl, nsISupportsCString,
+                   nsISupportsPrimitive)
+
 NS_IMETHODIMP nsSupportsCStringImpl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
 
     *aType = TYPE_CSTRING;
     return NS_OK;
 }
 
@@ -134,16 +139,19 @@ NS_IMETHODIMP nsSupportsCStringImpl::Set
     mData = aData;
     return NS_OK;
 }
 
 /*****************************************************************************
  * nsSupportsStringImpl
  *****************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsStringImpl, nsISupportsString,
+                   nsISupportsPrimitive)
+
 NS_IMETHODIMP nsSupportsStringImpl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
 
     *aType = TYPE_STRING;
     return NS_OK;
 }
 
@@ -166,16 +174,19 @@ NS_IMETHODIMP nsSupportsStringImpl::ToSt
 NS_IMETHODIMP nsSupportsStringImpl::SetData(const nsAString& aData)
 {
     mData = aData;
     return NS_OK;
 }
 
 /***************************************************************************/
 
+NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsPRBoolImpl, nsISupportsPRBool,
+                              nsISupportsPrimitive)
+
 nsSupportsPRBoolImpl::nsSupportsPRBoolImpl()
     : mData(PR_FALSE)
 {
 }
 
 NS_IMETHODIMP nsSupportsPRBoolImpl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
@@ -204,16 +215,19 @@ NS_IMETHODIMP nsSupportsPRBoolImpl::ToSt
     char* result = (char*) nsMemory::Clone(str,
                                 (strlen(str)+1)*sizeof(char));
     *_retval = result;
     return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsPRUint8Impl, nsISupportsPRUint8,
+                   nsISupportsPrimitive)
+
 nsSupportsPRUint8Impl::nsSupportsPRUint8Impl()
     : mData(0)
 {
 }
 
 NS_IMETHODIMP nsSupportsPRUint8Impl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
@@ -246,16 +260,19 @@ NS_IMETHODIMP nsSupportsPRUint8Impl::ToS
     char* result = (char*) nsMemory::Clone(buf,
                                 (strlen(buf)+1)*sizeof(char));
     *_retval = result;
     return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsPRUint16Impl, nsISupportsPRUint16,
+                   nsISupportsPrimitive)
+
 nsSupportsPRUint16Impl::nsSupportsPRUint16Impl()
     : mData(0)
 {
 }
 
 NS_IMETHODIMP nsSupportsPRUint16Impl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
@@ -288,16 +305,19 @@ NS_IMETHODIMP nsSupportsPRUint16Impl::To
     char* result = (char*) nsMemory::Clone(buf,
                                 (strlen(buf)+1)*sizeof(char));
     *_retval = result;
     return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsPRUint32Impl, nsISupportsPRUint32,
+                   nsISupportsPrimitive)
+
 nsSupportsPRUint32Impl::nsSupportsPRUint32Impl()
     : mData(0)
 {
 }
 
 NS_IMETHODIMP nsSupportsPRUint32Impl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
@@ -330,16 +350,19 @@ NS_IMETHODIMP nsSupportsPRUint32Impl::To
     char* result = (char*) nsMemory::Clone(buf,
                                 (strlen(buf)+1)*sizeof(char));
     *_retval = result;
     return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsPRUint64Impl, nsISupportsPRUint64,
+                   nsISupportsPrimitive)
+
 nsSupportsPRUint64Impl::nsSupportsPRUint64Impl()
     : mData(LL_ZERO)
 {
 }
 
 NS_IMETHODIMP nsSupportsPRUint64Impl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
@@ -372,16 +395,19 @@ NS_IMETHODIMP nsSupportsPRUint64Impl::To
     char* result = (char*) nsMemory::Clone(buf,
                                 (strlen(buf)+1)*sizeof(char));
     *_retval = result;
     return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsPRTimeImpl, nsISupportsPRTime,
+                   nsISupportsPrimitive)
+
 nsSupportsPRTimeImpl::nsSupportsPRTimeImpl()
     : mData(LL_ZERO)
 {
 }
 
 NS_IMETHODIMP nsSupportsPRTimeImpl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
@@ -414,16 +440,19 @@ NS_IMETHODIMP nsSupportsPRTimeImpl::ToSt
     char* result = (char*) nsMemory::Clone(buf,
                                 (strlen(buf)+1)*sizeof(char));
     *_retval = result;
     return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsCharImpl, nsISupportsChar,
+                   nsISupportsPrimitive)
+
 nsSupportsCharImpl::nsSupportsCharImpl()
     : mData(0)
 {
 }
 
 NS_IMETHODIMP nsSupportsCharImpl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
@@ -456,16 +485,19 @@ NS_IMETHODIMP nsSupportsCharImpl::ToStri
         result[1] = '\0';
     }
     *_retval = result;
     return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsPRInt16Impl, nsISupportsPRInt16,
+                   nsISupportsPrimitive)
+
 nsSupportsPRInt16Impl::nsSupportsPRInt16Impl()
     : mData(0)
 {
 }
 
 NS_IMETHODIMP nsSupportsPRInt16Impl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
@@ -498,16 +530,19 @@ NS_IMETHODIMP nsSupportsPRInt16Impl::ToS
     char* result = (char*) nsMemory::Clone(buf,
                                 (strlen(buf)+1)*sizeof(char));
     *_retval = result;
     return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsPRInt32Impl, nsISupportsPRInt32,
+                   nsISupportsPrimitive)
+
 nsSupportsPRInt32Impl::nsSupportsPRInt32Impl()
     : mData(0)
 {
 }
 
 NS_IMETHODIMP nsSupportsPRInt32Impl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
@@ -540,16 +575,19 @@ NS_IMETHODIMP nsSupportsPRInt32Impl::ToS
     char* result = (char*) nsMemory::Clone(buf,
                                 (strlen(buf)+1)*sizeof(char));
     *_retval = result;
     return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsPRInt64Impl, nsISupportsPRInt64,
+                   nsISupportsPrimitive)
+
 nsSupportsPRInt64Impl::nsSupportsPRInt64Impl()
     : mData(LL_ZERO)
 {
 }
 
 NS_IMETHODIMP nsSupportsPRInt64Impl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
@@ -582,16 +620,19 @@ NS_IMETHODIMP nsSupportsPRInt64Impl::ToS
     char* result = (char*) nsMemory::Clone(buf,
                                 (strlen(buf)+1)*sizeof(char));
     *_retval = result;
     return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsFloatImpl, nsISupportsFloat,
+                   nsISupportsPrimitive)
+
 nsSupportsFloatImpl::nsSupportsFloatImpl()
     : mData(float(0.0))
 {
 }
 
 NS_IMETHODIMP nsSupportsFloatImpl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
@@ -624,16 +665,19 @@ NS_IMETHODIMP nsSupportsFloatImpl::ToStr
     char* result = (char*) nsMemory::Clone(buf,
                                 (strlen(buf)+1)*sizeof(char));
     *_retval = result;
     return result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsDoubleImpl, nsISupportsDouble,
+                   nsISupportsPrimitive)
+
 nsSupportsDoubleImpl::nsSupportsDoubleImpl()
     : mData(double(0.0))
 {
 }
 
 NS_IMETHODIMP nsSupportsDoubleImpl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
@@ -667,16 +711,19 @@ NS_IMETHODIMP nsSupportsDoubleImpl::ToSt
                                 (strlen(buf)+1)*sizeof(char));
     *_retval = result;
     return  result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
 
+NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsVoidImpl, nsISupportsVoid,
+                              nsISupportsPrimitive)
+
 nsSupportsVoidImpl::nsSupportsVoidImpl()
     : mData(nsnull)
 {
 }
 
 NS_IMETHODIMP nsSupportsVoidImpl::GetType(PRUint16 *aType)
 {
     NS_ASSERTION(aType, "Bad pointer");
@@ -706,16 +753,20 @@ NS_IMETHODIMP nsSupportsVoidImpl::ToStri
     char* result = (char*) nsMemory::Clone(str, sizeof(str));
     *_retval = result;
     return  result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
 
+NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsInterfacePointerImpl,
+                              nsISupportsInterfacePointer,
+                              nsISupportsPrimitive)
+
 nsSupportsInterfacePointerImpl::nsSupportsInterfacePointerImpl()
     : mIID(nsnull)
 {
 }
 
 nsSupportsInterfacePointerImpl::~nsSupportsInterfacePointerImpl()
 {
     if (mIID) {
@@ -783,16 +834,18 @@ NS_IMETHODIMP nsSupportsInterfacePointer
     // the interface has a known human-readable name
     char* result = (char*) nsMemory::Clone(str, sizeof(str));
     *_retval = result;
     return  result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
 /***************************************************************************/
 
+NS_IMPL_ISUPPORTS2(nsSupportsDependentCString,nsISupportsCString,nsISupportsPrimitive)
+
 nsSupportsDependentCString::nsSupportsDependentCString(const char* aStr)
     : mData(aStr)
 { }
 
 NS_IMETHODIMP
 nsSupportsDependentCString::GetType(PRUint16 *aType)
 {
     NS_ENSURE_ARG_POINTER(aType);
--- a/xpcom/ds/nsUnicharBuffer.cpp
+++ b/xpcom/ds/nsUnicharBuffer.cpp
@@ -69,16 +69,18 @@ UnicharBufferImpl::Init(PRUint32 aBuffer
     aBufferSize = MIN_BUFFER_SIZE;
   }
   mSpace = aBufferSize;
   mLength = 0;
   mBuffer = new PRUnichar[aBufferSize];
   return mBuffer ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
+NS_IMPL_ISUPPORTS1(UnicharBufferImpl, nsIUnicharBuffer)
+
 UnicharBufferImpl::~UnicharBufferImpl()
 {
   if (nsnull != mBuffer) {
     delete[] mBuffer;
     mBuffer = nsnull;
   }
   mLength = 0;
 }
--- a/xpcom/ds/nsVariant.cpp
+++ b/xpcom/ds/nsVariant.cpp
@@ -1684,16 +1684,18 @@ nsVariant::Traverse(const nsDiscriminate
             break;
     }
 }
 
 /***************************************************************************/
 /***************************************************************************/
 // members...
 
+NS_IMPL_ISUPPORTS2(nsVariant, nsIVariant, nsIWritableVariant)
+
 nsVariant::nsVariant()
     : mWritable(PR_TRUE)
 {
     nsVariant::Initialize(&mData);
 
 #ifdef DEBUG
     {
         // Assert that the nsIDataType consts match the values #defined in
deleted file mode 100644
--- a/xpcom/ds/xpcomds.gqi
+++ /dev/null
@@ -1,139 +0,0 @@
-%import-idl "nsIMutableArray.idl"
-%import-idl "nsIProperty.idl"
-%import-idl "nsIINIParser.idl"
-%import-idl "nsIFactory.idl"
-%import-idl "nsIVariant.idl"
-%import-idl "nsIPersistentProperties2.idl"
-%import-idl "nsISimpleEnumerator.idl"
-%import-idl "nsIStringEnumerator.idl"
-%import-idl "nsISupportsArray.idl"
-%import-idl "nsISerializable.idl"
-%import-idl "nsIAtom.idl"
-%import-idl "nsISupportsPrimitives.idl"
-%import-idl "nsIWritablePropertyBag.idl"
-%import-idl "nsIWritablePropertyBag2.idl"
-
-%{C++
-#include "nsArray.h"
-#include "nsIByteBuffer.h"
-#include "nsHashPropertyBag.h"
-#include "nsINIParserImpl.h"
-#include "nsVariant.h"
-#include "nsByteBuffer.h"
-#include "nsPersistentProperties.h"
-#include "nsUnicharBuffer.h"
-#include "nsObserverList.h"
-#include "nsStringEnumerator.h"
-#include "nsSupportsArray.h"
-#include "nsAtomTable.h"
-#include "nsStaticAtom.h"
-#include "nsSupportsArrayEnumerator.h"
-#include "nsSupportsPrimitives.h"
-%}
-
-%pseudo-iid nsIByteBuffer e4a6e4b0-93b4-11d1-895b-006008911b81
-%pseudo-iid nsIUnicharBuffer 14cf6970-93b5-11d1-895b-006008911b81
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsArray)
-  NS_INTERFACE_MAP_ENTRY(nsIArray)
-  NS_INTERFACE_MAP_ENTRY(nsIMutableArray)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMutableArray)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_ISUPPORTS1(nsSimpleProperty, nsIProperty)
-
-NS_IMPL_ISUPPORTS2(nsINIParserFactory,
-                   nsIINIParserFactory,
-                   nsIFactory)
-
-NS_IMPL_ISUPPORTS1(nsINIParserImpl,
-                   nsIINIParser)
-
-NS_IMPL_ISUPPORTS2(nsVariant, nsIVariant, nsIWritableVariant)
-
-NS_IMPL_ISUPPORTS1(ByteBufferImpl,nsIByteBuffer)
-
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsPersistentProperties, nsIPersistentProperties, nsIProperties)
-
-NS_INTERFACE_MAP_BEGIN(nsHashPropertyBag)
-  NS_INTERFACE_MAP_ENTRY(nsIWritablePropertyBag)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIPropertyBag, nsIWritablePropertyBag)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWritablePropertyBag)
-  NS_INTERFACE_MAP_ENTRY(nsIPropertyBag2)
-  NS_INTERFACE_MAP_ENTRY(nsIWritablePropertyBag2)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_ISUPPORTS1(nsPropertyElement, nsIPropertyElement)
-
-NS_IMPL_ISUPPORTS1(UnicharBufferImpl, nsIUnicharBuffer)
-
-NS_IMPL_ISUPPORTS1(nsObserverEnumerator, nsISimpleEnumerator)
-
-NS_IMPL_ISUPPORTS3(nsStringEnumerator,
-                   nsIStringEnumerator,
-                   nsIUTF8StringEnumerator,
-                   nsISimpleEnumerator)
-
-NS_IMPL_THREADSAFE_ISUPPORTS3(nsSupportsArray, nsISupportsArray, nsICollection, nsISerializable)
-
-NS_IMPL_ISUPPORTS1(nsArrayEnumerator, nsISimpleEnumerator)
-
-NS_IMPL_ISUPPORTS1(AtomImpl, nsIAtom)
-
-NS_IMPL_QUERY_INTERFACE1(nsStaticAtomWrapper, nsIAtom)
-
-NS_IMPL_ISUPPORTS2(nsSupportsArrayEnumerator, nsIBidirectionalEnumerator, nsIEnumerator)
-
-NS_IMPL_ISUPPORTS2(nsSupportsIDImpl, nsISupportsID, nsISupportsPrimitive)
-
-NS_IMPL_ISUPPORTS2(nsSupportsCStringImpl, nsISupportsCString,
-                   nsISupportsPrimitive)
-
-NS_IMPL_ISUPPORTS2(nsSupportsStringImpl, nsISupportsString,
-                   nsISupportsPrimitive)
-
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsPRBoolImpl, nsISupportsPRBool,
-                              nsISupportsPrimitive)
-
-NS_IMPL_ISUPPORTS2(nsSupportsPRUint8Impl, nsISupportsPRUint8,
-                   nsISupportsPrimitive)
-
-NS_IMPL_ISUPPORTS2(nsSupportsPRUint16Impl, nsISupportsPRUint16,
-                   nsISupportsPrimitive)
-
-NS_IMPL_ISUPPORTS2(nsSupportsPRUint32Impl, nsISupportsPRUint32,
-                   nsISupportsPrimitive)
-
-NS_IMPL_ISUPPORTS2(nsSupportsPRUint64Impl, nsISupportsPRUint64,
-                   nsISupportsPrimitive)
-
-NS_IMPL_ISUPPORTS2(nsSupportsPRTimeImpl, nsISupportsPRTime,
-                   nsISupportsPrimitive)
-
-NS_IMPL_ISUPPORTS2(nsSupportsCharImpl, nsISupportsChar,
-                   nsISupportsPrimitive)
-
-NS_IMPL_ISUPPORTS2(nsSupportsPRInt16Impl, nsISupportsPRInt16,
-                   nsISupportsPrimitive)
-
-NS_IMPL_ISUPPORTS2(nsSupportsPRInt32Impl, nsISupportsPRInt32,
-                   nsISupportsPrimitive)
-
-NS_IMPL_ISUPPORTS2(nsSupportsPRInt64Impl, nsISupportsPRInt64,
-                   nsISupportsPrimitive)
-
-NS_IMPL_ISUPPORTS2(nsSupportsFloatImpl, nsISupportsFloat,
-                   nsISupportsPrimitive)
-
-NS_IMPL_ISUPPORTS2(nsSupportsDoubleImpl, nsISupportsDouble,
-                   nsISupportsPrimitive)
-
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsVoidImpl, nsISupportsVoid,
-                              nsISupportsPrimitive)
-
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsInterfacePointerImpl,
-                              nsISupportsInterfacePointer,
-                              nsISupportsPrimitive)
-
-NS_IMPL_ISUPPORTS2(nsSupportsDependentCString,nsISupportsCString,nsISupportsPrimitive)
-