Bug 64945: XML Prettyprinting stage 1

r=peterv sr=jst
This commit is contained in:
sicking%bigfoot.com 2002-09-04 06:57:25 +00:00
Родитель b418a7c2ff
Коммит 7aaa7b5df0
22 изменённых файлов: 904 добавлений и 309 удалений

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

@ -238,6 +238,9 @@ sub InstallNonChromeResources()
my($html_dir) = "$resource_dir" . "html:";
InstallResources(":mozilla:layout:html:base:src:MANIFEST_RES", "$html_dir");
my($xml_dir) = "$resource_dir" . "xml:";
InstallResources(":mozilla:content:xml:document:resources:MANIFEST_RES", "$xml_dir");
my($throbber_dir) = "$resource_dir" . "throbber:";
BuildFolderResourceAliases(":mozilla:webshell:tests:viewer:throbber:", "$throbber_dir");

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

@ -186,6 +186,10 @@ public:
static void GetDocShellFromCaller(nsIDocShell** aDocShell);
// Check if a node is in the document prolog, i.e. before the document
// element.
static PRBool InProlog(nsIDOMNode *aNode);
private:
static nsresult doReparentContentWrapper(nsIContent *aChild,
nsIDocument *aNewDocument,

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

@ -102,6 +102,9 @@ public:
NS_IMETHOD GetElementFactory(PRInt32 aNameSpaceID,
nsIElementFactory **aElementFactory) = 0;
NS_IMETHOD HasRegisteredFactory(PRInt32 aNameSpaceID,
PRBool* aHasFactory) = 0;
};
nsresult

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

@ -591,6 +591,46 @@ nsContentUtils::CanCallerAccess(nsIDOMNode *aNode)
return NS_SUCCEEDED(rv);
}
//static
PRBool
nsContentUtils::InProlog(nsIDOMNode *aNode)
{
NS_PRECONDITION(aNode, "missing node to nsContentUtils::InProlog");
// Check that there is an ancestor and that it is a document
nsCOMPtr<nsIDOMNode> parent;
aNode->GetParentNode(getter_AddRefs(parent));
if (!parent) {
return PR_FALSE;
}
PRUint16 type;
parent->GetNodeType(&type);
if (type != nsIDOMNode::DOCUMENT_NODE) {
return PR_FALSE;
}
nsCOMPtr<nsIDocument> doc = do_QueryInterface(parent);
NS_ASSERTION(doc, "document doesn't implement nsIDocument");
nsCOMPtr<nsIContent> cont = do_QueryInterface(aNode);
NS_ASSERTION(cont, "node doesn't implement nsIContent");
// Check that there are no elements before aNode to make sure we are not
// in the epilog
PRInt32 pos, i;
doc->IndexOf(cont, pos);
while (pos > 0) {
--pos;
nsCOMPtr<nsIContent> sibl;
doc->ChildAt(pos, *getter_AddRefs(sibl));
if (sibl->IsContentOfType(nsIContent::eELEMENT)) {
return PR_FALSE;
}
}
return PR_TRUE;
}
// static
nsresult
nsContentUtils::doReparentContentWrapper(nsIContent *aChild,

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

@ -66,6 +66,7 @@ static PRBool gNameSpaceManagerIsInitialized = PR_FALSE;
static nsHashtable* gURIToIDTable;
static nsVoidArray* gURIArray;
static nsISupportsArray* gElementFactoryArray;
static nsIElementFactory* gDefaultElementFactory;
#ifdef NS_DEBUG
static PRBool gNameSpaceManagerWasShutDown = PR_FALSE;
@ -116,6 +117,7 @@ static void InitializeNameSpaceManager()
gURIToIDTable->Put(&mathmlKey, NS_INT32_TO_PTR(kNameSpaceID_MathML));
NS_NewISupportsArray(&gElementFactoryArray);
NS_NewXMLElementFactory(&gDefaultElementFactory);
NS_ASSERTION(gURIToIDTable, "no URI table");
NS_ASSERTION(gURIArray, "no URI array");
@ -137,6 +139,7 @@ void NS_NameSpaceManagerShutdown()
gURIArray = nsnull;
NS_IF_RELEASE(gElementFactoryArray);
NS_IF_RELEASE(gDefaultElementFactory);
#ifdef NS_DEBUG
gNameSpaceManagerWasShutDown = PR_TRUE;
@ -393,6 +396,8 @@ public:
PRInt32& aNameSpaceID);
NS_IMETHOD GetElementFactory(PRInt32 aNameSpaceID,
nsIElementFactory **aElementFactory);
NS_IMETHOD HasRegisteredFactory(PRInt32 aNameSpaceID,
PRBool* aHasFactory);
private:
// These are not supported and are not implemented!
NameSpaceManagerImpl(const NameSpaceManagerImpl& aCopy);
@ -530,11 +535,7 @@ NameSpaceManagerImpl::GetElementFactory(PRInt32 aNameSpaceID,
}
if (!ef) {
nsresult rv = NS_NewXMLElementFactory(getter_AddRefs(ef));
if (NS_FAILED(rv)) {
return rv;
}
ef = gDefaultElementFactory;
}
PRUint32 count = 0;
@ -560,6 +561,18 @@ NameSpaceManagerImpl::GetElementFactory(PRInt32 aNameSpaceID,
return NS_OK;
}
NS_IMETHODIMP
NameSpaceManagerImpl::HasRegisteredFactory(PRInt32 aNameSpaceID,
PRBool* aHasFactory)
{
*aHasFactory = PR_FALSE;
nsCOMPtr<nsIElementFactory> ef;
GetElementFactory(aNameSpaceID, getter_AddRefs(ef));
NS_ENSURE_TRUE(gDefaultElementFactory, NS_ERROR_FAILURE);
*aHasFactory = ef != gDefaultElementFactory;
return NS_OK;
}
nsresult
NS_NewNameSpaceManager(nsINameSpaceManager** aInstancePtrResult)
{

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

@ -211,6 +211,8 @@ LAYOUT_ATOM(Korean, "ko")
// other
LAYOUT_ATOM(wildcard, "*")
LAYOUT_ATOM(mozdirty, "_moz_dirty")
LAYOUT_ATOM(stylesheet, "stylesheet")
LAYOUT_ATOM(transform, "transform")
#ifdef IBMBIDI
LAYOUT_ATOM(directionalFrame, "DirectionalFrame")

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

@ -87,6 +87,7 @@ nsXBLContentSink::nsXBLContentSink()
mProperty = nsnull;
mMethod = nsnull;
mField = nsnull;
mPrettyPrintXML = PR_FALSE;
}
nsXBLContentSink::~nsXBLContentSink()

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

@ -102,6 +102,10 @@ NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult,
const nsAString& aTarget,
const nsAString& aData);
extern nsresult
NS_NewXMLStylesheetProcessingInstruction(nsIContent** aInstancePtrResult,
const nsAString& aData);
extern nsresult
NS_NewXMLEntity(nsIContent** aInstancePtrResult,
const nsAString& aName,

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

@ -52,6 +52,7 @@ CPPSRCS = \
nsXMLEntity.cpp \
nsXMLNotation.cpp \
nsXMLNamedNodeMap.cpp \
nsXMLStylesheetPI.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.

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

@ -36,173 +36,20 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsIDOMProcessingInstruction.h"
#include "nsIDOMLinkStyle.h"
#include "nsIDOMStyleSheet.h"
#include "nsIDocument.h"
#include "nsIStyleSheet.h"
#include "nsIURI.h"
#include "nsGenericDOMDataNode.h"
#include "nsGenericElement.h"
#include "nsLayoutAtoms.h"
#include "nsHTMLAtoms.h"
#include "nsAString.h"
#include "nsXPIDLString.h"
#include "nsUnicharUtils.h"
#include "nsStyleLinkElement.h"
#include "nsXMLProcessingInstruction.h"
#include "nsParserUtils.h"
#include "nsNetUtil.h"
class nsXMLProcessingInstruction : public nsGenericDOMDataNode,
public nsIDOMProcessingInstruction,
public nsStyleLinkElement
{
public:
nsXMLProcessingInstruction(const nsAString& aTarget,
const nsAString& aData);
virtual ~nsXMLProcessingInstruction();
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMNode
NS_IMETHOD GetNodeName(nsAString& aNodeName);
NS_IMETHOD GetLocalName(nsAString& aLocalName) {
return nsGenericDOMDataNode::GetLocalName(aLocalName);
}
NS_IMETHOD GetNodeValue(nsAString& aNodeValue) {
return nsGenericDOMDataNode::GetNodeValue(aNodeValue);
}
NS_IMETHOD SetNodeValue(const nsAString& aNodeValue) {
nsresult rv = nsGenericDOMDataNode::SetNodeValue(aNodeValue);
if (NS_SUCCEEDED(rv)) {
UpdateStyleSheet();
}
return rv;
}
NS_IMETHOD GetNodeType(PRUint16* aNodeType);
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) {
return nsGenericDOMDataNode::GetParentNode(aParentNode);
}
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) {
return nsGenericDOMDataNode::GetChildNodes(aChildNodes);
}
NS_IMETHOD HasChildNodes(PRBool* aHasChildNodes) {
return nsGenericDOMDataNode::HasChildNodes(aHasChildNodes);
}
NS_IMETHOD HasAttributes(PRBool* aHasAttributes) {
return nsGenericDOMDataNode::HasAttributes(aHasAttributes);
}
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) {
return nsGenericDOMDataNode::GetFirstChild(aFirstChild);
}
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) {
return nsGenericDOMDataNode::GetLastChild(aLastChild);
}
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) {
return nsGenericDOMDataNode::GetPreviousSibling(aPreviousSibling);
}
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) {
return nsGenericDOMDataNode::GetNextSibling(aNextSibling);
}
NS_IMETHOD GetAttributes(nsIDOMNamedNodeMap** aAttributes) {
return nsGenericDOMDataNode::GetAttributes(aAttributes);
}
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild,
nsIDOMNode** aReturn) {
return nsGenericDOMDataNode::InsertBefore(aNewChild, aRefChild, aReturn);
}
NS_IMETHOD AppendChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) {
return nsGenericDOMDataNode::AppendChild(aOldChild, aReturn);
}
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild,
nsIDOMNode** aReturn) {
return nsGenericDOMDataNode::ReplaceChild(aNewChild, aOldChild, aReturn);
}
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn) {
return nsGenericDOMDataNode::RemoveChild(aOldChild, aReturn);
}
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) {
return nsGenericDOMDataNode::GetOwnerDocument(aOwnerDocument);
}
NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI) {
return nsGenericDOMDataNode::GetNamespaceURI(aNamespaceURI);
}
NS_IMETHOD GetPrefix(nsAString& aPrefix) {
return nsGenericDOMDataNode::GetPrefix(aPrefix);
}
NS_IMETHOD SetPrefix(const nsAString& aPrefix) {
return nsGenericDOMDataNode::SetPrefix(aPrefix);
}
NS_IMETHOD Normalize() {
return NS_OK;
}
NS_IMETHOD IsSupported(const nsAString& aFeature,
const nsAString& aVersion,
PRBool* aReturn) {
return nsGenericDOMDataNode::IsSupported(aFeature, aVersion, aReturn);
}
NS_IMETHOD GetBaseURI(nsAString& aURI) {
return nsGenericDOMDataNode::GetBaseURI(aURI);
}
NS_IMETHOD LookupNamespacePrefix(const nsAString& aNamespaceURI,
nsAString& aPrefix) {
return nsGenericDOMDataNode::LookupNamespacePrefix(aNamespaceURI, aPrefix);
}
NS_IMETHOD LookupNamespaceURI(const nsAString& aNamespacePrefix,
nsAString& aNamespaceURI) {
return nsGenericDOMDataNode::LookupNamespaceURI(aNamespacePrefix,
aNamespaceURI);
}
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
// nsIDOMProcessingInstruction
NS_DECL_NSIDOMPROCESSINGINSTRUCTION
// nsIContent
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers)
{
nsCOMPtr<nsIDocument> oldDoc = mDocument;
nsresult rv = nsGenericDOMDataNode::SetDocument(aDocument, aDeep,
aCompileEventHandlers);
if (NS_SUCCEEDED(rv)) {
UpdateStyleSheet(oldDoc);
}
return rv;
}
NS_IMETHOD GetTag(nsIAtom*& aResult) const;
#ifdef DEBUG
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
NS_IMETHOD DumpContent(FILE* out, PRInt32 aIndent, PRBool aDumpAll) const;
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
#endif
// nsStyleLinkElement
NS_IMETHOD GetCharset(nsAString& aCharset);
protected:
void GetStyleSheetURL(PRBool* aIsInline,
nsAString& aUrl);
void GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
PRBool* aIsAlternate);
PRBool GetAttrValue(const nsAString& aAttr, nsAString& aValue);
nsAutoString mTarget;
};
nsresult
NS_NewXMLProcessingInstruction(nsIContent** aInstancePtrResult,
const nsAString& aTarget,
const nsAString& aData)
{
if (aTarget.Equals(NS_LITERAL_STRING("xml-stylesheet"))) {
return NS_NewXMLStylesheetProcessingInstruction(aInstancePtrResult, aData);
}
*aInstancePtrResult = new nsXMLProcessingInstruction(aTarget, aData);
NS_ENSURE_TRUE(*aInstancePtrResult, NS_ERROR_OUT_OF_MEMORY);
@ -227,8 +74,6 @@ nsXMLProcessingInstruction::~nsXMLProcessingInstruction()
NS_INTERFACE_MAP_BEGIN(nsXMLProcessingInstruction)
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
NS_INTERFACE_MAP_ENTRY(nsIDOMProcessingInstruction)
NS_INTERFACE_MAP_ENTRY(nsIDOMLinkStyle)
NS_INTERFACE_MAP_ENTRY(nsIStyleSheetLinkingElement)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(ProcessingInstruction)
NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode)
@ -248,11 +93,7 @@ nsXMLProcessingInstruction::GetTarget(nsAString& aTarget)
NS_IMETHODIMP
nsXMLProcessingInstruction::SetData(const nsAString& aData)
{
nsresult rv = nsGenericDOMDataNode::SetData(aData);
if (NS_SUCCEEDED(rv)) {
UpdateStyleSheet();
}
return rv;
return SetNodeValue(aData);
}
NS_IMETHODIMP
@ -348,126 +189,3 @@ nsXMLProcessingInstruction::SizeOf(nsISizeOfHandler* aSizer,
return NS_OK;
}
#endif
static PRBool InProlog(nsIDOMNode *aThis)
{
// Check that there are no ancestor elements
// Typically this should loop once
nsCOMPtr<nsIDOMNode> current = aThis;
for(;;) {
nsCOMPtr<nsIDOMNode> parent;
current->GetParentNode(getter_AddRefs(parent));
if (!parent)
break;
PRUint16 type;
parent->GetNodeType(&type);
if (type == nsIDOMNode::ELEMENT_NODE)
return PR_FALSE;
current = parent;
}
// Check that there are no elements before
// Makes sure we are not in epilog
current = aThis;
for(;;) {
nsCOMPtr<nsIDOMNode> prev;
current->GetPreviousSibling(getter_AddRefs(prev));
if (!prev)
break;
PRUint16 type;
prev->GetNodeType(&type);
if (type == nsIDOMNode::ELEMENT_NODE)
return PR_FALSE;
current = prev;
}
return PR_TRUE;
}
NS_IMETHODIMP
nsXMLProcessingInstruction::GetCharset(nsAString& aCharset)
{
if (!GetAttrValue(NS_LITERAL_STRING("charset"), aCharset)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
void
nsXMLProcessingInstruction::GetStyleSheetURL(PRBool* aIsInline,
nsAString& aUrl)
{
*aIsInline = PR_FALSE;
aUrl.Truncate();
nsAutoString href;
GetAttrValue(NS_LITERAL_STRING("href"), href);
if (href.IsEmpty()) {
return;
}
nsCOMPtr<nsIURI> url, baseURL;
if (mDocument) {
mDocument->GetBaseURL(*getter_AddRefs(baseURL));
}
NS_MakeAbsoluteURI(aUrl, href, baseURL);
}
void
nsXMLProcessingInstruction::GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
PRBool* aIsAlternate)
{
aTitle.Truncate();
aType.Truncate();
aMedia.Truncate();
*aIsAlternate = PR_FALSE;
if (!mTarget.Equals(NS_LITERAL_STRING("xml-stylesheet"))) {
return;
}
// xml-stylesheet PI is special only in prolog
if (!InProlog(this)) {
return;
}
nsAutoString title, type, media, alternate;
GetAttrValue(NS_LITERAL_STRING("title"), title);
title.CompressWhitespace();
aTitle.Assign(title);
GetAttrValue(NS_LITERAL_STRING("alternate"), alternate);
// if alternate, does it have title?
if (alternate.Equals(NS_LITERAL_STRING("yes"))) {
if (aTitle.IsEmpty()) { // alternates must have title
return;
} else {
*aIsAlternate = PR_TRUE;
}
}
GetAttrValue(NS_LITERAL_STRING("media"), media);
aMedia.Assign(media);
ToLowerCase(aMedia); // case sensitivity?
GetAttrValue(NS_LITERAL_STRING("type"), type);
nsAutoString mimeType;
nsAutoString notUsed;
nsParserUtils::SplitMimeType(type, mimeType, notUsed);
if (!mimeType.IsEmpty() && !mimeType.EqualsIgnoreCase("text/css")) {
aType.Assign(type);
return;
}
// If we get here we assume that we're loading a css file, so set the
// type to 'text/css'
aType.Assign(NS_LITERAL_STRING("text/css"));
return;
}

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

@ -0,0 +1,81 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonas Sicking (original author)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIXMLProcessingInstruction_h___
#define nsIXMLProcessingInstruction_h___
#include "nsIDOMProcessingInstruction.h"
#include "nsIDocument.h"
#include "nsGenericDOMDataNode.h"
#include "nsAString.h"
class nsXMLProcessingInstruction : public nsGenericDOMDataNode,
public nsIDOMProcessingInstruction
{
public:
nsXMLProcessingInstruction(const nsAString& aTarget,
const nsAString& aData);
virtual ~nsXMLProcessingInstruction();
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMNode
NS_IMPL_NSIDOMNODE_USING_GENERIC_DOM_DATA
// nsIDOMProcessingInstruction
NS_DECL_NSIDOMPROCESSINGINSTRUCTION
// nsIContent
NS_IMETHOD GetTag(nsIAtom*& aResult) const;
#ifdef DEBUG
NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;
NS_IMETHOD DumpContent(FILE* out, PRInt32 aIndent, PRBool aDumpAll) const;
NS_IMETHOD SizeOf(nsISizeOfHandler* aSizer, PRUint32* aResult) const;
#endif
protected:
PRBool GetAttrValue(const nsAString& aAttr, nsAString& aValue);
nsAutoString mTarget;
};
#endif //nsIXMLProcessingInstruction_h___

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

@ -0,0 +1,244 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonas Sicking (original author)
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIDOMLinkStyle.h"
#include "nsIDOMStyleSheet.h"
#include "nsIDocument.h"
#include "nsIStyleSheet.h"
#include "nsIURI.h"
#include "nsStyleLinkElement.h"
#include "nsNetUtil.h"
#include "nsXMLProcessingInstruction.h"
#include "nsUnicharUtils.h"
#include "nsParserUtils.h"
class nsXMLStylesheetPI : public nsXMLProcessingInstruction,
public nsStyleLinkElement
{
public:
nsXMLStylesheetPI(const nsAString& aData);
virtual ~nsXMLStylesheetPI();
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsIDOMNode
NS_IMETHOD SetNodeValue(const nsAString& aData);
NS_IMETHOD CloneNode(PRBool aDeep, nsIDOMNode** aReturn);
// nsIContent
NS_IMETHOD SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers);
// nsStyleLinkElement
NS_IMETHOD GetCharset(nsAString& aCharset);
protected:
void GetStyleSheetURL(PRBool* aIsInline,
nsAString& aUrl);
void GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
PRBool* aIsAlternate);
};
// nsISupports implementation
NS_INTERFACE_MAP_BEGIN(nsXMLStylesheetPI)
NS_INTERFACE_MAP_ENTRY(nsIDOMLinkStyle)
NS_INTERFACE_MAP_ENTRY(nsIStyleSheetLinkingElement)
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(XMLStylesheetProcessingInstruction)
NS_INTERFACE_MAP_END_INHERITING(nsXMLProcessingInstruction)
NS_IMPL_ADDREF_INHERITED(nsXMLStylesheetPI, nsXMLProcessingInstruction)
NS_IMPL_RELEASE_INHERITED(nsXMLStylesheetPI, nsXMLProcessingInstruction)
nsXMLStylesheetPI::nsXMLStylesheetPI(const nsAString& aData) :
nsXMLProcessingInstruction(NS_LITERAL_STRING("xml-stylesheet"), aData)
{
}
nsXMLStylesheetPI::~nsXMLStylesheetPI()
{
}
// nsIContent
NS_IMETHODIMP
nsXMLStylesheetPI::SetDocument(nsIDocument* aDocument, PRBool aDeep,
PRBool aCompileEventHandlers)
{
nsCOMPtr<nsIDocument> oldDoc = mDocument;
nsresult rv = nsXMLProcessingInstruction::SetDocument(aDocument, aDeep,
aCompileEventHandlers);
if (NS_SUCCEEDED(rv)) {
UpdateStyleSheet(oldDoc);
}
return rv;
}
// nsIDOMNode
NS_IMETHODIMP
nsXMLStylesheetPI::SetNodeValue(const nsAString& aNodeValue)
{
nsresult rv = nsGenericDOMDataNode::SetNodeValue(aNodeValue);
if (NS_SUCCEEDED(rv)) {
UpdateStyleSheet();
}
return rv;
}
NS_IMETHODIMP
nsXMLStylesheetPI::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
{
nsAutoString data;
GetData(data);
*aReturn = new nsXMLStylesheetPI(data);
if (!*aReturn) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(*aReturn);
return NS_OK;
}
// nsStyleLinkElement
NS_IMETHODIMP
nsXMLStylesheetPI::GetCharset(nsAString& aCharset)
{
if (!GetAttrValue(NS_LITERAL_STRING("charset"), aCharset)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
void
nsXMLStylesheetPI::GetStyleSheetURL(PRBool* aIsInline,
nsAString& aUrl)
{
*aIsInline = PR_FALSE;
aUrl.Truncate();
nsAutoString href;
GetAttrValue(NS_LITERAL_STRING("href"), href);
if (href.IsEmpty()) {
return;
}
nsCOMPtr<nsIURI> url, baseURL;
if (mDocument) {
mDocument->GetBaseURL(*getter_AddRefs(baseURL));
}
NS_MakeAbsoluteURI(aUrl, href, baseURL);
}
void
nsXMLStylesheetPI::GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
PRBool* aIsAlternate)
{
aTitle.Truncate();
aType.Truncate();
aMedia.Truncate();
*aIsAlternate = PR_FALSE;
// xml-stylesheet PI is special only in prolog
if (!nsContentUtils::InProlog(this)) {
return;
}
nsAutoString title, type, media, alternate;
GetAttrValue(NS_LITERAL_STRING("title"), title);
title.CompressWhitespace();
aTitle.Assign(title);
GetAttrValue(NS_LITERAL_STRING("alternate"), alternate);
// if alternate, does it have title?
if (alternate.Equals(NS_LITERAL_STRING("yes"))) {
if (aTitle.IsEmpty()) { // alternates must have title
return;
} else {
*aIsAlternate = PR_TRUE;
}
}
GetAttrValue(NS_LITERAL_STRING("media"), media);
aMedia.Assign(media);
ToLowerCase(aMedia); // case sensitivity?
GetAttrValue(NS_LITERAL_STRING("type"), type);
nsAutoString mimeType;
nsAutoString notUsed;
nsParserUtils::SplitMimeType(type, mimeType, notUsed);
if (!mimeType.IsEmpty() && !mimeType.EqualsIgnoreCase("text/css")) {
aType.Assign(type);
return;
}
// If we get here we assume that we're loading a css file, so set the
// type to 'text/css'
aType.Assign(NS_LITERAL_STRING("text/css"));
return;
}
nsresult
NS_NewXMLStylesheetProcessingInstruction(nsIContent** aInstancePtrResult,
const nsAString& aData)
{
*aInstancePtrResult = new nsXMLStylesheetPI(aData);
if (!*aInstancePtrResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aInstancePtrResult);
return NS_OK;
}

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

@ -26,7 +26,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src
DIRS = public resources src
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,7 @@
#
# This is a list of local files which get copied to the mozilla:dist:bin:res:xml
#
XMLPrettyPrint.bmp
XMLPrettyPrint.css
XMLPrettyPrint.xsl

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

@ -0,0 +1,41 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
EXPORT_RESOURCE_CONTENT = \
$(srcdir)/XMLPrettyPrint.xsl \
$(srcdir)/XMLPrettyPrint.xml \
$(srcdir)/XMLPrettyPrint.bmp \
$(srcdir)/XMLPrettyPrint.css \
$(NULL)
libs::
$(INSTALL) $(EXPORT_RESOURCE_CONTENT) $(DIST)/bin/res/xml
install::
$(SYSINSTALL) $(IFLAGS1) $(EXPORT_RESOURCE_CONTENT) $(DESTDIR)$(mozappdir)/res/xml

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

@ -0,0 +1,119 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonas Sicking <sicking@bigfoot.com> (Original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* 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 ***** */
body {
font-family: 'Verdana', sans-serif;
width: 100%;
margin: 0;
padding: 0;
}
html {
width: 100%;
margin: 0;
padding: 0;
}
#header {
background-color: #ccc;
border-bottom: 3px solid black;
padding: 0.5em;
margin-bottom: 1em;
}
img {
float: left;
margin: 0.5em;
}
table {
border-spacing: 0;
margin: 0;
}
td {
padding: 0;
}
.markup {
color: blue
}
.elemname {
color: red;
}
.attrname {
color: #f88;
}
.attrvalue {
color: black;
}
.text {
color: black;
font-weight: bold;
}
.indent {
margin-left: 1em;
}
.comment {
color: green;
font-style: italic;
}
.pi {
color: blue;
}
.expander > div {
width: 1em;
}
.expander {
cursor: default;
-moz-user-select: none;
vertical-align: top;
text-align: center;
}
.expander-closed .expander-content {
display: none;
}

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

@ -0,0 +1,178 @@
<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is mozilla.org code.
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation.
- Portions created by the Initial Developer are Copyright (C) 2002
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Jonas Sicking <sicking@bigfoot.com> (Original author)
-
- Alternatively, the contents of this file may be used under the terms of
- either the GNU General Public License Version 2 or later (the "GPL"), or
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- in which case the provisions of the GPL or the LGPL are applicable instead
- of those above. If you wish to allow use of your version of this file only
- under the terms of either the GPL or the LGPL, and not to allow others to
- use your version of this file under the terms of the MPL, indicate your
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the LGPL or the GPL. If you do not delete
- 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 ***** -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" href="resource:///res/xml/XMLPrettyPrint.css"/>
<script><![CDATA[
function clicked(event) {
try {
var par = event.target.parentNode;
if (par.nodeName == 'td' && par.className == 'expander') {
if (par.parentNode.className == 'expander-closed') {
par.parentNode.className = '';
event.target.data = '-';
}
else {
par.parentNode.className = 'expander-closed';
event.target.data = '+';
}
}
} catch (e) {
}
}
]]></script>
</head>
<body onclick="clicked(event)">
<div id="header">
<p>
This XML file does not appear to have any style information
associated with it. The document tree is shown below.
</p>
</div>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="*">
<div class="indent">
<span class="markup">&lt;</span>
<span class="elemname"><xsl:value-of select="name(.)"/></span>
<xsl:apply-templates select="@*"/>
<span class="markup">/&gt;</span>
</div>
</xsl:template>
<xsl:template match="*[node()]">
<div class="indent">
<span class="markup">&lt;</span>
<span class="elemname"><xsl:value-of select="name(.)"/></span>
<xsl:apply-templates select="@*"/>
<span class="markup">&gt;</span>
<span class="text"><xsl:value-of select="."/></span>
<span class="markup">&lt;/</span>
<span class="elemname"><xsl:value-of select="name(.)"/></span>
<span class="markup">&gt;</span>
</div>
</xsl:template>
<xsl:template match="*[* or processing-instruction() or comment() or string-length(.) &gt; 50]">
<table>
<tr>
<td class="expander">-<div/></td>
<td>
<span class="markup">&lt;</span>
<span class="elemname"><xsl:value-of select="name(.)"/></span>
<xsl:apply-templates select="@*"/>
<span class="markup">&gt;</span>
<div class="expander-content"><xsl:apply-templates/></div>
<span class="markup">&lt;/</span>
<span class="elemname"><xsl:value-of select="name(.)"/></span>
<span class="markup">&gt;</span>
</td>
</tr>
</table>
</xsl:template>
<xsl:template match="@*">
<xsl:text> </xsl:text>
<span class="attrname"><xsl:value-of select="name(.)"/></span>
<span class="markup">="</span>
<span class="attrvalue"><xsl:value-of select="."/></span>
<span class="markup">"</span>
</xsl:template>
<xsl:template match="text()">
<xsl:if test="normalize-space(.)">
<div class="indent text"><xsl:value-of select="."/></div>
</xsl:if>
</xsl:template>
<xsl:template match="processing-instruction()">
<div class="indent pi">
&lt;?<xsl:value-of select="name(.)"/>
<xsl:text> </xsl:text>
<xsl:value-of select="."/>?&gt;
</div>
</xsl:template>
<xsl:template match="processing-instruction()[string-length(.) &gt; 50]">
<table>
<tr>
<td class="expander">-<div/></td>
<td class="pi">
&lt;?<xsl:value-of select="name(.)"/>
<div class="indent expander-content"><xsl:value-of select="."/></div>
<xsl:text>?&gt;</xsl:text>
</td>
</tr>
</table>
</xsl:template>
<xsl:template match="comment()">
<div class="comment indent">
&lt;!--
<xsl:value-of select="."/>
--&gt;
</div>
</xsl:template>
<xsl:template match="comment()[string-length(.) &gt; 50]">
<table>
<tr>
<td class="expander">-<div/></td>
<td class="comment">
&lt;!--
<div class="indent expander-content"><xsl:value-of select="."/></div>
<xsl:text>--&gt;</xsl:text>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>

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

@ -107,6 +107,13 @@
#include "nsIPrincipal.h"
#include "nsIAggregatePrincipal.h"
#include "nsICodebasePrincipal.h"
#include "nsIDOMDocumentView.h"
#include "nsIDOMAbstractView.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsIDOMViewCSS.h"
#include "nsXBLAtoms.h"
#include "nsIPref.h"
#include "nsIDOMDocumentXBL.h"
// XXX misnamed header file, but oh well
#include "nsHTMLTokens.h"
@ -183,6 +190,9 @@ nsXMLContentSink::nsXMLContentSink()
mStyleSheetCount = 0;
mCSSLoader = nsnull;
mNeedToBlockParser = PR_FALSE;
mPrettyPrintXML = PR_TRUE;
mPrettyPrintHasSpecialRoot = PR_FALSE;
mPrettyPrintHasFactoredElements = PR_FALSE;
}
nsXMLContentSink::~nsXMLContentSink()
@ -234,7 +244,10 @@ nsXMLContentSink::Init(nsIDocument* aDoc,
mDocumentBaseURL = aURL;
NS_ADDREF(aURL);
mWebShell = aContainer;
NS_IF_ADDREF(aContainer);
NS_IF_ADDREF(mWebShell);
if (!mWebShell) {
mPrettyPrintXML = PR_FALSE;
}
nsCOMPtr<nsIScriptLoader> loader;
nsresult rv = mDocument->GetScriptLoader(getter_AddRefs(loader));
@ -333,9 +346,82 @@ nsXMLContentSink::ScrollToRef()
}
}
PRBool
nsXMLContentSink::ShouldPrettyPrint()
{
if (!mPrettyPrintXML || (mPrettyPrintHasFactoredElements &&
!mPrettyPrintHasSpecialRoot)) {
mPrettyPrintXML = PR_FALSE;
return PR_FALSE;
}
// Check for correct load-command or if we're in a display:none iframe
nsAutoString command;
mParser->GetCommand(command);
if (!command.Equals(NS_LITERAL_STRING("view")) ||
!mDocument->GetNumberOfShells()) {
mPrettyPrintXML = PR_FALSE;
return PR_FALSE;
}
// check if we're in an invisible iframe
nsCOMPtr<nsIScriptGlobalObject> sgo;
mDocument->GetScriptGlobalObject(getter_AddRefs(sgo));
nsCOMPtr<nsIDOMWindowInternal> internalWin = do_QueryInterface(sgo);
nsCOMPtr<nsIDOMElement> frameElem;
if (internalWin) {
internalWin->GetFrameElement(getter_AddRefs(frameElem));
}
if (frameElem) {
nsCOMPtr<nsIDOMCSSStyleDeclaration> computedStyle;
nsCOMPtr<nsIDOMDocument> frameOwnerDoc;
frameElem->GetOwnerDocument(getter_AddRefs(frameOwnerDoc));
nsCOMPtr<nsIDOMDocumentView> docView = do_QueryInterface(frameOwnerDoc);
if (docView) {
nsCOMPtr<nsIDOMAbstractView> defaultView;
docView->GetDefaultView(getter_AddRefs(defaultView));
nsCOMPtr<nsIDOMViewCSS> defaultCSSView = do_QueryInterface(defaultView);
if (defaultCSSView) {
defaultCSSView->GetComputedStyle(frameElem, NS_LITERAL_STRING(""),
getter_AddRefs(computedStyle));
}
}
if (computedStyle) {
nsAutoString visibility;
computedStyle->GetPropertyValue(NS_LITERAL_STRING("visibility"), visibility);
if (!visibility.Equals(NS_LITERAL_STRING("visible"))) {
mPrettyPrintXML = PR_FALSE;
return PR_FALSE;
}
}
}
// check the pref
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
if (prefs) {
PRBool pref = PR_FALSE;
prefs->GetBoolPref("layout.xml.prettyprint", &pref);
if (!pref) {
mPrettyPrintXML = PR_FALSE;
return PR_FALSE;
}
}
return PR_TRUE;
}
NS_IMETHODIMP
nsXMLContentSink::DidBuildModel(PRInt32 aQualityLevel)
{
nsresult rv = NS_OK;
// XXX this is silly; who cares?
PRInt32 i, ns = mDocument->GetNumberOfShells();
for (i = 0; i < ns; i++) {
@ -359,7 +445,17 @@ nsXMLContentSink::DidBuildModel(PRInt32 aQualityLevel)
mDocument->SetRootContent(mDocElement);
nsresult rv = NS_OK;
// Check if we want to prettyprint
if (ShouldPrettyPrint()) {
NS_ASSERTION(!mXSLTransformMediator, "Prettyprinting an XSLT styled document");
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri),
NS_LITERAL_STRING("resource:///res/xml/XMLPrettyPrint.xsl"));
NS_ENSURE_SUCCESS(rv, rv);
LoadXSLStyleSheet(uri);
}
if (mXSLTransformMediator) {
rv = SetupTransformMediator();
}
@ -567,18 +663,30 @@ nsresult
nsXMLContentSink::CreateElement(const PRUnichar** aAtts, PRUint32 aAttsCount, PRInt32 aNameSpaceID,
nsINodeInfo* aNodeInfo, nsIContent** aResult)
{
nsresult rv = NS_OK;
// The first step here is to see if someone has provided their
// own content element implementation (e.g., XUL or MathML).
// This is done based off a contractid/namespace scheme.
nsCOMPtr<nsIElementFactory> elementFactory;
GetElementFactory(aNameSpaceID, getter_AddRefs(elementFactory));
if (elementFactory)
gNameSpaceManager->GetElementFactory(aNameSpaceID,
getter_AddRefs(elementFactory));
if (elementFactory) {
// Create the content element using the element factory.
elementFactory->CreateInstanceByTag(aNodeInfo, aResult);
}
else {
NS_NewXMLElement(aResult, aNodeInfo);
}
// If we care, find out if we just used a special factory.
if (!mPrettyPrintHasFactoredElements && !mPrettyPrintHasSpecialRoot &&
mPrettyPrintXML) {
PRBool hasFactory = PR_FALSE;
rv = gNameSpaceManager->HasRegisteredFactory(aNameSpaceID, &hasFactory);
NS_ENSURE_SUCCESS(rv, rv);
mPrettyPrintHasFactoredElements = hasFactory;
}
return NS_OK;
}
@ -674,6 +782,7 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
const nsString& aMedia)
{
nsresult rv = NS_OK;
mPrettyPrintXML = PR_FALSE;
if (aType.EqualsIgnoreCase(kXSLType) ||
aType.EqualsIgnoreCase(kXMLTextContentType) ||
@ -937,6 +1046,9 @@ nsXMLContentSink::ProcessHeaderData(nsIAtom* aHeader,const nsAString& aValue,nsI
// XXX necko isn't going to process headers coming in from the parser
//NS_WARNING("need to fix how necko adds mime headers (in HTMLContentSink::ProcessMETATag)");
// If we add support for linking scripts here then we have to remember to
// turn off prettyprinting
mDocument->SetHeaderData(aHeader, aValue);
// see if we have a refresh "header".
@ -1548,13 +1660,6 @@ MathMLElementFactoryImpl::CreateInstanceByTag(nsINodeInfo* aNodeInfo,
////////////////////////////////////////////////////////////////////////
void
nsXMLContentSink::GetElementFactory(PRInt32 aNameSpaceID,
nsIElementFactory** aResult)
{
gNameSpaceManager->GetElementFactory(aNameSpaceID, aResult);
}
NS_IMETHODIMP
nsXMLContentSink::HandleStartElement(const PRUnichar *aName,
const PRUnichar **aAtts,
@ -1600,6 +1705,7 @@ nsXMLContentSink::HandleStartElement(const PRUnichar *aName,
const PRBool isXHTML = nameSpaceID == kNameSpaceID_XHTML;
if (isXHTML) {
mPrettyPrintHasFactoredElements = PR_TRUE;
if (tagAtom.get() == nsHTMLAtoms::script) {
result = ProcessStartSCRIPTTag(aLineNumber);
// Don't append the content to the tree until we're all
@ -1651,6 +1757,17 @@ nsXMLContentSink::HandleStartElement(const PRUnichar *aName,
if (NS_OK == result) {
// If this is the document element
if (!mDocElement) {
// check for root elements that needs special handling for
// prettyprinting
if ((nameSpaceID == kNameSpaceID_XBL &&
tagAtom == nsXBLAtoms::bindings) ||
(nameSpaceID == kNameSpaceID_XSLT &&
(tagAtom == nsLayoutAtoms::stylesheet ||
tagAtom == nsLayoutAtoms::transform))) {
mPrettyPrintHasSpecialRoot = PR_TRUE;
}
mDocElement = content;
NS_ADDREF(mDocElement);
@ -1908,6 +2025,7 @@ nsXMLContentSink::HandleProcessingInstruction(const PRUnichar *aTarget,
if (ssle) {
ssle->InitStyleLinkElement(mParser, PR_FALSE);
ssle->SetEnableUpdates(PR_FALSE);
mPrettyPrintXML = PR_FALSE;
}
result = AddContentAsLeaf(node);

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

@ -173,6 +173,8 @@ protected:
void ScrollToRef();
PRBool ShouldPrettyPrint();
static nsINameSpaceManager* gNameSpaceManager;
static PRUint32 gRefCnt;
@ -200,6 +202,9 @@ protected:
PRPackedBool mConstrainSize;
PRPackedBool mInTitle;
PRPackedBool mNeedToBlockParser;
PRPackedBool mPrettyPrintXML;
PRPackedBool mPrettyPrintHasSpecialRoot;
PRPackedBool mPrettyPrintHasFactoredElements;
nsCOMPtr<nsISupportsArray> mContentStack;
nsCOMPtr<nsINodeInfoManager> mNodeInfoManager;

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

@ -261,6 +261,9 @@ enum nsDOMClassInfoID {
// ContentList object used for various live NodeLists
eDOMClassInfo_ContentList_id,
// Processing-instruction with target "xml-stylesheet"
eDOMClassInfo_XMLStylesheetProcessingInstruction_id,
// This one better be the last one in this list
eDOMClassInfoIDCount
};

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

@ -803,6 +803,9 @@ static nsDOMClassInfoData sClassInfoData[] = {
nsContentListSH,
ARRAY_SCRIPTABLE_FLAGS |
nsIXPCScriptable::WANT_PRECREATE)
NS_DEFINE_CLASSINFO_DATA(XMLStylesheetProcessingInstruction, nsNodeSH,
NODE_SCRIPTABLE_FLAGS)
};
nsIXPConnect *nsDOMClassInfo::sXPConnect = nsnull;
@ -1358,7 +1361,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(ProcessingInstruction, nsIDOMProcessingInstruction)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMProcessingInstruction)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_END
@ -1896,6 +1898,12 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMPkcs11)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XMLStylesheetProcessingInstruction, nsIDOMProcessingInstruction)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMProcessingInstruction)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMLinkStyle)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_END
#ifdef MOZ_SVG
#define DOM_CLASSINFO_SVG_ELEMENT_MAP_ENTRIES \
DOM_CLASSINFO_MAP_ENTRY(nsIDOMSVGElement) \

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

@ -211,6 +211,8 @@ LAYOUT_ATOM(Korean, "ko")
// other
LAYOUT_ATOM(wildcard, "*")
LAYOUT_ATOM(mozdirty, "_moz_dirty")
LAYOUT_ATOM(stylesheet, "stylesheet")
LAYOUT_ATOM(transform, "transform")
#ifdef IBMBIDI
LAYOUT_ATOM(directionalFrame, "DirectionalFrame")