Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
nsXBLPrototypeBinding Class Reference

#include <nsXBLPrototypeBinding.h>

Collaboration diagram for nsXBLPrototypeBinding:
Collaboration graph
[legend]

List of all members.

Classes

class  nsIIDKey

Public Member Functions

already_AddRefed< nsIContentGetBindingElement ()
void SetBindingElement (nsIContent *aElement)
nsIURIBindingURI () const
nsIURIDocURI () const
nsresult GetID (nsACString &aResult) const
nsresult GetAllowScripts (PRBool *aResult)
PRBool IsChrome ()
nsresult BindingAttached (nsIContent *aBoundElement)
nsresult BindingDetached (nsIContent *aBoundElement)
PRBool LoadResources ()
nsresult AddResource (nsIAtom *aResourceType, const nsAString &aSrc)
PRBool InheritsStyle () const
nsXBLPrototypeHandlerGetPrototypeHandlers ()
void SetPrototypeHandlers (nsXBLPrototypeHandler *aHandler)
nsXBLProtoImplAnonymousMethodGetConstructor ()
nsresult SetConstructor (nsXBLProtoImplAnonymousMethod *aConstructor)
nsXBLProtoImplAnonymousMethodGetDestructor ()
nsresult SetDestructor (nsXBLProtoImplAnonymousMethod *aDestructor)
nsresult InitClass (const nsCString &aClassName, JSContext *aContext, JSObject *aGlobal, JSObject *aScriptObject, void **aClassObject)
nsresult ConstructInterfaceTable (const nsAString &aImpls)
void SetImplementation (nsXBLProtoImpl *aImpl)
nsresult InstallImplementation (nsIContent *aBoundElement)
void AttributeChanged (nsIAtom *aAttribute, PRInt32 aNameSpaceID, PRBool aRemoveFlag, nsIContent *aChangedElement, nsIContent *aAnonymousContent, PRBool aNotify)
void SetBasePrototype (nsXBLPrototypeBinding *aBinding)
nsXBLPrototypeBindingGetBasePrototype ()
nsIXBLDocumentInfoXBLDocumentInfo () const
PRBool HasBasePrototype ()
void SetHasBasePrototype (PRBool aHasBase)
void SetInitialAttributes (nsIContent *aBoundElement, nsIContent *aAnonymousContent)
nsIStyleRuleProcessorGetRuleProcessor ()
nsCOMArray< nsICSSStyleSheet > * GetStyleSheets ()
PRBool HasInsertionPoints ()
PRBool HasStyleSheets ()
nsresult FlushSkinSheets ()
void InstantiateInsertionPoints (nsXBLBinding *aBinding)
nsIContentGetInsertionPoint (nsIContent *aBoundElement, nsIContent *aCopyRoot, nsIContent *aChild, PRUint32 *aIndex)
nsIContentGetSingleInsertionPoint (nsIContent *aBoundElement, nsIContent *aCopyRoot, PRUint32 *aIndex, PRBool *aMultiple)
nsIAtomGetBaseTag (PRInt32 *aNamespaceID)
void SetBaseTag (PRInt32 aNamespaceID, nsIAtom *aTag)
PRBool ImplementsInterface (REFNSIID aIID) const
PRBool ShouldBuildChildFrames () const
nsresult AddResourceListener (nsIContent *aBoundElement)
void Initialize ()
const nsCOMArray
< nsXBLKeyEventHandler > * 
GetKeyEventHandlers ()
 nsXBLPrototypeBinding ()
 ~nsXBLPrototypeBinding ()
nsresult Init (const nsACString &aRef, nsIXBLDocumentInfo *aInfo, nsIContent *aElement)
nsIContentGetImmediateChild (nsIAtom *aTag)
 GetImmediateChild locates the immediate child of our binding element which has the localname given by aTag and is in the XBL namespace.
nsIContentLocateInstance (nsIContent *aBoundElt, nsIContent *aTemplRoot, nsIContent *aCopyRoot, nsIContent *aTemplChild)

Static Public Attributes

static PRUint32 gRefCnt = 0
static nsFixedSizeAllocator * kAttrPool
static nsFixedSizeAllocator * kInsPool

Protected Member Functions

void ConstructAttributeTable (nsIContent *aElement)
void ConstructInsertionTable (nsIContent *aElement)
void GetNestedChildren (nsIAtom *aTag, PRInt32 aNamespace, nsIContent *aContent, nsCOMArray< nsIContent > &aList)
void CreateKeyHandlers ()

Protected Attributes

nsCOMPtr< nsIURLmBindingURI
nsCOMPtr< nsIContentmBinding
nsAutoPtr< nsXBLPrototypeHandlermPrototypeHandler
nsXBLProtoImplmImplementation
nsXBLPrototypeBindingmBaseBinding
PRPackedBool mInheritStyle
PRPackedBool mHasBaseProto
PRPackedBool mKeyHandlersRegistered
nsXBLPrototypeResourcesmResources
nsIXBLDocumentInfomXBLDocInfoWeak
nsObjectHashtable * mAttributeTable
nsObjectHashtable * mInsertionPointTable
nsSupportsHashtable * mInterfaceTable
PRInt32 mBaseNameSpaceID
nsCOMPtr< nsIAtommBaseTag
nsAutoRefCnt mRefCnt
nsCOMArray< nsXBLKeyEventHandlermKeyHandlers

Detailed Description

Definition at line 72 of file nsXBLPrototypeBinding.h.


Constructor & Destructor Documentation

Definition at line 300 of file nsXBLPrototypeBinding.cpp.


Member Function Documentation

nsresult nsXBLPrototypeBinding::AddResource ( nsIAtom aResourceType,
const nsAString &  aSrc 
)

Definition at line 366 of file nsXBLPrototypeBinding.cpp.

{
  if (!mResources) {
    mResources = new nsXBLPrototypeResources(this);
    if (!mResources)
      return NS_ERROR_OUT_OF_MEMORY;
  }

  mResources->AddResource(aResourceType, aSrc);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1310 of file nsXBLPrototypeBinding.cpp.

{
  if (!mResources)
    return NS_ERROR_FAILURE; // Makes no sense to add a listener when the binding
                             // has no resources.

  mResources->AddResourceListener(aBoundElement);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsXBLPrototypeBinding::AttributeChanged ( nsIAtom aAttribute,
PRInt32  aNameSpaceID,
PRBool  aRemoveFlag,
nsIContent aChangedElement,
nsIContent aAnonymousContent,
PRBool  aNotify 
)

Definition at line 449 of file nsXBLPrototypeBinding.cpp.

{
  if (!mAttributeTable)
    return;
  nsPRUint32Key nskey(aNameSpaceID);
  nsObjectHashtable *attributesNS = NS_STATIC_CAST(nsObjectHashtable*, 
                                                   mAttributeTable->Get(&nskey));
  if (!attributesNS)
    return;

  nsISupportsKey key(aAttribute);
  nsXBLAttributeEntry* xblAttr = NS_STATIC_CAST(nsXBLAttributeEntry*,
                                                attributesNS->Get(&key));
  if (!xblAttr)
    return;

  // Iterate over the elements in the array.
  nsCOMPtr<nsIContent> content = GetImmediateChild(nsXBLAtoms::content);
  while (xblAttr) {
    nsIContent* element = xblAttr->GetElement();

    nsCOMPtr<nsIContent> realElement = LocateInstance(aChangedElement, content,
                                                      aAnonymousContent,
                                                      element);

    if (realElement) {
      nsIAtom* dstAttr = xblAttr->GetDstAttribute();
      PRInt32 dstNs = xblAttr->GetDstNameSpace();

      if (aRemoveFlag)
        realElement->UnsetAttr(dstNs, dstAttr, aNotify);
      else {
        PRBool attrPresent = PR_TRUE;
        nsAutoString value;
        // Check to see if the src attribute is xbl:text.  If so, then we need to obtain the 
        // children of the real element and get the text nodes' values.
        if (aAttribute == nsHTMLAtoms::text && aNameSpaceID == kNameSpaceID_XBL) {
          nsXBLBinding::GetTextData(aChangedElement, value);
          value.StripChar(PRUnichar('\n'));
          value.StripChar(PRUnichar('\r'));
          nsAutoString stripVal(value);
          stripVal.StripWhitespace();
          if (stripVal.IsEmpty()) 
            attrPresent = PR_FALSE;
        }    
        else {
          nsresult result = aChangedElement->GetAttr(aNameSpaceID, aAttribute, value);
          attrPresent = (result == NS_CONTENT_ATTR_NO_VALUE ||
                         result == NS_CONTENT_ATTR_HAS_VALUE);
        }

        if (attrPresent)
          realElement->SetAttr(dstNs, dstAttr, value, aNotify);
      }

      // See if we're the <html> tag in XUL, and see if value is being
      // set or unset on us.  We may also be a tag that is having
      // xbl:text set on us.

      if ((dstAttr == nsHTMLAtoms::text && dstNs == kNameSpaceID_XBL) ||
          realElement->GetNodeInfo()->Equals(nsHTMLAtoms::html,
                                             kNameSpaceID_XUL) &&
          dstAttr == nsHTMLAtoms::value) {
        // Flush out all our kids.
        PRUint32 childCount = realElement->GetChildCount();
        for (PRUint32 i = 0; i < childCount; i++)
          realElement->RemoveChildAt(0, aNotify);

        if (!aRemoveFlag) {
          // Construct a new text node and insert it.
          nsAutoString value;
          aChangedElement->GetAttr(aNameSpaceID, aAttribute, value);
          if (!value.IsEmpty()) {
            nsCOMPtr<nsITextContent> textContent;
            NS_NewTextNode(getter_AddRefs(textContent),
                           realElement->GetNodeInfo()->NodeInfoManager());
            if (!textContent) {
              continue;
            }

            textContent->SetText(value, PR_TRUE);
            realElement->AppendChildTo(textContent, PR_TRUE);
          }
        }
      }
    }

    xblAttr = xblAttr->GetNext();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 387 of file nsXBLPrototypeBinding.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 396 of file nsXBLPrototypeBinding.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 78 of file nsXBLPrototypeBinding.h.

{ return mBindingURI; }

Here is the caller graph for this function:

Definition at line 996 of file nsXBLPrototypeBinding.cpp.

{
  // Don't add entries for <children> elements, since those will get
  // removed from the DOM when we construct the insertion point table.
  nsINodeInfo* nodeInfo = aElement->GetNodeInfo();
  if (nodeInfo && !nodeInfo->Equals(nsXBLAtoms::children,
                                    kNameSpaceID_XBL)) {
    nsAutoString inherits;
    aElement->GetAttr(kNameSpaceID_XBL, nsXBLAtoms::inherits, inherits);

    if (!inherits.IsEmpty()) {
      if (!mAttributeTable) {
        mAttributeTable = new nsObjectHashtable(nsnull, nsnull,
                                                DeleteAttributeTable,
                                                nsnull, 4);
        if (!mAttributeTable)
          return;
      }

      // The user specified at least one attribute.
      char* str = ToNewCString(inherits);
      char* newStr;
      // XXX We should use a strtok function that tokenizes PRUnichars
      // so that we don't have to convert from Unicode to ASCII and then back

      char* token = nsCRT::strtok( str, ", ", &newStr );
      while( token != NULL ) {
        // Build an atom out of this attribute.
        nsCOMPtr<nsIAtom> atom;
        PRInt32 atomNsID = kNameSpaceID_None;
        nsCOMPtr<nsIAtom> attribute;
        PRInt32 attributeNsID = kNameSpaceID_None;

        // Figure out if this token contains a :.
        nsAutoString attrTok; attrTok.AssignWithConversion(token);
        PRInt32 index = attrTok.Find("=", PR_TRUE);
        nsresult rv;
        if (index != -1) {
          // This attribute maps to something different.
          nsAutoString left, right;
          attrTok.Left(left, index);
          attrTok.Right(right, attrTok.Length()-index-1);

          rv = nsContentUtils::SplitQName(aElement, left, &attributeNsID,
                                          getter_AddRefs(attribute));
          if (NS_FAILED(rv))
            return;

          rv = nsContentUtils::SplitQName(aElement, right, &atomNsID,
                                          getter_AddRefs(atom));
          if (NS_FAILED(rv))
            return;
        }
        else {
          nsAutoString tok;
          tok.AssignWithConversion(token);
          rv = nsContentUtils::SplitQName(aElement, tok, &atomNsID, 
                                          getter_AddRefs(atom));
          if (NS_FAILED(rv))
            return;
          attribute = atom;
          attributeNsID = atomNsID;
        }

        nsPRUint32Key nskey(atomNsID);
        nsObjectHashtable* attributesNS =
          NS_STATIC_CAST(nsObjectHashtable*, mAttributeTable->Get(&nskey));
        if (!attributesNS) {
          attributesNS = new nsObjectHashtable(nsnull, nsnull,
                                               DeleteAttributeEntry,
                                               nsnull, 4);
          if (!attributesNS)
            return;

          mAttributeTable->Put(&nskey, attributesNS);
        }
      
        // Create an XBL attribute entry.
        nsXBLAttributeEntry* xblAttr =
          nsXBLAttributeEntry::Create(atom, attribute, attributeNsID, aElement);

        // Now we should see if some element within our anonymous
        // content is already observing this attribute.
        nsISupportsKey key(atom);
        nsXBLAttributeEntry* entry = NS_STATIC_CAST(nsXBLAttributeEntry*,
                                                    attributesNS->Get(&key));

        if (!entry) {
          // Put it in the table.
          attributesNS->Put(&key, xblAttr);
        } else {
          while (entry->GetNext())
            entry = entry->GetNext();

          entry->SetNext(xblAttr);
        }

        // Now remove the inherits attribute from the element so that it doesn't
        // show up on clones of the element.  It is used
        // by the template only, and we don't need it anymore.
        // XXXdwh Don't do this for XUL elements, since it faults them into heavyweight
        // elements. Should nuke from the prototype instead.
        // aElement->UnsetAttr(kNameSpaceID_XBL, nsXBLAtoms::inherits, PR_FALSE);

        token = nsCRT::strtok( newStr, ", ", &newStr );
      }

      nsMemory::Free(str);
    }
  }

  // Recur into our children.
  PRUint32 childCount = aElement->GetChildCount();
  for (PRUint32 i = 0; i < childCount; i++) {
    ConstructAttributeTable(aElement->GetChildAt(i));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1122 of file nsXBLPrototypeBinding.cpp.

{
  nsCOMArray<nsIContent> childrenElements;
  GetNestedChildren(nsXBLAtoms::children, kNameSpaceID_XBL, aContent,
                    childrenElements);

  PRInt32 count = childrenElements.Count();
  if (count == 0)
    return;

  mInsertionPointTable = new nsObjectHashtable(nsnull, nsnull,
                                               DeleteInsertionPointEntry,
                                               nsnull, 4);
  if (!mInsertionPointTable)
    return;

  PRInt32 i;
  for (i = 0; i < count; i++) {
    nsIContent* child = childrenElements[i];
    nsIContent* parent = child->GetParent(); 

    // Create an XBL insertion point entry.
    nsXBLInsertionPointEntry* xblIns = nsXBLInsertionPointEntry::Create(parent);

    nsAutoString includes;
    child->GetAttr(kNameSpaceID_None, nsXBLAtoms::includes, includes);
    if (includes.IsEmpty()) {
      nsISupportsKey key(nsXBLAtoms::children);
      xblIns->AddRef();
      mInsertionPointTable->Put(&key, xblIns);
    }
    else {
      // The user specified at least one attribute.
      char* str = ToNewCString(includes);
      char* newStr;
      // XXX We should use a strtok function that tokenizes PRUnichar's
      // so that we don't have to convert from Unicode to ASCII and then back

      char* token = nsCRT::strtok( str, "| ", &newStr );
      while( token != NULL ) {
        nsAutoString tok;
        tok.AssignWithConversion(token);

        // Build an atom out of this string.
        nsCOMPtr<nsIAtom> atom = do_GetAtom(tok);
           
        nsISupportsKey key(atom);
        xblIns->AddRef();
        mInsertionPointTable->Put(&key, xblIns);
          
        token = nsCRT::strtok( newStr, "| ", &newStr );
      }

      nsMemory::Free(str);
    }

    // Compute the index of the <children> element.  This index is
    // equal to the index of the <children> in the template minus the #
    // of previous insertion point siblings removed.  Because our childrenElements
    // array was built in a DFS that went from left-to-right through siblings,
    // if we dynamically obtain our index each time, then the removals of previous
    // siblings will cause the index to adjust (and we won't have to take that into
    // account explicitly).
    PRInt32 index = parent->IndexOf(child);
    xblIns->SetInsertionIndex((PRUint32)index);

    // Now remove the <children> element from the template.  This ensures that the
    // binding instantiation will not contain a clone of the <children> element when
    // it clones the binding template.
    parent->RemoveChildAt(index, PR_FALSE);

    // See if the insertion point contains default content.  Default content must
    // be cached in our insertion point entry, since it will need to be cloned
    // in situations where no content ends up being placed at the insertion point.
    PRUint32 defaultCount = child->GetChildCount();
    if (defaultCount > 0) {
      // Annotate the insertion point with our default content.
      xblIns->SetDefaultContent(child);

      // Reconnect back to our parent for access later.  This makes "inherits" easier
      // to work with on default content.
      // XXXbz this is somewhat screwed up, since it's sort of like anonymous
      // content... but not.
      nsresult rv =
        child->BindToTree(parent->GetCurrentDoc(), parent, nsnull, PR_FALSE);
      if (NS_FAILED(rv)) {
        // Well... now what?  Just unbind and bail out, I guess...
        // XXXbz This really shouldn't be a void method!
        child->UnbindFromTree();
        return;
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1218 of file nsXBLPrototypeBinding.cpp.

{
  if (!aImpls.IsEmpty()) {
    // Obtain the interface info manager that can tell us the IID
    // for a given interface name.
    nsCOMPtr<nsIInterfaceInfoManager> infoManager = getter_AddRefs(XPTI_GetInterfaceInfoManager());
    if (!infoManager)
      return NS_ERROR_FAILURE;

    // Create the table.
    if (!mInterfaceTable)
      mInterfaceTable = new nsSupportsHashtable(4);

    // The user specified at least one attribute.
    NS_ConvertUCS2toUTF8 utf8impl(aImpls);
    char* str = utf8impl.BeginWriting();
    char* newStr;
    // XXX We should use a strtok function that tokenizes PRUnichars
    // so that we don't have to convert from Unicode to ASCII and then back

    char* token = nsCRT::strtok( str, ", ", &newStr );
    while( token != NULL ) {
      // get the InterfaceInfo for the name
      nsCOMPtr<nsIInterfaceInfo> iinfo;
      infoManager->GetInfoForName(token, getter_AddRefs(iinfo));

      if (iinfo) {
        // obtain an IID.
        nsIID* iid = nsnull;
        iinfo->GetInterfaceIID(&iid);

        if (iid) {
          // We found a valid iid.  Add it to our table.
          nsIIDKey key(*iid);
          mInterfaceTable->Put(&key, mBinding);

          // this block adds the parent interfaces of each interface
          // defined in the xbl definition (implements="nsI...")
          nsCOMPtr<nsIInterfaceInfo> parentInfo;
          // if it has a parent, add it to the table
          while (NS_SUCCEEDED(iinfo->GetParent(getter_AddRefs(parentInfo))) && parentInfo) {
            // free the nsMemory::Clone()ed iid
            nsMemory::Free(iid);

            // get the iid
            parentInfo->GetInterfaceIID(&iid);

            // don't add nsISupports to the table
            if (!iid || iid->Equals(NS_GET_IID(nsISupports)))
              break;

            // add the iid to the table
            nsIIDKey parentKey(*iid);
            mInterfaceTable->Put(&parentKey, mBinding);

            // look for the next parent
            iinfo = parentInfo;
          }
        }

        // free the nsMemory::Clone()ed iid
        if (iid)
          nsMemory::Free(iid);
      }

      token = nsCRT::strtok( newStr, ", ", &newStr );
    }
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1321 of file nsXBLPrototypeBinding.cpp.

{
  nsXBLPrototypeHandler* curr = mPrototypeHandler;
  while (curr) {
    nsCOMPtr<nsIAtom> eventAtom = curr->GetEventName();
    if (eventAtom == nsXBLAtoms::keyup ||
        eventAtom == nsXBLAtoms::keydown ||
        eventAtom == nsXBLAtoms::keypress) {
      PRUint8 phase = curr->GetPhase();
      PRUint8 type = curr->GetType();

      PRInt32 count = mKeyHandlers.Count();
      PRInt32 i;
      nsXBLKeyEventHandler* handler = nsnull;
      for (i = 0; i < count; ++i) {
        handler = mKeyHandlers[i];
        if (handler->Matches(eventAtom, phase, type))
          break;
      }

      if (i == count) {
        nsRefPtr<nsXBLKeyEventHandler> newHandler;
        NS_NewXBLKeyEventHandler(eventAtom, phase, type,
                                 getter_AddRefs(newHandler));
        if (newHandler)
          mKeyHandlers.AppendObject(newHandler);
        handler = newHandler;
      }

      if (handler)
        handler->AddProtoHandler(curr);
    }

    curr = curr->GetNextHandler();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 79 of file nsXBLPrototypeBinding.h.

{ return mXBLDocInfoWeak->DocumentURI(); }

Here is the caller graph for this function:

Definition at line 379 of file nsXBLPrototypeBinding.cpp.

{
  if (mResources)
    return mResources->FlushSkinSheets();
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 348 of file nsXBLPrototypeBinding.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 116 of file nsXBLPrototypeBinding.h.

{ return mBaseBinding; }

Here is the caller graph for this function:

Definition at line 699 of file nsXBLPrototypeBinding.cpp.

{
  if (mBaseTag) {
    *aNamespaceID = mBaseNameSpaceID;
    return mBaseTag;
  }

  return nsnull;
}

Here is the caller graph for this function:

Definition at line 330 of file nsXBLPrototypeBinding.cpp.

{
  nsIContent* result = mBinding;
  NS_IF_ADDREF(result);
  return result;
}

Here is the caller graph for this function:

Definition at line 405 of file nsXBLPrototypeBinding.cpp.

Here is the caller graph for this function:

Definition at line 414 of file nsXBLPrototypeBinding.cpp.

Here is the caller graph for this function:

nsresult nsXBLPrototypeBinding::GetID ( nsACString &  aResult) const [inline]

Definition at line 80 of file nsXBLPrototypeBinding.h.

{ return mBindingURI->GetRef(aResult); }

Here is the caller graph for this function:

GetImmediateChild locates the immediate child of our binding element which has the localname given by aTag and is in the XBL namespace.

Definition at line 726 of file nsXBLPrototypeBinding.cpp.

{
  PRUint32 childCount = mBinding->GetChildCount();

  for (PRUint32 i = 0; i < childCount; i++) {
    nsIContent *child = mBinding->GetChildAt(i);
    nsINodeInfo *childNodeInfo = child->GetNodeInfo();

    if (childNodeInfo && childNodeInfo->Equals(aTag, kNameSpaceID_XBL)) {
      return child;
    }
  }

  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIContent * nsXBLPrototypeBinding::GetInsertionPoint ( nsIContent aBoundElement,
nsIContent aCopyRoot,
nsIContent aChild,
PRUint32 aIndex 
)

Definition at line 617 of file nsXBLPrototypeBinding.cpp.

{
  if (!mInsertionPointTable)
    return nsnull;

  nsISupportsKey key(aChild->Tag());
  nsXBLInsertionPointEntry* entry = NS_STATIC_CAST(nsXBLInsertionPointEntry*, mInsertionPointTable->Get(&key));
  if (!entry) {
    nsISupportsKey key2(nsXBLAtoms::children);
    entry = NS_STATIC_CAST(nsXBLInsertionPointEntry*, mInsertionPointTable->Get(&key2));
  }

  nsIContent *realContent = nsnull;
  if (entry) {
    nsIContent* content = entry->GetInsertionParent();
    *aIndex = entry->GetInsertionIndex();
    nsIContent* templContent = GetImmediateChild(nsXBLAtoms::content);
    realContent = LocateInstance(nsnull, templContent, aCopyRoot, content);
  }
  else {
    // We got nothin'.  Bail.
    return nsnull;
  }

  return realContent ? realContent : aBoundElement;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 157 of file nsXBLPrototypeBinding.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsXBLPrototypeBinding::GetNestedChildren ( nsIAtom aTag,
PRInt32  aNamespace,
nsIContent aContent,
nsCOMArray< nsIContent > &  aList 
) [protected]

Definition at line 1291 of file nsXBLPrototypeBinding.cpp.

{
  PRUint32 childCount = aContent->GetChildCount();

  for (PRUint32 i = 0; i < childCount; i++) {
    nsIContent *child = aContent->GetChildAt(i);

    nsINodeInfo *nodeInfo = child->GetNodeInfo();
    if (nodeInfo && nodeInfo->Equals(aTag, aNamespace)) {
      aList.AppendObject(child);
    }
    else
      GetNestedChildren(aTag, aNamespace, child, aList);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 94 of file nsXBLPrototypeBinding.h.

{ return mPrototypeHandler; }

Here is the caller graph for this function:

Definition at line 945 of file nsXBLPrototypeBinding.cpp.

{
  if (mResources) {
    return mResources->mRuleProcessor;
  }
  
  return nsnull;
}

Here is the caller graph for this function:

nsIContent * nsXBLPrototypeBinding::GetSingleInsertionPoint ( nsIContent aBoundElement,
nsIContent aCopyRoot,
PRUint32 aIndex,
PRBool aMultiple 
)

Definition at line 648 of file nsXBLPrototypeBinding.cpp.

{ 
  *aMultipleInsertionPoints = PR_FALSE;
  *aIndex = 0;

  if (!mInsertionPointTable)
    return nsnull;

  if (mInsertionPointTable->Count() != 1) {
    *aMultipleInsertionPoints = PR_TRUE;
    return nsnull;
  }

  nsISupportsKey key(nsXBLAtoms::children);
  nsXBLInsertionPointEntry* entry =
    NS_STATIC_CAST(nsXBLInsertionPointEntry*, mInsertionPointTable->Get(&key));

  if (!entry) {
    // The only insertion point specified was actually a filtered insertion
    // point. This means (strictly speaking) that we actually have multiple
    // insertion points: the filtered one and a generic insertion point
    // (content that doesn't match the filter will just go right underneath the
    // bound element).

    *aMultipleInsertionPoints = PR_TRUE;
    *aIndex = 0;
    return nsnull;
  }

  *aMultipleInsertionPoints = PR_FALSE;
  *aIndex = entry->GetInsertionIndex();

  nsIContent* templContent = GetImmediateChild(nsXBLAtoms::content);
  nsIContent* content = entry->GetInsertionParent();
  nsIContent *realContent = LocateInstance(nsnull, templContent, aCopyRoot,
                                           content);

  return realContent ? realContent : aBoundElement;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 955 of file nsXBLPrototypeBinding.cpp.

{
  if (mResources) {
    return &mResources->mStyleSheetList;
  }

  return nsnull;
}

Definition at line 120 of file nsXBLPrototypeBinding.h.

{ return mHasBaseProto; }

Here is the caller graph for this function:

Definition at line 128 of file nsXBLPrototypeBinding.h.

Here is the caller graph for this function:

Definition at line 130 of file nsXBLPrototypeBinding.h.

                          {
    return mResources && mResources->mStyleSheetList.Count() > 0;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 710 of file nsXBLPrototypeBinding.cpp.

{
  // Check our IID table.
  if (mInterfaceTable) {
    nsIIDKey key(aIID);
    nsCOMPtr<nsISupports> supports = getter_AddRefs(NS_STATIC_CAST(nsISupports*, 
                                                                   mInterfaceTable->Get(&key)));
    return supports != nsnull;
  }

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 92 of file nsXBLPrototypeBinding.h.

{ return mInheritStyle; }

Here is the caller graph for this function:

nsresult nsXBLPrototypeBinding::Init ( const nsACString &  aRef,
nsIXBLDocumentInfo aInfo,
nsIContent aElement 
)

Definition at line 263 of file nsXBLPrototypeBinding.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsXBLPrototypeBinding::InitClass ( const nsCString aClassName,
JSContext aContext,
JSObject aGlobal,
JSObject aScriptObject,
void **  aClassObject 
)

Definition at line 743 of file nsXBLPrototypeBinding.cpp.

{
  NS_ENSURE_ARG_POINTER(aClassObject); 

  *aClassObject = nsnull;

  return nsXBLBinding::DoInitJSClass(aContext, aGlobal, aScriptObject,
                                     aClassName, aClassObject);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 288 of file nsXBLPrototypeBinding.cpp.

{
  nsIContent* content = GetImmediateChild(nsXBLAtoms::content);
  if (content) {
    // Make sure to construct the attribute table first, since constructing the
    // insertion point table removes some of the subtrees, which makes them
    // unreachable by walking our DOM.
    ConstructAttributeTable(content);
    ConstructInsertionTable(content);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 441 of file nsXBLPrototypeBinding.cpp.

{
  if (mImplementation)
    return mImplementation->InstallImplementation(this, aBoundElement);
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 609 of file nsXBLPrototypeBinding.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 84 of file nsXBLPrototypeBinding.h.

{ return mXBLDocInfoWeak->IsChrome(); }

Here is the caller graph for this function:

Definition at line 354 of file nsXBLPrototypeBinding.cpp.

{
  if (mResources) {
    PRBool result;
    mResources->LoadResources(&result);
    return result;
  }

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsIContent * nsXBLPrototypeBinding::LocateInstance ( nsIContent aBoundElt,
nsIContent aTemplRoot,
nsIContent aCopyRoot,
nsIContent aTemplChild 
)

Definition at line 757 of file nsXBLPrototypeBinding.cpp.

{
  // XXX We will get in trouble if the binding instantiation deviates from the template
  // in the prototype.
  if (aTemplChild == aTemplRoot || !aTemplChild)
    return nsnull;

  nsCOMPtr<nsIContent> templParent = aTemplChild->GetParent();
  nsCOMPtr<nsIContent> childPoint;
  
  if (aBoundElement) {
    nsINodeInfo *ni = templParent->GetNodeInfo();

    if (ni->Equals(nsXBLAtoms::children, kNameSpaceID_XBL)) {
      childPoint = templParent;
      templParent = childPoint->GetParent();
    }
  }

  if (!templParent)
    return nsnull;

  nsIContent* result = nsnull;
  nsIContent *copyParent;

  if (templParent == aTemplRoot)
    copyParent = aCopyRoot;
  else
    copyParent = LocateInstance(aBoundElement, aTemplRoot, aCopyRoot, templParent);
  
  if (childPoint && aBoundElement) {
    // First we have to locate this insertion point and use its index and its
    // count to detemine our precise position within the template.
    nsIDocument* doc = aBoundElement->GetOwnerDoc();
    nsXBLBinding *binding = doc->BindingManager()->GetBinding(aBoundElement);
    nsIContent *anonContent = nsnull;

    while (binding) {
      anonContent = binding->GetAnonymousContent();
      if (anonContent)
        break;

      binding = binding->GetBaseBinding();
    }

    nsVoidArray* points;
    if (anonContent == copyParent)
      binding->GetInsertionPointsFor(aBoundElement, &points);
    else
      binding->GetInsertionPointsFor(copyParent, &points);
    PRInt32 count = points->Count();
    for (PRInt32 i = 0; i < count; i++) {
      // Next we have to find the real insertion point for this proto insertion
      // point.  If it does not contain any default content, then we should 
      // return null, since the content is not in the clone.
      nsXBLInsertionPoint* currPoint = NS_STATIC_CAST(nsXBLInsertionPoint*, points->ElementAt(i));
      nsCOMPtr<nsIContent> defContent = currPoint->GetDefaultContentTemplate();
      if (defContent == childPoint) {
        // Now check to see if we even built default content at this
        // insertion point.
        defContent = currPoint->GetDefaultContent();
        if (defContent) {
          // Find out the index of the template element within the <children> elt.
          PRInt32 index = childPoint->IndexOf(aTemplChild);
          
          // Now we just have to find the corresponding elt underneath the cloned
          // default content.
          result = defContent->GetChildAt(index);
        } 
        break;
      }
    }
  }
  else if (copyParent)
  {
    PRInt32 index = templParent->IndexOf(aTemplChild);
    result = copyParent->GetChildAt(index);
  }

  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 316 of file nsXBLPrototypeBinding.cpp.

{
  if (mBaseBinding == aBinding)
    return;

  if (mBaseBinding) {
    NS_ERROR("Base XBL prototype binding is already defined!");
    return;
  }

  mBaseBinding = aBinding;
}

Here is the caller graph for this function:

void nsXBLPrototypeBinding::SetBaseTag ( PRInt32  aNamespaceID,
nsIAtom aTag 
)

Definition at line 692 of file nsXBLPrototypeBinding.cpp.

{
  mBaseNameSpaceID = aNamespaceID;
  mBaseTag = aTag;
}

Here is the caller graph for this function:

Definition at line 338 of file nsXBLPrototypeBinding.cpp.

{
  mBinding = aElement;
  nsAutoString inheritStyle;
  mBinding->GetAttr(kNameSpaceID_None, nsXBLAtoms::inheritstyle, inheritStyle);
  if (inheritStyle.EqualsLiteral("false"))
    mInheritStyle = PR_FALSE;
}

Here is the caller graph for this function:

Definition at line 423 of file nsXBLPrototypeBinding.cpp.

{
  if (!mImplementation)
    return NS_ERROR_FAILURE;
  mImplementation->mConstructor = aMethod;
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 432 of file nsXBLPrototypeBinding.cpp.

{
  if (!mImplementation)
    return NS_ERROR_FAILURE;
  mImplementation->mDestructor = aMethod;
  return NS_OK;
}

Here is the caller graph for this function:

Definition at line 121 of file nsXBLPrototypeBinding.h.

{ mHasBaseProto = aHasBase; }

Here is the caller graph for this function:

Definition at line 108 of file nsXBLPrototypeBinding.h.

{ mImplementation = aImpl; }

Here is the caller graph for this function:

void nsXBLPrototypeBinding::SetInitialAttributes ( nsIContent aBoundElement,
nsIContent aAnonymousContent 
)

Definition at line 936 of file nsXBLPrototypeBinding.cpp.

{
  if (mAttributeTable) {
    nsXBLAttrChangeData data(this, aBoundElement, aAnonymousContent);
    mAttributeTable->Enumerate(SetAttrsNS, (void*)&data);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 95 of file nsXBLPrototypeBinding.h.

{ mPrototypeHandler = aHandler; }

Here is the caller graph for this function:

Definition at line 965 of file nsXBLPrototypeBinding.cpp.

{
  if (!mAttributeTable)
    return PR_TRUE;
  nsPRUint32Key nskey(kNameSpaceID_XBL);
  nsObjectHashtable* xblAttributes =
    NS_STATIC_CAST(nsObjectHashtable*, mAttributeTable->Get(&nskey));
  if (xblAttributes) {
    nsISupportsKey key(nsHTMLAtoms::text);
    void* entry = xblAttributes->Get(&key);
    return !entry;
  }

  return PR_TRUE;
}

Here is the caller graph for this function:

Definition at line 118 of file nsXBLPrototypeBinding.h.

{ return mXBLDocInfoWeak; }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 180 of file nsXBLPrototypeBinding.h.

nsFixedSizeAllocator * nsXBLPrototypeBinding::kAttrPool [static]

Definition at line 182 of file nsXBLPrototypeBinding.h.

nsFixedSizeAllocator * nsXBLPrototypeBinding::kInsPool [static]

Definition at line 183 of file nsXBLPrototypeBinding.h.

nsObjectHashtable* nsXBLPrototypeBinding::mAttributeTable [protected]

Definition at line 250 of file nsXBLPrototypeBinding.h.

Definition at line 241 of file nsXBLPrototypeBinding.h.

Definition at line 259 of file nsXBLPrototypeBinding.h.

Definition at line 260 of file nsXBLPrototypeBinding.h.

Definition at line 235 of file nsXBLPrototypeBinding.h.

Definition at line 234 of file nsXBLPrototypeBinding.h.

Definition at line 243 of file nsXBLPrototypeBinding.h.

Definition at line 238 of file nsXBLPrototypeBinding.h.

Definition at line 242 of file nsXBLPrototypeBinding.h.

nsObjectHashtable* nsXBLPrototypeBinding::mInsertionPointTable [protected]

Definition at line 254 of file nsXBLPrototypeBinding.h.

nsSupportsHashtable* nsXBLPrototypeBinding::mInterfaceTable [protected]

Definition at line 257 of file nsXBLPrototypeBinding.h.

Definition at line 264 of file nsXBLPrototypeBinding.h.

Definition at line 244 of file nsXBLPrototypeBinding.h.

Definition at line 236 of file nsXBLPrototypeBinding.h.

Definition at line 262 of file nsXBLPrototypeBinding.h.

Definition at line 246 of file nsXBLPrototypeBinding.h.

Definition at line 248 of file nsXBLPrototypeBinding.h.


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