From 3028d60ea352e2eca21ee8fc43734dfefa079577 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Thu, 28 Oct 2004 02:34:21 +0000 Subject: [PATCH] Fix some case issues with getElementsByTagName(NS) in tag-soup and XHTML. Bug 264609, r+sr=jst git-svn-id: svn://10.0.0.236/trunk@164539 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/content/src/nsGenericHTMLElement.cpp | 16 ++++++++++++++++ .../html/content/src/nsGenericHTMLElement.h | 3 +++ .../content/html/document/src/nsHTMLDocument.cpp | 4 +++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 452c78bc56e..0db0201a5f1 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -425,6 +425,22 @@ nsGenericHTMLElement::GetElementsByTagName(const nsAString& aTagname, return nsGenericElement::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 nsGenericElement::GetElementsByTagNameNS(aNamespaceURI, localName, + aReturn); +} + // Implementation for nsIDOMHTMLElement nsresult nsGenericHTMLElement::GetId(nsAString& aId) diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.h b/mozilla/content/html/content/src/nsGenericHTMLElement.h index a375442547a..3559f0c5168 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.h +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.h @@ -108,6 +108,9 @@ public: 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 diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index e02aed95f4f..9a34124ab5d 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -1395,7 +1395,9 @@ nsHTMLDocument::GetElementsByTagName(const nsAString& aTagname, nsIDOMNodeList** aReturn) { nsAutoString tmp(aTagname); - ToLowerCase(tmp); // HTML elements are lower case internally. + if (!IsXHTML()) { + ToLowerCase(tmp); // HTML elements are lower case internally. + } return nsDocument::GetElementsByTagName(tmp, aReturn); }