Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
nsBrowserWindow.cpp File Reference
#include "nsIPref.h"
#include "prmem.h"
#include "nsBrowserWindow.h"
#include "nsIAppShell.h"
#include "nsIWidget.h"
#include "nsITextWidget.h"
#include "nsIButton.h"
#include "nsITimer.h"
#include "nsIDOMDocument.h"
#include "nsIURL.h"
#include "nsIChannel.h"
#include "nsNetUtil.h"
#include "nsIDOMWindowInternal.h"
#include "nsIFilePicker.h"
#include "nsILookAndFeel.h"
#include "nsIComponentManager.h"
#include "nsIFactory.h"
#include "nsCRT.h"
#include "nsWidgetsCID.h"
#include "nsViewerApp.h"
#include "prprf.h"
#include "nsParserCIID.h"
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsIStringBundle.h"
#include "nsLayoutCID.h"
#include "nsIDocumentViewer.h"
#include "nsIContentViewer.h"
#include "nsIContentViewerFile.h"
#include "nsIContentViewerContainer.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsIDocument.h"
#include "nsILayoutDebugger.h"
#include "nsThrobber.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShellTreeNode.h"
#include "nsIWebNavigation.h"
#include "nsIWebBrowserFocus.h"
#include "nsIBaseWindow.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsIViewManager.h"
#include "nsGUIEvent.h"
#include "nsIWebProgress.h"
#include "nsIWebBrowserSetup.h"
#include "nsIWebBrowserPrint.h"
#include "nsCWebBrowser.h"
#include "nsUnicharUtils.h"
#include "nsInt64.h"
#include "nsIParser.h"
#include "nsEditorMode.h"
#include "nsICheckButton.h"
#include "nsILabel.h"
#include "nsWidgetSupport.h"
#include "nsXPBaseWindow.h"
#include "resources.h"
#include <ctype.h>
#include "nsISelection.h"
#include "nsISelectionController.h"
#include "nsFont.h"
#include "nsUnitConversion.h"
#include "nsIDeviceContext.h"
#include "nsIIOService.h"
#include "nsNetCID.h"

Go to the source code of this file.

Defines

#define THROBBING_N
#define CLEANUP_WIDGET(_widget, _txt)
#define THROBBER_WIDTH   32
#define THROBBER_HEIGHT   32
#define THROBBER_AT   "resource:/res/throbber/anims%02d.gif"
#define THROB_NUM   29
#define BUTTON_WIDTH   90
#define BUTTON_HEIGHT   THROBBER_HEIGHT
#define MAX_TEXT_LENGTH   30000
#define WEBSHELL_LEFT_INSET   0
#define WEBSHELL_RIGHT_INSET   0
#define WEBSHELL_TOP_INSET   0
#define WEBSHELL_BOTTOM_INSET   0
#define FILE_PROTOCOL   "file://"
#define DIALOG_FONT   "Helvetica"
#define DIALOG_FONT_SIZE   10
#define VIEWER_BUNDLE_URL   NS_LITERAL_CSTRING("resource:/res/viewer.properties")
#define TOOL_BAR_FONT   "Helvetica"
#define TOOL_BAR_FONT_SIZE   12
#define STATUS_BAR_FONT   "Helvetica"
#define STATUS_BAR_FONT_SIZE   10
#define USE_DTD   0
#define STANDARD   1
#define QUIRKS   2

Functions

static NS_DEFINE_CID (kIOServiceCID, NS_IOSERVICE_CID)
static NS_DEFINE_CID (kLookAndFeelCID, NS_LOOKANDFEEL_CID)
static NS_DEFINE_CID (kButtonCID, NS_BUTTON_CID)
static NS_DEFINE_CID (kTextFieldCID, NS_TEXTFIELD_CID)
static NS_DEFINE_CID (kWindowCID, NS_WINDOW_CID)
static NS_DEFINE_IID (kIXPBaseWindowIID, NS_IXPBASE_WINDOW_IID)
static NS_DEFINE_IID (kIButtonIID, NS_IBUTTON_IID)
static NS_DEFINE_IID (kIDOMDocumentIID, NS_IDOMDOCUMENT_IID)
static NS_DEFINE_IID (kITextWidgetIID, NS_ITEXTWIDGET_IID)
static NS_DEFINE_IID (kIWidgetIID, NS_IWIDGET_IID)
static NS_DEFINE_IID (kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID)
static NS_DEFINE_CID (kXPBaseWindowCID, NS_XPBASE_WINDOW_CID)
static NS_DEFINE_IID (kIStringBundleServiceIID, NS_ISTRINGBUNDLESERVICE_IID)
static NS_DEFINE_CID (kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID)
static NS_DEFINE_IID (kILayoutDebuggerIID, NS_ILAYOUT_DEBUGGER_IID)
static NS_DEFINE_CID (kLayoutDebuggerCID, NS_LAYOUT_DEBUGGER_CID)
static nsIPresShellGetPresShellFor (nsIDocShell *aDocShell)
static nsEventStatus PR_CALLBACK HandleBrowserEvent (nsGUIEvent *aEvent)
static nsEventStatus PR_CALLBACK HandleBackEvent (nsGUIEvent *aEvent)
static nsEventStatus PR_CALLBACK HandleForwardEvent (nsGUIEvent *aEvent)
static nsEventStatus PR_CALLBACK HandleLocationEvent (nsGUIEvent *aEvent)
static PRBool GetFileFromFileSelector (nsIDOMWindowInternal *aParentWindow, nsILocalFile **aFile, nsILocalFile **aDisplayDirectory)

Variables

static nsStringgTitleSuffix = nsnull

Define Documentation

Definition at line 174 of file nsBrowserWindow.cpp.

#define BUTTON_WIDTH   90

Definition at line 173 of file nsBrowserWindow.cpp.

#define CLEANUP_WIDGET (   _widget,
  _txt 
)
Value:
if(_widget) {            \
  DestroyWidget((_widget)); \
  refCnt = (_widget)->Release(); \
  (_widget) = nsnull; \
  NS_ASSERTION(refCnt == 0, (_txt)); \
  }

Definition at line 152 of file nsBrowserWindow.cpp.

#define DIALOG_FONT   "Helvetica"

Definition at line 1128 of file nsBrowserWindow.cpp.

Definition at line 1129 of file nsBrowserWindow.cpp.

#define FILE_PROTOCOL   "file://"

Definition at line 208 of file nsBrowserWindow.cpp.

#define MAX_TEXT_LENGTH   30000

Definition at line 175 of file nsBrowserWindow.cpp.

#define QUIRKS   2

Definition at line 2661 of file nsBrowserWindow.cpp.

#define STANDARD   1

Definition at line 2660 of file nsBrowserWindow.cpp.

#define STATUS_BAR_FONT   "Helvetica"

Definition at line 1485 of file nsBrowserWindow.cpp.

Definition at line 1486 of file nsBrowserWindow.cpp.

#define THROB_NUM   29

Definition at line 166 of file nsBrowserWindow.cpp.

#define THROBBER_AT   "resource:/res/throbber/anims%02d.gif"

Definition at line 165 of file nsBrowserWindow.cpp.

Definition at line 164 of file nsBrowserWindow.cpp.

Definition at line 163 of file nsBrowserWindow.cpp.

Definition at line 150 of file nsBrowserWindow.cpp.

#define TOOL_BAR_FONT   "Helvetica"

Definition at line 1483 of file nsBrowserWindow.cpp.

Definition at line 1484 of file nsBrowserWindow.cpp.

#define USE_DTD   0

Definition at line 2659 of file nsBrowserWindow.cpp.

#define VIEWER_BUNDLE_URL   NS_LITERAL_CSTRING("resource:/res/viewer.properties")

Definition at line 1196 of file nsBrowserWindow.cpp.

Definition at line 186 of file nsBrowserWindow.cpp.

Definition at line 183 of file nsBrowserWindow.cpp.

Definition at line 184 of file nsBrowserWindow.cpp.

Definition at line 185 of file nsBrowserWindow.cpp.


Function Documentation

static PRBool GetFileFromFileSelector ( nsIDOMWindowInternal aParentWindow,
nsILocalFile **  aFile,
nsILocalFile **  aDisplayDirectory 
) [static]

Definition at line 1062 of file nsBrowserWindow.cpp.

{
  nsresult rv;
  nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("@mozilla.org/filepicker;1");

  if (filePicker) {
    rv = filePicker->Init(aParentWindow, NS_LITERAL_STRING("Open HTML"),
                          nsIFilePicker::modeOpen);
    if (NS_SUCCEEDED(rv)) {
      filePicker->AppendFilters(nsIFilePicker::filterAll | nsIFilePicker::filterHTML |
                                nsIFilePicker::filterXML | nsIFilePicker::filterImages);
      if (*aDisplayDirectory)
        filePicker->SetDisplayDirectory(*aDisplayDirectory);
      
      PRInt16 dialogResult;
      rv = filePicker->Show(&dialogResult);
      if (NS_FAILED(rv) || dialogResult == nsIFilePicker::returnCancel)
        return PR_FALSE;

      filePicker->GetFile(aFile);
      if (*aFile) {
        NS_IF_RELEASE(*aDisplayDirectory);
        filePicker->GetDisplayDirectory(aDisplayDirectory);
        return PR_TRUE;
      }
    }
  }

  return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsIPresShell* GetPresShellFor ( nsIDocShell aDocShell) [static]

Definition at line 472 of file nsBrowserWindow.cpp.

{
  nsIPresShell* shell = nsnull;
  if (nsnull != aDocShell) {
    nsIContentViewer* cv = nsnull;
    aDocShell->GetContentViewer(&cv);
    if (nsnull != cv) {
      nsIDocumentViewer* docv = nsnull;
      cv->QueryInterface(kIDocumentViewerIID, (void**) &docv);
      if (nsnull != docv) {
        nsCOMPtr<nsPresContext> cx;
        docv->GetPresContext(getter_AddRefs(cx));
        if (nsnull != cx) {
          NS_IF_ADDREF(shell = cx->GetPresShell());
        }
        NS_RELEASE(docv);
      }
      NS_RELEASE(cv);
    }
  }
  return shell;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsEventStatus PR_CALLBACK HandleBackEvent ( nsGUIEvent aEvent) [static]

Definition at line 658 of file nsBrowserWindow.cpp.

{
  nsEventStatus result = nsEventStatus_eIgnore;
  nsBrowserWindow* bw =
    nsBrowserWindow::FindBrowserFor(aEvent->widget, FIND_BACK);
  if (nsnull != bw) {
    switch(aEvent->message) {
    case NS_MOUSE_LEFT_BUTTON_UP:
      bw->Back();
      break;
    }
    NS_RELEASE(bw);
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsEventStatus PR_CALLBACK HandleBrowserEvent ( nsGUIEvent aEvent) [static]

Definition at line 598 of file nsBrowserWindow.cpp.

{ 
  nsEventStatus result = nsEventStatus_eIgnore;
  nsBrowserWindow* bw =
    nsBrowserWindow::FindBrowserFor(aEvent->widget, FIND_WINDOW);
  if (nsnull != bw) {
    nsSizeEvent* sizeEvent;
    switch(aEvent->message) {
    case NS_SIZE:
      sizeEvent = (nsSizeEvent*)aEvent;  
      bw->Layout(sizeEvent->windowSize->width,
                 sizeEvent->windowSize->height);
      result = nsEventStatus_eConsumeNoDefault;
      break;

    case NS_XUL_CLOSE:
    case NS_DESTROY:
    {
      nsViewerApp* app = bw->mApp;
      app->CloseWindow(bw);
      result = nsEventStatus_eConsumeDoDefault;

#ifndef XP_MAC
      // XXX Really shouldn't just exit, we should just notify somebody...
      if (!nsBrowserWindow::gBrowsers || !nsBrowserWindow::gBrowsers->Count()) {
        app->Exit();
      }
#endif
    }
    return result;

    case NS_MENU_SELECTED:
      result = bw->DispatchMenuItem(((nsMenuEvent*)aEvent)->mCommand);
      break;

    case NS_ACTIVATE:
      {
        nsCOMPtr<nsIWebBrowserFocus> focus = do_GetInterface(bw->mWebBrowser);
        if (focus)
          focus->Activate();
      }
      break;

    case NS_DEACTIVATE:
      {
        nsCOMPtr<nsIWebBrowserFocus> focus = do_GetInterface(bw->mWebBrowser);
        if (focus)
          focus->Deactivate();
      }
      break;

    default:
      break;
    }
    NS_RELEASE(bw);
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsEventStatus PR_CALLBACK HandleForwardEvent ( nsGUIEvent aEvent) [static]

Definition at line 675 of file nsBrowserWindow.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 692 of file nsBrowserWindow.cpp.

{
  nsEventStatus result = nsEventStatus_eIgnore;
  nsBrowserWindow* bw =
    nsBrowserWindow::FindBrowserFor(aEvent->widget, FIND_LOCATION);
  if (nsnull != bw) {
    switch (aEvent->message) {
    case NS_KEY_UP:
      if (NS_VK_RETURN == ((nsKeyEvent*)aEvent)->keyCode) {
        nsAutoString text;
        PRUint32 size;
        bw->mLocation->GetText(text, 1000, size);
        bw->GoTo(text.get());
      }
      break;

    default:
      break;
    }
    NS_RELEASE(bw);
  }
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static NS_DEFINE_CID ( kIOServiceCID  ,
NS_IOSERVICE_CID   
) [static]
static NS_DEFINE_CID ( kLookAndFeelCID  ,
NS_LOOKANDFEEL_CID   
) [static]
static NS_DEFINE_CID ( kButtonCID  ,
NS_BUTTON_CID   
) [static]
static NS_DEFINE_CID ( kTextFieldCID  ,
NS_TEXTFIELD_CID   
) [static]
static NS_DEFINE_CID ( kWindowCID  ,
NS_WINDOW_CID   
) [static]
static NS_DEFINE_CID ( kXPBaseWindowCID  ,
NS_XPBASE_WINDOW_CID   
) [static]
static NS_DEFINE_CID ( kStringBundleServiceCID  ,
NS_STRINGBUNDLESERVICE_CID   
) [static]
static NS_DEFINE_CID ( kLayoutDebuggerCID  ,
NS_LAYOUT_DEBUGGER_CID   
) [static]
static NS_DEFINE_IID ( kIXPBaseWindowIID  ,
NS_IXPBASE_WINDOW_IID   
) [static]
static NS_DEFINE_IID ( kIButtonIID  ,
NS_IBUTTON_IID   
) [static]
static NS_DEFINE_IID ( kIDOMDocumentIID  ,
NS_IDOMDOCUMENT_IID   
) [static]
static NS_DEFINE_IID ( kITextWidgetIID  ,
NS_ITEXTWIDGET_IID   
) [static]
static NS_DEFINE_IID ( kIWidgetIID  ,
NS_IWIDGET_IID   
) [static]
static NS_DEFINE_IID ( kIDocumentViewerIID  ,
NS_IDOCUMENT_VIEWER_IID   
) [static]
static NS_DEFINE_IID ( kIStringBundleServiceIID  ,
NS_ISTRINGBUNDLESERVICE_IID   
) [static]
static NS_DEFINE_IID ( kILayoutDebuggerIID  ,
NS_ILAYOUT_DEBUGGER_IID   
) [static]

Variable Documentation

Definition at line 1198 of file nsBrowserWindow.cpp.