Fix for bug 560462 (Use fast unwrapping for more quickstubs) - add non-addrefing GetElementById and GetBody, add nsContentList-returning GetElementsByTagName(NS) and GetElementsByName. r=jst.
authorPeter Van der Beken <peterv@propagandism.org>
Mon, 19 Apr 2010 17:41:38 +0200
changeset 42425 d1dd21e11f2be2b89289d9fb1871f1c2bca0facb
parent 42424 5d1eab36de8095b637f424d0135f4e66a54079ae
child 42426 f84d783a5e24dd634f45b550d4c939e33864e9c7
push id13336
push userjst@mozilla.com
push dateTue, 18 May 2010 19:43:48 +0000
treeherdermozilla-central@d1dd21e11f2b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs560462
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Fix for bug 560462 (Use fast unwrapping for more quickstubs) - add non-addrefing GetElementById and GetBody, add nsContentList-returning GetElementsByTagName(NS) and GetElementsByName. r=jst.
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
content/html/document/src/nsHTMLDocument.cpp
content/html/document/src/nsHTMLDocument.h
content/xul/document/src/nsXULDocument.cpp
content/xul/document/src/nsXULDocument.h
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -3887,36 +3887,57 @@ nsDocument::GetElementByIdInternal(nsIAt
     // entry again, adding if necessary (the adding may be necessary in case
     // the flush actually deleted entries).
     entry = mIdentifierMap.PutEntry(aID);
   }
   
   return entry;
 }
 
-NS_IMETHODIMP
-nsDocument::GetElementById(const nsAString& aElementId,
-                           nsIDOMElement** aReturn)
-{
-  NS_ENSURE_ARG_POINTER(aReturn);
-  *aReturn = nsnull;
-
+Element*
+nsDocument::GetElementById(const nsAString& aElementId, nsresult *aResult)
+{
   nsCOMPtr<nsIAtom> idAtom(do_GetAtom(aElementId));
-  NS_ENSURE_TRUE(idAtom, NS_ERROR_OUT_OF_MEMORY);
-  if (!CheckGetElementByIdArg(idAtom))
-    return NS_OK;
+  if (!idAtom) {
+    *aResult = NS_ERROR_OUT_OF_MEMORY;
+
+    return nsnull;
+  }
+
+  if (!CheckGetElementByIdArg(idAtom)) {
+    *aResult = NS_OK;
+
+    return nsnull;
+  }
 
   nsIdentifierMapEntry *entry = GetElementByIdInternal(idAtom);
-  NS_ENSURE_TRUE(entry, NS_ERROR_OUT_OF_MEMORY);
-
-  Element *e = entry->GetIdElement();
-  if (!e)
-    return NS_OK;
-
-  return CallQueryInterface(e, aReturn);
+  if (!entry) {
+    *aResult = NS_ERROR_OUT_OF_MEMORY;
+
+    return nsnull;
+  }
+
+  *aResult = NS_OK;
+
+  return entry->GetIdElement();
+}
+
+NS_IMETHODIMP
+nsDocument::GetElementById(const nsAString& aId, nsIDOMElement** aReturn)
+{
+  nsresult rv;
+  Element *content = GetElementById(aId, &rv);
+  if (content) {
+    rv = CallQueryInterface(content, aReturn);
+  }
+  else {
+    *aReturn = nsnull;
+  }
+
+  return rv;
 }
 
 Element*
 nsDocument::AddIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver,
                                 void* aData)
 {
   if (!CheckGetElementByIdArg(aID))
     return nsnull;
@@ -4358,53 +4379,75 @@ nsDocument::CreateEntityReference(const 
                                   nsIDOMEntityReference** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
 
   *aReturn = nsnull;
   return NS_OK;
 }
 
+already_AddRefed<nsContentList>
+nsDocument::GetElementsByTagName(const nsAString& aTagname)
+{
+  nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aTagname);
+  if (IsHTML()) {
+    nsAutoString tmp(aTagname);
+    ToLowerCase(tmp); // HTML elements are lower case internally.
+    nameAtom = do_GetAtom(tmp);
+  }
+  else {
+    nameAtom = do_GetAtom(aTagname);
+  }
+  NS_ENSURE_TRUE(nameAtom, nsnull);
+
+  return NS_GetContentList(this, nameAtom, kNameSpaceID_Unknown);
+}
+
 NS_IMETHODIMP
 nsDocument::GetElementsByTagName(const nsAString& aTagname,
                                  nsIDOMNodeList** aReturn)
 {
-  nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aTagname);
-  NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
-
-  nsContentList *list = NS_GetContentList(this, nameAtom, kNameSpaceID_Unknown).get();
+  nsRefPtr<nsContentList> list = GetElementsByTagName(aTagname);
   NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
 
   // transfer ref to aReturn
-  *aReturn = list;
+  *aReturn = list.forget().get();
   return NS_OK;
 }
 
-NS_IMETHODIMP
+already_AddRefed<nsContentList>
 nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
-                                   const nsAString& aLocalName,
-                                   nsIDOMNodeList** aReturn)
+                                   const nsAString& aLocalName)
 {
   PRInt32 nameSpaceId = kNameSpaceID_Wildcard;
 
   if (!aNamespaceURI.EqualsLiteral("*")) {
     nsresult rv =
       nsContentUtils::NameSpaceManager()->RegisterNameSpace(aNamespaceURI,
                                                             nameSpaceId);
-    NS_ENSURE_SUCCESS(rv, rv);
+    NS_ENSURE_SUCCESS(rv, nsnull);
   }
 
   nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(aLocalName);
-  NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
-
-  nsContentList *list = NS_GetContentList(this, nameAtom, nameSpaceId).get();
+  NS_ENSURE_TRUE(nameAtom, nsnull);
+
+  return NS_GetContentList(this, nameAtom, nameSpaceId);
+}
+
+NS_IMETHODIMP
+nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
+                                   const nsAString& aLocalName,
+                                   nsIDOMNodeList** aReturn)
+{
+  nsRefPtr<nsContentList> list = GetElementsByTagNameNS(aNamespaceURI,
+                                                        aLocalName);
   NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
 
   // transfer ref to aReturn
-  *aReturn = list;
+  *aReturn = list.forget().get();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::GetAsync(PRBool *aAsync)
 {
   NS_ERROR("nsDocument::GetAsync() should be overriden by subclass!");
 
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -931,16 +931,25 @@ public:
   // Only BlockOnload should call this!
   void AsyncBlockOnload();
 
   virtual void SetScrollToRef(nsIURI *aDocumentURI);
   virtual void ScrollToRef();
   virtual void ResetScrolledToRefAlready();
   virtual void SetChangeScrollPosWhenScrollingToRef(PRBool aValue);
 
+  already_AddRefed<nsContentList>
+    GetElementsByTagName(const nsAString& aTagName);
+  already_AddRefed<nsContentList>
+    GetElementsByTagNameNS(const nsAString& aNamespaceURI,
+                           const nsAString& aLocalName);
+
+  virtual mozilla::dom::Element *GetElementById(const nsAString& aElementId,
+                                                nsresult *aResult);
+
 protected:
   friend class nsNodeUtils;
   void RegisterNamedItems(nsIContent *aContent);
   void UnregisterNamedItems(nsIContent *aContent);
   void UpdateNameTableEntry(Element *aElement);
   void UpdateIdTableEntry(Element *aElement);
   void RemoveFromNameTable(Element *aElement);
   void RemoveFromIdTable(Element *aElement);
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -1385,21 +1385,17 @@ nsHTMLDocument::CreateTextNode(const nsA
 {
   return nsDocument::CreateTextNode(aData, aReturn);
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetElementsByTagName(const nsAString& aTagname,
                                      nsIDOMNodeList** aReturn)
 {
-  nsAutoString tmp(aTagname);
-  if (IsHTML()) {
-    ToLowerCase(tmp); // HTML elements are lower case internally.
-  }
-  return nsDocument::GetElementsByTagName(tmp, aReturn);
+  return nsDocument::GetElementsByTagName(aTagname, aReturn);
 }
 
 // nsIDOM3Document interface implementation
 NS_IMETHODIMP
 nsHTMLDocument::GetXmlEncoding(nsAString& aXmlEncoding)
 {
   if (!IsHTML()) {
     return nsDocument::GetXmlEncoding(aXmlEncoding);
@@ -1577,47 +1573,58 @@ nsHTMLDocument::GetURL(nsAString& aURL)
     mDocumentURI->GetSpec(str);
   }
 
   CopyUTF8toUTF16(str, aURL);
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsHTMLDocument::GetBody(nsIDOMHTMLElement** aBody)
+nsIContent*
+nsHTMLDocument::GetBody(nsresult *aResult)
 {
-  *aBody = nsnull;
-
   Element* body = GetBodyElement();
 
+  *aResult = NS_OK;
+
   if (body) {
     // There is a body element, return that as the body.
-    return CallQueryInterface(body, aBody);
+    return body;
   }
 
   // The document is most likely a frameset document so look for the
   // outer most frameset element
-  nsCOMPtr<nsIDOMNodeList> nodeList;
+  nsRefPtr<nsContentList> nodeList;
+
+  if (IsHTML()) {
+    nodeList = nsDocument::GetElementsByTagName(NS_LITERAL_STRING("frameset"));
+  } else {
+    nodeList =
+      nsDocument::GetElementsByTagNameNS(NS_LITERAL_STRING("http://www.w3.org/1999/xhtml"),
+                             NS_LITERAL_STRING("frameset"));
+  }
+
+  if (!nodeList) {
+    *aResult = NS_ERROR_OUT_OF_MEMORY;
+
+    return nsnull;
+  }
+
+  return nodeList->GetNodeAt(0);
+}
+
+NS_IMETHODIMP
+nsHTMLDocument::GetBody(nsIDOMHTMLElement** aBody)
+{
+  *aBody = nsnull;
 
   nsresult rv;
-  if (IsHTML()) {
-    rv = GetElementsByTagName(NS_LITERAL_STRING("frameset"),
-                              getter_AddRefs(nodeList));
-  } else {
-    rv = GetElementsByTagNameNS(NS_LITERAL_STRING("http://www.w3.org/1999/xhtml"),
-                                NS_LITERAL_STRING("frameset"),
-                                getter_AddRefs(nodeList));
-  }
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsIDOMNode> node;
-  nodeList->Item(0, getter_AddRefs(node));
-
-  return node ? CallQueryInterface(node, aBody) : NS_OK;
+  nsIContent *body = GetBody(&rv);
+
+  return body ? CallQueryInterface(body, aBody) : rv;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::SetBody(nsIDOMHTMLElement* aBody)
 {
   nsCOMPtr<nsIContent> newBody = do_QueryInterface(aBody);
   Element* root = GetRootElement();
 
@@ -2283,28 +2290,21 @@ nsHTMLDocument::MatchNameAttribute(nsICo
     aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
                           *elementName, eCaseMatters);
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetElementsByName(const nsAString& aElementName,
                                   nsIDOMNodeList** aReturn)
 {
-  nsString* elementNameData = new nsString(aElementName);
-  NS_ENSURE_TRUE(elementNameData, NS_ERROR_OUT_OF_MEMORY);
-  nsContentList* elements =
-    NS_GetFuncStringContentList(this,
-                                MatchNameAttribute,
-                                nsContentUtils::DestroyMatchString,
-                                elementNameData,
-                                *elementNameData).get();
-  NS_ENSURE_TRUE(elements, NS_ERROR_OUT_OF_MEMORY);
+  nsRefPtr<nsContentList> list = GetElementsByName(aElementName);
+  NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
 
   // Transfer ownership
-  *aReturn = elements;
+  list.forget(aReturn);
 
   return NS_OK;
 }
 
 void
 nsHTMLDocument::ScriptLoading(nsIScriptElement *aScript)
 {
   if (mWriteState == eNotWriting) {
--- a/content/html/document/src/nsHTMLDocument.h
+++ b/content/html/document/src/nsHTMLDocument.h
@@ -155,16 +155,27 @@ public:
   NS_IMETHOD Open(void);
   NS_IMETHOD Close(void);
   NS_IMETHOD Write(const nsAString & text);
   NS_IMETHOD Writeln(const nsAString & text);
   NS_IMETHOD GetElementsByName(const nsAString & elementName,
                                nsIDOMNodeList **_retval);
   virtual nsresult GetDocumentAllResult(const nsAString& aID,
                                         nsISupports** aResult);
+  nsIContent *GetBody(nsresult *aResult);
+  already_AddRefed<nsContentList> GetElementsByName(const nsAString & aName)
+  {
+    nsString* elementNameData = new nsString(aName);
+
+    return NS_GetFuncStringContentList(this,
+                                       MatchNameAttribute,
+                                       nsContentUtils::DestroyMatchString,
+                                       elementNameData,
+                                       *elementNameData);
+  }
 
   // nsIDOMNSHTMLDocument interface
   NS_DECL_NSIDOMNSHTMLDOCUMENT
 
   virtual nsresult ResolveName(const nsAString& aName,
                                nsIDOMHTMLFormElement *aForm,
                                nsISupports **aResult);
 
@@ -223,16 +234,22 @@ public:
   }
 
   virtual nsresult SetEditingState(EditingState aState);
 
   virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
 
   virtual NS_HIDDEN_(void) RemovedFromDocShell();
 
+  virtual mozilla::dom::Element *GetElementById(const nsAString& aElementId,
+                                                nsresult *aResult)
+  {
+    return nsDocument::GetElementById(aElementId, aResult);
+  }
+
 protected:
   nsresult GetBodySize(PRInt32* aWidth,
                        PRInt32* aHeight);
 
   nsresult PrePopulateIdentifierMap();
 
   nsIContent *MatchId(nsIContent *aContent, const nsAString& aId);
 
--- a/content/xul/document/src/nsXULDocument.cpp
+++ b/content/xul/document/src/nsXULDocument.cpp
@@ -182,42 +182,42 @@ struct BroadcasterMapEntry : public PLDH
     nsSmallVoidArray mListeners;   // [OWNING] of BroadcastListener objects
 };
 
 struct BroadcastListener {
     nsWeakPtr mListener;
     nsCOMPtr<nsIAtom> mAttribute;
 };
 
-nsIContent*
-nsRefMapEntry::GetFirstContent()
+Element*
+nsRefMapEntry::GetFirstElement()
 {
-    return static_cast<nsIContent*>(mRefContentList.SafeElementAt(0));
+    return static_cast<Element*>(mRefContentList.SafeElementAt(0));
 }
 
 void
 nsRefMapEntry::AppendAll(nsCOMArray<nsIContent>* aElements)
 {
     for (PRInt32 i = 0; i < mRefContentList.Count(); ++i) {
         aElements->AppendObject(static_cast<nsIContent*>(mRefContentList[i]));
     }
 }
 
 PRBool
-nsRefMapEntry::AddContent(nsIContent* aContent)
+nsRefMapEntry::AddElement(Element* aElement)
 {
-    if (mRefContentList.IndexOf(aContent) >= 0)
+    if (mRefContentList.IndexOf(aElement) >= 0)
         return PR_TRUE;
-    return mRefContentList.AppendElement(aContent);
+    return mRefContentList.AppendElement(aElement);
 }
 
 PRBool
-nsRefMapEntry::RemoveContent(nsIContent* aContent)
+nsRefMapEntry::RemoveElement(Element* aElement)
 {
-    mRefContentList.RemoveElement(aContent);
+    mRefContentList.RemoveElement(aElement);
     return mRefContentList.Count() == 0;
 }
 
 //----------------------------------------------------------------------
 //
 // ctors & dtors
 //
 
@@ -973,17 +973,17 @@ nsXULDocument::AttributeWillChange(nsIDo
 {
     NS_ABORT_IF_FALSE(aContent, "Null content!");
     NS_PRECONDITION(aAttribute, "Must have an attribute that's changing!");
 
     // XXXbz check aNameSpaceID, dammit!
     // See if we need to update our ref map.
     if (aAttribute == nsGkAtoms::ref ||
         (aAttribute == nsGkAtoms::id && !aContent->GetIDAttributeName())) {
-        RemoveElementFromRefMap(aContent);
+        RemoveElementFromRefMap(aContent->AsElement());
     }
     
     nsXMLDocument::AttributeWillChange(aDocument, aContent, aNameSpaceID,
                                        aAttribute, aModType);
 }
 
 void
 nsXULDocument::AttributeChanged(nsIDocument* aDocument,
@@ -1318,17 +1318,17 @@ nsXULDocument::Persist(const nsAString& 
     // If we're currently reading persisted attributes out of the
     // localstore, _don't_ re-enter and try to set them again!
     if (mApplyingPersistedAttrs)
         return NS_OK;
 
     nsresult rv;
 
     nsCOMPtr<nsIDOMElement> domelement;
-    rv = GetElementById(aID, getter_AddRefs(domelement));
+    rv = nsDocument::GetElementById(aID, getter_AddRefs(domelement));
     if (NS_FAILED(rv)) return rv;
 
     if (! domelement)
         return NS_OK;
 
     nsCOMPtr<nsIContent> element = do_QueryInterface(domelement);
     NS_ASSERTION(element != nsnull, "null ptr");
     if (! element)
@@ -1655,43 +1655,44 @@ nsXULDocument::SetTooltipNode(nsIDOMNode
 NS_IMETHODIMP
 nsXULDocument::GetCommandDispatcher(nsIDOMXULCommandDispatcher** aTracker)
 {
     *aTracker = mCommandDispatcher;
     NS_IF_ADDREF(*aTracker);
     return NS_OK;
 }
 
-NS_IMETHODIMP
-nsXULDocument::GetElementById(const nsAString& aId,
-                              nsIDOMElement** aReturn)
+Element*
+nsXULDocument::GetElementById(const nsAString& aId, nsresult *aResult)
 {
-    NS_ENSURE_ARG_POINTER(aReturn);
-    *aReturn = nsnull;
-
-    nsCOMPtr<nsIAtom> atom = do_GetAtom(aId);
-    if (!atom)
-        return NS_ERROR_OUT_OF_MEMORY;
+    nsCOMPtr<nsIAtom> atom(do_GetAtom(aId));
+    if (!atom) {
+        *aResult = NS_ERROR_OUT_OF_MEMORY;
+
+        return nsnull;
+    }
+
+    *aResult = NS_OK;
 
     if (!CheckGetElementByIdArg(atom))
-        return NS_OK;
+        return nsnull;
 
     nsIdentifierMapEntry *entry = mIdentifierMap.GetEntry(atom);
     if (entry) {
         Element* element = entry->GetIdElement();
         if (element)
-            return CallQueryInterface(element, aReturn);
+            return element;
     }
     nsRefMapEntry* refEntry = mRefMap.GetEntry(atom);
     if (refEntry) {
-        NS_ASSERTION(refEntry->GetFirstContent(),
+        NS_ASSERTION(refEntry->GetFirstElement(),
                      "nsRefMapEntries should have nonempty content lists");
-        return CallQueryInterface(refEntry->GetFirstContent(), aReturn);
+        return refEntry->GetFirstElement();
     }
-    return NS_OK;
+    return nsnull;
 }
 
 nsresult
 nsXULDocument::AddElementToDocumentPre(Element* aElement)
 {
     // Do a bunch of work that's necessary when an element gets added
     // to the XUL Document.
     nsresult rv;
@@ -1893,59 +1894,59 @@ nsXULDocument::GetTemplateBuilderFor(nsI
     }
     else
         *aResult = nsnull;
 
     return NS_OK;
 }
 
 static void
-GetRefMapAttribute(nsIContent* aElement, nsAutoString* aValue)
+GetRefMapAttribute(Element* aElement, nsAutoString* aValue)
 {
     aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::ref, *aValue);
     if (aValue->IsEmpty() && !aElement->GetIDAttributeName()) {
         aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::id, *aValue);
     }
 }
 
 nsresult
-nsXULDocument::AddElementToRefMap(nsIContent* aElement)
+nsXULDocument::AddElementToRefMap(Element* aElement)
 {
     // Look at the element's 'ref' attribute, and if set,
     // add an entry in the resource-to-element map to the element.
     nsAutoString value;
     GetRefMapAttribute(aElement, &value);
     if (!value.IsEmpty()) {
         nsCOMPtr<nsIAtom> atom = do_GetAtom(value);
         if (!atom)
             return NS_ERROR_OUT_OF_MEMORY;
         nsRefMapEntry *entry = mRefMap.PutEntry(atom);
         if (!entry)
             return NS_ERROR_OUT_OF_MEMORY;
-        if (!entry->AddContent(aElement))
+        if (!entry->AddElement(aElement))
             return NS_ERROR_OUT_OF_MEMORY;
     }
 
     return NS_OK;
 }
 
 void
-nsXULDocument::RemoveElementFromRefMap(nsIContent* aElement)
+nsXULDocument::RemoveElementFromRefMap(Element* aElement)
 {
     // Remove the element from the resource-to-element map.
     nsAutoString value;
     GetRefMapAttribute(aElement, &value);
     if (!value.IsEmpty()) {
         nsCOMPtr<nsIAtom> atom = do_GetAtom(value);
         if (!atom)
             return;
         nsRefMapEntry *entry = mRefMap.GetEntry(atom);
         if (!entry)
             return;
-        if (entry->RemoveContent(aElement)) {
+        if (entry->RemoveElement(aElement)) {
             mRefMap.RemoveEntry(atom);
         }
     }
 }
 
 //----------------------------------------------------------------------
 //
 // nsIDOMNode interface
--- a/content/xul/document/src/nsXULDocument.h
+++ b/content/xul/document/src/nsXULDocument.h
@@ -85,27 +85,27 @@ public:
   {
   }
   nsRefMapEntry(const nsRefMapEntry& aOther) :
     nsISupportsHashKey(GetKey())
   {
     NS_ERROR("Should never be called");
   }
 
-  nsIContent* GetFirstContent();
+  mozilla::dom::Element* GetFirstElement();
   void AppendAll(nsCOMArray<nsIContent>* aElements);
   /**
-   * @return true if aContent was added, false if we failed due to OOM
+   * @return true if aElement was added, false if we failed due to OOM
    */
-  PRBool AddContent(nsIContent* aContent);
+  PRBool AddElement(mozilla::dom::Element* aElement);
   /**
-   * @return true if aContent was removed and it was the last content for
+   * @return true if aElement was removed and it was the last content for
    * this ref, so this entry should be removed from the map
    */
-  PRBool RemoveContent(nsIContent* aContent);
+  PRBool RemoveElement(mozilla::dom::Element* aElement);
 
 private:
   nsSmallVoidArray mRefContentList;
 };
 
 /**
  * The XUL document class
  */
@@ -160,19 +160,23 @@ public:
     NS_IMETHOD GetTemplateBuilderFor(nsIContent* aContent,
                                      nsIXULTemplateBuilder** aResult);
     NS_IMETHOD OnPrototypeLoadDone(PRBool aResumeWalk);
     PRBool OnDocumentParserError();
 
     // nsIDOMNode interface overrides
     NS_IMETHOD CloneNode(PRBool deep, nsIDOMNode **_retval);
 
-    // nsIDOMDocument interface overrides
-    NS_IMETHOD GetElementById(const nsAString & elementId,
-                              nsIDOMElement **_retval); 
+    // nsDocument interface overrides
+    NS_IMETHOD GetElementById(const nsAString& aId, nsIDOMElement** aReturn)
+    {
+        return nsDocument::GetElementById(aId, aReturn);
+    }
+    virtual mozilla::dom::Element* GetElementById(const nsAString & elementId,
+                                                  nsresult *aResult);
 
     // nsIDOMXULDocument interface
     NS_DECL_NSIDOMXULDOCUMENT
 
     // nsIDOMNSDocument
     NS_IMETHOD GetContentType(nsAString& aContentType);
 
     // nsICSSLoaderObserver
@@ -202,19 +206,19 @@ protected:
     // Implementation methods
     friend nsresult
     NS_NewXULDocument(nsIXULDocument** aResult);
 
     nsresult Init(void);
     nsresult StartLayout(void);
 
     nsresult
-    AddElementToRefMap(nsIContent* aElement);
+    AddElementToRefMap(mozilla::dom::Element* aElement);
     void
-    RemoveElementFromRefMap(nsIContent* aElement);
+    RemoveElementFromRefMap(mozilla::dom::Element* aElement);
 
     nsresult GetViewportSize(PRInt32* aWidth, PRInt32* aHeight);
 
     nsresult PrepareToLoad(nsISupports* aContainer,
                            const char* aCommand,
                            nsIChannel* aChannel,
                            nsILoadGroup* aLoadGroup,
                            nsIParser** aResult);