зеркало из https://github.com/mozilla/gecko-dev.git
Bug 185498: Don't rely on ::CreateElement to create html elements. Also make sure we insert html-<tbody>s when appropriate
r=Pike sr=peterv
This commit is contained in:
Родитель
5c3659f0e2
Коммит
c5865cbcc9
|
@ -64,6 +64,7 @@
|
||||||
#include "nsINameSpaceManager.h"
|
#include "nsINameSpaceManager.h"
|
||||||
#include "nsICSSStyleSheet.h"
|
#include "nsICSSStyleSheet.h"
|
||||||
#include "txStringUtils.h"
|
#include "txStringUtils.h"
|
||||||
|
#include "nsIHTMLDocument.h"
|
||||||
|
|
||||||
extern nsINameSpaceManager* gTxNameSpaceManager;
|
extern nsINameSpaceManager* gTxNameSpaceManager;
|
||||||
|
|
||||||
|
@ -354,8 +355,17 @@ void txMozillaXMLOutput::startElement(const nsAString& aName,
|
||||||
mDontAddCurrent = PR_FALSE;
|
mDontAddCurrent = PR_FALSE;
|
||||||
|
|
||||||
if ((mOutputFormat.mMethod == eHTMLOutput) && (aNsID == kNameSpaceID_None)) {
|
if ((mOutputFormat.mMethod == eHTMLOutput) && (aNsID == kNameSpaceID_None)) {
|
||||||
rv = mDocument->CreateElement(aName,
|
if (mDocumentIsHTML) {
|
||||||
getter_AddRefs(element));
|
rv = mDocument->CreateElement(aName,
|
||||||
|
getter_AddRefs(element));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nsAutoString lcname;
|
||||||
|
ToLowerCase(aName, lcname);
|
||||||
|
rv = mDocument->CreateElementNS(NS_LITERAL_STRING(kXHTMLNameSpaceURI),
|
||||||
|
lcname,
|
||||||
|
getter_AddRefs(element));
|
||||||
|
}
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -539,9 +549,15 @@ void txMozillaXMLOutput::endHTMLElement(nsIDOMElement* aElement,
|
||||||
// If no section, wrap table's children in a tbody.
|
// If no section, wrap table's children in a tbody.
|
||||||
nsCOMPtr<nsIDOMElement> wrapper;
|
nsCOMPtr<nsIDOMElement> wrapper;
|
||||||
|
|
||||||
rv = mDocument->CreateElementNS(NS_LITERAL_STRING(kXHTMLNameSpaceURI),
|
if (mDocumentIsHTML) {
|
||||||
NS_LITERAL_STRING("tbody"),
|
rv = mDocument->CreateElement(NS_LITERAL_STRING("tbody"),
|
||||||
getter_AddRefs(wrapper));
|
getter_AddRefs(wrapper));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rv = mDocument->CreateElementNS(NS_LITERAL_STRING(kXHTMLNameSpaceURI),
|
||||||
|
NS_LITERAL_STRING("tbody"),
|
||||||
|
getter_AddRefs(wrapper));
|
||||||
|
}
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't create tbody element");
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't create tbody element");
|
||||||
|
|
||||||
if (wrapper) {
|
if (wrapper) {
|
||||||
|
@ -671,18 +687,25 @@ txMozillaXMLOutput::createResultDocument(const nsAString& aName, PRInt32 aNsID,
|
||||||
if (mOutputFormat.mMethod == eHTMLOutput) {
|
if (mOutputFormat.mMethod == eHTMLOutput) {
|
||||||
doc = do_CreateInstance(kHTMLDocumentCID, &rv);
|
doc = do_CreateInstance(kHTMLDocumentCID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
mDocumentIsHTML = PR_TRUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// We should check the root name/namespace here and create the
|
// We should check the root name/namespace here and create the
|
||||||
// appropriate document
|
// appropriate document
|
||||||
doc = do_CreateInstance(kXMLDocumentCID, &rv);
|
doc = do_CreateInstance(kXMLDocumentCID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
mDocumentIsHTML = PR_FALSE;
|
||||||
}
|
}
|
||||||
mDocument = do_QueryInterface(doc);
|
mDocument = do_QueryInterface(doc);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mDocument = aResultDocument;
|
mDocument = aResultDocument;
|
||||||
doc = do_QueryInterface(aResultDocument);
|
doc = do_QueryInterface(aResultDocument);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(aResultDocument);
|
||||||
|
mDocumentIsHTML = !!htmlDoc;
|
||||||
}
|
}
|
||||||
mCurrentNode = mDocument;
|
mCurrentNode = mDocument;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче