Back to index

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

#include <nsMathMLFrame.h>

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

List of all members.

Public Member Functions

NS_IMETHOD QueryInterface (REFNSIID aIID, void **aInstancePtr)
 NS_IMETHOD_ (nsrefcnt) AddRef()
 NS_IMETHOD_ (nsrefcnt) Release()
NS_IMETHOD GetBoundingMetrics (nsBoundingMetrics &aBoundingMetrics)
NS_IMETHOD SetBoundingMetrics (const nsBoundingMetrics &aBoundingMetrics)
NS_IMETHOD GetReference (nsPoint &aReference)
NS_IMETHOD SetReference (const nsPoint &aReference)
virtual eMathMLFrameType GetMathMLFrameType ()
NS_IMETHOD Stretch (nsIRenderingContext &aRenderingContext, nsStretchDirection aStretchDirection, nsBoundingMetrics &aContainerSize, nsHTMLReflowMetrics &aDesiredStretchSize)
NS_IMETHOD Place (nsIRenderingContext &aRenderingContext, PRBool aPlaceOrigin, nsHTMLReflowMetrics &aDesiredSize)
NS_IMETHOD GetEmbellishData (nsEmbellishData &aEmbellishData)
NS_IMETHOD SetEmbellishData (const nsEmbellishData &aEmbellishData)
NS_IMETHOD GetPresentationData (nsPresentationData &aPresentationData)
NS_IMETHOD SetPresentationData (const nsPresentationData &aPresentationData)
NS_IMETHOD InheritAutomaticData (nsIFrame *aParent)
NS_IMETHOD TransmitAutomaticData ()
NS_IMETHOD UpdatePresentationData (PRInt32 aScriptLevelIncrement, PRUint32 aFlagsValues, PRUint32 aFlagsToUpdate)
NS_IMETHOD UpdatePresentationDataFromChildAt (PRInt32 aFirstIndex, PRInt32 aLastIndex, PRInt32 aScriptLevelIncrement, PRUint32 aFlagsValues, PRUint32 aFlagsToUpdate)
NS_IMETHOD ReResolveScriptStyle (PRInt32 aParentScriptLevel)

Static Public Member Functions

static void ResolveMathMLCharStyle (nsPresContext *aPresContext, nsIContent *aContent, nsStyleContext *aParenStyleContext, nsMathMLChar *aMathMLChar, PRBool aIsMutableChar)
static void GetEmbellishDataFrom (nsIFrame *aFrame, nsEmbellishData &aEmbellishData)
static void GetPresentationDataFrom (nsIFrame *aFrame, nsPresentationData &aPresentationData, PRBool aClimbTree=PR_TRUE)
static nsresult GetAttribute (nsIContent *aContent, nsIFrame *aMathMLmstyleFrame, nsIAtom *aAttributeAtom, nsString &aValue)
static PRBool ParseNumericValue (nsString &aString, nsCSSValue &aCSSValue)
static nscoord CalcLength (nsPresContext *aPresContext, nsStyleContext *aStyleContext, const nsCSSValue &aCSSValue)
static PRBool ParseNamedSpaceValue (nsIFrame *aMathMLmstyleFrame, nsString &aString, nsCSSValue &aCSSValue)
static eMathMLFrameType GetMathMLFrameTypeFor (nsIFrame *aFrame)
static void GetItalicCorrection (nsBoundingMetrics &aBoundingMetrics, nscoord &aItalicCorrection)
static void GetItalicCorrection (nsBoundingMetrics &aBoundingMetrics, nscoord &aLeftItalicCorrection, nscoord &aRightItalicCorrection)
static void GetSubDropFromChild (nsIFrame *aChild, nscoord &aSubDrop)
static void GetSupDropFromChild (nsIFrame *aChild, nscoord &aSupDrop)
static void GetSkewCorrectionFromChild (nsIFrame *aChild, nscoord &aSkewCorrection)
static void GetSubScriptShifts (nsIFontMetrics *fm, nscoord &aSubScriptShift1, nscoord &aSubScriptShift2)
static void GetSupScriptShifts (nsIFontMetrics *fm, nscoord &aSupScriptShift1, nscoord &aSupScriptShift2, nscoord &aSupScriptShift3)
static void GetSubDrop (nsIFontMetrics *fm, nscoord &aSubDrop)
static void GetSupDrop (nsIFontMetrics *fm, nscoord &aSupDrop)
static void GetNumeratorShifts (nsIFontMetrics *fm, nscoord &numShift1, nscoord &numShift2, nscoord &numShift3)
static void GetDenominatorShifts (nsIFontMetrics *fm, nscoord &denShift1, nscoord &denShift2)
static void GetEmHeight (nsIFontMetrics *fm, nscoord &emHeight)
static void GetAxisHeight (nsIFontMetrics *fm, nscoord &axisHeight)
static void GetBigOpSpacings (nsIFontMetrics *fm, nscoord &bigOpSpacing1, nscoord &bigOpSpacing2, nscoord &bigOpSpacing3, nscoord &bigOpSpacing4, nscoord &bigOpSpacing5)
static void GetRuleThickness (nsIFontMetrics *fm, nscoord &ruleThickness)
static void GetRuleThickness (nsIRenderingContext &aRenderingContext, nsIFontMetrics *aFontMetrics, nscoord &aRuleThickness)
static void GetAxisHeight (nsIRenderingContext &aRenderingContext, nsIFontMetrics *aFontMetrics, nscoord &aAxisHeight)
static PRInt32 MapAttributesIntoCSS (nsPresContext *aPresContext, nsIContent *aContent)
static PRInt32 MapAttributesIntoCSS (nsPresContext *aPresContext, nsIFrame *aFrame)

Protected Attributes

nsPresentationData mPresentationData
nsEmbellishData mEmbellishData
nsBoundingMetrics mBoundingMetrics
nsPoint mReference

Detailed Description

Definition at line 55 of file nsMathMLFrame.h.


Member Function Documentation

nscoord nsMathMLFrame::CalcLength ( nsPresContext aPresContext,
nsStyleContext aStyleContext,
const nsCSSValue aCSSValue 
) [static]

Definition at line 418 of file nsMathMLFrame.cpp.

{
  NS_ASSERTION(aCSSValue.IsLengthUnit(), "not a length unit");

  if (aCSSValue.IsFixedLengthUnit()) {
    return aCSSValue.GetLengthTwips();
  }

  nsCSSUnit unit = aCSSValue.GetUnit();

  if (eCSSUnit_Pixel == unit) {
    return NSFloatPixelsToTwips(aCSSValue.GetFloatValue(),
                                aPresContext->ScaledPixelsToTwips());
  }
  else if (eCSSUnit_EM == unit) {
    const nsStyleFont* font = aStyleContext->GetStyleFont();
    return NSToCoordRound(aCSSValue.GetFloatValue() * (float)font->mFont.size);
  }
  else if (eCSSUnit_XHeight == unit) {
    nscoord xHeight;
    const nsStyleFont* font = aStyleContext->GetStyleFont();
    nsCOMPtr<nsIFontMetrics> fm = aPresContext->GetMetricsFor(font->mFont);
    fm->GetXHeight(xHeight);
    return NSToCoordRound(aCSSValue.GetFloatValue() * (float)xHeight);
  }

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsMathMLFrame::GetAttribute ( nsIContent aContent,
nsIFrame aMathMLmstyleFrame,
nsIAtom aAttributeAtom,
nsString aValue 
) [static]

Definition at line 226 of file nsMathMLFrame.cpp.

{
  nsresult rv = NS_CONTENT_ATTR_NOT_THERE;

  // see if we can get the attribute from the content
  if (aContent) {
    rv = aContent->GetAttr(kNameSpaceID_None, aAttributeAtom, aValue);
  }

  if (NS_CONTENT_ATTR_NOT_THERE == rv) {
    // see if we can get the attribute from the mstyle frame
    if (aMathMLmstyleFrame) {
      nsIFrame* mstyleParent = aMathMLmstyleFrame->GetParent();

      nsPresentationData mstyleParentData;
      mstyleParentData.mstyle = nsnull;

      if (mstyleParent) {
        nsIMathMLFrame* mathMLFrame;
        mstyleParent->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame);
        if (mathMLFrame) {
          mathMLFrame->GetPresentationData(mstyleParentData);
        }
      }

      // recurse all the way up into the <mstyle> hierarchy
      rv = GetAttribute(aMathMLmstyleFrame->GetContent(),
                     mstyleParentData.mstyle, aAttributeAtom, aValue);
    }
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void nsMathMLFrame::GetAxisHeight ( nsIFontMetrics fm,
nscoord axisHeight 
) [inline, static]

Definition at line 385 of file nsMathMLFrame.h.

  {
    fm->GetXHeight (axisHeight);
    axisHeight = NSToCoordRound(250.000f/430.556f * axisHeight);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nsMathMLFrame::GetAxisHeight ( nsIRenderingContext aRenderingContext,
nsIFontMetrics aFontMetrics,
nscoord aAxisHeight 
) [static]

Definition at line 302 of file nsMathMLFrame.cpp.

{
  // get the bounding metrics of the minus sign, the rendering context
  // is assumed to have been set with the font of the current style context
#ifdef NS_DEBUG
  nsCOMPtr<nsIFontMetrics> currFontMetrics;
  aRenderingContext.GetFontMetrics(*getter_AddRefs(currFontMetrics));
  NS_ASSERTION(currFontMetrics->Font().Equals(aFontMetrics->Font()),
       "unexpected state");
#endif
  nscoord xHeight;
  aFontMetrics->GetXHeight(xHeight);
  PRUnichar minus = 0x2212; // not '-', but official Unicode minus sign
  nsBoundingMetrics bm;
  nsresult rv = aRenderingContext.GetBoundingMetrics(&minus, PRUint32(1), bm);
  if (NS_SUCCEEDED(rv)) {
    aAxisHeight = bm.ascent - (bm.ascent + bm.descent)/2;
  }
  if (NS_FAILED(rv) || aAxisHeight <= 0 || aAxisHeight >= xHeight) {
    // fall-back to the other version
    GetAxisHeight(aFontMetrics, aAxisHeight);
  }
}

Here is the call graph for this function:

static void nsMathMLFrame::GetBigOpSpacings ( nsIFontMetrics fm,
nscoord bigOpSpacing1,
nscoord bigOpSpacing2,
nscoord bigOpSpacing3,
nscoord bigOpSpacing4,
nscoord bigOpSpacing5 
) [inline, static]

Definition at line 393 of file nsMathMLFrame.h.

  {
    nscoord xHeight;
    fm->GetXHeight(xHeight);
    bigOpSpacing1 = NSToCoordRound(111.111f/430.556f * xHeight);
    bigOpSpacing2 = NSToCoordRound(166.667f/430.556f * xHeight);
    bigOpSpacing3 = NSToCoordRound(200.000f/430.556f * xHeight);
    bigOpSpacing4 = NSToCoordRound(600.000f/430.556f * xHeight);
    bigOpSpacing5 = NSToCoordRound(100.000f/430.556f * xHeight);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsMathMLFrame::GetBoundingMetrics ( nsBoundingMetrics &  aBoundingMetrics) [inline, virtual]

Implements nsIMathMLFrame.

Definition at line 75 of file nsMathMLFrame.h.

                                                          {
    aBoundingMetrics = mBoundingMetrics;
    return NS_OK;
  }
static void nsMathMLFrame::GetDenominatorShifts ( nsIFontMetrics fm,
nscoord denShift1,
nscoord denShift2 
) [inline, static]

Definition at line 362 of file nsMathMLFrame.h.

  {
    nscoord xHeight;
    fm->GetXHeight(xHeight);
    denShift1 = NSToCoordRound(685.951f/430.556f * xHeight);
    denShift2 = NSToCoordRound(344.841f/430.556f * xHeight);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsMathMLFrame::GetEmbellishData ( nsEmbellishData aEmbellishData) [inline, virtual]

Implements nsIMathMLFrame.

Definition at line 118 of file nsMathMLFrame.h.

                                                    {
    aEmbellishData = mEmbellishData;
    return NS_OK;
  }
void nsMathMLFrame::GetEmbellishDataFrom ( nsIFrame aFrame,
nsEmbellishData aEmbellishData 
) [static]

Definition at line 160 of file nsMathMLFrame.cpp.

{
  // initialize OUT params
  aEmbellishData.flags = 0;
  aEmbellishData.coreFrame = nsnull;
  aEmbellishData.direction = NS_STRETCH_DIRECTION_UNSUPPORTED;
  aEmbellishData.leftSpace = 0;
  aEmbellishData.rightSpace = 0;

  if (aFrame && aFrame->IsFrameOfType(nsIFrame::eMathML)) {
    nsIMathMLFrame* mathMLFrame;
    CallQueryInterface(aFrame, &mathMLFrame);
    if (mathMLFrame) {
      mathMLFrame->GetEmbellishData(aEmbellishData);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void nsMathMLFrame::GetEmHeight ( nsIFontMetrics fm,
nscoord emHeight 
) [inline, static]

Definition at line 373 of file nsMathMLFrame.h.

  {
#if 0 
    // should switch to this API in order to scale with changes of TextZoom
    fm->GetEmHeight(emHeight);
#else
    emHeight = NSToCoordRound(float(fm->Font().size));
#endif
  }

Here is the call graph for this function:

Here is the caller graph for this function:

static void nsMathMLFrame::GetItalicCorrection ( nsBoundingMetrics &  aBoundingMetrics,
nscoord aItalicCorrection 
) [inline, static]

Definition at line 248 of file nsMathMLFrame.h.

  {
    aItalicCorrection = aBoundingMetrics.rightBearing - aBoundingMetrics.width;
    if (0 > aItalicCorrection) {
      aItalicCorrection = 0;
    }
  }

Here is the caller graph for this function:

static void nsMathMLFrame::GetItalicCorrection ( nsBoundingMetrics &  aBoundingMetrics,
nscoord aLeftItalicCorrection,
nscoord aRightItalicCorrection 
) [inline, static]

Definition at line 258 of file nsMathMLFrame.h.

  {
    aRightItalicCorrection = aBoundingMetrics.rightBearing - aBoundingMetrics.width;
    if (0 > aRightItalicCorrection) {
      aRightItalicCorrection = 0;
    }
    aLeftItalicCorrection = -aBoundingMetrics.leftBearing;
    if (0 > aLeftItalicCorrection) {
      aLeftItalicCorrection = 0;
    }
  }

Implements nsIMathMLFrame.

Reimplemented in nsMathMLmfracFrame, nsMathMLmoFrame, and nsMathMLTokenFrame.

Definition at line 66 of file nsMathMLFrame.cpp.

{
  // see if it is an embellished operator (mapped to 'Op' in TeX)
  if (mEmbellishData.coreFrame)
    return GetMathMLFrameTypeFor(mEmbellishData.coreFrame);

  // if it has a prescribed base, fetch the type from there
  if (mPresentationData.baseFrame)
    return GetMathMLFrameTypeFor(mPresentationData.baseFrame);

  // everything else is treated as ordinary (mapped to 'Ord' in TeX)
  return eMathMLFrameType_Ordinary;  
}
static eMathMLFrameType nsMathMLFrame::GetMathMLFrameTypeFor ( nsIFrame aFrame) [inline, static]

Definition at line 235 of file nsMathMLFrame.h.

  {
    if (aFrame->IsFrameOfType(nsIFrame::eMathML)) {
      nsIMathMLFrame* mathMLFrame;
      CallQueryInterface(aFrame, &mathMLFrame);
      if (mathMLFrame)
        return mathMLFrame->GetMathMLFrameType();
    }
    return eMathMLFrameType_UNKNOWN;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

static void nsMathMLFrame::GetNumeratorShifts ( nsIFontMetrics fm,
nscoord numShift1,
nscoord numShift2,
nscoord numShift3 
) [inline, static]

Definition at line 349 of file nsMathMLFrame.h.

  {
    nscoord xHeight;
    fm->GetXHeight(xHeight);
    numShift1 = NSToCoordRound(676.508f/430.556f * xHeight);
    numShift2 = NSToCoordRound(393.732f/430.556f * xHeight);
    numShift3 = NSToCoordRound(443.731f/430.556f * xHeight);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsMathMLFrame::GetPresentationData ( nsPresentationData aPresentationData) [inline, virtual]

Implements nsIMathMLFrame.

Definition at line 130 of file nsMathMLFrame.h.

                                                             {
    aPresentationData = mPresentationData;
    return NS_OK;
  }

Here is the caller graph for this function:

void nsMathMLFrame::GetPresentationDataFrom ( nsIFrame aFrame,
nsPresentationData aPresentationData,
PRBool  aClimbTree = PR_TRUE 
) [static]

Definition at line 182 of file nsMathMLFrame.cpp.

{
  // initialize OUT params
  aPresentationData.flags = 0;
  aPresentationData.baseFrame = nsnull;
  aPresentationData.mstyle = nsnull;
  aPresentationData.scriptLevel = 0;

  nsIFrame* frame = aFrame;
  while (frame) {
    if (frame->IsFrameOfType(nsIFrame::eMathML)) {
      nsIMathMLFrame* mathMLFrame;
      CallQueryInterface(frame, &mathMLFrame);
      if (mathMLFrame) {
        mathMLFrame->GetPresentationData(aPresentationData);
        break;
      }
    }
    // stop if the caller doesn't want to lookup beyond the frame
    if (!aClimbTree) {
      break;
    }
    // stop if we reach the root <math> tag
    nsIContent* content = frame->GetContent();
    NS_ASSERTION(content, "dangling frame without a content node");
    if (!content)
      break;

    if (content->Tag() == nsMathMLAtoms::math) {
      const nsStyleDisplay* display = frame->GetStyleDisplay();
      if (display->mDisplay == NS_STYLE_DISPLAY_BLOCK) {
        aPresentationData.flags |= NS_MATHML_DISPLAYSTYLE;
      }
      break;
    }
    frame = frame->GetParent();
  }
  NS_ASSERTION(frame, "bad MathML markup - could not find the top <math> element");
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsMathMLFrame::GetReference ( nsPoint aReference) [inline, virtual]

Implements nsIMathMLFrame.

Definition at line 87 of file nsMathMLFrame.h.

                                    {
    aReference = mReference;
    return NS_OK;
  }
static void nsMathMLFrame::GetRuleThickness ( nsIFontMetrics fm,
nscoord ruleThickness 
) [inline, static]

Definition at line 410 of file nsMathMLFrame.h.

  {
    nscoord xHeight;
    fm->GetXHeight(xHeight);
    ruleThickness = NSToCoordRound(40.000f/430.556f * xHeight);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void nsMathMLFrame::GetRuleThickness ( nsIRenderingContext aRenderingContext,
nsIFontMetrics aFontMetrics,
nscoord aRuleThickness 
) [static]

Definition at line 263 of file nsMathMLFrame.cpp.

{
  // get the bounding metrics of the overbar char, the rendering context
  // is assumed to have been set with the font of the current style context
#ifdef NS_DEBUG
  nsCOMPtr<nsIFontMetrics> currFontMetrics;
  aRenderingContext.GetFontMetrics(*getter_AddRefs(currFontMetrics));
  NS_ASSERTION(currFontMetrics->Font().Equals(aFontMetrics->Font()),
      "unexpected state");
#endif
  nscoord xHeight;
  aFontMetrics->GetXHeight(xHeight);
  PRUnichar overBar = 0x00AF;
  nsBoundingMetrics bm;
  nsresult rv = aRenderingContext.GetBoundingMetrics(&overBar, PRUint32(1), bm);
  if (NS_SUCCEEDED(rv)) {
    aRuleThickness = bm.ascent + bm.descent;
  }
  if (NS_FAILED(rv) || aRuleThickness <= 0 || aRuleThickness >= xHeight) {
    // fall-back to the other version
    GetRuleThickness(aFontMetrics, aRuleThickness);
  }

#if 0
  nscoord oldRuleThickness;
  GetRuleThickness(aFontMetrics, oldRuleThickness);

  PRUnichar sqrt = 0xE063; // a sqrt glyph from TeX's CMEX font
  rv = aRenderingContext.GetBoundingMetrics(&sqrt, PRUint32(1), bm);
  nscoord sqrtrule = bm.ascent; // according to TeX, the ascent should be the rule

  printf("xheight:%4d rule:%4d oldrule:%4d  sqrtrule:%4d\n",
          xHeight, aRuleThickness, oldRuleThickness, sqrtrule);
#endif
}

Here is the call graph for this function:

static void nsMathMLFrame::GetSkewCorrectionFromChild ( nsIFrame aChild,
nscoord aSkewCorrection 
) [inline, static]

Definition at line 294 of file nsMathMLFrame.h.

  {
    // default is 0
    // individual classes should over-ride this method if necessary
    aSkewCorrection = 0;
  }
static void nsMathMLFrame::GetSubDrop ( nsIFontMetrics fm,
nscoord aSubDrop 
) [inline, static]

Definition at line 331 of file nsMathMLFrame.h.

  {
    nscoord xHeight;
    fm->GetXHeight(xHeight);
    aSubDrop = NSToCoordRound(50.000f/430.556f * xHeight);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

static void nsMathMLFrame::GetSubDropFromChild ( nsIFrame aChild,
nscoord aSubDrop 
) [inline, static]

Definition at line 274 of file nsMathMLFrame.h.

  {
    const nsStyleFont* font = aChild->GetStyleFont();
    nsCOMPtr<nsIFontMetrics> fm = aChild->GetPresContext()->GetMetricsFor(
                                                              font->mFont);
    GetSubDrop(fm, aSubDrop);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

static void nsMathMLFrame::GetSubScriptShifts ( nsIFontMetrics fm,
nscoord aSubScriptShift1,
nscoord aSubScriptShift2 
) [inline, static]

Definition at line 304 of file nsMathMLFrame.h.

  {
    nscoord xHeight;
    fm->GetXHeight(xHeight);
    aSubScriptShift1 = NSToCoordRound(150.000f/430.556f * xHeight);
    aSubScriptShift2 = NSToCoordRound(247.217f/430.556f * xHeight);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

static void nsMathMLFrame::GetSupDrop ( nsIFontMetrics fm,
nscoord aSupDrop 
) [inline, static]

Definition at line 340 of file nsMathMLFrame.h.

  {
    nscoord xHeight;
    fm->GetXHeight(xHeight);
    aSupDrop = NSToCoordRound(386.108f/430.556f * xHeight);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

static void nsMathMLFrame::GetSupDropFromChild ( nsIFrame aChild,
nscoord aSupDrop 
) [inline, static]

Definition at line 284 of file nsMathMLFrame.h.

  {
    const nsStyleFont* font = aChild->GetStyleFont();
    nsCOMPtr<nsIFontMetrics> fm = aChild->GetPresContext()->GetMetricsFor(
                                                              font->mFont);
    GetSupDrop(fm, aSupDrop);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

static void nsMathMLFrame::GetSupScriptShifts ( nsIFontMetrics fm,
nscoord aSupScriptShift1,
nscoord aSupScriptShift2,
nscoord aSupScriptShift3 
) [inline, static]

Definition at line 316 of file nsMathMLFrame.h.

  {
    nscoord xHeight;
    fm->GetXHeight(xHeight);
    aSupScriptShift1 = NSToCoordRound(412.892f/430.556f * xHeight);
    aSupScriptShift2 = NSToCoordRound(362.892f/430.556f * xHeight);
    aSupScriptShift3 = NSToCoordRound(288.889f/430.556f * xHeight);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsMathMLFrame::MapAttributesIntoCSS ( nsPresContext aPresContext,
nsIContent aContent 
) [static]

Definition at line 582 of file nsMathMLFrame.cpp.

{
  // normal case, quick return if there are no attributes
  NS_ASSERTION(aContent, "null arg");
  PRUint32 attrCount = 0;
  if (aContent)
    attrCount = aContent->GetAttrCount();
  if (!attrCount)
    return 0;

  // need to initialize here -- i.e., after registering nsMathMLAtoms
  static const nsCSSMapping
  kCSSMappingTable[] = {
    {kMathMLversion2, nsMathMLAtoms::mathcolor_,      "color:"},
    {kMathMLversion1, nsMathMLAtoms::color_,          "color:"},
    {kMathMLversion2, nsMathMLAtoms::mathsize_,       "font-size:"},
    {kMathMLversion1, nsMathMLAtoms::fontsize_,       "font-size:"},
    {kMathMLversion1, nsMathMLAtoms::fontfamily_,     "font-family:"},
    {kMathMLversion2, nsMathMLAtoms::mathbackground_, "background-color:"},
    {kMathMLversion1, nsMathMLAtoms::background_,     "background-color:"},
    {0, nsnull, nsnull}
  };

  nsCOMPtr<nsIDocument> doc;
  nsCOMPtr<nsIStyleSheet> sheet;
  nsCOMPtr<nsICSSStyleSheet> cssSheet;
  nsCOMPtr<nsIDOMCSSStyleSheet> domSheet;

  PRInt32 nameSpaceID;
  nsCOMPtr<nsIAtom> prefix;
  nsCOMPtr<nsIAtom> attrAtom;
  PRInt32 ruleCount = 0;
  for (PRUint32 i = 0; i < attrCount; ++i) {
    aContent->GetAttrNameAt(i, &nameSpaceID,
                            getter_AddRefs(attrAtom),
                            getter_AddRefs(prefix));

    // lookup the equivalent CSS property
    const nsCSSMapping* map = kCSSMappingTable;
    while (map->attrAtom && map->attrAtom != attrAtom)
      ++map;
    if (!map->attrAtom)
      continue;
    nsAutoString cssProperty(NS_ConvertASCIItoUCS2(map->cssProperty));

    nsAutoString attrValue;
    aContent->GetAttr(nameSpaceID, attrAtom, attrValue);
    if (attrValue.IsEmpty())
      continue;
    nsAutoString escapedAttrValue;
    nsStyleUtil::EscapeCSSString(attrValue, escapedAttrValue);

    // don't add rules that are already in mathml.css
    // (this will also clean up whitespace before units - see bug 125303)
    if (attrAtom == nsMathMLAtoms::fontsize_ || attrAtom == nsMathMLAtoms::mathsize_) {
      nsCSSValue cssValue;
      nsAutoString numericValue(attrValue);
      if (!ParseNumericValue(numericValue, cssValue))
        continue;
      // on exit, ParseNumericValue also returns a nicer string
      // in which the whitespace before the unit is cleaned up 
      cssProperty.Append(numericValue);
    }
    else
      cssProperty.Append(attrValue);

    nsAutoString attrName;
    attrAtom->ToString(attrName);

    // make a style rule that maps to the equivalent CSS property
    nsAutoString cssRule;
    cssRule.Assign(NS_LITERAL_STRING("[")  + attrName +
                   NS_LITERAL_STRING("='") + escapedAttrValue +
                   NS_LITERAL_STRING("']{") + cssProperty + NS_LITERAL_STRING("}"));

    if (!sheet) {
      // first time... we do this to defer the lookup up to the
      // point where we encounter attributes that actually matter
      doc = aContent->GetDocument();
      if (!doc) 
        return 0;
      GetMathMLAttributeStyleSheet(aPresContext, getter_AddRefs(sheet));
      if (!sheet)
        return 0;
      // by construction, these cannot be null at this point
      cssSheet = do_QueryInterface(sheet);
      domSheet = do_QueryInterface(sheet);
      NS_ASSERTION(cssSheet && domSheet, "unexpected null pointers");
      // we will keep the sheet orphan as we populate it. This way,
      // observers of the document won't be notified and we avoid any troubles
      // that may come from reconstructing the frame tree. Our rules only need
      // a re-resolve of style data and a reflow, not a reconstruct-all...
      sheet->SetOwningDocument(nsnull);
    }

    // check for duplicate, if a similar rule is already there, don't bother to add another one
    nsAutoString selector;
    selector.Assign(NS_LITERAL_STRING("*[") + attrName +
                    NS_LITERAL_STRING("=\"") + escapedAttrValue +
                    NS_LITERAL_STRING("\"]"));
    PRInt32 k, count;
    cssSheet->StyleRuleCount(count);
    for (k = 0; k < count; ++k) {
      nsAutoString tmpSelector;
      nsCOMPtr<nsICSSRule> tmpRule;
      cssSheet->GetStyleRuleAt(k, *getter_AddRefs(tmpRule));
      nsCOMPtr<nsICSSStyleRule> tmpStyleRule = do_QueryInterface(tmpRule);
      if (tmpStyleRule) {
        tmpStyleRule->GetSelectorText(tmpSelector);
        if (tmpSelector.Equals(selector)) {
          k = -1;
          break;
        }
      }
    }
    if (k >= 0) {
      // insert the rule (note: when the sheet already has @namespace and
      // friends, insert after them, e.g., at the end, otherwise it won't work)
      // For MathML 2, insert at the end to give it precedence
      PRInt32 pos = (map->compatibility == kMathMLversion2) ? count : 1;
      PRUint32 index;
      domSheet->InsertRule(cssRule, pos, &index);
      ++ruleCount;
    }
  }
  // restore the sheet to its owner
  if (sheet) {
    sheet->SetOwningDocument(doc);
  }

  return ruleCount;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsMathMLFrame::MapAttributesIntoCSS ( nsPresContext aPresContext,
nsIFrame aFrame 
) [static]

Definition at line 717 of file nsMathMLFrame.cpp.

{
  PRInt32 ruleCount = MapAttributesIntoCSS(aPresContext, aFrame->GetContent());
  if (!ruleCount)
    return 0;

  // now, re-resolve the style contexts in our subtree
  nsFrameManager *fm = aPresContext->FrameManager();
  nsStyleChangeList changeList;
  fm->ComputeStyleChangeFor(aFrame, &changeList, NS_STYLE_HINT_NONE);
#ifdef DEBUG
  // Use the parent frame to make sure we catch in-flows and such
  nsIFrame* parentFrame = aFrame->GetParent();
  fm->DebugVerifyStyleTree(parentFrame ? parentFrame : aFrame);
#endif

  return ruleCount;
}

Here is the call graph for this function:

Definition at line 62 of file nsMathMLFrame.h.

                                 {
    // not meaningfull for frames
    return 1;
  }

Definition at line 67 of file nsMathMLFrame.h.

                                  {
    // not meaningfull for frames
    return 1;
  }
PRBool nsMathMLFrame::ParseNamedSpaceValue ( nsIFrame aMathMLmstyleFrame,
nsString aString,
nsCSSValue aCSSValue 
) [static]

Definition at line 450 of file nsMathMLFrame.cpp.

{
  aCSSValue.Reset();
  aString.CompressWhitespace(); //  aString is not a const in this code...
  if (!aString.Length()) return PR_FALSE;

  // See if it is one of the 'namedspace' (ranging 1/18em...7/18em)
  PRInt32 i = 0;
  nsIAtom* namedspaceAtom = nsnull;
  if (aString.EqualsLiteral("veryverythinmathspace")) {
    i = 1;
    namedspaceAtom = nsMathMLAtoms::veryverythinmathspace_;
  }
  else if (aString.EqualsLiteral("verythinmathspace")) {
    i = 2;
    namedspaceAtom = nsMathMLAtoms::verythinmathspace_;
  }
  else if (aString.EqualsLiteral("thinmathspace")) {
    i = 3;
    namedspaceAtom = nsMathMLAtoms::thinmathspace_;
  }
  else if (aString.EqualsLiteral("mediummathspace")) {
    i = 4;
    namedspaceAtom = nsMathMLAtoms::mediummathspace_;
  }
  else if (aString.EqualsLiteral("thickmathspace")) {
    i = 5;
    namedspaceAtom = nsMathMLAtoms::thickmathspace_;
  }
  else if (aString.EqualsLiteral("verythickmathspace")) {
    i = 6;
    namedspaceAtom = nsMathMLAtoms::verythickmathspace_;
  }
  else if (aString.EqualsLiteral("veryverythickmathspace")) {
    i = 7;
    namedspaceAtom = nsMathMLAtoms::veryverythickmathspace_;
  }

  if (0 != i) {
    if (aMathMLmstyleFrame) {
      // see if there is a <mstyle> that has overriden the default value
      // GetAttribute() will recurse all the way up into the <mstyle> hierarchy
      nsAutoString value;
      if (NS_CONTENT_ATTR_HAS_VALUE ==
          GetAttribute(nsnull, aMathMLmstyleFrame, namedspaceAtom, value)) {
        if (ParseNumericValue(value, aCSSValue) &&
            aCSSValue.IsLengthUnit()) {
          return PR_TRUE;
        }
      }
    }

    // fall back to the default value
    aCSSValue.SetFloatValue(float(i)/float(18), eCSSUnit_EM);
    return PR_TRUE;
  }

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool nsMathMLFrame::ParseNumericValue ( nsString aString,
nsCSSValue aCSSValue 
) [static]

Definition at line 354 of file nsMathMLFrame.cpp.

{
  aCSSValue.Reset();
  aString.CompressWhitespace(); //  aString is not a const in this code...

  PRInt32 stringLength = aString.Length();
  if (!stringLength)
    return PR_FALSE;

  nsAutoString number, unit;

  // Gather up characters that make up the number
  PRBool gotDot = PR_FALSE;
  PRUnichar c;
  for (PRInt32 i = 0; i < stringLength; i++) {
    c = aString[i];
    if (gotDot && c == '.')
      return PR_FALSE;  // two dots encountered
    else if (c == '.')
      gotDot = PR_TRUE;
    else if (!nsCRT::IsAsciiDigit(c)) {
      aString.Right(unit, stringLength - i);
      unit.CompressWhitespace(); // some authors leave blanks before the unit
      break;
    }
    number.Append(c);
  }

  // on exit, also return a nicer string version of the value in case
  // the caller wants it (e.g., this removes whitespace before units)
  aString.Assign(number);
  aString.Append(unit);

  // Convert number to floating point
  PRInt32 errorCode;
  float floatValue = number.ToFloat(&errorCode);
  if (errorCode)
    return PR_FALSE;

  nsCSSUnit cssUnit;
  if (unit.IsEmpty()) {
    cssUnit = eCSSUnit_Number; // no explicit unit, this is a number that will act as a multiplier
  }
  else if (unit.EqualsLiteral("%")) {
    aCSSValue.SetPercentValue(floatValue / 100.0f);
    return PR_TRUE;
  }
  else if (unit.EqualsLiteral("em")) cssUnit = eCSSUnit_EM;
  else if (unit.EqualsLiteral("ex")) cssUnit = eCSSUnit_XHeight;
  else if (unit.EqualsLiteral("px")) cssUnit = eCSSUnit_Pixel;
  else if (unit.EqualsLiteral("in")) cssUnit = eCSSUnit_Inch;
  else if (unit.EqualsLiteral("cm")) cssUnit = eCSSUnit_Centimeter;
  else if (unit.EqualsLiteral("mm")) cssUnit = eCSSUnit_Millimeter;
  else if (unit.EqualsLiteral("pt")) cssUnit = eCSSUnit_Point;
  else if (unit.EqualsLiteral("pc")) cssUnit = eCSSUnit_Pica;
  else // unexpected unit
    return PR_FALSE;

  aCSSValue.SetFloatValue(floatValue, cssUnit);
  return PR_TRUE;
}

Here is the caller graph for this function:

NS_IMETHOD nsMathMLFrame::Place ( nsIRenderingContext aRenderingContext,
PRBool  aPlaceOrigin,
nsHTMLReflowMetrics aDesiredSize 
) [inline, virtual]
NS_IMETHOD nsMathMLFrame::QueryInterface ( REFNSIID  aIID,
void **  aInstancePtr 
)
NS_IMETHOD nsMathMLFrame::ReResolveScriptStyle ( PRInt32  aParentScriptLevel) [inline, virtual]
void nsMathMLFrame::ResolveMathMLCharStyle ( nsPresContext aPresContext,
nsIContent aContent,
nsStyleContext aParenStyleContext,
nsMathMLChar aMathMLChar,
PRBool  aIsMutableChar 
) [static]

Definition at line 142 of file nsMathMLFrame.cpp.

{
  nsIAtom* pseudoStyle = (aIsMutableChar) ?
    nsCSSAnonBoxes::mozMathStretchy :
    nsCSSAnonBoxes::mozMathAnonymous; // savings
  nsRefPtr<nsStyleContext> newStyleContext;
  newStyleContext = aPresContext->StyleSet()->
    ResolvePseudoStyleFor(aContent, pseudoStyle, aParentStyleContext);

  if (newStyleContext)
    aMathMLChar->SetStyleContext(newStyleContext);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD nsMathMLFrame::SetBoundingMetrics ( const nsBoundingMetrics &  aBoundingMetrics) [inline, virtual]

Implements nsIMathMLFrame.

Definition at line 81 of file nsMathMLFrame.h.

                                                                {
    mBoundingMetrics = aBoundingMetrics;
    return NS_OK;
  }

Here is the caller graph for this function:

NS_IMETHOD nsMathMLFrame::SetEmbellishData ( const nsEmbellishData aEmbellishData) [inline, virtual]

Implements nsIMathMLFrame.

Definition at line 124 of file nsMathMLFrame.h.

                                                          {
    mEmbellishData = aEmbellishData;
    return NS_OK;
  }
NS_IMETHOD nsMathMLFrame::SetPresentationData ( const nsPresentationData aPresentationData) [inline, virtual]

Implements nsIMathMLFrame.

Definition at line 136 of file nsMathMLFrame.h.

                                                                   {
    mPresentationData = aPresentationData;
    return NS_OK;
  }
NS_IMETHOD nsMathMLFrame::SetReference ( const nsPoint aReference) [inline, virtual]

Implements nsIMathMLFrame.

Definition at line 93 of file nsMathMLFrame.h.

                                          {
    mReference = aReference;
    return NS_OK;
  }

Here is the caller graph for this function:

NS_IMETHOD nsMathMLFrame::Stretch ( nsIRenderingContext aRenderingContext,
nsStretchDirection  aStretchDirection,
nsBoundingMetrics &  aContainerSize,
nsHTMLReflowMetrics aDesiredStretchSize 
) [inline, virtual]

Implements nsIMathMLFrame.

Reimplemented in nsMathMLmoFrame, and nsMathMLContainerFrame.

Definition at line 101 of file nsMathMLFrame.h.

  {
    return NS_OK;
  }
NS_IMETHODIMP nsMathMLFrame::UpdatePresentationData ( PRInt32  aScriptLevelIncrement,
PRUint32  aFlagsValues,
PRUint32  aFlagsToUpdate 
) [virtual]

Implements nsIMathMLFrame.

Reimplemented in nsMathMLmfracFrame, nsMathMLmoverFrame, nsMathMLmstyleFrame, nsMathMLmunderFrame, and nsMathMLmunderoverFrame.

Definition at line 111 of file nsMathMLFrame.cpp.

{
  mPresentationData.scriptLevel += aScriptLevelIncrement;
  // update flags that are relevant to this call
  if (NS_MATHML_IS_DISPLAYSTYLE(aFlagsToUpdate)) {
    // updating the displaystyle flag is allowed
    if (NS_MATHML_IS_DISPLAYSTYLE(aFlagsValues)) {
      mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE;
    }
    else {
      mPresentationData.flags &= ~NS_MATHML_DISPLAYSTYLE;
    }
  }
  if (NS_MATHML_IS_COMPRESSED(aFlagsToUpdate)) {
    // updating the compression flag is allowed
    if (NS_MATHML_IS_COMPRESSED(aFlagsValues)) {
      // 'compressed' means 'prime' style in App. G, TeXbook
      mPresentationData.flags |= NS_MATHML_COMPRESSED;
    }
    // no else. the flag is sticky. it retains its value once it is set
  }
  return NS_OK;
}
NS_IMETHOD nsMathMLFrame::UpdatePresentationDataFromChildAt ( PRInt32  aFirstIndex,
PRInt32  aLastIndex,
PRInt32  aScriptLevelIncrement,
PRUint32  aFlagsValues,
PRUint32  aFlagsToUpdate 
) [inline, virtual]

Member Data Documentation

nsBoundingMetrics nsMathMLFrame::mBoundingMetrics [protected]

Definition at line 449 of file nsMathMLFrame.h.

Definition at line 446 of file nsMathMLFrame.h.

Definition at line 443 of file nsMathMLFrame.h.

Definition at line 452 of file nsMathMLFrame.h.


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