added inline style sheet support for contained HTML

This commit is contained in:
peterl%netscape.com 1998-12-02 00:39:10 +00:00
Родитель ba1a0ff568
Коммит c1a6062752
4 изменённых файлов: 90 добавлений и 4 удалений

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

@ -32,6 +32,8 @@
#include "nsIHTMLContent.h"
#include "nsHTMLParts.h"
#include "nsIHTMLStyleSheet.h"
#include "nsIHTMLCSSStyleSheet.h"
#include "nsIStyleSet.h"
#include "nsRepository.h"
#include "nsIDOMComment.h"
#include "nsIDOMElement.h"
@ -62,6 +64,7 @@ nsXMLDocument::nsXMLDocument()
mParser = nsnull;
mNameSpaces = nsnull;
mAttrStyleSheet = nsnull;
mInlineStyleSheet = nsnull;
mProlog = nsnull;
mEpilog = nsnull;
@ -89,6 +92,10 @@ nsXMLDocument::~nsXMLDocument()
mAttrStyleSheet->SetOwningDocument(nsnull);
NS_RELEASE(mAttrStyleSheet);
}
if (nsnull != mInlineStyleSheet) {
mInlineStyleSheet->SetOwningDocument(nsnull);
NS_RELEASE(mInlineStyleSheet);
}
if (nsnull != mProlog) {
delete mProlog;
}
@ -143,6 +150,10 @@ nsXMLDocument::StartDocumentLoad(nsIURL *aUrl,
mAttrStyleSheet->SetOwningDocument(nsnull);
NS_RELEASE(mAttrStyleSheet);
}
if (nsnull != mInlineStyleSheet) {
mInlineStyleSheet->SetOwningDocument(nsnull);
NS_RELEASE(mInlineStyleSheet);
}
nsIWebShell* webShell;
@ -165,6 +176,9 @@ nsXMLDocument::StartDocumentLoad(nsIURL *aUrl,
if (NS_OK == NS_NewHTMLStyleSheet(&mAttrStyleSheet, aUrl, this)) {
AddStyleSheet(mAttrStyleSheet); // tell the world about our new style sheet
}
if (NS_OK == NS_NewHTMLCSSStyleSheet(&mInlineStyleSheet, aUrl, this)) {
AddStyleSheet(mInlineStyleSheet); // tell the world about our new style sheet
}
// Set the parser as the stream listener for the document loader...
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
@ -194,8 +208,6 @@ nsXMLDocument::EndLoad()
return nsDocument::EndLoad();
}
// XXX Currently a nsIHTMLDocument method. Should go into an interface
// implemented for XML documents that hold HTML content.
NS_IMETHODIMP
nsXMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult)
{
@ -213,6 +225,33 @@ nsXMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult)
return NS_OK;
}
NS_IMETHODIMP
nsXMLDocument::GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult)
{
NS_PRECONDITION(nsnull != aResult, "null ptr");
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
*aResult = mInlineStyleSheet;
if (nsnull == mInlineStyleSheet) {
return NS_ERROR_NOT_AVAILABLE; // probably not the right error...
}
else {
NS_ADDREF(mInlineStyleSheet);
}
return NS_OK;
}
void nsXMLDocument::AddStyleSheetToSet(nsIStyleSheet* aSheet, nsIStyleSet* aSet)
{
if ((nsnull != mInlineStyleSheet) && (aSheet != mInlineStyleSheet)) {
aSet->InsertDocStyleSheetAfter(aSheet, mInlineStyleSheet);
}
else {
aSet->InsertDocStyleSheetBefore(aSheet, nsnull); // put it in front
}
}
// nsIDOMDocument interface
NS_IMETHODIMP
nsXMLDocument::GetDoctype(nsIDOMDocumentType** aDocumentType)

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

@ -80,11 +80,15 @@ public:
// nsIHTMLContentContainer
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult);
protected:
void AddStyleSheetToSet(nsIStyleSheet* aSheet, nsIStyleSet* aSet);
// For HTML elements in our content model
nsIHTMLStyleSheet* mAttrStyleSheet;
nsIHTMLCSSStyleSheet* mInlineStyleSheet;
nsVoidArray *mProlog;
nsVoidArray *mEpilog;

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

@ -32,6 +32,8 @@
#include "nsIHTMLContent.h"
#include "nsHTMLParts.h"
#include "nsIHTMLStyleSheet.h"
#include "nsIHTMLCSSStyleSheet.h"
#include "nsIStyleSet.h"
#include "nsRepository.h"
#include "nsIDOMComment.h"
#include "nsIDOMElement.h"
@ -62,6 +64,7 @@ nsXMLDocument::nsXMLDocument()
mParser = nsnull;
mNameSpaces = nsnull;
mAttrStyleSheet = nsnull;
mInlineStyleSheet = nsnull;
mProlog = nsnull;
mEpilog = nsnull;
@ -89,6 +92,10 @@ nsXMLDocument::~nsXMLDocument()
mAttrStyleSheet->SetOwningDocument(nsnull);
NS_RELEASE(mAttrStyleSheet);
}
if (nsnull != mInlineStyleSheet) {
mInlineStyleSheet->SetOwningDocument(nsnull);
NS_RELEASE(mInlineStyleSheet);
}
if (nsnull != mProlog) {
delete mProlog;
}
@ -143,6 +150,10 @@ nsXMLDocument::StartDocumentLoad(nsIURL *aUrl,
mAttrStyleSheet->SetOwningDocument(nsnull);
NS_RELEASE(mAttrStyleSheet);
}
if (nsnull != mInlineStyleSheet) {
mInlineStyleSheet->SetOwningDocument(nsnull);
NS_RELEASE(mInlineStyleSheet);
}
nsIWebShell* webShell;
@ -165,6 +176,9 @@ nsXMLDocument::StartDocumentLoad(nsIURL *aUrl,
if (NS_OK == NS_NewHTMLStyleSheet(&mAttrStyleSheet, aUrl, this)) {
AddStyleSheet(mAttrStyleSheet); // tell the world about our new style sheet
}
if (NS_OK == NS_NewHTMLCSSStyleSheet(&mInlineStyleSheet, aUrl, this)) {
AddStyleSheet(mInlineStyleSheet); // tell the world about our new style sheet
}
// Set the parser as the stream listener for the document loader...
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
@ -194,8 +208,6 @@ nsXMLDocument::EndLoad()
return nsDocument::EndLoad();
}
// XXX Currently a nsIHTMLDocument method. Should go into an interface
// implemented for XML documents that hold HTML content.
NS_IMETHODIMP
nsXMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult)
{
@ -213,6 +225,33 @@ nsXMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult)
return NS_OK;
}
NS_IMETHODIMP
nsXMLDocument::GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult)
{
NS_PRECONDITION(nsnull != aResult, "null ptr");
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
*aResult = mInlineStyleSheet;
if (nsnull == mInlineStyleSheet) {
return NS_ERROR_NOT_AVAILABLE; // probably not the right error...
}
else {
NS_ADDREF(mInlineStyleSheet);
}
return NS_OK;
}
void nsXMLDocument::AddStyleSheetToSet(nsIStyleSheet* aSheet, nsIStyleSet* aSet)
{
if ((nsnull != mInlineStyleSheet) && (aSheet != mInlineStyleSheet)) {
aSet->InsertDocStyleSheetAfter(aSheet, mInlineStyleSheet);
}
else {
aSet->InsertDocStyleSheetBefore(aSheet, nsnull); // put it in front
}
}
// nsIDOMDocument interface
NS_IMETHODIMP
nsXMLDocument::GetDoctype(nsIDOMDocumentType** aDocumentType)

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

@ -80,11 +80,15 @@ public:
// nsIHTMLContentContainer
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult);
protected:
void AddStyleSheetToSet(nsIStyleSheet* aSheet, nsIStyleSet* aSet);
// For HTML elements in our content model
nsIHTMLStyleSheet* mAttrStyleSheet;
nsIHTMLCSSStyleSheet* mInlineStyleSheet;
nsVoidArray *mProlog;
nsVoidArray *mEpilog;