Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables
nsHTMLStyleSheet.cpp File Reference
#include "nsHTMLStyleSheet.h"
#include "nsINameSpaceManager.h"
#include "nsIAtom.h"
#include "nsIURL.h"
#include "nsISupportsArray.h"
#include "nsMappedAttributes.h"
#include "nsILink.h"
#include "nsIFrame.h"
#include "nsStyleContext.h"
#include "nsHTMLAtoms.h"
#include "nsPresContext.h"
#include "nsIEventStateManager.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsStyleConsts.h"
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMHTMLElement.h"
#include "nsCSSAnonBoxes.h"
#include "nsRuleWalker.h"
#include "nsRuleData.h"

Go to the source code of this file.

Classes

struct  MappedAttrTableEntry

Functions

static void PostResolveCallback (nsStyleStruct *aStyleStruct, nsRuleData *aRuleData)
static void ProcessTableRulesAttribute (nsStyleStruct *aStyleStruct, nsRuleData *aRuleData, PRUint8 aSide, PRBool aGroup, PRUint8 aRulesArg1, PRUint8 aRulesArg2, PRUint8 aRulesArg3)
static void TbodyPostResolveCallback (nsStyleStruct *aStyleStruct, nsRuleData *aRuleData)
static void RowPostResolveCallback (nsStyleStruct *aStyleStruct, nsRuleData *aRuleData)
static void ColgroupPostResolveCallback (nsStyleStruct *aStyleStruct, nsRuleData *aRuleData)
static void ColPostResolveCallback (nsStyleStruct *aStyleStruct, nsRuleData *aRuleData)
static void UngroupedColPostResolveCallback (nsStyleStruct *aStyleStruct, nsRuleData *aRuleData)
 MappedAttrTable_HashKey (PLDHashTable *table, const void *key)
 MappedAttrTable_ClearEntry (PLDHashTable *table, PLDHashEntryHdr *hdr)
 MappedAttrTable_MatchEntry (PLDHashTable *table, const PLDHashEntryHdr *hdr, const void *key)
static nsresult GetBodyColor (nsPresContext *aPresContext, nscolor *aColor)
nsresult NS_NewHTMLStyleSheet (nsHTMLStyleSheet **aInstancePtrResult, nsIURI *aURL, nsIDocument *aDocument)
nsresult NS_NewHTMLStyleSheet (nsHTMLStyleSheet **aInstancePtrResult)

Variables

static PLDHashTableOps MappedAttrTable_Ops

Function Documentation

static void ColgroupPostResolveCallback ( nsStyleStruct aStyleStruct,
nsRuleData aRuleData 
) [static]

Definition at line 238 of file nsHTMLStyleSheet.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void ColPostResolveCallback ( nsStyleStruct aStyleStruct,
nsRuleData aRuleData 
) [static]

Definition at line 256 of file nsHTMLStyleSheet.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult GetBodyColor ( nsPresContext aPresContext,
nscolor aColor 
) [static]

Definition at line 411 of file nsHTMLStyleSheet.cpp.

{
  nsIPresShell *shell = aPresContext->PresShell();
  nsCOMPtr<nsIDOMHTMLDocument> domdoc = do_QueryInterface(shell->GetDocument());
  if (!domdoc)
    return NS_ERROR_FAILURE;
  nsCOMPtr<nsIDOMHTMLElement> body;
  domdoc->GetBody(getter_AddRefs(body));
  nsCOMPtr<nsIContent> bodyContent = do_QueryInterface(body);
  nsIFrame *bodyFrame;
  shell->GetPrimaryFrameFor(bodyContent, &bodyFrame);
  if (!bodyFrame)
    return NS_ERROR_FAILURE;
  *aColor = bodyFrame->GetStyleColor()->mColor;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 310 of file nsHTMLStyleSheet.cpp.

Here is the call graph for this function:

MappedAttrTable_HashKey ( PLDHashTable table,
const void key 
)

Definition at line 301 of file nsHTMLStyleSheet.cpp.

{
  nsMappedAttributes *attributes =
    NS_STATIC_CAST(nsMappedAttributes*, NS_CONST_CAST(void*, key));

  return attributes->HashValue();
}

Here is the call graph for this function:

Definition at line 319 of file nsHTMLStyleSheet.cpp.

Here is the call graph for this function:

nsresult NS_NewHTMLStyleSheet ( nsHTMLStyleSheet **  aInstancePtrResult,
nsIURI aURL,
nsIDocument aDocument 
)

Definition at line 848 of file nsHTMLStyleSheet.cpp.

{
  nsresult rv;
  nsHTMLStyleSheet* sheet;
  if (NS_FAILED(rv = NS_NewHTMLStyleSheet(&sheet)))
    return rv;

  if (NS_FAILED(rv = sheet->Init(aURL, aDocument))) {
    NS_RELEASE(sheet);
    return rv;
  }

  *aInstancePtrResult = sheet;
  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult NS_NewHTMLStyleSheet ( nsHTMLStyleSheet **  aInstancePtrResult)

Definition at line 867 of file nsHTMLStyleSheet.cpp.

{
  NS_ASSERTION(aInstancePtrResult, "null out param");

  nsHTMLStyleSheet *it = new nsHTMLStyleSheet();
  if (!it) {
    *aInstancePtrResult = nsnull;
    return NS_ERROR_OUT_OF_MEMORY;
  }

  NS_ADDREF(it);
  nsresult rv = it->Init();
  if (NS_FAILED(rv))
    NS_RELEASE(it);

  *aInstancePtrResult = it; // NS_ADDREF above, or set to null by NS_RELEASE
  return rv;
}

Here is the call graph for this function:

static void PostResolveCallback ( nsStyleStruct aStyleStruct,
nsRuleData aRuleData 
) [static]

Definition at line 106 of file nsHTMLStyleSheet.cpp.

{
  nsStyleText* text = (nsStyleText*)aStyleStruct;
  if (text->mTextAlign == NS_STYLE_TEXT_ALIGN_DEFAULT) {
    nsStyleContext* parentContext = aRuleData->mStyleContext->GetParent();

    if (parentContext) {
      const nsStyleText* parentStyleText = parentContext->GetStyleText();
      PRUint8 parentAlign = parentStyleText->mTextAlign;
      text->mTextAlign = (NS_STYLE_TEXT_ALIGN_DEFAULT == parentAlign)
                              ? NS_STYLE_TEXT_ALIGN_CENTER : parentAlign;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void ProcessTableRulesAttribute ( nsStyleStruct aStyleStruct,
nsRuleData aRuleData,
PRUint8  aSide,
PRBool  aGroup,
PRUint8  aRulesArg1,
PRUint8  aRulesArg2,
PRUint8  aRulesArg3 
) [static]

Definition at line 132 of file nsHTMLStyleSheet.cpp.

{
  if (!aStyleStruct || !aRuleData || !aRuleData->mPresContext) return;

  nsStyleContext* tableContext = aRuleData->mStyleContext->GetParent();
  if (!tableContext)
    return;
  if (!aGroup) {
    tableContext = tableContext->GetParent();
    if (!tableContext)
      return;
  } 
  
  const nsStyleTable* tableData = tableContext->GetStyleTable();
  if (aRulesArg1 == tableData->mRules ||
      aRulesArg2 == tableData->mRules ||
      aRulesArg3 == tableData->mRules) {
    const nsStyleBorder* tableBorderData = tableContext->GetStyleBorder();
    PRUint8 tableBorderStyle = tableBorderData->GetBorderStyle(aSide);

    nsStyleBorder* borderData = (nsStyleBorder*)aStyleStruct;
    if (!borderData)
      return;
    PRUint8 borderStyle = borderData->GetBorderStyle(aSide);
    // XXX It appears that the style system erronously applies the custom style rule after css style, 
    // consequently it does not properly fit into the casade. For now, assume that a border style of none
    // implies that the style has not been set.
    // XXXldb No, there's nothing wrong with the style system.  The problem
    // is that the author of all these table rules made them work as
    // post-resolve callbacks, which is an override mechanism that was meant
    // to be used for other things.  They should instead map their rule data
    // normally (see nsIStyleRule.h).
    if (NS_STYLE_BORDER_STYLE_NONE == borderStyle) {
      // use the table's border style if it is dashed or dotted, otherwise use solid
      PRUint8 bStyle = ((NS_STYLE_BORDER_STYLE_NONE != tableBorderStyle) &&
                        (NS_STYLE_BORDER_STYLE_HIDDEN != tableBorderStyle)) 
                        ? tableBorderStyle : NS_STYLE_BORDER_STYLE_SOLID;
      if ((NS_STYLE_BORDER_STYLE_DASHED != bStyle) && 
          (NS_STYLE_BORDER_STYLE_DOTTED != bStyle) && 
          (NS_STYLE_BORDER_STYLE_SOLID  != bStyle)) {
        bStyle = NS_STYLE_BORDER_STYLE_SOLID;
      }
      bStyle |= NS_STYLE_BORDER_STYLE_RULES_MARKER;
      borderData->SetBorderStyle(aSide, bStyle);

      nscolor borderColor;
      PRBool transparent, foreground;
      borderData->GetBorderColor(aSide, borderColor, transparent, foreground);
      if (transparent || foreground) {
        // use the table's border color if it is set, otherwise use black
        nscolor tableBorderColor;
        tableBorderData->GetBorderColor(aSide, tableBorderColor, transparent, foreground);
        borderColor = (transparent || foreground) ? NS_RGB(0,0,0) : tableBorderColor;
        borderData->SetBorderColor(aSide, borderColor);
      }
      // set the border width to be 1 pixel
      nscoord onePixel =
        NSToCoordRound(aRuleData->mPresContext->ScaledPixelsToTwips());
      borderData->SetBorderWidth(aSide, onePixel);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void RowPostResolveCallback ( nsStyleStruct aStyleStruct,
nsRuleData aRuleData 
) [static]

Definition at line 220 of file nsHTMLStyleSheet.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void TbodyPostResolveCallback ( nsStyleStruct aStyleStruct,
nsRuleData aRuleData 
) [static]

Definition at line 201 of file nsHTMLStyleSheet.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void UngroupedColPostResolveCallback ( nsStyleStruct aStyleStruct,
nsRuleData aRuleData 
) [static]

Definition at line 264 of file nsHTMLStyleSheet.cpp.

{
  // Pass PR_TRUE for aGroup, so that we find the table's style
  // context correctly.
  ::ProcessTableRulesAttribute(aStyleStruct, aRuleData, NS_SIDE_LEFT, PR_TRUE, NS_STYLE_TABLE_RULES_ALL,
                               NS_STYLE_TABLE_RULES_COLS, NS_STYLE_TABLE_RULES_COLS);
  ::ProcessTableRulesAttribute(aStyleStruct, aRuleData, NS_SIDE_RIGHT, PR_TRUE, NS_STYLE_TABLE_RULES_ALL,
                               NS_STYLE_TABLE_RULES_COLS, NS_STYLE_TABLE_RULES_COLS);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation