Bug 468708 - namespaceURI for HTML elements should be http://www.w3.org/1999/xhtml (also make localName return in lower case) r=sicking, sr=peterv, a=beltzner
authorHenri Sivonen <hsivonen@iki.fi>
Tue, 09 Jun 2009 10:41:19 +0300
changeset 29004 39f1a74e500b5eebbe9009419951088c918042e0
parent 29003 66a40d5fda11d2aac03c2ef9ffb39c4039ec78ba
child 29005 9373d3073796951f79a6c9cc87fd93ebb5ad142b
push id7366
push userhsivonen@iki.fi
push dateTue, 09 Jun 2009 08:24:49 +0000
treeherderautoland@39f1a74e500b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking, peterv, beltzner
bugs468708
milestone1.9.2a1pre
Bug 468708 - namespaceURI for HTML elements should be http://www.w3.org/1999/xhtml (also make localName return in lower case) r=sicking, sr=peterv, a=beltzner
accessible/tests/mochitest/grid.js
browser/base/content/test/test_contextmenu.html
content/base/public/nsIContent.h
content/base/src/nsFrameLoader.cpp
content/base/src/nsXHTMLContentSerializer.cpp
content/base/test/test_bug276037-1.html
content/html/content/src/nsGenericHTMLElement.cpp
content/html/content/src/nsGenericHTMLElement.h
content/html/content/src/nsHTMLOptionElement.cpp
content/html/content/src/nsHTMLStyleElement.cpp
content/html/content/src/nsHTMLTableRowElement.cpp
content/html/document/src/nsHTMLContentSink.cpp
content/html/document/src/nsHTMLDocument.cpp
content/html/document/src/nsHTMLDocument.h
content/html/document/src/nsHTMLFragmentContentSink.cpp
content/html/document/src/nsImageDocument.cpp
content/html/document/src/nsMediaDocument.cpp
content/html/document/src/nsPluginDocument.cpp
content/html/document/src/nsVideoDocument.cpp
content/xml/tests/toc/toc.js
content/xslt/src/xpath/txNameTest.cpp
content/xslt/src/xpath/txXPathTreeWalker.h
content/xslt/src/xslt/txMozillaXMLOutput.cpp
content/xslt/src/xslt/txMozillaXMLOutput.h
editor/libeditor/base/nsEditor.cpp
layout/build/nsContentDLF.cpp
layout/forms/nsComboboxControlFrame.cpp
layout/forms/nsFileControlFrame.cpp
layout/forms/nsIsIndexFrame.cpp
layout/generic/nsObjectFrame.cpp
layout/style/nsCSSRuleProcessor.cpp
testing/tests/l10n/web/code-base.js
--- a/accessible/tests/mochitest/grid.js
+++ b/accessible/tests/mochitest/grid.js
@@ -73,17 +73,17 @@ function grid(aTableIdentifier)
     if (aEvent instanceof nsIDOMKeyEvent)
       this.handleKeyEvent(aEvent);
     else
       this.handleClickEvent(aEvent);
   }
 
   this.handleKeyEvent = function handleKeyEvent(aEvent)
   {
-    if (aEvent.target.localName != "TD")
+    if (aEvent.target.localName != "td")
       return;
 
     var cell = aEvent.target;
     switch(aEvent.keyCode) {
       case nsIDOMKeyEvent.DOM_VK_UP:
         var colsCount = this.getColsCount();
         var idx = this.getIndexByCell(cell);
         var upidx = idx - colsCount;
@@ -126,17 +126,17 @@ function grid(aTableIdentifier)
           nextcell.focus();
         }
         break;
     }
   }
 
   this.handleClickEvent = function handleClickEvent(aEvent)
   {
-    if (aEvent.target.localName != "TD")
+    if (aEvent.target.localName != "td")
       return;
     
     var curCell = this.getCurrentCell();
     var cell = aEvent.target;
 
     if (cell != curCell) {
       curCell.removeAttribute("tabindex");
       cell.setAttribute("tabindex", "0");
--- a/browser/base/content/test/test_contextmenu.html
+++ b/browser/base/content/test/test_contextmenu.html
@@ -40,17 +40,17 @@ function openContextMenuFor(element) {
     // fallback case in nsXULPopupListener::PreLaunchPopup.
     //
     // Also interesting is that just firing a mousedown+mouseup doesn't seem
     // to do anything. Not clear why we'd specifically have to fire a
     // contextmenu event instead of just a right-click.
 
     // This seems to work, as long as we explicitly set the popupNode first.
     // For frames, the popupNode needs to be set to inside the frame.
-    if (element.localName == "IFRAME")
+    if (element.localName == "iframe")
         chromeWin.document.popupNode = element.contentDocument.body;
     else
         chromeWin.document.popupNode = element;
     contextMenu.openPopup(element, "overlap", 5, 5, true, false);
 }
 
 function closeContextMenu() {
     contextMenu.hidePopup();
--- a/content/base/public/nsIContent.h
+++ b/content/base/public/nsIContent.h
@@ -37,20 +37,20 @@
 #ifndef nsIContent_h___
 #define nsIContent_h___
 
 #include "nsCOMPtr.h" // for already_AddRefed
 #include "nsStringGlue.h"
 #include "nsCaseTreatment.h"
 #include "nsChangeHint.h"
 #include "nsINode.h"
+#include "nsIDocument.h" // for IsInHTMLDocument
 
 // Forward declarations
 class nsIAtom;
-class nsIDocument;
 class nsPresContext;
 class nsIDOMEvent;
 class nsIContent;
 class nsIEventListenerManager;
 class nsIURI;
 class nsICSSStyleRule;
 class nsRuleWalker;
 class nsAttrValue;
@@ -198,16 +198,27 @@ public:
   PRBool IsInAnonymousSubtree() const
   {
     NS_ASSERTION(!IsInNativeAnonymousSubtree() || GetBindingParent() || !GetParent(),
                  "must have binding parent when in native anonymous subtree with a parent node");
     return IsInNativeAnonymousSubtree() || GetBindingParent() != nsnull;
   }
 
   /**
+   * 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();
+  }
+
+  /**
    * Get the namespace that this element's tag is defined in
    * @return the namespace
    */
   PRInt32 GetNameSpaceID() const
   {
     return mNodeInfo->NamespaceID();
   }
 
--- a/content/base/src/nsFrameLoader.cpp
+++ b/content/base/src/nsFrameLoader.cpp
@@ -812,17 +812,17 @@ nsFrameLoader::EnsureDocShell()
   NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
 
   // Get the frame name and tell the docshell about it.
   nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
   NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
   nsAutoString frameName;
 
   PRInt32 namespaceID = mOwnerContent->GetNameSpaceID();
-  if (namespaceID == kNameSpaceID_XHTML) {
+  if (namespaceID == kNameSpaceID_XHTML && !mOwnerContent->IsInHTMLDocument()) {
     mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::id, frameName);
   } else {
     mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, frameName);
     // XXX if no NAME then use ID, after a transition period this will be
     // changed so that XUL only uses ID too (bug 254284).
     if (frameName.IsEmpty() && namespaceID == kNameSpaceID_XUL) {
       mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::id, frameName);
     }
--- a/content/base/src/nsXHTMLContentSerializer.cpp
+++ b/content/base/src/nsXHTMLContentSerializer.cpp
@@ -486,18 +486,17 @@ nsXHTMLContentSerializer::AppendEndOfEle
 }
 
 void
 nsXHTMLContentSerializer::AfterElementStart(nsIContent * aContent,
                                             nsIDOMElement *aOriginalElement,
                                             nsAString& aStr)
 {
   nsIAtom *name = aContent->Tag();
-  if (((mIsHTMLSerializer && aContent->GetNameSpaceID() == kNameSpaceID_None) ||
-       (!mIsHTMLSerializer && aContent->GetNameSpaceID() == kNameSpaceID_XHTML)) &&
+  if (aContent->GetNameSpaceID() == kNameSpaceID_XHTML &&
       mIsWholeDocument &&
       name == nsGkAtoms::head) {
 
     // Check if there already are any content-type meta children.
     // If there are, they will be modified to use the correct charset.
     // If there aren't, we'll insert one here.
     PRBool hasMeta = PR_FALSE;
     PRUint32 i, childCount = aContent->GetChildCount();
@@ -569,18 +568,17 @@ nsXHTMLContentSerializer::CheckElementSt
   // indicate that this element should be pretty printed
   // even if we're not in pretty printing mode
   aForceFormat = aContent->HasAttr(kNameSpaceID_None,
                                    nsGkAtoms::mozdirty);
 
   nsIAtom *name = aContent->Tag();
   PRInt32 namespaceID = aContent->GetNameSpaceID();
 
-  if ((mIsHTMLSerializer && namespaceID == kNameSpaceID_None) ||
-      (!mIsHTMLSerializer && namespaceID == kNameSpaceID_XHTML)) {
+  if (namespaceID == kNameSpaceID_XHTML) {
     if (name == nsGkAtoms::br && mPreLevel > 0 && 
         (mFlags & nsIDocumentEncoder::OutputNoFormattingInPre)) {
       AppendNewLineToString(aStr);
       return PR_FALSE;
     }
 
     if (name == nsGkAtoms::body) {
       ++mInBody;
@@ -936,18 +934,17 @@ nsXHTMLContentSerializer::AppendToString
   nsXMLContentSerializer::AppendToStringWrapped(aStr, aOutputStr);
 }
 
 
 PRBool
 nsXHTMLContentSerializer::LineBreakBeforeOpen(PRInt32 aNamespaceID, nsIAtom* aName)
 {
 
-  if ((mIsHTMLSerializer && aNamespaceID != kNameSpaceID_None) ||
-      (!mIsHTMLSerializer && aNamespaceID != kNameSpaceID_XHTML)) {
+  if (aNamespaceID != kNameSpaceID_XHTML) {
     return mAddSpace;
   }
 
   if (aName == nsGkAtoms::title ||
       aName == nsGkAtoms::meta  ||
       aName == nsGkAtoms::link  ||
       aName == nsGkAtoms::style ||
       aName == nsGkAtoms::select ||
@@ -968,18 +965,17 @@ nsXHTMLContentSerializer::LineBreakBefor
 
   return mAddSpace;
 }
 
 PRBool 
 nsXHTMLContentSerializer::LineBreakAfterOpen(PRInt32 aNamespaceID, nsIAtom* aName)
 {
 
-  if ((mIsHTMLSerializer && aNamespaceID != kNameSpaceID_None) ||
-      (!mIsHTMLSerializer && aNamespaceID != kNameSpaceID_XHTML)) {
+  if (aNamespaceID != kNameSpaceID_XHTML) {
     return PR_FALSE;
   }
 
   if ((aName == nsGkAtoms::html) ||
       (aName == nsGkAtoms::head) ||
       (aName == nsGkAtoms::body) ||
       (aName == nsGkAtoms::ul) ||
       (aName == nsGkAtoms::ol) ||
@@ -1000,18 +996,17 @@ nsXHTMLContentSerializer::LineBreakAfter
 
   return PR_FALSE;
 }
 
 PRBool 
 nsXHTMLContentSerializer::LineBreakBeforeClose(PRInt32 aNamespaceID, nsIAtom* aName)
 {
 
-  if ((mIsHTMLSerializer && aNamespaceID != kNameSpaceID_None) ||
-      (!mIsHTMLSerializer && aNamespaceID != kNameSpaceID_XHTML)) {
+  if (aNamespaceID != kNameSpaceID_XHTML) {
     return PR_FALSE;
   }
 
   if ((aName == nsGkAtoms::html) ||
       (aName == nsGkAtoms::head) ||
       (aName == nsGkAtoms::body) ||
       (aName == nsGkAtoms::ul) ||
       (aName == nsGkAtoms::ol) ||
@@ -1023,18 +1018,17 @@ nsXHTMLContentSerializer::LineBreakBefor
   }
   return PR_FALSE;
 }
 
 PRBool 
 nsXHTMLContentSerializer::LineBreakAfterClose(PRInt32 aNamespaceID, nsIAtom* aName)
 {
 
-  if ((mIsHTMLSerializer && aNamespaceID != kNameSpaceID_None) ||
-      (!mIsHTMLSerializer && aNamespaceID != kNameSpaceID_XHTML)) {
+  if (aNamespaceID != kNameSpaceID_XHTML) {
     return PR_FALSE;
   }
 
   if ((aName == nsGkAtoms::html) ||
       (aName == nsGkAtoms::head) ||
       (aName == nsGkAtoms::body) ||
       (aName == nsGkAtoms::tr) ||
       (aName == nsGkAtoms::th) ||
@@ -1065,18 +1059,17 @@ nsXHTMLContentSerializer::LineBreakAfter
   return PR_FALSE;
 }
 
 
 void
 nsXHTMLContentSerializer::MaybeEnterInPreContent(nsIContent* aNode)
 {
 
-  if ((mIsHTMLSerializer && aNode->GetNameSpaceID() != kNameSpaceID_None) ||
-      (!mIsHTMLSerializer && aNode->GetNameSpaceID() != kNameSpaceID_XHTML)) {
+  if (aNode->GetNameSpaceID() != kNameSpaceID_XHTML) {
     return;
   }
 
   nsIAtom *name = aNode->Tag();
 
   if (name == nsGkAtoms::pre ||
       name == nsGkAtoms::script ||
       name == nsGkAtoms::style ||
@@ -1085,18 +1078,17 @@ nsXHTMLContentSerializer::MaybeEnterInPr
       ) {
     mPreLevel++;
   }
 }
 
 void
 nsXHTMLContentSerializer::MaybeLeaveFromPreContent(nsIContent* aNode)
 {
-  if ((mIsHTMLSerializer && aNode->GetNameSpaceID() != kNameSpaceID_None) ||
-      (!mIsHTMLSerializer && aNode->GetNameSpaceID() != kNameSpaceID_XHTML)) {
+  if (aNode->GetNameSpaceID() != kNameSpaceID_XHTML) {
     return;
   }
 
   nsIAtom *name = aNode->Tag();
   if (name == nsGkAtoms::pre ||
       name == nsGkAtoms::script ||
       name == nsGkAtoms::style ||
       name == nsGkAtoms::noscript ||
--- a/content/base/test/test_bug276037-1.html
+++ b/content/base/test/test_bug276037-1.html
@@ -13,69 +13,69 @@ https://bugzilla.mozilla.org/show_bug.cg
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=276037">Mozilla Bug 276037</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 /** Test for Bug 276037 **/
-function countElements (node, namespaceURI, tagName) {
+function countElements (node, namespaceURI, localName) {
   var count = 0;
   for (var i = 0; i < node.childNodes.length; i++) {
     var child = node.childNodes[i];
-    if (child.nodeType == Node.ELEMENT_NODE && child.tagName == tagName &&
+    if (child.nodeType == Node.ELEMENT_NODE && child.localName == localName &&
         child.namespaceURI == namespaceURI) {
       count++;
     }
     if (child.hasChildNodes()) {
-      count += countElements(child, namespaceURI, tagName);
+      count += countElements(child, namespaceURI, localName);
     }
   }
   return count;
 }
 
-function checkElements(namespaceURI, tagName) {
-  var elementsNS = document.getElementsByTagNameNS(namespaceURI, tagName);
-  var elements = document.getElementsByTagName(tagName);
-  var elementCount = countElements(document, namespaceURI, tagName);
-  const gEBTN = 'document.getElementsByTagName(\'' + tagName + '\').length: ' + elements.length;
-  const gEBTNNS = '; document.getElementsByTagNameNS(\'' + namespaceURI + '\', \'' + tagName + '\').length: ' + elementsNS.length;
+function checkElements(namespaceURI, localName) {
+  var elementsNS = document.getElementsByTagNameNS(namespaceURI, localName);
+  var elements = document.getElementsByTagName(localName);
+  var elementCount = countElements(document, namespaceURI, localName);
+  const gEBTN = 'document.getElementsByTagName(\'' + localName + '\').length: ' + elements.length;
+  const gEBTNNS = '; document.getElementsByTagNameNS(\'' + namespaceURI + '\', \'' + localName + '\').length: ' + elementsNS.length;
 
   text1 = gEBTN + '; element count: ' + elementCount;
   text2 = gEBTNNS + '; element count: ' + elementCount;
 
   is(elements.length, elementCount, text1);
   is(elementsNS.length, elementCount, text2);
-  is(global.gEBTN[namespaceURI][tagName].length, elementCount, text1);
-  is(global.gEBTNNS[namespaceURI][tagName].length, elementCount, text2);
+  is(global.gEBTN[namespaceURI][localName].length, elementCount, text1);
+  is(global.gEBTNNS[namespaceURI][localName].length, elementCount, text2);
 }
 
-const xhtmlNS = null;
+const xhtmlNS = 'http://www.w3.org/1999/xhtml';
 
 function checkSpansAndScripts () {
-  checkElements(xhtmlNS, 'SPAN');
-  checkElements(xhtmlNS, 'SCRIPT');
+  checkElements(xhtmlNS, 'span');
+  checkElements(xhtmlNS, 'script');
 }
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(function() { checkSpansAndScripts() });
 addLoadEvent(SimpleTest.finish);
 
 // Init our global lists
 var global = {};
 global.gEBTN = {};
 global.gEBTN[xhtmlNS] = {};
 global.gEBTNNS = {};
 global.gEBTNNS[xhtmlNS] = {};
 
-global.gEBTN[xhtmlNS].SPAN = document.getElementsByTagName("span");
-global.gEBTNNS[xhtmlNS].SPAN = document.getElementsByTagNameNS(xhtmlNS, "span");
-global.gEBTN[xhtmlNS].SCRIPT = document.getElementsByTagName("script");
-global.gEBTNNS[xhtmlNS].SCRIPT = document.getElementsByTagNameNS(xhtmlNS, "script");
+global.gEBTN[xhtmlNS].span = document.getElementsByTagName("span");
+global.gEBTNNS[xhtmlNS].span = document.getElementsByTagNameNS(xhtmlNS, "span");
+global.gEBTN[xhtmlNS].script = document.getElementsByTagName("script");
+global.gEBTNNS[xhtmlNS].script = document.getElementsByTagNameNS(xhtmlNS, "script");
 </script>
 <p><span>Static text in span.</span></p>
 <script type="text/javascript">
 checkSpansAndScripts();
 </script>
 <p><span>Static text in span.</span></p>
 <script type="text/javascript">
 checkSpansAndScripts();
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -300,17 +300,17 @@ nsGenericHTMLElement::SetAttribute(const
 {
   const nsAttrName* name = InternalGetExistingAttrNameFromQName(aName);
 
   if (!name) {
     nsresult rv = nsContentUtils::CheckQName(aName, PR_FALSE);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIAtom> nameAtom;
-    if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
+    if (IsInHTMLDocument()) {
       nsAutoString lower;
       ToLowerCase(aName, lower);
       nameAtom = do_GetAtom(lower);
     }
     else {
       nameAtom = do_GetAtom(aName);
     }
     NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
@@ -322,68 +322,35 @@ nsGenericHTMLElement::SetAttribute(const
                  aValue, PR_TRUE);
 }
 
 nsresult
 nsGenericHTMLElement::GetNodeName(nsAString& aNodeName)
 {
   mNodeInfo->GetQualifiedName(aNodeName);
 
-  if (mNodeInfo->NamespaceEquals(kNameSpaceID_None))
+  if (IsInHTMLDocument())
     ToUpperCase(aNodeName);
 
   return NS_OK;
 }
 
 nsresult
-nsGenericHTMLElement::GetLocalName(nsAString& aLocalName)
-{
-  mNodeInfo->GetLocalName(aLocalName);
-
-  if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
-    // No namespace, this means we're dealing with a good ol' HTML
-    // element, so uppercase the local name.
-
-    ToUpperCase(aLocalName);
-  }
-
-  return NS_OK;
-}
-
-nsresult
 nsGenericHTMLElement::GetElementsByTagName(const nsAString& aTagname,
                                            nsIDOMNodeList** aReturn)
 {
   nsAutoString tagName(aTagname);
 
-  // Only lowercase the name if this element has no namespace (i.e.
-  // it's a HTML element, not an XHTML element).
-  if (mNodeInfo && mNodeInfo->NamespaceEquals(kNameSpaceID_None))
+  // Only lowercase the name if this is an HTML document.
+  if (IsInHTMLDocument())
     ToLowerCase(tagName);
 
   return nsGenericHTMLElementBase::GetElementsByTagName(tagName, aReturn);
 }
 
-nsresult
-nsGenericHTMLElement::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
-                                             const nsAString& aLocalName,
-                                             nsIDOMNodeList** aReturn)
-{
-  nsAutoString localName(aLocalName);
-
-  // Only lowercase the name if this element has no namespace (i.e.
-  // it's a HTML element, not an XHTML element).
-  if (mNodeInfo && mNodeInfo->NamespaceEquals(kNameSpaceID_None))
-    ToLowerCase(localName);
-
-  return nsGenericHTMLElementBase::GetElementsByTagNameNS(aNamespaceURI,
-                                                          localName,
-                                                          aReturn);
-}
-
 // Implementation for nsIDOMHTMLElement
 nsresult
 nsGenericHTMLElement::GetId(nsAString& aId)
 {
   GetAttr(kNameSpaceID_None, nsGkAtoms::id, aId);
   return NS_OK;
 }
 
@@ -666,18 +633,17 @@ nsGenericHTMLElement::GetInnerHTML(nsASt
     return NS_OK; // We rely on the document for doing HTML conversion
   }
 
   nsCOMPtr<nsIDOMNode> thisNode(do_QueryInterface(static_cast<nsIContent *>
                                                              (this)));
   nsresult rv = NS_OK;
 
   nsAutoString contentType;
-  if (!doc->IsCaseSensitive()) {
-    // All case-insensitive documents are HTML as far as we're concerned
+  if (IsInHTMLDocument()) {
     contentType.AssignLiteral("text/html");
   } else {
     doc->GetContentType(contentType);
   }
   
   nsCOMPtr<nsIDocumentEncoder> docEncoder;
   docEncoder =
     do_CreateInstance(PromiseFlatCString(
@@ -1195,37 +1161,32 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 
   }
 
   return NS_OK;
 }
 
 already_AddRefed<nsIURI>
 nsGenericHTMLElement::GetBaseURI() const
 {
-  nsIDocument* doc = GetOwnerDoc();
-
   void* prop;
   if (HasFlag(NODE_HAS_PROPERTIES) && (prop = GetProperty(nsGkAtoms::htmlBaseHref))) {
     nsIURI* uri = static_cast<nsIURI*>(prop);
     NS_ADDREF(uri);
     
     return uri;
   }
 
   // If we are a plain old HTML element (not XHTML), don't bother asking the
   // base class -- our base URI is determined solely by the document base.
-  if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
-    if (doc) {
-      nsIURI *uri = doc->GetBaseURI();
-      NS_IF_ADDREF(uri);
-
-      return uri;
-    }
-
-    return nsnull;
+  if (IsInHTMLDocument()) {
+    // If we got here, GetOwnerDoc() is not null
+    nsIURI *uri = GetOwnerDoc()->GetBaseURI();
+    NS_IF_ADDREF(uri);
+
+    return uri;
   }
 
   return nsGenericHTMLElementBase::GetBaseURI();
 }
 
 void
 nsGenericHTMLElement::GetBaseTarget(nsAString& aBaseTarget) const
 {
@@ -3456,17 +3417,17 @@ nsGenericHTMLElement::GetHashFromHrefURI
     AppendUTF8toUTF16(ref, aHash);
   }
   return NS_OK;
 }
 
 const nsAttrName*
 nsGenericHTMLElement::InternalGetExistingAttrNameFromQName(const nsAString& aStr) const
 {
-  if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
+  if (IsInHTMLDocument()) {
     nsAutoString lower;
     ToLowerCase(aStr, lower);
     return mAttrsAndChildren.GetExistingAttrNameFromQName(
       NS_ConvertUTF16toUTF8(lower));
   }
 
   return mAttrsAndChildren.GetExistingAttrNameFromQName(
     NS_ConvertUTF16toUTF8(aStr));
--- a/content/html/content/src/nsGenericHTMLElement.h
+++ b/content/html/content/src/nsGenericHTMLElement.h
@@ -98,27 +98,23 @@ public:
   nsresult DOMQueryInterface(nsIDOMHTMLElement *aElement, REFNSIID aIID,
                              void **aInstancePtr);
 
   // From nsGenericElement
   nsresult CopyInnerTo(nsGenericElement* aDest) const;
 
   // Implementation for nsIDOMNode
   NS_METHOD GetNodeName(nsAString& aNodeName);
-  NS_METHOD GetLocalName(nsAString& aLocalName);
 
   // Implementation for nsIDOMElement
   NS_METHOD SetAttribute(const nsAString& aName,
                          const nsAString& aValue);
   NS_METHOD GetTagName(nsAString& aTagName);
   NS_METHOD GetElementsByTagName(const nsAString& aTagname,
                                  nsIDOMNodeList** aReturn);
-  NS_METHOD GetElementsByTagNameNS(const nsAString& aNamespaceURI,
-                                   const nsAString& aLocalName,
-                                   nsIDOMNodeList** aReturn);
 
   // nsIDOMHTMLElement methods. Note that these are non-virtual
   // methods, implementations are expected to forward calls to these
   // methods.
   nsresult GetId(nsAString& aId);
   nsresult SetId(const nsAString& aId);
   nsresult GetTitle(nsAString& aTitle);
   nsresult SetTitle(const nsAString& aTitle);
--- a/content/html/content/src/nsHTMLOptionElement.cpp
+++ b/content/html/content/src/nsHTMLOptionElement.cpp
@@ -147,17 +147,17 @@ NS_NewHTMLOptionElement(nsINodeInfo *aNo
    */
   nsCOMPtr<nsINodeInfo> nodeInfo(aNodeInfo);
   if (!nodeInfo) {
     nsCOMPtr<nsIDocument> doc =
       do_QueryInterface(nsContentUtils::GetDocumentFromCaller());
     NS_ENSURE_TRUE(doc, nsnull);
 
     nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::option, nsnull,
-                                                   kNameSpaceID_None);
+                                                   kNameSpaceID_XHTML);
     NS_ENSURE_TRUE(nodeInfo, nsnull);
   }
 
   return new nsHTMLOptionElement(nodeInfo);
 }
 
 nsHTMLOptionElement::nsHTMLOptionElement(nsINodeInfo *aNodeInfo)
   : nsGenericHTMLElement(aNodeInfo),
--- a/content/html/content/src/nsHTMLStyleElement.cpp
+++ b/content/html/content/src/nsHTMLStyleElement.cpp
@@ -316,17 +316,17 @@ void
 nsHTMLStyleElement::GetStyleSheetURL(PRBool* aIsInline,
                                      nsIURI** aURI)
 {
   *aURI = nsnull;
   *aIsInline = !HasAttr(kNameSpaceID_None, nsGkAtoms::src);
   if (*aIsInline) {
     return;
   }
-  if (mNodeInfo->NamespaceEquals(kNameSpaceID_XHTML)) {
+  if (!IsInHTMLDocument()) {
     // We stopped supporting <style src="..."> for XHTML as it is
     // non-standard.
     *aIsInline = PR_TRUE;
     return;
   }
 
   GetHrefURIForAnchors(aURI);
   return;
--- a/content/html/content/src/nsHTMLTableRowElement.cpp
+++ b/content/html/content/src/nsHTMLTableRowElement.cpp
@@ -245,17 +245,17 @@ nsHTMLTableRowElement::GetCells(nsIDOMHT
 {
   if (!mCells) {
     mCells = new nsContentList(this,
                                IsCell,
                                nsnull, // destroy func
                                nsnull, // closure data
                                PR_FALSE,
                                nsnull,
-                               kNameSpaceID_None,
+                               kNameSpaceID_XHTML,
                                PR_FALSE);
 
     NS_ENSURE_TRUE(mCells, NS_ERROR_OUT_OF_MEMORY);
   }
 
   NS_ADDREF(*aValue = mCells);
   return NS_OK;
 }
--- a/content/html/document/src/nsHTMLContentSink.cpp
+++ b/content/html/document/src/nsHTMLContentSink.cpp
@@ -543,30 +543,30 @@ HTMLContentSink::CreateContentObject(con
 
   nsCOMPtr<nsINodeInfo> nodeInfo;
 
   if (aNodeType == eHTMLTag_userdefined) {
     NS_ConvertUTF16toUTF8 tmp(aNode.GetText());
     ToLowerCase(tmp);
 
     nsCOMPtr<nsIAtom> name = do_GetAtom(tmp);
-    nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None);
+    nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_XHTML);
   }
   else if (mNodeInfoCache[aNodeType]) {
     nodeInfo = mNodeInfoCache[aNodeType];
   }
   else {
     nsIParserService *parserService = nsContentUtils::GetParserService();
     if (!parserService)
       return nsnull;
 
     nsIAtom *name = parserService->HTMLIdToAtomTag(aNodeType);
     NS_ASSERTION(name, "What? Reverse mapping of id to string broken!!!");
 
-    nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None);
+    nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_XHTML);
     NS_IF_ADDREF(mNodeInfoCache[aNodeType] = nodeInfo);
   }
 
   NS_ENSURE_TRUE(nodeInfo, nsnull);
 
   // Make the content object
   return CreateHTMLElement(aNodeType, nodeInfo, PR_TRUE);
 }
@@ -578,25 +578,18 @@ NS_NewHTMLElement(nsIContent** aResult, 
   *aResult = nsnull;
 
   nsIParserService* parserService = nsContentUtils::GetParserService();
   if (!parserService)
     return NS_ERROR_OUT_OF_MEMORY;
 
   nsIAtom *name = aNodeInfo->NameAtom();
 
-#ifdef DEBUG
-  if (aNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
-    nsAutoString nameStr, lname;
-    name->ToString(nameStr);
-    ToLowerCase(nameStr, lname);
-    NS_ASSERTION(nameStr.Equals(lname), "name should be lowercase by now");
-    NS_ASSERTION(!aNodeInfo->GetPrefixAtom(), "should not have a prefix");
-  }
-#endif
+  NS_ASSERTION(aNodeInfo->NamespaceEquals(kNameSpaceID_XHTML), 
+               "Trying to HTML elements that don't have the XHTML namespace");
   
   *aResult = CreateHTMLElement(parserService->
                                  HTMLCaseSensitiveAtomTagToId(name),
                                aNodeInfo, aFromParser).get();
   return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
 already_AddRefed<nsGenericHTMLElement>
@@ -1677,17 +1670,17 @@ HTMLContentSink::Init(nsIDocument* aDoc,
 
 
   // Changed from 8192 to greatly improve page loading performance on
   // large pages.  See bugzilla bug 77540.
   mMaxTextRun = nsContentUtils::GetIntPref("content.maxtextrun", 8191);
 
   nsCOMPtr<nsINodeInfo> nodeInfo;
   nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::html, nsnull,
-                                           kNameSpaceID_None);
+                                           kNameSpaceID_XHTML);
   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
   // Make root part
   nsIContent *doc_root = mDocument->GetRootContent();
 
   if (doc_root) {
     // If the document already has a root we'll use it. This will
     // happen when we do document.open()/.write()/.close()...
@@ -1705,17 +1698,17 @@ HTMLContentSink::Init(nsIDocument* aDoc,
     NS_ASSERTION(mDocument->GetChildCount() == 0,
                  "Document should have no kids here!");
     rv = mDocument->AppendChildTo(mRoot, PR_FALSE);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // Make head part
   nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::head,
-                                           nsnull, kNameSpaceID_None);
+                                           nsnull, kNameSpaceID_XHTML);
   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
   mHead = NS_NewHTMLHeadElement(nodeInfo);
   if (NS_FAILED(rv)) {
     MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::Init()\n"));
     MOZ_TIMER_STOP(mWatch);
     return NS_ERROR_OUT_OF_MEMORY;
   }
@@ -2898,17 +2891,17 @@ nsresult
 HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
 {
   nsresult  result = NS_OK;
 
   if (mCurrentContext) {
     // Create content object
     nsCOMPtr<nsIContent> element;
     nsCOMPtr<nsINodeInfo> nodeInfo;
-    nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::link, nsnull, kNameSpaceID_None);
+    nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::link, nsnull, kNameSpaceID_XHTML);
 
     result = NS_NewHTMLElement(getter_AddRefs(element), nodeInfo, PR_FALSE);
     NS_ENSURE_SUCCESS(result, result);
 
     nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(element));
 
     if (ssle) {
       // XXX need prefs. check here.
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -1207,17 +1207,17 @@ nsHTMLDocument::CreateElement(const nsAS
 
   if (!IsXHTML()) {
     ToLowerCase(tagName);
   }
 
   nsCOMPtr<nsIAtom> name = do_GetAtom(tagName);
 
   nsCOMPtr<nsIContent> content;
-  rv = CreateElem(name, nsnull, GetDefaultNamespaceID(), PR_TRUE,
+  rv = CreateElem(name, nsnull, kNameSpaceID_XHTML, PR_TRUE,
                   getter_AddRefs(content));
   NS_ENSURE_SUCCESS(rv, rv);
 
   return CallQueryInterface(content, aReturn);
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::CreateElementNS(const nsAString& aNamespaceURI,
@@ -1588,34 +1588,33 @@ nsHTMLDocument::SetBody(nsIDOMHTMLElemen
 
   return rootElem->AppendChild(aBody, getter_AddRefs(tmp));
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetImages(nsIDOMHTMLCollection** aImages)
 {
   if (!mImages) {
-    mImages = new nsContentList(this, nsGkAtoms::img, GetDefaultNamespaceID());
+    mImages = new nsContentList(this, nsGkAtoms::img, kNameSpaceID_XHTML);
     if (!mImages) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
   }
 
   *aImages = mImages;
   NS_ADDREF(*aImages);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetApplets(nsIDOMHTMLCollection** aApplets)
 {
   if (!mApplets) {
-    mApplets = new nsContentList(this, nsGkAtoms::applet,
-                                 GetDefaultNamespaceID());
+    mApplets = new nsContentList(this, nsGkAtoms::applet, kNameSpaceID_XHTML);
     if (!mApplets) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
   }
 
   *aApplets = mApplets;
   NS_ADDREF(*aApplets);
 
@@ -1638,20 +1637,19 @@ nsHTMLDocument::MatchLinks(nsIContent *a
         do_QueryInterface(aContent->GetCurrentDoc());
       NS_ASSERTION(htmldoc,
                    "Huh, how did this happen? This should only be used with "
                    "HTML documents!");
     }
 #endif
 
     nsINodeInfo *ni = aContent->NodeInfo();
-    PRInt32 namespaceID = doc->GetDefaultNamespaceID();
 
     nsIAtom *localName = ni->NameAtom();
-    if (ni->NamespaceID() == namespaceID &&
+    if (ni->NamespaceID() == kNameSpaceID_XHTML &&
         (localName == nsGkAtoms::a || localName == nsGkAtoms::area)) {
       return aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::href);
     }
   }
 
   return PR_FALSE;
 }
 
@@ -1683,18 +1681,17 @@ nsHTMLDocument::MatchAnchors(nsIContent 
     nsCOMPtr<nsIHTMLDocument> htmldoc =
       do_QueryInterface(aContent->GetCurrentDoc());
     NS_ASSERTION(htmldoc,
                  "Huh, how did this happen? This should only be used with "
                  "HTML documents!");
   }
 #endif
 
-  PRInt32 namespaceID = aContent->GetCurrentDoc()->GetDefaultNamespaceID();
-  if (aContent->NodeInfo()->Equals(nsGkAtoms::a, namespaceID)) {
+  if (aContent->NodeInfo()->Equals(nsGkAtoms::a, kNameSpaceID_XHTML)) {
     return aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::name);
   }
 
   return PR_FALSE;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetAnchors(nsIDOMHTMLCollection** aAnchors)
@@ -2250,23 +2247,17 @@ nsHTMLDocument::CreateAttributeNS(const 
   return nsDocument::CreateAttributeNS(aNamespaceURI, aQualifiedName, aReturn);
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
                                        const nsAString& aLocalName,
                                        nsIDOMNodeList** aReturn)
 {
-  nsAutoString tmp(aLocalName);
-
-  if (!IsXHTML()) {
-    ToLowerCase(tmp); // HTML elements are lower case internally.
-  }
-
-  return nsDocument::GetElementsByTagNameNS(aNamespaceURI, tmp, aReturn);
+  return nsDocument::GetElementsByTagNameNS(aNamespaceURI, aLocalName, aReturn);
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetElementById(const nsAString& aElementId,
                                nsIDOMElement** aReturn)
 {
   return nsDocument::GetElementById(aElementId, aReturn);
 }
@@ -2580,17 +2571,17 @@ nsHTMLDocument::SetFgColor(const nsAStri
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsHTMLDocument::GetEmbeds(nsIDOMHTMLCollection** aEmbeds)
 {
   if (!mEmbeds) {
-    mEmbeds = new nsContentList(this, nsGkAtoms::embed, GetDefaultNamespaceID());
+    mEmbeds = new nsContentList(this, nsGkAtoms::embed, kNameSpaceID_XHTML);
     if (!mEmbeds) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
   }
 
   *aEmbeds = mEmbeds;
   NS_ADDREF(*aEmbeds);
 
@@ -2913,17 +2904,17 @@ nsHTMLDocument::GetForms(nsIDOMHTMLColle
   NS_ADDREF(*aForms = forms);
   return NS_OK;
 }
 
 nsContentList*
 nsHTMLDocument::GetForms()
 {
   if (!mForms)
-    mForms = new nsContentList(this, nsGkAtoms::form, GetDefaultNamespaceID());
+    mForms = new nsContentList(this, nsGkAtoms::form, kNameSpaceID_XHTML);
 
   return mForms;
 }
 
 static PRBool MatchFormControls(nsIContent* aContent, PRInt32 aNamespaceID,
                                 nsIAtom* aAtom, void* aData)
 {
   return aContent->IsNodeOfType(nsIContent::eHTML_FORM_CONTROL);
@@ -3131,17 +3122,17 @@ static PRBool
 DocAllResultMatch(nsIContent* aContent, PRInt32 aNamespaceID, nsIAtom* aAtom,
                   void* aData)
 {
   if (aContent->GetID() == aAtom) {
     return PR_TRUE;
   }
 
   nsGenericHTMLElement* elm = nsGenericHTMLElement::FromContent(aContent);
-  if (!elm || aContent->GetNameSpaceID() != kNameSpaceID_None) {
+  if (!elm) {
     return PR_FALSE;
   }
 
   nsIAtom* tag = elm->Tag();
   if (tag != nsGkAtoms::a &&
       tag != nsGkAtoms::applet &&
       tag != nsGkAtoms::button &&
       tag != nsGkAtoms::embed &&
@@ -4054,41 +4045,16 @@ nsHTMLDocument::QueryCommandValue(const 
   nsXPIDLCString cStringResult;
   rv = cmdParams->GetCStringValue("state_attribute",
                                   getter_Copies(cStringResult));
   CopyUTF8toUTF16(cStringResult, _retval);
 
   return rv;
 }
 
-#ifdef DEBUG
-nsresult
-nsHTMLDocument::CreateElem(nsIAtom *aName, nsIAtom *aPrefix,
-                           PRInt32 aNamespaceID, PRBool aDocumentDefaultType,
-                           nsIContent** aResult)
-{
-  NS_ASSERTION(!aDocumentDefaultType || IsXHTML() ||
-               aNamespaceID == kNameSpaceID_None,
-               "HTML elements in an HTML document should have "
-               "kNamespaceID_None as their namespace ID.");
-
-  if (IsXHTML() &&
-      (aDocumentDefaultType || aNamespaceID == kNameSpaceID_XHTML)) {
-    nsCAutoString name, lcName;
-    aName->ToUTF8String(name);
-    ToLowerCase(name, lcName);
-    NS_ASSERTION(lcName.Equals(name),
-                 "aName should be lowercase, fix caller.");
-  }
-
-  return nsDocument::CreateElem(aName, aPrefix, aNamespaceID,
-                                aDocumentDefaultType, aResult);
-}
-#endif
-
 nsresult
 nsHTMLDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
 {
   NS_ASSERTION(aNodeInfo->NodeInfoManager() == mNodeInfoManager,
                "Can't import this document into another document!");
 
   nsRefPtr<nsHTMLDocument> clone = new nsHTMLDocument();
   NS_ENSURE_TRUE(clone, NS_ERROR_OUT_OF_MEMORY);
--- a/content/html/document/src/nsHTMLDocument.h
+++ b/content/html/document/src/nsHTMLDocument.h
@@ -179,23 +179,16 @@ public:
   virtual PRInt32 GetNumFormsSynchronous();
   virtual void TearingDownEditor(nsIEditor *aEditor);
   virtual void SetIsXHTML(PRBool aXHTML) { mIsRegularHTML = !aXHTML; }
   PRBool IsXHTML()
   {
     return !mIsRegularHTML;
   }
 
-#ifdef DEBUG
-  virtual nsresult CreateElem(nsIAtom *aName, nsIAtom *aPrefix,
-                              PRInt32 aNamespaceID,
-                              PRBool aDocumentDefaultType,
-                              nsIContent** aResult);
-#endif
-
   nsresult ChangeContentEditableCount(nsIContent *aElement, PRInt32 aChange);
 
   virtual EditingState GetEditingState()
   {
     return mEditingState;
   }
 
   virtual void DisableCookieAccess()
@@ -269,17 +262,17 @@ protected:
    * Like IsEditingOn(), but will flush as needed first.
    */
   PRBool IsEditingOnAfterFlush();
 
   void *GenerateParserKey(void);
 
   virtual PRInt32 GetDefaultNamespaceID() const
   {
-    return mIsRegularHTML ? kNameSpaceID_None : kNameSpaceID_XHTML;
+    return kNameSpaceID_XHTML;
   }
 
   nsCOMArray<nsIDOMHTMLMapElement> mImageMaps;
 
   nsCOMPtr<nsIDOMHTMLCollection> mImages;
   nsCOMPtr<nsIDOMHTMLCollection> mApplets;
   nsCOMPtr<nsIDOMHTMLCollection> mEmbeds;
   nsCOMPtr<nsIDOMHTMLCollection> mLinks;
--- a/content/html/document/src/nsHTMLFragmentContentSink.cpp
+++ b/content/html/document/src/nsHTMLFragmentContentSink.cpp
@@ -414,31 +414,35 @@ nsHTMLFragmentContentSink::OpenContainer
 
     nsCOMPtr<nsINodeInfo> nodeInfo;
 
     if (nodeType == eHTMLTag_userdefined) {
       NS_ConvertUTF16toUTF8 tmp(aNode.GetText());
       ToLowerCase(tmp);
 
       nsCOMPtr<nsIAtom> name = do_GetAtom(tmp);
-      nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None);
+      nodeInfo = mNodeInfoManager->GetNodeInfo(name, 
+                                               nsnull, 
+                                               kNameSpaceID_XHTML);
       NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
     }
     else if (mNodeInfoCache[nodeType]) {
       nodeInfo = mNodeInfoCache[nodeType];
     }
     else {
       nsIParserService* parserService = nsContentUtils::GetParserService();
       if (!parserService)
         return NS_ERROR_OUT_OF_MEMORY;
 
       nsIAtom *name = parserService->HTMLIdToAtomTag(nodeType);
       NS_ASSERTION(name, "This should not happen!");
 
-      nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None);
+      nodeInfo = mNodeInfoManager->GetNodeInfo(name, 
+                                               nsnull, 
+                                               kNameSpaceID_XHTML);
       NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
       NS_ADDREF(mNodeInfoCache[nodeType] = nodeInfo);
     }
 
     content = CreateHTMLElement(nodeType, nodeInfo, PR_FALSE).get();
     NS_ENSURE_TRUE(content, NS_ERROR_OUT_OF_MEMORY);
 
@@ -516,28 +520,28 @@ nsHTMLFragmentContentSink::AddLeaf(const
         nsCOMPtr<nsINodeInfo> nodeInfo;
 
         if (nodeType == eHTMLTag_userdefined) {
           NS_ConvertUTF16toUTF8 tmp(aNode.GetText());
           ToLowerCase(tmp);
 
           nsCOMPtr<nsIAtom> name = do_GetAtom(tmp);
           nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull,
-                                                   kNameSpaceID_None);
+                                                   kNameSpaceID_XHTML);
           NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
         }
         else if (mNodeInfoCache[nodeType]) {
           nodeInfo = mNodeInfoCache[nodeType];
         }
         else {
           nsIAtom *name = parserService->HTMLIdToAtomTag(nodeType);
           NS_ASSERTION(name, "This should not happen!");
 
           nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull,
-                                                   kNameSpaceID_None);
+                                                   kNameSpaceID_XHTML);
           NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
           NS_ADDREF(mNodeInfoCache[nodeType] = nodeInfo);
         }
 
         content = CreateHTMLElement(nodeType, nodeInfo, PR_FALSE);
         NS_ENSURE_TRUE(content, NS_ERROR_OUT_OF_MEMORY);
 
         result = AddAttributes(aNode, content);
@@ -1006,17 +1010,17 @@ nsHTMLParanoidFragmentSink::NameFromNode
   nsresult rv;
   eHTMLTags type = (eHTMLTags)aNode.GetNodeType();
   
   *aResult = nsnull;
   if (type == eHTMLTag_userdefined) {
     nsCOMPtr<nsINodeInfo> nodeInfo;
     rv =
       mNodeInfoManager->GetNodeInfo(aNode.GetText(), nsnull,
-                                    kNameSpaceID_None,
+                                    kNameSpaceID_XHTML,
                                     getter_AddRefs(nodeInfo));
     NS_ENSURE_SUCCESS(rv, rv);
     NS_IF_ADDREF(*aResult = nodeInfo->NameAtom());
   } else {
     rv = NameFromType(type, aResult);
   }
   return rv;
 }
@@ -1170,17 +1174,17 @@ nsHTMLParanoidFragmentSink::AddLeaf(cons
     // in the output
     if (name == nsGkAtoms::base) {
       nsCOMPtr<nsIContent> content;
       nsCOMPtr<nsINodeInfo> nodeInfo;
       nsIParserService* parserService = nsContentUtils::GetParserService();
       if (!parserService)
         return NS_ERROR_OUT_OF_MEMORY;
       nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull,
-                                               kNameSpaceID_None);
+                                               kNameSpaceID_XHTML);
       NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
       rv = NS_NewHTMLElement(getter_AddRefs(content), nodeInfo, PR_FALSE);
       NS_ENSURE_SUCCESS(rv, rv);
       AddAttributes(aNode, content);
       ProcessBaseTag(content);
       return NS_OK;
     }
 
--- a/content/html/document/src/nsImageDocument.cpp
+++ b/content/html/document/src/nsImageDocument.cpp
@@ -622,17 +622,17 @@ nsImageDocument::CreateSyntheticDocument
   nsIContent* body = GetBodyContent();
   if (!body) {
     NS_WARNING("no body on image document!");
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsINodeInfo> nodeInfo;
   nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::img, nsnull,
-                                           kNameSpaceID_None);
+                                           kNameSpaceID_XHTML);
   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
   mImageContent = NS_NewHTMLImageElement(nodeInfo);
   if (!mImageContent) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
   nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mImageContent);
   NS_ENSURE_TRUE(imageLoader, NS_ERROR_UNEXPECTED);
--- a/content/html/document/src/nsMediaDocument.cpp
+++ b/content/html/document/src/nsMediaDocument.cpp
@@ -229,42 +229,42 @@ nsMediaDocument::StartDocumentLoad(const
 nsresult
 nsMediaDocument::CreateSyntheticDocument()
 {
   // Synthesize an empty html document
   nsresult rv;
 
   nsCOMPtr<nsINodeInfo> nodeInfo;
   nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::html, nsnull,
-                                           kNameSpaceID_None);
+                                           kNameSpaceID_XHTML);
   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
   nsRefPtr<nsGenericHTMLElement> root = NS_NewHTMLHtmlElement(nodeInfo);
   if (!root) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   NS_ASSERTION(GetChildCount() == 0, "Shouldn't have any kids");
   rv = AppendChildTo(root, PR_FALSE);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::head, nsnull,
-                                           kNameSpaceID_None);
+                                           kNameSpaceID_XHTML);
   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
   // Create a <head> so our title has somewhere to live
   nsRefPtr<nsGenericHTMLElement> head = NS_NewHTMLHeadElement(nodeInfo);
   if (!head) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   root->AppendChildTo(head, PR_FALSE);
 
   nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::body, nsnull,
-                                           kNameSpaceID_None);
+                                           kNameSpaceID_XHTML);
   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
   nsRefPtr<nsGenericHTMLElement> body = NS_NewHTMLBodyElement(nodeInfo);
   if (!body) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   root->AppendChildTo(body, PR_FALSE);
--- a/content/html/document/src/nsPluginDocument.cpp
+++ b/content/html/document/src/nsPluginDocument.cpp
@@ -276,17 +276,17 @@ nsPluginDocument::CreateSyntheticPluginD
   NS_NAMED_LITERAL_STRING(zero, "0");
   body->SetAttr(kNameSpaceID_None, nsGkAtoms::marginwidth, zero, PR_FALSE);
   body->SetAttr(kNameSpaceID_None, nsGkAtoms::marginheight, zero, PR_FALSE);
 
 
   // make plugin content
   nsCOMPtr<nsINodeInfo> nodeInfo;
   nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::embed, nsnull,
-                                           kNameSpaceID_None);
+                                           kNameSpaceID_XHTML);
   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
   rv = NS_NewHTMLElement(getter_AddRefs(mPluginContent), nodeInfo, PR_FALSE);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // make it a named element
   mPluginContent->SetAttr(kNameSpaceID_None, nsGkAtoms::name,
                           NS_LITERAL_STRING("plugin"), PR_FALSE);
 
--- a/content/html/document/src/nsVideoDocument.cpp
+++ b/content/html/document/src/nsVideoDocument.cpp
@@ -104,17 +104,17 @@ nsVideoDocument::CreateSyntheticVideoDoc
   if (!body) {
     NS_WARNING("no body on video document!");
     return NS_ERROR_FAILURE;
   }
 
   // make content
   nsCOMPtr<nsINodeInfo> nodeInfo;
   nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::video, nsnull,
-                                           kNameSpaceID_None);
+                                           kNameSpaceID_XHTML);
   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_FAILURE);
 
   nsRefPtr<nsHTMLMediaElement> element =
     static_cast<nsHTMLMediaElement*>(NS_NewHTMLVideoElement(nodeInfo, PR_FALSE));
   if (!element)
     return NS_ERROR_OUT_OF_MEMORY;
   element->SetAutoplay(PR_TRUE);
   element->SetControls(PR_TRUE);
--- a/content/xml/tests/toc/toc.js
+++ b/content/xml/tests/toc/toc.js
@@ -32,17 +32,17 @@
  * 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 ***** */
 
 // Event handler for display togglers in Table of Contents
 function toggleDisplay(event)
 {
-  if (event.target.localName != "IMG")
+  if (event.target.localName != "img")
     return;
   var img = event.target;
   var div = img.nextSibling.nextSibling; 
 
   // Change the display: property of the container to
   // hide and show the container.
   if (div.style.display == "none") {
     div.style.display = "block";
--- a/content/xslt/src/xpath/txNameTest.cpp
+++ b/content/xslt/src/xpath/txNameTest.cpp
@@ -67,17 +67,22 @@ PRBool txNameTest::matches(const txXPath
         return PR_FALSE;
     }
 
     // Totally wild?
     if (mLocalName == txXPathAtoms::_asterix && !mPrefix)
         return MB_TRUE;
 
     // Compare namespaces
-    if (txXPathNodeUtils::getNamespaceID(aNode) != mNamespace)
+    if (mNamespace != txXPathNodeUtils::getNamespaceID(aNode) 
+#ifndef TX_EXE
+        && !(mNamespace == kNameSpaceID_None &&
+             txXPathNodeUtils::isHTMLElementInHTMLDocument(aNode))
+#endif
+       )
         return MB_FALSE;
 
     // Name wild?
     if (mLocalName == txXPathAtoms::_asterix)
         return MB_TRUE;
 
     // Compare local-names
     return txXPathNodeUtils::localNameEquals(aNode, mLocalName);
--- a/content/xslt/src/xpath/txXPathTreeWalker.h
+++ b/content/xslt/src/xpath/txXPathTreeWalker.h
@@ -138,18 +138,26 @@ public:
     static PRBool localNameEquals(const txXPathNode& aNode,
                                   nsIAtom* aLocalName);
     static PRBool isRoot(const txXPathNode& aNode);
     static PRBool isElement(const txXPathNode& aNode);
     static PRBool isAttribute(const txXPathNode& aNode);
     static PRBool isProcessingInstruction(const txXPathNode& aNode);
     static PRBool isComment(const txXPathNode& aNode);
     static PRBool isText(const txXPathNode& aNode);
-
-#ifdef TX_EXE
+#ifndef TX_EXE
+    static inline PRBool isHTMLElementInHTMLDocument(const txXPathNode& aNode)
+    {
+      if (!aNode.isContent()) {
+        return PR_FALSE;
+      }
+      nsIContent* content = aNode.Content();
+      return content->IsNodeOfType(nsINode::eHTML) && content->IsInHTMLDocument();
+    }
+#else
 private:
     static void appendNodeValueHelper(NodeDefinition* aNode, nsAString& aResult);
 #endif
 };
 
 #ifdef TX_EXE
 class txXPathNativeNode
 {
--- a/content/xslt/src/xslt/txMozillaXMLOutput.cpp
+++ b/content/xslt/src/xslt/txMozillaXMLOutput.cpp
@@ -448,62 +448,62 @@ txMozillaXMLOutput::startElement(nsIAtom
     if (mOutputFormat.mMethod == eHTMLOutput && aNsID == kNameSpaceID_None) {
         nsCOMPtr<nsIAtom> owner;
         if (!aLowercaseLocalName) {
             owner = TX_ToLowerCaseAtom(aLocalName);
             NS_ENSURE_TRUE(owner, NS_ERROR_OUT_OF_MEMORY);
 
             aLowercaseLocalName = owner;
         }
-        return startElementInternal(nsnull, aLowercaseLocalName,
-                                    kNameSpaceID_None, kNameSpaceID_XHTML);
+        return startElementInternal(nsnull, 
+                                    aLowercaseLocalName, 
+                                    kNameSpaceID_XHTML);
     }
 
-    return startElementInternal(aPrefix, aLocalName, aNsID, aNsID);
+    return startElementInternal(aPrefix, aLocalName, aNsID);
 }
 
 nsresult
 txMozillaXMLOutput::startElement(nsIAtom* aPrefix,
                                  const nsSubstring& aLocalName,
                                  const PRInt32 aNsID)
 {
-    PRInt32 elemType = aNsID;
+    PRInt32 nsId = aNsID;
     nsCOMPtr<nsIAtom> lname;
 
     if (mOutputFormat.mMethod == eHTMLOutput && aNsID == kNameSpaceID_None) {
-        elemType = kNameSpaceID_XHTML;
+        nsId = kNameSpaceID_XHTML;
 
         nsAutoString lnameStr;
         ToLowerCase(aLocalName, lnameStr);
         lname = do_GetAtom(lnameStr);
     }
     else {
         lname = do_GetAtom(aLocalName);
     }
 
     // No biggie if we loose the prefix due to OOM
     NS_ENSURE_TRUE(lname, NS_ERROR_OUT_OF_MEMORY);
 
     // Check that it's a valid name
-    if (!nsContentUtils::IsValidNodeName(lname, aPrefix, aNsID)) {
+    if (!nsContentUtils::IsValidNodeName(lname, aPrefix, nsId)) {
         // Try without prefix
         aPrefix = nsnull;
-        if (!nsContentUtils::IsValidNodeName(lname, aPrefix, aNsID)) {
+        if (!nsContentUtils::IsValidNodeName(lname, aPrefix, nsId)) {
             return NS_ERROR_XSLT_BAD_NODE_NAME;
         }
     }
 
-    return startElementInternal(aPrefix, lname, aNsID, elemType);
+    return startElementInternal(aPrefix, lname, nsId);
 }
 
 nsresult
 txMozillaXMLOutput::startElementInternal(nsIAtom* aPrefix,
                                          nsIAtom* aLocalName,
-                                         PRInt32 aNsID,
-                                         PRInt32 aElemType)
+                                         PRInt32 aNsID)
 {
     TX_ENSURE_CURRENTNODE;
 
     if (mBadChildLevel) {
         ++mBadChildLevel;
         PR_LOG(txLog::xslt, PR_LOG_DEBUG,
                ("startElement, mBadChildLevel = %d\n", mBadChildLevel));
         return NS_OK;
@@ -534,22 +534,22 @@ txMozillaXMLOutput::startElementInternal
     mTableState = NORMAL;
     mOpenedElementIsHTML = PR_FALSE;
 
     // Create the element
     nsCOMPtr<nsINodeInfo> ni;
     ni = mNodeInfoManager->GetNodeInfo(aLocalName, aPrefix, aNsID);
     NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
 
-    NS_NewElement(getter_AddRefs(mOpenedElement), aElemType, ni, PR_FALSE);
+    NS_NewElement(getter_AddRefs(mOpenedElement), aNsID, ni, PR_FALSE);
 
     // Set up the element and adjust state
     if (!mNoFixup) {
-        if (aElemType == kNameSpaceID_XHTML) {
-            mOpenedElementIsHTML = aNsID != kNameSpaceID_XHTML;
+        if (aNsID == kNameSpaceID_XHTML) {
+            mOpenedElementIsHTML = (mOutputFormat.mMethod == eHTMLOutput);
             rv = startHTMLElement(mOpenedElement, mOpenedElementIsHTML);
             NS_ENSURE_SUCCESS(rv, rv);
 
         }
         else if (aNsID == kNameSpaceID_SVG &&
                  aLocalName == txHTMLAtoms::script) {
             nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(mOpenedElement);
             sele->WillCallDoneAddingChildren();
@@ -966,17 +966,17 @@ txMozillaXMLOutput::createHTMLElement(ns
 {
     NS_ASSERTION(mOutputFormat.mMethod == eHTMLOutput,
                  "need to adjust createHTMLElement");
 
     *aResult = nsnull;
 
     nsCOMPtr<nsINodeInfo> ni;
     ni = mNodeInfoManager->GetNodeInfo(aName, nsnull,
-                                       kNameSpaceID_None);
+                                       kNameSpaceID_XHTML);
     NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
 
     return NS_NewHTMLElement(aResult, ni, PR_FALSE);
 }
 
 txTransformNotifier::txTransformNotifier()
     : mPendingStylesheetCount(0),
       mInTransform(PR_FALSE)      
--- a/content/xslt/src/xslt/txMozillaXMLOutput.h
+++ b/content/xslt/src/xslt/txMozillaXMLOutput.h
@@ -116,17 +116,17 @@ private:
                                   nsIDOMDocument* aSourceDocument,
                                   nsIDOMDocument* aResultDocument);
     nsresult createHTMLElement(nsIAtom* aName,
                                nsIContent** aResult);
 
     nsresult attributeInternal(nsIAtom* aPrefix, nsIAtom* aLocalName,
                                PRInt32 aNsID, const nsString& aValue);
     nsresult startElementInternal(nsIAtom* aPrefix, nsIAtom* aLocalName,
-                                  PRInt32 aNsID, PRInt32 aElemType);
+                                  PRInt32 aNsID);
 
     nsCOMPtr<nsIDocument> mDocument;
     nsCOMPtr<nsINode> mCurrentNode;     // This is updated once an element is
                                         // 'closed' (i.e. once we're done
                                         // adding attributes to it).
                                         // until then the opened element is
                                         // kept in mOpenedElement
     nsCOMPtr<nsIContent> mOpenedElement;
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -5180,22 +5180,16 @@ nsEditor::CreateHTMLContent(const nsAStr
              "check caller.");
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIAtom> tag = do_GetAtom(aTag);
   if (!tag)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(tempDoc);
-  if (htmlDoc) {
-      return doc->CreateElem(tag, nsnull, doc->GetDefaultNamespaceID(),
-                             PR_TRUE, aContent);
-  }
-
   return doc->CreateElem(tag, nsnull, kNameSpaceID_XHTML, PR_FALSE, aContent);
 }
 
 nsresult
 nsEditor::SetAttributeOrEquivalent(nsIDOMElement * aElement,
                                    const nsAString & aAttribute,
                                    const nsAString & aValue,
                                    PRBool aSuppressTransaction)
--- a/layout/build/nsContentDLF.cpp
+++ b/layout/build/nsContentDLF.cpp
@@ -353,25 +353,25 @@ nsContentDLF::CreateBlankDocument(nsILoa
   if (NS_SUCCEEDED(rv)) {
     rv = NS_ERROR_FAILURE;
 
     nsNodeInfoManager *nim = blankDoc->NodeInfoManager();
 
     nsCOMPtr<nsINodeInfo> htmlNodeInfo;
 
     // generate an html html element
-    htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::html, 0, kNameSpaceID_None);
+    htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::html, 0, kNameSpaceID_XHTML);
     nsCOMPtr<nsIContent> htmlElement = NS_NewHTMLHtmlElement(htmlNodeInfo);
 
     // generate an html head element
-    htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::head, 0, kNameSpaceID_None);
+    htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::head, 0, kNameSpaceID_XHTML);
     nsCOMPtr<nsIContent> headElement = NS_NewHTMLHeadElement(htmlNodeInfo);
 
     // generate an html body element
-    htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::body, 0, kNameSpaceID_None);
+    htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::body, 0, kNameSpaceID_XHTML);
     nsCOMPtr<nsIContent> bodyElement = NS_NewHTMLBodyElement(htmlNodeInfo);
 
     // blat in the structure
     if (htmlElement && headElement && bodyElement) {
       NS_ASSERTION(blankDoc->GetChildCount() == 0,
                    "Shouldn't have children");
       rv = blankDoc->AppendChildTo(htmlElement, PR_FALSE);
       if (NS_SUCCEEDED(rv)) {
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -1021,17 +1021,17 @@ nsComboboxControlFrame::CreateAnonymousC
     mListControlFrame->GetOptionText(mDisplayedIndex, mDisplayedOptionText);
   }
   ActuallyDisplayText(PR_FALSE);
 
   if (!aElements.AppendElement(mDisplayContent))
     return NS_ERROR_OUT_OF_MEMORY;
 
   nsCOMPtr<nsINodeInfo> nodeInfo;
-  nodeInfo = nimgr->GetNodeInfo(nsGkAtoms::input, nsnull, kNameSpaceID_None);
+  nodeInfo = nimgr->GetNodeInfo(nsGkAtoms::input, nsnull, kNameSpaceID_XHTML);
 
   // create button which drops the list down
   NS_NewHTMLElement(getter_AddRefs(mButtonContent), nodeInfo, PR_FALSE);
   if (!mButtonContent)
     return NS_ERROR_OUT_OF_MEMORY;
 
   // make someone to listen to the button. If its pressed by someone like Accessibility
   // then open or close the combo box.
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -150,17 +150,17 @@ nsFileControlFrame::Destroy()
 nsresult
 nsFileControlFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
 {
   // Get the NodeInfoManager and tag necessary to create input elements
   nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
 
   nsCOMPtr<nsINodeInfo> nodeInfo;
   nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::input, nsnull,
-                                                 kNameSpaceID_None);
+                                                 kNameSpaceID_XHTML);
 
   // Create the text content
   NS_NewHTMLElement(getter_AddRefs(mTextContent), nodeInfo, PR_FALSE);
   if (!mTextContent)
     return NS_ERROR_OUT_OF_MEMORY;
 
   // Mark the element to be native anonymous before setting any attributes.
   mTextContent->SetNativeAnonymous();
--- a/layout/forms/nsIsIndexFrame.cpp
+++ b/layout/forms/nsIsIndexFrame.cpp
@@ -188,17 +188,17 @@ nsresult
 nsIsIndexFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
 {
   // Get the node info manager (used to create hr's and input's)
   nsCOMPtr<nsIDocument> doc = mContent->GetDocument();
   nsNodeInfoManager *nimgr = doc->NodeInfoManager();
 
   // Create an hr
   nsCOMPtr<nsINodeInfo> hrInfo;
-  hrInfo = nimgr->GetNodeInfo(nsGkAtoms::hr, nsnull, kNameSpaceID_None);
+  hrInfo = nimgr->GetNodeInfo(nsGkAtoms::hr, nsnull, kNameSpaceID_XHTML);
 
   NS_NewHTMLElement(getter_AddRefs(mPreHr), hrInfo, PR_FALSE);
   if (!mPreHr || !aElements.AppendElement(mPreHr))
     return NS_ERROR_OUT_OF_MEMORY;
 
   // Add a child text content node for the label
   NS_NewTextNode(getter_AddRefs(mTextContent), nimgr);
   if (!mTextContent)
@@ -206,17 +206,17 @@ nsIsIndexFrame::CreateAnonymousContent(n
 
   // set the value of the text node and add it to the child list
   UpdatePromptLabel(PR_FALSE);
   if (!aElements.AppendElement(mTextContent))
     return NS_ERROR_OUT_OF_MEMORY;
 
   // Create text input field
   nsCOMPtr<nsINodeInfo> inputInfo;
-  inputInfo = nimgr->GetNodeInfo(nsGkAtoms::input, nsnull, kNameSpaceID_None);
+  inputInfo = nimgr->GetNodeInfo(nsGkAtoms::input, nsnull, kNameSpaceID_XHTML);
 
   NS_NewHTMLElement(getter_AddRefs(mInputContent), inputInfo, PR_FALSE);
   if (!mInputContent)
     return NS_ERROR_OUT_OF_MEMORY;
 
   mInputContent->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
                          NS_LITERAL_STRING("text"), PR_FALSE);
 
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -2962,31 +2962,20 @@ nsresult nsPluginInstanceOwner::EnsureCa
   nsCOMPtr<nsIDOMNodeList> allParams; 
 
   nsINodeInfo *ni = mContent->NodeInfo();
 
   // Making DOM method calls can cause our frame to go away, which
   // might kill us...
   nsCOMPtr<nsIPluginInstanceOwner> kungFuDeathGrip(this);
   
-  if (ni->NamespaceEquals(kNameSpaceID_XHTML)) {
-    // For XHTML elements we need to take the namespace URI into
-    // account when looking for param elements.
-
-    NS_NAMED_LITERAL_STRING(xhtml_ns, "http://www.w3.org/1999/xhtml");
-
-    mydomElement->GetElementsByTagNameNS(xhtml_ns, NS_LITERAL_STRING("param"),
-                                         getter_AddRefs(allParams));
-  } else {
-    // If content is not XHTML, it must be HTML, no need to worry
-    // about namespaces then...
-
-    mydomElement->GetElementsByTagName(NS_LITERAL_STRING("param"),
+  NS_NAMED_LITERAL_STRING(xhtml_ns, "http://www.w3.org/1999/xhtml");
+
+  mydomElement->GetElementsByTagNameNS(xhtml_ns, NS_LITERAL_STRING("param"),
                                        getter_AddRefs(allParams));
-  }    
 
   if (allParams) {
     PRUint32 numAllParams; 
     allParams->GetLength(&numAllParams);
     // loop through every so called dependent PARAM tag to check if it
     // "belongs" to us
 
     for (PRUint32 i = 0; i < numAllParams; i++) {
@@ -3067,17 +3056,17 @@ nsresult nsPluginInstanceOwner::EnsureCa
   // Some plugins (eg Flash, see bug 234675.) are actually sensitive to the
   // attribute order.  So we want to make sure we give the plugin the
   // attributes in the order they came in in the source, to be compatible with
   // other browsers.  Now in HTML, the storage order is the reverse of the
   // source order, while in XML and XHTML it's the same as the source order
   // (see the AddAttributes functions in the HTML and XML content sinks).
   PRInt16 start, end, increment;
   if (mContent->IsNodeOfType(nsINode::eHTML) &&
-      mContent->NodeInfo()->NamespaceEquals(kNameSpaceID_None)) {
+      mContent->IsInHTMLDocument()) {
     // HTML.  Walk attributes in reverse order.
     start = numRealAttrs - 1;
     end = -1;
     increment = -1;
   } else {
     // XHTML or XML.  Walk attributes in forward order.
     start = 0;
     end = numRealAttrs;
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -892,26 +892,21 @@ RuleProcessorData::RuleProcessorData(nsP
 
     // get the ID and classes for the content
     mContentID = aContent->GetID();
     mClasses = aContent->GetClasses();
 
     // see if there are attributes for the content
     mHasAttributes = aContent->GetAttrCount() > 0;
 
+    // get the namespace
+    mNameSpaceID = aContent->GetNameSpaceID();
+
     // check for HTMLContent and Link status
-    if (aContent->IsNodeOfType(nsINode::eHTML)) {
-      mIsHTMLContent = PR_TRUE;
-      // Note that we want to treat non-XML HTML content as XHTML for namespace
-      // purposes, since html.css has that namespace declared.
-      mNameSpaceID = kNameSpaceID_XHTML;
-    } else {
-      // get the namespace
-      mNameSpaceID = aContent->GetNameSpaceID();
-    }
+    mIsHTMLContent = (mNameSpaceID == kNameSpaceID_XHTML);
 
     // if HTML content and it has some attributes, check for an HTML link
     // NOTE: optimization: cannot be a link if no attributes (since it needs an href)
     nsILinkHandler* linkHandler =
       mPresContext ? mPresContext->GetLinkHandler() : nsnull;
     if (mIsHTMLContent && mHasAttributes) {
       // check if it is an HTML Link
       if(nsStyleUtil::IsHTMLLink(aContent, mContentTag, linkHandler,
@@ -990,24 +985,16 @@ const nsString* RuleProcessorData::GetLa
           break;
         }
       }
     }
   }
   return mLanguage;
 }
 
-static inline PRInt32
-CSSNameSpaceID(nsIContent *aContent)
-{
-  return aContent->IsNodeOfType(nsINode::eHTML)
-           ? kNameSpaceID_XHTML
-           : aContent->GetNameSpaceID();
-}
-
 PRInt32
 RuleProcessorData::GetNthIndex(PRBool aIsOfType, PRBool aIsFromEnd,
                                PRBool aCheckEdgeOnly)
 {
   NS_ASSERTION(mParentContent, "caller should check mParentContent");
   NS_ASSERTION(!mPreviousSiblingData ||
                mPreviousSiblingData->mContent->IsNodeOfType(nsINode::eELEMENT),
                "Unexpected previous sibling data");
@@ -1056,17 +1043,17 @@ RuleProcessorData::GetNthIndex(PRBool aI
       break;
     }
     nsIContent* child = *curChildPtr;
     if (child == mContent)
       break;
     if (child->IsNodeOfType(nsINode::eELEMENT) &&
         (!aIsOfType ||
          (child->Tag() == mContentTag &&
-          CSSNameSpaceID(child) == mNameSpaceID))) {
+          child->GetNameSpaceID() == mNameSpaceID))) {
       if (aCheckEdgeOnly) {
         // The caller only cares whether or not the result is 1, and we
         // now know it's not.
         result = -1;
         break;
       }
       ++result;
     }
@@ -1565,18 +1552,17 @@ static PRBool SelectorMatches(RuleProces
     }
     else if (nsCSSPseudoClasses::mozReadWrite == pseudoClass->mAtom) {
       stateToCheck = NS_EVENT_STATE_MOZ_READWRITE;
     }
     else if (nsCSSPseudoClasses::indeterminate == pseudoClass->mAtom) {
       stateToCheck = NS_EVENT_STATE_INDETERMINATE;
     }
     else if (nsCSSPseudoClasses::mozIsHTML == pseudoClass->mAtom) {
-      result = data.mIsHTMLContent &&
-        data.mContent->GetNameSpaceID() == kNameSpaceID_None;
+      result = data.mIsHTMLContent && data.mContent->IsInHTMLDocument();
     }
 #ifdef MOZ_MATHML
     else if (nsCSSPseudoClasses::mozMathIncrementScriptLevel == pseudoClass->mAtom) {
       stateToCheck = NS_EVENT_STATE_INCREMENT_SCRIPT_LEVEL;
     }
 #endif
     else {
       NS_ERROR("CSS parser parsed a pseudo-class that we do not handle");
--- a/testing/tests/l10n/web/code-base.js
+++ b/testing/tests/l10n/web/code-base.js
@@ -204,17 +204,17 @@ baseView = {
       }
       else {
         tab.removeAttribute('selected');
       }
     }
     return true;
   },
   onClickDisplay: function(event) {
-    if (event.target.localName != 'INPUT') {
+    if (event.target.localName != 'input') {
       return false;
     }
     var handler = function() {return function(){view.setTierDisplay(event.target)}};
     window.setTimeout(handler(),10);
     return true;
   },
   setTierDisplay: function(aTier, aTruth) {
     if (aTruth === undefined && aTier instanceof HTMLInputElement) {