зеркало из https://github.com/mozilla/gecko-dev.git
Make the CSSLoader correctly order stylesheets as they are dynamically added
and removed via the DOM. Clean up the nsIDocument stylesheet accessors. Clean up nsIDocumentObserver stylesheet stuff a bit. Make style sheets visible in the CSSOM (though not completely accessible) from the moment the load is kicked off. Make us have sheet objects that can be manipulated via CSSOM even for failed loads. Bug 107567, bug 47734, bug 57225, bug 178407. r=sicking, sr=peterv.
This commit is contained in:
Родитель
18c9e6244b
Коммит
fe53f95e60
|
@ -1389,7 +1389,7 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow)
|
|||
if (!document)
|
||||
return NS_OK;
|
||||
|
||||
// Deal with the agent sheets first.
|
||||
// Deal with the agent sheets first. Have to do all the style sets by hand.
|
||||
PRInt32 shellCount = document->GetNumberOfShells();
|
||||
for (PRInt32 k = 0; k < shellCount; k++) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
|
@ -1434,76 +1434,63 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow)
|
|||
styleSet->ReplaceAgentStyleSheets(newAgentSheets);
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);
|
||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||
rv = container->GetCSSLoader(*getter_AddRefs(cssLoader));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Build an array of nsIURIs of style sheets we need to load.
|
||||
nsCOMPtr<nsISupportsArray> oldSheets;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(oldSheets));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> newSheets;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(newSheets));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIHTMLStyleSheet> attrSheet;
|
||||
rv = container->GetAttributeStyleSheet(getter_AddRefs(attrSheet));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIHTMLCSSStyleSheet> inlineSheet;
|
||||
rv = container->GetInlineStyleSheet(getter_AddRefs(inlineSheet));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRInt32 count = 0;
|
||||
document->GetNumberOfStyleSheets(&count);
|
||||
|
||||
// Iterate over the style sheets.
|
||||
PRUint32 i;
|
||||
for (i = 0; i < (PRUint32)count; i++) {
|
||||
// Get the style sheet
|
||||
nsCOMPtr<nsIStyleSheet> styleSheet;
|
||||
document->GetStyleSheetAt(i, getter_AddRefs(styleSheet));
|
||||
|
||||
// Make sure we aren't the special style sheets that never change. We
|
||||
// want to skip those.
|
||||
|
||||
nsCOMPtr<nsIStyleSheet> attr = do_QueryInterface(attrSheet);
|
||||
nsCOMPtr<nsIStyleSheet> inl = do_QueryInterface(inlineSheet);
|
||||
if ((attr.get() != styleSheet.get()) &&
|
||||
(inl.get() != styleSheet.get()))
|
||||
// Add this sheet to the list of old style sheets.
|
||||
oldSheets->AppendElement(styleSheet);
|
||||
}
|
||||
|
||||
// Iterate over our old sheets and kick off a sync load of the new
|
||||
// sheet if and only if it's a chrome URL.
|
||||
PRUint32 oldCount;
|
||||
oldSheets->Count(&oldCount);
|
||||
for (i = 0; i < oldCount; i++) {
|
||||
nsCOMPtr<nsISupports> supp = getter_AddRefs(oldSheets->ElementAt(i));
|
||||
nsCOMPtr<nsIStyleSheet> sheet(do_QueryInterface(supp));
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = sheet->GetURL(*getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (IsChromeURI(uri)) {
|
||||
// Reload the sheet.
|
||||
nsCOMPtr<nsICSSStyleSheet> newSheet;
|
||||
LoadStyleSheetWithURL(uri, getter_AddRefs(newSheet));
|
||||
if (newSheet)
|
||||
newSheets->AppendElement(newSheet);
|
||||
}
|
||||
else // Just use the same sheet.
|
||||
newSheets->AppendElement(sheet);
|
||||
}
|
||||
|
||||
// Now notify the document that multiple sheets have been added and removed.
|
||||
document->UpdateStyleSheets(oldSheets, newSheets);
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
PRInt32 count = 0;
|
||||
document->GetNumberOfStyleSheets(PR_FALSE, &count);
|
||||
|
||||
// Iterate over the style sheets.
|
||||
PRInt32 i;
|
||||
for (i = 0; i < count; i++) {
|
||||
// Get the style sheet
|
||||
nsCOMPtr<nsIStyleSheet> styleSheet;
|
||||
document->GetStyleSheetAt(i, PR_FALSE, getter_AddRefs(styleSheet));
|
||||
|
||||
if (!oldSheets.AppendObject(styleSheet)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate over our old sheets and kick off a sync load of the new
|
||||
// sheet if and only if it's a chrome URL.
|
||||
for (i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsIStyleSheet> sheet = oldSheets[i];
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = sheet->GetURL(*getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (IsChromeURI(uri)) {
|
||||
// Reload the sheet.
|
||||
#ifdef DEBUG
|
||||
nsCOMPtr<nsICSSStyleSheet> oldCSSSheet = do_QueryInterface(sheet);
|
||||
NS_ASSERTION(oldCSSSheet, "Don't know how to reload a non-CSS sheet");
|
||||
#endif
|
||||
nsCOMPtr<nsICSSStyleSheet> newSheet;
|
||||
// XXX what about chrome sheets that have a title or are disabled? This
|
||||
// only works by sheer dumb luck.
|
||||
LoadStyleSheetWithURL(uri, getter_AddRefs(newSheet));
|
||||
// Even if it's null, we put in in there.
|
||||
newSheets.AppendObject(newSheet);
|
||||
}
|
||||
else {
|
||||
// Just use the same sheet.
|
||||
newSheets.AppendObject(sheet);
|
||||
}
|
||||
}
|
||||
|
||||
// Now notify the document that multiple sheets have been added and removed.
|
||||
document->UpdateStyleSheets(oldSheets, newSheets);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -3085,9 +3072,7 @@ nsresult nsChromeRegistry::LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet*
|
|||
getter_AddRefs(loader));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (loader) {
|
||||
PRBool complete;
|
||||
rv = loader->LoadAgentSheet(aURL, *aSheet, complete,
|
||||
nsnull);
|
||||
rv = loader->LoadAgentSheet(aURL, aSheet);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nsAString.h"
|
||||
#include "nsString.h"
|
||||
#include "nsChangeHint.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIArena;
|
||||
|
@ -269,19 +270,79 @@ public:
|
|||
NS_IMETHOD GetChildCount(PRInt32& aCount) = 0;
|
||||
|
||||
/**
|
||||
* Get the style sheets owned by this document.
|
||||
* Accessors to the collection of stylesheets owned by this document.
|
||||
* Style sheets are ordered, most significant last.
|
||||
*/
|
||||
NS_IMETHOD GetNumberOfStyleSheets(PRInt32* aCount) = 0;
|
||||
NS_IMETHOD GetStyleSheetAt(PRInt32 aIndex, nsIStyleSheet** aSheet) = 0;
|
||||
NS_IMETHOD GetIndexOfStyleSheet(nsIStyleSheet* aSheet, PRInt32* aIndex) = 0;
|
||||
virtual void AddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags) = 0;
|
||||
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet) = 0;
|
||||
NS_IMETHOD UpdateStyleSheets(nsISupportsArray* aOldSheets, nsISupportsArray* aNewSheets) = 0;
|
||||
|
||||
NS_IMETHOD InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex, PRBool aNotify) = 0;
|
||||
virtual void SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
|
||||
PRBool aDisabled) = 0;
|
||||
/**
|
||||
* Get the number of stylesheets
|
||||
*
|
||||
* @param aIncludeSpecialSheets if this is set to true, all sheets
|
||||
* that are document sheets (including "special" sheets like
|
||||
* attribute sheets and inline style sheets) will be returned. If
|
||||
* false, only "normal" stylesheets will be returned
|
||||
* @return the number of stylesheets
|
||||
* @throws no exceptions
|
||||
*/
|
||||
NS_IMETHOD GetNumberOfStyleSheets(PRBool aIncludeSpecialSheets,
|
||||
PRInt32* aCount) = 0;
|
||||
|
||||
/**
|
||||
* Get a particular stylesheet
|
||||
* @param aIndex the index the stylesheet lives at. This is zero-based
|
||||
* @param aIncludeSpecialSheets see GetNumberOfStyleSheets. If this
|
||||
* is false, not all sheets will be returnable
|
||||
* @return the stylesheet at aIndex. Null if aIndex is out of range.
|
||||
* @throws no exceptions
|
||||
*/
|
||||
NS_IMETHOD GetStyleSheetAt(PRInt32 aIndex, PRBool aIncludeSpecialSheets,
|
||||
nsIStyleSheet** aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Insert a sheet at a particular spot in the stylesheet list (zero-based)
|
||||
* @param aSheet the sheet to insert
|
||||
* @param aIndex the index to insert at. This index will be
|
||||
* adjusted for the "special" sheets.
|
||||
* @throws no exceptions
|
||||
*/
|
||||
NS_IMETHOD InsertStyleSheetAt(nsIStyleSheet* aSheet,
|
||||
PRInt32 aIndex) = 0;
|
||||
|
||||
/**
|
||||
* Get the index of a particular stylesheet. This will _always_
|
||||
* consider the "special" sheets as part of the sheet list.
|
||||
* @param aSheet the sheet to get the index of
|
||||
* @return aIndex the index of the sheet in the full list
|
||||
*/
|
||||
NS_IMETHOD GetIndexOfStyleSheet(nsIStyleSheet* aSheet, PRInt32* aIndex) = 0;
|
||||
|
||||
/**
|
||||
* Replace the stylesheets in aOldSheets with the stylesheets in
|
||||
* aNewSheets. The two lists must have equal length, and the sheet
|
||||
* at positon J in the first list will be replaced by the sheet at
|
||||
* position J in the second list. Some sheets in the second list
|
||||
* may be null; if so the corresponding sheets in the first list
|
||||
* will simply be removed.
|
||||
*/
|
||||
NS_IMETHOD UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
|
||||
nsCOMArray<nsIStyleSheet>& aNewSheets) = 0;
|
||||
|
||||
/**
|
||||
* Add a stylesheet to the document
|
||||
*/
|
||||
virtual void AddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags) = 0;
|
||||
|
||||
/**
|
||||
* Remove a stylesheet from the document
|
||||
*/
|
||||
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that the applicable state of the sheet changed
|
||||
* and that observers should be notified and style sets updated
|
||||
*/
|
||||
virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
|
||||
PRBool aApplicable) = 0;
|
||||
|
||||
/**
|
||||
* Set the object from which a document can get a script context.
|
||||
|
|
|
@ -235,10 +235,10 @@ public:
|
|||
PRInt32 aIndexInContainer) = 0;
|
||||
|
||||
/**
|
||||
* A StyleSheet has just been added to the document.
|
||||
* This method is called automatically when a StyleSheet gets added
|
||||
* to the document. The notification is passed on to all of the
|
||||
* document observers.
|
||||
* A StyleSheet has just been added to the document. This method is
|
||||
* called automatically when a StyleSheet gets added to the
|
||||
* document, even if the stylesheet is not applicable. The
|
||||
* notification is passed on to all of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that has been added
|
||||
|
@ -247,32 +247,32 @@ public:
|
|||
nsIStyleSheet* aStyleSheet) = 0;
|
||||
|
||||
/**
|
||||
* A StyleSheet has just been removed from the document.
|
||||
* This method is called automatically when a StyleSheet gets removed
|
||||
* from the document. The notification is passed on to all of the
|
||||
* document observers.
|
||||
* A StyleSheet has just been removed from the document. This
|
||||
* method is called automatically when a StyleSheet gets removed
|
||||
* from the document, even if the stylesheet is not applicable. The
|
||||
* notification is passed on to all of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that has been removed
|
||||
*/
|
||||
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* A StyleSheet has just disabled or enabled.
|
||||
* This method is called automatically when the disabled state
|
||||
* A StyleSheet has just changed its applicable state.
|
||||
* This method is called automatically when the applicable state
|
||||
* of a StyleSheet gets changed. The style sheet passes this
|
||||
* notification to the document. The notification is passed on
|
||||
* to all of the document observers.
|
||||
*
|
||||
* @param aDocument The document being observed
|
||||
* @param aStyleSheet the StyleSheet that has been added
|
||||
* @param aDisabled PR_TRUE if the sheet is disabled, PR_FALSE if
|
||||
* it is enabled
|
||||
* @param aStyleSheet the StyleSheet that has changed state
|
||||
* @param aApplicable PR_TRUE if the sheet is applicable, PR_FALSE if
|
||||
* it is not applicable
|
||||
*/
|
||||
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDisabled) = 0;
|
||||
NS_IMETHOD StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aApplicable) = 0;
|
||||
|
||||
/**
|
||||
* A StyleRule has just been modified within a style sheet.
|
||||
|
@ -331,62 +331,62 @@ public:
|
|||
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument *aDocument) = 0;
|
||||
};
|
||||
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER \
|
||||
NS_IMETHOD BeginUpdate(nsIDocument* aDocument); \
|
||||
NS_IMETHOD EndUpdate(nsIDocument* aDocument); \
|
||||
NS_IMETHOD BeginLoad(nsIDocument* aDocument); \
|
||||
NS_IMETHOD EndLoad(nsIDocument* aDocument); \
|
||||
NS_IMETHOD BeginReflow(nsIDocument* aDocument, \
|
||||
nsIPresShell* aShell); \
|
||||
NS_IMETHOD EndReflow(nsIDocument* aDocument, \
|
||||
nsIPresShell* aShell); \
|
||||
NS_IMETHOD ContentChanged(nsIDocument* aDocument, \
|
||||
nsIContent* aContent, \
|
||||
nsISupports* aSubContent); \
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument, \
|
||||
nsIContent* aContent1, \
|
||||
nsIContent* aContent2, \
|
||||
PRInt32 aStateMask); \
|
||||
NS_IMETHOD AttributeChanged(nsIDocument* aDocument, \
|
||||
nsIContent* aContent, \
|
||||
PRInt32 aNameSpaceID, \
|
||||
nsIAtom* aAttribute, \
|
||||
PRInt32 aModType, \
|
||||
nsChangeHint aHint); \
|
||||
NS_IMETHOD ContentAppended(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
PRInt32 aNewIndexInContainer); \
|
||||
NS_IMETHOD ContentInserted(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
nsIContent* aChild, \
|
||||
PRInt32 aIndexInContainer); \
|
||||
NS_IMETHOD ContentReplaced(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
nsIContent* aOldChild, \
|
||||
nsIContent* aNewChild, \
|
||||
PRInt32 aIndexInContainer); \
|
||||
NS_IMETHOD ContentRemoved(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
nsIContent* aChild, \
|
||||
PRInt32 aIndexInContainer); \
|
||||
NS_IMETHOD StyleSheetAdded(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet); \
|
||||
NS_IMETHOD StyleSheetRemoved(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet); \
|
||||
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
PRBool aDisabled); \
|
||||
NS_IMETHOD StyleRuleChanged(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
nsIStyleRule* aStyleRule, \
|
||||
nsChangeHint aHint); \
|
||||
NS_IMETHOD StyleRuleAdded(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
nsIStyleRule* aStyleRule); \
|
||||
NS_IMETHOD StyleRuleRemoved(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
nsIStyleRule* aStyleRule); \
|
||||
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument* aDocument); \
|
||||
#define NS_DECL_NSIDOCUMENTOBSERVER \
|
||||
NS_IMETHOD BeginUpdate(nsIDocument* aDocument); \
|
||||
NS_IMETHOD EndUpdate(nsIDocument* aDocument); \
|
||||
NS_IMETHOD BeginLoad(nsIDocument* aDocument); \
|
||||
NS_IMETHOD EndLoad(nsIDocument* aDocument); \
|
||||
NS_IMETHOD BeginReflow(nsIDocument* aDocument, \
|
||||
nsIPresShell* aShell); \
|
||||
NS_IMETHOD EndReflow(nsIDocument* aDocument, \
|
||||
nsIPresShell* aShell); \
|
||||
NS_IMETHOD ContentChanged(nsIDocument* aDocument, \
|
||||
nsIContent* aContent, \
|
||||
nsISupports* aSubContent); \
|
||||
NS_IMETHOD ContentStatesChanged(nsIDocument* aDocument, \
|
||||
nsIContent* aContent1, \
|
||||
nsIContent* aContent2, \
|
||||
PRInt32 aStateMask); \
|
||||
NS_IMETHOD AttributeChanged(nsIDocument* aDocument, \
|
||||
nsIContent* aContent, \
|
||||
PRInt32 aNameSpaceID, \
|
||||
nsIAtom* aAttribute, \
|
||||
PRInt32 aModType, \
|
||||
nsChangeHint aHint); \
|
||||
NS_IMETHOD ContentAppended(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
PRInt32 aNewIndexInContainer); \
|
||||
NS_IMETHOD ContentInserted(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
nsIContent* aChild, \
|
||||
PRInt32 aIndexInContainer); \
|
||||
NS_IMETHOD ContentReplaced(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
nsIContent* aOldChild, \
|
||||
nsIContent* aNewChild, \
|
||||
PRInt32 aIndexInContainer); \
|
||||
NS_IMETHOD ContentRemoved(nsIDocument* aDocument, \
|
||||
nsIContent* aContainer, \
|
||||
nsIContent* aChild, \
|
||||
PRInt32 aIndexInContainer); \
|
||||
NS_IMETHOD StyleSheetAdded(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet); \
|
||||
NS_IMETHOD StyleSheetRemoved(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet); \
|
||||
NS_IMETHOD StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
PRBool aApplicable); \
|
||||
NS_IMETHOD StyleRuleChanged(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
nsIStyleRule* aStyleRule, \
|
||||
nsChangeHint aHint); \
|
||||
NS_IMETHOD StyleRuleAdded(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
nsIStyleRule* aStyleRule); \
|
||||
NS_IMETHOD StyleRuleRemoved(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
nsIStyleRule* aStyleRule); \
|
||||
NS_IMETHOD DocumentWillBeDestroyed(nsIDocument* aDocument); \
|
||||
|
||||
|
||||
#define NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(_class) \
|
||||
|
@ -507,9 +507,9 @@ _class::StyleSheetRemoved(nsIDocument* aDocument, \
|
|||
return NS_OK; \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
_class::StyleSheetDisabledStateChanged(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
PRBool aDisabled) \
|
||||
_class::StyleSheetApplicableStateChanged(nsIDocument* aDocument, \
|
||||
nsIStyleSheet* aStyleSheet, \
|
||||
PRBool aApplicable) \
|
||||
{ \
|
||||
return NS_OK; \
|
||||
} \
|
||||
|
|
|
@ -70,9 +70,27 @@ public:
|
|||
NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const = 0;
|
||||
NS_IMETHOD_(PRBool) UseForMedium(nsIAtom* aMedium) const = 0;
|
||||
|
||||
NS_IMETHOD GetEnabled(PRBool& aEnabled) const = 0;
|
||||
/**
|
||||
* Whether the sheet is applicable. A sheet that is not applicable
|
||||
* should never be inserted into a style set. A sheet may not be
|
||||
* applicable for a variety of reasons including being disabled and
|
||||
* being incomplete.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetApplicable(PRBool& aApplicable) const = 0;
|
||||
|
||||
/**
|
||||
* Set the stylesheet to be enabled. This may or may not make it
|
||||
* applicable.
|
||||
*/
|
||||
NS_IMETHOD SetEnabled(PRBool aEnabled) = 0;
|
||||
|
||||
/**
|
||||
* Whether the sheet is complete.
|
||||
*/
|
||||
NS_IMETHOD GetComplete(PRBool& aComplete) const = 0;
|
||||
NS_IMETHOD SetComplete() = 0;
|
||||
|
||||
// style sheet owner info
|
||||
NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const = 0; // may be null
|
||||
NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const = 0; // may be null
|
||||
|
|
|
@ -88,12 +88,8 @@ public:
|
|||
* @param aOldDocument the document that this element was part
|
||||
* of (nsnull if we're not moving the element
|
||||
* from one document to another).
|
||||
* @param aDocIndex index of the stylesheet in the document's
|
||||
* stylesheet list. -1 means we'll look up the
|
||||
* index from the position of the element.
|
||||
*/
|
||||
NS_IMETHOD UpdateStyleSheet(nsIDocument *aOldDocument,
|
||||
PRInt32 aDocIndex) = 0;
|
||||
NS_IMETHOD UpdateStyleSheet(nsIDocument *aOldDocument) = 0;
|
||||
|
||||
/**
|
||||
* Tells this element wether to update the stylesheet when the
|
||||
|
|
|
@ -202,22 +202,17 @@ nsDOMStyleSheetList::GetLength(PRUint32* aLength)
|
|||
// observer notification to figure out if new ones have
|
||||
// been added or removed.
|
||||
if (-1 == mLength) {
|
||||
PRUint32 count = 0;
|
||||
PRInt32 i, imax = 0;
|
||||
mDocument->GetNumberOfStyleSheets(&imax);
|
||||
mDocument->GetNumberOfStyleSheets(PR_FALSE, &mLength);
|
||||
|
||||
for (i = 0; i < imax; i++) {
|
||||
#ifdef DEBUG
|
||||
PRInt32 i;
|
||||
for (i = 0; i < mLength; i++) {
|
||||
nsCOMPtr<nsIStyleSheet> sheet;
|
||||
mDocument->GetStyleSheetAt(i, getter_AddRefs(sheet));
|
||||
if (!sheet)
|
||||
continue;
|
||||
mDocument->GetStyleSheetAt(i, PR_FALSE, getter_AddRefs(sheet));
|
||||
nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(sheet));
|
||||
|
||||
if (domss) {
|
||||
count++;
|
||||
}
|
||||
NS_ASSERTION(domss, "All \"normal\" sheets implement nsIDOMStyleSheet");
|
||||
}
|
||||
mLength = count;
|
||||
#endif
|
||||
}
|
||||
*aLength = mLength;
|
||||
}
|
||||
|
@ -232,25 +227,14 @@ NS_IMETHODIMP
|
|||
nsDOMStyleSheetList::Item(PRUint32 aIndex, nsIDOMStyleSheet** aReturn)
|
||||
{
|
||||
*aReturn = nsnull;
|
||||
if (nsnull != mDocument) {
|
||||
PRUint32 count = 0;
|
||||
PRInt32 i, imax = 0;
|
||||
mDocument->GetNumberOfStyleSheets(&imax);
|
||||
|
||||
// XXX Not particularly efficient, but does anyone care?
|
||||
for (i = 0; (i < imax) && (nsnull == *aReturn); i++) {
|
||||
if (mDocument) {
|
||||
PRInt32 count = 0;
|
||||
mDocument->GetNumberOfStyleSheets(PR_FALSE, &count);
|
||||
if (aIndex < count) {
|
||||
nsCOMPtr<nsIStyleSheet> sheet;
|
||||
mDocument->GetStyleSheetAt(i, getter_AddRefs(sheet));
|
||||
if (!sheet)
|
||||
continue;
|
||||
nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(sheet));
|
||||
|
||||
if (domss) {
|
||||
if (count++ == aIndex) {
|
||||
*aReturn = domss;
|
||||
NS_IF_ADDREF(*aReturn);
|
||||
}
|
||||
}
|
||||
mDocument->GetStyleSheetAt(aIndex, PR_FALSE, getter_AddRefs(sheet));
|
||||
NS_ASSERTION(sheet, "Must have a sheet");
|
||||
return CallQueryInterface(sheet, aReturn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -782,17 +766,12 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup)
|
|||
nsIStyleSheet* sheet = mStyleSheets[indx];
|
||||
sheet->SetOwningDocument(nsnull);
|
||||
|
||||
PRInt32 pscount = mPresShells.Count();
|
||||
PRInt32 psindex;
|
||||
for (psindex = 0; psindex < pscount; psindex++) {
|
||||
nsCOMPtr<nsIPresShell> shell =
|
||||
(nsIPresShell*)mPresShells.ElementAt(psindex);
|
||||
nsCOMPtr<nsIStyleSet> set;
|
||||
if (NS_SUCCEEDED(shell->GetStyleSet(getter_AddRefs(set))) && set) {
|
||||
set->RemoveDocStyleSheet(sheet);
|
||||
}
|
||||
PRBool applicable;
|
||||
sheet->GetApplicable(applicable);
|
||||
if (applicable) {
|
||||
RemoveStyleSheetFromStyleSets(sheet);
|
||||
}
|
||||
|
||||
|
||||
// XXX Tell observers?
|
||||
}
|
||||
// Release all the sheets
|
||||
|
@ -1442,21 +1421,51 @@ nsDocument::GetChildCount(PRInt32& aCount)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetNumberOfStyleSheets(PRInt32* aCount)
|
||||
PRInt32
|
||||
nsDocument::InternalGetNumberOfStyleSheets()
|
||||
{
|
||||
*aCount = mStyleSheets.Count();
|
||||
return NS_OK;
|
||||
return mStyleSheets.Count();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetStyleSheetAt(PRInt32 aIndex, nsIStyleSheet** aSheet)
|
||||
nsDocument::GetNumberOfStyleSheets(PRBool aIncludeSpecialSheets,
|
||||
PRInt32* aCount)
|
||||
{
|
||||
if (aIncludeSpecialSheets) {
|
||||
*aCount = mStyleSheets.Count();
|
||||
} else {
|
||||
*aCount = InternalGetNumberOfStyleSheets();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIStyleSheet>
|
||||
nsDocument::InternalGetStyleSheetAt(PRInt32 aIndex)
|
||||
{
|
||||
if (aIndex >= 0 && aIndex < mStyleSheets.Count()) {
|
||||
*aSheet = mStyleSheets[aIndex];
|
||||
NS_ADDREF(*aSheet);
|
||||
nsIStyleSheet* sheet = mStyleSheets[aIndex];
|
||||
NS_ADDREF(sheet);
|
||||
return sheet;
|
||||
} else {
|
||||
*aSheet = nsnull;
|
||||
NS_ERROR("Index out of range");
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetStyleSheetAt(PRInt32 aIndex, PRBool aIncludeSpecialSheets,
|
||||
nsIStyleSheet** aSheet)
|
||||
{
|
||||
if (aIncludeSpecialSheets) {
|
||||
if (aIndex >= 0 && aIndex < mStyleSheets.Count()) {
|
||||
*aSheet = mStyleSheets[aIndex];
|
||||
NS_ADDREF(*aSheet);
|
||||
} else {
|
||||
NS_ERROR("Index out of range");
|
||||
*aSheet = nsnull;
|
||||
}
|
||||
} else {
|
||||
*aSheet = InternalGetStyleSheetAt(aIndex).get();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1492,26 +1501,23 @@ void nsDocument::AddStyleSheetToStyleSets(nsIStyleSheet* aSheet)
|
|||
|
||||
void nsDocument::AddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
NS_PRECONDITION(aSheet, "null arg");
|
||||
InternalAddStyleSheet(aSheet, aFlags);
|
||||
aSheet->SetOwningDocument(this);
|
||||
|
||||
PRBool enabled = PR_TRUE;
|
||||
aSheet->GetEnabled(enabled);
|
||||
|
||||
if (enabled) {
|
||||
PRBool applicable;
|
||||
aSheet->GetApplicable(applicable);
|
||||
|
||||
if (applicable) {
|
||||
AddStyleSheetToStyleSets(aSheet);
|
||||
|
||||
// XXX should observers be notified for disabled sheets??? I think not, but I could be wrong
|
||||
for (PRInt32 indx = 0; indx < mObservers.Count(); ++indx) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(indx);
|
||||
observer->StyleSheetAdded(this, aSheet);
|
||||
// handle the observer removing itself!
|
||||
if (observer != (nsIDocumentObserver*)mObservers.ElementAt(indx)) {
|
||||
indx--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if an observer removes itself, we're ok (not if it removes others though)
|
||||
PRInt32 i;
|
||||
for (i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(i);
|
||||
observer->StyleSheetAdded(this, aSheet);
|
||||
}
|
||||
}
|
||||
|
||||
void nsDocument::RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet)
|
||||
|
@ -1539,20 +1545,17 @@ void nsDocument::RemoveStyleSheet(nsIStyleSheet* aSheet)
|
|||
return;
|
||||
}
|
||||
|
||||
PRBool enabled = PR_TRUE;
|
||||
aSheet->GetEnabled(enabled);
|
||||
if (!mIsGoingAway) {
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
if (applicable) {
|
||||
RemoveStyleSheetFromStyleSets(aSheet);
|
||||
}
|
||||
|
||||
if (enabled && !mIsGoingAway) {
|
||||
RemoveStyleSheetFromStyleSets(aSheet);
|
||||
|
||||
// XXX should observers be notified for disabled sheets??? I think not, but I could be wrong
|
||||
for (PRInt32 indx = 0; indx < mObservers.Count(); ++indx) {
|
||||
// if an observer removes itself, we're ok (not if it removes others though)
|
||||
for (PRInt32 indx = mObservers.Count() - 1; indx >= 0; --indx) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(indx);
|
||||
observer->StyleSheetRemoved(this, aSheet);
|
||||
// handle the observer removing itself!
|
||||
if (observer != (nsIDocumentObserver*)mObservers.ElementAt(indx)) {
|
||||
indx--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1560,55 +1563,63 @@ void nsDocument::RemoveStyleSheet(nsIStyleSheet* aSheet)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::UpdateStyleSheets(nsISupportsArray* aOldSheets, nsISupportsArray* aNewSheets)
|
||||
nsDocument::UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
|
||||
nsCOMArray<nsIStyleSheet>& aNewSheets)
|
||||
{
|
||||
PRUint32 oldCount;
|
||||
aOldSheets->Count(&oldCount);
|
||||
nsCOMPtr<nsIStyleSheet> sheet;
|
||||
PRUint32 i;
|
||||
for (i = 0; i < oldCount; i++) {
|
||||
sheet = do_QueryElementAt(aOldSheets, i);
|
||||
if (sheet) {
|
||||
PRBool found = mStyleSheets.RemoveObject(sheet);
|
||||
NS_ASSERTION(found, "stylesheet not found");
|
||||
if (found) {
|
||||
PRBool enabled = PR_TRUE;
|
||||
sheet->GetEnabled(enabled);
|
||||
if (enabled) {
|
||||
RemoveStyleSheetFromStyleSets(sheet);
|
||||
}
|
||||
// XXX Need to set the sheet on the ownernode, if any
|
||||
NS_PRECONDITION(aOldSheets.Count() == aNewSheets.Count(),
|
||||
"The lists must be the same length!");
|
||||
PRInt32 count = aOldSheets.Count();
|
||||
|
||||
sheet->SetOwningDocument(nsnull);
|
||||
nsCOMPtr<nsIStyleSheet> oldSheet;
|
||||
PRInt32 i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
oldSheet = aOldSheets[i];
|
||||
|
||||
// First remove the old sheet.
|
||||
NS_ASSERTION(oldSheet, "None of the old sheets should be null");
|
||||
PRInt32 oldIndex = mStyleSheets.IndexOf(oldSheet);
|
||||
NS_ASSERTION(oldIndex != -1, "stylesheet not found");
|
||||
mStyleSheets.RemoveObjectAt(oldIndex);
|
||||
|
||||
PRBool applicable = PR_TRUE;
|
||||
oldSheet->GetApplicable(applicable);
|
||||
if (applicable) {
|
||||
RemoveStyleSheetFromStyleSets(oldSheet);
|
||||
}
|
||||
// XXX we should really notify here, but right now that would
|
||||
// force things like a full reframe on every sheet. We really
|
||||
// need a way to batch this sucker...
|
||||
|
||||
oldSheet->SetOwningDocument(nsnull);
|
||||
|
||||
// Now put the new one in its place. If it's null, just ignore it.
|
||||
nsIStyleSheet* newSheet = aNewSheets[i];
|
||||
if (newSheet) {
|
||||
mStyleSheets.InsertObjectAt(newSheet, oldIndex);
|
||||
newSheet->SetOwningDocument(this);
|
||||
PRBool applicable = PR_TRUE;
|
||||
newSheet->GetApplicable(applicable);
|
||||
if (applicable) {
|
||||
AddStyleSheetToStyleSets(newSheet);
|
||||
}
|
||||
|
||||
// XXX we should be notifying here too.
|
||||
}
|
||||
}
|
||||
|
||||
PRUint32 newCount;
|
||||
aNewSheets->Count(&newCount);
|
||||
for (i = 0; i < newCount; i++) {
|
||||
sheet = do_QueryElementAt(aNewSheets, i);
|
||||
if (sheet) {
|
||||
InternalAddStyleSheet(sheet, 0);
|
||||
sheet->SetOwningDocument(this);
|
||||
|
||||
PRBool enabled = PR_TRUE;
|
||||
sheet->GetEnabled(enabled);
|
||||
if (enabled) {
|
||||
AddStyleSheetToStyleSets(sheet);
|
||||
}
|
||||
// Now notify so _something_ happens, assuming we did anything
|
||||
if (oldSheet) {
|
||||
// if an observer removes itself, we're ok (not if it removes
|
||||
// others though)
|
||||
// XXXldb Hopefully the observer doesn't care which sheet you use.
|
||||
for (PRInt32 indx = mObservers.Count() - 1; indx >= 0; --indx) {
|
||||
nsIDocumentObserver* observer =
|
||||
(nsIDocumentObserver*)mObservers.ElementAt(indx);
|
||||
observer->StyleSheetRemoved(this, oldSheet);
|
||||
}
|
||||
}
|
||||
|
||||
// XXXldb Hopefully the observer doesn't care which sheet you use.
|
||||
for (PRInt32 indx = 0; indx < mObservers.Count(); ++indx) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(indx);
|
||||
observer->StyleSheetRemoved(this, sheet);
|
||||
// handle the observer removing itself!
|
||||
if (observer != (nsIDocumentObserver*)mObservers.ElementAt(indx)) {
|
||||
indx--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1620,77 +1631,54 @@ nsDocument::InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex, PRBool aNotify)
|
||||
nsDocument::InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null ptr");
|
||||
NS_PRECONDITION(aSheet, "null ptr");
|
||||
InternalInsertStyleSheetAt(aSheet, aIndex);
|
||||
|
||||
aSheet->SetOwningDocument(this);
|
||||
|
||||
PRBool enabled = PR_TRUE;
|
||||
aSheet->GetEnabled(enabled);
|
||||
PRBool applicable;
|
||||
aSheet->GetApplicable(applicable);
|
||||
|
||||
if (applicable) {
|
||||
AddStyleSheetToStyleSets(aSheet);
|
||||
}
|
||||
|
||||
PRInt32 count;
|
||||
PRInt32 indx;
|
||||
if (enabled) {
|
||||
count = mPresShells.Count();
|
||||
for (indx = 0; indx < count; ++indx) {
|
||||
nsCOMPtr<nsIPresShell> shell =
|
||||
(nsIPresShell*)mPresShells.ElementAt(indx);
|
||||
nsCOMPtr<nsIStyleSet> set;
|
||||
shell->GetStyleSet(getter_AddRefs(set));
|
||||
if (set) {
|
||||
set->AddDocStyleSheet(aSheet, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aNotify) { // notify here even if disabled, there may have been others that weren't notified
|
||||
for (indx = 0; indx < mObservers.Count(); ++indx) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(indx);
|
||||
observer->StyleSheetAdded(this, aSheet);
|
||||
// handle the observer removing itself!
|
||||
if (observer != (nsIDocumentObserver*)mObservers.ElementAt(indx)) {
|
||||
indx--;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if an observer removes itself, we're ok (not if it removes others though)
|
||||
PRInt32 i;
|
||||
for (i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(i);
|
||||
observer->StyleSheetAdded(this, aSheet);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void nsDocument::SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
|
||||
PRBool aDisabled)
|
||||
void nsDocument::SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
|
||||
PRBool aApplicable)
|
||||
{
|
||||
NS_PRECONDITION(aSheet, "null arg");
|
||||
PRInt32 indx = mStyleSheets.IndexOf(aSheet);
|
||||
|
||||
PRInt32 indx;
|
||||
PRInt32 count;
|
||||
// If we're actually in the document style sheet list
|
||||
if (-1 != indx) {
|
||||
count = mPresShells.Count();
|
||||
for (indx = 0; indx < count; ++indx) {
|
||||
nsCOMPtr<nsIPresShell> shell =
|
||||
(nsIPresShell*)mPresShells.ElementAt(indx);
|
||||
nsCOMPtr<nsIStyleSet> set;
|
||||
if (NS_SUCCEEDED(shell->GetStyleSet(getter_AddRefs(set)))) {
|
||||
if (set) {
|
||||
if (aDisabled) {
|
||||
set->RemoveDocStyleSheet(aSheet);
|
||||
}
|
||||
else {
|
||||
set->AddDocStyleSheet(aSheet, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (-1 != mStyleSheets.IndexOf(aSheet)) {
|
||||
if (aApplicable) {
|
||||
AddStyleSheetToStyleSets(aSheet);
|
||||
} else {
|
||||
RemoveStyleSheetFromStyleSets(aSheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (indx = 0; indx < mObservers.Count(); ++indx) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(indx);
|
||||
observer->StyleSheetDisabledStateChanged(this, aSheet, aDisabled);
|
||||
// handle the observer removing itself!
|
||||
if (observer != (nsIDocumentObserver*)mObservers.ElementAt(indx)) {
|
||||
indx--;
|
||||
}
|
||||
// XXX Some (nsHTMLEditor, eg) call this function for sheets that
|
||||
// are not document sheets! So we have to always notify.
|
||||
|
||||
// if an observer removes itself, we're ok (not if it removes others though)
|
||||
for (indx = mObservers.Count() - 1; indx >= 0; --indx) {
|
||||
nsIDocumentObserver* observer =
|
||||
(nsIDocumentObserver*)mObservers.ElementAt(indx);
|
||||
observer->StyleSheetApplicableStateChanged(this, aSheet, aApplicable);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@
|
|||
#include "nsINodeInfo.h"
|
||||
#include "nsIDOMDocumentEvent.h"
|
||||
#include "nsIDOM3DocumentEvent.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIWordBreakerFactory.h"
|
||||
|
@ -203,9 +202,9 @@ public:
|
|||
nsIStyleSheet* aStyleSheet);
|
||||
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet);
|
||||
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDisabled) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aApplicable) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule,
|
||||
|
@ -429,21 +428,22 @@ public:
|
|||
* Get the style sheets owned by this document.
|
||||
* These are ordered, highest priority last
|
||||
*/
|
||||
NS_IMETHOD GetNumberOfStyleSheets(PRInt32* aCount);
|
||||
NS_IMETHOD GetStyleSheetAt(PRInt32 aIndex, nsIStyleSheet** aSheet);
|
||||
NS_IMETHOD GetNumberOfStyleSheets(PRBool aIncludeSpecialSheets,
|
||||
PRInt32* aCount);
|
||||
NS_IMETHOD GetStyleSheetAt(PRInt32 aIndex, PRBool aIncludeSpecialSheets,
|
||||
nsIStyleSheet** aSheet);
|
||||
NS_IMETHOD GetIndexOfStyleSheet(nsIStyleSheet* aSheet, PRInt32* aIndex);
|
||||
virtual void AddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags);
|
||||
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet);
|
||||
|
||||
NS_IMETHOD UpdateStyleSheets(nsISupportsArray* aOldSheets,
|
||||
nsISupportsArray* aNewSheets);
|
||||
NS_IMETHOD UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
|
||||
nsCOMArray<nsIStyleSheet>& aNewSheets);
|
||||
virtual void AddStyleSheetToStyleSets(nsIStyleSheet* aSheet);
|
||||
virtual void RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet);
|
||||
|
||||
NS_IMETHOD InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex,
|
||||
PRBool aNotify);
|
||||
virtual void SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
|
||||
PRBool mDisabled);
|
||||
NS_IMETHOD InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex);
|
||||
virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
|
||||
PRBool aApplicable);
|
||||
|
||||
/**
|
||||
* Set the object from which a document can get a script context.
|
||||
|
@ -609,6 +609,8 @@ protected:
|
|||
PRUint32 aFlags);
|
||||
virtual void InternalInsertStyleSheetAt(nsIStyleSheet* aSheet,
|
||||
PRInt32 aIndex);
|
||||
virtual already_AddRefed<nsIStyleSheet> InternalGetStyleSheetAt(PRInt32 aIndex);
|
||||
virtual PRInt32 InternalGetNumberOfStyleSheets();
|
||||
|
||||
nsDocument();
|
||||
virtual ~nsDocument();
|
||||
|
|
|
@ -1661,21 +1661,21 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument,
|
|||
rv = CallCreateInstance(kStyleSetCID, aStyleSet);
|
||||
if (NS_OK == rv) {
|
||||
PRInt32 index = 0;
|
||||
aDocument->GetNumberOfStyleSheets(&index);
|
||||
aDocument->GetNumberOfStyleSheets(PR_TRUE, &index);
|
||||
|
||||
while (0 < index--) {
|
||||
nsCOMPtr<nsIStyleSheet> sheet;
|
||||
aDocument->GetStyleSheetAt(index, getter_AddRefs(sheet));
|
||||
aDocument->GetStyleSheetAt(index, PR_TRUE, getter_AddRefs(sheet));
|
||||
|
||||
/*
|
||||
* GetStyleSheetAt will return all style sheets in the document but
|
||||
* we're only interested in the ones that are enabled.
|
||||
*/
|
||||
|
||||
PRBool styleEnabled;
|
||||
sheet->GetEnabled(styleEnabled);
|
||||
PRBool styleApplicable;
|
||||
sheet->GetApplicable(styleApplicable);
|
||||
|
||||
if (styleEnabled) {
|
||||
if (styleApplicable) {
|
||||
(*aStyleSet)->AddDocStyleSheet(sheet, aDocument);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
@ -53,7 +54,16 @@ NS_IMETHODIMP
|
|||
nsStyleLinkElement::SetStyleSheet(nsIStyleSheet* aStyleSheet)
|
||||
{
|
||||
mStyleSheet = aStyleSheet;
|
||||
|
||||
nsCOMPtr<nsICSSStyleSheet> cssSheet = do_QueryInterface(aStyleSheet);
|
||||
if (cssSheet) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
CallQueryInterface(this,
|
||||
NS_STATIC_CAST(nsIDOMNode**, getter_AddRefs(node)));
|
||||
if (node) {
|
||||
cssSheet->SetOwningNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -153,8 +163,7 @@ const PRBool kBlockByDefault=PR_TRUE;
|
|||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStyleLinkElement::UpdateStyleSheet(nsIDocument *aOldDocument,
|
||||
PRInt32 aDocIndex)
|
||||
nsStyleLinkElement::UpdateStyleSheet(nsIDocument *aOldDocument)
|
||||
{
|
||||
if (mDontLoadStyle || !mUpdatesEnabled) {
|
||||
return NS_OK;
|
||||
|
@ -255,76 +264,6 @@ nsStyleLinkElement::UpdateStyleSheet(nsIDocument *aOldDocument,
|
|||
}
|
||||
*/
|
||||
|
||||
// The way we determine the stylesheet's position in the cascade is by looking
|
||||
// at the first of the next siblings that are style linking elements, and
|
||||
// insert just before that one. I'm not sure this is correct for every case for
|
||||
// XML documents (it seems to be all right for HTML). The sink should disable
|
||||
// this search by directly specifying a position.
|
||||
PRInt32 insertionPoint;
|
||||
|
||||
if (aDocIndex > -1) {
|
||||
insertionPoint = aDocIndex;
|
||||
}
|
||||
else {
|
||||
// We're not getting them in document order, look for where to insert.
|
||||
nsCOMPtr<nsIDOMNode> parentNode;
|
||||
nsCOMPtr<nsIStyleSheet> nextSheet;
|
||||
PRUint16 nodeType = 0;
|
||||
nsCOMPtr<nsIDOMNode> thisNode(do_QueryInterface(thisContent));
|
||||
nsCOMPtr<nsIContent> nextNode;
|
||||
nsCOMPtr<nsIStyleSheetLinkingElement> nextLink;
|
||||
|
||||
thisNode->GetParentNode(getter_AddRefs(parentNode));
|
||||
if (parentNode)
|
||||
parentNode->GetNodeType(&nodeType);
|
||||
if (nodeType == nsIDOMNode::DOCUMENT_NODE) {
|
||||
nsCOMPtr<nsIDocument> parent(do_QueryInterface(parentNode));
|
||||
if (parent) {
|
||||
PRInt32 index, count;
|
||||
|
||||
parent->GetChildCount(count);
|
||||
parent->IndexOf(thisContent, index);
|
||||
while (++index < count) {
|
||||
parent->ChildAt(index, *getter_AddRefs(nextNode));
|
||||
nextLink = do_QueryInterface(nextNode);
|
||||
if (nextLink) {
|
||||
nextLink->GetStyleSheet(*getter_AddRefs(nextSheet));
|
||||
if (nextSheet)
|
||||
// Found the first following sibling that is a style linking element.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIContent> parent(do_QueryInterface(parentNode));
|
||||
if (parent) {
|
||||
PRInt32 index, count;
|
||||
|
||||
parent->ChildCount(count);
|
||||
parent->IndexOf(thisContent, index);
|
||||
while (++index < count) {
|
||||
parent->ChildAt(index, *getter_AddRefs(nextNode));
|
||||
nextLink = do_QueryInterface(nextNode);
|
||||
if (nextLink) {
|
||||
nextLink->GetStyleSheet(*getter_AddRefs(nextSheet));
|
||||
if (nextSheet)
|
||||
// Found the first following sibling that is a style linking element.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nextSheet) {
|
||||
PRInt32 sheetIndex = 0;
|
||||
doc->GetIndexOfStyleSheet(nextSheet, &sheetIndex);
|
||||
insertionPoint = sheetIndex - 1;
|
||||
}
|
||||
else {
|
||||
doc->GetNumberOfStyleSheets(&insertionPoint);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAlternate && !title.IsEmpty()) { // possibly preferred sheet
|
||||
nsAutoString prefStyle;
|
||||
doc->GetHeaderData(nsHTMLAtoms::headerDefaultStyle, prefStyle);
|
||||
|
@ -373,13 +312,13 @@ nsStyleLinkElement::UpdateStyleSheet(nsIDocument *aOldDocument,
|
|||
// Now that we have a url and a unicode input stream, parse the
|
||||
// style sheet.
|
||||
rv = loader->LoadInlineStyle(thisContent, uin, title, media,
|
||||
kNameSpaceID_Unknown, insertionPoint,
|
||||
kNameSpaceID_Unknown,
|
||||
((blockParser) ? parser.get() : nsnull),
|
||||
doneLoading, nsnull);
|
||||
}
|
||||
else {
|
||||
rv = loader->LoadStyleLink(thisContent, uri, title, media,
|
||||
kNameSpaceID_Unknown, insertionPoint,
|
||||
kNameSpaceID_Unknown,
|
||||
((blockParser) ? parser.get() : nsnull),
|
||||
doneLoading, nsnull);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
NS_IMETHOD SetStyleSheet(nsIStyleSheet* aStyleSheet);
|
||||
NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aStyleSheet);
|
||||
NS_IMETHOD InitStyleLinkElement(nsIParser *aParser, PRBool aDontLoadStyle);
|
||||
NS_IMETHOD UpdateStyleSheet(nsIDocument *aOldDocument = nsnull, PRInt32 aDocIndex = -1);
|
||||
NS_IMETHOD UpdateStyleSheet(nsIDocument *aOldDocument = nsnull);
|
||||
NS_IMETHOD SetEnableUpdates(PRBool aEnableUpdates);
|
||||
NS_IMETHOD GetCharset(nsAString& aCharset);
|
||||
|
||||
|
|
|
@ -568,6 +568,11 @@ StyleSetImpl::GatherRuleProcessors(void)
|
|||
void StyleSetImpl::AppendOverrideStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mOverrideSheets)) {
|
||||
mOverrideSheets->RemoveElement(aSheet);
|
||||
mOverrideSheets->AppendElement(aSheet);
|
||||
|
@ -579,6 +584,11 @@ void StyleSetImpl::InsertOverrideStyleSheetAfter(nsIStyleSheet* aSheet,
|
|||
nsIStyleSheet* aAfterSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mOverrideSheets)) {
|
||||
mOverrideSheets->RemoveElement(aSheet);
|
||||
PRInt32 index = mOverrideSheets->IndexOf(aAfterSheet);
|
||||
|
@ -591,6 +601,11 @@ void StyleSetImpl::InsertOverrideStyleSheetBefore(nsIStyleSheet* aSheet,
|
|||
nsIStyleSheet* aBeforeSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mOverrideSheets)) {
|
||||
mOverrideSheets->RemoveElement(aSheet);
|
||||
PRInt32 index = mOverrideSheets->IndexOf(aBeforeSheet);
|
||||
|
@ -602,7 +617,11 @@ void StyleSetImpl::InsertOverrideStyleSheetBefore(nsIStyleSheet* aSheet,
|
|||
void StyleSetImpl::RemoveOverrideStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool complete = PR_TRUE;
|
||||
aSheet->GetComplete(complete);
|
||||
NS_ASSERTION(complete, "Incomplete sheet being removed from style set");
|
||||
#endif
|
||||
if (nsnull != mOverrideSheets) {
|
||||
mOverrideSheets->RemoveElement(aSheet);
|
||||
ClearOverrideRuleProcessors();
|
||||
|
@ -634,6 +653,11 @@ nsIStyleSheet* StyleSetImpl::GetOverrideStyleSheetAt(PRInt32 aIndex)
|
|||
void StyleSetImpl::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument)
|
||||
{
|
||||
NS_PRECONDITION((nsnull != aSheet) && (nsnull != aDocument), "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mDocSheets)) {
|
||||
mDocSheets->RemoveElement(aSheet);
|
||||
// lowest index last
|
||||
|
@ -670,7 +694,11 @@ void StyleSetImpl::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocumen
|
|||
void StyleSetImpl::RemoveDocStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool complete = PR_TRUE;
|
||||
aSheet->GetComplete(complete);
|
||||
NS_ASSERTION(complete, "Incomplete sheet being removed from style set");
|
||||
#endif
|
||||
if (nsnull != mDocSheets) {
|
||||
mDocSheets->RemoveElement(aSheet);
|
||||
ClearDocRuleProcessors();
|
||||
|
@ -702,6 +730,11 @@ nsIStyleSheet* StyleSetImpl::GetDocStyleSheetAt(PRInt32 aIndex)
|
|||
void StyleSetImpl::AppendUserStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mUserSheets)) {
|
||||
mUserSheets->RemoveElement(aSheet);
|
||||
mUserSheets->AppendElement(aSheet);
|
||||
|
@ -713,6 +746,11 @@ void StyleSetImpl::InsertUserStyleSheetAfter(nsIStyleSheet* aSheet,
|
|||
nsIStyleSheet* aAfterSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mUserSheets)) {
|
||||
mUserSheets->RemoveElement(aSheet);
|
||||
PRInt32 index = mUserSheets->IndexOf(aAfterSheet);
|
||||
|
@ -725,6 +763,11 @@ void StyleSetImpl::InsertUserStyleSheetBefore(nsIStyleSheet* aSheet,
|
|||
nsIStyleSheet* aBeforeSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mUserSheets)) {
|
||||
mUserSheets->RemoveElement(aSheet);
|
||||
PRInt32 index = mUserSheets->IndexOf(aBeforeSheet);
|
||||
|
@ -736,7 +779,11 @@ void StyleSetImpl::InsertUserStyleSheetBefore(nsIStyleSheet* aSheet,
|
|||
void StyleSetImpl::RemoveUserStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool complete = PR_TRUE;
|
||||
aSheet->GetComplete(complete);
|
||||
NS_ASSERTION(complete, "Incomplete sheet being removed from style set");
|
||||
#endif
|
||||
if (nsnull != mUserSheets) {
|
||||
mUserSheets->RemoveElement(aSheet);
|
||||
ClearUserRuleProcessors();
|
||||
|
@ -775,6 +822,11 @@ StyleSetImpl::ReplaceUserStyleSheets(nsISupportsArray* aNewUserSheets)
|
|||
void StyleSetImpl::AppendAgentStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mAgentSheets)) {
|
||||
mAgentSheets->RemoveElement(aSheet);
|
||||
mAgentSheets->AppendElement(aSheet);
|
||||
|
@ -786,6 +838,11 @@ void StyleSetImpl::InsertAgentStyleSheetAfter(nsIStyleSheet* aSheet,
|
|||
nsIStyleSheet* aAfterSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mAgentSheets)) {
|
||||
mAgentSheets->RemoveElement(aSheet);
|
||||
PRInt32 index = mAgentSheets->IndexOf(aAfterSheet);
|
||||
|
@ -798,6 +855,11 @@ void StyleSetImpl::InsertAgentStyleSheetBefore(nsIStyleSheet* aSheet,
|
|||
nsIStyleSheet* aBeforeSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mAgentSheets)) {
|
||||
mAgentSheets->RemoveElement(aSheet);
|
||||
PRInt32 index = mAgentSheets->IndexOf(aBeforeSheet);
|
||||
|
@ -809,7 +871,11 @@ void StyleSetImpl::InsertAgentStyleSheetBefore(nsIStyleSheet* aSheet,
|
|||
void StyleSetImpl::RemoveAgentStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool complete = PR_TRUE;
|
||||
aSheet->GetComplete(complete);
|
||||
NS_ASSERTION(complete, "Incomplete sheet being removed from style set");
|
||||
#endif
|
||||
if (nsnull != mAgentSheets) {
|
||||
mAgentSheets->RemoveElement(aSheet);
|
||||
ClearAgentRuleProcessors();
|
||||
|
@ -870,10 +936,10 @@ NS_IMETHODIMP StyleSetImpl::EnableQuirkStyleSheet(PRBool aEnable)
|
|||
PRUint32 count = 0;
|
||||
if (mAgentRuleProcessors)
|
||||
mAgentRuleProcessors->Count(&count);
|
||||
PRBool enabledNow;
|
||||
mQuirkStyleSheet->GetEnabled(enabledNow);
|
||||
NS_ASSERTION(count == 0 || aEnable == enabledNow,
|
||||
"enabling/disabling quirk stylesheet too late");
|
||||
PRBool applicableNow;
|
||||
mQuirkStyleSheet->GetApplicable(applicableNow);
|
||||
NS_ASSERTION(count == 0 || aEnable == applicableNow,
|
||||
"enabling/disabling quirk stylesheet too late or incomplete quirk stylesheet");
|
||||
if (count != 0 && aEnable == enabledNow)
|
||||
printf("WARNING: We set the quirks mode too many times.\n"); // we do!
|
||||
#endif
|
||||
|
@ -899,7 +965,7 @@ StyleSetImpl::ReplaceAgentStyleSheets(nsISupportsArray* aNewAgentSheets)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StyleSetImpl::NotifyStyleSheetStateChanged(PRBool aDisabled)
|
||||
StyleSetImpl::NotifyStyleSheetStateChanged(PRBool aApplicable)
|
||||
{
|
||||
ClearRuleProcessors();
|
||||
GatherRuleProcessors();
|
||||
|
|
|
@ -701,8 +701,7 @@ nsContentDLF::EnsureUAStyleSheet()
|
|||
NS_NewCSSLoader(getter_AddRefs(cssLoader));
|
||||
if (!cssLoader)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
PRBool complete;
|
||||
rv = cssLoader->LoadAgentSheet(uri, gUAStyleSheet, complete, nsnull);
|
||||
rv = cssLoader->LoadAgentSheet(uri, &gUAStyleSheet);
|
||||
#ifdef DEBUG
|
||||
if (NS_FAILED(rv))
|
||||
printf("*** open of %s failed: error=%x\n", UA_CSS_URL, rv);
|
||||
|
|
|
@ -393,7 +393,6 @@ public:
|
|||
nsString mBaseHREF;
|
||||
nsString mBaseTarget;
|
||||
|
||||
PRInt32 mStyleSheetCount;
|
||||
nsICSSLoader *mCSSLoader;
|
||||
PRInt32 mInsideNoXXXTag;
|
||||
PRInt32 mInMonolithicContainer;
|
||||
|
@ -4810,7 +4809,6 @@ HTMLContentSink::ProcessStyleLink(nsIHTMLContent* aElement,
|
|||
PRBool doneLoading;
|
||||
result = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia,
|
||||
kNameSpaceID_Unknown,
|
||||
mStyleSheetCount++,
|
||||
((blockParser) ? mParser : nsnull),
|
||||
doneLoading,
|
||||
this);
|
||||
|
@ -4918,10 +4916,7 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
|
|||
|
||||
if (ssle) {
|
||||
ssle->SetEnableUpdates(PR_TRUE);
|
||||
result = ssle->UpdateStyleSheet(nsnull, mStyleSheetCount);
|
||||
if (NS_SUCCEEDED(result) || (result == NS_ERROR_HTMLPARSER_BLOCK)) {
|
||||
mStyleSheetCount++;
|
||||
}
|
||||
result = ssle->UpdateStyleSheet(nsnull);
|
||||
|
||||
// look for <link rel="next" href="url">
|
||||
nsAutoString relVal;
|
||||
|
@ -5341,10 +5336,16 @@ NS_IMETHODIMP
|
|||
HTMLContentSink::StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet)
|
||||
{
|
||||
// Processing of a new style sheet causes recreation of the frame
|
||||
// model. As a result, all contexts should update their notion of
|
||||
// how much frame creation has happened.
|
||||
UpdateAllContexts();
|
||||
// We only care when applicable sheets are added
|
||||
NS_PRECONDITION(aStyleSheet, "Must have a style sheet!");
|
||||
PRBool applicable;
|
||||
aStyleSheet->GetApplicable(applicable);
|
||||
if (applicable) {
|
||||
// Processing of a new style sheet causes recreation of the frame
|
||||
// model. As a result, all contexts should update their notion of
|
||||
// how much frame creation has happened.
|
||||
UpdateAllContexts();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -5353,22 +5354,28 @@ NS_IMETHODIMP
|
|||
HTMLContentSink::StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet)
|
||||
{
|
||||
// Removing a style sheet causes recreation of the frame model.
|
||||
// As a result, all contexts should update their notion of how
|
||||
// much frame creation has happened.
|
||||
UpdateAllContexts();
|
||||
// We only care when applicable sheets are removed
|
||||
NS_PRECONDITION(aStyleSheet, "Must have a style sheet!");
|
||||
PRBool applicable;
|
||||
aStyleSheet->GetApplicable(applicable);
|
||||
if (applicable) {
|
||||
// Removing a style sheet causes recreation of the frame model.
|
||||
// As a result, all contexts should update their notion of how
|
||||
// much frame creation has happened.
|
||||
UpdateAllContexts();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLContentSink::StyleSheetDisabledStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDisabled)
|
||||
HTMLContentSink::StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aApplicable)
|
||||
{
|
||||
// Disabling/enabling a style sheet causes recreation of the frame
|
||||
// model. As a result, all contexts should update their notion of
|
||||
// how much frame creation has happened.
|
||||
// Changing a style sheet's applicable state causes recreation of
|
||||
// the frame model. As a result, all contexts should update their
|
||||
// notion of how much frame creation has happened.
|
||||
UpdateAllContexts();
|
||||
|
||||
return NS_OK;
|
||||
|
@ -5723,10 +5730,7 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode)
|
|||
|
||||
if (ssle) {
|
||||
ssle->SetEnableUpdates(PR_TRUE);
|
||||
rv = ssle->UpdateStyleSheet(nsnull, mStyleSheetCount);
|
||||
if (NS_SUCCEEDED(rv) || (rv == NS_ERROR_HTMLPARSER_BLOCK)) {
|
||||
mStyleSheetCount++;
|
||||
}
|
||||
rv = ssle->UpdateStyleSheet(nsnull);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -1239,16 +1239,22 @@ void
|
|||
nsHTMLDocument::InternalAddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags)
|
||||
{
|
||||
if (aSheet == mAttrStyleSheet) { // always first
|
||||
NS_ASSERTION(mStyleSheets.Count() == 0 ||
|
||||
mAttrStyleSheet != mStyleSheets[0],
|
||||
"Adding attr sheet twice!");
|
||||
mStyleSheets.InsertObjectAt(aSheet, 0);
|
||||
}
|
||||
else if (aSheet == mStyleAttrStyleSheet) { // always last
|
||||
NS_ASSERTION(mStyleSheets.Count() == 0 ||
|
||||
mStyleSheets[mStyleSheets.Count() - 1] != mStyleAttrStyleSheet,
|
||||
"Adding style attr sheet twice!");
|
||||
mStyleSheets.AppendObject(aSheet);
|
||||
}
|
||||
else {
|
||||
if (mStyleSheets.Count() != 0 &&
|
||||
mStyleAttrStyleSheet == mStyleSheets.ObjectAt(mStyleSheets.Count() - 1)) {
|
||||
PRInt32 count = mStyleSheets.Count();
|
||||
if (count != 0 && mStyleAttrStyleSheet == mStyleSheets[count - 1]) {
|
||||
// keep attr sheet last
|
||||
mStyleSheets.InsertObjectAt(aSheet, mStyleSheets.Count() - 1);
|
||||
mStyleSheets.InsertObjectAt(aSheet, count - 1);
|
||||
}
|
||||
else {
|
||||
mStyleSheets.AppendObject(aSheet);
|
||||
|
@ -1259,9 +1265,47 @@ nsHTMLDocument::InternalAddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags)
|
|||
void
|
||||
nsHTMLDocument::InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex)
|
||||
{
|
||||
NS_ASSERTION(0 <= aIndex &&
|
||||
aIndex <= (
|
||||
mStyleSheets.Count()
|
||||
/* Don't count Attribute stylesheet */
|
||||
- 1
|
||||
/* No insertion allowed after StyleAttr stylesheet */
|
||||
- ((mStyleAttrStyleSheet &&
|
||||
mStyleSheets.Count() > 0 &&
|
||||
mStyleAttrStyleSheet ==
|
||||
mStyleSheets[mStyleSheets.Count() - 1]) ? 1: 0)
|
||||
),
|
||||
"index out of bounds");
|
||||
|
||||
mStyleSheets.InsertObjectAt(aSheet, aIndex + 1); // offset one for the attr style sheet
|
||||
}
|
||||
|
||||
already_AddRefed<nsIStyleSheet>
|
||||
nsHTMLDocument::InternalGetStyleSheetAt(PRInt32 aIndex)
|
||||
{
|
||||
PRInt32 count = InternalGetNumberOfStyleSheets();
|
||||
if (aIndex >= 0 && aIndex < count) {
|
||||
nsIStyleSheet* sheet = mStyleSheets[aIndex + 1];
|
||||
NS_ADDREF(sheet);
|
||||
return sheet;
|
||||
} else {
|
||||
NS_ERROR("Index out of range");
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsHTMLDocument::InternalGetNumberOfStyleSheets()
|
||||
{
|
||||
PRInt32 count = mStyleSheets.Count();
|
||||
if (count != 0 && mStyleAttrStyleSheet == mStyleSheets[count - 1])
|
||||
--count;
|
||||
--count; // for the attr sheet
|
||||
NS_ASSERTION(count >= 0, "Why did we end up with a negative count?");
|
||||
return count;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetBaseURL(nsIURI*& aURL) const
|
||||
{
|
||||
|
|
|
@ -204,6 +204,9 @@ protected:
|
|||
PRUint32 aFlags);
|
||||
virtual void InternalInsertStyleSheetAt(nsIStyleSheet* aSheet,
|
||||
PRInt32 aIndex);
|
||||
virtual already_AddRefed<nsIStyleSheet> InternalGetStyleSheetAt(PRInt32 aIndex);
|
||||
virtual PRInt32 InternalGetNumberOfStyleSheets();
|
||||
|
||||
static PRBool MatchLinks(nsIContent *aContent, nsString* aData);
|
||||
static PRBool MatchAnchors(nsIContent *aContent, nsString* aData);
|
||||
static PRBool MatchLayers(nsIContent *aContent, nsString* aData);
|
||||
|
|
|
@ -77,17 +77,18 @@ public:
|
|||
nsICSSParser** aParser) = 0;
|
||||
NS_IMETHOD RecycleParser(nsICSSParser* aParser) = 0;
|
||||
|
||||
// XXX No one uses the aDefaultNameSpaceID params.... do we need them?
|
||||
|
||||
// Load an inline style sheet
|
||||
// - if aCompleted is PR_TRUE, the sheet is fully loaded, don't
|
||||
// block for it.
|
||||
// - if aCompleted is PR_FALSE, the sheet is still loading and
|
||||
// will be inserted in the document when complete
|
||||
// will be marked complete when complete
|
||||
NS_IMETHOD LoadInlineStyle(nsIContent* aElement,
|
||||
nsIUnicharInputStream* aIn,
|
||||
nsIUnicharInputStream* aStream,
|
||||
const nsString& aTitle,
|
||||
const nsString& aMedia,
|
||||
PRInt32 aDefaultNameSpaceID,
|
||||
PRInt32 aDocIndex,
|
||||
nsIParser* aParserToUnblock,
|
||||
PRBool& aCompleted,
|
||||
nsICSSLoaderObserver* aObserver) = 0;
|
||||
|
@ -96,13 +97,12 @@ public:
|
|||
// - if aCompleted is PR_TRUE, the sheet is fully loaded, don't
|
||||
// block for it.
|
||||
// - if aCompleted is PR_FALSE, the sheet is still loading and
|
||||
// will be inserted in the document when complete
|
||||
// will be marked complete when complete
|
||||
NS_IMETHOD LoadStyleLink(nsIContent* aElement,
|
||||
nsIURI* aURL,
|
||||
const nsString& aTitle,
|
||||
const nsString& aMedia,
|
||||
PRInt32 aDefaultNameSpaceID,
|
||||
PRInt32 aDocIndex,
|
||||
nsIParser* aParserToUnblock,
|
||||
PRBool& aCompleted,
|
||||
nsICSSLoaderObserver* aObserver) = 0;
|
||||
|
@ -112,18 +112,15 @@ public:
|
|||
nsIURI* aURL,
|
||||
const nsString& aMedia,
|
||||
PRInt32 aDefaultNameSpaceID,
|
||||
PRInt32 aSheetIndex,
|
||||
nsICSSImportRule* aRule) = 0;
|
||||
|
||||
// Load a user agent or user sheet immediately
|
||||
// (note that @imports mayl come in asynchronously)
|
||||
// - if aCompleted is PR_TRUE, the sheet is fully loaded
|
||||
// - if aCompleted is PR_FALSE, the sheet is still loading and
|
||||
// aCAllback will be called when the sheet is complete
|
||||
NS_IMETHOD LoadAgentSheet(nsIURI* aURL,
|
||||
nsICSSStyleSheet*& aSheet,
|
||||
PRBool& aCompleted,
|
||||
nsICSSLoaderObserver* aObserver) = 0;
|
||||
// Load a user agent or user sheet. The sheet is loaded
|
||||
// synchronously, including @imports from it.
|
||||
NS_IMETHOD LoadAgentSheet(nsIURI* aURL, nsICSSStyleSheet** aSheet) = 0;
|
||||
|
||||
// Load a user agent or user sheet. The sheet is loaded
|
||||
// asynchronously and the observer notified when the load finishes.
|
||||
NS_IMETHOD LoadAgentSheet(nsIURI* aURL, nsICSSLoaderObserver* aObserver) = 0;
|
||||
|
||||
// stop loading all sheets
|
||||
NS_IMETHOD Stop(void) = 0;
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
NS_IMETHOD GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& aSheet) const = 0;
|
||||
|
||||
NS_IMETHOD Init(nsIURI* aURL) = 0;
|
||||
NS_IMETHOD SetTitle(const nsString& aTitle) = 0;
|
||||
NS_IMETHOD SetTitle(const nsAString& aTitle) = 0;
|
||||
NS_IMETHOD AppendMedium(nsIAtom* aMedium) = 0;
|
||||
NS_IMETHOD ClearMedia(void) = 0;
|
||||
NS_IMETHOD SetOwningNode(nsIDOMNode* aOwningNode) = 0;
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -333,7 +333,6 @@ protected:
|
|||
nsCSSScanner* mScanner;
|
||||
nsIURI* mURL;
|
||||
nsICSSStyleSheet* mSheet;
|
||||
PRInt32 mChildSheetCount;
|
||||
nsICSSLoader* mChildLoader; // not ref counted, it owns us
|
||||
|
||||
enum nsCSSSection {
|
||||
|
@ -428,7 +427,6 @@ CSSParserImpl::CSSParserImpl()
|
|||
mScanner(nsnull),
|
||||
mURL(nsnull),
|
||||
mSheet(nsnull),
|
||||
mChildSheetCount(0),
|
||||
mChildLoader(nsnull),
|
||||
mSection(eCSSSection_Charset),
|
||||
mNavQuirkMode(PR_FALSE),
|
||||
|
@ -449,7 +447,6 @@ CSSParserImpl::Init(nsICSSStyleSheet* aSheet)
|
|||
mSheet = aSheet;
|
||||
if (mSheet) {
|
||||
NS_ADDREF(aSheet);
|
||||
mSheet->StyleSheetCount(mChildSheetCount);
|
||||
mSheet->GetNameSpace(mNameSpace);
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -486,7 +483,6 @@ CSSParserImpl::SetStyleSheet(nsICSSStyleSheet* aSheet)
|
|||
NS_IF_RELEASE(mSheet);
|
||||
mSheet = aSheet;
|
||||
NS_ADDREF(mSheet);
|
||||
mSheet->StyleSheetCount(mChildSheetCount);
|
||||
mSheet->GetNameSpace(mNameSpace);
|
||||
}
|
||||
|
||||
|
@ -554,8 +550,17 @@ CSSParserImpl::Parse(nsIUnicharInputStream* aInput,
|
|||
|
||||
if (! mSheet) {
|
||||
NS_NewCSSStyleSheet(&mSheet, aInputURL);
|
||||
mChildSheetCount = 0;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
mSheet->GetURL(*getter_AddRefs(uri));
|
||||
PRBool equal;
|
||||
aInputURL->Equals(uri, &equal);
|
||||
NS_ASSERTION(equal, "Sheet URI does not match passed URI");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (! mSheet) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1189,7 +1194,7 @@ PRBool CSSParserImpl::ProcessImport(PRInt32& aErrorCode, const nsString& aURLSpe
|
|||
PRBool bContains = PR_FALSE;
|
||||
if (NS_SUCCEEDED(mSheet->ContainsStyleSheet(url,bContains)) &&
|
||||
bContains != PR_TRUE ) { // don't allow circular references
|
||||
mChildLoader->LoadChildSheet(mSheet, url, aMedia, kNameSpaceID_Unknown, mChildSheetCount++, rule);
|
||||
mChildLoader->LoadChildSheet(mSheet, url, aMedia, kNameSpaceID_Unknown, rule);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -805,6 +805,7 @@ public:
|
|||
nsCOMPtr<nsINameSpace> mNameSpace;
|
||||
PRInt32 mDefaultNameSpaceID;
|
||||
nsHashtable mRelevantAttributes;
|
||||
PRPackedBool mComplete;
|
||||
};
|
||||
|
||||
|
||||
|
@ -829,7 +830,7 @@ public:
|
|||
NS_IMETHOD Init(nsIURI* aURL);
|
||||
NS_IMETHOD GetURL(nsIURI*& aURL) const;
|
||||
NS_IMETHOD GetTitle(nsString& aTitle) const;
|
||||
NS_IMETHOD SetTitle(const nsString& aTitle);
|
||||
NS_IMETHOD SetTitle(const nsAString& aTitle);
|
||||
NS_IMETHOD GetType(nsString& aType) const;
|
||||
NS_IMETHOD GetMediumCount(PRInt32& aCount) const;
|
||||
NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const;
|
||||
|
@ -839,9 +840,13 @@ public:
|
|||
NS_IMETHOD DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex);
|
||||
NS_IMETHOD InsertRuleIntoGroup(const nsAString& aRule, nsICSSGroupRule* aGroup, PRUint32 aIndex, PRUint32* _retval);
|
||||
|
||||
NS_IMETHOD GetEnabled(PRBool& aEnabled) const;
|
||||
NS_IMETHOD GetApplicable(PRBool& aApplicable) const;
|
||||
|
||||
NS_IMETHOD SetEnabled(PRBool aEnabled);
|
||||
|
||||
NS_IMETHOD GetComplete(PRBool& aComplete) const;
|
||||
NS_IMETHOD SetComplete();
|
||||
|
||||
// style sheet owner info
|
||||
NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const; // may be null
|
||||
NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const;
|
||||
|
@ -927,8 +932,8 @@ protected:
|
|||
CSSRuleListImpl* mRuleCollection;
|
||||
nsIDocument* mDocument;
|
||||
nsIDOMNode* mOwningNode; // weak ref
|
||||
PRBool mDisabled;
|
||||
PRBool mDirty; // has been modified
|
||||
PRPackedBool mDisabled;
|
||||
PRPackedBool mDirty; // has been modified
|
||||
|
||||
CSSStyleSheetInner* mInner;
|
||||
|
||||
|
@ -1482,7 +1487,8 @@ CSSStyleSheetInner::CSSStyleSheetInner(nsICSSStyleSheet* aParentSheet)
|
|||
mOrderedRules(nsnull),
|
||||
mNameSpace(nsnull),
|
||||
mDefaultNameSpaceID(kNameSpaceID_None),
|
||||
mRelevantAttributes()
|
||||
mRelevantAttributes(),
|
||||
mComplete(PR_FALSE)
|
||||
{
|
||||
MOZ_COUNT_CTOR(CSSStyleSheetInner);
|
||||
mSheets.AppendElement(aParentSheet);
|
||||
|
@ -1519,7 +1525,8 @@ CSSStyleSheetInner::CSSStyleSheetInner(CSSStyleSheetInner& aCopy,
|
|||
mURL(aCopy.mURL),
|
||||
mNameSpace(nsnull),
|
||||
mDefaultNameSpaceID(aCopy.mDefaultNameSpaceID),
|
||||
mRelevantAttributes()
|
||||
mRelevantAttributes(),
|
||||
mComplete(aCopy.mComplete)
|
||||
{
|
||||
MOZ_COUNT_CTOR(CSSStyleSheetInner);
|
||||
mSheets.AppendElement(aParentSheet);
|
||||
|
@ -1758,6 +1765,7 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(const CSSStyleSheetImpl& aCopy)
|
|||
|
||||
if (aCopy.mRuleCollection &&
|
||||
aCopy.mRuleCollection->mRulesAccessed) { // CSSOM's been there, force full copy now
|
||||
NS_ASSERTION(mInner->mComplete, "Why have rules been accessed on an incomplete sheet?");
|
||||
EnsureUniqueInner();
|
||||
}
|
||||
|
||||
|
@ -1925,7 +1933,7 @@ CSSStyleSheetImpl::GetURL(nsIURI*& aURL) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::SetTitle(const nsString& aTitle)
|
||||
CSSStyleSheetImpl::SetTitle(const nsAString& aTitle)
|
||||
{
|
||||
mTitle = aTitle;
|
||||
return NS_OK;
|
||||
|
@ -2012,25 +2020,46 @@ CSSStyleSheetImpl::ClearMedia(void)
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::GetEnabled(PRBool& aEnabled) const
|
||||
CSSStyleSheetImpl::GetApplicable(PRBool& aApplicable) const
|
||||
{
|
||||
aEnabled = !mDisabled;
|
||||
aApplicable = !mDisabled && mInner && mInner->mComplete;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::SetEnabled(PRBool aEnabled)
|
||||
{
|
||||
PRBool oldState = mDisabled;
|
||||
PRBool oldDisabled = mDisabled;
|
||||
mDisabled = !aEnabled;
|
||||
|
||||
if ((nsnull != mDocument) && (mDisabled != oldState)) {
|
||||
mDocument->SetStyleSheetDisabledState(this, mDisabled);
|
||||
if (mDocument && mInner && mInner->mComplete && oldDisabled != mDisabled) {
|
||||
mDocument->SetStyleSheetApplicableState(this, !mDisabled);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::GetComplete(PRBool& aComplete) const
|
||||
{
|
||||
aComplete = mInner && mInner->mComplete;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::SetComplete()
|
||||
{
|
||||
if (!mInner)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
NS_ASSERTION(!mDirty, "Can't set a dirty sheet complete!");
|
||||
mInner->mComplete = PR_TRUE;
|
||||
if (mDocument && !mDisabled) {
|
||||
// Let the document know
|
||||
mDocument->SetStyleSheetApplicableState(this, PR_TRUE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::GetParentSheet(nsIStyleSheet*& aParent) const
|
||||
{
|
||||
|
@ -2416,7 +2445,7 @@ CSSStyleSheetImpl::EnsureUniqueInner(void)
|
|||
if (! mInner) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
if (1 < mInner->mSheets.Count()) {
|
||||
if (1 < mInner->mSheets.Count()) {
|
||||
CSSStyleSheetInner* clone = mInner->CloneFor(this);
|
||||
if (clone) {
|
||||
mInner->RemoveSheet(this);
|
||||
|
@ -2609,6 +2638,11 @@ CSSStyleSheetImpl::ClearRuleCascades(void)
|
|||
nsresult
|
||||
CSSStyleSheetImpl::WillDirty(void)
|
||||
{
|
||||
if (mInner && !mInner->mComplete) {
|
||||
// Do nothing
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return EnsureUniqueInner();
|
||||
}
|
||||
|
||||
|
@ -2651,11 +2685,11 @@ CSSStyleSheetImpl::GetDisabled(PRBool* aDisabled)
|
|||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::SetDisabled(PRBool aDisabled)
|
||||
{
|
||||
PRBool oldState = mDisabled;
|
||||
PRBool oldDisabled = mDisabled;
|
||||
mDisabled = aDisabled;
|
||||
|
||||
if (mDocument && (mDisabled != oldState)) {
|
||||
mDocument->SetStyleSheetDisabledState(this, mDisabled);
|
||||
if (mDocument && mInner && mInner->mComplete && oldDisabled != mDisabled) {
|
||||
mDocument->SetStyleSheetApplicableState(this, !mDisabled);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -2750,6 +2784,13 @@ CSSStyleSheetImpl::GetOwnerRule(nsIDOMCSSRule** aOwnerRule)
|
|||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::GetCssRules(nsIDOMCSSRuleList** aCssRules)
|
||||
{
|
||||
// No doing this on incomplete sheets!
|
||||
PRBool complete;
|
||||
GetComplete(complete);
|
||||
if (!complete) {
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
}
|
||||
|
||||
//-- Security check: Only scripts from the same origin as the
|
||||
// style sheet can access rule collections
|
||||
|
||||
|
@ -2798,6 +2839,13 @@ CSSStyleSheetImpl::InsertRule(const nsAString& aRule,
|
|||
PRUint32* aReturn)
|
||||
{
|
||||
NS_ENSURE_TRUE(mInner, NS_ERROR_FAILURE);
|
||||
// No doing this if the sheet is not complete!
|
||||
PRBool complete;
|
||||
GetComplete(complete);
|
||||
if (!complete) {
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
}
|
||||
|
||||
nsresult result;
|
||||
result = WillDirty();
|
||||
if (NS_FAILED(result))
|
||||
|
@ -2979,6 +3027,12 @@ NS_IMETHODIMP
|
|||
CSSStyleSheetImpl::DeleteRule(PRUint32 aIndex)
|
||||
{
|
||||
nsresult result = NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
// No doing this if the sheet is not complete!
|
||||
PRBool complete;
|
||||
GetComplete(complete);
|
||||
if (!complete) {
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
}
|
||||
|
||||
// XXX TBI: handle @rule types
|
||||
if (mInner && mInner->mOrderedRules) {
|
||||
|
@ -3020,7 +3074,8 @@ NS_IMETHODIMP
|
|||
CSSStyleSheetImpl::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aGroup);
|
||||
|
||||
NS_ASSERTION(mInner && mInner->mComplete,
|
||||
"No deleting from an incomplete sheet!");
|
||||
nsresult result;
|
||||
nsCOMPtr<nsICSSRule> rule;
|
||||
result = aGroup->GetStyleRuleAt(aIndex, *getter_AddRefs(rule));
|
||||
|
@ -3038,8 +3093,10 @@ CSSStyleSheetImpl::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex)
|
|||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
result = mDocument->BeginUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
if (mDocument) {
|
||||
result = mDocument->BeginUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
result = WillDirty();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
@ -3051,11 +3108,13 @@ CSSStyleSheetImpl::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex)
|
|||
|
||||
DidDirty();
|
||||
|
||||
result = mDocument->StyleRuleRemoved(this, rule);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = mDocument->EndUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
if (mDocument) {
|
||||
result = mDocument->StyleRuleRemoved(this, rule);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = mDocument->EndUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3064,6 +3123,8 @@ NS_IMETHODIMP
|
|||
CSSStyleSheetImpl::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule* aGroup, PRUint32 aIndex, PRUint32* _retval)
|
||||
{
|
||||
nsresult result;
|
||||
NS_ASSERTION(mInner && mInner->mComplete,
|
||||
"No inserting into an incomplete sheet!");
|
||||
// check that the group actually belongs to this sheet!
|
||||
nsCOMPtr<nsIDOMCSSRule> domGroup(do_QueryInterface(aGroup));
|
||||
nsCOMPtr<nsIDOMCSSStyleSheet> groupSheet;
|
||||
|
@ -3097,8 +3158,10 @@ CSSStyleSheetImpl::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule*
|
|||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
// parse and grab the rule
|
||||
result = mDocument->BeginUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
if (mDocument) {
|
||||
result = mDocument->BeginUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
result = WillDirty();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
@ -3132,12 +3195,16 @@ CSSStyleSheetImpl::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule*
|
|||
rule = dont_AddRef((nsICSSRule*)rules->ElementAt(counter));
|
||||
CheckRuleForAttributes(rule);
|
||||
|
||||
result = mDocument->StyleRuleAdded(this, rule);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
if (mDocument) {
|
||||
result = mDocument->StyleRuleAdded(this, rule);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
}
|
||||
|
||||
result = mDocument->EndUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
if (mDocument) {
|
||||
result = mDocument->EndUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
if (loader) {
|
||||
loader->RecycleParser(css);
|
||||
|
@ -4459,10 +4526,10 @@ CSSRuleProcessor::CascadeSheetRulesInto(nsISupports* aSheet, void* aData)
|
|||
nsICSSStyleSheet* iSheet = (nsICSSStyleSheet*)aSheet;
|
||||
CSSStyleSheetImpl* sheet = (CSSStyleSheetImpl*)iSheet;
|
||||
CascadeEnumData* data = (CascadeEnumData*)aData;
|
||||
PRBool bSheetEnabled = PR_TRUE;
|
||||
sheet->GetEnabled(bSheetEnabled);
|
||||
PRBool bSheetApplicable = PR_TRUE;
|
||||
sheet->GetApplicable(bSheetApplicable);
|
||||
|
||||
if ((bSheetEnabled) && (sheet->UseForMedium(data->mMedium))) {
|
||||
if (bSheetApplicable && sheet->UseForMedium(data->mMedium)) {
|
||||
CSSStyleSheetImpl* child = sheet->mFirstChild;
|
||||
while (child) {
|
||||
CascadeSheetRulesInto((nsICSSStyleSheet*)child, data);
|
||||
|
|
|
@ -200,9 +200,13 @@ public:
|
|||
NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const;
|
||||
NS_IMETHOD_(PRBool) UseForMedium(nsIAtom* aMedium) const;
|
||||
|
||||
NS_IMETHOD GetEnabled(PRBool& aEnabled) const;
|
||||
NS_IMETHOD GetApplicable(PRBool& aApplicable) const;
|
||||
|
||||
NS_IMETHOD SetEnabled(PRBool aEnabled);
|
||||
|
||||
NS_IMETHOD GetComplete(PRBool& aComplete) const;
|
||||
NS_IMETHOD SetComplete();
|
||||
|
||||
// style sheet owner info
|
||||
NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const; // will be null
|
||||
NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const;
|
||||
|
@ -427,9 +431,9 @@ HTMLCSSStyleSheetImpl::UseForMedium(nsIAtom* aMedium) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLCSSStyleSheetImpl::GetEnabled(PRBool& aEnabled) const
|
||||
HTMLCSSStyleSheetImpl::GetApplicable(PRBool& aApplicable) const
|
||||
{
|
||||
aEnabled = PR_TRUE;
|
||||
aApplicable = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -439,6 +443,19 @@ HTMLCSSStyleSheetImpl::SetEnabled(PRBool aEnabled)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLCSSStyleSheetImpl::GetComplete(PRBool& aComplete) const
|
||||
{
|
||||
aComplete = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLCSSStyleSheetImpl::SetComplete()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// style sheet owner info
|
||||
NS_IMETHODIMP
|
||||
HTMLCSSStyleSheetImpl::GetParentSheet(nsIStyleSheet*& aParent) const
|
||||
|
|
|
@ -743,9 +743,13 @@ public:
|
|||
NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const;
|
||||
NS_IMETHOD_(PRBool) UseForMedium(nsIAtom* aMedium) const;
|
||||
|
||||
NS_IMETHOD GetEnabled(PRBool& aEnabled) const;
|
||||
NS_IMETHOD GetApplicable(PRBool& aApplicable) const;
|
||||
|
||||
NS_IMETHOD SetEnabled(PRBool aEnabled);
|
||||
|
||||
NS_IMETHOD GetComplete(PRBool& aComplete) const;
|
||||
NS_IMETHOD SetComplete();
|
||||
|
||||
// style sheet owner info
|
||||
NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const; // will be null
|
||||
NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const;
|
||||
|
@ -1105,9 +1109,9 @@ HTMLStyleSheetImpl::UseForMedium(nsIAtom* aMedium) const
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::GetEnabled(PRBool& aEnabled) const
|
||||
HTMLStyleSheetImpl::GetApplicable(PRBool& aApplicable) const
|
||||
{
|
||||
aEnabled = PR_TRUE;
|
||||
aApplicable = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1117,6 +1121,19 @@ HTMLStyleSheetImpl::SetEnabled(PRBool aEnabled)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::GetComplete(PRBool& aComplete) const
|
||||
{
|
||||
aComplete = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::SetComplete()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::GetParentSheet(nsIStyleSheet*& aParent) const
|
||||
{
|
||||
|
|
|
@ -136,8 +136,7 @@ nsXBLPrototypeResources::FlushSkinSheets()
|
|||
oldSheet->GetURL(*getter_AddRefs(uri));
|
||||
|
||||
if (IsChromeURI(uri)) {
|
||||
PRBool complete;
|
||||
if (NS_FAILED(loader->LoadAgentSheet(uri, *getter_AddRefs(newSheet), complete, nsnull)))
|
||||
if (NS_FAILED(loader->LoadAgentSheet(uri, getter_AddRefs(newSheet))))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -144,21 +144,13 @@ nsXBLResourceLoader::LoadResources(PRBool* aResult)
|
|||
|
||||
// Kick off the load of the stylesheet.
|
||||
PRBool doneLoading;
|
||||
nsAutoString empty;
|
||||
PRInt32 numSheets = 0;
|
||||
doc->GetNumberOfStyleSheets(&numSheets);
|
||||
NS_NAMED_LITERAL_STRING(empty, "");
|
||||
|
||||
#ifdef DEBUG
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
|
||||
NS_ASSERTION(loadGroup, "An XBL scoped stylesheet is unable to locate a load group. This means the onload is going to fire too early!");
|
||||
#endif
|
||||
|
||||
cssLoader->LoadStyleLink(nsnull, url, empty, empty, kNameSpaceID_Unknown,
|
||||
numSheets,
|
||||
nsresult rv = cssLoader->LoadStyleLink(nsnull, url, empty, empty, kNameSpaceID_Unknown,
|
||||
nsnull,
|
||||
doneLoading, this);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Load failed!!!");
|
||||
|
||||
if (!doneLoading)
|
||||
mPendingSheets++;
|
||||
}
|
||||
|
|
|
@ -170,7 +170,6 @@ nsXMLContentSink::nsXMLContentSink()
|
|||
mTextSize = 0;
|
||||
mConstrainSize = PR_TRUE;
|
||||
mInTitle = PR_FALSE;
|
||||
mStyleSheetCount = 0;
|
||||
mCSSLoader = nsnull;
|
||||
mNeedToBlockParser = PR_FALSE;
|
||||
mPrettyPrintXML = PR_TRUE;
|
||||
|
@ -692,12 +691,9 @@ nsXMLContentSink::CloseElement(nsIContent* aContent, PRBool* aAppendContent)
|
|||
|
||||
if (ssle) {
|
||||
ssle->SetEnableUpdates(PR_TRUE);
|
||||
rv = ssle->UpdateStyleSheet(nsnull, mStyleSheetCount);
|
||||
if (NS_SUCCEEDED(rv) || (rv == NS_ERROR_HTMLPARSER_BLOCK)) {
|
||||
if (rv == NS_ERROR_HTMLPARSER_BLOCK && mParser) {
|
||||
mParser->BlockParser();
|
||||
}
|
||||
++mStyleSheetCount;
|
||||
rv = ssle->UpdateStyleSheet(nsnull);
|
||||
if (rv == NS_ERROR_HTMLPARSER_BLOCK && mParser) {
|
||||
mParser->BlockParser();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -836,15 +832,12 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
|
|||
}
|
||||
PRBool doneLoading;
|
||||
rv = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia, kNameSpaceID_Unknown,
|
||||
mStyleSheetCount++,
|
||||
((!aAlternate) ? mParser : nsnull),
|
||||
doneLoading,
|
||||
this);
|
||||
if (NS_SUCCEEDED(rv) || (rv == NS_ERROR_HTMLPARSER_BLOCK)) {
|
||||
if (rv == NS_ERROR_HTMLPARSER_BLOCK && mParser) {
|
||||
mParser->BlockParser();
|
||||
}
|
||||
mStyleSheetCount++;
|
||||
// XXX should probably use kBlockByDefault here, no?
|
||||
if (NS_SUCCEEDED(rv) && !doneLoading && !aAlternate && mParser) {
|
||||
mParser->BlockParser();
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
@ -1644,10 +1637,10 @@ MathMLElementFactoryImpl::CreateInstanceByTag(nsINodeInfo* aNodeInfo,
|
|||
if (doc) {
|
||||
PRBool alreadyLoaded = PR_FALSE;
|
||||
PRInt32 i = 0, sheetCount = 0;
|
||||
doc->GetNumberOfStyleSheets(&sheetCount);
|
||||
doc->GetNumberOfStyleSheets(PR_TRUE, &sheetCount);
|
||||
for (; i < sheetCount; i++) {
|
||||
nsCOMPtr<nsIStyleSheet> sheet;
|
||||
doc->GetStyleSheetAt(i, getter_AddRefs(sheet));
|
||||
doc->GetStyleSheetAt(i, PR_TRUE, getter_AddRefs(sheet));
|
||||
NS_ASSERTION(sheet, "unexpected null stylesheet in the document");
|
||||
if (sheet) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
@ -1669,9 +1662,8 @@ MathMLElementFactoryImpl::CreateInstanceByTag(nsINodeInfo* aNodeInfo,
|
|||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), kMathMLStyleSheetURI);
|
||||
if (uri) {
|
||||
PRBool complete;
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet;
|
||||
cssLoader->LoadAgentSheet(uri, *getter_AddRefs(sheet), complete, nsnull);
|
||||
cssLoader->LoadAgentSheet(uri, getter_AddRefs(sheet));
|
||||
#ifdef NS_DEBUG
|
||||
nsCAutoString uriStr;
|
||||
uri->GetSpec(uriStr);
|
||||
|
@ -1919,9 +1911,9 @@ nsXMLContentSink::HandleDoctypeDecl(const nsAString & aSubset,
|
|||
// exit codes, error are not fatal here, just that the stylesheet won't apply
|
||||
nsCOMPtr<nsIURI> uri(do_QueryInterface(aCatalogData));
|
||||
if (uri) {
|
||||
PRBool complete;
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet;
|
||||
mCSSLoader->LoadAgentSheet(uri, *getter_AddRefs(sheet), complete, nsnull);
|
||||
mCSSLoader->LoadAgentSheet(uri, getter_AddRefs(sheet));
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
nsCAutoString uriStr;
|
||||
uri->GetSpec(uriStr);
|
||||
|
@ -1975,16 +1967,14 @@ nsXMLContentSink::HandleProcessingInstruction(const PRUnichar *aTarget,
|
|||
|
||||
if (ssle) {
|
||||
ssle->SetEnableUpdates(PR_TRUE);
|
||||
result = ssle->UpdateStyleSheet(nsnull, mStyleSheetCount);
|
||||
if (NS_SUCCEEDED(result) || (result == NS_ERROR_HTMLPARSER_BLOCK))
|
||||
mStyleSheetCount++; // This count may not reflect the real stylesheet count
|
||||
}
|
||||
result = ssle->UpdateStyleSheet(nsnull);
|
||||
|
||||
if (NS_FAILED(result)) {
|
||||
if (result == NS_ERROR_HTMLPARSER_BLOCK && mParser) {
|
||||
mParser->BlockParser();
|
||||
if (NS_FAILED(result)) {
|
||||
if (result == NS_ERROR_HTMLPARSER_BLOCK && mParser) {
|
||||
mParser->BlockParser();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// If it's not a CSS stylesheet PI...
|
||||
|
|
|
@ -191,7 +191,6 @@ protected:
|
|||
nsString mRef; // ScrollTo #ref
|
||||
nsString mTitleText;
|
||||
|
||||
PRInt32 mStyleSheetCount;
|
||||
PRInt32 mTextLength;
|
||||
PRInt32 mTextSize;
|
||||
PRUint32 mScriptLineNo;
|
||||
|
|
|
@ -597,20 +597,27 @@ nsXMLDocument::GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult)
|
|||
// subclass hook for sheet ordering
|
||||
void nsXMLDocument::InternalAddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags)
|
||||
{
|
||||
// XXXbz this catalog stuff should be in the UA level in the cascade!
|
||||
if (aFlags & NS_STYLESHEET_FROM_CATALOG) {
|
||||
// always after other catalog sheets
|
||||
mStyleSheets.InsertObjectAt(aSheet, mCountCatalogSheets);
|
||||
++mCountCatalogSheets;
|
||||
}
|
||||
else if (aSheet == mAttrStyleSheet) { // always after catalog sheets
|
||||
NS_ASSERTION(mStyleSheets.Count() == 0 ||
|
||||
mAttrStyleSheet != mStyleSheets[0],
|
||||
"Adding attr sheet twice!");
|
||||
mStyleSheets.InsertObjectAt(aSheet, mCountCatalogSheets);
|
||||
}
|
||||
else if (aSheet == mInlineStyleSheet) { // always last
|
||||
NS_ASSERTION(mStyleSheets.Count() == 0 ||
|
||||
mStyleSheets[mStyleSheets.Count() - 1] != mInlineStyleSheet,
|
||||
"Adding style attr sheet twice!");
|
||||
mStyleSheets.AppendObject(aSheet);
|
||||
}
|
||||
else {
|
||||
PRInt32 count = mStyleSheets.Count();
|
||||
if (count != 0 && mInlineStyleSheet == mStyleSheets.ObjectAt(count - 1)) {
|
||||
if (count != 0 && mInlineStyleSheet == mStyleSheets[count - 1]) {
|
||||
// keep attr sheet last
|
||||
mStyleSheets.InsertObjectAt(aSheet, count - 1);
|
||||
}
|
||||
|
@ -623,10 +630,47 @@ void nsXMLDocument::InternalAddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags
|
|||
void
|
||||
nsXMLDocument::InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex)
|
||||
{
|
||||
NS_ASSERTION(0 <= aIndex &&
|
||||
aIndex <= (
|
||||
mStyleSheets.Count()
|
||||
/* Don't count Attribute stylesheet */
|
||||
- 1
|
||||
/* Don't count catalog sheets */
|
||||
- mCountCatalogSheets
|
||||
/* No insertion allowed after StyleAttr stylesheet */
|
||||
- (mInlineStyleSheet ? 1: 0)
|
||||
),
|
||||
"index out of bounds");
|
||||
// offset w.r.t. catalog style sheets and the attr style sheet
|
||||
mStyleSheets.InsertObjectAt(aSheet, aIndex + mCountCatalogSheets + 1);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIStyleSheet>
|
||||
nsXMLDocument::InternalGetStyleSheetAt(PRInt32 aIndex)
|
||||
{
|
||||
PRInt32 count = InternalGetNumberOfStyleSheets();
|
||||
|
||||
if (aIndex >= 0 && aIndex < count) {
|
||||
nsIStyleSheet* sheet = mStyleSheets[aIndex + mCountCatalogSheets + 1];
|
||||
NS_ADDREF(sheet);
|
||||
return sheet;
|
||||
} else {
|
||||
NS_ERROR("Index out of range");
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32
|
||||
nsXMLDocument::InternalGetNumberOfStyleSheets()
|
||||
{
|
||||
PRInt32 count = mStyleSheets.Count();
|
||||
if (count != 0 && mInlineStyleSheet == mStyleSheets[count - 1])
|
||||
--count;
|
||||
count -= (mCountCatalogSheets + 1); // +1 for the attr sheet
|
||||
NS_ASSERTION(count >= 0, "Why did we end up with a negative count?");
|
||||
return count;
|
||||
}
|
||||
|
||||
// nsIDOMDocument interface
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetDoctype(nsIDOMDocumentType** aDocumentType)
|
||||
|
|
|
@ -137,6 +137,8 @@ protected:
|
|||
// subclass hooks for sheet ordering
|
||||
virtual void InternalAddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags);
|
||||
virtual void InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex);
|
||||
virtual already_AddRefed<nsIStyleSheet> InternalGetStyleSheetAt(PRInt32 aIndex);
|
||||
virtual PRInt32 InternalGetNumberOfStyleSheets();
|
||||
|
||||
nsresult CreateElement(nsINodeInfo *aNodeInfo, nsIDOMElement** aResult);
|
||||
|
||||
|
|
|
@ -58,9 +58,9 @@
|
|||
NS_IMPL_ISUPPORTS1(nsXMLPrettyPrinter,
|
||||
nsIDocumentObserver)
|
||||
|
||||
nsXMLPrettyPrinter::nsXMLPrettyPrinter() : mUnhookPending(PR_FALSE),
|
||||
mDocument(nsnull),
|
||||
mUpdateDepth(0)
|
||||
nsXMLPrettyPrinter::nsXMLPrettyPrinter() : mDocument(nsnull),
|
||||
mUpdateDepth(0),
|
||||
mUnhookPending(PR_FALSE)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class nsXMLPrettyPrinter : public nsIDocumentObserver
|
|||
{
|
||||
public:
|
||||
nsXMLPrettyPrinter();
|
||||
~nsXMLPrettyPrinter();
|
||||
virtual ~nsXMLPrettyPrinter();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOCUMENTOBSERVER
|
||||
|
|
|
@ -570,10 +570,7 @@ XULContentSinkImpl::ProcessStyleLink(nsIContent* aElement,
|
|||
return NS_ERROR_FAILURE; // doc went away!
|
||||
|
||||
PRBool doneLoading;
|
||||
PRInt32 numSheets = 0;
|
||||
doc->GetNumberOfStyleSheets(&numSheets);
|
||||
rv = mCSSLoader->LoadStyleLink(aElement, url, aTitle, aMedia, kNameSpaceID_Unknown,
|
||||
numSheets,
|
||||
((blockParser) ? mParser : nsnull),
|
||||
doneLoading, nsnull);
|
||||
if (NS_SUCCEEDED(rv) && blockParser && (! doneLoading)) {
|
||||
|
|
|
@ -1294,15 +1294,40 @@ nsXULDocument::GetChildCount(PRInt32& aCount)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::GetNumberOfStyleSheets(PRInt32 *aCount)
|
||||
nsXULDocument::GetNumberOfStyleSheets(PRBool aIncludeSpecialSheets,
|
||||
PRInt32 *aCount)
|
||||
{
|
||||
*aCount = mStyleSheets.Count();
|
||||
return NS_OK;
|
||||
PRInt32 count = mStyleSheets.Count();
|
||||
if (aIncludeSpecialSheets) {
|
||||
*aCount = count;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (count != 0 &&
|
||||
(nsIHTMLCSSStyleSheet*)mInlineStyleSheet == mStyleSheets.ElementAt(count - 1)) {
|
||||
// subtract the inline style sheet
|
||||
--count;
|
||||
}
|
||||
|
||||
if (count != 0 &&
|
||||
(nsIHTMLStyleSheet*)mAttrStyleSheet == mStyleSheets.ElementAt(0)) {
|
||||
// subtract the attr sheet
|
||||
--count;
|
||||
}
|
||||
|
||||
NS_ASSERTION(count >= 0, "How did we get a negative count?");
|
||||
|
||||
*aCount = count;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::GetStyleSheetAt(PRInt32 aIndex, nsIStyleSheet** aSheet)
|
||||
nsXULDocument::GetStyleSheetAt(PRInt32 aIndex, PRBool aIncludeSpecialSheets,
|
||||
nsIStyleSheet** aSheet)
|
||||
{
|
||||
if (!aIncludeSpecialSheets) {
|
||||
++aIndex; // adjust for the attr sheet
|
||||
}
|
||||
*aSheet = NS_STATIC_CAST(nsIStyleSheet*, mStyleSheets[aIndex]);
|
||||
NS_IF_ADDREF(*aSheet);
|
||||
return NS_OK;
|
||||
|
@ -1359,84 +1384,82 @@ nsXULDocument::AddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags)
|
|||
|
||||
aSheet->SetOwningDocument(this);
|
||||
|
||||
PRBool enabled;
|
||||
aSheet->GetEnabled(enabled);
|
||||
|
||||
if (enabled) {
|
||||
PRBool applicable;
|
||||
aSheet->GetApplicable(applicable);
|
||||
|
||||
if (applicable) {
|
||||
AddStyleSheetToStyleSets(aSheet);
|
||||
|
||||
// XXX should observers be notified for disabled sheets??? I think not, but I could be wrong
|
||||
// if an observer removes itself, we're ok (not if it removes others though)
|
||||
for (PRInt32 i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(i);
|
||||
observer->StyleSheetAdded(this, aSheet);
|
||||
}
|
||||
}
|
||||
|
||||
// if an observer removes itself, we're ok (not if it removes
|
||||
// others though)
|
||||
PRInt32 i;
|
||||
for (i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(i);
|
||||
observer->StyleSheetAdded(this, aSheet);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::UpdateStyleSheets(nsISupportsArray* aOldSheets, nsISupportsArray* aNewSheets)
|
||||
nsXULDocument::UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
|
||||
nsCOMArray<nsIStyleSheet>& aNewSheets)
|
||||
{
|
||||
PRUint32 oldCount;
|
||||
aOldSheets->Count(&oldCount);
|
||||
nsCOMPtr<nsIStyleSheet> sheet;
|
||||
PRUint32 i;
|
||||
for (i = 0; i < oldCount; i++) {
|
||||
aOldSheets->QueryElementAt(i, NS_GET_IID(nsIStyleSheet), getter_AddRefs(sheet));
|
||||
if (sheet) {
|
||||
mStyleSheets.RemoveElement(sheet);
|
||||
PRBool enabled = PR_TRUE;
|
||||
sheet->GetEnabled(enabled);
|
||||
if (enabled) {
|
||||
RemoveStyleSheetFromStyleSets(sheet);
|
||||
}
|
||||
// XXX Need to set the sheet on the ownernode if any
|
||||
NS_PRECONDITION(aOldSheets.Count() == aNewSheets.Count(),
|
||||
"The lists must be the same length!");
|
||||
PRInt32 count = aOldSheets.Count();
|
||||
|
||||
sheet->SetOwningDocument(nsnull);
|
||||
nsIStyleSheet* sheetPtr = sheet.get();
|
||||
NS_RELEASE(sheetPtr);
|
||||
nsCOMPtr<nsIStyleSheet> oldSheet;
|
||||
PRInt32 i;
|
||||
for (i = 0; i < count; ++i) {
|
||||
oldSheet = aOldSheets[i];
|
||||
|
||||
// First remove the old sheet.
|
||||
NS_ASSERTION(oldSheet, "None of the old sheets should be null");
|
||||
PRInt32 oldIndex = mStyleSheets.IndexOf((void*)oldSheet);
|
||||
NS_ASSERTION(oldIndex != -1, "stylesheet not found");
|
||||
mStyleSheets.RemoveElementAt(oldIndex);
|
||||
|
||||
PRBool applicable = PR_TRUE;
|
||||
oldSheet->GetApplicable(applicable);
|
||||
if (applicable) {
|
||||
RemoveStyleSheetFromStyleSets(oldSheet);
|
||||
}
|
||||
}
|
||||
// XXX we should really notify here, but right now that would
|
||||
// force things like a full reframe on every sheet. We really
|
||||
// need a way to batch this sucker...
|
||||
|
||||
PRUint32 newCount;
|
||||
aNewSheets->Count(&newCount);
|
||||
for (i = 0; i < newCount; i++) {
|
||||
aNewSheets->QueryElementAt(i, NS_GET_IID(nsIStyleSheet), getter_AddRefs(sheet));
|
||||
if (sheet) {
|
||||
if (sheet == mAttrStyleSheet.get()) { // always first
|
||||
mStyleSheets.InsertElementAt(sheet, 0);
|
||||
}
|
||||
else if (sheet == (nsIHTMLCSSStyleSheet*)mInlineStyleSheet) { // always last
|
||||
mStyleSheets.AppendElement(sheet);
|
||||
}
|
||||
else {
|
||||
PRInt32 count = mStyleSheets.Count();
|
||||
if (count != 0 &&
|
||||
(nsIHTMLCSSStyleSheet*)mInlineStyleSheet == mStyleSheets.ElementAt(count - 1)) {
|
||||
// keep attr sheet last
|
||||
mStyleSheets.InsertElementAt(sheet, mStyleSheets.Count() - 1);
|
||||
}
|
||||
else {
|
||||
mStyleSheets.AppendElement(sheet);
|
||||
}
|
||||
}
|
||||
oldSheet->SetOwningDocument(nsnull);
|
||||
nsIStyleSheet* sheetPtr = oldSheet.get();
|
||||
NS_RELEASE(sheetPtr);
|
||||
|
||||
nsIStyleSheet* sheetPtr = sheet;
|
||||
// Now put the new one in its place. If it's null, just ignore it.
|
||||
nsIStyleSheet* newSheet = aNewSheets[i];
|
||||
if (newSheet) {
|
||||
mStyleSheets.InsertElementAt((void*)newSheet, oldIndex);
|
||||
nsIStyleSheet* sheetPtr = newSheet;
|
||||
NS_ADDREF(sheetPtr);
|
||||
sheet->SetOwningDocument(this);
|
||||
|
||||
PRBool enabled = PR_TRUE;
|
||||
sheet->GetEnabled(enabled);
|
||||
if (enabled) {
|
||||
AddStyleSheetToStyleSets(sheet);
|
||||
sheet->SetOwningDocument(nsnull);
|
||||
newSheet->SetOwningDocument(this);
|
||||
PRBool applicable = PR_TRUE;
|
||||
newSheet->GetApplicable(applicable);
|
||||
if (applicable) {
|
||||
AddStyleSheetToStyleSets(newSheet);
|
||||
}
|
||||
|
||||
// XXX we should be notifying here too.
|
||||
}
|
||||
}
|
||||
|
||||
// if an observer removes itself, we're ok (not if it removes others though)
|
||||
for (PRInt32 indx = mObservers.Count() - 1; indx >= 0; --indx) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(indx);
|
||||
observer->StyleSheetRemoved(this, sheet);
|
||||
// Now notify so _something_ happens, assuming we did anything
|
||||
if (oldSheet) {
|
||||
// if an observer removes itself, we're ok (not if it removes
|
||||
// others though)
|
||||
// XXXldb Hopefully the observer doesn't care which sheet you use.
|
||||
for (PRInt32 indx = mObservers.Count() - 1; indx >= 0; --indx) {
|
||||
nsIDocumentObserver* observer =
|
||||
(nsIDocumentObserver*)mObservers.ElementAt(indx);
|
||||
observer->StyleSheetRemoved(this, oldSheet);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1464,18 +1487,16 @@ nsXULDocument::RemoveStyleSheet(nsIStyleSheet* aSheet)
|
|||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
mStyleSheets.RemoveElement(aSheet);
|
||||
|
||||
PRBool enabled = PR_TRUE;
|
||||
aSheet->GetEnabled(enabled);
|
||||
|
||||
if (enabled) {
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
if (applicable) {
|
||||
RemoveStyleSheetFromStyleSets(aSheet);
|
||||
}
|
||||
|
||||
// XXX should observers be notified for disabled sheets??? I think not, but I could be wrong
|
||||
// if an observer removes itself, we're ok (not if it removes others though)
|
||||
for (PRInt32 indx = mObservers.Count() - 1; indx >= 0; --indx) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(indx);
|
||||
observer->StyleSheetRemoved(this, aSheet);
|
||||
}
|
||||
// if an observer removes itself, we're ok (not if it removes others though)
|
||||
for (PRInt32 indx = mObservers.Count() - 1; indx >= 0; --indx) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(indx);
|
||||
observer->StyleSheetRemoved(this, aSheet);
|
||||
}
|
||||
|
||||
aSheet->SetOwningDocument(nsnull);
|
||||
|
@ -1483,7 +1504,7 @@ nsXULDocument::RemoveStyleSheet(nsIStyleSheet* aSheet)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex, PRBool aNotify)
|
||||
nsXULDocument::InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null ptr");
|
||||
|
||||
|
@ -1492,36 +1513,26 @@ nsXULDocument::InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex, PRBool
|
|||
NS_ADDREF(aSheet);
|
||||
aSheet->SetOwningDocument(this);
|
||||
|
||||
PRBool enabled = PR_TRUE;
|
||||
aSheet->GetEnabled(enabled);
|
||||
|
||||
PRInt32 count;
|
||||
PRInt32 i;
|
||||
if (enabled) {
|
||||
count = mPresShells.Count();
|
||||
for (i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsIPresShell> shell = (nsIPresShell*)mPresShells.ElementAt(i);
|
||||
nsCOMPtr<nsIStyleSet> set;
|
||||
shell->GetStyleSet(getter_AddRefs(set));
|
||||
if (set) {
|
||||
set->AddDocStyleSheet(aSheet, this);
|
||||
}
|
||||
}
|
||||
PRBool applicable;
|
||||
aSheet->GetApplicable(applicable);
|
||||
|
||||
if (applicable) {
|
||||
AddStyleSheetToStyleSets(aSheet);
|
||||
}
|
||||
if (aNotify) { // notify here even if disabled, there may have been others that weren't notified
|
||||
// if an observer removes itself, we're ok (not if it removes others though)
|
||||
for (i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
|
||||
// if an observer removes itself, we're ok (not if it removes
|
||||
// others though)
|
||||
PRInt32 i;
|
||||
for (i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(i);
|
||||
observer->StyleSheetAdded(this, aSheet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsXULDocument::SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
|
||||
PRBool aDisabled)
|
||||
nsXULDocument::SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
|
||||
PRBool aApplicable)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
PRInt32 count;
|
||||
|
@ -1529,28 +1540,22 @@ nsXULDocument::SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
|
|||
|
||||
// If we're actually in the document style sheet list
|
||||
if (-1 != mStyleSheets.IndexOf((void *)aSheet)) {
|
||||
count = mPresShells.Count();
|
||||
for (i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsIPresShell> shell =
|
||||
(nsIPresShell*)mPresShells.ElementAt(i);
|
||||
|
||||
nsCOMPtr<nsIStyleSet> set;
|
||||
shell->GetStyleSet(getter_AddRefs(set));
|
||||
if (set) {
|
||||
if (aDisabled) {
|
||||
set->RemoveDocStyleSheet(aSheet);
|
||||
}
|
||||
else {
|
||||
set->AddDocStyleSheet(aSheet, this); // put it first
|
||||
}
|
||||
}
|
||||
if (aApplicable) {
|
||||
AddStyleSheetToStyleSets(aSheet);
|
||||
} else {
|
||||
RemoveStyleSheetFromStyleSets(aSheet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// XXX Some (nsHTMLEditor, eg) call this function for sheets that
|
||||
// are not document sheets! So we have to always notify.
|
||||
|
||||
// if an observer removes itself, we're ok (not if it removes others though)
|
||||
for (i = mObservers.Count() - 1; i >= 0; --i) {
|
||||
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers.ElementAt(i);
|
||||
observer->StyleSheetDisabledStateChanged(this, aSheet, aDisabled);
|
||||
nsIDocumentObserver* observer =
|
||||
(nsIDocumentObserver*)mObservers.ElementAt(i);
|
||||
observer->StyleSheetApplicableStateChanged(this, aSheet, aApplicable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6308,11 +6313,9 @@ nsXULDocument::AddPrototypeSheets()
|
|||
// other than a skin switch anyway (since skin switching is the
|
||||
// only system that partially invalidates the XUL cache).
|
||||
// - dwh
|
||||
PRBool complete;
|
||||
nsCOMPtr<nsICSSLoader> loader;
|
||||
GetCSSLoader(*getter_AddRefs(loader));
|
||||
rv = loader->LoadAgentSheet(uri, *getter_AddRefs(sheet), complete,
|
||||
nsnull);
|
||||
rv = loader->LoadAgentSheet(uri, getter_AddRefs(sheet));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIWordBreakerFactory.h"
|
||||
#include "nsIXULDocument.h"
|
||||
|
@ -240,20 +241,23 @@ public:
|
|||
NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const;
|
||||
NS_IMETHOD GetChildCount(PRInt32& aCount);
|
||||
|
||||
NS_IMETHOD GetNumberOfStyleSheets(PRInt32* aCount);
|
||||
NS_IMETHOD GetStyleSheetAt(PRInt32 aIndex, nsIStyleSheet** aSheet);
|
||||
NS_IMETHOD GetNumberOfStyleSheets(PRBool aIncludeSpecialSheets,
|
||||
PRInt32* aCount);
|
||||
NS_IMETHOD GetStyleSheetAt(PRInt32 aIndex, PRBool aIncludeSpecialSheets,
|
||||
nsIStyleSheet** aSheet);
|
||||
NS_IMETHOD GetIndexOfStyleSheet(nsIStyleSheet* aSheet, PRInt32* aIndex);
|
||||
|
||||
virtual void AddStyleSheet(nsIStyleSheet* aSheet, PRUint32 aFlags);
|
||||
virtual void RemoveStyleSheet(nsIStyleSheet* aSheet);
|
||||
NS_IMETHOD UpdateStyleSheets(nsISupportsArray* aOldSheets, nsISupportsArray* aNewSheets);
|
||||
NS_IMETHOD UpdateStyleSheets(nsCOMArray<nsIStyleSheet>& aOldSheets,
|
||||
nsCOMArray<nsIStyleSheet>& aNewSheets);
|
||||
void AddStyleSheetToStyleSets(nsIStyleSheet* aSheet);
|
||||
void RemoveStyleSheetFromStyleSets(nsIStyleSheet* aSheet);
|
||||
|
||||
NS_IMETHOD InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex, PRBool aNotify);
|
||||
NS_IMETHOD InsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex);
|
||||
|
||||
virtual void SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
|
||||
PRBool aDisabled);
|
||||
virtual void SetStyleSheetApplicableState(nsIStyleSheet* aSheet,
|
||||
PRBool aApplicable);
|
||||
|
||||
NS_IMETHOD GetCSSLoader(nsICSSLoader*& aLoader);
|
||||
|
||||
|
|
|
@ -3560,20 +3560,10 @@ nsHTMLEditor::ReplaceStyleSheet(const nsAString& aURL)
|
|||
rv = NS_NewURI(getter_AddRefs(uaURI), aURL);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRBool complete;
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet;
|
||||
rv = cssLoader->LoadAgentSheet(uaURI, *getter_AddRefs(sheet),
|
||||
complete, this);
|
||||
rv = cssLoader->LoadAgentSheet(uaURI, this);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (complete)
|
||||
StyleSheetLoaded(sheet, PR_FALSE);
|
||||
|
||||
//
|
||||
// If not complete, we will be notified later
|
||||
// with a call to StyleSheetLoaded()
|
||||
//
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -3621,15 +3611,12 @@ nsHTMLEditor::AddOverrideStyleSheet(const nsAString& aURL)
|
|||
rv = NS_NewURI(getter_AddRefs(uaURI), aURL);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// We use null for the callback and data pointer because
|
||||
// we MUST ONLY load synchronous local files (no @import)
|
||||
PRBool complete;
|
||||
// We MUST ONLY load synchronous local files (no @import)
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet;
|
||||
rv = cssLoader->LoadAgentSheet(uaURI, *getter_AddRefs(sheet),
|
||||
complete, nsnull);
|
||||
rv = cssLoader->LoadAgentSheet(uaURI, getter_AddRefs(sheet));
|
||||
|
||||
// Synchronous loads should ALWAYS return completed
|
||||
if (!complete || !sheet)
|
||||
if (!sheet)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsCOMPtr<nsIStyleSheet> styleSheet;
|
||||
|
@ -3659,7 +3646,7 @@ nsHTMLEditor::AddOverrideStyleSheet(const nsAString& aURL)
|
|||
|
||||
// This notifies document observers to rebuild all frames
|
||||
// (this doesn't affect style sheet because it is not a doc sheet)
|
||||
document->SetStyleSheetDisabledState(styleSheet, PR_FALSE);
|
||||
document->SetStyleSheetApplicableState(styleSheet, PR_TRUE);
|
||||
|
||||
// Save as the last-loaded sheet
|
||||
mLastOverrideStyleSheetURL = aURL;
|
||||
|
@ -3718,7 +3705,7 @@ nsHTMLEditor::RemoveOverrideStyleSheet(const nsAString &aURL)
|
|||
|
||||
// This notifies document observers to rebuild all frames
|
||||
// (this doesn't affect style sheet because it is not a doc sheet)
|
||||
document->SetStyleSheetDisabledState(styleSheet, PR_FALSE);
|
||||
document->SetStyleSheetApplicableState(styleSheet, PR_FALSE);
|
||||
|
||||
// Remove it from our internal list
|
||||
return RemoveStyleSheetFromList(aURL);
|
||||
|
|
|
@ -112,10 +112,11 @@ inCSSValueSearch::SearchSync()
|
|||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
|
||||
if (doc) {
|
||||
PRInt32 count = 0;
|
||||
doc->GetNumberOfStyleSheets(&count);
|
||||
// we want all the sheets, including inline style and such
|
||||
doc->GetNumberOfStyleSheets(PR_TRUE, &count);
|
||||
for (PRInt32 i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsIStyleSheet> sheet;
|
||||
doc->GetStyleSheetAt(i, getter_AddRefs(sheet));
|
||||
doc->GetStyleSheetAt(i, PR_TRUE, getter_AddRefs(sheet));
|
||||
SearchStyleSheet(sheet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,8 +82,7 @@ txMozillaXMLOutput::txMozillaXMLOutput(const String& aRootName,
|
|||
nsIDOMDocument* aSourceDocument,
|
||||
nsIDOMDocument* aResultDocument,
|
||||
nsITransformObserver* aObserver)
|
||||
: mStyleSheetCount(0),
|
||||
mBadChildLevel(0),
|
||||
: mBadChildLevel(0),
|
||||
mDontAddCurrent(PR_FALSE),
|
||||
mHaveTitleElement(PR_FALSE),
|
||||
mHaveBaseElement(PR_FALSE),
|
||||
|
@ -101,8 +100,7 @@ txMozillaXMLOutput::txMozillaXMLOutput(const String& aRootName,
|
|||
|
||||
txMozillaXMLOutput::txMozillaXMLOutput(txOutputFormat* aFormat,
|
||||
nsIDOMDocumentFragment* aFragment)
|
||||
: mStyleSheetCount(0),
|
||||
mBadChildLevel(0),
|
||||
: mBadChildLevel(0),
|
||||
mDontAddCurrent(PR_FALSE),
|
||||
mHaveTitleElement(PR_FALSE),
|
||||
mHaveBaseElement(PR_FALSE),
|
||||
|
@ -314,10 +312,7 @@ void txMozillaXMLOutput::processingInstruction(const String& aTarget, const Stri
|
|||
|
||||
if (ssle) {
|
||||
ssle->SetEnableUpdates(PR_TRUE);
|
||||
rv = ssle->UpdateStyleSheet(nsnull, mStyleSheetCount);
|
||||
if (NS_SUCCEEDED(rv) || (rv == NS_ERROR_HTMLPARSER_BLOCK)) {
|
||||
mStyleSheetCount++;
|
||||
}
|
||||
ssle->UpdateStyleSheet(nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -615,9 +610,7 @@ void txMozillaXMLOutput::endHTMLElement(nsIDOMElement* aElement,
|
|||
do_QueryInterface(aElement);
|
||||
if (ssle) {
|
||||
ssle->SetEnableUpdates(PR_TRUE);
|
||||
rv = ssle->UpdateStyleSheet(nsnull, mStyleSheetCount);
|
||||
if (NS_SUCCEEDED(rv) || (rv == NS_ERROR_HTMLPARSER_BLOCK))
|
||||
mStyleSheetCount++;
|
||||
ssle->UpdateStyleSheet(nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,7 +188,6 @@ private:
|
|||
nsCOMPtr<nsIDOMNode> mNonAddedParent;
|
||||
nsCOMPtr<nsIDOMNode> mNonAddedNode;
|
||||
|
||||
PRInt32 mStyleSheetCount;
|
||||
PRUint32 mBadChildLevel;
|
||||
nsCString mRefreshString;
|
||||
|
||||
|
|
|
@ -1661,21 +1661,21 @@ DocumentViewerImpl::CreateStyleSet(nsIDocument* aDocument,
|
|||
rv = CallCreateInstance(kStyleSetCID, aStyleSet);
|
||||
if (NS_OK == rv) {
|
||||
PRInt32 index = 0;
|
||||
aDocument->GetNumberOfStyleSheets(&index);
|
||||
aDocument->GetNumberOfStyleSheets(PR_TRUE, &index);
|
||||
|
||||
while (0 < index--) {
|
||||
nsCOMPtr<nsIStyleSheet> sheet;
|
||||
aDocument->GetStyleSheetAt(index, getter_AddRefs(sheet));
|
||||
aDocument->GetStyleSheetAt(index, PR_TRUE, getter_AddRefs(sheet));
|
||||
|
||||
/*
|
||||
* GetStyleSheetAt will return all style sheets in the document but
|
||||
* we're only interested in the ones that are enabled.
|
||||
*/
|
||||
|
||||
PRBool styleEnabled;
|
||||
sheet->GetEnabled(styleEnabled);
|
||||
PRBool styleApplicable;
|
||||
sheet->GetApplicable(styleApplicable);
|
||||
|
||||
if (styleEnabled) {
|
||||
if (styleApplicable) {
|
||||
(*aStyleSet)->AddDocStyleSheet(sheet, aDocument);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1969,19 +1969,21 @@ PresShell::SelectAlternateStyleSheet(const nsString& aSheetTitle)
|
|||
{
|
||||
if (mDocument && mStyleSet) {
|
||||
PRInt32 count = 0;
|
||||
mDocument->GetNumberOfStyleSheets(&count);
|
||||
mDocument->GetNumberOfStyleSheets(PR_FALSE, &count);
|
||||
PRInt32 index;
|
||||
NS_NAMED_LITERAL_STRING(textHtml,"text/html");
|
||||
for (index = 0; index < count; index++) {
|
||||
nsCOMPtr<nsIStyleSheet> sheet;
|
||||
mDocument->GetStyleSheetAt(index, getter_AddRefs(sheet));
|
||||
if (sheet) {
|
||||
mDocument->GetStyleSheetAt(index, PR_FALSE, getter_AddRefs(sheet));
|
||||
PRBool complete;
|
||||
sheet->GetComplete(complete);
|
||||
if (complete) {
|
||||
nsAutoString type;
|
||||
sheet->GetType(type);
|
||||
if (PR_FALSE == type.Equals(textHtml)) {
|
||||
nsAutoString title;
|
||||
if (!type.Equals(textHtml)) {
|
||||
nsAutoString title;
|
||||
sheet->GetTitle(title);
|
||||
if (0 < title.Length()) {
|
||||
if (!title.IsEmpty()) {
|
||||
if (title.Equals(aSheetTitle)) {
|
||||
mStyleSet->AddDocStyleSheet(sheet, mDocument);
|
||||
}
|
||||
|
@ -2004,14 +2006,15 @@ PresShell::SelectAlternateStyleSheet(const nsString& aSheetTitle)
|
|||
NS_IMETHODIMP
|
||||
PresShell::ListAlternateStyleSheets(nsStringArray& aTitleList)
|
||||
{
|
||||
// XXX should this be returning incomplete sheets? Probably.
|
||||
if (mDocument) {
|
||||
PRInt32 count = 0;
|
||||
mDocument->GetNumberOfStyleSheets(&count);
|
||||
mDocument->GetNumberOfStyleSheets(PR_FALSE, &count);
|
||||
PRInt32 index;
|
||||
NS_NAMED_LITERAL_STRING(textHtml,"text/html");
|
||||
for (index = 0; index < count; index++) {
|
||||
nsCOMPtr<nsIStyleSheet> sheet;
|
||||
mDocument->GetStyleSheetAt(index, getter_AddRefs(sheet));
|
||||
mDocument->GetStyleSheetAt(index, PR_FALSE, getter_AddRefs(sheet));
|
||||
if (sheet) {
|
||||
nsAutoString type;
|
||||
sheet->GetType(type);
|
||||
|
@ -2149,7 +2152,7 @@ PresShell::SetPreferenceStyleRules(PRBool aForceReflow)
|
|||
// update the styleset now that we are done inserting our rules
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
if (mStyleSet) {
|
||||
mStyleSet->NotifyStyleSheetStateChanged(PR_FALSE);
|
||||
mStyleSet->NotifyStyleSheetStateChanged(PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2215,6 +2218,7 @@ nsresult PresShell::CreatePreferenceStyleSheet(void)
|
|||
NS_ASSERTION(uri, "null but no error");
|
||||
result = mPrefStyleSheet->Init(uri);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
mPrefStyleSheet->SetComplete();
|
||||
mPrefStyleSheet->SetDefaultNameSpaceID(kNameSpaceID_XHTML);
|
||||
mStyleSet->InsertUserStyleSheetBefore(mPrefStyleSheet, nsnull);
|
||||
}
|
||||
|
@ -5465,29 +5469,45 @@ NS_IMETHODIMP
|
|||
PresShell::StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet)
|
||||
{
|
||||
// If style information is being added, we don't need to rebuild the
|
||||
// rule tree, since no rule nodes have been rendered invalid by the
|
||||
// addition of new rule content.
|
||||
return ReconstructStyleData(PR_FALSE);
|
||||
// We only care when enabled sheets are added
|
||||
NS_PRECONDITION(aStyleSheet, "Must have a style sheet!");
|
||||
PRBool applicable;
|
||||
aStyleSheet->GetApplicable(applicable);
|
||||
if (applicable) {
|
||||
// If style information is being added, we don't need to rebuild the
|
||||
// rule tree, since no rule nodes have been rendered invalid by the
|
||||
// addition of new rule content.
|
||||
return ReconstructStyleData(PR_FALSE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PresShell::StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet)
|
||||
{
|
||||
// XXXdwh We'd like to be able to use ReconstructStyleData in all the
|
||||
// other style sheet calls, but it doesn't quite work because of HTML tables.
|
||||
return ReconstructStyleData(PR_TRUE);
|
||||
// We only care when enabled sheets are removed
|
||||
NS_PRECONDITION(aStyleSheet, "Must have a style sheet!");
|
||||
PRBool applicable;
|
||||
aStyleSheet->GetApplicable(applicable);
|
||||
if (applicable) {
|
||||
// XXXdwh We'd like to be able to use ReconstructStyleData in all the
|
||||
// other style sheet calls, but it doesn't quite work because of HTML tables.
|
||||
return ReconstructStyleData(PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PresShell::StyleSheetDisabledStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDisabled)
|
||||
PresShell::StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aApplicable)
|
||||
{
|
||||
// first notify the style set that a sheet's state has changed
|
||||
if (mStyleSet) {
|
||||
nsresult rv = mStyleSet->NotifyStyleSheetStateChanged(!aDisabled);
|
||||
nsresult rv = mStyleSet->NotifyStyleSheetStateChanged(aApplicable);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ public:
|
|||
NS_IMETHOD EnableQuirkStyleSheet(PRBool aEnable) = 0;
|
||||
|
||||
|
||||
NS_IMETHOD NotifyStyleSheetStateChanged(PRBool aDisabled) = 0;
|
||||
NS_IMETHOD NotifyStyleSheetStateChanged(PRBool aApplicable) = 0;
|
||||
|
||||
// get a style context for a non-pseudo frame
|
||||
virtual nsIStyleContext* ResolveStyleFor(nsIPresContext* aPresContext,
|
||||
|
|
|
@ -701,8 +701,7 @@ nsContentDLF::EnsureUAStyleSheet()
|
|||
NS_NewCSSLoader(getter_AddRefs(cssLoader));
|
||||
if (!cssLoader)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
PRBool complete;
|
||||
rv = cssLoader->LoadAgentSheet(uri, gUAStyleSheet, complete, nsnull);
|
||||
rv = cssLoader->LoadAgentSheet(uri, &gUAStyleSheet);
|
||||
#ifdef DEBUG
|
||||
if (NS_FAILED(rv))
|
||||
printf("*** open of %s failed: error=%x\n", UA_CSS_URL, rv);
|
||||
|
|
|
@ -131,9 +131,9 @@ public:
|
|||
nsIStyleSheet* aStyleSheet) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDisabled) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aApplicable) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule,
|
||||
|
|
|
@ -131,9 +131,9 @@ public:
|
|||
nsIStyleSheet* aStyleSheet) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetDisabledStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDisabled) { return NS_OK; }
|
||||
NS_IMETHOD StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aApplicable) { return NS_OK; }
|
||||
NS_IMETHOD StyleRuleChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
nsIStyleRule* aStyleRule,
|
||||
|
|
|
@ -1969,19 +1969,21 @@ PresShell::SelectAlternateStyleSheet(const nsString& aSheetTitle)
|
|||
{
|
||||
if (mDocument && mStyleSet) {
|
||||
PRInt32 count = 0;
|
||||
mDocument->GetNumberOfStyleSheets(&count);
|
||||
mDocument->GetNumberOfStyleSheets(PR_FALSE, &count);
|
||||
PRInt32 index;
|
||||
NS_NAMED_LITERAL_STRING(textHtml,"text/html");
|
||||
for (index = 0; index < count; index++) {
|
||||
nsCOMPtr<nsIStyleSheet> sheet;
|
||||
mDocument->GetStyleSheetAt(index, getter_AddRefs(sheet));
|
||||
if (sheet) {
|
||||
mDocument->GetStyleSheetAt(index, PR_FALSE, getter_AddRefs(sheet));
|
||||
PRBool complete;
|
||||
sheet->GetComplete(complete);
|
||||
if (complete) {
|
||||
nsAutoString type;
|
||||
sheet->GetType(type);
|
||||
if (PR_FALSE == type.Equals(textHtml)) {
|
||||
nsAutoString title;
|
||||
if (!type.Equals(textHtml)) {
|
||||
nsAutoString title;
|
||||
sheet->GetTitle(title);
|
||||
if (0 < title.Length()) {
|
||||
if (!title.IsEmpty()) {
|
||||
if (title.Equals(aSheetTitle)) {
|
||||
mStyleSet->AddDocStyleSheet(sheet, mDocument);
|
||||
}
|
||||
|
@ -2004,14 +2006,15 @@ PresShell::SelectAlternateStyleSheet(const nsString& aSheetTitle)
|
|||
NS_IMETHODIMP
|
||||
PresShell::ListAlternateStyleSheets(nsStringArray& aTitleList)
|
||||
{
|
||||
// XXX should this be returning incomplete sheets? Probably.
|
||||
if (mDocument) {
|
||||
PRInt32 count = 0;
|
||||
mDocument->GetNumberOfStyleSheets(&count);
|
||||
mDocument->GetNumberOfStyleSheets(PR_FALSE, &count);
|
||||
PRInt32 index;
|
||||
NS_NAMED_LITERAL_STRING(textHtml,"text/html");
|
||||
for (index = 0; index < count; index++) {
|
||||
nsCOMPtr<nsIStyleSheet> sheet;
|
||||
mDocument->GetStyleSheetAt(index, getter_AddRefs(sheet));
|
||||
mDocument->GetStyleSheetAt(index, PR_FALSE, getter_AddRefs(sheet));
|
||||
if (sheet) {
|
||||
nsAutoString type;
|
||||
sheet->GetType(type);
|
||||
|
@ -2149,7 +2152,7 @@ PresShell::SetPreferenceStyleRules(PRBool aForceReflow)
|
|||
// update the styleset now that we are done inserting our rules
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
if (mStyleSet) {
|
||||
mStyleSet->NotifyStyleSheetStateChanged(PR_FALSE);
|
||||
mStyleSet->NotifyStyleSheetStateChanged(PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2215,6 +2218,7 @@ nsresult PresShell::CreatePreferenceStyleSheet(void)
|
|||
NS_ASSERTION(uri, "null but no error");
|
||||
result = mPrefStyleSheet->Init(uri);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
mPrefStyleSheet->SetComplete();
|
||||
mPrefStyleSheet->SetDefaultNameSpaceID(kNameSpaceID_XHTML);
|
||||
mStyleSet->InsertUserStyleSheetBefore(mPrefStyleSheet, nsnull);
|
||||
}
|
||||
|
@ -5465,29 +5469,45 @@ NS_IMETHODIMP
|
|||
PresShell::StyleSheetAdded(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet)
|
||||
{
|
||||
// If style information is being added, we don't need to rebuild the
|
||||
// rule tree, since no rule nodes have been rendered invalid by the
|
||||
// addition of new rule content.
|
||||
return ReconstructStyleData(PR_FALSE);
|
||||
// We only care when enabled sheets are added
|
||||
NS_PRECONDITION(aStyleSheet, "Must have a style sheet!");
|
||||
PRBool applicable;
|
||||
aStyleSheet->GetApplicable(applicable);
|
||||
if (applicable) {
|
||||
// If style information is being added, we don't need to rebuild the
|
||||
// rule tree, since no rule nodes have been rendered invalid by the
|
||||
// addition of new rule content.
|
||||
return ReconstructStyleData(PR_FALSE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PresShell::StyleSheetRemoved(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet)
|
||||
{
|
||||
// XXXdwh We'd like to be able to use ReconstructStyleData in all the
|
||||
// other style sheet calls, but it doesn't quite work because of HTML tables.
|
||||
return ReconstructStyleData(PR_TRUE);
|
||||
// We only care when enabled sheets are removed
|
||||
NS_PRECONDITION(aStyleSheet, "Must have a style sheet!");
|
||||
PRBool applicable;
|
||||
aStyleSheet->GetApplicable(applicable);
|
||||
if (applicable) {
|
||||
// XXXdwh We'd like to be able to use ReconstructStyleData in all the
|
||||
// other style sheet calls, but it doesn't quite work because of HTML tables.
|
||||
return ReconstructStyleData(PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PresShell::StyleSheetDisabledStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aDisabled)
|
||||
PresShell::StyleSheetApplicableStateChanged(nsIDocument *aDocument,
|
||||
nsIStyleSheet* aStyleSheet,
|
||||
PRBool aApplicable)
|
||||
{
|
||||
// first notify the style set that a sheet's state has changed
|
||||
if (mStyleSet) {
|
||||
nsresult rv = mStyleSet->NotifyStyleSheetStateChanged(!aDisabled);
|
||||
nsresult rv = mStyleSet->NotifyStyleSheetStateChanged(aApplicable);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -73,10 +73,11 @@ ParseCSSFile(nsIURI *aSheetURI)
|
|||
{
|
||||
nsCOMPtr<nsICSSLoader> loader(do_CreateInstance(kCSSLoaderCID));
|
||||
nsCOMPtr<nsICSSStyleSheet> sheet;
|
||||
loader->LoadAgentSheet(aSheetURI, getter_AddRefs(sheet));
|
||||
NS_ASSERTION(sheet, "sheet load failed");
|
||||
PRBool complete;
|
||||
loader->LoadAgentSheet(aSheetURI, *getter_AddRefs(sheet),
|
||||
complete, nsnull);
|
||||
NS_ASSERTION(complete, "not complete");
|
||||
sheet->GetComplete(complete);
|
||||
NS_ASSERTION(complete, "synchronous load did not complete");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
|
|
@ -653,6 +653,8 @@ nsMathMLFrame::MapAttributesIntoCSS(nsIPresContext* aPresContext,
|
|||
// that may come from reconstructing the frame tree. Our rules only need
|
||||
// a re-resolve of style data and a reflow, not a reconstruct-all...
|
||||
sheet->SetOwningDocument(nsnull);
|
||||
// We're about to manipulate the CSSOM, so we better do this
|
||||
sheet->SetComplete();
|
||||
}
|
||||
|
||||
// check for duplicate, if a similar rule is already there, don't bother to add another one
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -333,7 +333,6 @@ protected:
|
|||
nsCSSScanner* mScanner;
|
||||
nsIURI* mURL;
|
||||
nsICSSStyleSheet* mSheet;
|
||||
PRInt32 mChildSheetCount;
|
||||
nsICSSLoader* mChildLoader; // not ref counted, it owns us
|
||||
|
||||
enum nsCSSSection {
|
||||
|
@ -428,7 +427,6 @@ CSSParserImpl::CSSParserImpl()
|
|||
mScanner(nsnull),
|
||||
mURL(nsnull),
|
||||
mSheet(nsnull),
|
||||
mChildSheetCount(0),
|
||||
mChildLoader(nsnull),
|
||||
mSection(eCSSSection_Charset),
|
||||
mNavQuirkMode(PR_FALSE),
|
||||
|
@ -449,7 +447,6 @@ CSSParserImpl::Init(nsICSSStyleSheet* aSheet)
|
|||
mSheet = aSheet;
|
||||
if (mSheet) {
|
||||
NS_ADDREF(aSheet);
|
||||
mSheet->StyleSheetCount(mChildSheetCount);
|
||||
mSheet->GetNameSpace(mNameSpace);
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -486,7 +483,6 @@ CSSParserImpl::SetStyleSheet(nsICSSStyleSheet* aSheet)
|
|||
NS_IF_RELEASE(mSheet);
|
||||
mSheet = aSheet;
|
||||
NS_ADDREF(mSheet);
|
||||
mSheet->StyleSheetCount(mChildSheetCount);
|
||||
mSheet->GetNameSpace(mNameSpace);
|
||||
}
|
||||
|
||||
|
@ -554,8 +550,17 @@ CSSParserImpl::Parse(nsIUnicharInputStream* aInput,
|
|||
|
||||
if (! mSheet) {
|
||||
NS_NewCSSStyleSheet(&mSheet, aInputURL);
|
||||
mChildSheetCount = 0;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
mSheet->GetURL(*getter_AddRefs(uri));
|
||||
PRBool equal;
|
||||
aInputURL->Equals(uri, &equal);
|
||||
NS_ASSERTION(equal, "Sheet URI does not match passed URI");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (! mSheet) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1189,7 +1194,7 @@ PRBool CSSParserImpl::ProcessImport(PRInt32& aErrorCode, const nsString& aURLSpe
|
|||
PRBool bContains = PR_FALSE;
|
||||
if (NS_SUCCEEDED(mSheet->ContainsStyleSheet(url,bContains)) &&
|
||||
bContains != PR_TRUE ) { // don't allow circular references
|
||||
mChildLoader->LoadChildSheet(mSheet, url, aMedia, kNameSpaceID_Unknown, mChildSheetCount++, rule);
|
||||
mChildLoader->LoadChildSheet(mSheet, url, aMedia, kNameSpaceID_Unknown, rule);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -805,6 +805,7 @@ public:
|
|||
nsCOMPtr<nsINameSpace> mNameSpace;
|
||||
PRInt32 mDefaultNameSpaceID;
|
||||
nsHashtable mRelevantAttributes;
|
||||
PRPackedBool mComplete;
|
||||
};
|
||||
|
||||
|
||||
|
@ -829,7 +830,7 @@ public:
|
|||
NS_IMETHOD Init(nsIURI* aURL);
|
||||
NS_IMETHOD GetURL(nsIURI*& aURL) const;
|
||||
NS_IMETHOD GetTitle(nsString& aTitle) const;
|
||||
NS_IMETHOD SetTitle(const nsString& aTitle);
|
||||
NS_IMETHOD SetTitle(const nsAString& aTitle);
|
||||
NS_IMETHOD GetType(nsString& aType) const;
|
||||
NS_IMETHOD GetMediumCount(PRInt32& aCount) const;
|
||||
NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const;
|
||||
|
@ -839,9 +840,13 @@ public:
|
|||
NS_IMETHOD DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex);
|
||||
NS_IMETHOD InsertRuleIntoGroup(const nsAString& aRule, nsICSSGroupRule* aGroup, PRUint32 aIndex, PRUint32* _retval);
|
||||
|
||||
NS_IMETHOD GetEnabled(PRBool& aEnabled) const;
|
||||
NS_IMETHOD GetApplicable(PRBool& aApplicable) const;
|
||||
|
||||
NS_IMETHOD SetEnabled(PRBool aEnabled);
|
||||
|
||||
NS_IMETHOD GetComplete(PRBool& aComplete) const;
|
||||
NS_IMETHOD SetComplete();
|
||||
|
||||
// style sheet owner info
|
||||
NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const; // may be null
|
||||
NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const;
|
||||
|
@ -927,8 +932,8 @@ protected:
|
|||
CSSRuleListImpl* mRuleCollection;
|
||||
nsIDocument* mDocument;
|
||||
nsIDOMNode* mOwningNode; // weak ref
|
||||
PRBool mDisabled;
|
||||
PRBool mDirty; // has been modified
|
||||
PRPackedBool mDisabled;
|
||||
PRPackedBool mDirty; // has been modified
|
||||
|
||||
CSSStyleSheetInner* mInner;
|
||||
|
||||
|
@ -1482,7 +1487,8 @@ CSSStyleSheetInner::CSSStyleSheetInner(nsICSSStyleSheet* aParentSheet)
|
|||
mOrderedRules(nsnull),
|
||||
mNameSpace(nsnull),
|
||||
mDefaultNameSpaceID(kNameSpaceID_None),
|
||||
mRelevantAttributes()
|
||||
mRelevantAttributes(),
|
||||
mComplete(PR_FALSE)
|
||||
{
|
||||
MOZ_COUNT_CTOR(CSSStyleSheetInner);
|
||||
mSheets.AppendElement(aParentSheet);
|
||||
|
@ -1519,7 +1525,8 @@ CSSStyleSheetInner::CSSStyleSheetInner(CSSStyleSheetInner& aCopy,
|
|||
mURL(aCopy.mURL),
|
||||
mNameSpace(nsnull),
|
||||
mDefaultNameSpaceID(aCopy.mDefaultNameSpaceID),
|
||||
mRelevantAttributes()
|
||||
mRelevantAttributes(),
|
||||
mComplete(aCopy.mComplete)
|
||||
{
|
||||
MOZ_COUNT_CTOR(CSSStyleSheetInner);
|
||||
mSheets.AppendElement(aParentSheet);
|
||||
|
@ -1758,6 +1765,7 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(const CSSStyleSheetImpl& aCopy)
|
|||
|
||||
if (aCopy.mRuleCollection &&
|
||||
aCopy.mRuleCollection->mRulesAccessed) { // CSSOM's been there, force full copy now
|
||||
NS_ASSERTION(mInner->mComplete, "Why have rules been accessed on an incomplete sheet?");
|
||||
EnsureUniqueInner();
|
||||
}
|
||||
|
||||
|
@ -1925,7 +1933,7 @@ CSSStyleSheetImpl::GetURL(nsIURI*& aURL) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::SetTitle(const nsString& aTitle)
|
||||
CSSStyleSheetImpl::SetTitle(const nsAString& aTitle)
|
||||
{
|
||||
mTitle = aTitle;
|
||||
return NS_OK;
|
||||
|
@ -2012,25 +2020,46 @@ CSSStyleSheetImpl::ClearMedia(void)
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::GetEnabled(PRBool& aEnabled) const
|
||||
CSSStyleSheetImpl::GetApplicable(PRBool& aApplicable) const
|
||||
{
|
||||
aEnabled = !mDisabled;
|
||||
aApplicable = !mDisabled && mInner && mInner->mComplete;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::SetEnabled(PRBool aEnabled)
|
||||
{
|
||||
PRBool oldState = mDisabled;
|
||||
PRBool oldDisabled = mDisabled;
|
||||
mDisabled = !aEnabled;
|
||||
|
||||
if ((nsnull != mDocument) && (mDisabled != oldState)) {
|
||||
mDocument->SetStyleSheetDisabledState(this, mDisabled);
|
||||
if (mDocument && mInner && mInner->mComplete && oldDisabled != mDisabled) {
|
||||
mDocument->SetStyleSheetApplicableState(this, !mDisabled);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::GetComplete(PRBool& aComplete) const
|
||||
{
|
||||
aComplete = mInner && mInner->mComplete;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::SetComplete()
|
||||
{
|
||||
if (!mInner)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
NS_ASSERTION(!mDirty, "Can't set a dirty sheet complete!");
|
||||
mInner->mComplete = PR_TRUE;
|
||||
if (mDocument && !mDisabled) {
|
||||
// Let the document know
|
||||
mDocument->SetStyleSheetApplicableState(this, PR_TRUE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::GetParentSheet(nsIStyleSheet*& aParent) const
|
||||
{
|
||||
|
@ -2416,7 +2445,7 @@ CSSStyleSheetImpl::EnsureUniqueInner(void)
|
|||
if (! mInner) {
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
if (1 < mInner->mSheets.Count()) {
|
||||
if (1 < mInner->mSheets.Count()) {
|
||||
CSSStyleSheetInner* clone = mInner->CloneFor(this);
|
||||
if (clone) {
|
||||
mInner->RemoveSheet(this);
|
||||
|
@ -2609,6 +2638,11 @@ CSSStyleSheetImpl::ClearRuleCascades(void)
|
|||
nsresult
|
||||
CSSStyleSheetImpl::WillDirty(void)
|
||||
{
|
||||
if (mInner && !mInner->mComplete) {
|
||||
// Do nothing
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return EnsureUniqueInner();
|
||||
}
|
||||
|
||||
|
@ -2651,11 +2685,11 @@ CSSStyleSheetImpl::GetDisabled(PRBool* aDisabled)
|
|||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::SetDisabled(PRBool aDisabled)
|
||||
{
|
||||
PRBool oldState = mDisabled;
|
||||
PRBool oldDisabled = mDisabled;
|
||||
mDisabled = aDisabled;
|
||||
|
||||
if (mDocument && (mDisabled != oldState)) {
|
||||
mDocument->SetStyleSheetDisabledState(this, mDisabled);
|
||||
if (mDocument && mInner && mInner->mComplete && oldDisabled != mDisabled) {
|
||||
mDocument->SetStyleSheetApplicableState(this, !mDisabled);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -2750,6 +2784,13 @@ CSSStyleSheetImpl::GetOwnerRule(nsIDOMCSSRule** aOwnerRule)
|
|||
NS_IMETHODIMP
|
||||
CSSStyleSheetImpl::GetCssRules(nsIDOMCSSRuleList** aCssRules)
|
||||
{
|
||||
// No doing this on incomplete sheets!
|
||||
PRBool complete;
|
||||
GetComplete(complete);
|
||||
if (!complete) {
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
}
|
||||
|
||||
//-- Security check: Only scripts from the same origin as the
|
||||
// style sheet can access rule collections
|
||||
|
||||
|
@ -2798,6 +2839,13 @@ CSSStyleSheetImpl::InsertRule(const nsAString& aRule,
|
|||
PRUint32* aReturn)
|
||||
{
|
||||
NS_ENSURE_TRUE(mInner, NS_ERROR_FAILURE);
|
||||
// No doing this if the sheet is not complete!
|
||||
PRBool complete;
|
||||
GetComplete(complete);
|
||||
if (!complete) {
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
}
|
||||
|
||||
nsresult result;
|
||||
result = WillDirty();
|
||||
if (NS_FAILED(result))
|
||||
|
@ -2979,6 +3027,12 @@ NS_IMETHODIMP
|
|||
CSSStyleSheetImpl::DeleteRule(PRUint32 aIndex)
|
||||
{
|
||||
nsresult result = NS_ERROR_DOM_INDEX_SIZE_ERR;
|
||||
// No doing this if the sheet is not complete!
|
||||
PRBool complete;
|
||||
GetComplete(complete);
|
||||
if (!complete) {
|
||||
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
|
||||
}
|
||||
|
||||
// XXX TBI: handle @rule types
|
||||
if (mInner && mInner->mOrderedRules) {
|
||||
|
@ -3020,7 +3074,8 @@ NS_IMETHODIMP
|
|||
CSSStyleSheetImpl::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aGroup);
|
||||
|
||||
NS_ASSERTION(mInner && mInner->mComplete,
|
||||
"No deleting from an incomplete sheet!");
|
||||
nsresult result;
|
||||
nsCOMPtr<nsICSSRule> rule;
|
||||
result = aGroup->GetStyleRuleAt(aIndex, *getter_AddRefs(rule));
|
||||
|
@ -3038,8 +3093,10 @@ CSSStyleSheetImpl::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex)
|
|||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
result = mDocument->BeginUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
if (mDocument) {
|
||||
result = mDocument->BeginUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
result = WillDirty();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
@ -3051,11 +3108,13 @@ CSSStyleSheetImpl::DeleteRuleFromGroup(nsICSSGroupRule* aGroup, PRUint32 aIndex)
|
|||
|
||||
DidDirty();
|
||||
|
||||
result = mDocument->StyleRuleRemoved(this, rule);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = mDocument->EndUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
if (mDocument) {
|
||||
result = mDocument->StyleRuleRemoved(this, rule);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = mDocument->EndUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3064,6 +3123,8 @@ NS_IMETHODIMP
|
|||
CSSStyleSheetImpl::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule* aGroup, PRUint32 aIndex, PRUint32* _retval)
|
||||
{
|
||||
nsresult result;
|
||||
NS_ASSERTION(mInner && mInner->mComplete,
|
||||
"No inserting into an incomplete sheet!");
|
||||
// check that the group actually belongs to this sheet!
|
||||
nsCOMPtr<nsIDOMCSSRule> domGroup(do_QueryInterface(aGroup));
|
||||
nsCOMPtr<nsIDOMCSSStyleSheet> groupSheet;
|
||||
|
@ -3097,8 +3158,10 @@ CSSStyleSheetImpl::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule*
|
|||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
// parse and grab the rule
|
||||
result = mDocument->BeginUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
if (mDocument) {
|
||||
result = mDocument->BeginUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
result = WillDirty();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
@ -3132,12 +3195,16 @@ CSSStyleSheetImpl::InsertRuleIntoGroup(const nsAString & aRule, nsICSSGroupRule*
|
|||
rule = dont_AddRef((nsICSSRule*)rules->ElementAt(counter));
|
||||
CheckRuleForAttributes(rule);
|
||||
|
||||
result = mDocument->StyleRuleAdded(this, rule);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
if (mDocument) {
|
||||
result = mDocument->StyleRuleAdded(this, rule);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
}
|
||||
|
||||
result = mDocument->EndUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
if (mDocument) {
|
||||
result = mDocument->EndUpdate();
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
if (loader) {
|
||||
loader->RecycleParser(css);
|
||||
|
@ -4459,10 +4526,10 @@ CSSRuleProcessor::CascadeSheetRulesInto(nsISupports* aSheet, void* aData)
|
|||
nsICSSStyleSheet* iSheet = (nsICSSStyleSheet*)aSheet;
|
||||
CSSStyleSheetImpl* sheet = (CSSStyleSheetImpl*)iSheet;
|
||||
CascadeEnumData* data = (CascadeEnumData*)aData;
|
||||
PRBool bSheetEnabled = PR_TRUE;
|
||||
sheet->GetEnabled(bSheetEnabled);
|
||||
PRBool bSheetApplicable = PR_TRUE;
|
||||
sheet->GetApplicable(bSheetApplicable);
|
||||
|
||||
if ((bSheetEnabled) && (sheet->UseForMedium(data->mMedium))) {
|
||||
if (bSheetApplicable && sheet->UseForMedium(data->mMedium)) {
|
||||
CSSStyleSheetImpl* child = sheet->mFirstChild;
|
||||
while (child) {
|
||||
CascadeSheetRulesInto((nsICSSStyleSheet*)child, data);
|
||||
|
|
|
@ -200,9 +200,13 @@ public:
|
|||
NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const;
|
||||
NS_IMETHOD_(PRBool) UseForMedium(nsIAtom* aMedium) const;
|
||||
|
||||
NS_IMETHOD GetEnabled(PRBool& aEnabled) const;
|
||||
NS_IMETHOD GetApplicable(PRBool& aApplicable) const;
|
||||
|
||||
NS_IMETHOD SetEnabled(PRBool aEnabled);
|
||||
|
||||
NS_IMETHOD GetComplete(PRBool& aComplete) const;
|
||||
NS_IMETHOD SetComplete();
|
||||
|
||||
// style sheet owner info
|
||||
NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const; // will be null
|
||||
NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const;
|
||||
|
@ -427,9 +431,9 @@ HTMLCSSStyleSheetImpl::UseForMedium(nsIAtom* aMedium) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLCSSStyleSheetImpl::GetEnabled(PRBool& aEnabled) const
|
||||
HTMLCSSStyleSheetImpl::GetApplicable(PRBool& aApplicable) const
|
||||
{
|
||||
aEnabled = PR_TRUE;
|
||||
aApplicable = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -439,6 +443,19 @@ HTMLCSSStyleSheetImpl::SetEnabled(PRBool aEnabled)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLCSSStyleSheetImpl::GetComplete(PRBool& aComplete) const
|
||||
{
|
||||
aComplete = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLCSSStyleSheetImpl::SetComplete()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// style sheet owner info
|
||||
NS_IMETHODIMP
|
||||
HTMLCSSStyleSheetImpl::GetParentSheet(nsIStyleSheet*& aParent) const
|
||||
|
|
|
@ -743,9 +743,13 @@ public:
|
|||
NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const;
|
||||
NS_IMETHOD_(PRBool) UseForMedium(nsIAtom* aMedium) const;
|
||||
|
||||
NS_IMETHOD GetEnabled(PRBool& aEnabled) const;
|
||||
NS_IMETHOD GetApplicable(PRBool& aApplicable) const;
|
||||
|
||||
NS_IMETHOD SetEnabled(PRBool aEnabled);
|
||||
|
||||
NS_IMETHOD GetComplete(PRBool& aComplete) const;
|
||||
NS_IMETHOD SetComplete();
|
||||
|
||||
// style sheet owner info
|
||||
NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const; // will be null
|
||||
NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const;
|
||||
|
@ -1105,9 +1109,9 @@ HTMLStyleSheetImpl::UseForMedium(nsIAtom* aMedium) const
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::GetEnabled(PRBool& aEnabled) const
|
||||
HTMLStyleSheetImpl::GetApplicable(PRBool& aApplicable) const
|
||||
{
|
||||
aEnabled = PR_TRUE;
|
||||
aApplicable = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1117,6 +1121,19 @@ HTMLStyleSheetImpl::SetEnabled(PRBool aEnabled)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::GetComplete(PRBool& aComplete) const
|
||||
{
|
||||
aComplete = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::SetComplete()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HTMLStyleSheetImpl::GetParentSheet(nsIStyleSheet*& aParent) const
|
||||
{
|
||||
|
|
|
@ -77,17 +77,18 @@ public:
|
|||
nsICSSParser** aParser) = 0;
|
||||
NS_IMETHOD RecycleParser(nsICSSParser* aParser) = 0;
|
||||
|
||||
// XXX No one uses the aDefaultNameSpaceID params.... do we need them?
|
||||
|
||||
// Load an inline style sheet
|
||||
// - if aCompleted is PR_TRUE, the sheet is fully loaded, don't
|
||||
// block for it.
|
||||
// - if aCompleted is PR_FALSE, the sheet is still loading and
|
||||
// will be inserted in the document when complete
|
||||
// will be marked complete when complete
|
||||
NS_IMETHOD LoadInlineStyle(nsIContent* aElement,
|
||||
nsIUnicharInputStream* aIn,
|
||||
nsIUnicharInputStream* aStream,
|
||||
const nsString& aTitle,
|
||||
const nsString& aMedia,
|
||||
PRInt32 aDefaultNameSpaceID,
|
||||
PRInt32 aDocIndex,
|
||||
nsIParser* aParserToUnblock,
|
||||
PRBool& aCompleted,
|
||||
nsICSSLoaderObserver* aObserver) = 0;
|
||||
|
@ -96,13 +97,12 @@ public:
|
|||
// - if aCompleted is PR_TRUE, the sheet is fully loaded, don't
|
||||
// block for it.
|
||||
// - if aCompleted is PR_FALSE, the sheet is still loading and
|
||||
// will be inserted in the document when complete
|
||||
// will be marked complete when complete
|
||||
NS_IMETHOD LoadStyleLink(nsIContent* aElement,
|
||||
nsIURI* aURL,
|
||||
const nsString& aTitle,
|
||||
const nsString& aMedia,
|
||||
PRInt32 aDefaultNameSpaceID,
|
||||
PRInt32 aDocIndex,
|
||||
nsIParser* aParserToUnblock,
|
||||
PRBool& aCompleted,
|
||||
nsICSSLoaderObserver* aObserver) = 0;
|
||||
|
@ -112,18 +112,15 @@ public:
|
|||
nsIURI* aURL,
|
||||
const nsString& aMedia,
|
||||
PRInt32 aDefaultNameSpaceID,
|
||||
PRInt32 aSheetIndex,
|
||||
nsICSSImportRule* aRule) = 0;
|
||||
|
||||
// Load a user agent or user sheet immediately
|
||||
// (note that @imports mayl come in asynchronously)
|
||||
// - if aCompleted is PR_TRUE, the sheet is fully loaded
|
||||
// - if aCompleted is PR_FALSE, the sheet is still loading and
|
||||
// aCAllback will be called when the sheet is complete
|
||||
NS_IMETHOD LoadAgentSheet(nsIURI* aURL,
|
||||
nsICSSStyleSheet*& aSheet,
|
||||
PRBool& aCompleted,
|
||||
nsICSSLoaderObserver* aObserver) = 0;
|
||||
// Load a user agent or user sheet. The sheet is loaded
|
||||
// synchronously, including @imports from it.
|
||||
NS_IMETHOD LoadAgentSheet(nsIURI* aURL, nsICSSStyleSheet** aSheet) = 0;
|
||||
|
||||
// Load a user agent or user sheet. The sheet is loaded
|
||||
// asynchronously and the observer notified when the load finishes.
|
||||
NS_IMETHOD LoadAgentSheet(nsIURI* aURL, nsICSSLoaderObserver* aObserver) = 0;
|
||||
|
||||
// stop loading all sheets
|
||||
NS_IMETHOD Stop(void) = 0;
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
NS_IMETHOD GetStyleSheetAt(PRInt32 aIndex, nsICSSStyleSheet*& aSheet) const = 0;
|
||||
|
||||
NS_IMETHOD Init(nsIURI* aURL) = 0;
|
||||
NS_IMETHOD SetTitle(const nsString& aTitle) = 0;
|
||||
NS_IMETHOD SetTitle(const nsAString& aTitle) = 0;
|
||||
NS_IMETHOD AppendMedium(nsIAtom* aMedium) = 0;
|
||||
NS_IMETHOD ClearMedia(void) = 0;
|
||||
NS_IMETHOD SetOwningNode(nsIDOMNode* aOwningNode) = 0;
|
||||
|
|
|
@ -70,9 +70,27 @@ public:
|
|||
NS_IMETHOD GetMediumAt(PRInt32 aIndex, nsIAtom*& aMedium) const = 0;
|
||||
NS_IMETHOD_(PRBool) UseForMedium(nsIAtom* aMedium) const = 0;
|
||||
|
||||
NS_IMETHOD GetEnabled(PRBool& aEnabled) const = 0;
|
||||
/**
|
||||
* Whether the sheet is applicable. A sheet that is not applicable
|
||||
* should never be inserted into a style set. A sheet may not be
|
||||
* applicable for a variety of reasons including being disabled and
|
||||
* being incomplete.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD GetApplicable(PRBool& aApplicable) const = 0;
|
||||
|
||||
/**
|
||||
* Set the stylesheet to be enabled. This may or may not make it
|
||||
* applicable.
|
||||
*/
|
||||
NS_IMETHOD SetEnabled(PRBool aEnabled) = 0;
|
||||
|
||||
/**
|
||||
* Whether the sheet is complete.
|
||||
*/
|
||||
NS_IMETHOD GetComplete(PRBool& aComplete) const = 0;
|
||||
NS_IMETHOD SetComplete() = 0;
|
||||
|
||||
// style sheet owner info
|
||||
NS_IMETHOD GetParentSheet(nsIStyleSheet*& aParent) const = 0; // may be null
|
||||
NS_IMETHOD GetOwningDocument(nsIDocument*& aDocument) const = 0; // may be null
|
||||
|
|
|
@ -568,6 +568,11 @@ StyleSetImpl::GatherRuleProcessors(void)
|
|||
void StyleSetImpl::AppendOverrideStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mOverrideSheets)) {
|
||||
mOverrideSheets->RemoveElement(aSheet);
|
||||
mOverrideSheets->AppendElement(aSheet);
|
||||
|
@ -579,6 +584,11 @@ void StyleSetImpl::InsertOverrideStyleSheetAfter(nsIStyleSheet* aSheet,
|
|||
nsIStyleSheet* aAfterSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mOverrideSheets)) {
|
||||
mOverrideSheets->RemoveElement(aSheet);
|
||||
PRInt32 index = mOverrideSheets->IndexOf(aAfterSheet);
|
||||
|
@ -591,6 +601,11 @@ void StyleSetImpl::InsertOverrideStyleSheetBefore(nsIStyleSheet* aSheet,
|
|||
nsIStyleSheet* aBeforeSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mOverrideSheets)) {
|
||||
mOverrideSheets->RemoveElement(aSheet);
|
||||
PRInt32 index = mOverrideSheets->IndexOf(aBeforeSheet);
|
||||
|
@ -602,7 +617,11 @@ void StyleSetImpl::InsertOverrideStyleSheetBefore(nsIStyleSheet* aSheet,
|
|||
void StyleSetImpl::RemoveOverrideStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool complete = PR_TRUE;
|
||||
aSheet->GetComplete(complete);
|
||||
NS_ASSERTION(complete, "Incomplete sheet being removed from style set");
|
||||
#endif
|
||||
if (nsnull != mOverrideSheets) {
|
||||
mOverrideSheets->RemoveElement(aSheet);
|
||||
ClearOverrideRuleProcessors();
|
||||
|
@ -634,6 +653,11 @@ nsIStyleSheet* StyleSetImpl::GetOverrideStyleSheetAt(PRInt32 aIndex)
|
|||
void StyleSetImpl::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument)
|
||||
{
|
||||
NS_PRECONDITION((nsnull != aSheet) && (nsnull != aDocument), "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mDocSheets)) {
|
||||
mDocSheets->RemoveElement(aSheet);
|
||||
// lowest index last
|
||||
|
@ -670,7 +694,11 @@ void StyleSetImpl::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocumen
|
|||
void StyleSetImpl::RemoveDocStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool complete = PR_TRUE;
|
||||
aSheet->GetComplete(complete);
|
||||
NS_ASSERTION(complete, "Incomplete sheet being removed from style set");
|
||||
#endif
|
||||
if (nsnull != mDocSheets) {
|
||||
mDocSheets->RemoveElement(aSheet);
|
||||
ClearDocRuleProcessors();
|
||||
|
@ -702,6 +730,11 @@ nsIStyleSheet* StyleSetImpl::GetDocStyleSheetAt(PRInt32 aIndex)
|
|||
void StyleSetImpl::AppendUserStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mUserSheets)) {
|
||||
mUserSheets->RemoveElement(aSheet);
|
||||
mUserSheets->AppendElement(aSheet);
|
||||
|
@ -713,6 +746,11 @@ void StyleSetImpl::InsertUserStyleSheetAfter(nsIStyleSheet* aSheet,
|
|||
nsIStyleSheet* aAfterSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mUserSheets)) {
|
||||
mUserSheets->RemoveElement(aSheet);
|
||||
PRInt32 index = mUserSheets->IndexOf(aAfterSheet);
|
||||
|
@ -725,6 +763,11 @@ void StyleSetImpl::InsertUserStyleSheetBefore(nsIStyleSheet* aSheet,
|
|||
nsIStyleSheet* aBeforeSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mUserSheets)) {
|
||||
mUserSheets->RemoveElement(aSheet);
|
||||
PRInt32 index = mUserSheets->IndexOf(aBeforeSheet);
|
||||
|
@ -736,7 +779,11 @@ void StyleSetImpl::InsertUserStyleSheetBefore(nsIStyleSheet* aSheet,
|
|||
void StyleSetImpl::RemoveUserStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool complete = PR_TRUE;
|
||||
aSheet->GetComplete(complete);
|
||||
NS_ASSERTION(complete, "Incomplete sheet being removed from style set");
|
||||
#endif
|
||||
if (nsnull != mUserSheets) {
|
||||
mUserSheets->RemoveElement(aSheet);
|
||||
ClearUserRuleProcessors();
|
||||
|
@ -775,6 +822,11 @@ StyleSetImpl::ReplaceUserStyleSheets(nsISupportsArray* aNewUserSheets)
|
|||
void StyleSetImpl::AppendAgentStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mAgentSheets)) {
|
||||
mAgentSheets->RemoveElement(aSheet);
|
||||
mAgentSheets->AppendElement(aSheet);
|
||||
|
@ -786,6 +838,11 @@ void StyleSetImpl::InsertAgentStyleSheetAfter(nsIStyleSheet* aSheet,
|
|||
nsIStyleSheet* aAfterSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mAgentSheets)) {
|
||||
mAgentSheets->RemoveElement(aSheet);
|
||||
PRInt32 index = mAgentSheets->IndexOf(aAfterSheet);
|
||||
|
@ -798,6 +855,11 @@ void StyleSetImpl::InsertAgentStyleSheetBefore(nsIStyleSheet* aSheet,
|
|||
nsIStyleSheet* aBeforeSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
#ifdef DEBUG
|
||||
PRBool applicable = PR_TRUE;
|
||||
aSheet->GetApplicable(applicable);
|
||||
NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");
|
||||
#endif
|
||||
if (EnsureArray(mAgentSheets)) {
|
||||
mAgentSheets->RemoveElement(aSheet);
|
||||
PRInt32 index = mAgentSheets->IndexOf(aBeforeSheet);
|
||||
|
@ -809,7 +871,11 @@ void StyleSetImpl::InsertAgentStyleSheetBefore(nsIStyleSheet* aSheet,
|
|||
void StyleSetImpl::RemoveAgentStyleSheet(nsIStyleSheet* aSheet)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSheet, "null arg");
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool complete = PR_TRUE;
|
||||
aSheet->GetComplete(complete);
|
||||
NS_ASSERTION(complete, "Incomplete sheet being removed from style set");
|
||||
#endif
|
||||
if (nsnull != mAgentSheets) {
|
||||
mAgentSheets->RemoveElement(aSheet);
|
||||
ClearAgentRuleProcessors();
|
||||
|
@ -870,10 +936,10 @@ NS_IMETHODIMP StyleSetImpl::EnableQuirkStyleSheet(PRBool aEnable)
|
|||
PRUint32 count = 0;
|
||||
if (mAgentRuleProcessors)
|
||||
mAgentRuleProcessors->Count(&count);
|
||||
PRBool enabledNow;
|
||||
mQuirkStyleSheet->GetEnabled(enabledNow);
|
||||
NS_ASSERTION(count == 0 || aEnable == enabledNow,
|
||||
"enabling/disabling quirk stylesheet too late");
|
||||
PRBool applicableNow;
|
||||
mQuirkStyleSheet->GetApplicable(applicableNow);
|
||||
NS_ASSERTION(count == 0 || aEnable == applicableNow,
|
||||
"enabling/disabling quirk stylesheet too late or incomplete quirk stylesheet");
|
||||
if (count != 0 && aEnable == enabledNow)
|
||||
printf("WARNING: We set the quirks mode too many times.\n"); // we do!
|
||||
#endif
|
||||
|
@ -899,7 +965,7 @@ StyleSetImpl::ReplaceAgentStyleSheets(nsISupportsArray* aNewAgentSheets)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
StyleSetImpl::NotifyStyleSheetStateChanged(PRBool aDisabled)
|
||||
StyleSetImpl::NotifyStyleSheetStateChanged(PRBool aApplicable)
|
||||
{
|
||||
ClearRuleProcessors();
|
||||
GatherRuleProcessors();
|
||||
|
|
|
@ -1389,7 +1389,7 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow)
|
|||
if (!document)
|
||||
return NS_OK;
|
||||
|
||||
// Deal with the agent sheets first.
|
||||
// Deal with the agent sheets first. Have to do all the style sets by hand.
|
||||
PRInt32 shellCount = document->GetNumberOfShells();
|
||||
for (PRInt32 k = 0; k < shellCount; k++) {
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
|
@ -1434,76 +1434,63 @@ nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindowInternal* aWindow)
|
|||
styleSet->ReplaceAgentStyleSheets(newAgentSheets);
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);
|
||||
nsCOMPtr<nsICSSLoader> cssLoader;
|
||||
rv = container->GetCSSLoader(*getter_AddRefs(cssLoader));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Build an array of nsIURIs of style sheets we need to load.
|
||||
nsCOMPtr<nsISupportsArray> oldSheets;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(oldSheets));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> newSheets;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(newSheets));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIHTMLStyleSheet> attrSheet;
|
||||
rv = container->GetAttributeStyleSheet(getter_AddRefs(attrSheet));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIHTMLCSSStyleSheet> inlineSheet;
|
||||
rv = container->GetInlineStyleSheet(getter_AddRefs(inlineSheet));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRInt32 count = 0;
|
||||
document->GetNumberOfStyleSheets(&count);
|
||||
|
||||
// Iterate over the style sheets.
|
||||
PRUint32 i;
|
||||
for (i = 0; i < (PRUint32)count; i++) {
|
||||
// Get the style sheet
|
||||
nsCOMPtr<nsIStyleSheet> styleSheet;
|
||||
document->GetStyleSheetAt(i, getter_AddRefs(styleSheet));
|
||||
|
||||
// Make sure we aren't the special style sheets that never change. We
|
||||
// want to skip those.
|
||||
|
||||
nsCOMPtr<nsIStyleSheet> attr = do_QueryInterface(attrSheet);
|
||||
nsCOMPtr<nsIStyleSheet> inl = do_QueryInterface(inlineSheet);
|
||||
if ((attr.get() != styleSheet.get()) &&
|
||||
(inl.get() != styleSheet.get()))
|
||||
// Add this sheet to the list of old style sheets.
|
||||
oldSheets->AppendElement(styleSheet);
|
||||
}
|
||||
|
||||
// Iterate over our old sheets and kick off a sync load of the new
|
||||
// sheet if and only if it's a chrome URL.
|
||||
PRUint32 oldCount;
|
||||
oldSheets->Count(&oldCount);
|
||||
for (i = 0; i < oldCount; i++) {
|
||||
nsCOMPtr<nsISupports> supp = getter_AddRefs(oldSheets->ElementAt(i));
|
||||
nsCOMPtr<nsIStyleSheet> sheet(do_QueryInterface(supp));
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = sheet->GetURL(*getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (IsChromeURI(uri)) {
|
||||
// Reload the sheet.
|
||||
nsCOMPtr<nsICSSStyleSheet> newSheet;
|
||||
LoadStyleSheetWithURL(uri, getter_AddRefs(newSheet));
|
||||
if (newSheet)
|
||||
newSheets->AppendElement(newSheet);
|
||||
}
|
||||
else // Just use the same sheet.
|
||||
newSheets->AppendElement(sheet);
|
||||
}
|
||||
|
||||
// Now notify the document that multiple sheets have been added and removed.
|
||||
document->UpdateStyleSheets(oldSheets, newSheets);
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
PRInt32 count = 0;
|
||||
document->GetNumberOfStyleSheets(PR_FALSE, &count);
|
||||
|
||||
// Iterate over the style sheets.
|
||||
PRInt32 i;
|
||||
for (i = 0; i < count; i++) {
|
||||
// Get the style sheet
|
||||
nsCOMPtr<nsIStyleSheet> styleSheet;
|
||||
document->GetStyleSheetAt(i, PR_FALSE, getter_AddRefs(styleSheet));
|
||||
|
||||
if (!oldSheets.AppendObject(styleSheet)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate over our old sheets and kick off a sync load of the new
|
||||
// sheet if and only if it's a chrome URL.
|
||||
for (i = 0; i < count; i++) {
|
||||
nsCOMPtr<nsIStyleSheet> sheet = oldSheets[i];
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = sheet->GetURL(*getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (IsChromeURI(uri)) {
|
||||
// Reload the sheet.
|
||||
#ifdef DEBUG
|
||||
nsCOMPtr<nsICSSStyleSheet> oldCSSSheet = do_QueryInterface(sheet);
|
||||
NS_ASSERTION(oldCSSSheet, "Don't know how to reload a non-CSS sheet");
|
||||
#endif
|
||||
nsCOMPtr<nsICSSStyleSheet> newSheet;
|
||||
// XXX what about chrome sheets that have a title or are disabled? This
|
||||
// only works by sheer dumb luck.
|
||||
LoadStyleSheetWithURL(uri, getter_AddRefs(newSheet));
|
||||
// Even if it's null, we put in in there.
|
||||
newSheets.AppendObject(newSheet);
|
||||
}
|
||||
else {
|
||||
// Just use the same sheet.
|
||||
newSheets.AppendObject(sheet);
|
||||
}
|
||||
}
|
||||
|
||||
// Now notify the document that multiple sheets have been added and removed.
|
||||
document->UpdateStyleSheets(oldSheets, newSheets);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -3085,9 +3072,7 @@ nsresult nsChromeRegistry::LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet*
|
|||
getter_AddRefs(loader));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (loader) {
|
||||
PRBool complete;
|
||||
rv = loader->LoadAgentSheet(aURL, *aSheet, complete,
|
||||
nsnull);
|
||||
rv = loader->LoadAgentSheet(aURL, aSheet);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче