Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes
nsTextFrame::TextStyle Struct Reference
Inheritance diagram for nsTextFrame::TextStyle:
Inheritance graph
[legend]
Collaboration diagram for nsTextFrame::TextStyle:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TextStyle (nsPresContext *aPresContext, nsIRenderingContext &aRenderingContext, nsStyleContext *sc)
 ~TextStyle ()

Public Attributes

const nsStyleFontmFont
const nsStyleTextmText
nsIFontMetricsmNormalFont
nsIFontMetricsmSmallFont
nsIFontMetricsmLastFont
PRBool mSmallCaps
nscoord mWordSpacing
nscoord mLetterSpacing
nscoord mSpaceWidth
nscoord mAveCharWidth
PRBool mJustifying
PRBool mPreformatted
PRInt32 mNumJustifiableCharacterToRender
PRInt32 mNumJustifiableCharacterToMeasure
nscoord mExtraSpacePerJustifiableCharacter
PRInt32 mNumJustifiableCharacterReceivingExtraJot

Detailed Description

Definition at line 559 of file nsTextFrame.cpp.


Constructor & Destructor Documentation

nsTextFrame::TextStyle::TextStyle ( nsPresContext aPresContext,
nsIRenderingContext aRenderingContext,
nsStyleContext sc 
) [inline]

Definition at line 577 of file nsTextFrame.cpp.

    {
      // Get style data
      mFont = sc->GetStyleFont();
      mText = sc->GetStyleText();

      // Cache the original decorations and reuse the current font
      // to query metrics, rather than creating a new font which is expensive.
      nsFont* plainFont = (nsFont *)&mFont->mFont; //XXX: Change to use a CONST_CAST macro.
      NS_ASSERTION(plainFont, "null plainFont: font problems in TextStyle::TextStyle");
      PRUint8 originalDecorations = plainFont->decorations;
      plainFont->decorations = NS_FONT_DECORATION_NONE;
      mAveCharWidth = 0;
      SetFontFromStyle(&aRenderingContext, sc); // some users of the struct expect this state
      aRenderingContext.GetFontMetrics(mNormalFont);
      mNormalFont->GetSpaceWidth(mSpaceWidth);
      mNormalFont->GetAveCharWidth(mAveCharWidth);
      mLastFont = mNormalFont;

      // Get the small-caps font if needed
      mSmallCaps = NS_STYLE_FONT_VARIANT_SMALL_CAPS == plainFont->variant;
      if (mSmallCaps) {
        nscoord originalSize = plainFont->size;
        plainFont->size = nscoord(0.8 * plainFont->size);
        mSmallFont = aPresContext->GetMetricsFor(*plainFont).get();  // addrefs
        // Reset to the size value saved earlier.
        plainFont->size = originalSize;
      }
      else {
        mSmallFont = nsnull;
      }

      // Reset to the decoration saved earlier
      plainFont->decorations = originalDecorations; 

      // Get the word and letter spacing
      PRIntn unit = mText->mWordSpacing.GetUnit();
      if (eStyleUnit_Coord == unit) {
        mWordSpacing = mText->mWordSpacing.GetCoordValue();
      } else {
        mWordSpacing = 0;
      }

      unit = mText->mLetterSpacing.GetUnit();
      if (eStyleUnit_Coord == unit) {
        mLetterSpacing = mText->mLetterSpacing.GetCoordValue();
      } else {
        mLetterSpacing = 0;
      }

      mNumJustifiableCharacterToRender = 0;
      mNumJustifiableCharacterToMeasure = 0;
      mNumJustifiableCharacterReceivingExtraJot = 0;
      mExtraSpacePerJustifiableCharacter = 0;
      mPreformatted = (NS_STYLE_WHITESPACE_PRE == mText->mWhiteSpace) ||
        (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == mText->mWhiteSpace);

      mJustifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == mText->mTextAlign) &&
        !mPreformatted;
    }

Here is the call graph for this function:


Member Data Documentation

Definition at line 569 of file nsTextFrame.cpp.

Definition at line 574 of file nsTextFrame.cpp.

Definition at line 560 of file nsTextFrame.cpp.

Definition at line 570 of file nsTextFrame.cpp.

Definition at line 564 of file nsTextFrame.cpp.

Definition at line 567 of file nsTextFrame.cpp.

Definition at line 562 of file nsTextFrame.cpp.

Definition at line 575 of file nsTextFrame.cpp.

Definition at line 573 of file nsTextFrame.cpp.

Definition at line 572 of file nsTextFrame.cpp.

Definition at line 571 of file nsTextFrame.cpp.

Definition at line 565 of file nsTextFrame.cpp.

Definition at line 563 of file nsTextFrame.cpp.

Definition at line 568 of file nsTextFrame.cpp.

Definition at line 561 of file nsTextFrame.cpp.

Definition at line 566 of file nsTextFrame.cpp.


The documentation for this struct was generated from the following file: