Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes
nsXBLResourceLoader Class Reference

#include <nsXBLResourceLoader.h>

Inheritance diagram for nsXBLResourceLoader:
Inheritance graph
Collaboration diagram for nsXBLResourceLoader:
Collaboration graph

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS NS_IMETHOD StyleSheetLoaded (nsICSSStyleSheet *aSheet, PRBool aNotify)
void LoadResources (PRBool *aResult)
void AddResource (nsIAtom *aResourceType, const nsAString &aSrc)
void AddResourceListener (nsIContent *aElement)
 nsXBLResourceLoader (nsXBLPrototypeBinding *aBinding, nsXBLPrototypeResources *aResources)
virtual ~nsXBLResourceLoader ()
void NotifyBoundElements ()

Public Attributes

PRPackedBool mLoadingResources
PRPackedBool mInLoadResourcesFunc
PRInt16 mPendingSheets
nsCOMPtr< nsISupportsArraymBoundElements

Detailed Description

Definition at line 74 of file nsXBLResourceLoader.h.

Constructor & Destructor Documentation

Definition at line 76 of file nsXBLResourceLoader.cpp.

  delete mResourceList;

Member Function Documentation

void nsXBLResourceLoader::AddResource ( nsIAtom aResourceType,
const nsAString &  aSrc 

Definition at line 192 of file nsXBLResourceLoader.cpp.

  nsXBLResource* res = new nsXBLResource(aResourceType, aSrc);
  if (!res)

  if (!mResourceList)
    mResourceList = res;
    mLastResource->mNext = res;

  mLastResource = res;

Here is the caller graph for this function:

Definition at line 207 of file nsXBLResourceLoader.cpp.

  if (!mBoundElements) {
    if (!mBoundElements)


Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 82 of file nsXBLResourceLoader.cpp.

  mInLoadResourcesFunc = PR_TRUE;

  if (mLoadingResources) {
    *aResult = (mPendingSheets == 0);
    mInLoadResourcesFunc = PR_FALSE;

  mLoadingResources = PR_TRUE;
  *aResult = PR_TRUE;

  // Declare our loaders.
  nsCOMPtr<nsIDocument> doc;

  nsICSSLoader* cssLoader = doc->CSSLoader();
  nsIURI *docURL = doc->GetDocumentURI();

  nsCOMPtr<nsIURI> url;

  for (nsXBLResource* curr = mResourceList; curr; curr = curr->mNext) {
    if (curr->mSrc.IsEmpty())

    if (NS_FAILED(NS_NewURI(getter_AddRefs(url), curr->mSrc,
                            doc->GetDocumentCharacterSet().get(), docURL)))

    if (curr->mType == nsXBLAtoms::image) {
      if (!nsContentUtils::CanLoadImage(url, doc, doc)) {
        // We're not permitted to load this image, move on...

      // Now kick off the image load...
      // Passing NULL for pretty much everything -- cause we don't care!
      // XXX: initialDocumentURI is NULL! 
      nsCOMPtr<imgIRequest> req;
      nsContentUtils::LoadImage(url, doc, docURL, nsnull,
    else if (curr->mType == nsXBLAtoms::stylesheet) {
      // Kick off the load of the stylesheet.

      // Always load chrome synchronously
      PRBool chrome;
      nsresult rv;
      if (NS_SUCCEEDED(url->SchemeIs("chrome", &chrome)) && chrome)
        nsCOMPtr<nsICSSStyleSheet> sheet;
        rv = cssLoader->LoadAgentSheet(url, getter_AddRefs(sheet));
        NS_ASSERTION(NS_SUCCEEDED(rv), "Load failed!!!");
        if (NS_SUCCEEDED(rv))
          rv = StyleSheetLoaded(sheet, PR_TRUE);
          NS_ASSERTION(NS_SUCCEEDED(rv), "Processing the style sheet failed!!!");
        PRBool doneLoading;
        NS_NAMED_LITERAL_STRING(empty, "");
        rv = cssLoader->LoadStyleLink(nsnull, url, empty, empty,
                                      nsnull, doneLoading, this);
        NS_ASSERTION(NS_SUCCEEDED(rv), "Load failed!!!");

        if (!doneLoading)

  *aResult = (mPendingSheets == 0);
  mInLoadResourcesFunc = PR_FALSE;
  // Destroy our resource list.
  delete mResourceList;
  mResourceList = nsnull;

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 219 of file nsXBLResourceLoader.cpp.

  nsCOMPtr<nsIXBLService> xblService(do_GetService(";1"));
  nsIURI* bindingURI = mBinding->BindingURI();

  PRUint32 eltCount;
  for (PRUint32 j = 0; j < eltCount; j++) {
    nsCOMPtr<nsIContent> content(do_QueryElementAt(mBoundElements, j));
    PRBool ready = PR_FALSE;
    xblService->BindingReady(content, bindingURI, &ready);

    if (ready) {
      // We need the document to flush out frame construction and
      // such, so we want to use the current document.
      nsIDocument* doc = content->GetCurrentDoc();
      if (doc) {
        // Flush first to make sure we can get the frame for content

        // If |content| is (in addition to having binding |mBinding|)
        // also a descendant of another element with binding |mBinding|,
        // then we might have just constructed it due to the
        // notification of its parent.  (We can know about both if the
        // binding loads were triggered from the DOM rather than frame
        // construction.)  So we have to check both whether the element
        // has a primary frame and whether it's in the undisplayed map
        // before sending a ContentInserted notification, or bad things
        // will happen.
        nsIPresShell *shell = doc->GetShellAt(0);
        if (shell) {
          nsIFrame* childFrame;
          shell->GetPrimaryFrameFor(content, &childFrame);
          if (!childFrame) {
            // Check to see if it's in the undisplayed content map.
            nsStyleContext* sc =

            if (!sc) {

        // Flush again
        // XXXbz why is this needed?

  // Clear out the whole array.
  mBoundElements = nsnull;

  // Delete ourselves.

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsICSSLoaderObserver.

Definition at line 167 of file nsXBLResourceLoader.cpp.

  if (!mResources) {
    // Our resources got destroyed -- just bail out
    return NS_OK;

  if (!mInLoadResourcesFunc)
  if (mPendingSheets == 0) {
    // All stylesheets are loaded.  
    mResources->mRuleProcessor =
      new nsCSSRuleProcessor(mResources->mStyleSheetList);

    // XXX Check for mPendingScripts when scripts also come online.
    if (!mInLoadResourcesFunc)
  return NS_OK;

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

Definition at line 93 of file nsXBLResourceLoader.h.

Definition at line 106 of file nsXBLResourceLoader.h.

Definition at line 103 of file nsXBLResourceLoader.h.

Definition at line 100 of file nsXBLResourceLoader.h.

Definition at line 102 of file nsXBLResourceLoader.h.

Definition at line 104 of file nsXBLResourceLoader.h.

Definition at line 99 of file nsXBLResourceLoader.h.

Definition at line 94 of file nsXBLResourceLoader.h.

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