Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
nsLayoutStylesheetCache Class Reference

#include <nsLayoutStylesheetCache.h>

Inheritance diagram for nsLayoutStylesheetCache:
Inheritance graph
[legend]
Collaboration diagram for nsLayoutStylesheetCache:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Private Member Functions

 nsLayoutStylesheetCache ()
 ~nsLayoutStylesheetCache ()
void InitFromProfile ()

Static Private Member Functions

NS_DECL_ISUPPORTS static
NS_DECL_NSIOBSERVER
nsICSSStyleSheet
ScrollbarsSheet ()
static nsICSSStyleSheetFormsSheet ()
static nsICSSStyleSheetUserContentSheet ()
static nsICSSStyleSheetUserChromeSheet ()
static void Shutdown ()
static void EnsureGlobal ()
static void LoadSheetFile (nsIFile *aFile, nsCOMPtr< nsICSSStyleSheet > &aSheet)
static void LoadSheet (nsIURI *aURI, nsCOMPtr< nsICSSStyleSheet > &aSheet, PRBool aEnableUnsafeRules)

Private Attributes

nsCOMPtr< nsICSSStyleSheetmScrollbarsSheet
nsCOMPtr< nsICSSStyleSheetmFormsSheet
nsCOMPtr< nsICSSStyleSheetmUserContentSheet
nsCOMPtr< nsICSSStyleSheetmUserChromeSheet

Static Private Attributes

static nsLayoutStylesheetCachegStyleCache = nsnull

Detailed Description

Definition at line 48 of file nsLayoutStylesheetCache.h.


Constructor & Destructor Documentation

Definition at line 150 of file nsLayoutStylesheetCache.cpp.

{
  nsCOMPtr<nsIObserverService> obsSvc =
    do_GetService("@mozilla.org/observer-service;1");
  NS_ASSERTION(obsSvc, "No global observer service?");

  if (obsSvc) {
    obsSvc->AddObserver(this, "profile-before-change", PR_FALSE);
    obsSvc->AddObserver(this, "profile-do-change", PR_FALSE);
    obsSvc->AddObserver(this, "chrome-flush-skin-caches", PR_FALSE);
    obsSvc->AddObserver(this, "chrome-flush-caches", PR_FALSE);
  }

  InitFromProfile();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 166 of file nsLayoutStylesheetCache.cpp.


Member Function Documentation

Definition at line 172 of file nsLayoutStylesheetCache.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 103 of file nsLayoutStylesheetCache.cpp.

{
  EnsureGlobal();
  if (!gStyleCache)
    return nsnull;

  if (!gStyleCache->mFormsSheet) {
    nsCOMPtr<nsIURI> sheetURI;
      NS_NewURI(getter_AddRefs(sheetURI),
                NS_LITERAL_CSTRING("resource://gre/res/forms.css"));

    // forms.css needs access to unsafe rules
    if (sheetURI)
      LoadSheet(sheetURI, gStyleCache->mFormsSheet, PR_TRUE);

    NS_ASSERTION(gStyleCache->mFormsSheet, "Could not load forms.css.");
  }

  return gStyleCache->mFormsSheet;
}

Here is the call graph for this function:

Definition at line 183 of file nsLayoutStylesheetCache.cpp.

{
  nsCOMPtr<nsIFile> contentFile;
  nsCOMPtr<nsIFile> chromeFile;

  NS_GetSpecialDirectory(NS_APP_USER_CHROME_DIR,
                         getter_AddRefs(contentFile));
  if (!contentFile) {
    // if we don't have a profile yet, that's OK!
    return;
  }

  contentFile->Clone(getter_AddRefs(chromeFile));
  if (!chromeFile) return;

  contentFile->Append(NS_LITERAL_STRING("userContent.css"));
  chromeFile->Append(NS_LITERAL_STRING("userChrome.css"));

  LoadSheetFile(contentFile, mUserContentSheet);
  LoadSheetFile(chromeFile, mUserChromeSheet);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsLayoutStylesheetCache::LoadSheet ( nsIURI aURI,
nsCOMPtr< nsICSSStyleSheet > &  aSheet,
PRBool  aEnableUnsafeRules 
) [static, private]

Definition at line 222 of file nsLayoutStylesheetCache.cpp.

{
  if (!aURI) {
    NS_ERROR("Null URI. Out of memory?");
    return;
  }

  // note: CSS Loader is treated as a service here... slightly unusual,
  // but within the rules.
  nsCOMPtr<nsICSSLoader_MOZILLA_1_8_BRANCH> cssLoader = do_GetService(kCSSLoaderCID);
  if (!cssLoader) return;

  cssLoader->LoadSheetSync(aURI, aEnableUnsafeRules, getter_AddRefs(aSheet));
}  

Here is the call graph for this function:

Here is the caller graph for this function:

void nsLayoutStylesheetCache::LoadSheetFile ( nsIFile aFile,
nsCOMPtr< nsICSSStyleSheet > &  aSheet 
) [static, private]

Definition at line 206 of file nsLayoutStylesheetCache.cpp.

{
  PRBool exists = PR_FALSE;
  aFile->Exists(&exists);

  if (!exists) return;

  nsCOMPtr<nsIURI> uri;
  NS_NewFileURI(getter_AddRefs(uri), aFile);

  LoadSheet(uri, aSheet, PR_FALSE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.

Definition at line 74 of file nsLayoutStylesheetCache.cpp.

{
  EnsureGlobal();
  if (!gStyleCache)
    return nsnull;

  if (!gStyleCache->mScrollbarsSheet) {
    nsCOMPtr<nsIURI> sheetURI;
    NS_NewURI(getter_AddRefs(sheetURI),
#ifdef XP_MACOSX
              NS_LITERAL_CSTRING("chrome://global/skin/nativescrollbars.css"));
#else
              NS_LITERAL_CSTRING("chrome://global/skin/xulscrollbars.css"));
#endif

    // Scrollbars don't need access to unsafe rules
    if (sheetURI)
      LoadSheet(sheetURI, gStyleCache->mScrollbarsSheet, PR_FALSE);
#ifdef XP_MACOSX
    NS_ASSERTION(gStyleCache->mScrollbarsSheet, "Could not load nativescrollbars.css.");
#else
    NS_ASSERTION(gStyleCache->mScrollbarsSheet, "Could not load xulscrollbars.css.");
#endif
  }

  return gStyleCache->mScrollbarsSheet;
}

Here is the call graph for this function:

void nsLayoutStylesheetCache::Shutdown ( ) [static, private]

Definition at line 145 of file nsLayoutStylesheetCache.cpp.

Definition at line 135 of file nsLayoutStylesheetCache.cpp.

Here is the call graph for this function:

Definition at line 125 of file nsLayoutStylesheetCache.cpp.

Here is the call graph for this function:


Member Data Documentation

Definition at line 71 of file nsLayoutStylesheetCache.h.

Definition at line 73 of file nsLayoutStylesheetCache.h.

Definition at line 72 of file nsLayoutStylesheetCache.h.

Definition at line 75 of file nsLayoutStylesheetCache.h.

Definition at line 74 of file nsLayoutStylesheetCache.h.


The documentation for this class was generated from the following files: