Browse Source

Bug 966: kmeleon.display.maximized ignored at startup

Fix launching kmeleon a second time doesn't open a new window/tab
master
boisso 14 years ago
commit
cc620cfe72
  1. 13
      CVSROOT/checkoutlist
  2. 15
      CVSROOT/commitinfo
  3. 11
      CVSROOT/config
  4. 23
      CVSROOT/cvswrappers
  5. 21
      CVSROOT/editinfo
  6. 26
      CVSROOT/loginfo
  7. 26
      CVSROOT/modules
  8. 12
      CVSROOT/notify
  9. 13
      CVSROOT/rcsinfo
  10. 20
      CVSROOT/taginfo
  11. 21
      CVSROOT/verifymsg
  12. 80
      k-meleon/About.cpp
  13. 40
      k-meleon/About.h
  14. 484
      k-meleon/AccelParser.cpp
  15. 62
      k-meleon/AccelParser.h
  16. 956
      k-meleon/BrowserFrameGlue.cpp
  17. 1613
      k-meleon/BrowserFrm.cpp
  18. 358
      k-meleon/BrowserFrm.h
  19. 876
      k-meleon/BrowserFrmTab.cpp
  20. 173
      k-meleon/BrowserFrmTab.h
  21. 434
      k-meleon/BrowserGlue.cpp
  22. 847
      k-meleon/BrowserImpl.cpp
  23. 125
      k-meleon/BrowserImpl.h
  24. 88
      k-meleon/BrowserImplCtxMenuLstnr.cpp
  25. 189
      k-meleon/BrowserImplWebPrgrsLstnr.cpp
  26. 1022
      k-meleon/BrowserView.cpp
  27. 323
      k-meleon/BrowserView.h
  28. 220
      k-meleon/BrowserViewFind.cpp
  29. 216
      k-meleon/BrowserViewPanning.cpp
  30. 535
      k-meleon/BrowserViewUtils.cpp
  31. 1797
      k-meleon/BrowserWindow.cpp
  32. 327
      k-meleon/BrowserWindow.h
  33. 187
      k-meleon/CmdLine.cpp
  34. 12
      k-meleon/CmdLine.h
  35. 174
      k-meleon/Components.cpp
  36. 149
      k-meleon/CookiePromptService.cpp
  37. 81
      k-meleon/CookiePromptService.h
  38. 88
      k-meleon/Cookies.h
  39. 249
      k-meleon/CookiesViewerDlg.cpp
  40. 63
      k-meleon/CookiesViewerDlg.h
  41. 126
      k-meleon/DialogEx.h
  42. 186
      k-meleon/DialogUtils.cpp
  43. 39
      k-meleon/DialogUtils.h
  44. 526
      k-meleon/Dialogs.cpp
  45. 183
      k-meleon/Dialogs.h
  46. 835
      k-meleon/FavIconList.cpp
  47. 85
      k-meleon/FavIconList.h
  48. 212
      k-meleon/FontPackageHandler.cpp
  49. 88
      k-meleon/FontPackageHandler.h
  50. 112
      k-meleon/GenKeyPairDialogs.cpp
  51. 75
      k-meleon/GenKeyPairDialogs.h
  52. 443
      k-meleon/GenericDlg.cpp
  53. 140
      k-meleon/GenericDlg.h
  54. 347
      k-meleon/HiddenWnd.cpp
  55. 83
      k-meleon/HiddenWnd.h
  56. 192
      k-meleon/IBrowserFrameGlue.h
  57. 340
      k-meleon/Install/GNUlicense.txt
  58. BIN
      k-meleon/Install/K-Meleon.bmp
  59. 1
      k-meleon/Install/K-MeleonUNINST.ini
  60. 916
      k-meleon/Install/License.txt
  61. 981
      k-meleon/Install/SetDefault.nsi
  62. 50
      k-meleon/Install/english.nlf
  63. BIN
      k-meleon/Install/install.ico
  64. BIN
      k-meleon/Install/k-meleon.ico
  65. 728
      k-meleon/Install/k-meleon.nsi
  66. BIN
      k-meleon/Install/makensis.exe
  67. 118
      k-meleon/Install/readme.txt
  68. BIN
      k-meleon/Install/uninstall.ico
  69. 21
      k-meleon/JSBridge/JSBridge.sln
  70. 188
      k-meleon/JSBridge/JSBridge.vcproj
  71. 2
      k-meleon/JSBridge/genidl.cmd
  72. 71
      k-meleon/JSBridge/jscomp.cpp
  73. 21
      k-meleon/JSBridge/jscomp.h
  74. 107
      k-meleon/JSBridge/jsplugin.cpp
  75. 214
      k-meleon/JSBridge/nsGenericFactory.cpp
  76. 24
      k-meleon/JSBridge/nsIJSBridge.idl
  77. 540
      k-meleon/KMeleon.dsp
  78. 185
      k-meleon/KMeleon.dsw
  79. 293
      k-meleon/KMeleon.sln
  80. 1037
      k-meleon/KMeleon.vcproj
  81. 90
      k-meleon/KMeleonConst.h
  82. 375
      k-meleon/KmMenu.cpp
  83. 227
      k-meleon/KmMenu.h
  84. 192
      k-meleon/LangParser.cpp
  85. 57
      k-meleon/LangParser.h
  86. 400
      k-meleon/LocalesUtils.h
  87. 223
      k-meleon/Log.h
  88. 219
      k-meleon/MenuParser.cpp
  89. 45
      k-meleon/MenuParser.h
  90. 1636
      k-meleon/MfcEmbed.cpp
  91. 199
      k-meleon/MfcEmbed.h
  92. 1774
      k-meleon/MfcEmbed.rc
  93. 112
      k-meleon/MostRecentUrls.cpp
  94. 40
      k-meleon/MostRecentUrls.h
  95. 445
      k-meleon/MozUtils.cpp
  96. 35
      k-meleon/MozUtils.h
  97. 923
      k-meleon/NSSDialogs.cpp
  98. 296
      k-meleon/NSSDialogs.h
  99. 192
      k-meleon/Parser.cpp
  100. 21
      k-meleon/Parser.h

13
CVSROOT/checkoutlist

@ -0,0 +1,13 @@
# The "checkoutlist" file is used to support additional version controlled
# administrative files in $CVSROOT/CVSROOT, such as template files.
#
# The first entry on a line is a filename which will be checked out from
# the corresponding RCS file in the $CVSROOT/CVSROOT directory.
# The remainder of the line is an error message to use if the file cannot
# be checked out.
#
# File format:
#
# [<whitespace>]<filename><whitespace><error message><end-of-line>
#
# comment lines begin with '#'

15
CVSROOT/commitinfo

@ -0,0 +1,15 @@
# The "commitinfo" file is used to control pre-commit checks.
# The filter on the right is invoked with the repository and a list
# of files to check. A non-zero exit of the filter program will
# cause the commit to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT. For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

11
CVSROOT/config

@ -0,0 +1,11 @@
# Set this to "no" if pserver shouldn't check system users/passwords
#SystemAuth=no
# Set `PreservePermissions' to `yes' to save file status information
# in the repository.
#PreservePermissions=no
# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
# level of the new working directory when using the `cvs checkout'
# command.
#TopLevelAdmin=no

23
CVSROOT/cvswrappers

@ -0,0 +1,23 @@
# This file affects handling of files based on their names.
#
# The -t/-f options allow one to treat directories of files
# as a single file, or to transform a file in other ways on
# its way in and out of CVS.
#
# The -m option specifies whether CVS attempts to merge files.
#
# The -k option specifies keyword expansion (e.g. -kb for binary).
#
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
#
# wildcard [option value][option value]...
#
# where option is one of
# -f from cvs filter value: path to filter
# -t to cvs filter value: path to filter
# -m update methodology value: MERGE or COPY
# -k expansion mode value: b, o, kkv, &c
#
# and value is a single-quote delimited value.
# For example:
#*.gif -k 'b'

21
CVSROOT/editinfo

@ -0,0 +1,21 @@
# The "editinfo" file is used to allow verification of logging
# information. It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure. Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
# Making sure that the entered bug-id number is correct.
# Validating that the code that was reviewed is indeed the code being
# checked in (using the bug-id number or a seperate review
# number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported. There can be only one entry that matches a given
# repository.

26
CVSROOT/loginfo

@ -0,0 +1,26 @@
# The "loginfo" file controls where "cvs commit" log information
# is sent. The first entry on a line is a regular expression which must match
# the directory that the change is being made to, relative to the
# $CVSROOT. If a match is found, then the remainder of the line is a filter
# program that should expect log information on its standard input.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name ALL appears as a regular expression it is always used
# in addition to the first matching regex or DEFAULT.
#
# You may specify a format string as part of the
# filter. The string is composed of a `%' followed
# by a single format character, or followed by a set of format
# characters surrounded by `{' and `}' as separators. The format
# characters are:
#
# s = file name
# V = old version number (pre-checkin)
# v = new version number (post-checkin)
#
# For example:
#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
# or
#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog

26
CVSROOT/modules

@ -0,0 +1,26 @@
# Three different line formats are valid:
# key -a aliases...
# key [options] directory
# key [options] directory files...
#
# Where "options" are composed of:
# -i prog Run "prog" on "cvs commit" from top-level of module.
# -o prog Run "prog" on "cvs checkout" of module.
# -e prog Run "prog" on "cvs export" of module.
# -t prog Run "prog" on "cvs rtag" of module.
# -u prog Run "prog" on "cvs update" of module.
# -d dir Place module in directory "dir" instead of module name.
# -l Top-level directory only -- do not recurse.
#
# NOTE: If you change any of the "Run" options above, you'll have to
# release and re-checkout any working directories of these modules.
#
# And "directory" is a path to a directory relative to $CVSROOT.
#
# The "-a" option specifies an alias. An alias is interpreted as if
# everything on the right of the "-a" had been typed on the command line.
#
# You can encode a module within a module by using the special '&'
# character to interpose another module into the current module. This
# can be useful for creating a module that consists of many directories
# spread out over the entire source repository.

12
CVSROOT/notify

@ -0,0 +1,12 @@
# The "notify" file controls where notifications from watches set by
# "cvs watch add" or "cvs edit" are sent. The first entry on a line is
# a regular expression which is tested against the directory that the
# change is being made to, relative to the $CVSROOT. If it matches,
# then the remainder of the line is a filter program that should contain
# one occurrence of %s for the user to notify, and information on its
# standard input.
#
# "ALL" or "DEFAULT" can be used in place of the regular expression.
#
# For example:
#ALL mail %s -s "CVS notification"

13
CVSROOT/rcsinfo

@ -0,0 +1,13 @@
# The "rcsinfo" file is used to control templates with which the editor
# is invoked on commit and import.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being made to, relative to the
# $CVSROOT. For the first match that is found, then the remainder of the
# line is the name of the file that contains the template.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

20
CVSROOT/taginfo

@ -0,0 +1,20 @@
# The "taginfo" file is used to control pre-tag checks.
# The filter on the right is invoked with the following arguments:
#
# $1 -- tagname
# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
# $3 -- repository
# $4-> file revision [file revision ...]
#
# A non-zero exit of the filter program will cause the tag to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT. For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".

21
CVSROOT/verifymsg

@ -0,0 +1,21 @@
# The "verifymsg" file is used to allow verification of logging
# information. It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure. Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
# Making sure that the entered bug-id number is correct.
# Validating that the code that was reviewed is indeed the code being
# checked in (using the bug-id number or a seperate review
# number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported. There can be only one entry that matches a given
# repository.

80
k-meleon/About.cpp

@ -0,0 +1,80 @@
/*
* Copyright (C) 2001 Jeff Doozan
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "StdAfx.h"
#include "version.h"
#include "About.h"
#include "BrowserFrm.h"
#include "MfcEmbed.h"
extern CMfcEmbedApp theApp;
#define _QUOTE(blah) #blah
CAboutDlg::CAboutDlg(CWnd *wndParent) : CDialog(CAboutDlg::IDD, wndParent)
{
m_credits = _QUOTE(
\r\n
K-Meleon - Copyright 2000-2003\r\n
\r\n
Uses the Gecko rendering engine by the Mozilla Group\r\n
Based on MfcEmbed\r\n
\r\n
Core Developers:\r\n
Jeff Doozan <jeff@tcbmi.com>\r\n
Brian Harris <binaryc@teamreaction.com>\r\n
Mark Liffiton <liffiton@simons-rock.edu>\r\n
\r\n
Plugin Developers:\r\n
Ulf Erikson <ulferikson@fastmail.fm>\r\n
Rob Johnson <rob@rob-johnson.net>\r\n
\r\n
Project Documentation:\r\n
Andrew Mutch <amutch@tln.lib.mi.us>\r\n
\r\n
Past Contributors:\r\n
Sebastian Spaeth <Sebastian@SSpaeth.de>\r\n
Christophe Thibault <christophe@nullsoft.com>\r\n
Chak Nanga <chak@netscape.com>\r\n
);
m_version.Format("Version %s Build %d Compiled %s", VERSION, BUILD_NUMBER, BUILD_TIME);
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX){
DDX_Text(pDX, IDC_CREDITS, m_credits);
DDX_Text(pDX, IDC_VERSION, m_version);
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CMfcEmbedApp)
ON_COMMAND(IDC_KMELEON_HOME, OnHome)
ON_COMMAND(IDC_KMELEON_FORUM, OnForum)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CAboutDlg::OnHome() {
if (theApp.m_pMostRecentBrowserFrame)
theApp.m_pMostRecentBrowserFrame->PostMessage(WM_COMMAND, ID_LINK_KMELEON_HOME);
}
void CAboutDlg::OnForum() {
if (theApp.m_pMostRecentBrowserFrame)
theApp.m_pMostRecentBrowserFrame->PostMessage(WM_COMMAND, ID_LINK_KMELEON_FORUM);
}

40
k-meleon/About.h

@ -0,0 +1,40 @@
/*
* Copyright (C) 2001 Jeff Doozan
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "resource.h"
#include "BrowserView.h"
#include "DialogEx.h"
class CAboutDlg : public CDialog
{
public:
CAboutDlg(CWnd *wndParent);
enum { IDD = IDD_ABOUTBOX };
protected:
CString m_credits;
CString m_version;
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
afx_msg void OnHome();
afx_msg void OnForum();
DECLARE_MESSAGE_MAP()
};

484
k-meleon/AccelParser.cpp

@ -0,0 +1,484 @@
/*
* Copyright (C) 2000 Brian Harris
* Copyright (C) 2006 Dorian Boissonnade
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "StdAfx.h"
#include "MfcEmbed.h"
#include "AccelParser.h"
#include "Utils.h"
#include "resource.h"
#include "Plugins.h"
#define BEGIN_VK_TEST if (0){}
#define VK_TEST(KEY) else if (stricmp(p, #KEY) == 0){ key = VK_##KEY; }
// a few that winuser.h doesn't have for some reason (snagged from msdn)
#define VK_OEM_PLUS 0xBB
#define VK_OEM_COMMA 0xBC
#define VK_OEM_MINUS 0xBD
#define VK_OEM_PERIOD 0xBE
// and some more friendly definitions...
#define VK_PLUS VK_OEM_PLUS
#define VK_EQUALS VK_OEM_PLUS
#define VK_MINUS VK_OEM_MINUS
#define VK_COMMA VK_OEM_COMMA
#define VK_PERIOD VK_OEM_PERIOD
#define VK_PERIOD VK_OEM_PERIOD
#define VK_PAGE_UP VK_PRIOR
#define VK_PAGE_DOWN VK_NEXT
//Standard accel to show in menu
static const ACCEL stdAccels[] = {
{FCONTROL, 'C', ID_EDIT_COPY},
{FCONTROL, 'V', ID_EDIT_PASTE},
{FCONTROL, 'X', ID_EDIT_CUT},
{FVIRTKEY|FALT, VK_F4, ID_FILE_CLOSE}
};
extern BOOL ParsePluginCommand(char *pszCommand, char** plugin, char **parameter);
CAccelParser::CAccelParser()
{
accelTable = NULL;
numAccelerators = 0;
memset(accelerators, 0, sizeof(ACCEL) * MAX_ACCEL);
numMKeys = 0;
memset(mouse, 0, sizeof(ACCEL) * MAX_MOUSE);
}
CAccelParser::CAccelParser(LPCTSTR filename)
{
accelTable = NULL;
numAccelerators = 0;
memset(accelerators, 0, sizeof(ACCEL) * MAX_ACCEL);
Load(filename);
}
CAccelParser::~CAccelParser()
{
if (accelTable){
DestroyAcceleratorTable(accelTable);
}
}
int CAccelParser::Load(LPCTSTR filename)
{
SETUP_LOG("Accel");
if (accelTable){
DestroyAcceleratorTable(accelTable);
accelTable = NULL;
numAccelerators = 0;
}
int retVal = CParser::Load(filename);
END_LOG();
return retVal;
}
int CAccelParser::Parse(char *p)
{
// <modifiers> <key> = <command>
char *e = strchr(p, '=');
if (e){
*e = 0;
e++;
e = SkipWhiteSpace(e);
TrimWhiteSpace(e);
TrimWhiteSpace(p);
return SetAccel(p, e);
}
return 0;
}
int CAccelParser::SetAccel(const char* pKey, char* pCommand)
{
int command = 0;
const char *alt, *ctrl, *shift;
const char* p;
BYTE virt;
int key;
char *plugin, *parameter;
if (ParsePluginCommand(pCommand, &plugin, &parameter))
{
if (theApp.plugins.SendMessage(plugin, "* AccelParser", "DoAccel", (long)parameter, (long)&command)) {
LOG_2("Called plugin %s with parameter %s", plugin, parameter);
}
else {
LOG_ERROR_2( "Plugin %s has no accelerator %s", plugin, parameter);
return 0;
}
}
else {
command = theApp.GetID(pCommand);
if (!command)
command = atoi(pCommand);
}
virt = 0;
p = pKey;
alt = strstr(pKey, "ALT");
if (alt){
virt |= FALT;
p = alt + 3;
}
ctrl = strstr(pKey, "CTRL");
if (ctrl){
virt |= FCONTROL;
if (ctrl > alt){
p = ctrl + 4;
}
}
shift = strstr(pKey, "SHIFT");
if (shift){
virt |= FSHIFT;
if ((shift > alt) && (shift > ctrl)){
p = shift + 5;
}
}
// by now, p should be past the modifiers and point to " <key>"
p = SkipWhiteSpace((char*)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(PAGE_UP)
VK_TEST(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(PLUS)
VK_TEST(MINUS)
VK_TEST(COMMA)
VK_TEST(PERIOD)
VK_TEST(EQUALS)
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 if (stricmp(p, "LButton") == 0){
SetMAccel(command, virt, WM_LBUTTONDOWN);
return true;
}
else if (stricmp(p, "MButton") == 0){
SetMAccel(command, virt, WM_MBUTTONDOWN);
return true;
}
else if (stricmp(p, "RButton") == 0){
SetMAccel(command, virt, WM_RBUTTONDOWN);
return true;
}
else {
// regular key, convert it to virtual-key code to
// get the associated key on the keyboard.
key = VkKeyScanA(*p) & 0xff;
}
virt |= FVIRTKEY;
SetAccel(command, virt, key);
return true;
}
void CAccelParser::SetAccel(WORD command, BYTE virt, WORD key)
{
int oldAccel = FindAccel(virt, key);
if (command != 0 && oldAccel == -1) {
accelerators[numAccelerators].cmd = command;
accelerators[numAccelerators].fVirt = virt;
accelerators[numAccelerators].key = key;
numAccelerators++;
}
else {
if (command != 0)
accelerators[oldAccel].cmd = command;
else if (oldAccel>=0)
DeleteAccel(oldAccel);
}
if (accelTable) {
DestroyAcceleratorTable(accelTable);
accelTable = NULL;
}
}
void CAccelParser::SetMAccel(WORD command, BYTE virt, WORD button)
{
int oldAccel = FindMAccel(virt, button);
if (command == 0) {
if(oldAccel != -1)
DeleteMAccel(oldAccel);
return;
}
if (oldAccel != -1) {
mouse[oldAccel].cmd = command;
return;
}
mouse[numMKeys].cmd = command;
mouse[numMKeys].fVirt = virt;
mouse[numMKeys].key = button;
numMKeys++;
}
void CAccelParser::DeleteMAccel(int idx)
{
ASSERT(idx>=0&&idx<=MAX_MOUSE);
int i;
--numMKeys;
for (i=idx;i<numMKeys;i++)
mouse[i] = mouse[i+1];
}
void CAccelParser::DeleteAccel(int idx)
{
ASSERT(idx>=0&&idx<=MAX_ACCEL);
int i;
--numAccelerators;
for (i=idx;i<numAccelerators;i++)
accelerators[i] = accelerators[i+1];
}
int CAccelParser::FindMAccel(WORD virt, DWORD key)
{
const ACCEL* accel = NULL;
for (int i=0;i<numAccelerators;i++)
if (mouse[i].key == key && mouse[i].fVirt == virt)
return i;
return -1;
}
int CAccelParser::FindAccel(WORD virt, DWORD key)
{
const ACCEL* accel = NULL;
for (int i=0;i<numAccelerators;i++)
if (accelerators[i].key == key && accelerators[i].fVirt == virt)
return i;
return -1;
}
HACCEL CAccelParser::GetTable(){
if (!accelTable){
accelTable = CreateAcceleratorTable(accelerators, numAccelerators);
}
return accelTable;
}
CString CAccelParser::GetStrAccel(UINT id)
{
const ACCEL* accel = NULL;
for (int i=0;i<numAccelerators;i++) {
if (accelerators[i].cmd == id) {
accel = &accelerators[i];
break;
}
}
if (!accel) {
for (int i=0;i<sizeof(stdAccels)/sizeof(ACCEL);i++) {
if (stdAccels[i].cmd == id) {
accel = &stdAccels[i];
break;
}
}
}
if (accel) {
CString str;
TCHAR buf[25];
if(accel->fVirt & FCONTROL) {
GetKeyNameText(MapVirtualKey(VK_CONTROL, 0)<<16, buf, sizeof(buf));
if (*buf) {
CharLowerBuff(buf+1, _tcslen(buf)-1);
str = str + buf + _T("+");
}
}
if(accel->fVirt & FSHIFT) {
GetKeyNameText(MapVirtualKey(VK_SHIFT, 0)<<16, buf, sizeof(buf));
if (*buf) {
CharLowerBuff(buf+1, _tcslen(buf)-1);
str = str + buf + _T("+");
}
}
if(accel->fVirt & FALT) {
GetKeyNameText(MapVirtualKey(VK_MENU, 0)<<16, buf, sizeof(buf));
if (*buf) {
CharLowerBuff(buf+1, _tcslen(buf)-1);
str = str + buf + _T("+");
}
}
if(accel->fVirt & FVIRTKEY) {
WORD key = accel->key;
UINT scan = MapVirtualKey(key, 0);
if ((key >= VK_PRIOR) && (key<=VK_DELETE))
scan |= 0x100; // should remove the numpad text
if (GetKeyNameText(scan<<16 , buf, sizeof(buf)) == 0)
return _T("");
// Since I can't find a way to remove the numpad indication
// for /,* or . I'm removing it the hard way.
TCHAR* parenthesis = _tcschr(buf, '(');
if (parenthesis && parenthesis>buf)
*parenthesis = 0;
if (*buf) {
CharLowerBuff(buf+1, _tcslen(buf)-1);
str += buf;
}
}
else {
char c[2] = { accel->key & 0xff, '\0' };
USES_CONVERSION;
str += A2CT(c);
}
return str;
}
return _T("");
}
int CAccelParser::CheckMouse(UINT message){
int i, virt = 0;
virt = message >> 8;
switch (message & 0xff) {
case MK_LBUTTON: message = WM_LBUTTONDOWN; break;
case MK_RBUTTON: message = WM_RBUTTONDOWN; break;
case MK_MBUTTON: message = WM_MBUTTONDOWN; break;
default : ;
}
for (i=0; i<numMKeys; i++) {
if (mouse[i].key == message) {
if (mouse[i].fVirt == virt)
return mouse[i].cmd;
}
}
return 0;
}

62
k-meleon/AccelParser.h

@ -0,0 +1,62 @@
/*
* Copyright (C) 2000 Brian Harris
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __ACCELPARSER_H__
#define __ACCELPARSER_H__
#include "StdAfx.h"
#include "Parser.h"
#define MAX_ACCEL 127
#define MAX_MOUSE 12
class CAccelParser : public CParser {
protected:
ACCEL accelerators[MAX_ACCEL];
int numAccelerators;
ACCEL mouse[MAX_MOUSE];
int numMKeys;
HACCEL accelTable;
void DeleteAccel(int idx);
void DeleteMAccel(int idx);
int FindAccel(WORD virt, DWORD key);
int FindMAccel(WORD virt, DWORD key);
public:
CAccelParser();
CAccelParser(LPCTSTR filename);
~CAccelParser();
int Load(LPCTSTR filename);
int Parse(char *p);
int SetAccel(const char* key, char* command);
void SetAccel(WORD command, BYTE virt, WORD key);
void SetMAccel(WORD command, BYTE virt, WORD button);
HACCEL GetTable();
CString GetStrAccel(UINT id);
int CheckMouse(UINT message);
};
#endif // __ACCELPARSER_H__

956
k-meleon/BrowserFrameGlue.cpp

@ -0,0 +1,956 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: Mozilla-sample-code 1.0
*
* Copyright (c) 2002 Netscape Communications Corporation and
* other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this Mozilla sample software and associated documentation files
* (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*
* ***** END LICENSE BLOCK ***** */
// File Overview....
//
// This file has the IBrowserFrameGlueObj implementation
// This frame glue object is nested inside of the BrowserFrame
// object(See BrowserFrm.h for more info)
//
// This is the place where all the platform specific interaction
// with the browser frame window takes place in response to
// callbacks from Gecko interface methods
//
// The main purpose of this interface is to separate the cross
// platform code in BrowserImpl*.cpp from the platform specific
// code(which is in this file)
//
// You'll also notice the use of a macro named "METHOD_PROLOGUE"
// through out this file. This macro essentially makes the pointer
// to a "containing" class available inside of the class which is
// being contained via a var named "pThis". In our case, the
// BrowserFrameGlue object is contained inside of the BrowserFrame
// object so "pThis" will be a pointer to a BrowserFrame object
// Refer to MFC docs for more info on METHOD_PROLOGUE macro
#include "stdafx.h"
#include "MfcEmbed.h"
#include "BrowserFrm.h"
#include "Dialogs.h"
#include "MenuParser.h"
#include "KmeleonConst.h"
#include "nsIDOMHTMLAreaElement.h"
#include "nsIDOMHTMLInputElement.h"
extern CMfcEmbedApp theApp;
extern nsresult NewURI(nsIURI **result, const nsACString &spec);
/////////////////////////////////////////////////////////////////////////////
// IBrowserFrameGlue implementation
void CBrowserFrame::BrowserFrameGlueObj::UpdateStatusBarText(const PRUnichar *aMessage)
{
#ifndef _UNICODE
if (aMessage && (wcslen(aMessage) > 1024)) return;
#endif
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
CString str;
if (aMessage && wcslen(aMessage) > 0)
str = W2CT(aMessage);
else
str.LoadString(AFX_IDS_IDLEMESSAGE);
pThis->m_wndStatusBar.SetPaneText(0, str);
}
void CBrowserFrame::BrowserFrameGlueObj::UpdateProgress(PRInt32 aCurrent, PRInt32 aMax)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
pThis->m_wndProgressBar.SetRange32(0, aMax);
pThis->m_wndProgressBar.SetPos(aCurrent);
}
void CBrowserFrame::BrowserFrameGlueObj::UpdateBusyState(PRBool aBusy)
{
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
pThis->m_wndBrowserView.UpdateBusyState(aBusy);
//if (!aBusy)
pThis->PostMessage(UWM_UPDATEBUSYSTATE, aBusy == PR_TRUE ? 1 : 0, 0);
if (!aBusy) {
CString szUrl;
pThis->m_wndUrlBar.GetEnteredURL(szUrl);
if (_tcscmp(szUrl, _T("about:blank"))==0)
pThis->m_wndUrlBar.MaintainFocus();
// XXX We have to resize XUL dialog manually. They should have they own
// glue and window object!
if (pThis->m_bSizeOnLoad) {
nsCOMPtr<nsIDOMWindow> domWindow;
pThis->m_wndBrowserView.mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
if (domWindow)
domWindow->SizeToContent();
// It must be repositionned somewhat after the resize. Centering it
// all the time is not that bad.
//if (pThis->m_chromeMask & nsIWebBrowserChrome::CHROME_CENTER_SCREEN)
pThis->CenterWindow();
pThis->ShowWindow(SW_SHOW);
pThis->UpdateWindow();
pThis->m_bSizeOnLoad = FALSE;
}
}
else
pThis->m_wndBrowserView.mbDOMLoaded = FALSE;
pThis->m_wndBrowserView.m_lastMouseActionNode = nsnull;
}
// Called from the OnLocationChange() method in the nsIWebProgressListener
// interface implementation in CBrowserImpl to update the current URI
// Will get called after a URI is successfully loaded in the browser
// We use this info to update the URL bar's edit box
//
void CBrowserFrame::BrowserFrameGlueObj::UpdateCurrentURI(nsIURI *aLocation)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
if(aLocation)
{
USES_CONVERSION;
nsEmbedCString uriString;
aLocation->GetSpec(uriString);
nsEmbedString uriString2;
NS_CStringToUTF16(uriString, NS_CSTRING_ENCODING_UTF8, uriString2);
// Reset the popup notification and the icon uri
if (!(pThis->m_wndBrowserView.m_csHostPopupBlocked.IsEmpty())) {
pThis->m_wndStatusBar.RemoveIcon(ID_POPUP_BLOCKED_ICON);
pThis->m_wndBrowserView.m_csHostPopupBlocked.Empty();
}
#ifdef INTERNAL_SITEICONS
// Must be done here, before testing if we have the same address
// because xul error page have its own icon, and since the address
// doesn't change when retrying, the icon may stay in the urlbar.
pThis->m_wndBrowserView.m_IconUri = nsnull;
#endif
// Prevent to move the caret in the urlbar
CString currentURL;
pThis->m_wndUrlBar.GetEnteredURL(currentURL);
if (currentURL.Compare(W2CT(uriString2.get())) == 0)
return;
// XXX Since Mozilla 1.8.0.2 about:blank is always passed here
// before anything else, broking stuffs, so ignore it!
if ( stricmp (uriString.get(), "about:blank") == 0 &&
currentURL.GetLength())
return;
pThis->m_wndUrlBar.SetCurrentURL(W2CT(uriString2.get()));
// Add a MRU entry. Note that I'm only only allowing
// http or https uri
PRBool allowMRU,b;
aLocation->SchemeIs("http", &b);
allowMRU = b;
aLocation->SchemeIs("https", &b);
allowMRU |= b;
if ( allowMRU ) {
if (theApp.preferences.MRUbehavior == 0){
nsEmbedCString password;
aLocation->GetUsername(password);
aLocation->SetUserPass(password);
aLocation->GetSpec(uriString);
theApp.m_MRUList->AddURL(A2CT(uriString.get()));
}
else if (theApp.preferences.MRUbehavior == 1){
nsEmbedCString nsScheme, nsHost;
aLocation->GetScheme(nsScheme);
aLocation->GetHost(nsHost);
nsHost.Insert("://",0);
nsHost.Insert(nsScheme,0);
theApp.m_MRUList->AddURL(A2CT(nsHost.get()));
}
}
}
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameTitle(PRUnichar **aTitle)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
CString title;
pThis->GetWindowText(title);
/* TCHAR psz[256];
CString appTitle;
appTitle.LoadString(AFX_IDS_APP_TITLE);
theApp.preferences.GetString("kmeleon.display.title", psz, appTitle.GetBuffer(0));
appTitle = psz;
title.Replace(_T(" (") + appTitle + _T(')'), _T(""));
*/
if(!title.IsEmpty())
{
USES_CONVERSION;
nsEmbedString nsTitle;
nsTitle.Assign(T2CW(title));
*aTitle = NS_StringCloneData(nsTitle);
}
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFrameTitle(const PRUnichar *aTitle)
{
#ifndef _UNICODE
if (wcslen(aTitle) > 1024) return;
#endif
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
TCHAR psz[256];
CString appTitle;
appTitle.LoadString(AFX_IDS_APP_TITLE);
theApp.preferences.GetString("kmeleon.display.title", psz, appTitle.GetBuffer(0));
appTitle = psz;
CString title;
USES_CONVERSION;
title = W2CT(aTitle);
if (title.IsEmpty()){
pThis->m_wndUrlBar.GetEnteredURL(title);
}
if (!appTitle.IsEmpty())
title += _T(" (") + appTitle + _T(")");
pThis->SetWindowText(title);
pThis->PostMessage(UWM_UPDATESESSIONHISTORY, 0, 0);
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFrameSize(PRInt32 aCX, PRInt32 aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
if (pThis->m_ignoreMoveResize > 0) {
pThis->m_ignoreMoveResize--;
return;
}
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
pThis->GetWindowPlacement(&wp);
if (wp.showCmd != SW_SHOWNORMAL)
return;
pThis->SetWindowPos(NULL, 0, 0, aCX, aCY,
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER
);
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserSize(PRInt32 aCX, PRInt32 aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
if (pThis->m_ignoreMoveResize > 0) {
pThis->m_ignoreMoveResize--;
return;
}
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
pThis->GetWindowPlacement(&wp);
if (wp.showCmd != SW_SHOWNORMAL)
return;
// first we have to figure out how much bigger the frame is than the view
RECT frameRect, viewRect;
pThis->GetWindowRect(&frameRect);
pThis->m_wndBrowserView.GetClientRect(&viewRect);
int deltax = (frameRect.right - frameRect.left - viewRect.right);
int deltay = (frameRect.bottom - frameRect.top - viewRect.bottom);
pThis->SetWindowPos(NULL, 0, 0, aCX+deltax, aCY+deltay,
SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER
);
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameSize(PRInt32 *aCX, PRInt32 *aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
RECT wndRect;
pThis->GetWindowRect(&wndRect);
if (aCX)
*aCX = wndRect.right - wndRect.left;
if (aCY)
*aCY = wndRect.bottom - wndRect.top;
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserSize(PRInt32 *aCX, PRInt32 *aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
RECT wndRect;
pThis->m_wndBrowserView.GetClientRect(&wndRect);
if (aCX)
*aCX = wndRect.right - wndRect.left;
if (aCY)
*aCY = wndRect.bottom - wndRect.top;
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserFramePosition(PRInt32 aX, PRInt32 aY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
if (pThis->m_ignoreMoveResize > 0) {
pThis->m_ignoreMoveResize--;
return;
}
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
pThis->GetWindowPlacement(&wp);
if (wp.showCmd != SW_SHOWNORMAL)
return;
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)
RECT wndRect;
pThis->GetWindowRect(&wndRect);
if (aX)
*aX = wndRect.left;
if (aY)
*aY = wndRect.top;
}
void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFramePositionAndSize(PRInt32 *aX, PRInt32 *aY, PRInt32 *aCX, PRInt32 *aCY)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
RECT wndRect;
pThis->GetWindowRect(&wndRect);
if (aX)
*aX = wndRect.left;
if (aY)
*aY = wndRect.top;
if (aCX)
*aCX = wndRect.right - wndRect.left;
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)
if (pThis->m_ignoreMoveResize > 0) {
pThis->m_ignoreMoveResize--;
return;
}
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
pThis->GetWindowPlacement(&wp);
if (wp.showCmd != SW_SHOWNORMAL)
return;
pThis->SetWindowPos(NULL, aX, aY, aCX, aCY,
SWP_NOACTIVATE | SWP_NOZORDER);
}
void CBrowserFrame::BrowserFrameGlueObj::SetBrowserPositionAndSize(PRInt32 aX, PRInt32 aY, PRInt32 aCX, PRInt32 aCY, PRBool fRepaint)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
if (pThis->m_ignoreMoveResize > 0) {
pThis->m_ignoreMoveResize--;
return;
}
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
pThis->GetWindowPlacement(&wp);
if (wp.showCmd != SW_SHOWNORMAL)
return;
// first we have to figure out how much bigger the frame is than the view
RECT frameRect, viewRect;
pThis->GetWindowRect(&frameRect);
pThis->m_wndBrowserView.GetClientRect(&viewRect);
int deltax = (frameRect.right-frameRect.left)-(viewRect.right-viewRect.left);
int deltay = (frameRect.bottom-frameRect.top)-(viewRect.bottom-viewRect.top);
pThis->SetWindowPos(NULL, aX, aY, aCX+deltax, aCY+(deltay/2),
SWP_NOACTIVATE | SWP_NOZORDER);
}
void CBrowserFrame::BrowserFrameGlueObj::SetFocus(){
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
//if (!::IsChild(pThis->m_hWnd,::GetFocus()))
// pThis->BringWindowToTop();
pThis->m_wndBrowserView.mBaseWindow->SetFocus();
}
void CBrowserFrame::BrowserFrameGlueObj::FocusAvailable(PRBool *aFocusAvail)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
HWND focusWnd = ::GetFocus(); // GetFocus()->m_hWnd;
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)
{
if (pThis->m_bSizeOnLoad)
return; // Not yet, waiting for resize in UpdateBusyState
if (pThis->IsIconic())
return;
if (!pThis->IsWindowVisible()) {
if (pThis->m_created)
return;
pThis->m_created = true;
}
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?
CWnd *pWnd = GetActiveWindow();
if (!pWnd || pWnd->m_hWnd != pThis->m_hWnd)
{
*aVisible = PR_FALSE;
return;
}*/
*aVisible = pThis->IsIconic() || !pThis->IsWindowVisible() ? PR_FALSE : PR_TRUE;
}
PRBool CBrowserFrame::BrowserFrameGlueObj::CreateNewBrowserFrame(PRUint32 chromeMask,
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
//
CBrowserFrame* pFrm = pApp->CreateNewBrowserFrame(chromeMask, x, y, cx, cy, PR_FALSE);
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)
pThis->PostMessage(WM_CLOSE, -1, -1);
}
void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aInfo)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
int nodeHack = pThis->m_wndBrowserView.m_iGetNodeHack;
pThis->m_wndBrowserView.m_iGetNodeHack = 0;
// No context menu for chrome
if (pThis->m_chromeMask & nsIWebBrowserChrome::CHROME_OPENAS_CHROME)
return;
BOOL bContentHasFrames = FALSE;
UINT nIDResource = IDR_CTXMENU_DOCUMENT;
if (nodeHack == 0) {
if (GetKeyState(VK_SHIFT) < 0 ||
GetKeyState(VK_CONTROL) < 0 ||
GetKeyState(VK_MENU) < 0)
return;
}
// Reset the values from the last invocation
// Clear image src & link url
nsEmbedString empty;
pThis->m_wndBrowserView.SetCtxMenuImageSrc(empty);
pThis->m_wndBrowserView.SetCtxMenuLinkUrl(empty);
pThis->m_wndBrowserView.SetCurrentFrameURL(empty);
/*
!!BAD HACK!! !!BAD HACK!! !!BAD HACK!! !!BAD HACK!! !!BAD HACK!!
The bGetElementHack flag is part of the GetElementFromPoint function.
Basically, there's no easy way that I've found to get the link
information by point from mozilla, so as a workaround, the function
simply sends a contextmenu notifier with the point we want. It's
our job here to make sure the context menu doesn't get shown.
!!BAD HACK!! !!BAD HACK!! !!BAD HACK!! !!BAD HACK!! !!BAD HACK!!
*/
nsCOMPtr<nsIDOMNode> node;
nsresult rv = aInfo->GetTargetNode(getter_AddRefs(node));
if (NS_FAILED(rv)) return;
if (nodeHack == 1) {
pThis->m_wndBrowserView.m_pGetNode = node;
return;
}
nsCOMPtr<nsIURI> imgURI;
// Check if there is a image first
if(aContextFlags & nsIContextMenuListener2::CONTEXT_IMAGE)
{
nIDResource = IDR_CTXMENU_IMAGE;
// Get the IMG SRC
aInfo->GetImageSrc(getter_AddRefs(imgURI));
if(!imgURI)
return;
}
if(aContextFlags & nsIContextMenuListener2::CONTEXT_DOCUMENT)
{
nIDResource = IDR_CTXMENU_DOCUMENT;
}
else if(aContextFlags & nsIContextMenuListener2::CONTEXT_TEXT)
{
nIDResource = IDR_CTXMENU_TEXT;
}
else if (aContextFlags & nsIContextMenuListener2::CONTEXT_INPUT)
{
if (!(aContextFlags & nsIContextMenuListener2::CONTEXT_IMAGE)) {
// Mozilla don't tell if the input is of type text or password...
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(node));
if (inputElement) {
nsEmbedString inputElemType;
inputElement->GetType(inputElemType);
if ((wcsicmp(inputElemType.get(), L"text") == 0) ||
(wcsicmp(inputElemType.get(), L"password") == 0))
nIDResource = IDR_CTXMENU_TEXT;
}
}
}
else if(aContextFlags & nsIContextMenuListener2::CONTEXT_LINK)
{
nIDResource = IDR_CTXMENU_LINK;
// 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
nsEmbedString strUrlUcs2;
nsresult rv = aInfo->GetAssociatedLink(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);
}
// Check for a background image if the menu type is document
if ( (nIDResource == IDR_CTXMENU_DOCUMENT) && !imgURI &&
(aContextFlags & nsIContextMenuListener2::CONTEXT_BACKGROUND_IMAGE))
aInfo->GetBackgroundImageSrc(getter_AddRefs(imgURI));
if (imgURI) {
nsEmbedCString strImgSrcUtf8;
imgURI->GetSpec(strImgSrcUtf8);
if(!strImgSrcUtf8.IsEmpty()) {
// Set the new Img Src
nsEmbedString strImgSrc;
NS_CStringToUTF16(strImgSrcUtf8, NS_CSTRING_ENCODING_UTF8, strImgSrc);
pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrc);
nsCOMPtr<imgIContainer> img;
aInfo->GetImageContainer(getter_AddRefs(img));
//pThis->m_wndBrowserView.SetCtxImage(img);
}
}
// Determine if we need to add the Frame related context menu items
// such as "View Frame Source" etc.
// node is not set for xml documents, ... but we still
// want the context menu for them.
if (node)
{