Back to index

lightning-sunbird  0.9+nobinonly
nsICSSLoader.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1999
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 #ifndef nsICSSLoader_h___
00038 #define nsICSSLoader_h___
00039 
00040 #include "nsISupports.h"
00041 #include "nsSubstring.h"
00042 #include "nsCompatibility.h"
00043 
00044 class nsIAtom;
00045 class nsIURI;
00046 class nsICSSParser;
00047 class nsICSSStyleSheet;
00048 class nsPresContext;
00049 class nsIContent;
00050 class nsIParser;
00051 class nsIDocument;
00052 class nsIUnicharInputStream;
00053 class nsICSSLoaderObserver;
00054 class nsMediaList;
00055 class nsICSSImportRule;
00056 
00057 // IID for the nsICSSLoader interface
00058 // 6c50f676-c764-4f2f-b62b-99d1076b44e9
00059 #define NS_ICSS_LOADER_IID     \
00060 {0x6c50f676, 0xc764, 0x4f2f, {0xb6, 0x2b, 0x99, 0xd1, 0x07, 0x6b, 0x44, 0xe9}}
00061 
00062 typedef void (*nsCSSLoaderCallbackFunc)(nsICSSStyleSheet* aSheet, void *aData, PRBool aDidNotify);
00063 
00064 class nsICSSLoader : public nsISupports {
00065 public:
00066   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICSS_LOADER_IID)
00067 
00068   NS_IMETHOD Init(nsIDocument* aDocument) = 0;
00069   NS_IMETHOD DropDocumentReference(void) = 0; // notification that doc is going away
00070 
00071   NS_IMETHOD SetCaseSensitive(PRBool aCaseSensitive) = 0;
00072   NS_IMETHOD SetCompatibilityMode(nsCompatibility aCompatMode) = 0;
00073   NS_IMETHOD SetPreferredSheet(const nsAString& aTitle) = 0;
00074   NS_IMETHOD GetPreferredSheet(nsAString& aTitle) = 0;
00075 
00076   // Get/Recycle a CSS parser for general use
00077   NS_IMETHOD GetParserFor(nsICSSStyleSheet* aSheet,
00078                           nsICSSParser** aParser) = 0;
00079   NS_IMETHOD RecycleParser(nsICSSParser* aParser) = 0;
00080 
00081   // XXX No one uses the aDefaultNameSpaceID params.... do we need them?
00082   
00083   // Load an inline style sheet
00084   // - if aCompleted is PR_TRUE, the sheet is fully loaded, don't
00085   //   block for it.
00086   // - if aCompleted is PR_FALSE, the sheet is still loading and 
00087   //   will be marked complete when complete
00088   NS_IMETHOD LoadInlineStyle(nsIContent* aElement,
00089                              nsIUnicharInputStream* aStream, 
00090                              PRUint32 aLineNumber,
00091                              const nsSubstring& aTitle, 
00092                              const nsSubstring& aMedia, 
00093                              nsIParser* aParserToUnblock,
00094                              PRBool& aCompleted,
00095                              nsICSSLoaderObserver* aObserver) = 0;
00096 
00097   // Load a linked style sheet
00098   // - if aCompleted is PR_TRUE, the sheet is fully loaded, don't
00099   //   block for it.
00100   // - if aCompleted is PR_FALSE, the sheet is still loading and 
00101   //   will be marked complete when complete
00102   NS_IMETHOD LoadStyleLink(nsIContent* aElement,
00103                            nsIURI* aURL, 
00104                            const nsSubstring& aTitle, 
00105                            const nsSubstring& aMedia, 
00106                            nsIParser* aParserToUnblock,
00107                            PRBool& aCompleted,
00108                            nsICSSLoaderObserver* aObserver) = 0;
00109 
00110   // Load a child style sheet (@import)
00111   NS_IMETHOD LoadChildSheet(nsICSSStyleSheet* aParentSheet,
00112                             nsIURI* aURL, 
00113                             nsMediaList* aMedia,
00114                             nsICSSImportRule* aRule) = 0;
00115 
00116   // Load a user agent or user sheet.  The sheet is loaded
00117   // synchronously, including @imports from it.
00118   NS_IMETHOD LoadAgentSheet(nsIURI* aURL, nsICSSStyleSheet** aSheet) = 0;
00119 
00120   // Load a user agent or user sheet.  The sheet is loaded
00121   // asynchronously and the observer notified when the load finishes.
00122   NS_IMETHOD LoadAgentSheet(nsIURI* aURL, nsICSSLoaderObserver* aObserver) = 0;
00123 
00124   // stop loading all sheets
00125   NS_IMETHOD Stop(void) = 0;
00126 
00127   // stop loading one sheet
00128   NS_IMETHOD StopLoadingSheet(nsIURI* aURL) = 0;
00129 
00137   NS_IMETHOD GetEnabled(PRBool *aEnabled) = 0;
00138   NS_IMETHOD SetEnabled(PRBool aEnabled) = 0;
00139 };
00140 
00141 // IID for the nsICSSLoader_MOZILLA_1_8_BRANCH interface
00142 // 8cee4512-b487-4573-8bcb-190d36fff66a
00143 #define NS_ICSS_LOADER_MOZILLA_1_8_BRANCH_IID     \
00144 {0x8cee4512, 0xb487, 0x4573, {0x8b, 0xcb, 0x19, 0x0d, 0x36, 0xff, 0xf6, 0x6a}}
00145 
00146 class nsICSSLoader_MOZILLA_1_8_BRANCH : public nsISupports {
00147 public:
00148   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICSS_LOADER_MOZILLA_1_8_BRANCH_IID)
00149 
00150   // Load a sheet, with optional enabling of unsafe rules
00151   NS_IMETHOD LoadSheetSync(nsIURI* aURL, PRBool aEnableUnsafeRules, nsICSSStyleSheet** aSheet) = 0;
00152 };
00153 
00154 nsresult 
00155 NS_NewCSSLoader(nsIDocument* aDocument, nsICSSLoader** aLoader);
00156 
00157 nsresult 
00158 NS_NewCSSLoader(nsICSSLoader** aLoader);
00159 
00160 #endif /* nsICSSLoader_h___ */