Bug 720124 - Remove dead code from HTMLContentSink: frameset - link - style - doctype; r=hsivonen
authorMs2ger <ms2ger@gmail.com>
Wed, 25 Jan 2012 08:48:59 +0100
changeset 86422 086f5438276f90f2a9bbfbfa891b92f1b33d09a3
parent 86421 90480621f7c5276483c563b864ee3943c8d6fb7f
child 86423 90ce75a0083fe9594a04b055cb35caee10ed843b
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsivonen
bugs720124
milestone12.0a1
Bug 720124 - Remove dead code from HTMLContentSink: frameset - link - style - doctype; r=hsivonen
content/html/document/src/nsHTMLContentSink.cpp
--- a/content/html/document/src/nsHTMLContentSink.cpp
+++ b/content/html/document/src/nsHTMLContentSink.cpp
@@ -238,17 +238,16 @@ protected:
 
   nsCOMPtr<nsIHTMLDocument> mHTMLDocument;
 
   // The maximum length of a text run
   PRInt32 mMaxTextRun;
 
   nsRefPtr<nsGenericHTMLElement> mRoot;
   nsRefPtr<nsGenericHTMLElement> mBody;
-  nsRefPtr<nsGenericHTMLElement> mFrameset;
   nsRefPtr<nsGenericHTMLElement> mHead;
 
   nsRefPtr<nsGenericHTMLElement> mCurrentForm;
 
   nsAutoTArray<SinkContext*, 8> mContextStack;
   SinkContext* mCurrentContext;
   SinkContext* mHeadContext;
   PRInt32 mNumOpenIFRAMES;
@@ -268,31 +267,22 @@ protected:
   PRUint8 mFramesEnabled : 1;
   PRUint8 mFormOnStack : 1;
   PRUint8 unused : 5;  // bits available if someone needs one
 
   nsINodeInfo* mNodeInfoCache[NS_HTML_TAG_MAX + 1];
 
   nsresult FlushTags();
 
-  void StartLayout(bool aIgnorePendingSheets);
-
   // Routines for tags that require special handling
   nsresult CloseHTML();
-  nsresult OpenFrameset(const nsIParserNode& aNode);
-  nsresult CloseFrameset();
   nsresult OpenBody(const nsIParserNode& aNode);
   nsresult CloseBody();
   nsresult OpenForm(const nsIParserNode& aNode);
   nsresult CloseForm();
-  nsresult ProcessLINKTag(const nsIParserNode& aNode);
-
-  // Routines for tags that require special handling when we reach their end
-  // tag.
-  nsresult ProcessSTYLEEndTag(nsGenericHTMLElement* content);
 
   nsresult OpenHeadContext();
   void CloseHeadContext();
 
   // nsContentSink overrides
   void UpdateChildCounts();
 
   void NotifyInsert(nsIContent* aContent,
@@ -653,18 +643,17 @@ SinkContext::IsCurrentContainer(nsHTMLTa
   }
 
   return false;
 }
 
 void
 SinkContext::DidAddContent(nsIContent* aContent)
 {
-  if ((mStackPos == 2) && (mSink->mBody == mStack[1].mContent ||
-                           mSink->mFrameset == mStack[1].mContent)) {
+  if ((mStackPos == 2) && (mSink->mBody == mStack[1].mContent)) {
     // We just finished adding something to the body
     mNotifyLevel = 0;
   }
 
   // If we just added content to a node for which
   // an insertion happen, we need to do an immediate
   // notification for that insertion.
   if (0 < mStackPos &&
@@ -735,35 +724,16 @@ SinkContext::OpenContainer(const nsIPars
   }
 
   mStack[mStackPos].mType = nodeType;
   mStack[mStackPos].mContent = content;
   mStack[mStackPos].mNumFlushed = 0;
   mStack[mStackPos].mInsertionPoint = -1;
   ++mStackPos;
 
-  // XXX Need to do this before we start adding attributes.
-  if (nodeType == eHTMLTag_style) {
-    nsCOMPtr<nsIStyleSheetLinkingElement> ssle = do_QueryInterface(content);
-    NS_ASSERTION(ssle, "Style content isn't a style sheet?");
-    ssle->SetLineNumber(aNode.GetSourceLineNumber());
-
-    // Now disable updates so that every time we add an attribute or child
-    // text token, we don't try to update the style sheet.
-    if (!mSink->mInsideNoXXXTag) {
-      ssle->InitStyleLinkElement(false);
-    }
-    else {
-      // We're not going to be evaluating this style anyway.
-      ssle->InitStyleLinkElement(true);
-    }
-
-    ssle->SetEnableUpdates(false);
-  }
-  
   rv = mSink->AddAttributes(aNode, content);
   MaybeSetForm(content, nodeType, mSink);
 
   mStack[mStackPos - 2].Add(content);
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (mSink->IsMonolithicContainer(nodeType)) {
@@ -772,36 +742,31 @@ SinkContext::OpenContainer(const nsIPars
 
   // Special handling for certain tags
   switch (nodeType) {
     case eHTMLTag_form:
       mSink->mCurrentForm = content;
       break;
 
     case eHTMLTag_frameset:
-      if (!mSink->mFrameset && mSink->mFramesEnabled) {
-        mSink->mFrameset = content;
-      }
+      MOZ_NOT_REACHED("Must not use HTMLContentSink for frames.");
       break;
 
     case eHTMLTag_noembed:
     case eHTMLTag_noframes:
       mSink->mInsideNoXXXTag++;
       break;
 
     case eHTMLTag_iframe:
       mSink->mNumOpenIFRAMES++;
       break;
 
     case eHTMLTag_script:
-      {
-        nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(content);
-        NS_ASSERTION(sele, "Script content isn't a script element?");
-        sele->SetScriptLineNumber(aNode.GetSourceLineNumber());
-      }
+    case eHTMLTag_style:
+      MOZ_NOT_REACHED("Must not use HTMLContentSink for styles and scripts.");
       break;
 
     case eHTMLTag_button:
 #ifdef MOZ_MEDIA
     case eHTMLTag_audio:
     case eHTMLTag_video:
 #endif
       content->DoneCreatingElement();
@@ -944,17 +909,18 @@ SinkContext::CloseContainer(const nsHTML
     break;
 
   case eHTMLTag_script:
     MOZ_NOT_REACHED("Must not use HTMLContentSink to run scripts.");
     result = NS_ERROR_NOT_IMPLEMENTED;
     break;
 
   case eHTMLTag_style:
-    result = mSink->ProcessSTYLEEndTag(content);
+    MOZ_NOT_REACHED("Must not use HTMLContentSink for styles.");
+    result = NS_ERROR_NOT_IMPLEMENTED;
     break;
 
   default:
     break;
   }
 
   NS_IF_RELEASE(content);
 
@@ -1001,18 +967,17 @@ SinkContext::AddLeaf(const nsIParserNode
       // Add new leaf to its parent
       AddLeaf(content);
 
       // Additional processing needed once the element is in the tree
       switch (nodeType) {
       case eHTMLTag_meta:
         // XXX It's just not sufficient to check if the parent is head. Also
         // check for the preference.
-        // Bug 40072: Don't evaluate METAs after FRAMESET.
-        if (!mSink->mInsideNoXXXTag && !mSink->mFrameset) {
+        if (!mSink->mInsideNoXXXTag) {
           rv = mSink->ProcessMETATag(content);
         }
         break;
 
       case eHTMLTag_input:
         content->DoneCreatingElement();
         break;
 
@@ -1099,17 +1064,17 @@ SinkContext::AddComment(const nsIParserN
   NS_ASSERTION(mStackPos > 0, "stack out of bounds");
   if (mStackPos <= 0) {
     return NS_ERROR_FAILURE;
   }
 
   {
     Node &parentNode = mStack[mStackPos - 1];
     nsGenericHTMLElement *parent = parentNode.mContent;
-    if (!mSink->mBody && !mSink->mFrameset && mSink->mHead)
+    if (!mSink->mBody && mSink->mHead)
       // XXXbz but this will make DidAddContent use the wrong parent for
       // the notification!  That seems so bogus it's not even funny.
       parentNode.mContent = mSink->mHead;
     DidAddContent(parentNode.Add(comment));
     parentNode.mContent = parent;
   }
 
 #ifdef DEBUG
@@ -1483,29 +1448,27 @@ HTMLContentSink::~HTMLContentSink()
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLContentSink)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLContentSink, nsContentSink)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mHTMLDocument)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mRoot)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mBody)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFrameset)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mHead)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCurrentForm)
   for (PRUint32 i = 0; i < ArrayLength(tmp->mNodeInfoCache); ++i) {
     NS_IF_RELEASE(tmp->mNodeInfoCache[i]);
   }
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLContentSink,
                                                   nsContentSink)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mHTMLDocument)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mRoot)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mBody)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFrameset)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mHead)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCurrentForm)
   for (PRUint32 i = 0; i < ArrayLength(tmp->mNodeInfoCache); ++i) {
     NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mNodeInfoCache[i]");
     cb.NoteXPCOMChild(tmp->mNodeInfoCache[i]);
   }
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
@@ -1667,17 +1630,17 @@ HTMLContentSink::WillBuildModel(nsDTDMod
 }
 
 NS_IMETHODIMP
 HTMLContentSink::DidBuildModel(bool aTerminated)
 {
   DidBuildModelImpl(aTerminated);
 
   // Reflow the last batch of content
-  if (mBody || mFrameset) {
+  if (mBody) {
     SINK_TRACE(gSinkLogModuleInfo, SINK_TRACE_REFLOW,
                ("HTMLContentSink::DidBuildModel: layout final content"));
     mCurrentContext->FlushTags();
   } else if (!mLayoutStarted) {
     // We never saw the body, and layout never got started. Force
     // layout *now*, to get an initial reflow.
     SINK_TRACE(gSinkLogModuleInfo, SINK_TRACE_REFLOW,
                ("HTMLContentSink::DidBuildModel: forcing reflow on empty "
@@ -1997,103 +1960,16 @@ HTMLContentSink::CloseForm()
     }
 
     mCurrentForm = nsnull;
   }
 
   return result;
 }
 
-nsresult
-HTMLContentSink::OpenFrameset(const nsIParserNode& aNode)
-{
-  SINK_TRACE_NODE(SINK_TRACE_CALLS,
-                  "HTMLContentSink::OpenFrameset", 
-                  eHTMLTag_frameset,
-                  mCurrentContext->mStackPos, 
-                  this);
-
-  CloseHeadContext(); // do this just in case if the HEAD was left open!
-
-  // Need to keep track of whether OpenContainer changes mFrameset
-  nsGenericHTMLElement* oldFrameset = mFrameset;
-  nsresult rv = mCurrentContext->OpenContainer(aNode);
-  bool isFirstFrameset = NS_SUCCEEDED(rv) && mFrameset != oldFrameset;
-
-  if (isFirstFrameset && mCurrentContext->mStackPos > 1) {
-    NS_ASSERTION(mFrameset, "Must have frameset!");
-    // Have to notify for the frameset now, since we never actually
-    // close out <html>, so won't notify for it then.
-    PRInt32 parentIndex    = mCurrentContext->mStackPos - 2;
-    nsGenericHTMLElement *parent = mCurrentContext->mStack[parentIndex].mContent;
-    PRInt32 numFlushed     = mCurrentContext->mStack[parentIndex].mNumFlushed;
-    PRInt32 childCount = parent->GetChildCount();
-    NS_ASSERTION(numFlushed < childCount, "Already notified on the frameset?");
-
-    PRInt32 insertionPoint =
-      mCurrentContext->mStack[parentIndex].mInsertionPoint;
-
-    // XXX: I have yet to see a case where numFlushed is non-zero and
-    // insertionPoint is not -1, but this code will try to handle
-    // those cases too.
-
-    PRUint32 oldUpdates = mUpdatesInNotification;
-    mUpdatesInNotification = 0;
-    if (insertionPoint != -1) {
-      NotifyInsert(parent, mFrameset, insertionPoint - 1);
-    } else {
-      NotifyAppend(parent, numFlushed);
-    }
-    mCurrentContext->mStack[parentIndex].mNumFlushed = childCount;
-    if (mUpdatesInNotification > 1) {
-      UpdateChildCounts();
-    }
-    mUpdatesInNotification = oldUpdates;
-  }
-  
-  return rv;
-}
-
-nsresult
-HTMLContentSink::CloseFrameset()
-{
-  SINK_TRACE_NODE(SINK_TRACE_CALLS,
-                   "HTMLContentSink::CloseFrameset", 
-                   eHTMLTag_frameset,
-                   mCurrentContext->mStackPos - 1,
-                   this);
-
-  SinkContext* sc = mCurrentContext;
-  nsGenericHTMLElement* fs = sc->mStack[sc->mStackPos - 1].mContent;
-  bool done = fs == mFrameset;
-
-  nsresult rv;
-  if (done) {
-    bool didFlush;
-    rv = sc->FlushTextAndRelease(&didFlush);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-
-    // Flush out anything that's left
-    SINK_TRACE(gSinkLogModuleInfo, SINK_TRACE_REFLOW,
-               ("HTMLContentSink::CloseFrameset: layout final content"));
-
-    sc->FlushTags();
-  }
-
-  rv = sc->CloseContainer(eHTMLTag_frameset);
-
-  if (done && mFramesEnabled) {
-    StartLayout(false);
-  }
-
-  return rv;
-}
-
 NS_IMETHODIMP
 HTMLContentSink::IsEnabled(PRInt32 aTag, bool* aReturn)
 {
   nsHTMLTag theHTMLTag = nsHTMLTag(aTag);
 
   if (theHTMLTag == eHTMLTag_script) {
     *aReturn = mScriptEnabled;
   } else if (theHTMLTag == eHTMLTag_frameset) {
@@ -2107,17 +1983,18 @@ HTMLContentSink::IsEnabled(PRInt32 aTag,
 
 NS_IMETHODIMP
 HTMLContentSink::OpenContainer(const nsIParserNode& aNode)
 {
   nsresult rv = NS_OK;
 
   switch (aNode.GetNodeType()) {
     case eHTMLTag_frameset:
-      rv = OpenFrameset(aNode);
+      MOZ_NOT_REACHED("Must not use HTMLContentSink for frames.");
+      rv = NS_ERROR_NOT_IMPLEMENTED;
       break;
     case eHTMLTag_head:
       rv = OpenHeadContext();
       if (NS_SUCCEEDED(rv)) {
         rv = AddAttributes(aNode, mHead, true, mHaveSeenHead);
         mHaveSeenHead = true;
       }
       break;
@@ -2148,17 +2025,18 @@ HTMLContentSink::OpenContainer(const nsI
 
 NS_IMETHODIMP
 HTMLContentSink::CloseContainer(const eHTMLTags aTag)
 {
   nsresult rv = NS_OK;
 
   switch (aTag) {
     case eHTMLTag_frameset:
-      rv = CloseFrameset();
+      MOZ_NOT_REACHED("Must not use HTMLContentSink for frames.");
+      rv = NS_ERROR_NOT_IMPLEMENTED;
       break;
     case eHTMLTag_head:
       CloseHeadContext();
       break;
     case eHTMLTag_body:
       rv = CloseBody();
       break;
     case eHTMLTag_html:
@@ -2184,18 +2062,18 @@ HTMLContentSink::CloseMalformedContainer
 NS_IMETHODIMP
 HTMLContentSink::AddLeaf(const nsIParserNode& aNode)
 {
   nsresult rv;
 
   nsHTMLTag nodeType = nsHTMLTag(aNode.GetNodeType());
   switch (nodeType) {
   case eHTMLTag_link:
-    mCurrentContext->FlushTextAndRelease();
-    rv = ProcessLINKTag(aNode);
+    rv = NS_ERROR_NOT_IMPLEMENTED;
+    MOZ_NOT_REACHED("Must not use HTMLContentSink for links.");
 
     break;
   default:
     rv = mCurrentContext->AddLeaf(aNode);
 
     break;
   }
 
@@ -2234,234 +2112,18 @@ HTMLContentSink::AddProcessingInstructio
 /**
  *  This gets called by the parser when it encounters
  *  a DOCTYPE declaration in the HTML document.
  */
 
 NS_IMETHODIMP
 HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode)
 {
-  nsAutoString docTypeStr(aNode.GetText());
-  nsresult rv = NS_OK;
-
-  PRInt32 publicStart = docTypeStr.Find("PUBLIC", true);
-  PRInt32 systemStart = docTypeStr.Find("SYSTEM", true);
-  nsAutoString name, publicId, systemId;
-
-  if (publicStart >= 0 || systemStart >= 0) {
-    /*
-     * If we find the keyword 'PUBLIC' after the keyword 'SYSTEM' we assume
-     * that we got a system id that happens to contain the string "PUBLIC"
-     * and we ignore that as the start of the public id.
-     */
-    if (systemStart >= 0 && (publicStart > systemStart)) {
-      publicStart = -1;
-    }
-
-    /*
-     * We found 'PUBLIC' or 'SYSTEM' in the doctype, put everything before
-     * the first one of those in name.
-     */
-    docTypeStr.Mid(name, 0, publicStart >= 0 ? publicStart : systemStart);
-
-    if (publicStart >= 0) {
-      // We did find 'PUBLIC'
-      docTypeStr.Mid(publicId, publicStart + 6,
-                     docTypeStr.Length() - publicStart);
-      publicId.Trim(" \t\n\r");
-
-      // Strip quotes
-      PRUnichar ch = publicId.IsEmpty() ? '\0' : publicId.First();
-
-      bool hasQuote = false;
-      if (ch == '"' || ch == '\'') {
-        publicId.Cut(0, 1);
-
-        PRInt32 end = publicId.FindChar(ch);
-
-        if (end < 0) {
-          /*
-           * We didn't find an end quote, so just make sure we cut off
-           * the '>' on the end of the doctype declaration
-           */
-
-          end = publicId.FindChar('>');
-        } else {
-          hasQuote = true;
-        }
-
-        /*
-         * If we didn't find a closing quote or a '>' we leave publicId as
-         * it is.
-         */
-        if (end >= 0) {
-          publicId.Truncate(end);
-        }
-      } else {
-        // No quotes, ignore the public id
-        publicId.Truncate();
-      }
-
-      /*
-       * Make sure the 'SYSTEM' word we found is not inside the pubilc id
-       */
-      PRInt32 pos = docTypeStr.Find(publicId);
-
-      if (systemStart > 0) {
-        if (systemStart < pos + (PRInt32)publicId.Length()) {
-          systemStart = docTypeStr.Find("SYSTEM", true,
-                                        pos + publicId.Length());
-        }
-      }
-
-      /*
-       * If we didn't find 'SYSTEM' we treat everything after the public id
-       * as the system id.
-       */
-      if (systemStart < 0) {
-        // 1 is the end quote
-        systemStart = pos + publicId.Length() + (hasQuote ? 1 : 0);
-      }
-    }
-
-    if (systemStart >= 0) {
-      // We either found 'SYSTEM' or we have data after the public id
-      docTypeStr.Mid(systemId, systemStart,
-                     docTypeStr.Length() - systemStart);
-
-      // Strip off 'SYSTEM' if we have it.
-      if (StringBeginsWith(systemId, NS_LITERAL_STRING("SYSTEM")))
-        systemId.Cut(0, 6);
-
-      systemId.Trim(" \t\n\r");
-
-      // Strip quotes
-      PRUnichar ch = systemId.IsEmpty() ? '\0' : systemId.First();
-
-      if (ch == '"' || ch == '\'') {
-        systemId.Cut(0, 1);
-
-        PRInt32 end = systemId.FindChar(ch);
-
-        if (end < 0) {
-          // We didn't find an end quote, then we just make sure we
-          // cut of the '>' on the end of the doctype declaration
-
-          end = systemId.FindChar('>');
-        }
-
-        // If we found an closing quote nor a '>' we truncate systemId
-        // at that length.
-        if (end >= 0) {
-          systemId.Truncate(end);
-        }
-      } else {
-        systemId.Truncate();
-      }
-    }
-  } else {
-    name.Assign(docTypeStr);
-  }
-
-  // Cut out "<!DOCTYPE" or "DOCTYPE" from the name.
-  if (StringBeginsWith(name, NS_LITERAL_STRING("<!DOCTYPE"), nsCaseInsensitiveStringComparator())) {
-    name.Cut(0, 9);
-  } else if (StringBeginsWith(name, NS_LITERAL_STRING("DOCTYPE"), nsCaseInsensitiveStringComparator())) {
-    name.Cut(0, 7);
-  }
-
-  name.Trim(" \t\n\r");
-
-  // Check if name contains whitespace chars. If it does and the first
-  // char is not a quote, we set the name to contain the characters
-  // before the whitespace
-  PRInt32 nameEnd = 0;
-
-  if (name.IsEmpty() || (name.First() != '"' && name.First() != '\'')) {
-    nameEnd = name.FindCharInSet(" \n\r\t");
-  }
-
-  // If we didn't find a public id we grab everything after the name
-  // and use that as public id.
-  if (publicStart < 0) {
-    name.Mid(publicId, nameEnd, name.Length() - nameEnd);
-    publicId.Trim(" \t\n\r");
-
-    PRUnichar ch = publicId.IsEmpty() ? '\0' : publicId.First();
-
-    if (ch == '"' || ch == '\'') {
-      publicId.Cut(0, 1);
-
-      PRInt32 publicEnd = publicId.FindChar(ch);
-
-      if (publicEnd < 0) {
-        publicEnd = publicId.FindChar('>');
-      }
-
-      if (publicEnd < 0) {
-        publicEnd = publicId.Length();
-      }
-
-      publicId.Truncate(publicEnd);
-    } else {
-      // No quotes, no public id
-      publicId.Truncate();
-    }
-  }
-
-  if (nameEnd >= 0) {
-    name.Truncate(nameEnd);
-  } else {
-    nameEnd = name.FindChar('>');
-
-    if (nameEnd >= 0) {
-      name.Truncate(nameEnd);
-    }
-  }
-
-  if (!publicId.IsEmpty() || !systemId.IsEmpty() || !name.IsEmpty()) {
-    nsCOMPtr<nsIDOMDocumentType> oldDocType;
-    nsCOMPtr<nsIDOMDocumentType> docType;
-
-    nsCOMPtr<nsIDOMDocument> doc(do_QueryInterface(mHTMLDocument));
-    doc->GetDoctype(getter_AddRefs(oldDocType));
-
-    // Assign "HTML" if we don't have anything, and normalize
-    // the name if it is something like "hTmL", per HTML5.
-    if (name.IsEmpty() || name.LowerCaseEqualsLiteral("html")) {
-      name.AssignLiteral("HTML");
-    }
-
-    nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(name);
-    if (!nameAtom) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-
-    // Indicate that there is no internal subset (not just an empty one)
-    rv = NS_NewDOMDocumentType(getter_AddRefs(docType),
-                               mDocument->NodeInfoManager(), nameAtom,
-                               publicId, systemId, NullString());
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    if (oldDocType) {
-      // If we already have a doctype we replace the old one.
-      nsCOMPtr<nsIDOMNode> tmpNode;
-      rv = doc->ReplaceChild(oldDocType, docType, getter_AddRefs(tmpNode));
-    } else {
-      // If we don't already have one we insert it as the first child,
-      // this might not be 100% correct but since this is called from
-      // the content sink we assume that this is what we want.
-      nsCOMPtr<nsIContent> content = do_QueryInterface(docType);
-      NS_ASSERTION(content, "Doctype isn't content?");
-      
-      mDocument->InsertChildAt(content, 0, true);
-    }
-  }
-
-  return rv;
+  MOZ_NOT_REACHED("Must not use HTMLContentSink for doctypes.");
+  return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 HTMLContentSink::DidProcessTokens(void)
 {
   return NS_OK;
 }
 
@@ -2484,28 +2146,16 @@ HTMLContentSink::WillInterrupt()
 }
 
 NS_IMETHODIMP
 HTMLContentSink::WillResume()
 {
   return WillResumeImpl();
 }
 
-void
-HTMLContentSink::StartLayout(bool aIgnorePendingSheets)
-{
-  if (mLayoutStarted) {
-    return;
-  }
-
-  mHTMLDocument->SetIsFrameset(mFrameset != nsnull);
-
-  nsContentSink::StartLayout(aIgnorePendingSheets);
-}
-
 nsresult
 HTMLContentSink::OpenHeadContext()
 {
   if (mCurrentContext && mCurrentContext->IsCurrentContainer(eHTMLTag_head))
     return NS_OK;
 
   // Flush everything in the current context so that we don't have
   // to worry about insertions resulting in inconsistent frame creation.
@@ -2547,23 +2197,16 @@ HTMLContentSink::CloseHeadContext()
   if (!mContextStack.IsEmpty())
   {
     PRUint32 n = mContextStack.Length() - 1;
     mCurrentContext = mContextStack.ElementAt(n);
     mContextStack.RemoveElementAt(n);
   }
 }
 
-nsresult
-HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
-{
-  MOZ_NOT_REACHED("Old HTMLContentSink used for processing links.");
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
 #ifdef DEBUG
 void
 HTMLContentSink::ForceReflow()
 {
   mCurrentContext->FlushTags();
 }
 #endif
 
@@ -2636,26 +2279,16 @@ HTMLContentSink::UpdateChildCounts()
     SinkContext* sc = mContextStack.ElementAt(i);
 
     sc->UpdateChildCounts();
   }
 
   mCurrentContext->UpdateChildCounts();
 }
 
-// 3 ways to load a style sheet: inline, style src=, link tag
-// XXX What does nav do if we have SRC= and some style data inline?
-
-nsresult
-HTMLContentSink::ProcessSTYLEEndTag(nsGenericHTMLElement* content)
-{
-  MOZ_NOT_REACHED("Old HTMLContentSink used for processing style elements.");
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
 void
 HTMLContentSink::FlushPendingNotifications(mozFlushType aType)
 {
   // Only flush tags if we're not doing the notification ourselves
   // (since we aren't reentrant)
   if (!mInNotification) {
     // Only flush if we're still a document observer (so that our child counts
     // should be correct).