Back to index

lightning-sunbird  0.9+nobinonly
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
nsHTMLStyleSheet Class Reference

#include <nsHTMLStyleSheet.h>

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

List of all members.

Classes

class  GenericTableRule
class  HTMLColorRule
class  TableColgroupRule
class  TableColRule
class  TableRowRule
class  TableTbodyRule
class  TableTHRule
class  TableUngroupedColRule

Public Types

typedef PRBool(* PR_CALLBACK )(nsIStyleRuleProcessor *, void *)

Public Member Functions

 nsHTMLStyleSheet (void)
nsresult Init ()
NS_DECL_ISUPPORTS NS_IMETHOD GetSheetURI (nsIURI **aSheetURL) const
NS_IMETHOD GetBaseURI (nsIURI **aBaseURL) const
NS_IMETHOD GetTitle (nsString &aTitle) const
NS_IMETHOD GetType (nsString &aType) const
 NS_IMETHOD_ (PRBool) UseForMedium(nsPresContext *aPresContext) const
 NS_IMETHOD_ (PRBool) HasRules() const
NS_IMETHOD GetApplicable (PRBool &aApplicable) const
 Whether the sheet is applicable.
NS_IMETHOD SetEnabled (PRBool aEnabled)
 Set the stylesheet to be enabled.
NS_IMETHOD GetComplete (PRBool &aComplete) const
 Whether the sheet is complete.
NS_IMETHOD SetComplete ()
NS_IMETHOD GetParentSheet (nsIStyleSheet *&aParent) const
NS_IMETHOD GetOwningDocument (nsIDocument *&aDocument) const
NS_IMETHOD SetOwningDocument (nsIDocument *aDocumemt)
NS_IMETHOD RulesMatching (ElementRuleProcessorData *aData)
 Find the |nsIStyleRule|s matching the given content node and position the given |nsRuleWalker| at the |nsRuleNode| in the rule tree representing that ordered list of rules (with higher precedence being farther from the root of the lexicographic tree).
NS_IMETHOD RulesMatching (PseudoRuleProcessorData *aData)
 Just like the previous |RulesMatching|, except for a given content node and pseudo-element.
NS_IMETHOD HasStateDependentStyle (StateRuleProcessorData *aData, nsReStyleHint *aResult)
 Return how (as described by nsReStyleHint) style can depend on a change of the given content state on the given content node.
NS_IMETHOD HasAttributeDependentStyle (AttributeRuleProcessorData *aData, nsReStyleHint *aResult)
 Return how (as described by nsReStyleHint) style can depend on the presence or value of the given attribute for the given content node.
nsresult Init (nsIURI *aURL, nsIDocument *aDocument)
nsresult Reset (nsIURI *aURL)
nsresult GetLinkColor (nscolor &aColor)
nsresult GetActiveLinkColor (nscolor &aColor)
nsresult GetVisitedLinkColor (nscolor &aColor)
nsresult SetLinkColor (nscolor aColor)
nsresult SetActiveLinkColor (nscolor aColor)
nsresult SetVisitedLinkColor (nscolor aColor)
already_AddRefed
< nsMappedAttributes
UniqueMappedAttributes (nsMappedAttributes *aMapped)
void DropMappedAttributes (nsMappedAttributes *aMapped)

Private Member Functions

 nsHTMLStyleSheet (const nsHTMLStyleSheet &aCopy)
nsHTMLStyleSheetoperator= (const nsHTMLStyleSheet &aCopy)
 ~nsHTMLStyleSheet ()

Private Attributes

nsIURImURL
nsIDocumentmDocument
HTMLColorRulemLinkRule
HTMLColorRulemVisitedRule
HTMLColorRulemActiveRule
HTMLColorRulemDocumentColorRule
TableTbodyRulemTableTbodyRule
TableRowRulemTableRowRule
TableColgroupRulemTableColgroupRule
TableColRulemTableColRule
TableUngroupedColRulemTableUngroupedColRule
TableTHRulemTableTHRule
PLDHashTable mMappedAttrTable

Friends

class HTMLColorRule
class GenericTableRule
class TableTHRule
class TableTbodyRule
class TableRowRule
class TableColgroupRule
class TableColRule
class TableUngroupedColRule

Detailed Description

Definition at line 49 of file nsHTMLStyleSheet.h.


Member Typedef Documentation

Definition at line 182 of file nsIStyleRuleProcessor.h.


Constructor & Destructor Documentation


Member Function Documentation

Definition at line 816 of file nsHTMLStyleSheet.cpp.

{
  NS_ENSURE_TRUE(aMapped, );

  NS_ASSERTION(mMappedAttrTable.ops, "table uninitialized");
#ifdef DEBUG
  PRUint32 entryCount = mMappedAttrTable.entryCount - 1;
#endif

  PL_DHashTableOperate(&mMappedAttrTable, aMapped, PL_DHASH_REMOVE);

  NS_ASSERTION(entryCount == mMappedAttrTable.entryCount, "not removed");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 714 of file nsHTMLStyleSheet.cpp.

{
  if (!mActiveRule) {
    return NS_HTML_STYLE_PROPERTY_NOT_THERE;
  }
  else {
    aColor = mActiveRule->mColor;
    return NS_OK;
  }
}
NS_IMETHODIMP nsHTMLStyleSheet::GetApplicable ( PRBool aApplicable) const [virtual]

Whether the sheet is applicable.

A sheet that is not applicable should never be inserted into a style set. A sheet may not be applicable for a variety of reasons including being disabled and being incomplete.

Implements nsIStyleSheet.

Definition at line 618 of file nsHTMLStyleSheet.cpp.

{
  aApplicable = PR_TRUE;
  return NS_OK;
}
NS_IMETHODIMP nsHTMLStyleSheet::GetBaseURI ( nsIURI **  aBaseURL) const [virtual]

Implements nsIStyleSheet.

Definition at line 584 of file nsHTMLStyleSheet.cpp.

{
  *aBaseURI = mURL;
  NS_IF_ADDREF(*aBaseURI);
  return NS_OK;
}
NS_IMETHODIMP nsHTMLStyleSheet::GetComplete ( PRBool aComplete) const [virtual]

Whether the sheet is complete.

Implements nsIStyleSheet.

Definition at line 631 of file nsHTMLStyleSheet.cpp.

{
  aComplete = PR_TRUE;
  return NS_OK;
}

Definition at line 702 of file nsHTMLStyleSheet.cpp.

{
  if (!mLinkRule) {
    return NS_HTML_STYLE_PROPERTY_NOT_THERE;
  }
  else {
    aColor = mLinkRule->mColor;
    return NS_OK;
  }
}

Implements nsIStyleSheet.

Definition at line 651 of file nsHTMLStyleSheet.cpp.

{
  aDocument = mDocument;
  NS_IF_ADDREF(aDocument);
  return NS_OK;
}

Implements nsIStyleSheet.

Definition at line 644 of file nsHTMLStyleSheet.cpp.

{
  aParent = nsnull;
  return NS_OK;
}
NS_IMETHODIMP nsHTMLStyleSheet::GetSheetURI ( nsIURI **  aSheetURL) const [virtual]

Implements nsIStyleSheet.

Definition at line 576 of file nsHTMLStyleSheet.cpp.

{
  *aSheetURI = mURL;
  NS_IF_ADDREF(*aSheetURI);
  return NS_OK;
}
NS_IMETHODIMP nsHTMLStyleSheet::GetTitle ( nsString aTitle) const [virtual]

Implements nsIStyleSheet.

Definition at line 592 of file nsHTMLStyleSheet.cpp.

{
  aTitle.Truncate();
  return NS_OK;
}
NS_IMETHODIMP nsHTMLStyleSheet::GetType ( nsString aType) const [virtual]

Implements nsIStyleSheet.

Definition at line 599 of file nsHTMLStyleSheet.cpp.

{
  aType.AssignLiteral("text/html");
  return NS_OK;
}

Definition at line 726 of file nsHTMLStyleSheet.cpp.

{
  if (!mVisitedRule) {
    return NS_HTML_STYLE_PROPERTY_NOT_THERE;
  }
  else {
    aColor = mVisitedRule->mColor;
    return NS_OK;
  }
}

Return how (as described by nsReStyleHint) style can depend on the presence or value of the given attribute for the given content node.

This test is used for optimization only, and may err on the side of reporting more dependencies than really exist.

Implements nsIStyleRuleProcessor.

Definition at line 532 of file nsHTMLStyleSheet.cpp.

{
  // Result is true for |href| changes on HTML links if we have link rules.
  nsIStyledContent *styledContent = aData->mStyledContent;
  if (aData->mAttribute == nsHTMLAtoms::href &&
      (mLinkRule || mVisitedRule || mActiveRule) &&
      styledContent &&
      styledContent->IsContentOfType(nsIContent::eHTML) &&
      aData->mContentTag == nsHTMLAtoms::a) {
    *aResult = eReStyle_Self;
    return NS_OK;
  }

  // Don't worry about the mDocumentColorRule since it only applies
  // to descendants of body, when we're already reresolving.

  // Handle the content style rules.
  if (styledContent && styledContent->IsAttributeMapped(aData->mAttribute)) {
    *aResult = eReStyle_Self;
    return NS_OK;
  }

  *aResult = nsReStyleHint(0);
  return NS_OK;
}

Here is the call graph for this function:

Return how (as described by nsReStyleHint) style can depend on a change of the given content state on the given content node.

This test is used for optimization only, and may err on the side of reporting more dependencies than really exist.

Event states are defined in nsIEventStateManager.h.

Implements nsIStyleRuleProcessor.

Definition at line 513 of file nsHTMLStyleSheet.cpp.

nsresult nsHTMLStyleSheet::Init ( nsIURI aURL,
nsIDocument aDocument 
)

Definition at line 666 of file nsHTMLStyleSheet.cpp.

{
  NS_PRECONDITION(aURL && aDocument, "null ptr");
  if (! aURL || ! aDocument)
    return NS_ERROR_NULL_POINTER;

  if (mURL || mDocument)
    return NS_ERROR_ALREADY_INITIALIZED;

  mDocument = aDocument; // not refcounted!
  mURL = aURL;
  NS_ADDREF(mURL);
  return NS_OK;
}

Here is the call graph for this function:

nsHTMLStyleSheet::NS_IMETHOD_ ( PRBool  ) const [virtual]

Implements nsIStyleSheet.

nsHTMLStyleSheet::NS_IMETHOD_ ( PRBool  ) const [virtual]

Implements nsIStyleSheet.

nsHTMLStyleSheet& nsHTMLStyleSheet::operator= ( const nsHTMLStyleSheet aCopy) [private]

Find the |nsIStyleRule|s matching the given content node and position the given |nsRuleWalker| at the |nsRuleNode| in the rule tree representing that ordered list of rules (with higher precedence being farther from the root of the lexicographic tree).

Implements nsIStyleRuleProcessor.

Definition at line 429 of file nsHTMLStyleSheet.cpp.

{
  nsIStyledContent *styledContent = aData->mStyledContent;

  if (styledContent) {
    nsRuleWalker *ruleWalker = aData->mRuleWalker;
    if (aData->mIsHTMLContent) {
      nsIAtom* tag = aData->mContentTag;

      // if we have anchor colors, check if this is an anchor with an href
      if (tag == nsHTMLAtoms::a) {
        if (mLinkRule || mVisitedRule || mActiveRule) {
          if (aData->mIsHTMLLink) {
            switch (aData->mLinkState) {
              case eLinkState_Unvisited:
                if (mLinkRule)
                  ruleWalker->Forward(mLinkRule);
                break;
              case eLinkState_Visited:
                if (mVisitedRule)
                  ruleWalker->Forward(mVisitedRule);
                break;
              default:
                break;
            }

            // No need to add to the active rule if it's not a link
            if (mActiveRule && (aData->mEventState & NS_EVENT_STATE_ACTIVE))
              ruleWalker->Forward(mActiveRule);
          }
        } // end link/visited/active rules
      } // end A tag
      // add the rule to handle text-align for a <th>
      else if (tag == nsHTMLAtoms::th) {
        ruleWalker->Forward(mTableTHRule);
      }
      else if (tag == nsHTMLAtoms::tr) {
        ruleWalker->Forward(mTableRowRule);
      }
      else if ((tag == nsHTMLAtoms::thead) || (tag == nsHTMLAtoms::tbody) || (tag == nsHTMLAtoms::tfoot)) {
        ruleWalker->Forward(mTableTbodyRule);
      }
      else if (tag == nsHTMLAtoms::col) {
        nsIContent* parent = aData->mParentContent;
        if (parent && parent->IsContentOfType(nsIContent::eHTML) &&
            parent->Tag() == nsHTMLAtoms::colgroup) {
          ruleWalker->Forward(mTableColRule);
        } else {
          ruleWalker->Forward(mTableUngroupedColRule);
        }
      }
      else if (tag == nsHTMLAtoms::colgroup) {
        ruleWalker->Forward(mTableColgroupRule);
      }
      else if (tag == nsHTMLAtoms::table) {
        if (aData->mCompatMode == eCompatibility_NavQuirks) {
          nscolor bodyColor;
          nsresult rv =
            GetBodyColor(ruleWalker->GetCurrentNode()->GetPresContext(),
                         &bodyColor);
          if (NS_SUCCEEDED(rv) &&
              (!mDocumentColorRule || bodyColor != mDocumentColorRule->mColor)) {
            NS_IF_RELEASE(mDocumentColorRule);
            mDocumentColorRule = new HTMLColorRule();
            if (mDocumentColorRule) {
              NS_ADDREF(mDocumentColorRule);
              mDocumentColorRule->mColor = bodyColor;
            }
          }
          if (mDocumentColorRule)
            ruleWalker->Forward(mDocumentColorRule);
        }
      }
    } // end html element

    // just get the style rules from the content
    styledContent->WalkContentStyleRules(ruleWalker);
  }

  return NS_OK;
}

Here is the call graph for this function:

Just like the previous |RulesMatching|, except for a given content node and pseudo-element.

Implements nsIStyleRuleProcessor.

Definition at line 561 of file nsHTMLStyleSheet.cpp.

{
  nsIAtom* pseudoTag = aData->mPseudoTag;
  if (pseudoTag == nsCSSAnonBoxes::tableCol) {
    nsRuleWalker *ruleWalker = aData->mRuleWalker;
    if (ruleWalker) {
      ruleWalker->Forward(mTableColRule);
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 757 of file nsHTMLStyleSheet.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsIStyleSheet.

Definition at line 638 of file nsHTMLStyleSheet.cpp.

{
  return NS_OK;
}

Set the stylesheet to be enabled.

This may or may not make it applicable.

Implements nsIStyleSheet.

Definition at line 625 of file nsHTMLStyleSheet.cpp.

{ // these can't be disabled
  return NS_OK;
}

Definition at line 738 of file nsHTMLStyleSheet.cpp.

{
  if (mLinkRule) {
    if (mLinkRule->mColor == aColor)
      return NS_OK;
    NS_RELEASE(mLinkRule);
  }

  mLinkRule = new HTMLColorRule();
  if (!mLinkRule)
    return NS_ERROR_OUT_OF_MEMORY;
  NS_ADDREF(mLinkRule);

  mLinkRule->mColor = aColor;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implements nsIStyleSheet.

Definition at line 659 of file nsHTMLStyleSheet.cpp.

{
  mDocument = aDocument; // not refcounted
  return NS_OK;
}

Definition at line 775 of file nsHTMLStyleSheet.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 793 of file nsHTMLStyleSheet.cpp.

{
  if (!mMappedAttrTable.ops) {
    PRBool res = PL_DHashTableInit(&mMappedAttrTable, &MappedAttrTable_Ops,
                                   nsnull, sizeof(MappedAttrTableEntry), 16);
    if (!res) {
      mMappedAttrTable.ops = nsnull;
      return nsnull;
    }
  }
  MappedAttrTableEntry *entry = NS_STATIC_CAST(MappedAttrTableEntry*,
    PL_DHashTableOperate(&mMappedAttrTable, aMapped, PL_DHASH_ADD));
  if (!entry)
    return nsnull;
  if (!entry->mAttributes) {
    // We added a new entry to the hashtable, so we have a new unique set.
    entry->mAttributes = aMapped;
  }
  NS_ADDREF(entry->mAttributes); // for caller
  return entry->mAttributes;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class GenericTableRule [friend]

Definition at line 122 of file nsHTMLStyleSheet.h.

friend class HTMLColorRule [friend]

Definition at line 104 of file nsHTMLStyleSheet.h.

friend class TableColgroupRule [friend]

Definition at line 169 of file nsHTMLStyleSheet.h.

friend class TableColRule [friend]

Definition at line 181 of file nsHTMLStyleSheet.h.

friend class TableRowRule [friend]

Definition at line 159 of file nsHTMLStyleSheet.h.

friend class TableTbodyRule [friend]

Definition at line 149 of file nsHTMLStyleSheet.h.

friend class TableTHRule [friend]

Definition at line 138 of file nsHTMLStyleSheet.h.

friend class TableUngroupedColRule [friend]

Definition at line 192 of file nsHTMLStyleSheet.h.


Member Data Documentation

Definition at line 205 of file nsHTMLStyleSheet.h.

Definition at line 202 of file nsHTMLStyleSheet.h.

Definition at line 206 of file nsHTMLStyleSheet.h.

Definition at line 203 of file nsHTMLStyleSheet.h.

Definition at line 214 of file nsHTMLStyleSheet.h.

Definition at line 209 of file nsHTMLStyleSheet.h.

Definition at line 210 of file nsHTMLStyleSheet.h.

Definition at line 208 of file nsHTMLStyleSheet.h.

Definition at line 207 of file nsHTMLStyleSheet.h.

Definition at line 212 of file nsHTMLStyleSheet.h.

Definition at line 211 of file nsHTMLStyleSheet.h.

Definition at line 201 of file nsHTMLStyleSheet.h.

Definition at line 204 of file nsHTMLStyleSheet.h.


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