Bug 487023. Refactor IsCaseSensitive() into non-virtual inline IsHTML(). r=hsivonen, sr=jst
authorDavid Zbarsky <dzbarsky@gmail.com>
Tue, 25 Aug 2009 13:15:55 -0400
changeset 31946 2f27256aa1542fba50f6ccb1b59666a60c744980
parent 31945 bf78b6bb0b03028777302c582b8a36030bb220a4
child 31947 7af754a937d69cec0d2dbce5df4609b6b7d50770
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsivonen, jst
bugs487023
milestone1.9.3a1pre
Bug 487023. Refactor IsCaseSensitive() into non-virtual inline IsHTML(). r=hsivonen, sr=jst
content/base/public/nsIContent.h
content/base/public/nsIDocument.h
content/base/src/nsContentUtils.cpp
content/base/src/nsCopySupport.cpp
content/base/src/nsDocument.cpp
content/base/src/nsDocument.h
content/base/src/nsDocumentEncoder.cpp
content/base/src/nsHTMLContentSerializer.cpp
content/html/content/src/nsGenericHTMLElement.cpp
content/html/document/src/nsHTMLDocument.cpp
content/html/document/src/nsHTMLDocument.h
content/xslt/src/xpath/nsXPathEvaluator.cpp
content/xslt/src/xslt/txMozillaXSLTProcessor.cpp
--- a/content/base/public/nsIContent.h
+++ b/content/base/public/nsIContent.h
@@ -212,17 +212,17 @@ public:
   /**
    * Return true iff this node is in an HTML document (in the HTML5 sense of
    * the term, i.e. not in an XHTML/XML document).
    */
   inline PRBool IsInHTMLDocument() const
   {
     nsIDocument* doc = GetOwnerDoc();
     return doc && // XXX clean up after bug 335998 lands
-           !doc->IsCaseSensitive();
+           doc->IsHTML();
   }
 
   /**
    * Get the namespace that this element's tag is defined in
    * @return the namespace
    */
   PRInt32 GetNameSpaceID() const
   {
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -718,19 +718,19 @@ public:
    */
   virtual void SetXMLDeclaration(const PRUnichar *aVersion,
                                  const PRUnichar *aEncoding,
                                  const PRInt32 aStandalone) = 0;
   virtual void GetXMLDeclaration(nsAString& aVersion,
                                  nsAString& aEncoding,
                                  nsAString& Standalone) = 0;
 
-  virtual PRBool IsCaseSensitive()
+  PRBool IsHTML() const
   {
-    return PR_TRUE;
+    return mIsRegularHTML;
   }
 
   virtual PRBool IsScriptEnabled() = 0;
 
   virtual nsresult AddXMLEventsContent(nsIContent * aXMLEventsElement) = 0;
 
   /**
    * Create an element with the specified name, prefix and namespace ID.
@@ -1228,16 +1228,18 @@ protected:
   // True if this document is the initial document for a window.  This should
   // basically be true only for documents that exist in newly-opened windows or
   // documents created to satisfy a GetDocument() on a window when there's no
   // document in it.
   PRPackedBool mIsInitialDocumentInWindow;
 
   PRPackedBool mShellsAreHidden;
 
+  PRPackedBool mIsRegularHTML;
+
   // True if we're loaded as data and therefor has any dangerous stuff, such
   // as scripts and plugins, disabled.
   PRPackedBool mLoadedAsData;
 
   // If true, whoever is creating the document has gotten it to the
   // point where it's safe to start layout on it.
   PRPackedBool mMayStartLayout;
   
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -3583,17 +3583,17 @@ nsContentUtils::CreateContextualFragment
   nsCOMPtr<nsINode> node = do_QueryInterface(aContextNode);
   NS_ENSURE_TRUE(node, NS_ERROR_NOT_AVAILABLE);
 
   // If we don't have a document here, we can't get the right security context
   // for compiling event handlers... so just bail out.
   nsCOMPtr<nsIDocument> document = node->GetOwnerDoc();
   NS_ENSURE_TRUE(document, NS_ERROR_NOT_AVAILABLE);
   
-  PRBool bCaseSensitive = document->IsCaseSensitive();
+  PRBool bCaseSensitive = !document->IsHTML();
 
   nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(document));
   PRBool isHTML = htmlDoc && !bCaseSensitive;
 
   if (isHTML && nsHtml5Module::sEnabled) {
     // See if the document has a cached fragment parser. nsHTMLDocument is the
     // only one that should really have one at the moment.
     nsCOMPtr<nsIParser> parser = document->GetFragmentParser();
--- a/content/base/src/nsCopySupport.cpp
+++ b/content/base/src/nsCopySupport.cpp
@@ -378,17 +378,17 @@ nsresult nsCopySupport::IsPlainTextConte
     }
   }
   
   // also consider ourselves in a text widget if we can't find an html
   // document. Note that XHTML is not counted as HTML here, because we can't
   // copy it properly (all the copy code for non-plaintext assumes using HTML
   // serializers and parsers is OK, and those mess up XHTML).
   nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(aDoc);
-  if (!htmlDoc || aDoc->IsCaseSensitive())
+  if (!(htmlDoc && aDoc->IsHTML()))
     *aIsPlainTextContext = PR_TRUE;
 
   return NS_OK;
 }
 
 nsresult
 nsCopySupport::GetContents(const nsACString& aMimeType, PRUint32 aFlags, nsISelection *aSel, nsIDocument *aDoc, nsAString& outdata)
 {
@@ -536,17 +536,17 @@ static nsresult AppendDOMNode(nsITransfe
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Note that XHTML is not counted as HTML here, because we can't copy it
   // properly (all the copy code for non-plaintext assumes using HTML
   // serializers and parsers is OK, and those mess up XHTML).
   nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(domDocument, &rv);
   NS_ENSURE_SUCCESS(rv, NS_OK);
 
-  NS_ENSURE_TRUE(!(document->IsCaseSensitive()), NS_OK);
+  NS_ENSURE_TRUE(document->IsHTML(), NS_OK);
 
   // init encoder with document and node
   rv = docEncoder->Init(domDocument, NS_LITERAL_STRING(kHTMLMime),
                         nsIDocumentEncoder::OutputAbsoluteLinks |
                         nsIDocumentEncoder::OutputEncodeW3CEntities);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = docEncoder->SetNode(aDOMNode);
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -4075,17 +4075,17 @@ NS_IMETHODIMP
 nsDocument::CreateElement(const nsAString& aTagName,
                           nsIDOMElement** aReturn)
 {
   *aReturn = nsnull;
 
   nsresult rv = nsContentUtils::CheckQName(aTagName, PR_FALSE);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  NS_ASSERTION(IsCaseSensitive(),
+  NS_ASSERTION(!IsHTML(),
                "nsDocument::CreateElement() called on document that is not "
                "case sensitive. Fix caller, or fix "
                "nsDocument::CreateElement()!");
 
   nsCOMPtr<nsIAtom> name = do_GetAtom(aTagName);
 
   nsCOMPtr<nsIContent> content;
   rv = CreateElem(name, nsnull, GetDefaultNamespaceID(), PR_TRUE,
@@ -6362,17 +6362,17 @@ nsDocument::IsScriptEnabled()
   return enabled;
 }
 
 nsresult
 nsDocument::GetRadioGroup(const nsAString& aName,
                           nsRadioGroupStruct **aRadioGroup)
 {
   nsAutoString tmKey(aName);
-  if(!IsCaseSensitive())
+  if(IsHTML())
      ToLowerCase(tmKey); //should case-insensitive.
   if (mRadioGroups.Get(tmKey, aRadioGroup))
     return NS_OK;
 
   nsAutoPtr<nsRadioGroupStruct> radioGroup(new nsRadioGroupStruct());
   NS_ENSURE_TRUE(radioGroup, NS_ERROR_OUT_OF_MEMORY);
   NS_ENSURE_TRUE(mRadioGroups.Put(tmKey, radioGroup), NS_ERROR_OUT_OF_MEMORY);
 
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -1050,16 +1050,17 @@ protected:
   nsIContent* GetBodyContent() {
     return GetHtmlChildContent(nsGkAtoms::body);
   }
   // Get the canonical <head> element, or return null if there isn't one (e.g.
   // if the root isn't <html> or if the <head> isn't there)
   nsIContent* GetHeadContent() {
     return GetHtmlChildContent(nsGkAtoms::head);
   }
+
   // Get the first <title> element with the given IsNodeOfType type, or
   // return null if there isn't one
   nsIContent* GetTitleContent(PRUint32 aNodeType);
   // Find the first "title" element in the given IsNodeOfType type and
   // append the concatenation of its text node children to aTitle. Do
   // nothing if there is no such element.
   void GetTitleFromElement(PRUint32 aNodeType, nsAString& aTitle);
 
@@ -1167,20 +1168,17 @@ protected:
   // has been saved.
   PRPackedBool mRemovedFromDocShell:1;
   // True if the document is being destroyed.
   PRPackedBool mInDestructor:1;
   // True if the document "page" is not hidden
   PRPackedBool mVisible:1;
   // True if document has ever had script handling object.
   PRPackedBool mHasHadScriptHandlingObject:1;
-  // True if this is a regular (non-XHTML) HTML document
-  // XXXbz should this be reset if someone manually calls
-  // SetContentType() on this document?
-  PRPackedBool mIsRegularHTML:1;
+
   // True if this document has ever had an HTML or SVG <title> element
   // bound to it
   PRPackedBool mMayHaveTitleElement:1;
 
   PRPackedBool mHasWarnedAboutBoxObjects:1;
 
   PRPackedBool mDelayFrameLoaderInitialization:1;
 
--- a/content/base/src/nsDocumentEncoder.cpp
+++ b/content/base/src/nsDocumentEncoder.cpp
@@ -1180,17 +1180,17 @@ nsHTMLCopyEncoder::SetSelection(nsISelec
         mIsTextWidget = PR_TRUE;
         break;
       }
     }
   }
   
   // also consider ourselves in a text widget if we can't find an html document
   nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
-  if (!htmlDoc || mDocument->IsCaseSensitive())
+  if (!(htmlDoc && mDocument->IsHTML()))
     mIsTextWidget = PR_TRUE;
   
   // normalize selection if we are not in a widget
   if (mIsTextWidget) 
   {
     mSelection = aSelection;
     mMimeType.AssignLiteral("text/plain");
     return NS_OK;
--- a/content/base/src/nsHTMLContentSerializer.cpp
+++ b/content/base/src/nsHTMLContentSerializer.cpp
@@ -116,19 +116,18 @@ nsHTMLContentSerializer::SerializeAttrib
 
   nsresult rv;
   nsAutoString nameStr, valueStr;
   NS_NAMED_LITERAL_STRING(_mozStr, "_moz");
 
   // HTML5 parser stored them in the order they were parsed so we want to
   // loop forward in that case.
   nsIDocument* doc = aContent->GetOwnerDocument();
-  PRBool caseSensitive = doc && doc->IsCaseSensitive();
   PRBool loopForward = PR_FALSE;
-  if (!caseSensitive) {
+  if (!doc || doc->IsHTML()) {
     nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(doc));
     if (htmlDoc) {
       loopForward = nsHtml5Module::sEnabled;
     }
   }
   PRInt32 index, limit, step;
   if (loopForward) {
     index = 0;
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -647,17 +647,17 @@ nsGenericHTMLElement::GetInnerHTML(nsASt
   }
   
   nsCOMPtr<nsIDocumentEncoder> docEncoder;
   docEncoder =
     do_CreateInstance(PromiseFlatCString(
         nsDependentCString(NS_DOC_ENCODER_CONTRACTID_BASE) +
         NS_ConvertUTF16toUTF8(contentType)
       ).get());
-  if (!docEncoder && doc->IsCaseSensitive()) {
+  if (!(docEncoder || doc->IsHTML())) {
     // This could be some type for which we create a synthetic document.  Try
     // again as XML
     contentType.AssignLiteral("application/xml");
     docEncoder = do_CreateInstance(NS_DOC_ENCODER_CONTRACTID_BASE "application/xml");
   }
 
   NS_ENSURE_TRUE(docEncoder, NS_ERROR_FAILURE);
 
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -272,17 +272,17 @@ 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
   // match our compat mode.
-  CSSLoader()->SetCaseSensitive(IsXHTML());
+  CSSLoader()->SetCaseSensitive(!IsHTML());
   CSSLoader()->SetCompatibilityMode(mCompatMode);
 
   PrePopulateIdentifierMap();
   return NS_OK;
 }
 
 
 void
@@ -323,21 +323,21 @@ nsHTMLDocument::ResetToURI(nsIURI *aURI,
   // document, after all. Once we start getting data, this may be
   // changed.
   mContentType = "text/html";
 }
 
 nsStyleSet::sheetType
 nsHTMLDocument::GetAttrSheetType()
 {
-  if (IsXHTML()) {
-    return nsDocument::GetAttrSheetType();
+  if (IsHTML()) {
+    return nsStyleSet::eHTMLPresHintSheet;
   }
-  
-  return nsStyleSet::eHTMLPresHintSheet;
+
+  return nsDocument::GetAttrSheetType();
 }
 
 nsresult
 nsHTMLDocument::CreateShell(nsPresContext* aContext,
                             nsIViewManager* aViewManager,
                             nsStyleSet* aStyleSet,
                             nsIPresShell** aInstancePtrResult)
 {
@@ -677,17 +677,17 @@ nsHTMLDocument::StartDocumentLoad(const 
   }
 #ifdef DEBUG
   else {
     NS_ASSERTION(mIsRegularHTML,
                  "Hey, someone forgot to reset mIsRegularHTML!!!");
   }
 #endif
 
-  CSSLoader()->SetCaseSensitive(IsXHTML());
+  CSSLoader()->SetCaseSensitive(!IsHTML());
   CSSLoader()->SetCompatibilityMode(mCompatMode);
   
   PRBool needsParser = PR_TRUE;
   if (aCommand)
   {
     if (!nsCRT::strcmp(aCommand, "view delayedContentLoad")) {
       needsParser = PR_FALSE;
     }
@@ -735,17 +735,17 @@ nsHTMLDocument::StartDocumentLoad(const 
   // mParentDocument.
 
   // in this block of code, if we get an error result, we return it
   // but if we get a null pointer, that's perfectly legal for parent
   // and parentContentViewer
   nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(aContainer));
 
   // No support yet for docshell-less HTML
-  NS_ENSURE_TRUE(docShell || IsXHTML(), NS_ERROR_FAILURE);
+  NS_ENSURE_TRUE(docShell || !IsHTML(), NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
 
   nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
   if (docShellAsItem) {
     docShellAsItem->GetSameTypeParent(getter_AddRefs(parentAsItem));
   }
 
@@ -795,17 +795,17 @@ nsHTMLDocument::StartDocumentLoad(const 
 
   // These are the charset source and charset for the parser.  This can differ
   // from that for the document if the channel is a wyciwyg channel.
   PRInt32 parserCharsetSource;
   nsCAutoString parserCharset;
 
   nsCOMPtr<nsIWyciwygChannel> wyciwygChannel;
   
-  if (IsXHTML()) {
+  if (!IsHTML()) {
     charsetSource = kCharsetFromDocTypeDefault;
     charset.AssignLiteral("UTF-8");
     TryChannelCharset(aChannel, charsetSource, charset);
     parserCharsetSource = charsetSource;
     parserCharset = charset;
   } else {
     NS_ASSERTION(docShell && docShellAsItem, "Unexpected null value");
     
@@ -939,17 +939,17 @@ nsHTMLDocument::StartDocumentLoad(const 
 
     // create the content sink
     nsCOMPtr<nsIContentSink> sink;
 
     if (aSink) {
       NS_ASSERTION(!loadAsHtml5, "Panic: We are loading as HTML5 and someone tries to set an external sink!");
       sink = aSink;
     } else {
-      if (IsXHTML()) {
+      if (!IsHTML()) {
         nsCOMPtr<nsIXMLContentSink> xmlsink;
         rv = NS_NewXMLContentSink(getter_AddRefs(xmlsink), this, uri,
                                   docShell, aChannel);
 
         sink = xmlsink;
       } else {
         if (loadAsHtml5) {
           nsHtml5Module::Initialize(mParser, this, uri, docShell, aChannel);
@@ -1140,17 +1140,17 @@ nsHTMLDocument::GetImageMap(const nsAStr
 
   for (i = 0; i < n; ++i) {
     nsIDOMHTMLMapElement *map = mImageMaps[i];
     NS_ASSERTION(map, "Null map in map list!");
 
     PRBool match;
     nsresult rv;
 
-    if (IsXHTML()) {
+    if (!IsHTML()) {
       rv = map->GetId(name);
 
       match = name.Equals(aMapName);
     } else {
       rv = map->GetName(name);
 
       match = name.Equals(aMapName, nsCaseInsensitiveStringComparator());
     }
@@ -1177,36 +1177,30 @@ nsHTMLDocument::GetImageMap(const nsAStr
   }
 
   return firstMatch;
 }
 
 void
 nsHTMLDocument::SetCompatibilityMode(nsCompatibility aMode)
 {
-  NS_ASSERTION(!IsXHTML() || aMode == eCompatibility_FullStandards,
+  NS_ASSERTION(IsHTML() || aMode == eCompatibility_FullStandards,
                "Bad compat mode for XHTML document!");
 
   mCompatMode = aMode;
   CSSLoader()->SetCompatibilityMode(mCompatMode);
   nsCOMPtr<nsIPresShell> shell = GetPrimaryShell();
   if (shell) {
     nsPresContext *pc = shell->GetPresContext();
     if (pc) {
       pc->CompatibilityModeChanged();
     }
   }
 }
 
-PRBool
-nsHTMLDocument::IsCaseSensitive()
-{
-  return IsXHTML();
-}
-
 //
 // nsIDOMDocument interface implementation
 //
 NS_IMETHODIMP
 nsHTMLDocument::CreateElement(const nsAString& aTagName,
                               nsIDOMElement** aReturn)
 {
   *aReturn = nsnull;
@@ -1220,17 +1214,17 @@ nsHTMLDocument::CreateElement(const nsAS
       tagName.First() == '<' &&
       tagName.Last() == '>') {
     tagName = Substring(tagName, 1, tagName.Length() - 2); 
   }
 
   rv = nsContentUtils::CheckQName(tagName, PR_FALSE);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (!IsXHTML()) {
+  if (IsHTML()) {
     ToLowerCase(tagName);
   }
 
   nsCOMPtr<nsIAtom> name = do_GetAtom(tagName);
 
   nsCOMPtr<nsIContent> content;
   rv = CreateElem(name, nsnull, kNameSpaceID_XHTML, PR_TRUE,
                   getter_AddRefs(content));
@@ -1247,45 +1241,45 @@ nsHTMLDocument::CreateElementNS(const ns
   return nsDocument::CreateElementNS(aNamespaceURI, aQualifiedName, aReturn);
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::CreateProcessingInstruction(const nsAString& aTarget,
                                             const nsAString& aData,
                                             nsIDOMProcessingInstruction** aReturn)
 {
-  if (IsXHTML()) {
+  if (!IsHTML()) {
     return nsDocument::CreateProcessingInstruction(aTarget, aData, aReturn);
   }
 
   // There are no PIs for HTML
   *aReturn = nsnull;
 
   return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::CreateCDATASection(const nsAString& aData,
                                    nsIDOMCDATASection** aReturn)
 {
-  if (IsXHTML()) {
+  if (!IsHTML()) {
     return nsDocument::CreateCDATASection(aData, aReturn);
   }
 
   // There are no CDATASections in HTML
   *aReturn = nsnull;
 
   return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::CreateEntityReference(const nsAString& aName,
                                       nsIDOMEntityReference** aReturn)
 {
-  if (IsXHTML()) {
+  if (!IsHTML()) {
     return nsDocument::CreateEntityReference(aName, aReturn);
   }
 
   // There are no EntityReferences in HTML
   *aReturn = nsnull;
 
   return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
 }
@@ -1332,17 +1326,17 @@ nsHTMLDocument::CreateTextNode(const nsA
   return nsDocument::CreateTextNode(aData, aReturn);
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetElementsByTagName(const nsAString& aTagname,
                                      nsIDOMNodeList** aReturn)
 {
   nsAutoString tmp(aTagname);
-  if (!IsXHTML()) {
+  if (IsHTML()) {
     ToLowerCase(tmp); // HTML elements are lower case internally.
   }
   return nsDocument::GetElementsByTagName(tmp, aReturn);
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetBaseURI(nsAString &aURI)
 {
@@ -1362,64 +1356,64 @@ nsHTMLDocument::GetBaseURI(nsAString &aU
 
   return NS_OK;
 }
 
 // nsIDOM3Document interface implementation
 NS_IMETHODIMP
 nsHTMLDocument::GetXmlEncoding(nsAString& aXmlEncoding)
 {
-  if (IsXHTML()) {
+  if (!IsHTML()) {
     return nsDocument::GetXmlEncoding(aXmlEncoding);
   }
 
   SetDOMStringToNull(aXmlEncoding);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetXmlStandalone(PRBool *aXmlStandalone)
 {
-  if (IsXHTML()) {
+  if (!IsHTML()) {
     return nsDocument::GetXmlStandalone(aXmlStandalone);
   }
 
   *aXmlStandalone = PR_FALSE;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::SetXmlStandalone(PRBool aXmlStandalone)
 {
-  if (IsXHTML()) {
+  if (!IsHTML()) {
     return nsDocument::SetXmlStandalone(aXmlStandalone);
   }
 
   return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
 }
 
 
 NS_IMETHODIMP
 nsHTMLDocument::GetXmlVersion(nsAString& aXmlVersion)
 {
-  if (IsXHTML()) {
+  if (!IsHTML()) {
     return nsDocument::GetXmlVersion(aXmlVersion);
   }
 
   SetDOMStringToNull(aXmlVersion);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::SetXmlVersion(const nsAString& aXmlVersion)
 {
-  if (IsXHTML()) {
+  if (!IsHTML()) {
     return nsDocument::SetXmlVersion(aXmlVersion);
   }
 
   return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
 }
 
 //
 // nsIDOMHTMLDocument interface implementation
@@ -1560,23 +1554,23 @@ nsHTMLDocument::GetBody(nsIDOMHTMLElemen
     return CallQueryInterface(body, aBody);
   }
 
   // The document is most likely a frameset document so look for the
   // outer most frameset element
   nsCOMPtr<nsIDOMNodeList> nodeList;
 
   nsresult rv;
-  if (IsXHTML()) {
+  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));
-  } else {
-    rv = GetElementsByTagName(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;
 }
@@ -1794,17 +1788,17 @@ nsHTMLDocument::SetCookie(const nsAStrin
 
   return NS_OK;
 }
 
 // XXX TBI: accepting arguments to the open method.
 nsresult
 nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
 {
-  if (IsXHTML()) {
+  if (!IsHTML()) {
     // No calling document.open() on XHTML
 
     return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
   }
 
   PRBool loadAsHtml5 = nsHtml5Module::sEnabled;
 
   nsresult rv = NS_OK;
@@ -2054,17 +2048,17 @@ nsHTMLDocument::Clear()
 {
   // This method has been deprecated
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::Close()
 {
-  if (IsXHTML()) {
+  if (!IsHTML()) {
     // No calling document.close() on XHTML!
 
     return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
   }
 
   nsresult rv = NS_OK;
 
   if (mParser && mWriteState == eDocumentOpened) {
@@ -2119,17 +2113,17 @@ nsHTMLDocument::Close()
 nsresult
 nsHTMLDocument::WriteCommon(const nsAString& aText,
                             PRBool aNewlineTerminate)
 {
   mTooDeepWriteRecursion =
     (mWriteLevel > NS_MAX_DOCUMENT_WRITE_DEPTH || mTooDeepWriteRecursion);
   NS_ENSURE_STATE(!mTooDeepWriteRecursion);
 
-  if (IsXHTML()) {
+  if (!IsHTML()) {
     // No calling document.write*() on XHTML!
 
     return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
   }
 
   nsresult rv = NS_OK;
 
   void *key = GenerateParserKey();
--- a/content/html/document/src/nsHTMLDocument.h
+++ b/content/html/document/src/nsHTMLDocument.h
@@ -118,18 +118,16 @@ public:
 
   virtual PRBool GetIsFrameset() { return mIsFrameset; }
   virtual void SetIsFrameset(PRBool aFrameset) { mIsFrameset = aFrameset; }
 
   virtual NS_HIDDEN_(nsContentList*) GetForms();
  
   virtual NS_HIDDEN_(nsContentList*) GetFormControls();
  
-  virtual PRBool IsCaseSensitive();
-
   // nsIDOMDocument interface
   NS_DECL_NSIDOMDOCUMENT
 
   // nsIDOM3Document interface
   NS_IMETHOD GetXmlEncoding(nsAString& aXmlVersion);
   NS_IMETHOD GetXmlStandalone(PRBool *aXmlStandalone);
   NS_IMETHOD SetXmlStandalone(PRBool aXmlStandalone);
   NS_IMETHOD GetXmlVersion(nsAString& aXmlVersion);
@@ -174,20 +172,16 @@ public:
   virtual void ScriptLoading(nsIScriptElement *aScript);
   virtual void ScriptExecuted(nsIScriptElement *aScript);
 
   virtual void AddedForm();
   virtual void RemovedForm();
   virtual PRInt32 GetNumFormsSynchronous();
   virtual void TearingDownEditor(nsIEditor *aEditor);
   virtual void SetIsXHTML(PRBool aXHTML) { mIsRegularHTML = !aXHTML; }
-  PRBool IsXHTML()
-  {
-    return !mIsRegularHTML;
-  }
 
   nsresult ChangeContentEditableCount(nsIContent *aElement, PRInt32 aChange);
 
   virtual EditingState GetEditingState()
   {
     return mEditingState;
   }
 
--- a/content/xslt/src/xpath/nsXPathEvaluator.cpp
+++ b/content/xslt/src/xpath/nsXPathEvaluator.cpp
@@ -219,17 +219,17 @@ nsXPathEvaluator::CreateExpression(const
         NS_ENSURE_SUCCESS(rv, rv);
         
         mRecycler = recycler;
     }
 
     nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
     nsXPathEvaluatorParseContext pContext(*this, aResolver, aNamespaceIDs,
                                           aContractIDs, aState,
-                                          !doc || doc->IsCaseSensitive());
+                                          !(doc && doc->IsHTML()));
 
     nsAutoPtr<Expr> expression;
     rv = txExprParser::createExpr(PromiseFlatString(aExpression), &pContext,
                                   getter_Transfers(expression));
     if (NS_FAILED(rv)) {
         if (rv == NS_ERROR_DOM_NAMESPACE_ERR) {
             return NS_ERROR_DOM_NAMESPACE_ERR;
         }
--- a/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp
+++ b/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp
@@ -188,20 +188,20 @@ txToFragmentHandlerFactory::createHandle
         {
             txOutputFormat format;
             format.merge(*aFormat);
             nsCOMPtr<nsIDOMDocument> domdoc;
             mFragment->GetOwnerDocument(getter_AddRefs(domdoc));
             NS_ASSERTION(domdoc, "unable to get ownerdocument");
             nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
 
-            if (!doc || doc->IsCaseSensitive()) {
+            if (doc && doc->IsHTML()) {
+                format.mMethod = eHTMLOutput;
+            } else {
                 format.mMethod = eXMLOutput;
-            } else {
-                format.mMethod = eHTMLOutput;
             }
 
             *aHandler = new txMozillaXMLOutput(&format, mFragment, PR_FALSE);
             break;
         }
 
         case eXMLOutput:
         case eHTMLOutput: