More comprehensive fix for HTML nodes in XHTML namespace (bug 468708)

This commit is contained in:
Henri Sivonen 2009-03-20 16:58:37 +02:00
Родитель aeb7393726
Коммит 0f8172224f
14 изменённых файлов: 40 добавлений и 53 удалений

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

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

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

@ -319,7 +319,8 @@ nsHTMLStyleElement::GetStyleSheetURL(PRBool* aIsInline,
if (*aIsInline) {
return;
}
if (mNodeInfo->NamespaceEquals(kNameSpaceID_XHTML)) {
if (GetOwnerDoc() && // XXX clean up after bug 335998 lands
!(GetOwnerDoc()->IsCaseSensitive())) {
// We stopped supporting <style src="..."> for XHTML as it is
// non-standard.
*aIsInline = PR_TRUE;

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

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

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

@ -419,7 +419,7 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
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]) {
@ -433,7 +433,7 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode)
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);
@ -521,7 +521,7 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
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]) {
@ -532,7 +532,7 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode)
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);
}
@ -1011,7 +1011,7 @@ nsHTMLParanoidFragmentSink::NameFromNode(const nsIParserNode& aNode,
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());

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

@ -631,7 +631,7 @@ nsImageDocument::CreateSyntheticDocument()
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);

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

@ -234,7 +234,7 @@ nsMediaDocument::CreateSyntheticDocument()
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);
@ -247,7 +247,7 @@ nsMediaDocument::CreateSyntheticDocument()
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
@ -259,7 +259,7 @@ nsMediaDocument::CreateSyntheticDocument()
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);

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

@ -108,7 +108,7 @@ nsVideoDocument::CreateSyntheticVideoDocument(nsIChannel* aChannel,
// 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 =

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

@ -453,11 +453,10 @@ txMozillaXMLOutput::startElement(nsIAtom* aPrefix, nsIAtom* aLocalName,
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
@ -465,11 +464,11 @@ 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);
@ -483,22 +482,21 @@ txMozillaXMLOutput::startElement(nsIAtom* aPrefix,
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;
@ -539,12 +537,12 @@ txMozillaXMLOutput::startElementInternal(nsIAtom* aPrefix,
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);

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

@ -121,7 +121,7 @@ private:
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

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

@ -93,7 +93,7 @@ txUnknownHandler::startElement(nsIAtom* aPrefix, nsIAtom* aLocalName,
aLowercaseLocalName = owner;
}
PRBool htmlRoot = aNsID == kNameSpaceID_None && !aPrefix &&
PRBool htmlRoot = aNsID == kNameSpaceID_XHTML && !aPrefix &&
aLowercaseLocalName == txHTMLAtoms::html;
// Use aLocalName and not aLowercaseLocalName in case the output

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

@ -361,15 +361,15 @@ nsContentDLF::CreateBlankDocument(nsILoadGroup *aLoadGroup,
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

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

@ -3057,21 +3057,10 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays()
// 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");
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"),
mydomElement->GetElementsByTagNameNS(xhtml_ns, NS_LITERAL_STRING("param"),
getter_AddRefs(allParams));
}
if (allParams) {
PRUint32 numAllParams;
@ -3162,7 +3151,8 @@ nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays()
// (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->GetOwnerDoc() && // XXX clean up after bug 335998 lands
!(mContent->GetOwnerDoc()->IsCaseSensitive())) {
// HTML. Walk attributes in reverse order.
start = numRealAttrs - 1;
end = -1;

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

@ -291,7 +291,7 @@ int main(int argc, char** argv)
nsIAtom* li = NS_NewAtom("li");
nsCOMPtr<nsINodeInfo> ni;
myDoc->NodeInfoManager()->GetNodeInfo(li, nsnull, kNameSpaceID_None,
myDoc->NodeInfoManager()->GetNodeInfo(li, nsnull, kNameSpaceID_XHTML,
getter_AddRefs(ni));
rv = NS_NewHTMLLIElement(&container,ni);

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

@ -900,13 +900,10 @@ RuleProcessorData::RuleProcessorData(nsPresContext* aPresContext,
// 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();
}
// get the namespace
mNameSpaceID = aContent->GetNameSpaceID();
// 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)
@ -1571,7 +1568,8 @@ static PRBool SelectorMatches(RuleProcessorData &data,
}
else if (nsCSSPseudoClasses::mozIsHTML == pseudoClass->mAtom) {
result = data.mIsHTMLContent &&
data.mContent->GetNameSpaceID() == kNameSpaceID_None;
data.mContent->GetOwnerDoc() && // XXX clean up after bug 335998 lands
!(data.mContent->GetOwnerDoc()->IsCaseSensitive());
}
#ifdef MOZ_MATHML
else if (nsCSSPseudoClasses::mozMathIncrementScriptLevel == pseudoClass->mAtom) {