mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Remove nsIHTMLContentContainer, merge those three functions into nsIDocument,
and make XUL style attribute dynamic changes get a proper CSSLoader off the document. Bug 211376, r+sr=jst
This commit is contained in:
parent
e1b3204886
commit
8093efd14c
@ -83,6 +83,9 @@ class nsISupportsArray;
|
||||
class nsIScriptLoader;
|
||||
class nsIContentSink;
|
||||
class nsIScriptEventManager;
|
||||
class nsICSSLoader;
|
||||
class nsIHTMLStyleSheet;
|
||||
class nsIHTMLCSSStyleSheet;
|
||||
|
||||
// IID for the nsIDocument interface
|
||||
#define NS_IDOCUMENT_IID \
|
||||
@ -415,6 +418,24 @@ public:
|
||||
virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
|
||||
PRBool aApplicable) = 0;
|
||||
|
||||
/**
|
||||
* Get this document's CSSLoader. May return null in error
|
||||
* conditions (OOM)
|
||||
*/
|
||||
virtual nsICSSLoader* GetCSSLoader() = 0;
|
||||
|
||||
/**
|
||||
* Get this document's attribute stylesheet. May return null if
|
||||
* there isn't one.
|
||||
*/
|
||||
virtual nsIHTMLStyleSheet* GetAttributeStyleSheet() const = 0;
|
||||
|
||||
/**
|
||||
* Get this document's inline style sheet. May return null if there
|
||||
* isn't one
|
||||
*/
|
||||
virtual nsIHTMLCSSStyleSheet* GetInlineStyleSheet() const = 0;
|
||||
|
||||
/**
|
||||
* Set the object from which a document can get a script context.
|
||||
* This is the context within which all scripts (during document
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "nsContentSink.h"
|
||||
#include "nsIScriptLoader.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsStyleLinkElement.h"
|
||||
#include "nsINodeInfo.h"
|
||||
@ -177,10 +176,7 @@ nsContentSink::Init(nsIDocument* aDoc,
|
||||
nsresult rv = loader->AddObserver(proxy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContainer(do_QueryInterface(aDoc));
|
||||
if (htmlContainer) {
|
||||
htmlContainer->GetCSSLoader(*getter_AddRefs(mCSSLoader));
|
||||
}
|
||||
mCSSLoader = aDoc->GetCSSLoader();
|
||||
|
||||
// XXX this presumes HTTP header info is already set in document
|
||||
// XXX if it isn't we need to set it here...
|
||||
|
@ -573,6 +573,14 @@ nsDocument::~nsDocument()
|
||||
mNodeInfoManager->DropDocumentReference();
|
||||
}
|
||||
|
||||
if (mAttrStyleSheet) {
|
||||
mAttrStyleSheet->SetOwningDocument(nsnull);
|
||||
}
|
||||
|
||||
if (mStyleAttrStyleSheet) {
|
||||
mStyleAttrStyleSheet->SetOwningDocument(nsnull);
|
||||
}
|
||||
|
||||
delete mHeaderData;
|
||||
delete mBoxObjectTable;
|
||||
delete mXPathDocument;
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMStyleSheet.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIUnicharInputStream.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
@ -239,12 +238,7 @@ nsStyleLinkElement::UpdateStyleSheet(nsIDocument *aOldDocument,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContainer(do_QueryInterface(doc));
|
||||
nsCOMPtr<nsICSSLoader> loader;
|
||||
|
||||
if (htmlContainer) {
|
||||
htmlContainer->GetCSSLoader(*getter_AddRefs(loader));
|
||||
}
|
||||
nsICSSLoader* loader = doc->GetCSSLoader();
|
||||
|
||||
if (!loader) {
|
||||
return NS_OK;
|
||||
|
@ -90,7 +90,6 @@
|
||||
#include "nsILayoutHistoryState.h"
|
||||
#include "nsIFrameManager.h"
|
||||
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsHTMLParts.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsString.h"
|
||||
@ -1245,19 +1244,6 @@ nsGenericHTMLElement::ScrollIntoView(PRBool aTop)
|
||||
}
|
||||
|
||||
|
||||
static nsIHTMLStyleSheet* GetAttrStyleSheet(nsIDocument* aDocument)
|
||||
{
|
||||
nsIHTMLStyleSheet* sheet = nsnull;
|
||||
|
||||
if (aDocument) {
|
||||
nsCOMPtr<nsIHTMLContentContainer> container(do_QueryInterface(aDocument));
|
||||
|
||||
container->GetAttributeStyleSheet(&sheet);
|
||||
}
|
||||
|
||||
return sheet;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsGenericHTMLElement::InNavQuirksMode(nsIDocument* aDoc)
|
||||
{
|
||||
@ -1281,10 +1267,9 @@ nsGenericHTMLElement::SetDocument(nsIDocument* aDocument, PRBool aDeep,
|
||||
|
||||
if (!doNothing && mDocument && mAttributes) {
|
||||
ReparseStyleAttribute();
|
||||
nsIHTMLStyleSheet* sheet = GetAttrStyleSheet(mDocument);
|
||||
nsIHTMLStyleSheet* sheet = mDocument->GetAttributeStyleSheet();
|
||||
if (sheet) {
|
||||
mAttributes->SetStyleSheet(sheet);
|
||||
NS_RELEASE(sheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1712,8 +1697,7 @@ nsGenericHTMLElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
// set as string value to avoid another string copy
|
||||
PRBool mapped = HasAttributeDependentStyle(aAttribute);
|
||||
|
||||
nsCOMPtr<nsIHTMLStyleSheet> sheet =
|
||||
dont_AddRef(GetAttrStyleSheet(mDocument));
|
||||
nsIHTMLStyleSheet* sheet = mDocument ? mDocument->GetAttributeStyleSheet() : nsnull;
|
||||
|
||||
if (!mAttributes) {
|
||||
result = NS_NewHTMLAttributes(&mAttributes);
|
||||
@ -1928,7 +1912,7 @@ nsGenericHTMLElement::SetHTMLAttribute(nsIAtom* aAttribute,
|
||||
}
|
||||
|
||||
PRBool mapped = HasAttributeDependentStyle(aAttribute);
|
||||
nsCOMPtr<nsIHTMLStyleSheet> sheet;
|
||||
nsIHTMLStyleSheet* sheet = nsnull;
|
||||
if (mDocument) {
|
||||
PRBool modification = PR_TRUE;
|
||||
nsAutoString oldValueStr;
|
||||
@ -1945,7 +1929,8 @@ nsGenericHTMLElement::SetHTMLAttribute(nsIAtom* aAttribute,
|
||||
if (aNotify) {
|
||||
mDocument->AttributeWillChange(this, kNameSpaceID_None, aAttribute);
|
||||
}
|
||||
sheet = dont_AddRef(GetAttrStyleSheet(mDocument));
|
||||
sheet = mDocument->GetAttributeStyleSheet();
|
||||
// XXXbz this code is repeated at the end of the method too... seems silly.
|
||||
if (sheet) {
|
||||
if (!mAttributes) {
|
||||
nsresult rv = NS_NewHTMLAttributes(&mAttributes);
|
||||
@ -2061,8 +2046,7 @@ nsGenericHTMLElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute,
|
||||
}
|
||||
|
||||
if (mAttributes) {
|
||||
nsCOMPtr<nsIHTMLStyleSheet> sheet
|
||||
= dont_AddRef(GetAttrStyleSheet(mDocument));
|
||||
nsIHTMLStyleSheet* sheet = mDocument ? mDocument->GetAttributeStyleSheet() : nsnull;
|
||||
PRInt32 count;
|
||||
result = mAttributes->UnsetAttributeFor(aAttribute, aNameSpaceID, this,
|
||||
sheet, count);
|
||||
@ -3119,13 +3103,8 @@ nsGenericHTMLElement::ParseStyleAttribute(const nsAString& aValue, nsHTMLValue&
|
||||
}
|
||||
|
||||
if (isCSS) {
|
||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||
nsICSSLoader* cssLoader = doc->GetCSSLoader();
|
||||
nsCOMPtr<nsICSSParser> cssParser;
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContainer(do_QueryInterface(doc));
|
||||
|
||||
if (htmlContainer) {
|
||||
htmlContainer->GetCSSLoader(*getter_AddRefs(cssLoader));
|
||||
}
|
||||
if (cssLoader) {
|
||||
result = cssLoader->GetParserFor(nsnull, getter_AddRefs(cssParser));
|
||||
}
|
||||
|
@ -54,7 +54,6 @@
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIDocShell.h"
|
||||
@ -522,29 +521,24 @@ void MapAttributesIntoRule(const nsIHTMLMappedAttributes* aAttributes, nsRuleDat
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
presShell->GetDocument(getter_AddRefs(doc));
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContainer =
|
||||
do_QueryInterface(doc);
|
||||
if (htmlContainer) {
|
||||
nsCOMPtr<nsIHTMLStyleSheet> styleSheet;
|
||||
htmlContainer->GetAttributeStyleSheet(getter_AddRefs(styleSheet));
|
||||
if (styleSheet) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::link, value);
|
||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
||||
styleSheet->SetLinkColor(value.GetColorValue());
|
||||
}
|
||||
nsIHTMLStyleSheet* styleSheet = doc->GetAttributeStyleSheet();
|
||||
if (styleSheet) {
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::link, value);
|
||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
||||
styleSheet->SetLinkColor(value.GetColorValue());
|
||||
}
|
||||
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::alink, value);
|
||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
||||
styleSheet->SetActiveLinkColor(value.GetColorValue());
|
||||
}
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::alink, value);
|
||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
||||
styleSheet->SetActiveLinkColor(value.GetColorValue());
|
||||
}
|
||||
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::vlink, value);
|
||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
||||
styleSheet->SetVisitedLinkColor(value.GetColorValue());
|
||||
}
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::vlink, value);
|
||||
if ((eHTMLUnit_Color == value.GetUnit()) ||
|
||||
(eHTMLUnit_ColorName == value.GetUnit())) {
|
||||
styleSheet->SetVisitedLinkColor(value.GetColorValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -573,35 +567,13 @@ nsHTMLBodyElement::GetAttributeMappingFunction(nsMapRuleToAttributesFunc& aMapRu
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsIHTMLStyleSheet* GetAttrStyleSheet(nsIDocument* aDocument)
|
||||
{
|
||||
nsIHTMLStyleSheet* sheet = nsnull;
|
||||
|
||||
if (aDocument) {
|
||||
nsCOMPtr<nsIHTMLContentContainer> container(do_QueryInterface(aDocument));
|
||||
|
||||
if (container) {
|
||||
container->GetAttributeStyleSheet(&sheet);
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(nsnull != sheet, "can't get attribute style sheet");
|
||||
return sheet;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLBodyElement::WalkContentStyleRules(nsRuleWalker* aRuleWalker)
|
||||
{
|
||||
nsGenericHTMLContainerElement::WalkContentStyleRules(aRuleWalker);
|
||||
|
||||
if (!mContentStyleRule) {
|
||||
nsCOMPtr<nsIHTMLStyleSheet> sheet;
|
||||
|
||||
if (mDocument) { // find style sheet
|
||||
sheet = dont_AddRef(GetAttrStyleSheet(mDocument));
|
||||
}
|
||||
|
||||
mContentStyleRule = new BodyRule(this, sheet);
|
||||
if (!mContentStyleRule && mDocument) {
|
||||
mContentStyleRule = new BodyRule(this, mDocument->GetAttributeStyleSheet());
|
||||
NS_IF_ADDREF(mContentStyleRule);
|
||||
}
|
||||
if (aRuleWalker && mContentStyleRule) {
|
||||
|
@ -47,7 +47,6 @@
|
||||
#include "nsIDOMEventReceiver.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsHTMLAttributes.h"
|
||||
#include "nsIDOMMutationEvent.h"
|
||||
|
||||
@ -149,20 +148,6 @@ nsHTMLUnknownElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsIHTMLStyleSheet* GetAttrStyleSheet(nsIDocument* aDocument)
|
||||
{
|
||||
nsIHTMLStyleSheet *sheet=nsnull;
|
||||
|
||||
if (aDocument) {
|
||||
nsCOMPtr<nsIHTMLContentContainer> container(do_QueryInterface(aDocument));
|
||||
|
||||
container->GetAttributeStyleSheet(&sheet);
|
||||
}
|
||||
|
||||
return sheet;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLUnknownElement::SetAttribute(PRInt32 aNameSpaceID,
|
||||
nsIAtom* aAttribute,
|
||||
@ -206,7 +191,8 @@ nsHTMLUnknownElement::SetAttribute(PRInt32 aNameSpaceID,
|
||||
// set as string value to avoid another string copy
|
||||
PRBool mapped = HasAttributeDependentStyle(aAttribute);
|
||||
|
||||
nsCOMPtr<nsIHTMLStyleSheet> sheet(dont_AddRef(GetAttrStyleSheet(mDocument)));
|
||||
nsIHTMLStyleSheet* sheet =
|
||||
mDocument ? mDocument->GetAttributeStyleSheet() : nsnull;
|
||||
if (!mAttributes) {
|
||||
result = NS_NewHTMLAttributes(&mAttributes);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
@ -72,7 +72,6 @@ CPPSRCS = \
|
||||
|
||||
EXPORTS = \
|
||||
nsIHTMLDocument.h \
|
||||
nsIHTMLContentContainer.h \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
|
@ -309,14 +309,6 @@ nsHTMLDocument::nsHTMLDocument()
|
||||
|
||||
nsHTMLDocument::~nsHTMLDocument()
|
||||
{
|
||||
if (mAttrStyleSheet) {
|
||||
mAttrStyleSheet->SetOwningDocument(nsnull);
|
||||
}
|
||||
|
||||
if (mStyleAttrStyleSheet) {
|
||||
mStyleAttrStyleSheet->SetOwningDocument(nsnull);
|
||||
}
|
||||
|
||||
if (--gRefCntRDFService == 0) {
|
||||
NS_IF_RELEASE(gRDF);
|
||||
}
|
||||
@ -335,7 +327,6 @@ NS_INTERFACE_MAP_BEGIN(nsHTMLDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHTMLDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHTMLContentContainer)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLDocument)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDocument)
|
||||
|
||||
@ -1170,38 +1161,6 @@ nsHTMLDocument::GetImageMap(const nsAString& aMapName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
*aResult = mAttrStyleSheet;
|
||||
|
||||
if (!*aResult) {
|
||||
return NS_ERROR_NOT_AVAILABLE; // probably not the right error...
|
||||
}
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
*aResult = mStyleAttrStyleSheet;
|
||||
|
||||
if (!*aResult) {
|
||||
return NS_ERROR_NOT_AVAILABLE; // probably not the right error...
|
||||
}
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// subclass hooks for sheet ordering
|
||||
void
|
||||
nsHTMLDocument::InternalAddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags)
|
||||
@ -1294,21 +1253,18 @@ nsHTMLDocument::SetReferrer(const nsAString& aReferrer)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetCSSLoader(nsICSSLoader*& aLoader)
|
||||
nsICSSLoader*
|
||||
nsHTMLDocument::GetCSSLoader()
|
||||
{
|
||||
if (!mCSSLoader) {
|
||||
nsresult rv = NS_NewCSSLoader(this, getter_AddRefs(mCSSLoader));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_NewCSSLoader(this, getter_AddRefs(mCSSLoader));
|
||||
if (mCSSLoader) {
|
||||
mCSSLoader->SetCaseSensitive(IsXHTML());
|
||||
mCSSLoader->SetCompatibilityMode(mCompatMode);
|
||||
}
|
||||
}
|
||||
|
||||
mCSSLoader->SetCaseSensitive(IsXHTML());
|
||||
mCSSLoader->SetCompatibilityMode(mCompatMode);
|
||||
|
||||
aLoader = mCSSLoader;
|
||||
NS_ADDREF(aLoader);
|
||||
|
||||
return NS_OK;
|
||||
|
||||
return mCSSLoader;
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include "nsIDOMHTMLBodyElement.h"
|
||||
#include "nsIDOMHTMLMapElement.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIParser.h"
|
||||
#include "jsapi.h"
|
||||
#include "rdf.h"
|
||||
@ -73,8 +72,7 @@ class nsICacheEntryDescriptor;
|
||||
class nsHTMLDocument : public nsDocument,
|
||||
public nsIHTMLDocument,
|
||||
public nsIDOMHTMLDocument,
|
||||
public nsIDOMNSHTMLDocument,
|
||||
public nsIHTMLContentContainer
|
||||
public nsIDOMNSHTMLDocument
|
||||
{
|
||||
public:
|
||||
nsHTMLDocument();
|
||||
@ -113,9 +111,7 @@ public:
|
||||
NS_IMETHOD GetImageMap(const nsAString& aMapName,
|
||||
nsIDOMHTMLMapElement** aResult);
|
||||
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aStyleSheet);
|
||||
NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aStyleSheet);
|
||||
NS_IMETHOD GetCSSLoader(nsICSSLoader*& aLoader);
|
||||
virtual nsICSSLoader* GetCSSLoader();
|
||||
|
||||
virtual void GetBaseTarget(nsAString& aTarget) const;
|
||||
virtual void SetBaseTarget(const nsAString& aTarget);
|
||||
@ -267,9 +263,6 @@ protected:
|
||||
|
||||
virtual void RetrieveRelevantHeaders(nsIChannel *aChannel);
|
||||
|
||||
nsCOMPtr<nsIHTMLStyleSheet> mAttrStyleSheet;
|
||||
nsCOMPtr<nsIHTMLCSSStyleSheet> mStyleAttrStyleSheet;
|
||||
|
||||
nsString mBaseTarget;
|
||||
nsString mReferrer;
|
||||
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "nsIParser.h"
|
||||
#include "nsIParserService.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsHTMLTokens.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
|
@ -1,65 +0,0 @@
|
||||
/* -*- 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.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* 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 nsIHTMLContentContainer_h___
|
||||
#define nsIHTMLContentContainer_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIHTMLStyleSheet;
|
||||
class nsIHTMLCSSStyleSheet;
|
||||
class nsICSSLoader;
|
||||
|
||||
/* a6cf90cc-15b3-11d2-932e-00805f8add32 */
|
||||
#define NS_IHTMLCONTENTCONTAINER_IID \
|
||||
{0xa6cf90cc, 0x15b3, 0x11d2, \
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
/**
|
||||
* Interface implemented by any document class that can container
|
||||
* HTML content.
|
||||
* XXX Could do with a better name for this interface.
|
||||
*/
|
||||
class nsIHTMLContentContainer : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTMLCONTENTCONTAINER_IID)
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aStyleSheet) = 0;
|
||||
NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aStyleSheet) = 0;
|
||||
NS_IMETHOD GetCSSLoader(nsICSSLoader*& aLoader) = 0;
|
||||
};
|
||||
|
||||
#endif // nsIHTMLContentContainer_h___
|
@ -45,7 +45,6 @@
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsICSSParser.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIDocument.h"
|
||||
@ -986,10 +985,8 @@ DOMCSSDeclarationImpl::GetCSSParsingEnvironment(nsIURI** aURI,
|
||||
sheet->GetURL(*aURI);
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
sheet->GetOwningDocument(*getter_AddRefs(document));
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContainer =
|
||||
do_QueryInterface(document);
|
||||
if (htmlContainer) {
|
||||
htmlContainer->GetCSSLoader(*aCSSLoader);
|
||||
if (document) {
|
||||
NS_IF_ADDREF(*aCSSLoader = document->GetCSSLoader());
|
||||
NS_ASSERTION(*aCSSLoader, "Document with no CSS loader!");
|
||||
}
|
||||
}
|
||||
|
@ -59,9 +59,8 @@
|
||||
#include "nsICSSNameSpaceRule.h"
|
||||
#include "nsICSSMediaRule.h"
|
||||
#include "nsIMediaList.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIStyledContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
@ -2617,13 +2616,15 @@ CSSStyleSheetImpl::InsertRule(const nsAString& aRule,
|
||||
if (aIndex > count)
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
|
||||
// Hold strong ref to the CSSLoader in case the document update
|
||||
// kills the document
|
||||
nsCOMPtr<nsICSSLoader> loader;
|
||||
nsCOMPtr<nsICSSParser> css;
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContainer(do_QueryInterface(mDocument));
|
||||
if (htmlContainer) {
|
||||
htmlContainer->GetCSSLoader(*getter_AddRefs(loader));
|
||||
if (mDocument) {
|
||||
loader = mDocument->GetCSSLoader();
|
||||
NS_ASSERTION(loader, "Document with no CSS loader!");
|
||||
}
|
||||
NS_ASSERTION(loader || !mDocument, "Document with no CSS loader!");
|
||||
|
||||
nsCOMPtr<nsICSSParser> css;
|
||||
if (loader) {
|
||||
result = loader->GetParserFor(this, getter_AddRefs(css));
|
||||
}
|
||||
@ -2856,15 +2857,15 @@ CSSStyleSheetImpl::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule*
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// get the css parser
|
||||
// Hold strong ref to the CSSLoader in case the document update
|
||||
// kills the document
|
||||
nsCOMPtr<nsICSSLoader> loader;
|
||||
nsCOMPtr<nsICSSParser> css;
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContainer(do_QueryInterface(mDocument));
|
||||
if (htmlContainer) {
|
||||
htmlContainer->GetCSSLoader(*getter_AddRefs(loader));
|
||||
if (mDocument) {
|
||||
loader = mDocument->GetCSSLoader();
|
||||
NS_ASSERTION(loader, "Document with no CSS loader!");
|
||||
}
|
||||
NS_ASSERTION(loader || !mDocument, "Document with no CSS loader!");
|
||||
|
||||
nsCOMPtr<nsICSSParser> css;
|
||||
if (loader) {
|
||||
result = loader->GetParserFor(this, getter_AddRefs(css));
|
||||
}
|
||||
|
@ -49,7 +49,6 @@
|
||||
#include "nsICSSParser.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsStyleConsts.h"
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(nsDOMCSSAttributeDeclaration)
|
||||
@ -155,11 +154,10 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
|
||||
nsCOMPtr<nsIURI> base = mContent->GetBaseURI();
|
||||
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContainer(do_QueryInterface(doc));
|
||||
if (htmlContainer) {
|
||||
htmlContainer->GetCSSLoader(*aCSSLoader);
|
||||
if (doc) {
|
||||
NS_IF_ADDREF(*aCSSLoader = doc->GetCSSLoader());
|
||||
NS_ASSERTION(*aCSSLoader, "Document with no CSS loader!");
|
||||
}
|
||||
NS_ASSERTION(!doc || *aCSSLoader, "Document with no CSS loader!");
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -73,7 +73,6 @@
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
#include "nsIHTMLCSSStyleSheet.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
|
||||
#include "nsIStyleRuleProcessor.h"
|
||||
#include "nsIWeakReference.h"
|
||||
@ -1267,12 +1266,10 @@ nsBindingManager::WalkRules(nsStyleSet* aStyleSet,
|
||||
if (parent) {
|
||||
// We cut ourselves off, but we still need to walk the document's attribute sheet
|
||||
// so that inline style continues to work on anonymous content.
|
||||
nsCOMPtr<nsIHTMLContentContainer> container(
|
||||
do_QueryInterface(content->GetDocument()));
|
||||
if (container) {
|
||||
nsCOMPtr<nsIHTMLCSSStyleSheet> inlineSheet;
|
||||
container->GetInlineStyleSheet(getter_AddRefs(inlineSheet));
|
||||
nsCOMPtr<nsIStyleRuleProcessor> inlineCSS(do_QueryInterface(inlineSheet));
|
||||
nsIDocument* doc = content->GetDocument();
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIStyleRuleProcessor> inlineCSS(
|
||||
do_QueryInterface(doc->GetInlineStyleSheet()));
|
||||
if (inlineCSS)
|
||||
(*aFunc)(inlineCSS, aData);
|
||||
}
|
||||
|
@ -52,7 +52,6 @@
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsIXBLDocumentInfo.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsXBLAtoms.h"
|
||||
#include "nsIFrameManager.h"
|
||||
@ -133,8 +132,7 @@ nsXBLResourceLoader::LoadResources(PRBool* aResult)
|
||||
}
|
||||
else if (curr->mType == nsXBLAtoms::stylesheet) {
|
||||
if (!cssLoader) {
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContent(do_QueryInterface(doc));
|
||||
htmlContent->GetCSSLoader(*getter_AddRefs(cssLoader));
|
||||
cssLoader = doc->GetCSSLoader();
|
||||
}
|
||||
|
||||
if (!cssLoader)
|
||||
|
@ -70,7 +70,6 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
@ -1052,45 +1051,41 @@ MathMLElementFactoryImpl::CreateInstanceByTag(nsINodeInfo* aNodeInfo,
|
||||
// this bit of code is to load mathml.css on demand
|
||||
nsIDocument* doc = aNodeInfo->GetDocument();
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContainer(do_QueryInterface(doc));
|
||||
if (htmlContainer) {
|
||||
PRBool enabled;
|
||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||
htmlContainer->GetCSSLoader(*getter_AddRefs(cssLoader));
|
||||
if (cssLoader && NS_SUCCEEDED(cssLoader->GetEnabled(&enabled)) && enabled) {
|
||||
PRBool alreadyLoaded = PR_FALSE;
|
||||
PRInt32 sheetCount = doc->GetNumberOfStyleSheets(PR_TRUE);
|
||||
for (PRInt32 i = 0; i < sheetCount; i++) {
|
||||
nsIStyleSheet* sheet = doc->GetStyleSheetAt(i, PR_TRUE);
|
||||
NS_ASSERTION(sheet, "unexpected null stylesheet in the document");
|
||||
if (sheet) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
sheet->GetURL(*getter_AddRefs(uri));
|
||||
nsCAutoString uriStr;
|
||||
uri->GetSpec(uriStr);
|
||||
if (uriStr.Equals(kMathMLStyleSheetURI)) {
|
||||
alreadyLoaded = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
nsICSSLoader* cssLoader = doc->GetCSSLoader();
|
||||
PRBool enabled;
|
||||
if (cssLoader && NS_SUCCEEDED(cssLoader->GetEnabled(&enabled)) && enabled) {
|
||||
PRBool alreadyLoaded = PR_FALSE;
|
||||
PRInt32 sheetCount = doc->GetNumberOfStyleSheets(PR_TRUE);
|
||||
for (PRInt32 i = 0; i < sheetCount; i++) {
|
||||
nsIStyleSheet* sheet = doc->GetStyleSheetAt(i, PR_TRUE);
|
||||
NS_ASSERTION(sheet, "unexpected null stylesheet in the document");
|
||||
if (sheet) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
sheet->GetURL(*getter_AddRefs(uri));
|
||||
nsCAutoString uriStr;
|
||||
uri->GetSpec(uriStr);
|
||||
if (uriStr.Equals(kMathMLStyleSheetURI)) {
|
||||
alreadyLoaded = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!alreadyLoaded) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), kMathMLStyleSheetURI);
|
||||
if (uri) {
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet;
|
||||
cssLoader->LoadAgentSheet(uri, getter_AddRefs(sheet));
|
||||
}
|
||||
if (!alreadyLoaded) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), kMathMLStyleSheetURI);
|
||||
if (uri) {
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet;
|
||||
cssLoader->LoadAgentSheet(uri, getter_AddRefs(sheet));
|
||||
#ifdef NS_DEBUG
|
||||
nsCAutoString uriStr;
|
||||
uri->GetSpec(uriStr);
|
||||
printf("MathML Factory: loading catalog stylesheet: %s ... %s\n", uriStr.get(), sheet.get() ? "Done" : "Failed");
|
||||
NS_ASSERTION(uriStr.Equals(kMathMLStyleSheetURI), "resolved URI unexpected");
|
||||
nsCAutoString uriStr;
|
||||
uri->GetSpec(uriStr);
|
||||
printf("MathML Factory: loading catalog stylesheet: %s ... %s\n", uriStr.get(), sheet.get() ? "Done" : "Failed");
|
||||
NS_ASSERTION(uriStr.Equals(kMathMLStyleSheetURI), "resolved URI unexpected");
|
||||
#endif
|
||||
if (sheet) {
|
||||
doc->BeginUpdate(UPDATE_STYLE);
|
||||
doc->AddStyleSheet(sheet, NS_STYLESHEET_FROM_CATALOG);
|
||||
doc->EndUpdate(UPDATE_STYLE);
|
||||
}
|
||||
if (sheet) {
|
||||
doc->BeginUpdate(UPDATE_STYLE);
|
||||
doc->AddStyleSheet(sheet, NS_STYLESHEET_FROM_CATALOG);
|
||||
doc->EndUpdate(UPDATE_STYLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,16 +194,6 @@ nsXMLDocument::nsXMLDocument()
|
||||
|
||||
nsXMLDocument::~nsXMLDocument()
|
||||
{
|
||||
if (mAttrStyleSheet) {
|
||||
mAttrStyleSheet->SetOwningDocument(nsnull);
|
||||
}
|
||||
if (mInlineStyleSheet) {
|
||||
mInlineStyleSheet->SetOwningDocument(nsnull);
|
||||
}
|
||||
if (mCSSLoader) {
|
||||
mCSSLoader->DropDocumentReference();
|
||||
}
|
||||
|
||||
// XXX We rather crash than hang
|
||||
mLoopingForSyncLoad = PR_FALSE;
|
||||
}
|
||||
@ -211,7 +201,6 @@ nsXMLDocument::~nsXMLDocument()
|
||||
|
||||
// QueryInterface implementation for nsXMLDocument
|
||||
NS_INTERFACE_MAP_BEGIN(nsXMLDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHTMLContentContainer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHttpEventSink)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMXMLDocument)
|
||||
@ -245,13 +234,6 @@ nsXMLDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAttrStyleSheet) {
|
||||
mAttrStyleSheet->SetOwningDocument(nsnull);
|
||||
}
|
||||
if (mInlineStyleSheet) {
|
||||
mInlineStyleSheet->SetOwningDocument(nsnull);
|
||||
}
|
||||
|
||||
SetDefaultStylesheets(url);
|
||||
|
||||
mBaseTarget.Truncate();
|
||||
@ -596,10 +578,9 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
}
|
||||
|
||||
// styles
|
||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||
nsresult rv = GetCSSLoader(*getter_AddRefs(cssLoader));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
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
|
||||
}
|
||||
@ -699,32 +680,6 @@ nsXMLDocument::EndLoad()
|
||||
nsDocument::EndLoad();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
*aResult = mAttrStyleSheet;
|
||||
NS_ENSURE_TRUE(mAttrStyleSheet, NS_ERROR_NOT_AVAILABLE); // probably not the right error...
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
*aResult = mInlineStyleSheet;
|
||||
NS_ENSURE_TRUE(mInlineStyleSheet, NS_ERROR_NOT_AVAILABLE); // probably not the right error...
|
||||
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// subclass hook for sheet ordering
|
||||
void
|
||||
nsXMLDocument::InternalAddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags)
|
||||
@ -741,15 +696,15 @@ nsXMLDocument::InternalAddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags)
|
||||
"Adding attr sheet twice!");
|
||||
mStyleSheets.InsertObjectAt(aSheet, mCatalogSheetCount);
|
||||
}
|
||||
else if (aSheet == mInlineStyleSheet) { // always last
|
||||
else if (aSheet == mStyleAttrStyleSheet) { // always last
|
||||
NS_ASSERTION(mStyleSheets.Count() == 0 ||
|
||||
mStyleSheets[mStyleSheets.Count() - 1] != mInlineStyleSheet,
|
||||
mStyleSheets[mStyleSheets.Count() - 1] != mStyleAttrStyleSheet,
|
||||
"Adding style attr sheet twice!");
|
||||
mStyleSheets.AppendObject(aSheet);
|
||||
}
|
||||
else {
|
||||
PRInt32 count = mStyleSheets.Count();
|
||||
if (count != 0 && mInlineStyleSheet == mStyleSheets[count - 1]) {
|
||||
if (count != 0 && mStyleAttrStyleSheet == mStyleSheets[count - 1]) {
|
||||
// keep attr sheet last
|
||||
mStyleSheets.InsertObjectAt(aSheet, count - 1);
|
||||
}
|
||||
@ -770,7 +725,7 @@ nsXMLDocument::InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex)
|
||||
/* Don't count catalog sheets */
|
||||
- mCatalogSheetCount
|
||||
/* No insertion allowed after StyleAttr stylesheet */
|
||||
- (mInlineStyleSheet ? 1: 0)
|
||||
- (mStyleAttrStyleSheet ? 1: 0)
|
||||
),
|
||||
"index out of bounds");
|
||||
// offset w.r.t. catalog style sheets and the attr style sheet
|
||||
@ -795,7 +750,7 @@ nsXMLDocument::InternalGetNumberOfStyleSheets() const
|
||||
{
|
||||
PRInt32 count = mStyleSheets.Count();
|
||||
|
||||
if (count != 0 && mInlineStyleSheet == mStyleSheets[count - 1]) {
|
||||
if (count != 0 && mStyleAttrStyleSheet == mStyleSheets[count - 1]) {
|
||||
// subtract the inline style sheet
|
||||
--count;
|
||||
}
|
||||
@ -1080,17 +1035,25 @@ nsXMLDocument::SetDefaultStylesheets(nsIURI* aUrl)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXXbz this code is very similar to the HTMLDocument code; should merge!
|
||||
if (mAttrStyleSheet) {
|
||||
mAttrStyleSheet->SetOwningDocument(nsnull);
|
||||
}
|
||||
if (mStyleAttrStyleSheet) {
|
||||
mStyleAttrStyleSheet->SetOwningDocument(nsnull);
|
||||
}
|
||||
|
||||
nsresult rv = NS_NewHTMLStyleSheet(getter_AddRefs(mAttrStyleSheet), aUrl,
|
||||
this);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = NS_NewHTMLCSSStyleSheet(getter_AddRefs(mInlineStyleSheet), aUrl,
|
||||
rv = NS_NewHTMLCSSStyleSheet(getter_AddRefs(mStyleAttrStyleSheet), aUrl,
|
||||
this);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// tell the world about our new style sheets
|
||||
AddStyleSheet(mAttrStyleSheet, 0);
|
||||
AddStyleSheet(mInlineStyleSheet, 0);
|
||||
AddStyleSheet(mStyleAttrStyleSheet, 0);
|
||||
|
||||
return rv;
|
||||
}
|
||||
@ -1107,22 +1070,19 @@ nsXMLDocument::GetBaseTarget(nsAString &aBaseTarget) const
|
||||
aBaseTarget.Assign(mBaseTarget);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetCSSLoader(nsICSSLoader*& aLoader)
|
||||
nsICSSLoader*
|
||||
nsXMLDocument::GetCSSLoader()
|
||||
{
|
||||
if (!mCSSLoader) {
|
||||
nsresult rv = NS_NewCSSLoader(this, getter_AddRefs(mCSSLoader));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mCSSLoader->SetCaseSensitive(PR_TRUE);
|
||||
// no quirks in XML
|
||||
mCSSLoader->SetCompatibilityMode(eCompatibility_FullStandards);
|
||||
NS_NewCSSLoader(this, getter_AddRefs(mCSSLoader));
|
||||
if (mCSSLoader) {
|
||||
mCSSLoader->SetCaseSensitive(PR_TRUE);
|
||||
// no quirks in XML
|
||||
mCSSLoader->SetCompatibilityMode(eCompatibility_FullStandards);
|
||||
}
|
||||
}
|
||||
|
||||
aLoader = mCSSLoader;
|
||||
NS_IF_ADDREF(aLoader);
|
||||
|
||||
return NS_OK;
|
||||
return mCSSLoader;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -40,7 +40,6 @@
|
||||
#define nsXMLDocument_h___
|
||||
|
||||
#include "nsDocument.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
@ -56,7 +55,6 @@ class nsICSSLoader;
|
||||
class nsIURI;
|
||||
|
||||
class nsXMLDocument : public nsDocument,
|
||||
public nsIHTMLContentContainer,
|
||||
public nsIInterfaceRequestor,
|
||||
public nsIHttpEventSink
|
||||
{
|
||||
@ -107,10 +105,7 @@ public:
|
||||
NS_IMETHOD GetElementById(const nsAString& aElementId,
|
||||
nsIDOMElement** aReturn);
|
||||
|
||||
// nsIHTMLContentContainer
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
|
||||
NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult);
|
||||
NS_IMETHOD GetCSSLoader(nsICSSLoader*& aLoader);
|
||||
virtual nsICSSLoader* GetCSSLoader();
|
||||
|
||||
// nsIInterfaceRequestor
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
@ -136,10 +131,6 @@ protected:
|
||||
|
||||
nsresult SetDefaultStylesheets(nsIURI* aUrl);
|
||||
|
||||
// For HTML elements in our content model
|
||||
// XXX This is not clean, but is there a better way?
|
||||
nsCOMPtr<nsIHTMLStyleSheet> mAttrStyleSheet;
|
||||
nsCOMPtr<nsIHTMLCSSStyleSheet> mInlineStyleSheet;
|
||||
// For additional catalog sheets (if any) needed to layout the XML vocabulary
|
||||
// of the document. Catalog sheets are kept at the beginning of our array of
|
||||
// style sheets and this counter is used as an offset to distinguish them
|
||||
|
@ -59,6 +59,8 @@
|
||||
#include "nsFixedSizeAllocator.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsICSSParser.h"
|
||||
#include "nsICSSStyleRule.h"
|
||||
#include "nsIDOMElement.h"
|
||||
@ -720,18 +722,28 @@ nsresult nsXULAttributes::UpdateStyleRule(nsIURI* aDocURL, const nsAString& aVal
|
||||
{
|
||||
if (aValue.IsEmpty())
|
||||
{
|
||||
// XXX: Removing the rule. Is this sufficient?
|
||||
mStyleRule = nsnull;
|
||||
return NS_OK;
|
||||
// Just remove the rule; we'll be getting our style reresolved
|
||||
mStyleRule = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDocument* doc = mContent->GetNodeInfo()->GetDocument();
|
||||
|
||||
nsICSSLoader* cssLoader = nsnull;
|
||||
if (doc) {
|
||||
cssLoader = doc->GetCSSLoader();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICSSParser> css;
|
||||
nsresult result = NS_OK;
|
||||
|
||||
nsCOMPtr<nsICSSParser> css(do_CreateInstance(kCSSParserCID, &result));
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
if (cssLoader) {
|
||||
result = cssLoader->GetParserFor(nsnull, getter_AddRefs(css));
|
||||
} else {
|
||||
css = do_CreateInstance(kCSSParserCID, &result);
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
nsCOMPtr<nsICSSStyleRule> rule;
|
||||
result = css->ParseStyleAttribute(aValue, aDocURL, getter_AddRefs(rule));
|
||||
|
||||
@ -739,6 +751,10 @@ nsresult nsXULAttributes::UpdateStyleRule(nsIURI* aDocURL, const nsAString& aVal
|
||||
mStyleRule = rule;
|
||||
}
|
||||
|
||||
if (cssLoader) {
|
||||
cssLoader->RecycleParser(css);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,6 @@
|
||||
#include "nsIEventListenerManager.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIFastLoadService.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
#include "nsINameSpace.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
|
@ -302,8 +302,13 @@ public:
|
||||
protected:
|
||||
static nsICSSParser* GetCSSParser()
|
||||
{
|
||||
if (!sCSSParser)
|
||||
if (!sCSSParser) {
|
||||
CallCreateInstance(kCSSParserCID, &sCSSParser);
|
||||
if (sCSSParser) {
|
||||
sCSSParser->SetCaseSensitive(PR_TRUE);
|
||||
sCSSParser->SetQuirkMode(PR_FALSE);
|
||||
}
|
||||
}
|
||||
return sCSSParser;
|
||||
}
|
||||
static nsICSSParser* sCSSParser;
|
||||
|
@ -65,7 +65,6 @@
|
||||
#include "nsIDocumentLoader.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
#include "nsINameSpace.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
@ -597,14 +596,9 @@ XULContentSinkImpl::Init(nsIDocument* aDocument, nsIXULPrototypeDocument* aProto
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Get the CSS loader from the document so we can load
|
||||
// stylesheets.
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContainer = do_QueryInterface(aDocument);
|
||||
NS_ASSERTION(htmlContainer != nsnull, "not an HTML container");
|
||||
if (! htmlContainer)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
rv = htmlContainer->GetCSSLoader(*getter_AddRefs(mCSSLoader));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// stylesheets
|
||||
mCSSLoader = aDocument->GetCSSLoader();
|
||||
NS_ENSURE_TRUE(mCSSLoader, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
rv = aPrototype->GetNodeInfoManager(getter_AddRefs(mNodeInfoManager));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -483,7 +483,6 @@ NS_IMPL_RELEASE_INHERITED(nsXULDocument, nsXMLDocument)
|
||||
NS_INTERFACE_MAP_BEGIN(nsXULDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIXULDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMXULDocument)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIHTMLContentContainer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStreamLoaderObserver)
|
||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(XULDocument)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsXMLDocument)
|
||||
@ -530,6 +529,8 @@ nsXULDocument::PrepareStyleSheets(nsIURI* anURL)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// XXXbz this is similar to code in nsHTMLDocument and
|
||||
// nsXMLDocument; move up to nsDocument?
|
||||
// Delete references to style sheets - this should be done in superclass...
|
||||
PRInt32 i = mStyleSheets.Count();
|
||||
while (--i >= 0) {
|
||||
@ -548,14 +549,13 @@ nsXULDocument::PrepareStyleSheets(nsIURI* anURL)
|
||||
|
||||
// Create an inline style sheet for inline content that contains a style
|
||||
// attribute.
|
||||
rv = NS_NewHTMLCSSStyleSheet(getter_AddRefs(mInlineStyleSheet), anURL,
|
||||
this);
|
||||
rv = NS_NewHTMLCSSStyleSheet(getter_AddRefs(mStyleAttrStyleSheet), anURL, this);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("unable to add inline style sheet");
|
||||
return rv;
|
||||
}
|
||||
|
||||
AddStyleSheet(mInlineStyleSheet, 0);
|
||||
AddStyleSheet(mStyleAttrStyleSheet, 0);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -3699,9 +3699,8 @@ nsXULDocument::AddPrototypeSheets()
|
||||
// only system that partially invalidates the XUL cache).
|
||||
// - dwh
|
||||
//XXXbz we hit this code from fastload all the time. Bug 183505.
|
||||
nsCOMPtr<nsICSSLoader> loader;
|
||||
rv = GetCSSLoader(*getter_AddRefs(loader));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsICSSLoader* loader = GetCSSLoader();
|
||||
NS_ENSURE_TRUE(loader, NS_ERROR_OUT_OF_MEMORY);
|
||||
rv = loader->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
|
||||
|
@ -67,7 +67,6 @@
|
||||
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsIDocumentStateListener.h"
|
||||
|
||||
|
@ -78,7 +78,6 @@
|
||||
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "nsIDocumentStateListener.h"
|
||||
|
||||
@ -3862,17 +3861,11 @@ nsHTMLEditor::GetCSSLoader(const nsAString& aURL, nsICSSLoader** aCSSLoader)
|
||||
NS_ENSURE_SUCCESS(rv, rv);;
|
||||
if (!document) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);
|
||||
if (!container) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||
nsCOMPtr<nsICSSStyleSheet> cssStyleSheet;
|
||||
NS_IF_ADDREF(*aCSSLoader = document->GetCSSLoader());
|
||||
if (!*aCSSLoader) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
rv = container->GetCSSLoader(*getter_AddRefs(cssLoader));
|
||||
NS_ENSURE_SUCCESS(rv, rv);;
|
||||
if (!cssLoader) return NS_ERROR_NULL_POINTER;
|
||||
*aCSSLoader = cssLoader;
|
||||
NS_ADDREF(*aCSSLoader);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,6 @@
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIDocumentObserver.h"
|
||||
#include "TypeInState.h"
|
||||
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsICSSParser.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIDocument.h"
|
||||
@ -986,10 +985,8 @@ DOMCSSDeclarationImpl::GetCSSParsingEnvironment(nsIURI** aURI,
|
||||
sheet->GetURL(*aURI);
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
sheet->GetOwningDocument(*getter_AddRefs(document));
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContainer =
|
||||
do_QueryInterface(document);
|
||||
if (htmlContainer) {
|
||||
htmlContainer->GetCSSLoader(*aCSSLoader);
|
||||
if (document) {
|
||||
NS_IF_ADDREF(*aCSSLoader = document->GetCSSLoader());
|
||||
NS_ASSERTION(*aCSSLoader, "Document with no CSS loader!");
|
||||
}
|
||||
}
|
||||
|
@ -59,9 +59,8 @@
|
||||
#include "nsICSSNameSpaceRule.h"
|
||||
#include "nsICSSMediaRule.h"
|
||||
#include "nsIMediaList.h"
|
||||
#include "nsIHTMLContent.h"
|
||||
#include "nsIStyledContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsHTMLAtoms.h"
|
||||
@ -2617,13 +2616,15 @@ CSSStyleSheetImpl::InsertRule(const nsAString& aRule,
|
||||
if (aIndex > count)
|
||||
return NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
|
||||
// Hold strong ref to the CSSLoader in case the document update
|
||||
// kills the document
|
||||
nsCOMPtr<nsICSSLoader> loader;
|
||||
nsCOMPtr<nsICSSParser> css;
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContainer(do_QueryInterface(mDocument));
|
||||
if (htmlContainer) {
|
||||
htmlContainer->GetCSSLoader(*getter_AddRefs(loader));
|
||||
if (mDocument) {
|
||||
loader = mDocument->GetCSSLoader();
|
||||
NS_ASSERTION(loader, "Document with no CSS loader!");
|
||||
}
|
||||
NS_ASSERTION(loader || !mDocument, "Document with no CSS loader!");
|
||||
|
||||
nsCOMPtr<nsICSSParser> css;
|
||||
if (loader) {
|
||||
result = loader->GetParserFor(this, getter_AddRefs(css));
|
||||
}
|
||||
@ -2856,15 +2857,15 @@ CSSStyleSheetImpl::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule*
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// get the css parser
|
||||
// Hold strong ref to the CSSLoader in case the document update
|
||||
// kills the document
|
||||
nsCOMPtr<nsICSSLoader> loader;
|
||||
nsCOMPtr<nsICSSParser> css;
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContainer(do_QueryInterface(mDocument));
|
||||
if (htmlContainer) {
|
||||
htmlContainer->GetCSSLoader(*getter_AddRefs(loader));
|
||||
if (mDocument) {
|
||||
loader = mDocument->GetCSSLoader();
|
||||
NS_ASSERTION(loader, "Document with no CSS loader!");
|
||||
}
|
||||
NS_ASSERTION(loader || !mDocument, "Document with no CSS loader!");
|
||||
|
||||
nsCOMPtr<nsICSSParser> css;
|
||||
if (loader) {
|
||||
result = loader->GetParserFor(this, getter_AddRefs(css));
|
||||
}
|
||||
|
@ -49,7 +49,6 @@
|
||||
#include "nsICSSParser.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsStyleConsts.h"
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(nsDOMCSSAttributeDeclaration)
|
||||
@ -155,11 +154,10 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI,
|
||||
|
||||
nsCOMPtr<nsIURI> base = mContent->GetBaseURI();
|
||||
|
||||
nsCOMPtr<nsIHTMLContentContainer> htmlContainer(do_QueryInterface(doc));
|
||||
if (htmlContainer) {
|
||||
htmlContainer->GetCSSLoader(*aCSSLoader);
|
||||
if (doc) {
|
||||
NS_IF_ADDREF(*aCSSLoader = doc->GetCSSLoader());
|
||||
NS_ASSERTION(*aCSSLoader, "Document with no CSS loader!");
|
||||
}
|
||||
NS_ASSERTION(!doc || *aCSSLoader, "Document with no CSS loader!");
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -79,7 +79,6 @@
|
||||
#include "nsIStyleSheet.h"
|
||||
#include "nsIHTMLCSSStyleSheet.h"
|
||||
#include "nsIHTMLStyleSheet.h"
|
||||
#include "nsIHTMLContentContainer.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsISupportsArray.h"
|
||||
@ -1566,13 +1565,6 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// The document sheets just need to be done once; the document will notify
|
||||
// the presshells and style sets
|
||||
nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);
|
||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||
rv = container->GetCSSLoader(*getter_AddRefs(cssLoader));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Build an array of nsIURIs of style sheets we need to load.
|
||||
nsCOMArray<nsIStyleSheet> oldSheets;
|
||||
nsCOMArray<nsIStyleSheet> newSheets;
|
||||
@ -1607,6 +1599,7 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow)
|
||||
nsCOMPtr<nsICSSStyleSheet> newSheet;
|
||||
// XXX what about chrome sheets that have a title or are disabled? This
|
||||
// only works by sheer dumb luck.
|
||||
// XXXbz this should really use the document's CSSLoader!
|
||||
LoadStyleSheetWithURL(uri, getter_AddRefs(newSheet));
|
||||
// Even if it's null, we put in in there.
|
||||
newSheets.AppendObject(newSheet);
|
||||
|
@ -761,12 +761,6 @@ nsIXMLContent = { /* a6cf90cb-15b3-11d2-932e-00805f8add32 */
|
||||
0x11d2,
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}
|
||||
};
|
||||
nsIHTMLContentContainer = { /* a6cf90cc-15b3-11d2-932e-00805f8add32 */
|
||||
0xa6cf90cc,
|
||||
0x15b3,
|
||||
0x11d2,
|
||||
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}
|
||||
};
|
||||
nsIDOMNSDocument = { /* a6cf90cd-15b3-11d2-932e-00805f8add32 */
|
||||
0xa6cf90cd,
|
||||
0x15b3,
|
||||
|
Loading…
Reference in New Issue
Block a user