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

This commit is contained in:
Henri Sivonen 2009-06-09 10:41:19 +03:00
Родитель 581aa9e694
Коммит 649265dc70
32 изменённых файлов: 138 добавлений и 240 удалений

Просмотреть файл

@ -78,7 +78,7 @@ function grid(aTableIdentifier)
this.handleKeyEvent = function handleKeyEvent(aEvent) this.handleKeyEvent = function handleKeyEvent(aEvent)
{ {
if (aEvent.target.localName != "TD") if (aEvent.target.localName != "td")
return; return;
var cell = aEvent.target; var cell = aEvent.target;
@ -131,7 +131,7 @@ function grid(aTableIdentifier)
this.handleClickEvent = function handleClickEvent(aEvent) this.handleClickEvent = function handleClickEvent(aEvent)
{ {
if (aEvent.target.localName != "TD") if (aEvent.target.localName != "td")
return; return;
var curCell = this.getCurrentCell(); var curCell = this.getCurrentCell();

Просмотреть файл

@ -45,7 +45,7 @@ function openContextMenuFor(element) {
// This seems to work, as long as we explicitly set the popupNode first. // 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. // 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; chromeWin.document.popupNode = element.contentDocument.body;
else else
chromeWin.document.popupNode = element; chromeWin.document.popupNode = element;

Просмотреть файл

@ -42,10 +42,10 @@
#include "nsCaseTreatment.h" #include "nsCaseTreatment.h"
#include "nsChangeHint.h" #include "nsChangeHint.h"
#include "nsINode.h" #include "nsINode.h"
#include "nsIDocument.h" // for IsInHTMLDocument
// Forward declarations // Forward declarations
class nsIAtom; class nsIAtom;
class nsIDocument;
class nsPresContext; class nsPresContext;
class nsIDOMEvent; class nsIDOMEvent;
class nsIContent; class nsIContent;
@ -202,6 +202,17 @@ public:
return IsInNativeAnonymousSubtree() || GetBindingParent() != nsnull; 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 * Get the namespace that this element's tag is defined in
* @return the namespace * @return the namespace

Просмотреть файл

@ -817,7 +817,7 @@ nsFrameLoader::EnsureDocShell()
nsAutoString frameName; nsAutoString frameName;
PRInt32 namespaceID = mOwnerContent->GetNameSpaceID(); PRInt32 namespaceID = mOwnerContent->GetNameSpaceID();
if (namespaceID == kNameSpaceID_XHTML) { if (namespaceID == kNameSpaceID_XHTML && !mOwnerContent->IsInHTMLDocument()) {
mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::id, frameName); mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::id, frameName);
} else { } else {
mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, frameName); mOwnerContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, frameName);

Просмотреть файл

@ -491,8 +491,7 @@ nsXHTMLContentSerializer::AfterElementStart(nsIContent * aContent,
nsAString& aStr) nsAString& aStr)
{ {
nsIAtom *name = aContent->Tag(); nsIAtom *name = aContent->Tag();
if (((mIsHTMLSerializer && aContent->GetNameSpaceID() == kNameSpaceID_None) || if (aContent->GetNameSpaceID() == kNameSpaceID_XHTML &&
(!mIsHTMLSerializer && aContent->GetNameSpaceID() == kNameSpaceID_XHTML)) &&
mIsWholeDocument && mIsWholeDocument &&
name == nsGkAtoms::head) { name == nsGkAtoms::head) {
@ -574,8 +573,7 @@ nsXHTMLContentSerializer::CheckElementStart(nsIContent * aContent,
nsIAtom *name = aContent->Tag(); nsIAtom *name = aContent->Tag();
PRInt32 namespaceID = aContent->GetNameSpaceID(); PRInt32 namespaceID = aContent->GetNameSpaceID();
if ((mIsHTMLSerializer && namespaceID == kNameSpaceID_None) || if (namespaceID == kNameSpaceID_XHTML) {
(!mIsHTMLSerializer && namespaceID == kNameSpaceID_XHTML)) {
if (name == nsGkAtoms::br && mPreLevel > 0 && if (name == nsGkAtoms::br && mPreLevel > 0 &&
(mFlags & nsIDocumentEncoder::OutputNoFormattingInPre)) { (mFlags & nsIDocumentEncoder::OutputNoFormattingInPre)) {
AppendNewLineToString(aStr); AppendNewLineToString(aStr);
@ -941,8 +939,7 @@ PRBool
nsXHTMLContentSerializer::LineBreakBeforeOpen(PRInt32 aNamespaceID, nsIAtom* aName) nsXHTMLContentSerializer::LineBreakBeforeOpen(PRInt32 aNamespaceID, nsIAtom* aName)
{ {
if ((mIsHTMLSerializer && aNamespaceID != kNameSpaceID_None) || if (aNamespaceID != kNameSpaceID_XHTML) {
(!mIsHTMLSerializer && aNamespaceID != kNameSpaceID_XHTML)) {
return mAddSpace; return mAddSpace;
} }
@ -973,8 +970,7 @@ PRBool
nsXHTMLContentSerializer::LineBreakAfterOpen(PRInt32 aNamespaceID, nsIAtom* aName) nsXHTMLContentSerializer::LineBreakAfterOpen(PRInt32 aNamespaceID, nsIAtom* aName)
{ {
if ((mIsHTMLSerializer && aNamespaceID != kNameSpaceID_None) || if (aNamespaceID != kNameSpaceID_XHTML) {
(!mIsHTMLSerializer && aNamespaceID != kNameSpaceID_XHTML)) {
return PR_FALSE; return PR_FALSE;
} }
@ -1005,8 +1001,7 @@ PRBool
nsXHTMLContentSerializer::LineBreakBeforeClose(PRInt32 aNamespaceID, nsIAtom* aName) nsXHTMLContentSerializer::LineBreakBeforeClose(PRInt32 aNamespaceID, nsIAtom* aName)
{ {
if ((mIsHTMLSerializer && aNamespaceID != kNameSpaceID_None) || if (aNamespaceID != kNameSpaceID_XHTML) {
(!mIsHTMLSerializer && aNamespaceID != kNameSpaceID_XHTML)) {
return PR_FALSE; return PR_FALSE;
} }
@ -1028,8 +1023,7 @@ PRBool
nsXHTMLContentSerializer::LineBreakAfterClose(PRInt32 aNamespaceID, nsIAtom* aName) nsXHTMLContentSerializer::LineBreakAfterClose(PRInt32 aNamespaceID, nsIAtom* aName)
{ {
if ((mIsHTMLSerializer && aNamespaceID != kNameSpaceID_None) || if (aNamespaceID != kNameSpaceID_XHTML) {
(!mIsHTMLSerializer && aNamespaceID != kNameSpaceID_XHTML)) {
return PR_FALSE; return PR_FALSE;
} }
@ -1070,8 +1064,7 @@ void
nsXHTMLContentSerializer::MaybeEnterInPreContent(nsIContent* aNode) nsXHTMLContentSerializer::MaybeEnterInPreContent(nsIContent* aNode)
{ {
if ((mIsHTMLSerializer && aNode->GetNameSpaceID() != kNameSpaceID_None) || if (aNode->GetNameSpaceID() != kNameSpaceID_XHTML) {
(!mIsHTMLSerializer && aNode->GetNameSpaceID() != kNameSpaceID_XHTML)) {
return; return;
} }
@ -1090,8 +1083,7 @@ nsXHTMLContentSerializer::MaybeEnterInPreContent(nsIContent* aNode)
void void
nsXHTMLContentSerializer::MaybeLeaveFromPreContent(nsIContent* aNode) nsXHTMLContentSerializer::MaybeLeaveFromPreContent(nsIContent* aNode)
{ {
if ((mIsHTMLSerializer && aNode->GetNameSpaceID() != kNameSpaceID_None) || if (aNode->GetNameSpaceID() != kNameSpaceID_XHTML) {
(!mIsHTMLSerializer && aNode->GetNameSpaceID() != kNameSpaceID_XHTML)) {
return; return;
} }

Просмотреть файл

@ -18,42 +18,42 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=276037
<pre id="test"> <pre id="test">
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
/** Test for Bug 276037 **/ /** Test for Bug 276037 **/
function countElements (node, namespaceURI, tagName) { function countElements (node, namespaceURI, localName) {
var count = 0; var count = 0;
for (var i = 0; i < node.childNodes.length; i++) { for (var i = 0; i < node.childNodes.length; i++) {
var child = node.childNodes[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) { child.namespaceURI == namespaceURI) {
count++; count++;
} }
if (child.hasChildNodes()) { if (child.hasChildNodes()) {
count += countElements(child, namespaceURI, tagName); count += countElements(child, namespaceURI, localName);
} }
} }
return count; return count;
} }
function checkElements(namespaceURI, tagName) { function checkElements(namespaceURI, localName) {
var elementsNS = document.getElementsByTagNameNS(namespaceURI, tagName); var elementsNS = document.getElementsByTagNameNS(namespaceURI, localName);
var elements = document.getElementsByTagName(tagName); var elements = document.getElementsByTagName(localName);
var elementCount = countElements(document, namespaceURI, tagName); var elementCount = countElements(document, namespaceURI, localName);
const gEBTN = 'document.getElementsByTagName(\'' + tagName + '\').length: ' + elements.length; const gEBTN = 'document.getElementsByTagName(\'' + localName + '\').length: ' + elements.length;
const gEBTNNS = '; document.getElementsByTagNameNS(\'' + namespaceURI + '\', \'' + tagName + '\').length: ' + elementsNS.length; const gEBTNNS = '; document.getElementsByTagNameNS(\'' + namespaceURI + '\', \'' + localName + '\').length: ' + elementsNS.length;
text1 = gEBTN + '; element count: ' + elementCount; text1 = gEBTN + '; element count: ' + elementCount;
text2 = gEBTNNS + '; element count: ' + elementCount; text2 = gEBTNNS + '; element count: ' + elementCount;
is(elements.length, elementCount, text1); is(elements.length, elementCount, text1);
is(elementsNS.length, elementCount, text2); is(elementsNS.length, elementCount, text2);
is(global.gEBTN[namespaceURI][tagName].length, elementCount, text1); is(global.gEBTN[namespaceURI][localName].length, elementCount, text1);
is(global.gEBTNNS[namespaceURI][tagName].length, elementCount, text2); is(global.gEBTNNS[namespaceURI][localName].length, elementCount, text2);
} }
const xhtmlNS = null; const xhtmlNS = 'http://www.w3.org/1999/xhtml';
function checkSpansAndScripts () { function checkSpansAndScripts () {
checkElements(xhtmlNS, 'SPAN'); checkElements(xhtmlNS, 'span');
checkElements(xhtmlNS, 'SCRIPT'); checkElements(xhtmlNS, 'script');
} }
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
@ -67,10 +67,10 @@ global.gEBTN[xhtmlNS] = {};
global.gEBTNNS = {}; global.gEBTNNS = {};
global.gEBTNNS[xhtmlNS] = {}; global.gEBTNNS[xhtmlNS] = {};
global.gEBTN[xhtmlNS].SPAN = document.getElementsByTagName("span"); global.gEBTN[xhtmlNS].span = document.getElementsByTagName("span");
global.gEBTNNS[xhtmlNS].SPAN = document.getElementsByTagNameNS(xhtmlNS, "span"); global.gEBTNNS[xhtmlNS].span = document.getElementsByTagNameNS(xhtmlNS, "span");
global.gEBTN[xhtmlNS].SCRIPT = document.getElementsByTagName("script"); global.gEBTN[xhtmlNS].script = document.getElementsByTagName("script");
global.gEBTNNS[xhtmlNS].SCRIPT = document.getElementsByTagNameNS(xhtmlNS, "script"); global.gEBTNNS[xhtmlNS].script = document.getElementsByTagNameNS(xhtmlNS, "script");
</script> </script>
<p><span>Static text in span.</span></p> <p><span>Static text in span.</span></p>
<script type="text/javascript"> <script type="text/javascript">

Просмотреть файл

@ -305,7 +305,7 @@ nsGenericHTMLElement::SetAttribute(const nsAString& aName,
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIAtom> nameAtom; nsCOMPtr<nsIAtom> nameAtom;
if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) { if (IsInHTMLDocument()) {
nsAutoString lower; nsAutoString lower;
ToLowerCase(aName, lower); ToLowerCase(aName, lower);
nameAtom = do_GetAtom(lower); nameAtom = do_GetAtom(lower);
@ -327,58 +327,25 @@ nsGenericHTMLElement::GetNodeName(nsAString& aNodeName)
{ {
mNodeInfo->GetQualifiedName(aNodeName); mNodeInfo->GetQualifiedName(aNodeName);
if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) if (IsInHTMLDocument())
ToUpperCase(aNodeName); ToUpperCase(aNodeName);
return NS_OK; 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 nsresult
nsGenericHTMLElement::GetElementsByTagName(const nsAString& aTagname, nsGenericHTMLElement::GetElementsByTagName(const nsAString& aTagname,
nsIDOMNodeList** aReturn) nsIDOMNodeList** aReturn)
{ {
nsAutoString tagName(aTagname); nsAutoString tagName(aTagname);
// Only lowercase the name if this element has no namespace (i.e. // Only lowercase the name if this is an HTML document.
// it's a HTML element, not an XHTML element). if (IsInHTMLDocument())
if (mNodeInfo && mNodeInfo->NamespaceEquals(kNameSpaceID_None))
ToLowerCase(tagName); ToLowerCase(tagName);
return nsGenericHTMLElementBase::GetElementsByTagName(tagName, aReturn); 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 // Implementation for nsIDOMHTMLElement
nsresult nsresult
nsGenericHTMLElement::GetId(nsAString& aId) nsGenericHTMLElement::GetId(nsAString& aId)
@ -671,8 +638,7 @@ nsGenericHTMLElement::GetInnerHTML(nsAString& aInnerHTML)
nsresult rv = NS_OK; nsresult rv = NS_OK;
nsAutoString contentType; nsAutoString contentType;
if (!doc->IsCaseSensitive()) { if (IsInHTMLDocument()) {
// All case-insensitive documents are HTML as far as we're concerned
contentType.AssignLiteral("text/html"); contentType.AssignLiteral("text/html");
} else { } else {
doc->GetContentType(contentType); doc->GetContentType(contentType);
@ -1200,8 +1166,6 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
already_AddRefed<nsIURI> already_AddRefed<nsIURI>
nsGenericHTMLElement::GetBaseURI() const nsGenericHTMLElement::GetBaseURI() const
{ {
nsIDocument* doc = GetOwnerDoc();
void* prop; void* prop;
if (HasFlag(NODE_HAS_PROPERTIES) && (prop = GetProperty(nsGkAtoms::htmlBaseHref))) { if (HasFlag(NODE_HAS_PROPERTIES) && (prop = GetProperty(nsGkAtoms::htmlBaseHref))) {
nsIURI* uri = static_cast<nsIURI*>(prop); nsIURI* uri = static_cast<nsIURI*>(prop);
@ -1212,15 +1176,12 @@ nsGenericHTMLElement::GetBaseURI() const
// If we are a plain old HTML element (not XHTML), don't bother asking the // 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. // base class -- our base URI is determined solely by the document base.
if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) { if (IsInHTMLDocument()) {
if (doc) { // If we got here, GetOwnerDoc() is not null
nsIURI *uri = doc->GetBaseURI(); nsIURI *uri = GetOwnerDoc()->GetBaseURI();
NS_IF_ADDREF(uri); NS_IF_ADDREF(uri);
return uri; return uri;
}
return nsnull;
} }
return nsGenericHTMLElementBase::GetBaseURI(); return nsGenericHTMLElementBase::GetBaseURI();
@ -3461,7 +3422,7 @@ nsGenericHTMLElement::GetHashFromHrefURI(nsAString& aHash)
const nsAttrName* const nsAttrName*
nsGenericHTMLElement::InternalGetExistingAttrNameFromQName(const nsAString& aStr) const nsGenericHTMLElement::InternalGetExistingAttrNameFromQName(const nsAString& aStr) const
{ {
if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) { if (IsInHTMLDocument()) {
nsAutoString lower; nsAutoString lower;
ToLowerCase(aStr, lower); ToLowerCase(aStr, lower);
return mAttrsAndChildren.GetExistingAttrNameFromQName( return mAttrsAndChildren.GetExistingAttrNameFromQName(

Просмотреть файл

@ -103,7 +103,6 @@ public:
// Implementation for nsIDOMNode // Implementation for nsIDOMNode
NS_METHOD GetNodeName(nsAString& aNodeName); NS_METHOD GetNodeName(nsAString& aNodeName);
NS_METHOD GetLocalName(nsAString& aLocalName);
// Implementation for nsIDOMElement // Implementation for nsIDOMElement
NS_METHOD SetAttribute(const nsAString& aName, NS_METHOD SetAttribute(const nsAString& aName,
@ -111,9 +110,6 @@ public:
NS_METHOD GetTagName(nsAString& aTagName); NS_METHOD GetTagName(nsAString& aTagName);
NS_METHOD GetElementsByTagName(const nsAString& aTagname, NS_METHOD GetElementsByTagName(const nsAString& aTagname,
nsIDOMNodeList** aReturn); nsIDOMNodeList** aReturn);
NS_METHOD GetElementsByTagNameNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName,
nsIDOMNodeList** aReturn);
// nsIDOMHTMLElement methods. Note that these are non-virtual // nsIDOMHTMLElement methods. Note that these are non-virtual
// methods, implementations are expected to forward calls to these // methods, implementations are expected to forward calls to these

Просмотреть файл

@ -152,7 +152,7 @@ NS_NewHTMLOptionElement(nsINodeInfo *aNodeInfo, PRBool aFromParser)
NS_ENSURE_TRUE(doc, nsnull); NS_ENSURE_TRUE(doc, nsnull);
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::option, nsnull, nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::option, nsnull,
kNameSpaceID_None); kNameSpaceID_XHTML);
NS_ENSURE_TRUE(nodeInfo, nsnull); NS_ENSURE_TRUE(nodeInfo, nsnull);
} }

Просмотреть файл

@ -321,7 +321,7 @@ nsHTMLStyleElement::GetStyleSheetURL(PRBool* aIsInline,
if (*aIsInline) { if (*aIsInline) {
return; return;
} }
if (mNodeInfo->NamespaceEquals(kNameSpaceID_XHTML)) { if (!IsInHTMLDocument()) {
// We stopped supporting <style src="..."> for XHTML as it is // We stopped supporting <style src="..."> for XHTML as it is
// non-standard. // non-standard.
*aIsInline = PR_TRUE; *aIsInline = PR_TRUE;

Просмотреть файл

@ -250,7 +250,7 @@ nsHTMLTableRowElement::GetCells(nsIDOMHTMLCollection** aValue)
nsnull, // closure data nsnull, // closure data
PR_FALSE, PR_FALSE,
nsnull, nsnull,
kNameSpaceID_None, kNameSpaceID_XHTML,
PR_FALSE); PR_FALSE);
NS_ENSURE_TRUE(mCells, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(mCells, NS_ERROR_OUT_OF_MEMORY);

Просмотреть файл

@ -548,7 +548,7 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
ToLowerCase(tmp); ToLowerCase(tmp);
nsCOMPtr<nsIAtom> name = do_GetAtom(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]) { else if (mNodeInfoCache[aNodeType]) {
nodeInfo = mNodeInfoCache[aNodeType]; nodeInfo = mNodeInfoCache[aNodeType];
@ -561,7 +561,7 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
nsIAtom *name = parserService->HTMLIdToAtomTag(aNodeType); nsIAtom *name = parserService->HTMLIdToAtomTag(aNodeType);
NS_ASSERTION(name, "What? Reverse mapping of id to string broken!!!"); 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_IF_ADDREF(mNodeInfoCache[aNodeType] = nodeInfo);
} }
@ -583,15 +583,8 @@ NS_NewHTMLElement(nsIContent** aResult, nsINodeInfo *aNodeInfo,
nsIAtom *name = aNodeInfo->NameAtom(); nsIAtom *name = aNodeInfo->NameAtom();
#ifdef DEBUG NS_ASSERTION(aNodeInfo->NamespaceEquals(kNameSpaceID_XHTML),
if (aNodeInfo->NamespaceEquals(kNameSpaceID_None)) { "Trying to HTML elements that don't have the XHTML namespace");
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
*aResult = CreateHTMLElement(parserService-> *aResult = CreateHTMLElement(parserService->
HTMLCaseSensitiveAtomTagToId(name), HTMLCaseSensitiveAtomTagToId(name),
@ -1682,7 +1675,7 @@ HTMLContentSink::Init(nsIDocument* aDoc,
nsCOMPtr<nsINodeInfo> nodeInfo; nsCOMPtr<nsINodeInfo> nodeInfo;
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::html, nsnull, nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::html, nsnull,
kNameSpaceID_None); kNameSpaceID_XHTML);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
// Make root part // Make root part
@ -1710,7 +1703,7 @@ HTMLContentSink::Init(nsIDocument* aDoc,
// Make head part // Make head part
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::head, nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::head,
nsnull, kNameSpaceID_None); nsnull, kNameSpaceID_XHTML);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
mHead = NS_NewHTMLHeadElement(nodeInfo); mHead = NS_NewHTMLHeadElement(nodeInfo);
@ -2903,7 +2896,7 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
// Create content object // Create content object
nsCOMPtr<nsIContent> element; nsCOMPtr<nsIContent> element;
nsCOMPtr<nsINodeInfo> nodeInfo; 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); result = NS_NewHTMLElement(getter_AddRefs(element), nodeInfo, PR_FALSE);
NS_ENSURE_SUCCESS(result, result); NS_ENSURE_SUCCESS(result, result);

Просмотреть файл

@ -1212,7 +1212,7 @@ nsHTMLDocument::CreateElement(const nsAString& aTagName,
nsCOMPtr<nsIAtom> name = do_GetAtom(tagName); nsCOMPtr<nsIAtom> name = do_GetAtom(tagName);
nsCOMPtr<nsIContent> content; nsCOMPtr<nsIContent> content;
rv = CreateElem(name, nsnull, GetDefaultNamespaceID(), PR_TRUE, rv = CreateElem(name, nsnull, kNameSpaceID_XHTML, PR_TRUE,
getter_AddRefs(content)); getter_AddRefs(content));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -1593,7 +1593,7 @@ NS_IMETHODIMP
nsHTMLDocument::GetImages(nsIDOMHTMLCollection** aImages) nsHTMLDocument::GetImages(nsIDOMHTMLCollection** aImages)
{ {
if (!mImages) { if (!mImages) {
mImages = new nsContentList(this, nsGkAtoms::img, GetDefaultNamespaceID()); mImages = new nsContentList(this, nsGkAtoms::img, kNameSpaceID_XHTML);
if (!mImages) { if (!mImages) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
@ -1609,8 +1609,7 @@ NS_IMETHODIMP
nsHTMLDocument::GetApplets(nsIDOMHTMLCollection** aApplets) nsHTMLDocument::GetApplets(nsIDOMHTMLCollection** aApplets)
{ {
if (!mApplets) { if (!mApplets) {
mApplets = new nsContentList(this, nsGkAtoms::applet, mApplets = new nsContentList(this, nsGkAtoms::applet, kNameSpaceID_XHTML);
GetDefaultNamespaceID());
if (!mApplets) { if (!mApplets) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
@ -1643,10 +1642,9 @@ nsHTMLDocument::MatchLinks(nsIContent *aContent, PRInt32 aNamespaceID,
#endif #endif
nsINodeInfo *ni = aContent->NodeInfo(); nsINodeInfo *ni = aContent->NodeInfo();
PRInt32 namespaceID = doc->GetDefaultNamespaceID();
nsIAtom *localName = ni->NameAtom(); nsIAtom *localName = ni->NameAtom();
if (ni->NamespaceID() == namespaceID && if (ni->NamespaceID() == kNameSpaceID_XHTML &&
(localName == nsGkAtoms::a || localName == nsGkAtoms::area)) { (localName == nsGkAtoms::a || localName == nsGkAtoms::area)) {
return aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::href); return aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::href);
} }
@ -1688,8 +1686,7 @@ nsHTMLDocument::MatchAnchors(nsIContent *aContent, PRInt32 aNamespaceID,
} }
#endif #endif
PRInt32 namespaceID = aContent->GetCurrentDoc()->GetDefaultNamespaceID(); if (aContent->NodeInfo()->Equals(nsGkAtoms::a, kNameSpaceID_XHTML)) {
if (aContent->NodeInfo()->Equals(nsGkAtoms::a, namespaceID)) {
return aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::name); return aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::name);
} }
@ -2255,13 +2252,7 @@ nsHTMLDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName, const nsAString& aLocalName,
nsIDOMNodeList** aReturn) nsIDOMNodeList** aReturn)
{ {
nsAutoString tmp(aLocalName); return nsDocument::GetElementsByTagNameNS(aNamespaceURI, aLocalName, aReturn);
if (!IsXHTML()) {
ToLowerCase(tmp); // HTML elements are lower case internally.
}
return nsDocument::GetElementsByTagNameNS(aNamespaceURI, tmp, aReturn);
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -2585,7 +2576,7 @@ NS_IMETHODIMP
nsHTMLDocument::GetEmbeds(nsIDOMHTMLCollection** aEmbeds) nsHTMLDocument::GetEmbeds(nsIDOMHTMLCollection** aEmbeds)
{ {
if (!mEmbeds) { if (!mEmbeds) {
mEmbeds = new nsContentList(this, nsGkAtoms::embed, GetDefaultNamespaceID()); mEmbeds = new nsContentList(this, nsGkAtoms::embed, kNameSpaceID_XHTML);
if (!mEmbeds) { if (!mEmbeds) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
@ -2918,7 +2909,7 @@ nsContentList*
nsHTMLDocument::GetForms() nsHTMLDocument::GetForms()
{ {
if (!mForms) if (!mForms)
mForms = new nsContentList(this, nsGkAtoms::form, GetDefaultNamespaceID()); mForms = new nsContentList(this, nsGkAtoms::form, kNameSpaceID_XHTML);
return mForms; return mForms;
} }
@ -3136,7 +3127,7 @@ DocAllResultMatch(nsIContent* aContent, PRInt32 aNamespaceID, nsIAtom* aAtom,
} }
nsGenericHTMLElement* elm = nsGenericHTMLElement::FromContent(aContent); nsGenericHTMLElement* elm = nsGenericHTMLElement::FromContent(aContent);
if (!elm || aContent->GetNameSpaceID() != kNameSpaceID_None) { if (!elm) {
return PR_FALSE; return PR_FALSE;
} }
@ -4059,31 +4050,6 @@ nsHTMLDocument::QueryCommandValue(const nsAString & commandID,
return rv; 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 nsresult
nsHTMLDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const nsHTMLDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
{ {

Просмотреть файл

@ -184,13 +184,6 @@ public:
return !mIsRegularHTML; return !mIsRegularHTML;
} }
#ifdef DEBUG
virtual nsresult CreateElem(nsIAtom *aName, nsIAtom *aPrefix,
PRInt32 aNamespaceID,
PRBool aDocumentDefaultType,
nsIContent** aResult);
#endif
nsresult ChangeContentEditableCount(nsIContent *aElement, PRInt32 aChange); nsresult ChangeContentEditableCount(nsIContent *aElement, PRInt32 aChange);
virtual EditingState GetEditingState() virtual EditingState GetEditingState()
@ -274,7 +267,7 @@ protected:
virtual PRInt32 GetDefaultNamespaceID() const virtual PRInt32 GetDefaultNamespaceID() const
{ {
return mIsRegularHTML ? kNameSpaceID_None : kNameSpaceID_XHTML; return kNameSpaceID_XHTML;
} }
nsCOMArray<nsIDOMHTMLMapElement> mImageMaps; nsCOMArray<nsIDOMHTMLMapElement> mImageMaps;

Просмотреть файл

@ -419,7 +419,9 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
ToLowerCase(tmp); ToLowerCase(tmp);
nsCOMPtr<nsIAtom> name = do_GetAtom(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); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
} }
else if (mNodeInfoCache[nodeType]) { else if (mNodeInfoCache[nodeType]) {
@ -433,7 +435,9 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
nsIAtom *name = parserService->HTMLIdToAtomTag(nodeType); nsIAtom *name = parserService->HTMLIdToAtomTag(nodeType);
NS_ASSERTION(name, "This should not happen!"); 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_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(mNodeInfoCache[nodeType] = nodeInfo); NS_ADDREF(mNodeInfoCache[nodeType] = nodeInfo);
@ -521,7 +525,7 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
nsCOMPtr<nsIAtom> name = do_GetAtom(tmp); nsCOMPtr<nsIAtom> name = do_GetAtom(tmp);
nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull, nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull,
kNameSpaceID_None); kNameSpaceID_XHTML);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
} }
else if (mNodeInfoCache[nodeType]) { else if (mNodeInfoCache[nodeType]) {
@ -532,7 +536,7 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
NS_ASSERTION(name, "This should not happen!"); NS_ASSERTION(name, "This should not happen!");
nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull, nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull,
kNameSpaceID_None); kNameSpaceID_XHTML);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(mNodeInfoCache[nodeType] = nodeInfo); NS_ADDREF(mNodeInfoCache[nodeType] = nodeInfo);
} }
@ -1011,7 +1015,7 @@ nsHTMLParanoidFragmentSink::NameFromNode(const nsIParserNode& aNode,
nsCOMPtr<nsINodeInfo> nodeInfo; nsCOMPtr<nsINodeInfo> nodeInfo;
rv = rv =
mNodeInfoManager->GetNodeInfo(aNode.GetText(), nsnull, mNodeInfoManager->GetNodeInfo(aNode.GetText(), nsnull,
kNameSpaceID_None, kNameSpaceID_XHTML,
getter_AddRefs(nodeInfo)); getter_AddRefs(nodeInfo));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
NS_IF_ADDREF(*aResult = nodeInfo->NameAtom()); NS_IF_ADDREF(*aResult = nodeInfo->NameAtom());
@ -1175,7 +1179,7 @@ nsHTMLParanoidFragmentSink::AddLeaf(const nsIParserNode& aNode)
if (!parserService) if (!parserService)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull, nodeInfo = mNodeInfoManager->GetNodeInfo(name, nsnull,
kNameSpaceID_None); kNameSpaceID_XHTML);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
rv = NS_NewHTMLElement(getter_AddRefs(content), nodeInfo, PR_FALSE); rv = NS_NewHTMLElement(getter_AddRefs(content), nodeInfo, PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -627,7 +627,7 @@ nsImageDocument::CreateSyntheticDocument()
nsCOMPtr<nsINodeInfo> nodeInfo; nsCOMPtr<nsINodeInfo> nodeInfo;
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::img, nsnull, nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::img, nsnull,
kNameSpaceID_None); kNameSpaceID_XHTML);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
mImageContent = NS_NewHTMLImageElement(nodeInfo); mImageContent = NS_NewHTMLImageElement(nodeInfo);

Просмотреть файл

@ -234,7 +234,7 @@ nsMediaDocument::CreateSyntheticDocument()
nsCOMPtr<nsINodeInfo> nodeInfo; nsCOMPtr<nsINodeInfo> nodeInfo;
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::html, nsnull, nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::html, nsnull,
kNameSpaceID_None); kNameSpaceID_XHTML);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
nsRefPtr<nsGenericHTMLElement> root = NS_NewHTMLHtmlElement(nodeInfo); nsRefPtr<nsGenericHTMLElement> root = NS_NewHTMLHtmlElement(nodeInfo);
@ -247,7 +247,7 @@ nsMediaDocument::CreateSyntheticDocument()
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::head, nsnull, nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::head, nsnull,
kNameSpaceID_None); kNameSpaceID_XHTML);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
// Create a <head> so our title has somewhere to live // Create a <head> so our title has somewhere to live
@ -259,7 +259,7 @@ nsMediaDocument::CreateSyntheticDocument()
root->AppendChildTo(head, PR_FALSE); root->AppendChildTo(head, PR_FALSE);
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::body, nsnull, nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::body, nsnull,
kNameSpaceID_None); kNameSpaceID_XHTML);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
nsRefPtr<nsGenericHTMLElement> body = NS_NewHTMLBodyElement(nodeInfo); nsRefPtr<nsGenericHTMLElement> body = NS_NewHTMLBodyElement(nodeInfo);

Просмотреть файл

@ -281,7 +281,7 @@ nsPluginDocument::CreateSyntheticPluginDocument()
// make plugin content // make plugin content
nsCOMPtr<nsINodeInfo> nodeInfo; nsCOMPtr<nsINodeInfo> nodeInfo;
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::embed, nsnull, nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::embed, nsnull,
kNameSpaceID_None); kNameSpaceID_XHTML);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
rv = NS_NewHTMLElement(getter_AddRefs(mPluginContent), nodeInfo, PR_FALSE); rv = NS_NewHTMLElement(getter_AddRefs(mPluginContent), nodeInfo, PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -109,7 +109,7 @@ nsVideoDocument::CreateSyntheticVideoDocument(nsIChannel* aChannel,
// make content // make content
nsCOMPtr<nsINodeInfo> nodeInfo; nsCOMPtr<nsINodeInfo> nodeInfo;
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::video, nsnull, nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::video, nsnull,
kNameSpaceID_None); kNameSpaceID_XHTML);
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_FAILURE); NS_ENSURE_TRUE(nodeInfo, NS_ERROR_FAILURE);
nsRefPtr<nsHTMLMediaElement> element = nsRefPtr<nsHTMLMediaElement> element =

Просмотреть файл

@ -37,7 +37,7 @@
// Event handler for display togglers in Table of Contents // Event handler for display togglers in Table of Contents
function toggleDisplay(event) function toggleDisplay(event)
{ {
if (event.target.localName != "IMG") if (event.target.localName != "img")
return; return;
var img = event.target; var img = event.target;
var div = img.nextSibling.nextSibling; var div = img.nextSibling.nextSibling;

Просмотреть файл

@ -72,7 +72,12 @@ PRBool txNameTest::matches(const txXPathNode& aNode, txIMatchContext* aContext)
return MB_TRUE; return MB_TRUE;
// Compare namespaces // 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; return MB_FALSE;
// Name wild? // Name wild?

Просмотреть файл

@ -143,8 +143,16 @@ public:
static PRBool isProcessingInstruction(const txXPathNode& aNode); static PRBool isProcessingInstruction(const txXPathNode& aNode);
static PRBool isComment(const txXPathNode& aNode); static PRBool isComment(const txXPathNode& aNode);
static PRBool isText(const txXPathNode& aNode); static PRBool isText(const txXPathNode& aNode);
#ifndef TX_EXE
#ifdef 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: private:
static void appendNodeValueHelper(NodeDefinition* aNode, nsAString& aResult); static void appendNodeValueHelper(NodeDefinition* aNode, nsAString& aResult);
#endif #endif

Просмотреть файл

@ -453,11 +453,12 @@ txMozillaXMLOutput::startElement(nsIAtom* aPrefix, nsIAtom* aLocalName,
aLowercaseLocalName = owner; aLowercaseLocalName = owner;
} }
return startElementInternal(nsnull, aLowercaseLocalName, return startElementInternal(nsnull,
kNameSpaceID_None, kNameSpaceID_XHTML); aLowercaseLocalName,
kNameSpaceID_XHTML);
} }
return startElementInternal(aPrefix, aLocalName, aNsID, aNsID); return startElementInternal(aPrefix, aLocalName, aNsID);
} }
nsresult nsresult
@ -465,11 +466,11 @@ txMozillaXMLOutput::startElement(nsIAtom* aPrefix,
const nsSubstring& aLocalName, const nsSubstring& aLocalName,
const PRInt32 aNsID) const PRInt32 aNsID)
{ {
PRInt32 elemType = aNsID; PRInt32 nsId = aNsID;
nsCOMPtr<nsIAtom> lname; nsCOMPtr<nsIAtom> lname;
if (mOutputFormat.mMethod == eHTMLOutput && aNsID == kNameSpaceID_None) { if (mOutputFormat.mMethod == eHTMLOutput && aNsID == kNameSpaceID_None) {
elemType = kNameSpaceID_XHTML; nsId = kNameSpaceID_XHTML;
nsAutoString lnameStr; nsAutoString lnameStr;
ToLowerCase(aLocalName, lnameStr); ToLowerCase(aLocalName, lnameStr);
@ -483,22 +484,21 @@ txMozillaXMLOutput::startElement(nsIAtom* aPrefix,
NS_ENSURE_TRUE(lname, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(lname, NS_ERROR_OUT_OF_MEMORY);
// Check that it's a valid name // Check that it's a valid name
if (!nsContentUtils::IsValidNodeName(lname, aPrefix, aNsID)) { if (!nsContentUtils::IsValidNodeName(lname, aPrefix, nsId)) {
// Try without prefix // Try without prefix
aPrefix = nsnull; aPrefix = nsnull;
if (!nsContentUtils::IsValidNodeName(lname, aPrefix, aNsID)) { if (!nsContentUtils::IsValidNodeName(lname, aPrefix, nsId)) {
return NS_ERROR_XSLT_BAD_NODE_NAME; return NS_ERROR_XSLT_BAD_NODE_NAME;
} }
} }
return startElementInternal(aPrefix, lname, aNsID, elemType); return startElementInternal(aPrefix, lname, nsId);
} }
nsresult nsresult
txMozillaXMLOutput::startElementInternal(nsIAtom* aPrefix, txMozillaXMLOutput::startElementInternal(nsIAtom* aPrefix,
nsIAtom* aLocalName, nsIAtom* aLocalName,
PRInt32 aNsID, PRInt32 aNsID)
PRInt32 aElemType)
{ {
TX_ENSURE_CURRENTNODE; TX_ENSURE_CURRENTNODE;
@ -539,12 +539,12 @@ txMozillaXMLOutput::startElementInternal(nsIAtom* aPrefix,
ni = mNodeInfoManager->GetNodeInfo(aLocalName, aPrefix, aNsID); ni = mNodeInfoManager->GetNodeInfo(aLocalName, aPrefix, aNsID);
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY); 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 // Set up the element and adjust state
if (!mNoFixup) { if (!mNoFixup) {
if (aElemType == kNameSpaceID_XHTML) { if (aNsID == kNameSpaceID_XHTML) {
mOpenedElementIsHTML = aNsID != kNameSpaceID_XHTML; mOpenedElementIsHTML = (mOutputFormat.mMethod == eHTMLOutput);
rv = startHTMLElement(mOpenedElement, mOpenedElementIsHTML); rv = startHTMLElement(mOpenedElement, mOpenedElementIsHTML);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -971,7 +971,7 @@ txMozillaXMLOutput::createHTMLElement(nsIAtom* aName,
nsCOMPtr<nsINodeInfo> ni; nsCOMPtr<nsINodeInfo> ni;
ni = mNodeInfoManager->GetNodeInfo(aName, nsnull, ni = mNodeInfoManager->GetNodeInfo(aName, nsnull,
kNameSpaceID_None); kNameSpaceID_XHTML);
NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY);
return NS_NewHTMLElement(aResult, ni, PR_FALSE); return NS_NewHTMLElement(aResult, ni, PR_FALSE);

Просмотреть файл

@ -121,7 +121,7 @@ private:
nsresult attributeInternal(nsIAtom* aPrefix, nsIAtom* aLocalName, nsresult attributeInternal(nsIAtom* aPrefix, nsIAtom* aLocalName,
PRInt32 aNsID, const nsString& aValue); PRInt32 aNsID, const nsString& aValue);
nsresult startElementInternal(nsIAtom* aPrefix, nsIAtom* aLocalName, nsresult startElementInternal(nsIAtom* aPrefix, nsIAtom* aLocalName,
PRInt32 aNsID, PRInt32 aElemType); PRInt32 aNsID);
nsCOMPtr<nsIDocument> mDocument; nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<nsINode> mCurrentNode; // This is updated once an element is nsCOMPtr<nsINode> mCurrentNode; // This is updated once an element is

Просмотреть файл

@ -5185,12 +5185,6 @@ nsEditor::CreateHTMLContent(const nsAString& aTag, nsIContent** aContent)
if (!tag) if (!tag)
return NS_ERROR_OUT_OF_MEMORY; 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); return doc->CreateElem(tag, nsnull, kNameSpaceID_XHTML, PR_FALSE, aContent);
} }

Просмотреть файл

@ -358,15 +358,15 @@ nsContentDLF::CreateBlankDocument(nsILoadGroup *aLoadGroup,
nsCOMPtr<nsINodeInfo> htmlNodeInfo; nsCOMPtr<nsINodeInfo> htmlNodeInfo;
// generate an html html element // 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); nsCOMPtr<nsIContent> htmlElement = NS_NewHTMLHtmlElement(htmlNodeInfo);
// generate an html head element // 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); nsCOMPtr<nsIContent> headElement = NS_NewHTMLHeadElement(htmlNodeInfo);
// generate an html body element // 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); nsCOMPtr<nsIContent> bodyElement = NS_NewHTMLBodyElement(htmlNodeInfo);
// blat in the structure // blat in the structure

Просмотреть файл

@ -1026,7 +1026,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsINodeInfo> nodeInfo; 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 // create button which drops the list down
NS_NewHTMLElement(getter_AddRefs(mButtonContent), nodeInfo, PR_FALSE); NS_NewHTMLElement(getter_AddRefs(mButtonContent), nodeInfo, PR_FALSE);

Просмотреть файл

@ -155,7 +155,7 @@ nsFileControlFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
nsCOMPtr<nsINodeInfo> nodeInfo; nsCOMPtr<nsINodeInfo> nodeInfo;
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::input, nsnull, nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::input, nsnull,
kNameSpaceID_None); kNameSpaceID_XHTML);
// Create the text content // Create the text content
NS_NewHTMLElement(getter_AddRefs(mTextContent), nodeInfo, PR_FALSE); NS_NewHTMLElement(getter_AddRefs(mTextContent), nodeInfo, PR_FALSE);

Просмотреть файл

@ -193,7 +193,7 @@ nsIsIndexFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
// Create an hr // Create an hr
nsCOMPtr<nsINodeInfo> hrInfo; 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); NS_NewHTMLElement(getter_AddRefs(mPreHr), hrInfo, PR_FALSE);
if (!mPreHr || !aElements.AppendElement(mPreHr)) if (!mPreHr || !aElements.AppendElement(mPreHr))
@ -211,7 +211,7 @@ nsIsIndexFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
// Create text input field // Create text input field
nsCOMPtr<nsINodeInfo> inputInfo; 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); NS_NewHTMLElement(getter_AddRefs(mInputContent), inputInfo, PR_FALSE);
if (!mInputContent) if (!mInputContent)

Просмотреть файл

@ -2967,21 +2967,10 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays()
// might kill us... // might kill us...
nsCOMPtr<nsIPluginInstanceOwner> kungFuDeathGrip(this); nsCOMPtr<nsIPluginInstanceOwner> kungFuDeathGrip(this);
if (ni->NamespaceEquals(kNameSpaceID_XHTML)) { NS_NAMED_LITERAL_STRING(xhtml_ns, "http://www.w3.org/1999/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"),
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"),
getter_AddRefs(allParams)); getter_AddRefs(allParams));
}
if (allParams) { if (allParams) {
PRUint32 numAllParams; PRUint32 numAllParams;
@ -3072,7 +3061,7 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays()
// (see the AddAttributes functions in the HTML and XML content sinks). // (see the AddAttributes functions in the HTML and XML content sinks).
PRInt16 start, end, increment; PRInt16 start, end, increment;
if (mContent->IsNodeOfType(nsINode::eHTML) && if (mContent->IsNodeOfType(nsINode::eHTML) &&
mContent->NodeInfo()->NamespaceEquals(kNameSpaceID_None)) { mContent->IsInHTMLDocument()) {
// HTML. Walk attributes in reverse order. // HTML. Walk attributes in reverse order.
start = numRealAttrs - 1; start = numRealAttrs - 1;
end = -1; end = -1;

Просмотреть файл

@ -897,16 +897,11 @@ RuleProcessorData::RuleProcessorData(nsPresContext* aPresContext,
// see if there are attributes for the content // see if there are attributes for the content
mHasAttributes = aContent->GetAttrCount() > 0; mHasAttributes = aContent->GetAttrCount() > 0;
// get the namespace
mNameSpaceID = aContent->GetNameSpaceID();
// check for HTMLContent and Link status // check for HTMLContent and Link status
if (aContent->IsNodeOfType(nsINode::eHTML)) { mIsHTMLContent = (mNameSpaceID == kNameSpaceID_XHTML);
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();
}
// if HTML content and it has some attributes, check for an HTML link // 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) // NOTE: optimization: cannot be a link if no attributes (since it needs an href)
@ -995,14 +990,6 @@ const nsString* RuleProcessorData::GetLang()
return mLanguage; return mLanguage;
} }
static inline PRInt32
CSSNameSpaceID(nsIContent *aContent)
{
return aContent->IsNodeOfType(nsINode::eHTML)
? kNameSpaceID_XHTML
: aContent->GetNameSpaceID();
}
PRInt32 PRInt32
RuleProcessorData::GetNthIndex(PRBool aIsOfType, PRBool aIsFromEnd, RuleProcessorData::GetNthIndex(PRBool aIsOfType, PRBool aIsFromEnd,
PRBool aCheckEdgeOnly) PRBool aCheckEdgeOnly)
@ -1061,7 +1048,7 @@ RuleProcessorData::GetNthIndex(PRBool aIsOfType, PRBool aIsFromEnd,
if (child->IsNodeOfType(nsINode::eELEMENT) && if (child->IsNodeOfType(nsINode::eELEMENT) &&
(!aIsOfType || (!aIsOfType ||
(child->Tag() == mContentTag && (child->Tag() == mContentTag &&
CSSNameSpaceID(child) == mNameSpaceID))) { child->GetNameSpaceID() == mNameSpaceID))) {
if (aCheckEdgeOnly) { if (aCheckEdgeOnly) {
// The caller only cares whether or not the result is 1, and we // The caller only cares whether or not the result is 1, and we
// now know it's not. // now know it's not.
@ -1570,8 +1557,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
stateToCheck = NS_EVENT_STATE_INDETERMINATE; stateToCheck = NS_EVENT_STATE_INDETERMINATE;
} }
else if (nsCSSPseudoClasses::mozIsHTML == pseudoClass->mAtom) { else if (nsCSSPseudoClasses::mozIsHTML == pseudoClass->mAtom) {
result = data.mIsHTMLContent && result = data.mIsHTMLContent && data.mContent->IsInHTMLDocument();
data.mContent->GetNameSpaceID() == kNameSpaceID_None;
} }
#ifdef MOZ_MATHML #ifdef MOZ_MATHML
else if (nsCSSPseudoClasses::mozMathIncrementScriptLevel == pseudoClass->mAtom) { else if (nsCSSPseudoClasses::mozMathIncrementScriptLevel == pseudoClass->mAtom) {

Просмотреть файл

@ -209,7 +209,7 @@ baseView = {
return true; return true;
}, },
onClickDisplay: function(event) { onClickDisplay: function(event) {
if (event.target.localName != 'INPUT') { if (event.target.localName != 'input') {
return false; return false;
} }
var handler = function() {return function(){view.setTierDisplay(event.target)}}; var handler = function() {return function(){view.setTierDisplay(event.target)}};