reformatted (replaced tabs with 3 spaces)

import/tags/KMELEON_0_4
binaryc 22 years ago
parent 8f44c86b4b
commit 45850b7d02
  1. 398
      k-meleon/AccelParser.cpp
  2. 672
      k-meleon/BrowserFrameGlue.cpp
  3. 234
      k-meleon/BrowserImpl.cpp
  4. 8
      k-meleon/BrowserImplCtxMenuLstnr.cpp
  5. 271
      k-meleon/BrowserImplPrompt.cpp
  6. 90
      k-meleon/BrowserImplWebPrgrsLstnr.cpp
  7. 75
      k-meleon/KMeleon.dsp
  8. 2
      k-meleon/MfcEmbed.cpp
  9. 12
      k-meleon/version.h

@ -27,212 +27,212 @@
#define VK_TEST(KEY) else if (stricmp(p, #KEY) == 0){ key = VK_##KEY; }
CAccelParser::CAccelParser(){
accelTable = NULL;
numAccelerators = 0;
memset(accelerators, 0, sizeof(ACCEL) * MAX_ACCEL);
accelTable = NULL;
numAccelerators = 0;
memset(accelerators, 0, sizeof(ACCEL) * MAX_ACCEL);
}
CAccelParser::CAccelParser(CString &filename){
accelTable = NULL;
numAccelerators = 0;
memset(accelerators, 0, sizeof(ACCEL) * MAX_ACCEL);
accelTable = NULL;
numAccelerators = 0;
memset(accelerators, 0, sizeof(ACCEL) * MAX_ACCEL);
Load(filename);
Load(filename);
}
CAccelParser::~CAccelParser(){
if (accelTable){
DestroyAcceleratorTable(accelTable);
}
if (accelTable){
DestroyAcceleratorTable(accelTable);
}
}
int CAccelParser::Load(CString &filename){
if (accelTable){
DestroyAcceleratorTable(accelTable);
accelTable = NULL;
numAccelerators = 0;
}
CFile *accelFile;
TRY {
accelFile = new CFile(filename, CFile::modeRead);
}
CATCH (CFileException, e) {
accelFile = NULL;
return false;
}
END_CATCH
long length = accelFile->GetLength();
char *buffer = new char[length + 1];
accelFile->Read(buffer, length);
// force the terminating 0
buffer[length] = 0;
accelFile->Close();
delete accelFile;
accelFile = NULL;
CMap<CString, LPCSTR, int, int &> defineMap;
if (accelTable){
DestroyAcceleratorTable(accelTable);
accelTable = NULL;
numAccelerators = 0;
}
CFile *accelFile;
TRY {
accelFile = new CFile(filename, CFile::modeRead);
}
CATCH (CFileException, e) {
accelFile = NULL;
return false;
}
END_CATCH
long length = accelFile->GetLength();
char *buffer = new char[length + 1];
accelFile->Read(buffer, length);
// force the terminating 0
buffer[length] = 0;
accelFile->Close();
delete accelFile;
accelFile = NULL;
CMap<CString, LPCSTR, int, int &> defineMap;
#include "defineMap.cpp"
char *e, *s;
char *alt, *ctrl, *shift;
BYTE virt;
int command;
int key;
char *p = strtok(buffer, "\r\n");
while (p){
if (p[0] == '#'){
}
else {
// <modifiers> <key> = <command>
e = strchr(p, '=');
if (e){
*e = 0;
e++;
e = SkipWhiteSpace(e);
TrimWhiteSpace(e);
if (!defineMap.Lookup(e, command)){
command = atoi(e);
}
TrimWhiteSpace(p);
s = p;
virt = 0;
alt = strstr(s, "ALT");
if (alt){
virt |= FALT;
p = alt + 3;
}
ctrl = strstr(s, "CTRL");
if (ctrl){
virt |= FCONTROL;
if (ctrl > alt){
p = ctrl + 4;
}
}
shift = strstr(s, "SHIFT");
if (shift){
virt |= FSHIFT;
if ((shift > alt) && (shift > ctrl)){
p = shift + 5;
}
}
virt |= FVIRTKEY;
// by now, p should be past the modifiers and point to " <key>"
p = SkipWhiteSpace(p);
if (strncmp(p, "VK_", 3) == 0){
p+=3;
key = 0;
// these should be in order of frequency of use to speed up parsing
BEGIN_VK_TEST
VK_TEST(ESCAPE)
VK_TEST(LEFT)
VK_TEST(RIGHT)
VK_TEST(F1)
VK_TEST(F2)
VK_TEST(F3)
VK_TEST(F4)
VK_TEST(F5)
VK_TEST(F6)
VK_TEST(F7)
VK_TEST(F8)
VK_TEST(F9)
VK_TEST(F10)
VK_TEST(F11)
VK_TEST(F12)
VK_TEST(HOME)
VK_TEST(END)
VK_TEST(PRIOR) // page up
VK_TEST(NEXT) // page down
VK_TEST(UP)
VK_TEST(DOWN)
VK_TEST(INSERT)
VK_TEST(DELETE)
VK_TEST(SPACE)
VK_TEST(HELP)
VK_TEST(EXECUTE)
VK_TEST(SELECT)
VK_TEST(PRINT)
VK_TEST(SNAPSHOT) // print screen?
VK_TEST(BACK)
VK_TEST(TAB)
VK_TEST(CLEAR)
VK_TEST(RETURN)
VK_TEST(MULTIPLY)
VK_TEST(ADD)
VK_TEST(SUBTRACT)
VK_TEST(DECIMAL)
VK_TEST(DIVIDE)
VK_TEST(SEPARATOR)
VK_TEST(PAUSE)
VK_TEST(CAPITAL)
VK_TEST(MENU)
VK_TEST(KANA)
VK_TEST(JUNJA)
VK_TEST(FINAL)
VK_TEST(HANJA)
VK_TEST(KANJI)
VK_TEST(CONVERT)
VK_TEST(NONCONVERT)
VK_TEST(ACCEPT)
VK_TEST(MODECHANGE)
VK_TEST(LWIN)
VK_TEST(RWIN)
VK_TEST(APPS)
VK_TEST(NUMPAD0)
VK_TEST(NUMPAD1)
VK_TEST(NUMPAD2)
VK_TEST(NUMPAD3)
VK_TEST(NUMPAD4)
VK_TEST(NUMPAD5)
VK_TEST(NUMPAD6)
VK_TEST(NUMPAD7)
VK_TEST(NUMPAD8)
VK_TEST(NUMPAD9)
VK_TEST(F13)
VK_TEST(F14)
VK_TEST(F15)
VK_TEST(F16)
VK_TEST(F17)
VK_TEST(F18)
VK_TEST(F19)
VK_TEST(F20)
VK_TEST(F21)
VK_TEST(F22)
VK_TEST(F23)
VK_TEST(F24)
VK_TEST(NUMLOCK)
VK_TEST(SCROLL)
}
else {
// regular key...
key = (WORD)*p;
}
accelerators[numAccelerators].cmd = command;
accelerators[numAccelerators].fVirt = virt;
accelerators[numAccelerators].key = key;
numAccelerators++;
char *e, *s;
char *alt, *ctrl, *shift;
BYTE virt;
int command;
int key;
char *p = strtok(buffer, "\r\n");
while (p){
if (p[0] == '#'){
}
else {
// <modifiers> <key> = <command>
e = strchr(p, '=');
if (e){
*e = 0;
e++;
e = SkipWhiteSpace(e);
TrimWhiteSpace(e);
if (!defineMap.Lookup(e, command)){
command = atoi(e);
}
TrimWhiteSpace(p);
s = p;
virt = 0;
alt = strstr(s, "ALT");
if (alt){
virt |= FALT;
p = alt + 3;
}
ctrl = strstr(s, "CTRL");
if (ctrl){
virt |= FCONTROL;
if (ctrl > alt){
p = ctrl + 4;
}
}
shift = strstr(s, "SHIFT");
if (shift){
virt |= FSHIFT;
if ((shift > alt) && (shift > ctrl)){
p = shift + 5;
}
}
virt |= FVIRTKEY;
// by now, p should be past the modifiers and point to " <key>"
p = SkipWhiteSpace(p);
if (strncmp(p, "VK_", 3) == 0){
p+=3;
key = 0;
// these should be in order of frequency of use to speed up parsing
BEGIN_VK_TEST
VK_TEST(ESCAPE)
VK_TEST(LEFT)
VK_TEST(RIGHT)
VK_TEST(F1)
VK_TEST(F2)
VK_TEST(F3)
VK_TEST(F4)
VK_TEST(F5)
VK_TEST(F6)
VK_TEST(F7)
VK_TEST(F8)
VK_TEST(F9)
VK_TEST(F10)
VK_TEST(F11)
VK_TEST(F12)
VK_TEST(HOME)
VK_TEST(END)
VK_TEST(PRIOR) // page up
VK_TEST(NEXT) // page down
VK_TEST(UP)
VK_TEST(DOWN)
VK_TEST(INSERT)
VK_TEST(DELETE)
VK_TEST(SPACE)
VK_TEST(HELP)
VK_TEST(EXECUTE)
VK_TEST(SELECT)
VK_TEST(PRINT)
VK_TEST(SNAPSHOT) // print screen?
VK_TEST(BACK)
VK_TEST(TAB)
VK_TEST(CLEAR)
VK_TEST(RETURN)
VK_TEST(MULTIPLY)
VK_TEST(ADD)
VK_TEST(SUBTRACT)
VK_TEST(DECIMAL)
VK_TEST(DIVIDE)
VK_TEST(SEPARATOR)
VK_TEST(PAUSE)
VK_TEST(CAPITAL)
VK_TEST(MENU)
VK_TEST(KANA)
VK_TEST(JUNJA)
VK_TEST(FINAL)
VK_TEST(HANJA)
VK_TEST(KANJI)
VK_TEST(CONVERT)
VK_TEST(NONCONVERT)
VK_TEST(ACCEPT)
VK_TEST(MODECHANGE)
VK_TEST(LWIN)
VK_TEST(RWIN)
VK_TEST(APPS)
VK_TEST(NUMPAD0)
VK_TEST(NUMPAD1)
VK_TEST(NUMPAD2)
VK_TEST(NUMPAD3)
VK_TEST(NUMPAD4)
VK_TEST(NUMPAD5)
VK_TEST(NUMPAD6)
VK_TEST(NUMPAD7)
VK_TEST(NUMPAD8)
VK_TEST(NUMPAD9)
VK_TEST(F13)
VK_TEST(F14)
VK_TEST(F15)
VK_TEST(F16)
VK_TEST(F17)
VK_TEST(F18)
VK_TEST(F19)
VK_TEST(F20)
VK_TEST(F21)
VK_TEST(F22)
VK_TEST(F23)
VK_TEST(F24)
VK_TEST(NUMLOCK)
VK_TEST(SCROLL)
}
else {
// regular key...
key = (WORD)*p;
}
accelerators[numAccelerators].cmd = command;
accelerators[numAccelerators].fVirt = virt;
accelerators[numAccelerators].key = key;
numAccelerators++;
} // if e
}
p = strtok(NULL, "\r\n");
@ -244,10 +244,8 @@ int CAccelParser::Load(CString &filename){
}
HACCEL CAccelParser::GetTable(){
if (!accelTable){
accelTable = CreateAcceleratorTable(accelerators, numAccelerators);
}
return accelTable;
if (!accelTable){
accelTable = CreateAcceleratorTable(accelerators, numAccelerators);
}
return accelTable;
}

@ -58,33 +58,33 @@ extern CMfcEmbedApp theApp;
void CBrowserFrame::BrowserFrameGlueObj::UpdateStatusBarText(const PRUnichar *aMessage)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
nsCString strStatus;
nsCString strStatus;
if(aMessage)
strStatus.AssignWithConversion(aMessage);
if(aMessage)
strStatus.AssignWithConversion(aMessage);
pThis->m_wndStatusBar.SetPaneText(0, strStatus.GetBuffer());
pThis->m_wndStatusBar.SetPaneText(0, strStatus.GetBuffer());
}
void CBrowserFrame::BrowserFrameGlueObj::UpdateProgress(PRInt32 aCurrent, PRInt32 aMax)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->m_wndProgressBar.SetRange32(0, aMax);
pThis->m_wndProgressBar.SetPos(aCurrent);
pThis->m_wndProgressBar.SetRange32(0, aMax);
pThis->m_wndProgressBar.SetPos(aCurrent);
}
void CBrowserFrame::BrowserFrameGlueObj::UpdateBusyState(PRBool aBusy)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
// Just notify the view of the busy state
// There's code in there which will take care of
// updating the STOP toolbar btn. etc
// Just notify the view of the busy state
// There's code in there which will take care of
// updating the STOP toolbar btn. etc
pThis->m_wndBrowserView.UpdateBusyState(aBusy);
pThis->m_wndBrowserView.UpdateBusyState(aBusy);
}
// Called from the OnLocationChange() method in the nsIWebProgressListener
@ -94,463 +94,463 @@ void CBrowserFrame::BrowserFrameGlueObj::UpdateBusyState(PRBool aBusy)
//
void CBrowserFrame::BrowserFrameGlueObj::UpdateCurrentURI(nsIURI *aLocation)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
if(aLocation) {
nsXPIDLCString uriString;
aLocation->GetSpec(getter_Copies(uriString));
if(aLocation) {
nsXPIDLCString uriString;
aLocation->GetSpec(getter_Copies(uriString));
pThis->m_wndUrlBar.SetCurrentURL(uriString.get());
}
pThis->m_wndUrlBar.SetCurrentURL(uriString.get());
}
// post notification that the session history is changing
// this will be updated later when OnUpdateBusy state is called
// because the page title has not yet loaded
theApp.m_pMainWnd->GetActiveWindow()->PostMessage(WM_UPDATESESSIONHISTORY, 0, 0);
// post notification that the session history is changing
// this will be updated later when OnUpdateBusy state is called
// because the page title has not yet loaded
theApp.m_pMainWnd->GetActiveWindow()->PostMessage(WM_UPDATESESSIONHISTORY, 0, 0);
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameTitle(PRUnichar **aTitle)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
CString title;
pThis->GetWindowText(title);
CString title;
pThis->GetWindowText(title);
if(!title.IsEmpty())
{
nsString nsTitle;
nsTitle.AssignWithConversion(title.GetBuffer(0));
if(!title.IsEmpty())
{
nsString nsTitle;
nsTitle.AssignWithConversion(title.GetBuffer(0));
*aTitle = nsTitle.ToNewUnicode();
}
*aTitle = nsTitle.ToNewUnicode();
}
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFrameTitle(const PRUnichar *aTitle)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
USES_CONVERSION;
CString cs;
cs.LoadString(AFX_IDS_APP_TITLE);
CString cs;
cs.LoadString(AFX_IDS_APP_TITLE);
CString title = W2T(aTitle);
CString title = W2T(aTitle);
if (title.IsEmpty()){
pThis->m_wndUrlBar.GetEnteredURL(title);
}
if (title.IsEmpty()){
pThis->m_wndUrlBar.GetEnteredURL(title);
}
title += " (" + cs + ')';
pThis->SetWindowText(title);
title += " (" + cs + ')';
pThis->SetWindowText(title);
// then steal focus
if (pThis->IsChild(GetFocus())){
pThis->SetFocus();
}
// then steal focus
if (pThis->IsChild(GetFocus())){
pThis->SetFocus();
}
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFrameSize(PRInt32 aCX, PRInt32 aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->SetWindowPos(NULL, 0, 0, aCX, aCY,
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER
);
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->SetWindowPos(NULL, 0, 0, aCX, aCY,
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER
);
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameSize(PRInt32 *aCX, PRInt32 *aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
RECT wndRect;
pThis->GetWindowRect(&wndRect);
RECT wndRect;
pThis->GetWindowRect(&wndRect);
if (aCX)
*aCX = wndRect.right - wndRect.left;
if (aCX)
*aCX = wndRect.right - wndRect.left;
if (aCY)
*aCY = wndRect.bottom - wndRect.top;
if (aCY)
*aCY = wndRect.bottom - wndRect.top;
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFramePosition(PRInt32 aX, PRInt32 aY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->SetWindowPos(NULL, aX, aY, 0, 0,
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
pThis->SetWindowPos(NULL, aX, aY, 0, 0,
SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFramePosition(PRInt32 *aX, PRInt32 *aY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
RECT wndRect;
pThis->GetWindowRect(&wndRect);
RECT wndRect;
pThis->GetWindowRect(&wndRect);
if (aX)
*aX = wndRect.left;
if (aX)
*aX = wndRect.left;
if (aY)
*aY = wndRect.top;
if (aY)
*aY = wndRect.top;
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFramePositionAndSize(PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
RECT wndRect;
pThis->GetWindowRect(&wndRect);
RECT wndRect;
pThis->GetWindowRect(&wndRect);
if (aX)
*aX = wndRect.left;
if (aX)
*aX = wndRect.left;
if (aY)
*aY = wndRect.top;
if (aY)
*aY = wndRect.top;
if (aCX)
*aCX = wndRect.right - wndRect.left;
if (aCX)
*aCX = wndRect.right - wndRect.left;
if (aCY)
*aCY = wndRect.bottom - wndRect.top;
if (aCY)
*aCY = wndRect.bottom - wndRect.top;
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFramePositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool fRepaint)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->SetWindowPos(NULL, aX, aY, aCX, aCY,
SWP_NOACTIVATE | SWP_NOZORDER);
pThis->SetWindowPos(NULL, aX, aY, aCX, aCY,
SWP_NOACTIVATE | SWP_NOZORDER);
}
void CBrowserFrame::BrowserFrameGlueObj::SetFocus()
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->SetFocus();
pThis->SetFocus();
}
void CBrowserFrame::BrowserFrameGlueObj::FocusAvailable(PRBool *aFocusAvail)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
HWND focusWnd = GetFocus()->m_hWnd;
HWND focusWnd = GetFocus()->m_hWnd;
if ((focusWnd == pThis->m_hWnd) || ::IsChild(pThis->m_hWnd, focusWnd))
*aFocusAvail = PR_TRUE;
else
*aFocusAvail = PR_FALSE;
if ((focusWnd == pThis->m_hWnd) || ::IsChild(pThis->m_hWnd, focusWnd))
*aFocusAvail = PR_TRUE;
else
*aFocusAvail = PR_FALSE;
}
void CBrowserFrame::BrowserFrameGlueObj::ShowBrowserFrame(PRBool aShow)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
if(aShow)
{
pThis->ShowWindow(SW_SHOW);
pThis->SetActiveWindow();
pThis->UpdateWindow();
}
else
{
pThis->ShowWindow(SW_HIDE);
}
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
if(aShow)
{
pThis->ShowWindow(SW_SHOW);
pThis->SetActiveWindow();
pThis->UpdateWindow();
}
else
{
pThis->ShowWindow(SW_HIDE);
}
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameVisibility(PRBool *aVisible)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
// Is the current BrowserFrame the active one?
if (GetActiveWindow()->m_hWnd != pThis->m_hWnd)
{
*aVisible = PR_FALSE;
return;
}
// We're the active one
//Return FALSE if we're minimized
WINDOWPLACEMENT wpl;
pThis->GetWindowPlacement(&wpl);
if ((wpl.showCmd == SW_RESTORE) || (wpl.showCmd == SW_MAXIMIZE))
*aVisible = PR_TRUE;
else
*aVisible = PR_FALSE;
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
// Is the current BrowserFrame the active one?
if (GetActiveWindow()->m_hWnd != pThis->m_hWnd)
{
*aVisible = PR_FALSE;
return;
}
// We're the active one
//Return FALSE if we're minimized
WINDOWPLACEMENT wpl;
pThis->GetWindowPlacement(&wpl);
if ((wpl.showCmd == SW_RESTORE) || (wpl.showCmd == SW_MAXIMIZE))
*aVisible = PR_TRUE;
else
*aVisible = PR_FALSE;
}
PRBool CBrowserFrame::BrowserFrameGlueObj::CreateNewBrowserFrame(PRUint32 chromeMask,
PRInt32 x, PRInt32 y,
PRInt32 cx, PRInt32 cy,
nsIWebBrowser** aWebBrowser)
PRInt32 x, PRInt32 y,
PRInt32 cx, PRInt32 cy,
nsIWebBrowser** aWebBrowser)
{
NS_ENSURE_ARG_POINTER(aWebBrowser);
*aWebBrowser = nsnull;
CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp();
if(!pApp)
return PR_FALSE;
// Note that we're calling with the last param set to "false" i.e.
// this instructs not to show the frame window
// This is mainly needed when the window size is specified in the window.open()
// JS call. In those cases Gecko calls us to create the browser with a default
// size (all are -1) and then it calls the SizeBrowserTo() method to set
// the proper window size. If this window were to be visible then you'll see
// the window size changes on the screen causing an unappealing flicker
//
// Changing the last param back to TRUE since the latest nsIWebBrowserSiteWindow
// changes have gotten rid of the SetVisibility() method which we were using
// to finally show the browser window. I think we need that functionality
// back in
// Chak
// Feb 2, 2001
CBrowserFrame* pFrm = pApp->CreateNewBrowserFrame(chromeMask, x, y, cx, cy, PR_TRUE);
if(!pFrm)
return PR_FALSE;
// At this stage we have a new CBrowserFrame and a new CBrowserView
// objects. The CBrowserView also would have an embedded browser
// object created. Get the mWebBrowser member from the CBrowserView
// and return it. (See CBrowserView's CreateBrowser() on how the
// embedded browser gets created and how it's mWebBrowser member
// gets initialized)
NS_IF_ADDREF(*aWebBrowser = pFrm->m_wndBrowserView.mWebBrowser);
return PR_TRUE;
CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp();
if(!pApp)
return PR_FALSE;
// Note that we're calling with the last param set to "false" i.e.
// this instructs not to show the frame window
// This is mainly needed when the window size is specified in the window.open()
// JS call. In those cases Gecko calls us to create the browser with a default
// size (all are -1) and then it calls the SizeBrowserTo() method to set
// the proper window size. If this window were to be visible then you'll see
// the window size changes on the screen causing an unappealing flicker
//
// Changing the last param back to TRUE since the latest nsIWebBrowserSiteWindow
// changes have gotten rid of the SetVisibility() method which we were using
// to finally show the browser window. I think we need that functionality
// back in
// Chak
// Feb 2, 2001
CBrowserFrame* pFrm = pApp->CreateNewBrowserFrame(chromeMask, x, y, cx, cy, PR_TRUE);
if(!pFrm)
return PR_FALSE;
// At this stage we have a new CBrowserFrame and a new CBrowserView
// objects. The CBrowserView also would have an embedded browser
// object created. Get the mWebBrowser member from the CBrowserView
// and return it. (See CBrowserView's CreateBrowser() on how the
// embedded browser gets created and how it's mWebBrowser member
// gets initialized)
NS_IF_ADDREF(*aWebBrowser = pFrm->m_wndBrowserView.mWebBrowser);
return PR_TRUE;
}
void CBrowserFrame::BrowserFrameGlueObj::DestroyBrowserFrame()
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->PostMessage(WM_CLOSE);
pThis->PostMessage(WM_CLOSE);
}
void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
char *menuType = _T("DocumentPopup");
if(aContextFlags & nsIContextMenuListener::CONTEXT_DOCUMENT)
menuType = _T("DocumentPopup");
else if(aContextFlags & nsIContextMenuListener::CONTEXT_TEXT)
menuType = _T("TextPopup");
else if(aContextFlags & nsIContextMenuListener::CONTEXT_LINK)
{
menuType = _T("LinkPopup");
// Since we handle all the browser menu/toolbar commands
// in the View, we basically setup the Link's URL in the
// BrowserView object. When a menu selection in the context
// menu is made, the appropriate command handler in the
// BrowserView will be invoked and the value of the URL
// will be accesible in the view
// Reset the value from the last invocation
// (A new value will be set after we determine it below)
//
nsAutoString strUrlUcs2;
pThis->m_wndBrowserView.SetCtxMenuLinkUrl(strUrlUcs2);
// Get the URL from the link. This is two step process
// 1. We first get the nsIDOMHTMLAnchorElement
// 2. We then get the URL associated with the link
nsresult rv = NS_OK;
nsCOMPtr<nsIDOMHTMLAnchorElement> linkElement(do_QueryInterface(aNode, &rv));
if(NS_FAILED(rv)){
nsCOMPtr<nsIDOMNode> parentNode;
aNode->GetParentNode(getter_AddRefs(parentNode));
linkElement = do_QueryInterface(parentNode, &rv);
if (NS_FAILED(rv)){
return;
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
char *menuType = _T("DocumentPopup");
if(aContextFlags & nsIContextMenuListener::CONTEXT_DOCUMENT)
menuType = _T("DocumentPopup");
else if(aContextFlags & nsIContextMenuListener::CONTEXT_TEXT)
menuType = _T("TextPopup");
else if(aContextFlags & nsIContextMenuListener::CONTEXT_LINK)
{
menuType = _T("LinkPopup");
// Since we handle all the browser menu/toolbar commands
// in the View, we basically setup the Link's URL in the
// BrowserView object. When a menu selection in the context
// menu is made, the appropriate command handler in the
// BrowserView will be invoked and the value of the URL
// will be accesible in the view
// Reset the value from the last invocation
// (A new value will be set after we determine it below)
//
nsAutoString strUrlUcs2;
pThis->m_wndBrowserView.SetCtxMenuLinkUrl(strUrlUcs2);
// Get the URL from the link. This is two step process
// 1. We first get the nsIDOMHTMLAnchorElement
// 2. We then get the URL associated with the link
nsresult rv = NS_OK;
nsCOMPtr<nsIDOMHTMLAnchorElement> linkElement(do_QueryInterface(aNode, &rv));
if(NS_FAILED(rv)){
nsCOMPtr<nsIDOMNode> parentNode;
aNode->GetParentNode(getter_AddRefs(parentNode));
linkElement = do_QueryInterface(parentNode, &rv);
if (NS_FAILED(rv)){
return;
}
}
}
rv = linkElement->GetHref(strUrlUcs2);
if(NS_FAILED(rv))
return;
// Update the view with the new LinkUrl
// Note that this string is in UCS2 format
pThis->m_wndBrowserView.SetCtxMenuLinkUrl(strUrlUcs2);
}
if(aContextFlags & nsIContextMenuListener::CONTEXT_IMAGE) {
if(aContextFlags & nsIContextMenuListener::CONTEXT_LINK)
menuType = _T("ImageLinkPopup");
else
menuType = _T("ImagePopup");
nsAutoString strImgSrcUcs2;
pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrcUcs2); // Clear it
// Get the IMG SRC
nsresult rv = NS_OK;
nsCOMPtr<nsIDOMHTMLImageElement> imgElement(do_QueryInterface(aNode, &rv));
if(NS_FAILED(rv))
return;
rv = imgElement->GetSrc(strImgSrcUcs2);
if(NS_FAILED(rv))
return;
pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrcUcs2); // Set the new Img Src
}
CMenu *ctxMenu = theApp.menus.GetMenu(menuType);
if(ctxMenu)
{
POINT cursorPos;
GetCursorPos(&cursorPos);
ctxMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, cursorPos.x, cursorPos.y, pThis);
}
rv = linkElement->GetHref(strUrlUcs2);
if(NS_FAILED(rv))
return;
// Update the view with the new LinkUrl
// Note that this string is in UCS2 format
pThis->m_wndBrowserView.SetCtxMenuLinkUrl(strUrlUcs2);
}
if(aContextFlags & nsIContextMenuListener::CONTEXT_IMAGE) {
if(aContextFlags & nsIContextMenuListener::CONTEXT_LINK)
menuType = _T("ImageLinkPopup");
else
menuType = _T("ImagePopup");
nsAutoString strImgSrcUcs2;
pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrcUcs2); // Clear it
// Get the IMG SRC
nsresult rv = NS_OK;
nsCOMPtr<nsIDOMHTMLImageElement> imgElement(do_QueryInterface(aNode, &rv));
if(NS_FAILED(rv))
return;
rv = imgElement->GetSrc(strImgSrcUcs2);
if(NS_FAILED(rv))
return;
pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrcUcs2); // Set the new Img Src
}
CMenu *ctxMenu = theApp.menus.GetMenu(menuType);
if(ctxMenu)
{
POINT cursorPos;
GetCursorPos(&cursorPos);
ctxMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, cursorPos.x, cursorPos.y, pThis);
}
}
nsresult CBrowserFrame::BrowserFrameGlueObj::FindNamedBrowserItem(const PRUnichar *aName, nsIWebBrowserChrome* aWebBrowserChrome, nsIDocShellTreeItem ** aBrowserItem)
{
NS_ENSURE_ARG(aName);
NS_ENSURE_ARG_POINTER(aBrowserItem);
*aBrowserItem = nsnull;
// Get pointer to our App
CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp();
if(!pApp)
return NS_ERROR_FAILURE;
// Now walk thru' all frames to see if we can find the
// named item
//
CBrowserFrame* pFrm = NULL;
POSITION pos = pApp->m_FrameWndLst.GetHeadPosition();
while( pos != NULL )
{
pFrm = (CBrowserFrame *) pApp->m_FrameWndLst.GetNext(pos);
if(pFrm)
{
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(pFrm->m_wndBrowserView.mWebBrowser));
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
docShellAsItem->FindItemWithName(aName, aWebBrowserChrome, aBrowserItem);
NS_ENSURE_ARG(aName);
NS_ENSURE_ARG_POINTER(aBrowserItem);
*aBrowserItem = nsnull;
// Get pointer to our App
CMfcEmbedApp *pApp = (CMfcEmbedApp *)AfxGetApp();
if(!pApp)
return NS_ERROR_FAILURE;
// Now walk thru' all frames to see if we can find the
// named item
//
CBrowserFrame* pFrm = NULL;
POSITION pos = pApp->m_FrameWndLst.GetHeadPosition();
while( pos != NULL )
{
pFrm = (CBrowserFrame *) pApp->m_FrameWndLst.GetNext(pos);
if(pFrm)
{
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(pFrm->m_wndBrowserView.mWebBrowser));
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
docShellAsItem->FindItemWithName(aName, aWebBrowserChrome, aBrowserItem);
if(*aBrowserItem)
break;
}
}
break;
}
}
return NS_OK;
return NS_OK;
}
void CBrowserFrame::BrowserFrameGlueObj::Alert(const PRUnichar *dialogTitle, const PRUnichar *text)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
USES_CONVERSION;
pThis->MessageBox(W2T(text), W2T(dialogTitle), MB_OK | MB_ICONEXCLAMATION);
pThis->MessageBox(W2T(text), W2T(dialogTitle), MB_OK | MB_ICONEXCLAMATION);
}
void CBrowserFrame::BrowserFrameGlueObj::Confirm(const PRUnichar *dialogTitle, const PRUnichar *text, PRBool *retval)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
USES_CONVERSION;
int iChoice = pThis->MessageBox(W2T(text), W2T(dialogTitle), MB_OKCANCEL | MB_ICONEXCLAMATION);
int iChoice = pThis->MessageBox(W2T(text), W2T(dialogTitle), MB_OKCANCEL | MB_ICONEXCLAMATION);
*retval = (iChoice == IDOK) ? PR_TRUE : PR_FALSE;
*retval = (iChoice == IDOK) ? PR_TRUE : PR_FALSE;
}
void CBrowserFrame::BrowserFrameGlueObj::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text,
const PRUnichar *defaultEditText, PRUnichar **result, PRBool *retval)
const PRUnichar *defaultEditText, PRUnichar **result, PRBool *retval)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
USES_CONVERSION;
CPromptDialog dlg(pThis, W2T(dialogTitle), W2T(text), W2T(defaultEditText));
if(dlg.DoModal() == IDOK)
{
// Get the value entered in the editbox of the PromptDlg
nsString csPromptEditValue;
csPromptEditValue.AssignWithConversion(dlg.m_csPromptAnswer.GetBuffer(0));
CPromptDialog dlg(pThis, W2T(dialogTitle), W2T(text), W2T(defaultEditText));
if(dlg.DoModal() == IDOK)
{
// Get the value entered in the editbox of the PromptDlg
nsString csPromptEditValue;
csPromptEditValue.AssignWithConversion(dlg.m_csPromptAnswer.GetBuffer(0));
*result = csPromptEditValue.ToNewUnicode();
*result = csPromptEditValue.ToNewUnicode();
*retval = PR_TRUE;
}
else
{
*retval = PR_FALSE;
}
*retval = PR_TRUE;
}
else
{
*retval = PR_FALSE;
}
}
void CBrowserFrame::BrowserFrameGlueObj::PromptPassword(const PRUnichar *dialogTitle,
const PRUnichar *text, const PRUnichar *checkboxMsg,
PRBool *checkboxState, PRUnichar **result, PRBool *retval)
const PRUnichar *text, const PRUnichar *checkboxMsg,
PRBool *checkboxState, PRUnichar **result, PRBool *retval)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
CPromptPasswordDialog dlg(pThis, W2T(dialogTitle), W2T(text), W2T(checkboxMsg));
if(dlg.DoModal() == IDOK)
{
// Get the password entered
nsString csPassword;
csPassword.AssignWithConversion(dlg.m_csPassword.GetBuffer(0));
*result = csPassword.ToNewUnicode();
if(checkboxState) //Checkbox will be hidden in non single sign-on case
*checkboxState = dlg.m_bSavePassword;
*retval = PR_TRUE;
}
else
{
*retval = PR_FALSE;
}
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
CPromptPasswordDialog dlg(pThis, W2T(dialogTitle), W2T(text), W2T(checkboxMsg));
if(dlg.DoModal() == IDOK)
{
// Get the password entered
nsString csPassword;
csPassword.AssignWithConversion(dlg.m_csPassword.GetBuffer(0));
*result = csPassword.ToNewUnicode();
if(checkboxState) //Checkbox will be hidden in non single sign-on case
*checkboxState = dlg.m_bSavePassword;
*retval = PR_TRUE;
}
else
{
*retval = PR_FALSE;
}
}
void CBrowserFrame::BrowserFrameGlueObj::PromptUserNamePassword(const PRUnichar *dialogTitle,
const PRUnichar *text, const PRUnichar *userNameLabel,
const PRUnichar *passwordLabel, const PRUnichar *checkboxMsg,
PRBool *checkboxState, PRUnichar **username, PRUnichar **password,
PRBool *retval)
const PRUnichar *text, const PRUnichar *userNameLabel,
const PRUnichar *passwordLabel, const PRUnichar *checkboxMsg,
PRBool *checkboxState, PRUnichar **username, PRUnichar **password,
PRBool *retval)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
USES_CONVERSION;
CPromptUsernamePasswordDialog dlg(pThis, W2T(dialogTitle), W2T(text),
W2T(userNameLabel), W2T(passwordLabel),
W2T(checkboxMsg));
CPromptUsernamePasswordDialog dlg(pThis, W2T(dialogTitle), W2T(text),
W2T(userNameLabel), W2T(passwordLabel),
W2T(checkboxMsg));
if(dlg.DoModal() == IDOK)
{
// Get the username entered
nsString csUserName;
csUserName.AssignWithConversion(dlg.m_csUserName.GetBuffer(0));
*username = csUserName.ToNewUnicode();
if(dlg.DoModal() == IDOK)
{
// Get the username entered
nsString csUserName;
csUserName.AssignWithConversion(dlg.m_csUserName.GetBuffer(0));
*username = csUserName.ToNewUnicode();
// Get the password entered
nsString csPassword;
csPassword.AssignWithConversion(dlg.m_csPassword.GetBuffer(0));
*password = csPassword.ToNewUnicode();
// Get the password entered
nsString csPassword;
csPassword.AssignWithConversion(dlg.m_csPassword.GetBuffer(0));
*password = csPassword.ToNewUnicode();
if(checkboxState) //Checkbox will be hidden in non single sign-on case
*checkboxState = dlg.m_bSavePassword;
if(checkboxState) //Checkbox will be hidden in non single sign-on case
*checkboxState = dlg.m_bSavePassword;
*retval = PR_TRUE;
*retval = PR_TRUE;
}
else
{
*retval = PR_FALSE;
}
}
}
else
{
*retval = PR_FALSE;
}
}

@ -66,10 +66,10 @@
CBrowserImpl::CBrowserImpl()
{
NS_INIT_ISUPPORTS();
NS_INIT_ISUPPORTS();
m_pBrowserFrameGlue = NULL;
mWebBrowser = nsnull;
m_pBrowserFrameGlue = NULL;
mWebBrowser = nsnull;
}
@ -81,13 +81,13 @@ CBrowserImpl::~CBrowserImpl()
// Call on this Init() method with proper values after creation
//
NS_METHOD CBrowserImpl::Init(PBROWSERFRAMEGLUE pBrowserFrameGlue,
nsIWebBrowser* aWebBrowser)
nsIWebBrowser* aWebBrowser)
{
m_pBrowserFrameGlue = pBrowserFrameGlue;
SetWebBrowser(aWebBrowser);
SetWebBrowser(aWebBrowser);
return NS_OK;
return NS_OK;
}
//*****************************************************************************
@ -106,48 +106,48 @@ NS_INTERFACE_MAP_BEGIN(CBrowserImpl)
NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener)
NS_INTERFACE_MAP_ENTRY(nsIPrompt)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_END
NS_INTERFACE_MAP_END
//*****************************************************************************
// CBrowserImpl::nsIInterfaceRequestor
//*****************************************************************************
//*****************************************************************************
// CBrowserImpl::nsIInterfaceRequestor
//*****************************************************************************
NS_IMETHODIMP CBrowserImpl::GetInterface(const nsIID &aIID, void** aInstancePtr)
NS_IMETHODIMP CBrowserImpl::GetInterface(const nsIID &aIID, void** aInstancePtr)
{
// Note that we're wrapping our nsIPrompt impl. with the
// nsISingleSignOnPrompt - if USE_SINGLE_SIGN_ON is defined
// (and if single sign-on support dll's are present and enabled)
// This allows the embedding app to use the password save
// feature. When signing on to a host which needs authentication
// the Single sign-on service will check to see if the auth. info
// is already saved and if so uses it to pre-fill the sign-on form
// If not, our nsIPrompt impl will be called
// to present the auth UI and return the required auth info.
// If we do not compile with single sign-on support or if that
// service is missing we just fall back to the regular
// implementation of nsIPrompt
if(aIID.Equals(NS_GET_IID(nsIPrompt)))
{
if (!mPrompter)
{
// Note that we're wrapping our nsIPrompt impl. with the
// nsISingleSignOnPrompt - if USE_SINGLE_SIGN_ON is defined
// (and if single sign-on support dll's are present and enabled)
// This allows the embedding app to use the password save
// feature. When signing on to a host which needs authentication
// the Single sign-on service will check to see if the auth. info
// is already saved and if so uses it to pre-fill the sign-on form
// If not, our nsIPrompt impl will be called
// to present the auth UI and return the required auth info.
// If we do not compile with single sign-on support or if that
// service is missing we just fall back to the regular
// implementation of nsIPrompt
if(aIID.Equals(NS_GET_IID(nsIPrompt)))
{
if (!mPrompter)
{
#ifdef USE_SINGLE_SIGN_ON
nsresult rv;
nsCOMPtr<nsISingleSignOnPrompt> siPrompt = do_CreateInstance(NS_SINGLESIGNONPROMPT_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
{
siPrompt->SetPromptDialogs(NS_STATIC_CAST(nsIPrompt*, this));
mPrompter = siPrompt;
}
else
nsresult rv;
nsCOMPtr<nsISingleSignOnPrompt> siPrompt = do_CreateInstance(NS_SINGLESIGNONPROMPT_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
{
siPrompt->SetPromptDialogs(NS_STATIC_CAST(nsIPrompt*, this));
mPrompter = siPrompt;
}
else
#endif
mPrompter = NS_STATIC_CAST(nsIPrompt*, this);
}
NS_ENSURE_TRUE(mPrompter, NS_ERROR_FAILURE);
return mPrompter->QueryInterface(aIID, aInstancePtr);
}
else
return QueryInterface(aIID, aInstancePtr);
mPrompter = NS_STATIC_CAST(nsIPrompt*, this);
}
NS_ENSURE_TRUE(mPrompter, NS_ERROR_FAILURE);
return mPrompter->QueryInterface(aIID, aInstancePtr);
}
else
return QueryInterface(aIID, aInstancePtr);
}
//*****************************************************************************
@ -158,12 +158,12 @@ NS_IMETHODIMP CBrowserImpl::GetInterface(const nsIID &aIID, void** aInstancePtr)
//
NS_IMETHODIMP CBrowserImpl::SetStatus(PRUint32 aType, const PRUnichar* aStatus)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->UpdateStatusBarText(aStatus);
m_pBrowserFrameGlue->UpdateStatusBarText(aStatus);
return NS_OK;
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::GetWebBrowser(nsIWebBrowser** aWebBrowser)
@ -205,14 +205,14 @@ NS_IMETHODIMP CBrowserImpl::SetChromeFlags(PRUint32 aChromeMask)
//
NS_IMETHODIMP CBrowserImpl::CreateBrowserWindow(PRUint32 chromeMask, PRInt32 aX, P