Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Member Functions | Private Member Functions | Private Attributes
nsMappedAttributes Class Reference

#include <nsMappedAttributes.h>

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

List of all members.

Classes

struct  InternalAttr

Public Member Functions

 nsMappedAttributes (nsHTMLStyleSheet *aSheet, nsMapRuleToAttributesFunc aMapRuleFunc)
voidoperator new (size_t size, PRUint32 aAttrCount=1) CPP_THROW_NEW
nsMappedAttributesClone (PRBool aWillAddAttr)
NS_DECL_ISUPPORTS nsresult SetAndTakeAttr (nsIAtom *aAttrName, nsAttrValue &aValue)
const nsAttrValueGetAttr (nsIAtom *aAttrName) const
PRUint32 Count () const
PRBool Equals (const nsMappedAttributes *aAttributes) const
PRUint32 HashValue () const
void DropStyleSheetReference ()
void SetStyleSheet (nsHTMLStyleSheet *aSheet)
nsHTMLStyleSheetGetStyleSheet ()
const nsAttrNameNameAt (PRUint32 aPos) const
const nsAttrValueAttrAt (PRUint32 aPos) const
void RemoveAttrAt (PRUint32 aPos, nsAttrValue &aValue)
const nsAttrNameGetExistingAttrNameFromQName (const nsACString &aName) const
PRInt32 IndexOfAttr (nsIAtom *aLocalName, PRInt32 aNamespaceID) const
NS_IMETHOD MapRuleInfoInto (nsRuleData *aRuleData)
 |nsIStyleRule::MapRuleInfoInto| is a request to copy all stylistic data represented by the rule that:

Private Member Functions

 nsMappedAttributes (const nsMappedAttributes &aCopy)
 ~nsMappedAttributes ()
const InternalAttrAttrs () const
 Due to a compiler bug in VisualAge C++ for AIX, we need to return the address of the first index into mAttrs here, instead of simply returning mAttrs itself.
InternalAttrAttrs ()

Private Attributes

PRUint16 mAttrCount
nsHTMLStyleSheetmSheet
nsMapRuleToAttributesFunc mRuleMapper
voidmAttrs [1]

Detailed Description

Definition at line 50 of file nsMappedAttributes.h.


Class Documentation

struct nsMappedAttributes::InternalAttr

Definition at line 110 of file nsMappedAttributes.h.

Collaboration diagram for nsMappedAttributes::InternalAttr:
Class Members
nsAttrName mName
nsAttrValue mValue

Constructor & Destructor Documentation

Definition at line 44 of file nsMappedAttributes.cpp.

  : mAttrCount(0),
    mSheet(aSheet),
    mRuleMapper(aMapRuleFunc)
{
}

Here is the caller graph for this function:

Definition at line 52 of file nsMappedAttributes.cpp.

  : mAttrCount(aCopy.mAttrCount),
    mSheet(aCopy.mSheet),
    mRuleMapper(aCopy.mRuleMapper)
{
  NS_ASSERTION(mBufferSize >= aCopy.mAttrCount, "can't fit attributes");

  PRUint32 i;
  for (i = 0; i < mAttrCount; ++i) {
    new (&Attrs()[i]) InternalAttr(aCopy.Attrs()[i]);
  }
}

Here is the call graph for this function:

Definition at line 65 of file nsMappedAttributes.cpp.

{
  if (mSheet) {
    mSheet->DropMappedAttributes(this);
  }

  PRUint32 i;
  for (i = 0; i < mAttrCount; ++i) {
    Attrs()[i].~InternalAttr();
  }
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 88 of file nsMappedAttributes.h.

  {
    NS_ASSERTION(aPos < mAttrCount, "out-of-bounds");
    return &Attrs()[aPos].mValue;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

const InternalAttr* nsMappedAttributes::Attrs ( ) const [inline, private]

Due to a compiler bug in VisualAge C++ for AIX, we need to return the address of the first index into mAttrs here, instead of simply returning mAttrs itself.

See Bug 231104 for more information.

Definition at line 123 of file nsMappedAttributes.h.

  {
    return NS_REINTERPRET_CAST(const InternalAttr*, &(mAttrs[0]));
  }

Here is the caller graph for this function:

InternalAttr* nsMappedAttributes::Attrs ( ) [inline, private]

Definition at line 127 of file nsMappedAttributes.h.

  {
    return NS_REINTERPRET_CAST(InternalAttr*, &(mAttrs[0]));
  }

Definition at line 79 of file nsMappedAttributes.cpp.

{
  PRUint32 extra = aWillAddAttr ? 1 : 0;

  // This will call the overridden operator new
  return new (mAttrCount + extra) nsMappedAttributes(*this);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRUint32 nsMappedAttributes::Count ( ) const [inline]

Definition at line 65 of file nsMappedAttributes.h.

  {
    return mAttrCount;
  }

Here is the caller graph for this function:

Definition at line 73 of file nsMappedAttributes.h.

  {
    mSheet = nsnull;
  }

Here is the caller graph for this function:

Definition at line 150 of file nsMappedAttributes.cpp.

{
  if (this == aOther) {
    return PR_TRUE;
  }

  if (mRuleMapper != aOther->mRuleMapper || mAttrCount != aOther->mAttrCount) {
    return PR_FALSE;
  }

  PRUint32 i;
  for (i = 0; i < mAttrCount; ++i) {
    if (!Attrs()[i].mName.Equals(aOther->Attrs()[i].mName) ||
        !Attrs()[i].mValue.Equals(aOther->Attrs()[i].mValue)) {
      return PR_FALSE;
    }
  }

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 137 of file nsMappedAttributes.cpp.

{
  NS_PRECONDITION(aAttrName, "null name");

  PRInt32 i = IndexOfAttr(aAttrName, kNameSpaceID_None);
  if (i >= 0) {
    return &Attrs()[i].mValue;
  }

  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 242 of file nsMappedAttributes.cpp.

{
  PRUint32 i;
  for (i = 0; i < mAttrCount; ++i) {
    if (Attrs()[i].mName.IsAtom()) {
      if (Attrs()[i].mName.Atom()->EqualsUTF8(aName)) {
        return &Attrs()[i].mName;
      }
    }
    else {
      if (Attrs()[i].mName.NodeInfo()->QualifiedNameEquals(aName)) {
        return &Attrs()[i].mName;
      }
    }
  }

  return nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 78 of file nsMappedAttributes.h.

  {
    return mSheet;
  }

Here is the caller graph for this function:

Definition at line 172 of file nsMappedAttributes.cpp.

{
  PRUint32 value = NS_PTR_TO_INT32(mRuleMapper);

  PRUint32 i;
  for (i = 0; i < mAttrCount; ++i) {
    value ^= Attrs()[i].mName.HashValue() ^ Attrs()[i].mValue.HashValue();
  }

  return value;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsMappedAttributes::IndexOfAttr ( nsIAtom aLocalName,
PRInt32  aNamespaceID 
) const

Definition at line 262 of file nsMappedAttributes.cpp.

{
  PRUint32 i;
  if (aNamespaceID == kNameSpaceID_None) {
    // This should be the common case so lets make an optimized loop
    for (i = 0; i < mAttrCount; ++i) {
      if (Attrs()[i].mName.Equals(aLocalName)) {
        return i;
      }
    }
  }
  else {
    for (i = 0; i < mAttrCount; ++i) {
      if (Attrs()[i].mName.Equals(aLocalName, aNamespaceID)) {
        return i;
      }
    }
  }

  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

|nsIStyleRule::MapRuleInfoInto| is a request to copy all stylistic data represented by the rule that:

  • are relevant for |aRuleData->mSID| (the style struct ID)
  • are not already filled into the data struct into the appropriate data struct in |aRuleData|. It is important that only empty data are filled in, since the rule tree is walked from highest priority rule to least, so that the walk can stop if all needed data are found. Thus overwriting non-empty data will break CSS cascading rules.

Implements nsIStyleRule.

Definition at line 194 of file nsMappedAttributes.cpp.

{
  if (mRuleMapper) {
    (*mRuleMapper)(this, aRuleData);
  }
  return NS_OK;
}

Definition at line 83 of file nsMappedAttributes.h.

  {
    NS_ASSERTION(aPos < mAttrCount, "out-of-bounds");
    return &Attrs()[aPos].mName;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void * nsMappedAttributes::operator new ( size_t  size,
PRUint32  aAttrCount = 1 
)

Definition at line 87 of file nsMappedAttributes.cpp.

{
  NS_ASSERTION(aAttrCount > 0, "zero-attribute nsMappedAttributes requested");

  // aSize will include the mAttrs buffer so subtract that.
  void* newAttrs = ::operator new(aSize - sizeof(void*[1]) +
                                  aAttrCount * sizeof(InternalAttr));

#ifdef DEBUG
  if (newAttrs) {
    NS_STATIC_CAST(nsMappedAttributes*, newAttrs)->mBufferSize = aAttrCount;
  }
#endif

  return newAttrs;
}

Definition at line 232 of file nsMappedAttributes.cpp.

{
  Attrs()[aPos].mValue.SwapValueWith(aValue);
  Attrs()[aPos].~InternalAttr();
  memmove(&Attrs()[aPos], &Attrs()[aPos + 1],
          (mAttrCount - aPos - 1) * sizeof(InternalAttr));
  mAttrCount--;
}

Here is the call graph for this function:

Definition at line 185 of file nsMappedAttributes.cpp.

{
  if (mSheet) {
    mSheet->DropMappedAttributes(this);
  }
  mSheet = aSheet;  // not ref counted
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 132 of file nsMappedAttributes.h.

Definition at line 138 of file nsMappedAttributes.h.

Definition at line 137 of file nsMappedAttributes.h.

Definition at line 136 of file nsMappedAttributes.h.


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