mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Create CSSLoaders when the document object is created and deCOMify the getter.
Bug 290068, r=sicking, sr=peterv, a=brendan
This commit is contained in:
parent
6e9df675ad
commit
8df9c25d22
@ -435,10 +435,11 @@ public:
|
||||
virtual void EnsureCatalogStyleSheet(const char *aStyleSheetURI) = 0;
|
||||
|
||||
/**
|
||||
* Get this document's CSSLoader. May return null in error
|
||||
* conditions (OOM)
|
||||
* Get this document's CSSLoader. This is guaranteed to not return null.
|
||||
*/
|
||||
virtual nsICSSLoader* GetCSSLoader() = 0;
|
||||
nsICSSLoader* CSSLoader() const {
|
||||
return mCSSLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this document's attribute stylesheet. May return null if
|
||||
@ -698,6 +699,10 @@ protected:
|
||||
nsCOMPtr<nsIBindingManager> mBindingManager;
|
||||
nsNodeInfoManager* mNodeInfoManager; // [STRONG]
|
||||
|
||||
nsICSSLoader* mCSSLoader; // [STRONG; not a COMPtr to avoid
|
||||
// including nsICSSLoader.h; the ownership
|
||||
// is managed by nsDocument]
|
||||
|
||||
// Table of element properties for this document.
|
||||
nsPropertyTable mPropertyTable;
|
||||
|
||||
|
@ -181,7 +181,7 @@ nsContentSink::Init(nsIDocument* aDoc,
|
||||
nsresult rv = loader->AddObserver(proxy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mCSSLoader = aDoc->GetCSSLoader();
|
||||
mCSSLoader = aDoc->CSSLoader();
|
||||
|
||||
ProcessHTTPHeaders(aChannel);
|
||||
|
||||
|
@ -586,7 +586,9 @@ nsDocument::~nsDocument()
|
||||
}
|
||||
|
||||
if (mCSSLoader) {
|
||||
// Could be null here if Init() failed
|
||||
mCSSLoader->DropDocumentReference();
|
||||
NS_RELEASE(mCSSLoader);
|
||||
}
|
||||
|
||||
// XXX Ideally we'd do this cleanup in the nsIDocument destructor.
|
||||
@ -666,6 +668,10 @@ NS_IMPL_RELEASE(nsDocument)
|
||||
nsresult
|
||||
nsDocument::Init()
|
||||
{
|
||||
if (mBindingManager || mCSSLoader || mNodeInfoManager) {
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
|
||||
// Force initialization.
|
||||
nsBindingManager *bindingManager = new nsBindingManager();
|
||||
NS_ENSURE_TRUE(bindingManager, NS_ERROR_OUT_OF_MEMORY);
|
||||
@ -675,9 +681,11 @@ nsDocument::Init()
|
||||
// (static cast to the correct interface pointer)
|
||||
mObservers.InsertElementAt(NS_STATIC_CAST(nsIDocumentObserver*, bindingManager), 0);
|
||||
|
||||
if (mNodeInfoManager) {
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
NS_NewCSSLoader(this, &mCSSLoader);
|
||||
NS_ENSURE_TRUE(mCSSLoader, NS_ERROR_OUT_OF_MEMORY);
|
||||
// Assume we're not HTML and not quirky, until we know otherwise
|
||||
mCSSLoader->SetCaseSensitive(PR_TRUE);
|
||||
mCSSLoader->SetCompatibilityMode(eCompatibility_FullStandards);
|
||||
|
||||
mNodeInfoManager = new nsNodeInfoManager();
|
||||
NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_OUT_OF_MEMORY);
|
||||
@ -1221,14 +1229,7 @@ nsDocument::SetHeaderData(nsIAtom* aHeaderField, const nsAString& aData)
|
||||
nsAutoString title;
|
||||
PRInt32 index;
|
||||
|
||||
// We lazily create our CSSLoader.
|
||||
// XXXbz why? Wouldn't it make more sense to just create it at
|
||||
// document creation and not do all these null-checks all over?
|
||||
nsICSSLoader* cssLoader = GetCSSLoader();
|
||||
if (!cssLoader) {
|
||||
return;
|
||||
}
|
||||
cssLoader->SetPreferredSheet(aData);
|
||||
CSSLoader()->SetPreferredSheet(aData);
|
||||
|
||||
PRInt32 count = mStyleSheets.Count();
|
||||
for (index = 0; index < count; index++) {
|
||||
@ -1793,9 +1794,9 @@ nsDocument::AddCatalogStyleSheet(nsIStyleSheet* aSheet)
|
||||
void
|
||||
nsDocument::EnsureCatalogStyleSheet(const char *aStyleSheetURI)
|
||||
{
|
||||
nsICSSLoader* cssLoader = GetCSSLoader();
|
||||
nsICSSLoader* cssLoader = CSSLoader();
|
||||
PRBool enabled;
|
||||
if (cssLoader && NS_SUCCEEDED(cssLoader->GetEnabled(&enabled)) && enabled) {
|
||||
if (NS_SUCCEEDED(cssLoader->GetEnabled(&enabled)) && enabled) {
|
||||
PRInt32 sheetCount = GetNumberOfCatalogStyleSheets();
|
||||
for (PRInt32 i = 0; i < sheetCount; i++) {
|
||||
nsIStyleSheet* sheet = GetCatalogStyleSheetAt(i);
|
||||
@ -2622,12 +2623,7 @@ nsDocument::GetStyleSheets(nsIDOMStyleSheetList** aStyleSheets)
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetPreferredStylesheetSet(nsAString& aStyleTitle)
|
||||
{
|
||||
if (mCSSLoader) {
|
||||
mCSSLoader->GetPreferredSheet(aStyleTitle);
|
||||
}
|
||||
else {
|
||||
aStyleTitle.Truncate();
|
||||
}
|
||||
CSSLoader()->GetPreferredSheet(aStyleTitle);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -594,7 +594,6 @@ protected:
|
||||
|
||||
nsSupportsHashtable* mBoxObjectTable;
|
||||
|
||||
nsCOMPtr<nsICSSLoader> mCSSLoader;
|
||||
nsRefPtr<nsHTMLStyleSheet> mAttrStyleSheet;
|
||||
nsCOMPtr<nsIHTMLCSSStyleSheet> mStyleAttrStyleSheet;
|
||||
nsRefPtr<nsXMLEventsManager> mXMLEventsManager;
|
||||
|
@ -261,12 +261,6 @@ nsStyleLinkElement::UpdateStyleSheet(nsIDocument *aOldDocument,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsICSSLoader* loader = doc->GetCSSLoader();
|
||||
|
||||
if (!loader) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool blockParser = kBlockByDefault;
|
||||
if (isAlternate) {
|
||||
blockParser = PR_FALSE;
|
||||
@ -325,14 +319,16 @@ nsStyleLinkElement::UpdateStyleSheet(nsIDocument *aOldDocument,
|
||||
|
||||
// Now that we have a url and a unicode input stream, parse the
|
||||
// style sheet.
|
||||
rv = loader->LoadInlineStyle(thisContent, uin, mLineNumber, title, media,
|
||||
((blockParser) ? parser.get() : nsnull),
|
||||
doneLoading, aObserver);
|
||||
rv = doc->CSSLoader()->
|
||||
LoadInlineStyle(thisContent, uin, mLineNumber, title, media,
|
||||
((blockParser) ? parser.get() : nsnull),
|
||||
doneLoading, aObserver);
|
||||
}
|
||||
else {
|
||||
rv = loader->LoadStyleLink(thisContent, uri, title, media,
|
||||
((blockParser) ? parser.get() : nsnull),
|
||||
doneLoading, aObserver);
|
||||
rv = doc->CSSLoader()->
|
||||
LoadStyleLink(thisContent, uri, title, media,
|
||||
((blockParser) ? parser.get() : nsnull),
|
||||
doneLoading, aObserver);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && blockParser && !doneLoading) {
|
||||
|
@ -2621,19 +2621,9 @@ nsGenericHTMLElement::ParseStyleAttribute(nsIContent* aContent,
|
||||
}
|
||||
|
||||
if (isCSS) {
|
||||
nsICSSLoader* cssLoader = doc->GetCSSLoader();
|
||||
nsICSSLoader* cssLoader = doc->CSSLoader();
|
||||
nsCOMPtr<nsICSSParser> cssParser;
|
||||
if (cssLoader) {
|
||||
result = cssLoader->GetParserFor(nsnull, getter_AddRefs(cssParser));
|
||||
}
|
||||
else {
|
||||
result = NS_NewCSSParser(getter_AddRefs(cssParser));
|
||||
if (cssParser) {
|
||||
// look up our namespace. If we're XHTML, we need to be case-sensitive
|
||||
// Otherwise, we should not be.
|
||||
cssParser->SetCaseSensitive(aCaseSensitive);
|
||||
}
|
||||
}
|
||||
result = cssLoader->GetParserFor(nsnull, getter_AddRefs(cssParser));
|
||||
if (cssParser) {
|
||||
nsCOMPtr<nsIURI> baseURI = aContent->GetBaseURI();
|
||||
|
||||
@ -2641,9 +2631,7 @@ nsGenericHTMLElement::ParseStyleAttribute(nsIContent* aContent,
|
||||
result = cssParser->ParseStyleAttribute(aValue, doc->GetDocumentURI(),
|
||||
baseURI,
|
||||
getter_AddRefs(rule));
|
||||
if (cssLoader) {
|
||||
cssLoader->RecycleParser(cssParser);
|
||||
}
|
||||
cssLoader->RecycleParser(cssParser);
|
||||
|
||||
if (rule) {
|
||||
aResult.SetTo(rule);
|
||||
|
@ -673,10 +673,6 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
nsCAutoString contentType;
|
||||
aChannel->GetContentType(contentType);
|
||||
|
||||
// Note: we MUST set the compat mode and default namespace ID before we call
|
||||
// StartDocumentLoad on our superclass (since that could force creation of a
|
||||
// CSSLoader and the CSSLoader creation needs to know our compat mode and
|
||||
// case sensitivity.
|
||||
if (contentType.Equals("application/xhtml+xml") &&
|
||||
(!aCommand || nsCRT::strcmp(aCommand, "view-source") != 0)) {
|
||||
// We're parsing XHTML as XML, remember that.
|
||||
@ -691,6 +687,9 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
}
|
||||
#endif
|
||||
|
||||
CSSLoader()->SetCaseSensitive(IsXHTML());
|
||||
CSSLoader()->SetCompatibilityMode(mCompatMode);
|
||||
|
||||
PRBool needsParser = PR_TRUE;
|
||||
if (aCommand)
|
||||
{
|
||||
@ -1052,22 +1051,6 @@ nsHTMLDocument::GetImageMap(const nsAString& aMapName)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
||||
nsICSSLoader*
|
||||
nsHTMLDocument::GetCSSLoader()
|
||||
{
|
||||
if (!mCSSLoader) {
|
||||
NS_NewCSSLoader(this, getter_AddRefs(mCSSLoader));
|
||||
if (mCSSLoader) {
|
||||
mCSSLoader->SetCaseSensitive(IsXHTML());
|
||||
mCSSLoader->SetCompatibilityMode(mCompatMode);
|
||||
}
|
||||
}
|
||||
|
||||
return mCSSLoader;
|
||||
}
|
||||
|
||||
|
||||
nsCompatibility
|
||||
nsHTMLDocument::GetCompatibilityMode()
|
||||
{
|
||||
@ -1081,9 +1064,7 @@ nsHTMLDocument::SetCompatibilityMode(nsCompatibility aMode)
|
||||
"Bad compat mode for XHTML document!");
|
||||
|
||||
mCompatMode = aMode;
|
||||
if (mCSSLoader) {
|
||||
mCSSLoader->SetCompatibilityMode(mCompatMode);
|
||||
}
|
||||
CSSLoader()->SetCompatibilityMode(mCompatMode);
|
||||
nsCOMPtr<nsIPresShell> shell = (nsIPresShell*)mPresShells.SafeElementAt(0);
|
||||
if (shell) {
|
||||
nsPresContext *pc = shell->GetPresContext();
|
||||
|
@ -61,7 +61,6 @@
|
||||
#include "nsICommandManager.h"
|
||||
|
||||
class nsIParser;
|
||||
class nsICSSLoader;
|
||||
class nsIURI;
|
||||
class nsIMarkupDocumentViewer;
|
||||
class nsIDocumentCharsetInfo;
|
||||
@ -109,8 +108,6 @@ public:
|
||||
|
||||
virtual nsIDOMHTMLMapElement *GetImageMap(const nsAString& aMapName);
|
||||
|
||||
virtual nsICSSLoader* GetCSSLoader();
|
||||
|
||||
virtual nsCompatibility GetCompatibilityMode();
|
||||
virtual void SetCompatibilityMode(nsCompatibility aMode);
|
||||
|
||||
|
@ -738,18 +738,14 @@ nsSVGElement::UpdateContentStyleRule()
|
||||
}
|
||||
|
||||
// Try to fetch the CSS Parser from the document.
|
||||
nsICSSLoader* cssLoader = doc->GetCSSLoader();
|
||||
nsICSSLoader* cssLoader = doc->CSSLoader();
|
||||
|
||||
nsCOMPtr<nsICSSParser> parser;
|
||||
nsresult rv = NS_OK;
|
||||
if (cssLoader) {
|
||||
rv = cssLoader->GetParserFor(nsnull, getter_AddRefs(parser));
|
||||
} else {
|
||||
rv = NS_NewCSSParser(getter_AddRefs(parser));
|
||||
}
|
||||
rv = cssLoader->GetParserFor(nsnull, getter_AddRefs(parser));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("failed to get or create a css parser");
|
||||
NS_WARNING("failed to get a css parser");
|
||||
declaration->RuleAbort();
|
||||
return;
|
||||
}
|
||||
@ -788,11 +784,9 @@ nsSVGElement::UpdateContentStyleRule()
|
||||
declaration->RuleAbort();
|
||||
}
|
||||
|
||||
// Recycle the parser if it a CSS loader exists.
|
||||
if (cssLoader) {
|
||||
parser->SetSVGMode(PR_FALSE);
|
||||
cssLoader->RecycleParser(parser);
|
||||
}
|
||||
// Recycle the parser
|
||||
parser->SetSVGMode(PR_FALSE);
|
||||
cssLoader->RecycleParser(parser);
|
||||
}
|
||||
|
||||
nsISVGValue*
|
||||
|
@ -93,11 +93,10 @@ nsXBLResourceLoader::LoadResources(PRBool* aResult)
|
||||
*aResult = PR_TRUE;
|
||||
|
||||
// Declare our loaders.
|
||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
mBinding->XBLDocumentInfo()->GetDocument(getter_AddRefs(doc));
|
||||
|
||||
nsICSSLoader* cssLoader = doc->CSSLoader();
|
||||
nsIURI *docURL = doc->GetDocumentURI();
|
||||
|
||||
nsCOMPtr<nsIURI> url;
|
||||
@ -125,13 +124,6 @@ nsXBLResourceLoader::LoadResources(PRBool* aResult)
|
||||
getter_AddRefs(req));
|
||||
}
|
||||
else if (curr->mType == nsXBLAtoms::stylesheet) {
|
||||
if (!cssLoader) {
|
||||
cssLoader = doc->GetCSSLoader();
|
||||
}
|
||||
|
||||
if (!cssLoader)
|
||||
continue;
|
||||
|
||||
// Kick off the load of the stylesheet.
|
||||
|
||||
// Always load chrome synchronously
|
||||
|
@ -61,7 +61,6 @@
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
@ -560,12 +559,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
}
|
||||
|
||||
// styles
|
||||
nsICSSLoader* cssLoader = GetCSSLoader();
|
||||
if (!cssLoader)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (cssLoader) {
|
||||
cssLoader->SetEnabled(PR_FALSE); // Do not load/process styles when loading as data
|
||||
}
|
||||
CSSLoader()->SetEnabled(PR_FALSE); // Do not load/process styles when loading as data
|
||||
} else if (nsCRT::strcmp("loadAsInteractiveData", aCommand) == 0) {
|
||||
mLoadedAsInteractiveData = PR_TRUE;
|
||||
aCommand = kLoadAsData; // XBL, for example, needs scripts and styles
|
||||
@ -790,18 +784,3 @@ nsXMLDocument::GetElementById(const nsAString& aElementId,
|
||||
|
||||
return CallQueryInterface(content, aReturn);
|
||||
}
|
||||
|
||||
nsICSSLoader*
|
||||
nsXMLDocument::GetCSSLoader()
|
||||
{
|
||||
if (!mCSSLoader) {
|
||||
NS_NewCSSLoader(this, getter_AddRefs(mCSSLoader));
|
||||
if (mCSSLoader) {
|
||||
mCSSLoader->SetCaseSensitive(PR_TRUE);
|
||||
// no quirks in XML
|
||||
mCSSLoader->SetCompatibilityMode(eCompatibility_FullStandards);
|
||||
}
|
||||
}
|
||||
|
||||
return mCSSLoader;
|
||||
}
|
||||
|
@ -50,7 +50,6 @@
|
||||
|
||||
class nsIParser;
|
||||
class nsIDOMNode;
|
||||
class nsICSSLoader;
|
||||
class nsIURI;
|
||||
|
||||
class nsXMLDocument : public nsDocument,
|
||||
@ -83,8 +82,6 @@ public:
|
||||
NS_IMETHOD GetElementById(const nsAString& aElementId,
|
||||
nsIDOMElement** aReturn);
|
||||
|
||||
virtual nsICSSLoader* GetCSSLoader();
|
||||
|
||||
// nsIInterfaceRequestor
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
||||
|
@ -551,8 +551,7 @@ XULContentSinkImpl::Init(nsIDocument* aDocument, nsIXULPrototypeDocument* aProto
|
||||
|
||||
// Get the CSS loader from the document so we can load
|
||||
// stylesheets
|
||||
mCSSLoader = aDocument->GetCSSLoader();
|
||||
NS_ENSURE_TRUE(mCSSLoader, NS_ERROR_OUT_OF_MEMORY);
|
||||
mCSSLoader = aDocument->CSSLoader();
|
||||
|
||||
mNodeInfoManager = aPrototype->GetNodeInfoManager();
|
||||
if (! mNodeInfoManager)
|
||||
|
@ -690,9 +690,9 @@ nsXULDocument::EndLoad()
|
||||
if (isChrome) {
|
||||
nsCOMPtr<nsIXULOverlayProvider> reg =
|
||||
do_GetService(NS_CHROMEREGISTRY_CONTRACTID);
|
||||
nsCOMPtr<nsICSSLoader> cssLoader = GetCSSLoader();
|
||||
nsICSSLoader* cssLoader = CSSLoader();
|
||||
|
||||
if (reg && cssLoader) {
|
||||
if (reg) {
|
||||
nsCOMPtr<nsISimpleEnumerator> overlays;
|
||||
reg->GetStyleOverlays(uri, getter_AddRefs(overlays));
|
||||
|
||||
@ -3769,9 +3769,7 @@ nsXULDocument::AddPrototypeSheets()
|
||||
// only system that partially invalidates the XUL cache).
|
||||
// - dwh
|
||||
//XXXbz we hit this code from fastload all the time. Bug 183505.
|
||||
nsICSSLoader* loader = GetCSSLoader();
|
||||
NS_ENSURE_TRUE(loader, NS_ERROR_OUT_OF_MEMORY);
|
||||
rv = loader->LoadAgentSheet(uri, getter_AddRefs(sheet));
|
||||
rv = CSSLoader()->LoadAgentSheet(uri, getter_AddRefs(sheet));
|
||||
// XXXldb We need to prevent bogus sheets from being held in the
|
||||
// prototype's list, but until then, don't propagate the failure
|
||||
// from LoadAgentSheet (and thus exit the loop).
|
||||
|
@ -3748,10 +3748,7 @@ nsHTMLEditor::GetCSSLoader(const nsAString& aURL, nsICSSLoader** aCSSLoader)
|
||||
nsIDocument *document = ps->GetDocument();
|
||||
if (!document) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_IF_ADDREF(*aCSSLoader = document->GetCSSLoader());
|
||||
if (!*aCSSLoader) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_ADDREF(*aCSSLoader = document->CSSLoader());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -940,10 +940,7 @@ txTransformNotifier::SignalTransformEnd(nsresult aResult)
|
||||
}
|
||||
|
||||
if (NS_FAILED(aResult)) {
|
||||
nsICSSLoader *cssLoader = doc->GetCSSLoader();
|
||||
if (cssLoader) {
|
||||
cssLoader->Stop();
|
||||
}
|
||||
doc->CSSLoader()->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1022,8 +1022,7 @@ DOMCSSDeclarationImpl::GetCSSParsingEnvironment(nsIURI** aSheetURI,
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
sheet->GetOwningDocument(*getter_AddRefs(document));
|
||||
if (document) {
|
||||
NS_IF_ADDREF(*aCSSLoader = document->GetCSSLoader());
|
||||
NS_ASSERTION(*aCSSLoader, "Document with no CSS loader!");
|
||||
NS_ADDREF(*aCSSLoader = document->CSSLoader());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2231,7 +2231,7 @@ nsCSSStyleSheet::InsertRule(const nsAString& aRule,
|
||||
// kills the document
|
||||
nsCOMPtr<nsICSSLoader> loader;
|
||||
if (mDocument) {
|
||||
loader = mDocument->GetCSSLoader();
|
||||
loader = mDocument->CSSLoader();
|
||||
NS_ASSERTION(loader, "Document with no CSS loader!");
|
||||
}
|
||||
|
||||
@ -2476,7 +2476,7 @@ nsCSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule,
|
||||
// kills the document
|
||||
nsCOMPtr<nsICSSLoader> loader;
|
||||
if (mDocument) {
|
||||
loader = mDocument->GetCSSLoader();
|
||||
loader = mDocument->CSSLoader();
|
||||
NS_ASSERTION(loader, "Document with no CSS loader!");
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include "nsIStyledContent.h"
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsICSSParser.h"
|
||||
#include "nsIURI.h"
|
||||
@ -155,28 +154,17 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aSheetURI,
|
||||
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
|
||||
nsCOMPtr<nsIURI> sheetURI = doc->GetDocumentURI();
|
||||
|
||||
if (doc) {
|
||||
NS_IF_ADDREF(*aCSSLoader = doc->GetCSSLoader());
|
||||
NS_ASSERTION(*aCSSLoader, "Document with no CSS loader!");
|
||||
}
|
||||
NS_ADDREF(*aCSSLoader = doc->CSSLoader());
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (*aCSSLoader) {
|
||||
rv = (*aCSSLoader)->GetParserFor(nsnull, aCSSParser);
|
||||
} else {
|
||||
rv = NS_NewCSSParser(aCSSParser);
|
||||
}
|
||||
// Note: parsers coming from a CSSLoader for a document already have
|
||||
// the right case-sensitivity, quirkiness, etc.
|
||||
rv = (*aCSSLoader)->GetParserFor(nsnull, aCSSParser);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// If we are not HTML, we need to be case-sensitive. Otherwise, Look up our
|
||||
// namespace. If we're XHTML, we need to be case-sensitive Otherwise, we
|
||||
// should not be
|
||||
(*aCSSParser)->SetCaseSensitive(!mContent->IsContentOfType(nsIContent::eHTML) ||
|
||||
mContent->GetNodeInfo()->NamespaceEquals(kNameSpaceID_XHTML));
|
||||
|
||||
baseURI.swap(*aBaseURI);
|
||||
sheetURI.swap(*aSheetURI);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user