Updated to 1.2b codebase, better tab key handling

kmeleon10_branch
doozan 20 years ago
parent 4dd3ac64a8
commit a95f824a6f
  1. 139
      k-meleon/BrowserFrameGlue.cpp
  2. 15
      k-meleon/BrowserFrm.cpp
  3. 19
      k-meleon/BrowserFrm.h
  4. 8
      k-meleon/BrowserImpl.cpp
  5. 4
      k-meleon/BrowserImpl.h
  6. 4
      k-meleon/BrowserImplCtxMenuLstnr.cpp
  7. 6
      k-meleon/BrowserView.cpp
  8. 2
      k-meleon/BrowserViewPanning.cpp
  9. 13
      k-meleon/IBrowserFrameGlue.h
  10. 4
      k-meleon/KMeleon.dsp
  11. 38
      k-meleon/KMeleon.dsw
  12. 2
      k-meleon/PromptService.cpp
  13. 7
      k-meleon/StdAfx.h
  14. 2
      k-meleon/Tooltips.h
  15. 2
      k-meleon/UnknownContentTypeHandler.h

@ -347,7 +347,7 @@ void CBrowserFrame::BrowserFrameGlueObj::DestroyBrowserFrame()
pThis->PostMessage(WM_CLOSE);
}
void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode)
void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aInfo)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
@ -375,9 +375,14 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags,
!!BAD HACK!! !!BAD HACK!! !!BAD HACK!! !!BAD HACK!! !!BAD HACK!!
*/
nsCOMPtr<nsIDOMNode> node;
aInfo->GetTargetNode(getter_AddRefs(node));
if (pThis->m_wndBrowserView.m_iGetNodeHack == 1) {
pThis->m_wndBrowserView.m_iGetNodeHack = 0;
pThis->m_wndBrowserView.m_pGetNode = aNode;
pThis->m_wndBrowserView.m_pGetNode = node;
return;
}
@ -388,9 +393,9 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags,
menuType = _T("DocumentPopup");
else if((aContextFlags & nsIContextMenuListener::CONTEXT_TEXT) || (aContextFlags & nsIContextMenuListener::CONTEXT_INPUT))
*/
if((aContextFlags & nsIContextMenuListener::CONTEXT_TEXT) || (aContextFlags & nsIContextMenuListener::CONTEXT_INPUT))
if((aContextFlags & nsIContextMenuListener2::CONTEXT_TEXT) || (aContextFlags & nsIContextMenuListener2::CONTEXT_INPUT))
menuType = _T("TextPopup");
else if(aContextFlags & nsIContextMenuListener::CONTEXT_LINK)
else if(aContextFlags & nsIContextMenuListener2::CONTEXT_LINK)
{
// Since we handle all the browser menu/toolbar commands
// in the View, we basically setup the Link's URL in the
@ -400,37 +405,11 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags,
// will be accesible in the view
// 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;
nsresult rv = aInfo->GetAssociatedLink(strUrlUcs2);
if (NS_FAILED(rv))
return;
nsCOMPtr<nsIDOMHTMLAreaElement> areaElement;
areaElement = do_QueryInterface(aNode);
if (areaElement) {
areaElement->GetHref(strUrlUcs2);
}
else {
// Search for an anchor element
nsCOMPtr<nsIDOMHTMLAnchorElement> linkElement;
nsCOMPtr<nsIDOMNode> node = aNode;
while (node) {
linkElement = do_QueryInterface(node);
if (linkElement)
break;
nsCOMPtr<nsIDOMNode> parentNode;
node->GetParentNode(getter_AddRefs(parentNode));
node = parentNode;
}
if (linkElement) {
rv = linkElement->GetHref(strUrlUcs2);
}
}
if (strUrlUcs2.Length()) {
if (strUrlUcs2.Length()) {
// Update the view with the new LinkUrl
// Note that this string is in UCS2 format
pThis->m_wndBrowserView.SetCtxMenuLinkUrl(strUrlUcs2);
@ -438,25 +417,55 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags,
menuType = _T("LinkPopup");
}
}
if(aContextFlags & nsIContextMenuListener::CONTEXT_IMAGE) {
if(aContextFlags & nsIContextMenuListener2::CONTEXT_IMAGE) {
// Get the IMG SRC
nsresult rv = NS_OK;
nsCOMPtr<nsIDOMHTMLImageElement> imgElement(do_QueryInterface(aNode, &rv));
if(NS_SUCCEEDED(rv)) {
rv = imgElement->GetSrc(strImgSrcUcs2);
if(NS_SUCCEEDED(rv)) {
pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrcUcs2); // Set the new Img Src
nsCOMPtr<nsIURI> imgURI;
aInfo->GetImageSrc(getter_AddRefs(imgURI));
if (!imgURI)
return;
nsCAutoString strImgSrcUtf8;
imgURI->GetSpec(strImgSrcUtf8);
if (strImgSrcUtf8.IsEmpty())
return;
strImgSrcUcs2 = NS_ConvertUTF8toUCS2(strImgSrcUtf8);
pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrcUcs2); // Set the new Img Src
if(aContextFlags & nsIContextMenuListener2::CONTEXT_LINK)
menuType = _T("ImageLinkPopup");
else
menuType = _T("ImagePopup");
if(aContextFlags & nsIContextMenuListener::CONTEXT_LINK)
menuType = _T("ImageLinkPopup");
else
menuType = _T("ImagePopup");
}
}
}
else if(aContextFlags & nsIContextMenuListener2::CONTEXT_BACKGROUND_IMAGE) {
nsAutoString strImgSrcUcs2;
pThis->m_wndBrowserView.SetCtxMenuImageSrc(strImgSrcUcs2); // Clear it
// Get the IMG SRC
nsCOMPtr<nsIURI> imgURI;
aInfo->GetBackgroundImageSrc(getter_AddRefs(imgURI));
if (!imgURI)
return;
nsCAutoString uri;
imgURI->GetSpec(uri);
pThis->m_wndBrowserView.SetCtxMenuImageSrc(NS_ConvertUTF8toUCS2(uri)); // Set the new Img Src
if(aContextFlags & nsIContextMenuListener2::CONTEXT_LINK)
menuType = _T("ImageLinkPopup");
else
menuType = _T("ImagePopup");
}
// Determine if we need to add the Frame related context menu items
// such as "View Frame Source" etc.
//
@ -465,8 +474,9 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags,
//Determine the current Frame URL
//
nsresult rv = NS_OK;
nsCOMPtr<nsIDOMDocument> domDoc;
rv = aNode->GetOwnerDocument(getter_AddRefs(domDoc));
rv = node->GetOwnerDocument(getter_AddRefs(domDoc));
if(NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(domDoc, &rv));
@ -474,15 +484,15 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags,
rv = htmlDoc->GetURL(strFrameURL);
if(NS_SUCCEEDED(rv)) {
pThis->m_wndBrowserView.SetCurrentFrameURL(strFrameURL); //Set it to the new URL
if(aContextFlags & nsIContextMenuListener::CONTEXT_LINK) {
if(aContextFlags & nsIContextMenuListener::CONTEXT_IMAGE)
if(aContextFlags & nsIContextMenuListener2::CONTEXT_LINK) {
if(aContextFlags & nsIContextMenuListener2::CONTEXT_IMAGE)
menuType = _T("FrameImageLinkPopup");
else
menuType = _T("FrameLinkPopup");
}
else {
if(aContextFlags & nsIContextMenuListener::CONTEXT_IMAGE)
if(aContextFlags & nsIContextMenuListener2::CONTEXT_IMAGE)
menuType = _T("FrameImagePopup");
else
menuType = _T("FrameDocumentPopup");
@ -496,7 +506,7 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags,
/* !!BAD HACK!! !!BAD HACK!! !!BAD HACK!! !!BAD HACK!! */
if (pThis->m_wndBrowserView.m_iGetNodeHack == 2) {
pThis->m_wndBrowserView.m_iGetNodeHack = 0;
pThis->m_wndBrowserView.m_pGetNode = aNode;
pThis->m_wndBrowserView.m_pGetNode = node;
return;
}
@ -545,7 +555,6 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowTooltip(PRInt32 x, PRInt32 y, const
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
if (!text) {
pThis->m_wndToolTip.Hide();
return;
@ -561,4 +570,24 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowTooltip(PRInt32 x, PRInt32 y, const
point.y += GetSystemMetrics(SM_CYCURSOR); // jump to below the cursor, otherwise we appear right on top of the cursor
pThis->m_wndToolTip.Show(text, point.x, point.y);
}
}
void CBrowserFrame::BrowserFrameGlueObj::FocusNextElement() {
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
nsCOMPtr<nsIWebBrowserFocus> focus(do_GetInterface(pThis->m_wndBrowserView.mWebBrowser));
if(focus) {
pThis->m_wndUrlBar.MaintainFocus();
::SetFocus(pThis->m_wndUrlBar.m_hwndEdit);
}
}
void CBrowserFrame::BrowserFrameGlueObj::FocusPrevElement() {
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
nsCOMPtr<nsIWebBrowserFocus> focus(do_GetInterface(pThis->m_wndBrowserView.mWebBrowser));
if(focus) {
pThis->m_wndUrlBar.MaintainFocus();
::SetFocus(pThis->m_wndUrlBar.m_hwndEdit);
}
}

@ -116,6 +116,21 @@ CBrowserFrame::~CBrowserFrame()
{
}
BOOL CBrowserFrame::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message==WM_KEYDOWN && pMsg->wParam == VK_TAB && pMsg->hwnd == m_wndUrlBar.m_hwndEdit) {
nsCOMPtr<nsIWebBrowserFocus> focus(do_GetInterface(m_wndBrowserView.mWebBrowser));
if(focus) {
focus->Activate();
focus->SetFocusAtFirstElement();
return 1;
}
}
return CFrameWnd::PreTranslateMessage(pMsg);
}
void CBrowserFrame::OnClose()
{

@ -48,6 +48,10 @@ extern CMfcEmbedApp theApp;
class CUrlBar : public CComboBoxEx {
public:
HWND m_hwndEdit;
int Create(DWORD style, RECT &rect, CWnd *parentWnd, UINT id) {
int ret = CComboBoxEx::Create(style | CBS_AUTOHSCROLL, rect, parentWnd, id);
@ -62,6 +66,10 @@ public:
m_changed = FALSE;
m_bSelected = FALSE;
m_iFocusCount = 0;
CEdit *edit = GetEditCtrl();
if (edit)
m_hwndEdit = edit->m_hWnd;
return ret;
}
@ -114,12 +122,9 @@ public:
if (m_changed)
GetEditCtrl()->SetSel(-1, 0);
// mozilla always tries to steal focus twice after
// the page has finished loading
if (!bDocumentLoading) {
if (++m_iFocusCount >= 2)
m_preserveUrlBarFocus = FALSE;
}
// mozilla always tries to steal focus twice
if (++m_iFocusCount >= 2)
m_preserveUrlBarFocus = FALSE;
}
void EndFocus() {
m_preserveUrlBarFocus = FALSE;
@ -131,6 +136,7 @@ public:
}
else m_changed = state;
}
protected:
CMostRecentUrls m_MRUList;
@ -279,6 +285,7 @@ public:
//{{AFX_VIRTUAL(CBrowserFrame)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
//}}AFX_VIRTUAL

@ -105,7 +105,7 @@ NS_INTERFACE_MAP_BEGIN(CBrowserImpl)
NS_INTERFACE_MAP_ENTRY(nsIWebBrowserChromeFocus)
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener)
NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener2)
NS_INTERFACE_MAP_ENTRY(nsITooltipListener)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_END
@ -313,12 +313,14 @@ CBrowserImpl::GetPersistence(PRBool* aPersistX, PRBool* aPersistY,
NS_IMETHODIMP CBrowserImpl::FocusNextElement()
{
return NS_ERROR_NOT_IMPLEMENTED;
m_pBrowserFrameGlue->FocusNextElement();
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::FocusPrevElement()
{
return NS_ERROR_NOT_IMPLEMENTED;
m_pBrowserFrameGlue->FocusPrevElement();
return NS_OK;
}
//*****************************************************************************

@ -31,7 +31,7 @@ class CBrowserImpl : public nsIInterfaceRequestor,
public nsIWebBrowserChromeFocus,
public nsIEmbeddingSiteWindow,
public nsIWebProgressListener,
public nsIContextMenuListener,
public nsIContextMenuListener2,
public nsITooltipListener,
public nsSupportsWeakReference
{
@ -47,7 +47,7 @@ public:
NS_DECL_NSIWEBBROWSERCHROMEFOCUS
NS_DECL_NSIEMBEDDINGSITEWINDOW
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSICONTEXTMENULISTENER
NS_DECL_NSICONTEXTMENULISTENER2
NS_DECL_NSITOOLTIPLISTENER
protected:

@ -34,10 +34,10 @@
// CBrowserImpl::nsIContextMenuListener
//*****************************************************************************
NS_IMETHODIMP CBrowserImpl::OnShowContextMenu(PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode)
NS_IMETHODIMP CBrowserImpl::OnShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aInfo)
{
if(m_pBrowserFrameGlue)
m_pBrowserFrameGlue->ShowContextMenu(aContextFlags, aNode);
m_pBrowserFrameGlue->ShowContextMenu(aContextFlags, aInfo);
return NS_OK;
}

@ -505,7 +505,11 @@ void CBrowserView::OnNewUrlEnteredInUrlBar()
{
mpBrowserFrame->m_wndUrlBar.EditChanged(FALSE);
SetFocus();
nsCOMPtr<nsIWebBrowserFocus> focus(do_GetInterface(mWebBrowser));
if(focus)
focus->Activate();
// Get the currently entered URL
CString strUrl;

@ -130,6 +130,6 @@ BOOL CBrowserView::PreTranslateMessage(MSG* pMsg)
if(m_panning && (pMsg->message==WM_LBUTTONDOWN || pMsg->message==WM_RBUTTONDOWN))
StopPanning();
return CWnd::PreTranslateMessage(pMsg);
}

@ -67,13 +67,17 @@ struct IBrowserFrameGlue {
virtual void GetBrowserFrameVisibility(PRBool *aVisible) = 0;
// ContextMenu Related Methods
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode) = 0;
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aInfo) = 0;
//Prompt Related Methods
virtual HWND GetBrowserFrameNativeWnd() = 0;
// Tooltip function
virtual void ShowTooltip(PRInt32 x, PRInt32 y, const char *text) = 0;
virtual void FocusNextElement() = 0;
virtual void FocusPrevElement() = 0;
};
#define NS_DECL_BROWSERFRAMEGLUE \
@ -99,9 +103,12 @@ struct IBrowserFrameGlue {
virtual void SetFocus(); \
virtual void FocusAvailable(PRBool *aFocusAvail); \
virtual void GetBrowserFrameVisibility(PRBool *aVisible); \
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode); \
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIContextMenuInfo *aInfo); \
virtual HWND GetBrowserFrameNativeWnd(); \
virtual void ShowTooltip(PRInt32 x, PRInt32 y, const char *text);
virtual void ShowTooltip(PRInt32 x, PRInt32 y, const char *text); \
virtual void FocusNextElement(); \
virtual void FocusPrevElement();
typedef IBrowserFrameGlue *PBROWSERFRAMEGLUE;

@ -8,12 +8,12 @@ CFG=kmeleon - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "kmeleon.mak".
!MESSAGE NMAKE /f "KMeleon.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "kmeleon.mak" CFG="kmeleon - Win32 Debug"
!MESSAGE NMAKE /f "KMeleon.mak" CFG="kmeleon - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE

@ -3,6 +3,18 @@ Microsoft Developer Studio Workspace File, Format Version 6.00
###############################################################################
Project: "Layers"=".\layers\Layers.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "bmp_menu"=".\bmp_menu\bmp_menu.dsp" - Package Owner=<4>
Package=<5>
@ -15,6 +27,18 @@ Package=<4>
###############################################################################
Project: "external"=".\External\external.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "fullscreen"=".\fullscreen\fullscreen.dsp" - Package Owner=<4>
Package=<5>
@ -51,7 +75,7 @@ Package=<4>
###############################################################################
Project: "kmeleon"=".\kmeleon.dsp" - Package Owner=<4>
Project: "kmeleon"=".\KMeleon.dsp" - Package Owner=<4>
Package=<5>
{{{
@ -111,6 +135,18 @@ Package=<4>
###############################################################################
Project: "op_hotlist"=".\op_hotlist\op_hotlist.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "rebar_menu"=".\rebar_menu\rebar_menu.dsp" - Package Owner=<4>
Package=<5>

@ -55,7 +55,7 @@ NS_IMPL_ISUPPORTS1(CPromptService, nsIPromptService)
CPromptService::CPromptService() :
mWWatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"))
{
NS_INIT_REFCNT();
NS_INIT_ISUPPORTS();
}
CPromptService::~CPromptService() {

@ -35,6 +35,10 @@
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#ifndef NEW_H
#define NEW_H <new>
#endif
//
// These headers are very evil, as they will define DEBUG if _DEBUG is
// defined, which is lame and not what we want for things like
@ -150,7 +154,7 @@
// webBrowser_core:
#include "nsITooltipTextProvider.h"
#include "nsIWebBrowser.h"
#include "nsIContextMenuListener.h"
#include "nsIContextMenuListener2.h"
#include "nsIWebBrowserPrint.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsIWebBrowserChrome.h"
@ -184,6 +188,7 @@
#include "nsIServiceManager.h"
#include "nsError.h"
#include "nsObserverService.h"
#include "imgIContainer.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsIObserver.h"
#include "nsCOMPtr.h"

@ -32,7 +32,7 @@ public:
// ctor/dtor
CTooltipTextProvider() {
NS_INIT_REFCNT();
NS_INIT_ISUPPORTS();
}
virtual ~CTooltipTextProvider() {
}

@ -13,7 +13,7 @@ public:
// ctor/dtor
CUnknownContentTypeHandler() {
NS_INIT_REFCNT();
NS_INIT_ISUPPORTS();
}
virtual ~CUnknownContentTypeHandler() {
}

Loading…
Cancel
Save