Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
nsRenderingContextImpl.cpp File Reference
#include "nsCOMPtr.h"
#include "nsRenderingContextImpl.h"
#include "nsIDeviceContext.h"
#include "nsIImage.h"
#include "nsTransform2D.h"
#include "nsIRegion.h"
#include "nsIFontMetrics.h"
#include "nsUnicharUtils.h"
#include <stdlib.h>
#include "imgIContainer.h"
#include "gfxIImageFrame.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"

Go to the source code of this file.

Defines

#define MAX_GFX_TEXT_BUF_SIZE   8000

Functions

static PRInt32 GetMaxChunkLength (nsRenderingContextImpl *aContext)
static PRInt32 FindSafeLength (nsRenderingContextImpl *aContext, const PRUnichar *aString, PRUint32 aLength, PRUint32 aMaxChunkLength)
static PRInt32 FindSafeLength (nsRenderingContextImpl *aContext, const char *aString, PRUint32 aLength, PRUint32 aMaxChunkLength)

Define Documentation

Definition at line 485 of file nsRenderingContextImpl.cpp.


Function Documentation

static PRInt32 FindSafeLength ( nsRenderingContextImpl aContext,
const PRUnichar aString,
PRUint32  aLength,
PRUint32  aMaxChunkLength 
) [static]

Definition at line 492 of file nsRenderingContextImpl.cpp.

{
  if (aLength <= aMaxChunkLength)
    return aLength;
  
  PRUint8 buffer[MAX_GFX_TEXT_BUF_SIZE + 1];
  // Fill in the cluster hint information, if it's available.
  PRUint32 clusterHint;
  aContext->GetHints(clusterHint);
  clusterHint &= NS_RENDERING_HINT_TEXT_CLUSTERS;

  PRInt32 len = aMaxChunkLength;

  if (clusterHint) {
    nsresult rv =
      aContext->GetClusterInfo(aString, aMaxChunkLength + 1, buffer);
    if (NS_FAILED(rv))
      return len;
  }

  // Ensure that we don't break inside a cluster or inside a surrogate pair
  while (len > 0 &&
         (IS_LOW_SURROGATE(aString[len]) || (clusterHint && !buffer[len]))) {
    len--;
  }
  if (len == 0) {
    // We don't want our caller to go into an infinite loop, so don't return
    // zero. It's hard to imagine how we could actually get here unless there
    // are languages that allow clusters of arbitrary size. If there are and
    // someone feeds us a 500+ character cluster, too bad.
    return aMaxChunkLength;
  }
  return len;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRInt32 FindSafeLength ( nsRenderingContextImpl aContext,
const char *  aString,
PRUint32  aLength,
PRUint32  aMaxChunkLength 
) [static]

Definition at line 529 of file nsRenderingContextImpl.cpp.

{
  // Since it's ASCII, we don't need to worry about clusters or RTL
  return PR_MIN(aLength, aMaxChunkLength);
}
static PRInt32 GetMaxChunkLength ( nsRenderingContextImpl aContext) [static]

Definition at line 486 of file nsRenderingContextImpl.cpp.

{
  PRInt32 len = aContext->GetMaxStringLength();
  return PR_MIN(len, MAX_GFX_TEXT_BUF_SIZE);
}

Here is the call graph for this function:

Here is the caller graph for this function: