Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions
nsTextFrame.cpp File Reference
#include "nsCOMPtr.h"
#include "nsHTMLParts.h"
#include "nsCRT.h"
#include "nsSplittableFrame.h"
#include "nsLineLayout.h"
#include "nsString.h"
#include "nsUnicharUtils.h"
#include "nsPresContext.h"
#include "nsIContent.h"
#include "nsStyleConsts.h"
#include "nsStyleContext.h"
#include "nsCoord.h"
#include "nsIFontMetrics.h"
#include "nsIRenderingContext.h"
#include "nsIPresShell.h"
#include "nsIView.h"
#include "nsIViewManager.h"
#include "nsITimer.h"
#include "prtime.h"
#include "nsVoidArray.h"
#include "prprf.h"
#include "nsIDOMText.h"
#include "nsIDocument.h"
#include "nsIDeviceContext.h"
#include "nsICaret.h"
#include "nsCSSPseudoElements.h"
#include "nsILineBreaker.h"
#include "nsIWordBreaker.h"
#include "nsCompatibility.h"
#include "nsCSSColorUtils.h"
#include "nsITextContent.h"
#include "nsTextFragment.h"
#include "nsTextTransformer.h"
#include "nsHTMLAtoms.h"
#include "nsLayoutAtoms.h"
#include "nsIFrameSelection.h"
#include "nsISelection.h"
#include "nsIDOMRange.h"
#include "nsILookAndFeel.h"
#include "nsCSSRendering.h"
#include "nsContentUtils.h"
#include "nsILineIterator.h"
#include "nsCompressedCharMap.h"
#include "nsIServiceManager.h"
#include "nsGUIEvent.h"
#include "nsAutoPtr.h"
#include "nsStyleSet.h"
#include "nsBidiFrames.h"
#include "nsBidiPresUtils.h"
#include "nsBidiUtils.h"
#include "punct_marks.ccmap"

Go to the source code of this file.

Classes

struct  nsAutoIndexBuffer
struct  nsAutoPRUint8Buffer
class  nsBlinkTimer
struct  nsBlinkTimer::FrameData
class  nsTextFrame
struct  nsTextFrame::TextStyle
struct  nsTextFrame::TextPaintStyle
struct  nsTextFrame::TextReflowData
class  nsContinuingTextFrame
class  DrawSelectionIterator
struct  SegmentData
struct  TextRun

Defines

#define kSZLIG   0x00DF
#define TEXT_BUF_SIZE   100
#define TEXT_SKIP_LEADING_WS   0x01000000
#define TEXT_HAS_MULTIBYTE   0x02000000
#define TEXT_IN_WORD   0x04000000
#define TEXT_FIRST_LETTER   0x08000000
#define TEXT_WAS_TRANSFORMED   0x10000000
#define TEXT_REFLOW_FLAGS   0x1F000000
#define TEXT_TRIMMED_WS   0x20000000
#define TEXT_OPTIMIZE_RESIZE   0x40000000
#define TEXT_BLINK_ON   0x80000000
#define TEXT_IS_ONLY_WHITESPACE   0x00100000
#define TEXT_ISNOT_ONLY_WHITESPACE   0x00200000
#define TEXT_WHITESPACE_FLAGS   0x00300000
#define TEXT_IS_END_OF_LINE   0x00400000
#define DEBUG_VERIFY_NOT_DIRTY(state)
#define IME_RAW_COLOR   NS_RGB(198,33,66)
#define IME_CONVERTED_COLOR   NS_RGB(255,198,198)
#define TEXT_MAX_NUM_SEGMENTS   65
#define IsPunctuationMark(ch)   (CCMAP_HAS_CHAR(gPuncCharsCCMap, ch))

Functions

PRBool CanDarken (nsPresContext *aPresContext)
nscolor EnsureDifferentColors (nscolor colorA, nscolor colorB)
nsresult NS_NewTextFrame (nsIPresShell *aPresShell, nsIFrame **aNewFrame)
nsresult NS_NewContinuingTextFrame (nsIPresShell *aPresShell, nsIFrame **aNewFrame)
PRBool IsEndOfLine (nsFrameState aState)
PRBool BinarySearchForPosition (nsIRenderingContext *aRendContext, const PRUnichar *aText, PRInt32 aBaseWidth, PRInt32 aBaseInx, PRInt32 aStartInx, PRInt32 aEndInx, PRInt32 aCursorPos, PRInt32 &aIndex, PRInt32 &aTextWidth)
void ForceDrawFrame (nsFrame *aFrame)
static void TransformTextToUnicode (char *aText, PRInt32 aNumChars)
 DEFINE_CCMAP (gPuncCharsCCMap, const)
static void RevertSpacesToNBSP (PRUnichar *aBuffer, PRInt32 aWordLen)

Define Documentation

Definition at line 1456 of file nsTextFrame.cpp.

#define IME_CONVERTED_COLOR   NS_RGB(255,198,198)

Definition at line 2015 of file nsTextFrame.cpp.

#define IME_RAW_COLOR   NS_RGB(198,33,66)

Definition at line 2014 of file nsTextFrame.cpp.

#define IsPunctuationMark (   ch)    (CCMAP_HAS_CHAR(gPuncCharsCCMap, ch))

Definition at line 5167 of file nsTextFrame.cpp.

#define kSZLIG   0x00DF

Definition at line 125 of file nsTextFrame.cpp.

#define TEXT_BLINK_ON   0x80000000

Definition at line 1432 of file nsTextFrame.cpp.

#define TEXT_BUF_SIZE   100

Definition at line 128 of file nsTextFrame.cpp.

#define TEXT_FIRST_LETTER   0x08000000

Definition at line 1422 of file nsTextFrame.cpp.

#define TEXT_HAS_MULTIBYTE   0x02000000

Definition at line 1418 of file nsTextFrame.cpp.

#define TEXT_IN_WORD   0x04000000

Definition at line 1419 of file nsTextFrame.cpp.

#define TEXT_IS_END_OF_LINE   0x00400000

Definition at line 1440 of file nsTextFrame.cpp.

#define TEXT_IS_ONLY_WHITESPACE   0x00100000

Definition at line 1434 of file nsTextFrame.cpp.

Definition at line 1436 of file nsTextFrame.cpp.

Definition at line 5064 of file nsTextFrame.cpp.

#define TEXT_OPTIMIZE_RESIZE   0x40000000

Definition at line 1430 of file nsTextFrame.cpp.

#define TEXT_REFLOW_FLAGS   0x1F000000

Definition at line 1426 of file nsTextFrame.cpp.

#define TEXT_SKIP_LEADING_WS   0x01000000

Definition at line 1417 of file nsTextFrame.cpp.

#define TEXT_TRIMMED_WS   0x20000000

Definition at line 1428 of file nsTextFrame.cpp.

#define TEXT_WAS_TRANSFORMED   0x10000000

Definition at line 1423 of file nsTextFrame.cpp.

#define TEXT_WHITESPACE_FLAGS   0x00300000

Definition at line 1438 of file nsTextFrame.cpp.


Function Documentation

PRBool BinarySearchForPosition ( nsIRenderingContext aRendContext,
const PRUnichar aText,
PRInt32  aBaseWidth,
PRInt32  aBaseInx,
PRInt32  aStartInx,
PRInt32  aEndInx,
PRInt32  aCursorPos,
PRInt32 aIndex,
PRInt32 aTextWidth 
)

Definition at line 3814 of file nsTextFrame.cpp.

{
  PRInt32 range = aEndInx - aStartInx;
  if ((range == 1) || (range == 2 && IS_HIGH_SURROGATE(aText[aStartInx]))) {
    aIndex   = aStartInx + aBaseInx;
    aRendContext->GetWidth(aText, aIndex, aTextWidth);
    return PR_TRUE;
  }

  PRInt32 inx = aStartInx + (range / 2);

  // Make sure we don't leave a dangling low surrogate
  if (IS_HIGH_SURROGATE(aText[inx-1]))
    inx++;

  PRInt32 textWidth = 0;
  aRendContext->GetWidth(aText, inx, textWidth);

  PRInt32 fullWidth = aBaseWidth + textWidth;
  if (fullWidth == aCursorPos) {
    aTextWidth = textWidth;
    aIndex = inx;
    return PR_TRUE;
  } else if (aCursorPos < fullWidth) {
    aTextWidth = aBaseWidth;
    if (BinarySearchForPosition(aRendContext, aText, aBaseWidth, aBaseInx, aStartInx, inx, aCursorPos, aIndex, aTextWidth)) {
      return PR_TRUE;
    }
  } else {
    aTextWidth = fullWidth;
    if (BinarySearchForPosition(aRendContext, aText, aBaseWidth, aBaseInx, inx, aEndInx, aCursorPos, aIndex, aTextWidth)) {
      return PR_TRUE;
    }
  }
  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool CanDarken ( nsPresContext aPresContext) [inline]

Definition at line 134 of file nsTextFrame.cpp.

{
  PRBool darken;

  if (aPresContext->GetBackgroundColorDraw()) {
    darken = PR_FALSE;
  } else {
    if (aPresContext->GetBackgroundImageDraw()) {
      darken = PR_FALSE;
    } else {
      darken = PR_TRUE;
    }
  }

  return darken;
}

Here is the call graph for this function:

Here is the caller graph for this function:

DEFINE_CCMAP ( gPuncCharsCCMap  ,
const   
)
nscolor EnsureDifferentColors ( nscolor  colorA,
nscolor  colorB 
) [inline]

Definition at line 1035 of file nsTextFrame.cpp.

{
    if (colorA == colorB)
    {
      nscolor res;
      res = NS_RGB(NS_GET_R(colorA) ^ 0xff,
                   NS_GET_G(colorA) ^ 0xff,
                   NS_GET_B(colorA) ^ 0xff);
      return res;
    }
    return colorA;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ForceDrawFrame ( nsFrame aFrame)
PRBool IsEndOfLine ( nsFrameState  aState) [inline]

Definition at line 1744 of file nsTextFrame.cpp.

{
  return (aState & TEXT_IS_END_OF_LINE) ? PR_TRUE : PR_FALSE;
}

Here is the caller graph for this function:

nsresult NS_NewContinuingTextFrame ( nsIPresShell aPresShell,
nsIFrame **  aNewFrame 
)

Definition at line 1475 of file nsTextFrame.cpp.

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

Here is the caller graph for this function:

nsresult NS_NewTextFrame ( nsIPresShell aPresShell,
nsIFrame **  aNewFrame 
)

Definition at line 1460 of file nsTextFrame.cpp.

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

Here is the caller graph for this function:

static void RevertSpacesToNBSP ( PRUnichar aBuffer,
PRInt32  aWordLen 
) [static]

Definition at line 6229 of file nsTextFrame.cpp.

{
  PRUnichar* end = aBuffer + aWordLen;
  for (; aBuffer < end; aBuffer++) {
    PRUnichar ch = *aBuffer;
    if (ch == ' ') {
      *aBuffer = CH_NBSP;
    }
  }
}

Here is the caller graph for this function:

static void TransformTextToUnicode ( char *  aText,
PRInt32  aNumChars 
) [static]

Definition at line 5127 of file nsTextFrame.cpp.

{
  // Go backwards over the characters and convert them.
  unsigned char*  cp1 = (unsigned char*)aText + aNumChars - 1;
  PRUnichar*      cp2 = (PRUnichar*)aText + (aNumChars - 1);
  
  while (aNumChars-- > 0) {
    // XXX: If you crash here then you may see the issue described
    // in http://bugzilla.mozilla.org/show_bug.cgi?id=36146#c44
    *cp2-- = PRUnichar(*cp1--);
  }
}

Here is the caller graph for this function: