Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
BrowserView.cpp File Reference
#include "stdafx.h"
#include "MfcEmbed.h"
#include "BrowserView.h"
#include "BrowserImpl.h"
#include "BrowserFrm.h"
#include "Dialogs.h"
#include "CPageSetupPropSheet.h"
#include "nsIIOService.h"
#include "nsIWidget.h"
#include "nsServiceManagerUtils.h"
#include "nsComponentManagerUtils.h"
#include "nsMemory.h"
#include "nsXPCOM.h"

Go to the source code of this file.

Functions

static nsresult NewURI (nsIURI **result, const nsAString &spec)
static void ReplaceChar (nsAString &str, char oldChar, char newChar)
static void StripChars (nsAString &str, const char *chars)
static void StripChars (nsACString &str, const char *chars)
static void CompressWhitespace (nsAString &str)

Variables

static const char * kWhitespace = "\b\t\r\n "
static UINT WM_FINDMSG = ::RegisterWindowMessage(FINDMSGSTRING)

Function Documentation

static void CompressWhitespace ( nsAString &  str) [static]

Definition at line 150 of file BrowserView.cpp.

{
  const PRUnichar *p;
  PRInt32 i, len = (PRInt32) NS_StringGetData(str, &p);

  // trim leading whitespace

  for (i=0; i<len; ++i)
  {
    if (!strchr(kWhitespace, (char) p[i]))
      break;
  }

  if (i>0)
  {
    NS_StringCutData(str, 0, i);
    len = (PRInt32) NS_StringGetData(str, &p);
  }

  // trim trailing whitespace

  for (i=len-1; i>=0; --i)
  {
    if (!strchr(kWhitespace, (char) p[i]))
      break;
  }

  if (++i < len)
    NS_StringCutData(str, i, len - i);
}

Here is the call graph for this function:

static nsresult NewURI ( nsIURI **  result,
const nsAString &  spec 
) [static]

Definition at line 74 of file BrowserView.cpp.

{
  nsEmbedCString specUtf8;
  NS_UTF16ToCString(spec, NS_CSTRING_ENCODING_UTF8, specUtf8);

  nsCOMPtr<nsIIOService> ios = do_GetService("@mozilla.org/network/io-service;1");
  NS_ENSURE_TRUE(ios, NS_ERROR_UNEXPECTED);

  return ios->NewURI(specUtf8, nsnull, nsnull, result);
}

Here is the call graph for this function:

static void ReplaceChar ( nsAString &  str,
char  oldChar,
char  newChar 
) [static]

Definition at line 86 of file BrowserView.cpp.

{
  // XXX this could be much more efficient

  PRUnichar *data = NS_StringCloneData(str);
  PRUnichar *datastring = data;
  for (; *data; ++data)
  {
    if ((char ) *data == oldChar)
      *data = (PRUnichar) newChar;
  }
  NS_StringSetData(str, datastring);
  nsMemory::Free(datastring);
}

Here is the call graph for this function:

static void StripChars ( nsAString &  str,
const char *  chars 
) [static]

Definition at line 102 of file BrowserView.cpp.

{
  // XXX this could be much more efficient

  PRUint32 len = str.Length();

  PRUnichar *data = NS_StringCloneData(str);
  PRUnichar *datastring = data;
  PRUnichar *dataEnd = data + len;
  for (; *data; ++data)
  {
    if (strchr(chars, (char ) *data))
    {
      // include trailing null terminator in the memmove
      memmove(data, data + 1, (dataEnd - data) * sizeof(PRUnichar));
      --dataEnd;
    }
  }
  NS_StringSetData(str, datastring);
  nsMemory::Free(datastring);
}

Here is the call graph for this function:

static void StripChars ( nsACString &  str,
const char *  chars 
) [static]

Definition at line 125 of file BrowserView.cpp.

{
  // XXX this could be much more efficient

  PRUint32 len = str.Length();

  char *data = NS_CStringCloneData(str);
  char *datastring = data;
  char *dataEnd = data + len;
  for (; *data; ++data)
  {
    if (strchr(chars, *data))
    {
      // include trailing null terminator in the memmove
      memmove(data, data + 1, dataEnd - data);
      --dataEnd;
    }
  }
  NS_CStringSetData(str, datastring);
  nsMemory::Free(datastring);
}

Here is the call graph for this function:


Variable Documentation

const char* kWhitespace = "\b\t\r\n " [static]

Definition at line 147 of file BrowserView.cpp.

UINT WM_FINDMSG = ::RegisterWindowMessage(FINDMSGSTRING) [static]

Definition at line 188 of file BrowserView.cpp.