Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
nsMathMLContainerFrame.cpp File Reference
#include "nsCOMPtr.h"
#include "nsHTMLParts.h"
#include "nsFrame.h"
#include "nsPresContext.h"
#include "nsIPresShell.h"
#include "nsCSSAnonBoxes.h"
#include "nsUnitConversion.h"
#include "nsStyleContext.h"
#include "nsStyleConsts.h"
#include "nsINameSpaceManager.h"
#include "nsIRenderingContext.h"
#include "nsIFontMetrics.h"
#include "nsIDOMText.h"
#include "nsITextContent.h"
#include "nsIDOMMutationEvent.h"
#include "nsFrameManager.h"
#include "nsStyleChangeList.h"
#include "nsMathMLAtoms.h"
#include "nsMathMLParts.h"
#include "nsMathMLChar.h"
#include "nsMathMLContainerFrame.h"
#include "nsAutoPtr.h"
#include "nsStyleSet.h"

Go to the source code of this file.

Defines

#define GET_INTERSPACE(scriptlevel_, frametype1_, frametype2_, space_)

Functions

 NS_DEFINE_CID (kInlineFrameCID, NS_INLINE_FRAME_CID)
static nscoord GetInterFrameSpacing (PRInt32 aScriptLevel, eMathMLFrameType aFirstFrameType, eMathMLFrameType aSecondFrameType, eMathMLFrameType *aFromFrameType, PRInt32 *aCarrySpace)
static nscoord GetInterFrameSpacingFor (PRInt32 aScriptLevel, nsIFrame *aParentFrame, nsIFrame *aChildFrame)
nsresult NS_NewMathMLmathBlockFrame (nsIPresShell *aPresShell, nsIFrame **aNewFrame)
nsresult NS_NewMathMLmathInlineFrame (nsIPresShell *aPresShell, nsIFrame **aNewFrame)

Variables

static PRInt32 kInterFrameSpacingTable [eMathMLFrameType_COUNT][eMathMLFrameType_COUNT]

Define Documentation

#define GET_INTERSPACE (   scriptlevel_,
  frametype1_,
  frametype2_,
  space_ 
)
Value:
/* no space if there is a frame that we know nothing about */        \
   if (frametype1_ == eMathMLFrameType_UNKNOWN ||                       \
       frametype2_ == eMathMLFrameType_UNKNOWN)                         \
    space_ = 0;                                                         \
  else {                                                                \
    space_ = kInterFrameSpacingTable[frametype1_][frametype2_];         \
    space_ = (scriptlevel_ > 0 && (space_ & 0xF0))                      \
      ? 0 /* spacing is disabled */                                     \
      : space_ & 0x0F;                                                  \
  }                                                                     \

Definition at line 1200 of file nsMathMLContainerFrame.cpp.


Function Documentation

static nscoord GetInterFrameSpacing ( PRInt32  aScriptLevel,
eMathMLFrameType  aFirstFrameType,
eMathMLFrameType  aSecondFrameType,
eMathMLFrameType aFromFrameType,
PRInt32 aCarrySpace 
) [static]

Definition at line 1223 of file nsMathMLContainerFrame.cpp.

{
  eMathMLFrameType firstType = aFirstFrameType;
  eMathMLFrameType secondType = aSecondFrameType;

  PRInt32 space;
  GET_INTERSPACE(aScriptLevel, firstType, secondType, space);

  // feedback control to avoid the inter-space to be added when not necessary
  if (secondType == eMathMLFrameType_OperatorInvisible) {
    // see if we should start to carry the space forward until we
    // encounter a visible frame
    if (*aFromFrameType == eMathMLFrameType_UNKNOWN) {
      *aFromFrameType = firstType;
      *aCarrySpace = space;
    }
    // keep carrying *aCarrySpace forward, while returning 0 for this stage
    space = 0;
  }
  else if (*aFromFrameType != eMathMLFrameType_UNKNOWN) {
    // no carry-forward anymore, get the real inter-space between
    // the two frames of interest

    firstType = *aFromFrameType;

    // But... the invisible operator that we encountered earlier could
    // be sitting between italic and upright identifiers, e.g.,
    //
    // 1. <mi>sin</mi> <mo>&ApplyFunction;</mo> <mi>x</mi>
    // 2. <mi>x</mi> <mo>&InvisibileTime;</mo> <mi>sin</mi>
    //
    // the trick to get the inter-space in either situation
    // is to promote "<mi>sin</mi><mo>&ApplyFunction;</mo>" and
    // "<mo>&InvisibileTime;</mo><mi>sin</mi>" to user-defined operators...
    if (firstType == eMathMLFrameType_UprightIdentifier) {
      firstType = eMathMLFrameType_OperatorUserDefined;
    }
    else if (secondType == eMathMLFrameType_UprightIdentifier) {
      secondType = eMathMLFrameType_OperatorUserDefined;
    }

    GET_INTERSPACE(aScriptLevel, firstType, secondType, space);

    // Now, we have two values: the computed space and the space that
    // has been carried forward until now. Which value do we pick?
    // If the second type is an operator (e.g., fence), it already has
    // built-in lspace & rspace, so we let them win. Otherwise we pick
    // the max between the two values that we have.
    if (secondType != eMathMLFrameType_OperatorOrdinary &&
        space < *aCarrySpace)
      space = *aCarrySpace;

    // reset everything now that the carry-forward is done
    *aFromFrameType = eMathMLFrameType_UNKNOWN;
    *aCarrySpace = 0;
  }

  return space;
}

Here is the caller graph for this function:

static nscoord GetInterFrameSpacingFor ( PRInt32  aScriptLevel,
nsIFrame aParentFrame,
nsIFrame aChildFrame 
) [static]

Definition at line 1404 of file nsMathMLContainerFrame.cpp.

{
  nsIFrame* childFrame = aParentFrame->GetFirstChild(nsnull);
  if (!childFrame || aChildFrame == childFrame)
    return 0;

  PRInt32 carrySpace = 0;
  eMathMLFrameType fromFrameType = eMathMLFrameType_UNKNOWN;
  eMathMLFrameType prevFrameType = eMathMLFrameType_UNKNOWN;
  eMathMLFrameType childFrameType = nsMathMLFrame::GetMathMLFrameTypeFor(childFrame);
  childFrame = childFrame->GetNextSibling();
  while (childFrame) {
    prevFrameType = childFrameType;
    childFrameType = nsMathMLFrame::GetMathMLFrameTypeFor(childFrame);
    nscoord space = GetInterFrameSpacing(aScriptLevel,
      prevFrameType, childFrameType, &fromFrameType, &carrySpace);
    if (aChildFrame == childFrame) {
      // get thinspace
      nsStyleContext* parentContext = aParentFrame->GetStyleContext();
      const nsStyleFont* font = parentContext->GetStyleFont();
      nscoord thinSpace = NSToCoordRound(float(font->mFont.size)*float(3) / float(18));
      // we are done
      return space * thinSpace;
    }
    childFrame = childFrame->GetNextSibling();
  }

  NS_NOTREACHED("child not in the childlist of its parent");
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_DEFINE_CID ( kInlineFrameCID  ,
NS_INLINE_FRAME_CID   
)
nsresult NS_NewMathMLmathBlockFrame ( nsIPresShell aPresShell,
nsIFrame **  aNewFrame 
)

Definition at line 1476 of file nsMathMLContainerFrame.cpp.

{
  NS_PRECONDITION(aNewFrame, "null OUT ptr");
  if (nsnull == aNewFrame) {
    return NS_ERROR_NULL_POINTER;
  }
  nsMathMLmathBlockFrame* it = new (aPresShell) nsMathMLmathBlockFrame;
  if (nsnull == it) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  *aNewFrame = it;
  return NS_OK;
}

Here is the caller graph for this function:

nsresult NS_NewMathMLmathInlineFrame ( nsIPresShell aPresShell,
nsIFrame **  aNewFrame 
)

Definition at line 1493 of file nsMathMLContainerFrame.cpp.

{
  NS_PRECONDITION(aNewFrame, "null OUT ptr");
  if (nsnull == aNewFrame) {
    return NS_ERROR_NULL_POINTER;
  }
  nsMathMLmathInlineFrame* it = new (aPresShell) nsMathMLmathInlineFrame;
  if (nsnull == it) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  *aNewFrame = it;
  return NS_OK;
}

Here is the caller graph for this function:


Variable Documentation

Initial value:
{
  
  
  

  
     {0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00},
     {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
     {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
     {0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01},
     {0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01},
    {0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01},
   {0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01}
}

Definition at line 1184 of file nsMathMLContainerFrame.cpp.